"vscode:/vscode.git/clone" did not exist on "2ff992eea0f84555ca76906a93216b6ed3f85357"
Commit 32bf4241 authored by beaver383's avatar beaver383
Browse files

小程序同步修改优惠券问题

parent 898942fa
...@@ -17,6 +17,7 @@ Page({ ...@@ -17,6 +17,7 @@ Page({
cartId: 0, cartId: 0,
addressId: 0, addressId: 0,
couponId: 0, couponId: 0,
userCouponId: 0,
message: '', message: '',
grouponLinkId: 0, //参与的团购,如果是发起则为0 grouponLinkId: 0, //参与的团购,如果是发起则为0
grouponRulesId: 0 //团购规则ID grouponRulesId: 0 //团购规则ID
...@@ -32,6 +33,7 @@ Page({ ...@@ -32,6 +33,7 @@ Page({
cartId: that.data.cartId, cartId: that.data.cartId,
addressId: that.data.addressId, addressId: that.data.addressId,
couponId: that.data.couponId, couponId: that.data.couponId,
userCouponId: that.data.userCouponId,
grouponRulesId: that.data.grouponRulesId grouponRulesId: that.data.grouponRulesId
}).then(function(res) { }).then(function(res) {
if (res.errno === 0) { if (res.errno === 0) {
...@@ -47,6 +49,7 @@ Page({ ...@@ -47,6 +49,7 @@ Page({
orderTotalPrice: res.data.orderTotalPrice, orderTotalPrice: res.data.orderTotalPrice,
addressId: res.data.addressId, addressId: res.data.addressId,
couponId: res.data.couponId, couponId: res.data.couponId,
userCouponId: res.data.userCouponId,
grouponRulesId: res.data.grouponRulesId, grouponRulesId: res.data.grouponRulesId,
}); });
} }
...@@ -90,6 +93,10 @@ Page({ ...@@ -90,6 +93,10 @@ Page({
if (couponId === "") { if (couponId === "") {
couponId = 0; couponId = 0;
} }
var userCouponId = wx.getStorageSync('userCouponId');
if (userCouponId === "") {
userCouponId = 0;
}
var grouponRulesId = wx.getStorageSync('grouponRulesId'); var grouponRulesId = wx.getStorageSync('grouponRulesId');
if (grouponRulesId === "") { if (grouponRulesId === "") {
grouponRulesId = 0; grouponRulesId = 0;
...@@ -103,6 +110,7 @@ Page({ ...@@ -103,6 +110,7 @@ Page({
cartId: cartId, cartId: cartId,
addressId: addressId, addressId: addressId,
couponId: couponId, couponId: couponId,
userCouponId: userCouponId,
grouponRulesId: grouponRulesId, grouponRulesId: grouponRulesId,
grouponLinkId: grouponLinkId grouponLinkId: grouponLinkId
}); });
...@@ -131,6 +139,7 @@ Page({ ...@@ -131,6 +139,7 @@ Page({
cartId: this.data.cartId, cartId: this.data.cartId,
addressId: this.data.addressId, addressId: this.data.addressId,
couponId: this.data.couponId, couponId: this.data.couponId,
userCouponId: this.data.userCouponId,
message: this.data.message, message: this.data.message,
grouponRulesId: this.data.grouponRulesId, grouponRulesId: this.data.grouponRulesId,
grouponLinkId: this.data.grouponLinkId grouponLinkId: this.data.grouponLinkId
......
...@@ -8,6 +8,7 @@ Page({ ...@@ -8,6 +8,7 @@ Page({
couponList: [], couponList: [],
cartId: 0, cartId: 0,
couponId: 0, couponId: 0,
userCouponId: 0,
grouponLinkId: 0, grouponLinkId: 0,
scrollTop: 0 scrollTop: 0
}, },
...@@ -46,6 +47,11 @@ Page({ ...@@ -46,6 +47,11 @@ Page({
couponId = 0; couponId = 0;
} }
var userCouponId = wx.getStorageSync('userCouponId');
if (!userCouponId) {
userCouponId = 0;
}
var grouponRulesId = wx.getStorageSync('grouponRulesId'); var grouponRulesId = wx.getStorageSync('grouponRulesId');
if (!grouponRulesId) { if (!grouponRulesId) {
grouponRulesId = 0; grouponRulesId = 0;
...@@ -54,6 +60,7 @@ Page({ ...@@ -54,6 +60,7 @@ Page({
this.setData({ this.setData({
cartId: cartId, cartId: cartId,
couponId: couponId, couponId: couponId,
userCouponId: userCouponId,
grouponRulesId: grouponRulesId grouponRulesId: grouponRulesId
}); });
...@@ -116,8 +123,14 @@ Page({ ...@@ -116,8 +123,14 @@ Page({
grouponRulesId: that.data.grouponRulesId, grouponRulesId: that.data.grouponRulesId,
}).then(function (res) { }).then(function (res) {
if (res.errno === 0) { if (res.errno === 0) {
let list = [];
for (var i = 0; i < res.data.list.length; i++) {
if (res.data.list[i].available) {
list.push(res.data.list[i]);
}
}
that.setData({ that.setData({
couponList: res.data.list couponList: list
}); });
} }
wx.hideToast(); wx.hideToast();
...@@ -126,7 +139,8 @@ Page({ ...@@ -126,7 +139,8 @@ Page({
}, },
selectCoupon: function (e) { selectCoupon: function (e) {
try { try {
wx.setStorageSync('couponId', e.currentTarget.dataset.id); wx.setStorageSync('couponId', e.currentTarget.dataset.cid);
wx.setStorageSync('userCouponId', e.currentTarget.dataset.id);
} catch (error) { } catch (error) {
} }
...@@ -137,6 +151,7 @@ Page({ ...@@ -137,6 +151,7 @@ Page({
// 如果优惠券ID设置-1,则表示订单不使用优惠券 // 如果优惠券ID设置-1,则表示订单不使用优惠券
try { try {
wx.setStorageSync('couponId', -1); wx.setStorageSync('couponId', -1);
wx.setStorageSync('userCouponId', -1);
} catch (error) { } catch (error) {
} }
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<view class="unselect" bindtap='unselectCoupon'>不选择优惠券</view> <view class="unselect" bindtap='unselectCoupon'>不选择优惠券</view>
<view class="item" wx:for="{{couponList}}" wx:for-index="index" wx:for-item="item" wx:key="id" bindtap="selectCoupon" data-id="{{item.id}}"> <view class="item" wx:for="{{couponList}}" wx:for-index="index" wx:for-item="item" wx:key="id" bindtap="selectCoupon" data-id="{{item.id}}" data-cid="{{item.cid}}">
<view class="tag">{{item.tag}}</view> <view class="tag">{{item.tag}}</view>
<view class="content"> <view class="content">
<view class="left"> <view class="left">
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment