Commit b1f0a54c46e030378eaa24a35878af67c7eff608
1 parent
1032406f
小程序合并
Showing
4 changed files
with
57 additions
and
0 deletions
components/diy_scan/diy_scan.js
0 → 100644
1 | +Component({ | |
2 | + properties: { | |
3 | + object: { | |
4 | + type: Object, | |
5 | + value: null | |
6 | + }, | |
7 | + // 这里定义了innerText属性,属性值可以在组件使用时指定 | |
8 | + }, | |
9 | + data: { | |
10 | + // 这里是一些组件内部数据 | |
11 | + someData: {}, | |
12 | + left:getApp().globalData.windowWidth-50, | |
13 | + top:200, | |
14 | + }, | |
15 | + methods: { | |
16 | + // 这里是一个自定义方法 | |
17 | + customMethod() { }, | |
18 | + //-- 如果触摸移动 -- | |
19 | + setTouchMove:function (e) { | |
20 | + var w=getApp().globalData.windowWidth; | |
21 | + if(e.touches[0].clientX<10 || e.touches[0].clientX>w-50) return false; | |
22 | + if(e.touches[0].clientY<10) return false; | |
23 | + this.setData({left: e.touches[0].clientX,top: e.touches[0].clientY}) | |
24 | + }, | |
25 | + | |
26 | + //-- 扫描成功之后 -- | |
27 | + getScancode:function(){ | |
28 | + var _this = this; | |
29 | + //-- 允许从相机和相册扫码 -- | |
30 | + wx.scanCode({ | |
31 | + success: (res) => { | |
32 | + var result = res.result; | |
33 | + wx.navigateTo({ | |
34 | + url: "/pages/goods/search/search?s_key=" + result, | |
35 | + }); | |
36 | + } | |
37 | + }) | |
38 | + } | |
39 | + } | |
40 | +}) | |
0 | 41 | \ No newline at end of file | ... | ... |
components/diy_scan/diy_scan.json
0 → 100644
components/diy_scan/diy_scan.wxml
0 → 100644
1 | +<view class="scan_view" disable-scroll="true" bindtap='getScancode' style="top:{{top}}px;left:{{left}}px;" bindtouchmove="setTouchMove"> | |
2 | + <view style="text-align: center;"> | |
3 | + <image class="cs-img" src="{{object.img}}"></image> | |
4 | + <view class="s_title" wx:if="{{object.title!=''}}">{{object.title}}</view> | |
5 | + </view> | |
6 | +</view> | |
7 | + | ... | ... |
components/diy_scan/diy_scan.wxss
0 → 100644
1 | +.scan_view{ | |
2 | + position: fixed;z-index: 100; left: 0; top: 0; width: 100rpx; height: 100rpx; | |
3 | + border-radius: 50%; background-color: rgba(125,125,2,0.5);box-shadow: #ccc 0px 0px 70px 1px; | |
4 | + display: flex;align-items: center;justify-content: center; color: #f8f8f8; | |
5 | +} | |
6 | +.cs-img{ width: 32rpx; height: 32rpx; } | |
7 | +.s_title{ font-size: 20rpx;} | |
0 | 8 | \ No newline at end of file | ... | ... |