1.加扫码功能 2.修复bug
Showing
13 changed files
with
169 additions
and
63 deletions
... | @@ -10,6 +10,6 @@ | ... | @@ -10,6 +10,6 @@ |
10 | <view wx:if="{{item.commodityType == 'packet'}}" class="tips"> | 10 | <view wx:if="{{item.commodityType == 'packet'}}" class="tips"> |
11 | 后台审核通过后,红包将会通过公众号消息或微信服务消息发送,届时请及时领取! | 11 | 后台审核通过后,红包将会通过公众号消息或微信服务消息发送,届时请及时领取! |
12 | </view> | 12 | </view> |
13 | <view wx:else class="tips">您可以在“个人中心→我的订单”中查看物流进度</view> | 13 | <view wx:else class="tips">您可以在“礼物兑换→我的订单”中查看物流进度</view> |
14 | </view> | 14 | </view> |
15 | </view> | 15 | </view> | ... | ... |
... | @@ -8,20 +8,20 @@ | ... | @@ -8,20 +8,20 @@ |
8 | .cont { | 8 | .cont { |
9 | background: #FFFFFF; | 9 | background: #FFFFFF; |
10 | @extend .shadow; | 10 | @extend .shadow; |
11 | width: 670px; | 11 | width: 640px; |
12 | margin: 0 auto; | 12 | margin: 0 auto; |
13 | min-height: 900px; | 13 | min-height: 900px; |
14 | @extend .bb; | 14 | @extend .bb; |
15 | padding: 20px 30px 20px; | 15 | padding: 20px 30px 20px; |
16 | 16 | ||
17 | .tit { | 17 | .tit { |
18 | font-size: 40px; | 18 | font-size: 36px; |
19 | text-align: center; | 19 | text-align: center; |
20 | } | 20 | } |
21 | 21 | ||
22 | .img-wrap { | 22 | .img-wrap { |
23 | $imgWidth: 610px; | 23 | $imgWidth: 580px; |
24 | $imgHeight: 480px; | 24 | $imgHeight: 580px; |
25 | margin: 20px 0; | 25 | margin: 20px 0; |
26 | width: $imgWidth; | 26 | width: $imgWidth; |
27 | height: $imgHeight; | 27 | height: $imgHeight; |
... | @@ -42,16 +42,15 @@ | ... | @@ -42,16 +42,15 @@ |
42 | .desc { | 42 | .desc { |
43 | color: #333333; | 43 | color: #333333; |
44 | font-size: 28px; | 44 | font-size: 28px; |
45 | height: 320px; | 45 | height: 230px; |
46 | line-height: 48px; | 46 | line-height: 48px; |
47 | } | 47 | } |
48 | |||
49 | } | 48 | } |
50 | 49 | ||
51 | .close { | 50 | .close { |
52 | width: 82px; | 51 | width: 82px; |
53 | height: 112px; | 52 | height: 112px; |
54 | margin: 0 auto 40px; | 53 | margin: 0 auto 24px; |
55 | 54 | ||
56 | .btn { | 55 | .btn { |
57 | width: 82px; | 56 | width: 82px; | ... | ... |
... | @@ -11,6 +11,7 @@ function wxLogin() { | ... | @@ -11,6 +11,7 @@ function wxLogin() { |
11 | success: function (res) { | 11 | success: function (res) { |
12 | // isWxLogin = true; | 12 | // isWxLogin = true; |
13 | Store.setItem('wxcode', res.code); | 13 | Store.setItem('wxcode', res.code); |
14 | console.log("wxLogin code:", res.code); | ||
14 | resolve(); | 15 | resolve(); |
15 | } | 16 | } |
16 | }); | 17 | }); |
... | @@ -68,6 +69,7 @@ function login() { | ... | @@ -68,6 +69,7 @@ function login() { |
68 | wx.login({ | 69 | wx.login({ |
69 | success: function (res) { | 70 | success: function (res) { |
70 | Store.setItem('wxcode', res.code); | 71 | Store.setItem('wxcode', res.code); |
72 | console.log("auth code:", res.code); | ||
71 | view.showAuth(); | 73 | view.showAuth(); |
72 | } | 74 | } |
73 | }); | 75 | }); | ... | ... |
... | @@ -16,11 +16,11 @@ Page({ | ... | @@ -16,11 +16,11 @@ Page({ |
16 | onReady() { | 16 | onReady() { |
17 | // app.store.clear("sessionId"); | 17 | // app.store.clear("sessionId"); |
18 | let _this = this; | 18 | let _this = this; |
19 | wx.login({ | 19 | // wx.login({ |
20 | success: function (res) { | 20 | // success: function (res) { |
21 | _this.data.loginData = res; | 21 | // _this.data.loginData = res; |
22 | } | 22 | // } |
23 | }); | 23 | // }); |
24 | }, | 24 | }, |
25 | bindGetUserInfo(e) { | 25 | bindGetUserInfo(e) { |
26 | wx.showLoading(); | 26 | wx.showLoading(); | ... | ... |
... | @@ -119,7 +119,7 @@ Page({ | ... | @@ -119,7 +119,7 @@ Page({ |
119 | 119 | ||
120 | wx.showModal({ | 120 | wx.showModal({ |
121 | title: '兑换确认', | 121 | title: '兑换确认', |
122 | content: `将花费${item.commodityPrice}兑换${item.commodityTitle}一份`, | 122 | content: `将花费${item.commodityPrice}积分兑换${item.commodityTitle}一份`, |
123 | success(res) { | 123 | success(res) { |
124 | if (res.confirm) { | 124 | if (res.confirm) { |
125 | app.post({ | 125 | app.post({ | ... | ... |
... | @@ -42,7 +42,7 @@ | ... | @@ -42,7 +42,7 @@ |
42 | <view class="label">收货地址</view> | 42 | <view class="label">收货地址</view> |
43 | <view class="cont">{{defaultReceiver.receiverAddress}}</view> | 43 | <view class="cont">{{defaultReceiver.receiverAddress}}</view> |
44 | </view> | 44 | </view> |
45 | <textarea value="{{remark}}" bindinput="bindRemarkInput" placeholder="备注您的其他要求" class="form-remark"></textarea> | 45 | <textarea wx:if="{{!orderSubmitSuccessCompVisible && !commonTipsCompVisible}}" value="{{remark}}" bindinput="bindRemarkInput" placeholder="备注您的其他要求" class="form-remark"></textarea> |
46 | </view> | 46 | </view> |
47 | <!-- 添加地址按钮 --> | 47 | <!-- 添加地址按钮 --> |
48 | <view wx:else bindtap="onAddressAddHandler" class="manage-add">我的收货地址</view> | 48 | <view wx:else bindtap="onAddressAddHandler" class="manage-add">我的收货地址</view> | ... | ... |
1 | import { | 1 | import { |
2 | getBindtapData | 2 | getBindtapData, |
3 | getQueryByUrl | ||
3 | } from '../../utils/util'; | 4 | } from '../../utils/util'; |
4 | 5 | ||
5 | let app = getApp(); | 6 | let app = getApp(); |
... | @@ -15,7 +16,9 @@ Page({ | ... | @@ -15,7 +16,9 @@ Page({ |
15 | curProductDetail: {}, // 选中的产品详情 | 16 | curProductDetail: {}, // 选中的产品详情 |
16 | qrCodeCode: "", | 17 | qrCodeCode: "", |
17 | userInfo: {}, //用户信息 | 18 | userInfo: {}, //用户信息 |
18 | code: "", // 手输入码 | 19 | code: "", // 手输入码 / 扫出的积分码 |
20 | memberCode: "", // 扫出的用户码 | ||
21 | // integralCode: "", // 扫出的积分码 | ||
19 | }, | 22 | }, |
20 | onShareAppMessage() {}, | 23 | onShareAppMessage() {}, |
21 | showAuth() { | 24 | showAuth() { |
... | @@ -24,30 +27,48 @@ Page({ | ... | @@ -24,30 +27,48 @@ Page({ |
24 | }) | 27 | }) |
25 | }, | 28 | }, |
26 | onLoad(options) { | 29 | onLoad(options) { |
30 | let q = decodeURIComponent(options.q); | ||
31 | if (q) { | ||
32 | // 获取会员码 | ||
33 | let m = getQueryByUrl("m", q); | ||
34 | if (m) { | ||
35 | this.setData({ | ||
36 | memberCode: m | ||
37 | }) | ||
38 | } | ||
27 | 39 | ||
28 | this.queryProduct(); | 40 | // 获取积分码 |
29 | this.queryBanner(); | 41 | let c = getQueryByUrl("c", q); |
30 | 42 | if (c) { | |
31 | let scene = decodeURIComponent(options.scene) || ""; | ||
32 | // scene = "ab4cbd54dcf04d29a6c23d00a900b332" | ||
33 | if (scene) { | ||
34 | this.setData({ | 43 | this.setData({ |
35 | scene | 44 | code: c |
36 | }) | 45 | }) |
37 | } | 46 | } |
47 | } | ||
48 | this.queryProduct(); | ||
49 | this.queryBanner(); | ||
50 | |||
38 | this.initData(); | 51 | this.initData(); |
39 | }, | 52 | }, |
40 | 53 | ||
54 | onShow() { | ||
55 | console.log("onShow memberCode:", this.data.memberCode); | ||
56 | console.log("onShow code:", this.data.code); | ||
57 | }, | ||
58 | |||
41 | initData() { | 59 | initData() { |
42 | let { | 60 | let { |
43 | scene | 61 | memberCode, |
62 | code | ||
44 | } = this.data; | 63 | } = this.data; |
45 | if (scene) { | 64 | // 如果存在扫码参数,则需要拉用户身份(未授权的情况下 要拉授权) |
46 | // 可能要拉授权 | ||
47 | this.queryMember().then((result) => { | 65 | this.queryMember().then((result) => { |
48 | this.queryScanPersonQrcode().then((result) => {}).catch((err) => {}); | 66 | this.queryScanPersonQrcode().then((result2) => { |
49 | }); | 67 | if (code) { |
68 | this.onSearchHandler(); | ||
50 | } | 69 | } |
70 | }); | ||
71 | }); | ||
51 | }, | 72 | }, |
52 | 73 | ||
53 | 74 | ||
... | @@ -127,24 +148,25 @@ Page({ | ... | @@ -127,24 +148,25 @@ Page({ |
127 | 148 | ||
128 | /** | 149 | /** |
129 | * 扫个人码 | 150 | * 扫个人码 |
151 | * 如果没有码,直接返回 | ||
130 | */ | 152 | */ |
131 | queryScanPersonQrcode() { | 153 | queryScanPersonQrcode() { |
132 | return new Promise((resolve, reject) => { | 154 | return new Promise((resolve, reject) => { |
133 | let { | 155 | let { |
134 | scene | 156 | memberCode |
135 | } = this.data; | 157 | } = this.data; |
136 | if (scene) { | 158 | if (memberCode) { |
137 | app.post({ | 159 | app.post({ |
138 | toast: false, | 160 | toast: false, |
139 | url: app.api.scanPersonQrcode, | 161 | url: app.api.scanPersonQrcode, |
140 | data: { | 162 | data: { |
141 | memberCode: scene | 163 | memberCode: memberCode |
142 | } | 164 | } |
143 | }).then((result) => { | 165 | }).then((result) => { |
144 | this.setData({ | 166 | resolve(); |
145 | prizeInfo: result | ||
146 | }) | ||
147 | }) | 167 | }) |
168 | } else { | ||
169 | resolve(); | ||
148 | } | 170 | } |
149 | }); | 171 | }); |
150 | }, | 172 | }, |
... | @@ -159,19 +181,45 @@ Page({ | ... | @@ -159,19 +181,45 @@ Page({ |
159 | productDetailVisible: true | 181 | productDetailVisible: true |
160 | }) | 182 | }) |
161 | }, | 183 | }, |
184 | |||
162 | /** | 185 | /** |
163 | * 点击扫码按钮 | 186 | * 点击扫码按钮 |
164 | */ | 187 | */ |
165 | onScanHandler() { | 188 | onScanHandler() { |
189 | let _this = this; | ||
166 | wx.scanCode({ | 190 | wx.scanCode({ |
167 | onlyFromCamera: true, | 191 | onlyFromCamera: true, |
168 | success(res) { | 192 | success(res) { |
169 | // 扫码结果 | 193 | // 扫码结果 |
170 | let result = res.result; | 194 | let q = res.result; |
171 | let { | 195 | console.log("q:", q) |
172 | qrCodeCode, | 196 | |
173 | memberCode | 197 | // 获取会员码 |
174 | } = result; | 198 | let m = getQueryByUrl("m", q); |
199 | console.log("m:", m) | ||
200 | if (m) { | ||
201 | _this.setData({ | ||
202 | memberCode: m | ||
203 | }) | ||
204 | _this.queryScanPersonQrcode(); | ||
205 | } | ||
206 | |||
207 | // 获取积分码 | ||
208 | let c = getQueryByUrl("c", q); | ||
209 | if (c) { | ||
210 | app.router.push({ | ||
211 | path: "scanResult", | ||
212 | query: { | ||
213 | code: c | ||
214 | } | ||
215 | }) | ||
216 | } else { | ||
217 | wx.showModal({ | ||
218 | content: '未发现积分码,换一个二维码试试', | ||
219 | showCancel: false, | ||
220 | success(res) {} | ||
221 | }) | ||
222 | } | ||
175 | }, | 223 | }, |
176 | fail(err) { | 224 | fail(err) { |
177 | console.log("err:", err); | 225 | console.log("err:", err); |
... | @@ -183,10 +231,22 @@ Page({ | ... | @@ -183,10 +231,22 @@ Page({ |
183 | * 点击搜索 | 231 | * 点击搜索 |
184 | */ | 232 | */ |
185 | onSearchHandler() { | 233 | onSearchHandler() { |
234 | let code = this.data.code; | ||
235 | this.setData({ | ||
236 | code: "" | ||
237 | }) | ||
238 | if (code.length != 16) { | ||
239 | wx.showModal({ | ||
240 | content: '请输入16位积分码', | ||
241 | showCancel: false, | ||
242 | success(res) {} | ||
243 | }) | ||
244 | return; | ||
245 | } | ||
186 | app.router.push({ | 246 | app.router.push({ |
187 | path: "scanResult", | 247 | path: "scanResult", |
188 | query: { | 248 | query: { |
189 | code: this.data.code | 249 | code: code |
190 | } | 250 | } |
191 | }) | 251 | }) |
192 | }, | 252 | }, | ... | ... |
... | @@ -14,10 +14,10 @@ | ... | @@ -14,10 +14,10 @@ |
14 | <image class="icon" mode="aspectFit" src="../../image/icon/icon-search.png" /> | 14 | <image class="icon" mode="aspectFit" src="../../image/icon/icon-search.png" /> |
15 | </view> | 15 | </view> |
16 | <!-- 隐藏扫描二维码 --> | 16 | <!-- 隐藏扫描二维码 --> |
17 | <!-- <view class="search-line"></view> | 17 | <view class="search-line"></view> |
18 | <view bindtap="onScanHandler" class="search-scan"> | 18 | <view bindtap="onScanHandler" class="search-scan"> |
19 | <image class="icon" mode="aspectFit" src="../../image/icon/icon-scan.png" /> | 19 | <image class="icon" mode="aspectFit" src="../../image/icon/icon-scan.png" /> |
20 | </view> --> | 20 | </view> |
21 | </view> | 21 | </view> |
22 | </view> | 22 | </view> |
23 | <view class="top-space"></view> | 23 | <view class="top-space"></view> | ... | ... |
... | @@ -21,6 +21,9 @@ Page({ | ... | @@ -21,6 +21,9 @@ Page({ |
21 | initData() { | 21 | initData() { |
22 | // 获取用户信息 小程序码 | 22 | // 获取用户信息 小程序码 |
23 | this.queryMember().then((result) => { | 23 | this.queryMember().then((result) => { |
24 | wx.showLoading({ | ||
25 | title: '二维码生成中···', | ||
26 | }); | ||
24 | // 获取海报数据 | 27 | // 获取海报数据 |
25 | let posterData = this.getPosterConfig(); | 28 | let posterData = this.getPosterConfig(); |
26 | // 绘制设置海报 | 29 | // 绘制设置海报 | ... | ... |
1 | import { | ||
2 | getBindtapData, | ||
3 | getQueryByUrl | ||
4 | } from '../../utils/util'; | ||
5 | |||
1 | let app = getApp(); | 6 | let app = getApp(); |
2 | Page({ | 7 | Page({ |
3 | data: { | 8 | data: { |
... | @@ -14,21 +19,11 @@ Page({ | ... | @@ -14,21 +19,11 @@ Page({ |
14 | }, | 19 | }, |
15 | onLoad(options) { | 20 | onLoad(options) { |
16 | 21 | ||
17 | // 扫小程序码进入 | ||
18 | let scene = decodeURIComponent(options.scene) || ""; | ||
19 | // scene = "02llmPvYl1CFN2bc" | ||
20 | if (scene) { | ||
21 | this.setData({ | ||
22 | scene | ||
23 | }) | ||
24 | } | ||
25 | |||
26 | // 手输码 | 22 | // 手输码 |
27 | let code = options.code || ""; | 23 | let code = options.code || ""; |
28 | console.log("code:", code); | ||
29 | if (code) { | 24 | if (code) { |
30 | this.setData({ | 25 | this.setData({ |
31 | scene: code | 26 | code: code |
32 | }) | 27 | }) |
33 | } | 28 | } |
34 | 29 | ||
... | @@ -65,13 +60,13 @@ Page({ | ... | @@ -65,13 +60,13 @@ Page({ |
65 | queryScanIntegralQrcode() { | 60 | queryScanIntegralQrcode() { |
66 | return new Promise((resolve, reject) => { | 61 | return new Promise((resolve, reject) => { |
67 | let { | 62 | let { |
68 | scene | 63 | code |
69 | } = this.data; | 64 | } = this.data; |
70 | if (scene) { | 65 | if (code) { |
71 | app.post({ | 66 | app.post({ |
72 | url: app.api.scanIntegralQrcode, | 67 | url: app.api.scanIntegralQrcode, |
73 | data: { | 68 | data: { |
74 | qrCodeCode: scene | 69 | qrCodeCode: code |
75 | } | 70 | } |
76 | }).then((result) => { | 71 | }).then((result) => { |
77 | this.setData({ | 72 | this.setData({ |
... | @@ -101,6 +96,42 @@ Page({ | ... | @@ -101,6 +96,42 @@ Page({ |
101 | }); | 96 | }); |
102 | }, | 97 | }, |
103 | 98 | ||
99 | |||
100 | /** | ||
101 | * 点击扫码按钮 | ||
102 | */ | ||
103 | onScanHandler() { | ||
104 | let _this = this; | ||
105 | wx.scanCode({ | ||
106 | onlyFromCamera: true, | ||
107 | success(res) { | ||
108 | // 扫码结果 | ||
109 | let q = res.result; | ||
110 | |||
111 | // 获取积分码 | ||
112 | let c = getQueryByUrl("c", q); | ||
113 | if (c) { | ||
114 | // app.router.push({ | ||
115 | // path: "scanResult", | ||
116 | // query: { | ||
117 | // code: c | ||
118 | // } | ||
119 | // }) | ||
120 | _this.queryScanIntegralQrcode(); | ||
121 | } else { | ||
122 | wx.showModal({ | ||
123 | content: '未发现积分码,换一个二维码试试', | ||
124 | showCancel: false, | ||
125 | success(res) {} | ||
126 | }) | ||
127 | } | ||
128 | }, | ||
129 | fail(err) { | ||
130 | console.log("err:", err); | ||
131 | } | ||
132 | }) | ||
133 | }, | ||
134 | |||
104 | /** | 135 | /** |
105 | * 查看我的积分 | 136 | * 查看我的积分 |
106 | */ | 137 | */ | ... | ... |
... | @@ -13,7 +13,7 @@ | ... | @@ -13,7 +13,7 @@ |
13 | 积分 | 13 | 积分 |
14 | </view> | 14 | </view> |
15 | <view class="btn-wrap"> | 15 | <view class="btn-wrap"> |
16 | <!-- <view class="btn">再扫一次</view> --> | 16 | <view bindtap="onScanHandler" class="btn">再扫一次</view> |
17 | <view bindtap="onMyIntegralHandler" class="btn btn2">查看我的积分</view> | 17 | <view bindtap="onMyIntegralHandler" class="btn btn2">查看我的积分</view> |
18 | </view> | 18 | </view> |
19 | </view> | 19 | </view> |
... | @@ -25,7 +25,7 @@ | ... | @@ -25,7 +25,7 @@ |
25 | <!-- 其他异常 --> | 25 | <!-- 其他异常 --> |
26 | <text wx:else class="tips tips1">此产品码已被扫过!\n若有异常,请联系客服</text> | 26 | <text wx:else class="tips tips1">此产品码已被扫过!\n若有异常,请联系客服</text> |
27 | <view class="btn-wrap"> | 27 | <view class="btn-wrap"> |
28 | <!-- <view class="btn">再扫一次</view> --> | 28 | <view bindtap="onScanHandler" class="btn">再扫一次</view> |
29 | <view bindtap="onMyIntegralHandler" class="btn btn2">查看我的积分</view> | 29 | <view bindtap="onMyIntegralHandler" class="btn btn2">查看我的积分</view> |
30 | <!-- <view class="btn btn2">联系客服</view> --> | 30 | <!-- <view class="btn btn2">联系客服</view> --> |
31 | </view> | 31 | </view> | ... | ... |
... | @@ -90,11 +90,11 @@ Page({ | ... | @@ -90,11 +90,11 @@ Page({ |
90 | toast: false, | 90 | toast: false, |
91 | url: app.api.sign, | 91 | url: app.api.sign, |
92 | }).then((result) => { | 92 | }).then((result) => { |
93 | this.queryMember().then((result) => { | 93 | this.queryMember().then((result2) => { |
94 | this.querySignInfo().then((result2) => { | 94 | this.querySignInfo().then((result3) => { |
95 | // 签到成功 | 95 | // 签到成功 |
96 | this.setData({ | 96 | this.setData({ |
97 | signPrize: result2, | 97 | signPrize: result, |
98 | giftSignTipsCompVisible: true | 98 | giftSignTipsCompVisible: true |
99 | }) | 99 | }) |
100 | }) | 100 | }) | ... | ... |
... | @@ -122,6 +122,16 @@ function formatWeek(week) { | ... | @@ -122,6 +122,16 @@ function formatWeek(week) { |
122 | return result; | 122 | return result; |
123 | } | 123 | } |
124 | 124 | ||
125 | |||
126 | /** | ||
127 | * 根据url获取参数 | ||
128 | * @param {*} name | ||
129 | */ | ||
130 | function getQueryByUrl(name, url) { | ||
131 | return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(url) || [, ""])[1].replace(/\+/g, '%20')) || null; | ||
132 | } | ||
133 | |||
134 | |||
125 | /** | 135 | /** |
126 | * 获取点击传值 | 136 | * 获取点击传值 |
127 | * @param {*} evt | 137 | * @param {*} evt |
... | @@ -232,5 +242,6 @@ module.exports = { | ... | @@ -232,5 +242,6 @@ module.exports = { |
232 | formatWeek: formatWeek, | 242 | formatWeek: formatWeek, |
233 | getBindtapData: getBindtapData, | 243 | getBindtapData: getBindtapData, |
234 | wxacodeGet: wxacodeGet, | 244 | wxacodeGet: wxacodeGet, |
235 | getObjByListKeyValue: getObjByListKeyValue | 245 | getObjByListKeyValue: getObjByListKeyValue, |
246 | getQueryByUrl: getQueryByUrl, | ||
236 | } | 247 | } | ... | ... |
-
Please register or sign in to post a comment