diff --git a/pages/order/components/coupon/index.js b/pages/order/components/coupon/index.js
index 14cf5dc..0fbb534 100644
--- a/pages/order/components/coupon/index.js
+++ b/pages/order/components/coupon/index.js
@@ -1,4 +1,5 @@
// pages/order/components/coupon/index.js
+import commonApi from "../../../../utils/https/common"
let app = getApp()
Component({
/**
@@ -23,20 +24,57 @@ Component({
},
pageLifetimes: {
show: function() {
- this.setData({
- coupon:app.globalData.couponInfo
- })
+ this.getMaxCoupon()
}
},
-
+ lifetimes:{
+ attached(){
+ },
+ },
/**
* 组件的方法列表
*/
methods: {
setNullCoupon:function(){
+ app.globalData.couponInfo = null
this.setData({
coupon:null
})
- }
+ },
+ getMaxCoupon(){
+ // console.log(app.globalData.couponInfo);
+ console.log(this.data.coupon);
+ if (app.globalData.couponInfo===false) {
+ this.setData({
+ coupon:null
+ })
+ this.triggerEvent('getNewCoupon',null);
+ }else{
+ commonApi.user_post('coupon/use_max_coupon_list',{
+ money:this.data.money,
+ sku_ids:this.data.sku
+ }).then(res=>{
+ if (app.globalData.couponInfo&&app.globalData.couponInfo.hasOwnProperty('SubCoupon')) {
+ this.setData({
+ coupon:app.globalData.couponInfo
+ })
+ this.triggerEvent('getNewCoupon',app.globalData.couponInfo);
+ console.log("我用的原来的数据");
+ }else{
+ console.log("我用的新的数据");
+ if ( Object.keys(res.data).length!=0) {
+ app.globalData.couponInfo = res.data
+ this.setData({
+ coupon:res.data
+ })
+ console.log(this.data.coupon);
+ this.triggerEvent('getNewCoupon',res.data);
+ }
+ }
+ })
+ }
+
}
+ },
+
})
diff --git a/pages/order/coupon/index.js b/pages/order/coupon/index.js
index 1b7c0c3..5a3d7b1 100644
--- a/pages/order/coupon/index.js
+++ b/pages/order/coupon/index.js
@@ -15,6 +15,7 @@ Page({
/**
* 生命周期函数--监听页面加载
*/
+
onLoad: function (options) {
this.getList(options)
},
@@ -30,6 +31,27 @@ Page({
this.setData({
list:res.data
})
+ this.getMaxC(options)
+ })
+ },
+ //获取最高优惠
+ getMaxC(options){
+ commonApi.user_post('coupon/use_max_coupon_list',{
+ money:options.money,
+ sku_ids:options.sku
+ }).then(res=>{
+ console.log(app.globalData.couponInfo);
+
+ app.globalData.couponInfo?app.globalData.couponInfo:app.globalData.couponInfo= res.data;
+ let listT = this.data.list
+ listT.forEach(item => {
+ if (item.id == app.globalData.couponInfo.id) {
+ item.selected = true
+ }
+ });
+ this.setData({
+ list:listT
+ })
})
},
selectIt:function(e){
@@ -53,10 +75,15 @@ Page({
list.map(item=>{
if(item.selected){
coupon = item;
+ item.SubCoupon = true
}
})
- console.log(coupon)
- app.globalData.couponInfo = coupon;
+ if (coupon===null) {
+ app.globalData.couponInfo = false
+ }else{
+ app.globalData.couponInfo = coupon;
+ }
+
util.back()
},
@@ -71,7 +98,7 @@ Page({
* 生命周期函数--监听页面显示
*/
onShow: function () {
- app.globalData.couponInfo = null;
+
},
/**
diff --git a/pages/order/movie/index.js b/pages/order/movie/index.js
index 7a449ef..d722ee3 100644
--- a/pages/order/movie/index.js
+++ b/pages/order/movie/index.js
@@ -13,7 +13,7 @@ Page({
tel:'',
product:null,
price:0,
- coupon:null,
+ coupon:app.globalData.couponInfo,
prizeId:null,
num:0,
sPrice:0,
@@ -24,7 +24,10 @@ Page({
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
- console.log(options);
+ app.globalData.couponInfo = null
+ this.setData({
+ coupon:app.globalData.couponInfo
+ })
this.setData({
prizeId:wx.getStorageSync('prizeId')
})
@@ -123,22 +126,26 @@ Page({
this.setData({
hideMx:!this.data.hideMx
})
- },
+ },
+ //获取最高优惠券
+ getNewCoupon(e){
+ this.setData({
+ coupon:e.detail
+ })
+ },
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
- this.setData({
- coupon:app.globalData.couponInfo,
- })
+
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
- app.globalData.couponInfo = null
+
},
/**
diff --git a/pages/order/movie/index.wxml b/pages/order/movie/index.wxml
index a749339..0172212 100644
--- a/pages/order/movie/index.wxml
+++ b/pages/order/movie/index.wxml
@@ -31,7 +31,7 @@
手机号码:
-
+
diff --git a/pages/order/postOrder/index.js b/pages/order/postOrder/index.js
index f847587..265207d 100644
--- a/pages/order/postOrder/index.js
+++ b/pages/order/postOrder/index.js
@@ -12,7 +12,7 @@ Page({
from: null,
address: null,
postFee: 0,
- coupon: null,
+ coupon:app.globalData.couponInfo,
sku_id: '',
kjId: null,
gp_id: null,
@@ -255,6 +255,12 @@ Page({
})
this.changePrice()
},
+ //获取最高优惠券
+ getNewCoupon(e){
+ this.setData({
+ coupon:e.detail
+ })
+ },
/**
* 生命周期函数--监听页面初次渲染完成
@@ -267,9 +273,9 @@ Page({
* 生命周期函数--监听页面显示
*/
onShow: function () {
- this.setData({
- coupon: app.globalData.couponInfo
- })
+ // this.setData({
+ // coupon: app.globalData.couponInfo
+ // })
// 获取补贴
// if (this.data.product.length == 1) {
// commonApi.user_post("product/getProductAllowancePrice", {
diff --git a/pages/order/postOrder/index.wxml b/pages/order/postOrder/index.wxml
index 6c3ab93..8753b18 100644
--- a/pages/order/postOrder/index.wxml
+++ b/pages/order/postOrder/index.wxml
@@ -47,7 +47,7 @@
-
+
合计:
-
+