-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
159 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
module.exports = { | ||
version: '9.14.1', | ||
note: '增加商品浏览足迹', // 这个为版本描述,无需修改 | ||
version: '9.15.0', | ||
note: '增加合成优惠券功能', // 这个为版本描述,无需修改 | ||
subDomain: 'tz', // 此处改成你自己的专属域名。什么是专属域名?请看教程 https://www.it120.cc/help/qr6l4m.html | ||
sdkAppID: 1400450467, // 腾讯实时音视频应用编号,请看教程 https://www.it120.cc/help/nxoqsl.html | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
const WXAPI = require('apifm-wxapi') | ||
const AUTH = require('../../utils/auth') | ||
Page({ | ||
data: { | ||
|
||
}, | ||
onLoad: function (options) { | ||
this.mergeCouponsRules(); | ||
}, | ||
onShow: function () { | ||
|
||
}, | ||
async mergeCouponsRules() { | ||
const res = await WXAPI.mergeCouponsRules() | ||
if (res.code == 0) { | ||
this.setData({ | ||
mergeCouponsRules: res.data | ||
}) | ||
} | ||
}, | ||
onPullDownRefresh() { | ||
this.mergeCouponsRules() | ||
wx.stopPullDownRefresh() | ||
}, | ||
async merge(e) { | ||
const idx = e.currentTarget.dataset.idx | ||
const mergeCouponsRule = this.data.mergeCouponsRules[idx] | ||
this.setData({loading: true}) | ||
let res = await WXAPI.myCoupons({ | ||
token: wx.getStorageSync('token'), | ||
status: 0 | ||
}) | ||
if (res.code == 700) { | ||
wx.showToast({ | ||
title: '您暂无可用的优惠券', | ||
icon: 'none' | ||
}) | ||
this.setData({loading: false}) | ||
return | ||
} | ||
if (res.code != 0) { | ||
wx.showToast({ | ||
title: res.msg, | ||
icon: 'none' | ||
}) | ||
this.setData({loading: false}) | ||
return | ||
} | ||
const myCoupons = res.data.reverse() | ||
const couponIds = [] // 用来合成的优惠券id | ||
let ok = true | ||
let msg = '' | ||
mergeCouponsRule.rules.filter(rule => { | ||
return rule.type == 0 | ||
}).forEach(rule => { | ||
for (let i = 0; i < rule.number; i++) { | ||
const couponIndex = myCoupons.findIndex(ele => { return ele.pid == rule.couponId}) | ||
if (couponIndex == -1) { | ||
ok = false | ||
msg = rule.couponName | ||
return | ||
} | ||
const coupon = myCoupons[couponIndex] | ||
couponIds.push(coupon.id) | ||
myCoupons.splice(couponIndex, 1) | ||
} | ||
}) | ||
if (!ok) { | ||
wx.showToast({ | ||
title: '缺少优惠券:' + msg, | ||
icon: 'none' | ||
}) | ||
this.setData({loading: false}) | ||
return | ||
} | ||
res = await WXAPI.mergeCoupons({ | ||
token: wx.getStorageSync('token'), | ||
mergeId: mergeCouponsRule.id, | ||
couponIds: couponIds.join() | ||
}) | ||
if (res.code != 0) { | ||
wx.showToast({ | ||
title: res.msg, | ||
icon: 'none' | ||
}) | ||
this.setData({loading: false}) | ||
return | ||
} | ||
wx.showToast({ | ||
title: '兑换成功' | ||
}) | ||
this.setData({loading: false}) | ||
setTimeout(() => { | ||
wx.navigateBack({ | ||
delta: 0, | ||
}) | ||
}, 1000); | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"navigationBarTitleText": "优惠券合成", | ||
"enablePullDownRefresh": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<van-empty wx:if="{{ !mergeCouponsRules }}" description="暂无合成规则" /> | ||
<van-cell-group wx:for="{{mergeCouponsRules}}" wx:key="id" title="{{ item.name }}"> | ||
<van-cell | ||
wx:for="{{item.rules}}" | ||
wx:for-item="rule" | ||
wx:key="id" | ||
icon="{{ rule.type == 0 ? 'delete' : 'share-o' }}" | ||
title="{{ rule.typeStr }}" | ||
label="优惠券:{{ rule.couponName }}" | ||
value="{{rule.number}} 张" | ||
/> | ||
<view class="block-btn"> | ||
<van-button type="primary" block data-idx="{{ index }}" loading="{{ loading }}" bind:click="merge">立即合成</van-button> | ||
</view> | ||
</van-cell-group> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/* pages/coupons/merge.wxss */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
{ | ||
"enablePullDownRefresh": true | ||
"enablePullDownRefresh": true, | ||
"navigationBarBackgroundColor": "#e64340", | ||
"navigationBarTextStyle": "white", | ||
"backgroundColor": "#e64340" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
{ | ||
"navigationBarTitleText": "搜索一下" | ||
"navigationBarTitleText": "搜一搜" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters