diy_scan.js 1.08 KB
Component({
  properties: {
    object: {
      type: Object,
      value: null
    },
    // 这里定义了innerText属性,属性值可以在组件使用时指定
  },
  data: {
    // 这里是一些组件内部数据
    someData: {},
	left:getApp().globalData.windowWidth-50,
	top:200,
  },
  methods: {
       // 这里是一个自定义方法
       customMethod() { },
       //-- 如果触摸移动 --
	   setTouchMove:function (e) {		
		  var w=getApp().globalData.windowWidth;	  		   
          if(e.touches[0].clientX<10 || e.touches[0].clientX>w-50) return false;
          if(e.touches[0].clientY<10) return false;
		  this.setData({left: e.touches[0].clientX,top: e.touches[0].clientY})			   
	   },	
	   
	   //-- 扫描成功之后 --
	   getScancode:function(){
		   var _this = this;
           getApp().globalData.no_clear=1;
		   //-- 允许从相机和相册扫码 --
		   wx.scanCode({
		     success: (res) => {
		       var result = res.result;
		       wx.navigateTo({
		         url: "/packageG/pages/goods/search/search?s_key=" + result,
		       });
		     }
		   })
	   }
  }
})