|
@@ -10,6 +10,7 @@ Page({
|
|
|
noResult: false,
|
|
|
noMore: false,
|
|
|
bannerList: [],
|
|
|
+ couponList: [],
|
|
|
channelid: '',
|
|
|
shopid: '',
|
|
|
storeid: ''
|
|
@@ -34,6 +35,7 @@ Page({
|
|
|
*/
|
|
|
onShow: function () {
|
|
|
this.getBannerList()
|
|
|
+ this.getCouponList()
|
|
|
},
|
|
|
|
|
|
/**
|
|
@@ -73,9 +75,9 @@ Page({
|
|
|
|
|
|
getBannerList: function() {
|
|
|
Integralinfo.getBannerList({
|
|
|
- channelid: this.channelid,
|
|
|
- shopid: this.shopid,
|
|
|
- storeid: this.storeid
|
|
|
+ channelid: this.data.channelid,
|
|
|
+ shopid: this.data.shopid,
|
|
|
+ storeid: this.data.storeid
|
|
|
}).then(res => {
|
|
|
console.log(res.data)
|
|
|
this.setData({
|
|
@@ -85,5 +87,47 @@ Page({
|
|
|
console.log(err)
|
|
|
})
|
|
|
},
|
|
|
+
|
|
|
+getCouponList: function() {
|
|
|
+ Integralinfo.getList({
|
|
|
+ channelid: this.data.channelid,
|
|
|
+ shopid: this.data.shopid,
|
|
|
+ storeid: this.data.storeid
|
|
|
+ }).then(res => {
|
|
|
+ this.couponListView(res.data)
|
|
|
+ this.data.lock = false
|
|
|
+ }).catch(_ => {
|
|
|
+ console.log(_)
|
|
|
+ this.data.lock = false
|
|
|
+ })
|
|
|
+},
|
|
|
+
|
|
|
+couponListView: function(data) {
|
|
|
+ if (!Array.isArray(data) || data.length == 0) {
|
|
|
+ console.log("优惠券列表数据为空");
|
|
|
+ }
|
|
|
+ data.forEach((v) => {
|
|
|
+ v.quantity = 0
|
|
|
+ v.integral = v.price * v.ratio
|
|
|
+ })
|
|
|
+ if (this.mobile != '********') {
|
|
|
+ let num = this.integralNum > 20000 ? 19999 : this.integralNum
|
|
|
+ const arr = []
|
|
|
+ for (let i = 0; i < data.length; i++) {
|
|
|
+ data[i].quantity = parseInt(num / data[i].integral)
|
|
|
+ if (data[i].quantity > 0) {
|
|
|
+ num -= (data[i].quantity * data[i].price) * data[i].ratio
|
|
|
+ this.total += (data[i].quantity * data[i].price) * data[i].ratio
|
|
|
+ arr.push(data[i])
|
|
|
+ data.splice(i, 1)
|
|
|
+ i--
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.setData({
|
|
|
+ couponList: [...arr, ...data]
|
|
|
+ })
|
|
|
+ console.log(this.data.couponList)
|
|
|
+ }
|
|
|
+}
|
|
|
|
|
|
})
|