diy_scan.js
1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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,
});
}
})
}
}
})