Browse Source

优惠券

master
nige 3 years ago
parent
commit
97c6001038
  1. 48
      pages/order/components/coupon/index.js
  2. 33
      pages/order/coupon/index.js
  3. 21
      pages/order/movie/index.js
  4. 2
      pages/order/movie/index.wxml
  5. 14
      pages/order/postOrder/index.js
  6. 2
      pages/order/postOrder/index.wxml
  7. 11
      pages/order/roadOrder/index.js
  8. 2
      pages/order/roadOrder/index.wxml
  9. 30
      pages/order/scene/index.js
  10. 2
      pages/order/scene/index.wxml

48
pages/order/components/coupon/index.js

@ -1,4 +1,5 @@
// pages/order/components/coupon/index.js // pages/order/components/coupon/index.js
import commonApi from "../../../../utils/https/common"
let app = getApp() let app = getApp()
Component({ Component({
/** /**
@ -23,20 +24,57 @@ Component({
}, },
pageLifetimes: { pageLifetimes: {
show: function() { show: function() {
this.setData({ this.getMaxCoupon()
coupon:app.globalData.couponInfo
})
} }
}, },
lifetimes:{
attached(){
},
},
/** /**
* 组件的方法列表 * 组件的方法列表
*/ */
methods: { methods: {
setNullCoupon:function(){ setNullCoupon:function(){
app.globalData.couponInfo = null
this.setData({ this.setData({
coupon:null 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);
}
}
})
}
} }
},
}) })

33
pages/order/coupon/index.js

@ -15,6 +15,7 @@ Page({
/** /**
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad: function (options) { onLoad: function (options) {
this.getList(options) this.getList(options)
}, },
@ -30,6 +31,27 @@ Page({
this.setData({ this.setData({
list:res.data 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){ selectIt:function(e){
@ -53,10 +75,15 @@ Page({
list.map(item=>{ list.map(item=>{
if(item.selected){ if(item.selected){
coupon = item; coupon = item;
item.SubCoupon = true
} }
}) })
console.log(coupon) if (coupon===null) {
app.globalData.couponInfo = coupon; app.globalData.couponInfo = false
}else{
app.globalData.couponInfo = coupon;
}
util.back() util.back()
}, },
@ -71,7 +98,7 @@ Page({
* 生命周期函数--监听页面显示 * 生命周期函数--监听页面显示
*/ */
onShow: function () { onShow: function () {
app.globalData.couponInfo = null;
}, },
/** /**

21
pages/order/movie/index.js

@ -13,7 +13,7 @@ Page({
tel:'', tel:'',
product:null, product:null,
price:0, price:0,
coupon:null, coupon:app.globalData.couponInfo,
prizeId:null, prizeId:null,
num:0, num:0,
sPrice:0, sPrice:0,
@ -24,7 +24,10 @@ Page({
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad: function (options) { onLoad: function (options) {
console.log(options); app.globalData.couponInfo = null
this.setData({
coupon:app.globalData.couponInfo
})
this.setData({ this.setData({
prizeId:wx.getStorageSync('prizeId') prizeId:wx.getStorageSync('prizeId')
}) })
@ -123,22 +126,26 @@ Page({
this.setData({ this.setData({
hideMx:!this.data.hideMx hideMx:!this.data.hideMx
}) })
}, },
//获取最高优惠券
getNewCoupon(e){
this.setData({
coupon:e.detail
})
},
/** /**
* 生命周期函数--监听页面显示 * 生命周期函数--监听页面显示
*/ */
onShow: function () { onShow: function () {
this.setData({
coupon:app.globalData.couponInfo,
})
}, },
/** /**
* 生命周期函数--监听页面隐藏 * 生命周期函数--监听页面隐藏
*/ */
onHide: function () { onHide: function () {
app.globalData.couponInfo = null
}, },
/** /**

2
pages/order/movie/index.wxml

@ -31,7 +31,7 @@
<text>手机号码:</text> <text>手机号码:</text>
<input value="{{tel}}" type="number" bindinput="changeTel" placeholder="输入您的手机号"></input> <input value="{{tel}}" type="number" bindinput="changeTel" placeholder="输入您的手机号"></input>
</view> </view>
<coupon money="{{price}}" sku="{{product.product.sku_info.id}}"></coupon> <coupon bind:getNewCoupon = 'getNewCoupon' money="{{price}}" sku="{{product.product.sku_info.id}}"></coupon>
<view class="fix-info {{!hideMx?'hide':''}}"> <view class="fix-info {{!hideMx?'hide':''}}">

14
pages/order/postOrder/index.js

@ -12,7 +12,7 @@ Page({
from: null, from: null,
address: null, address: null,
postFee: 0, postFee: 0,
coupon: null, coupon:app.globalData.couponInfo,
sku_id: '', sku_id: '',
kjId: null, kjId: null,
gp_id: null, gp_id: null,
@ -255,6 +255,12 @@ Page({
}) })
this.changePrice() this.changePrice()
}, },
//获取最高优惠券
getNewCoupon(e){
this.setData({
coupon:e.detail
})
},
/** /**
* 生命周期函数--监听页面初次渲染完成 * 生命周期函数--监听页面初次渲染完成
@ -267,9 +273,9 @@ Page({
* 生命周期函数--监听页面显示 * 生命周期函数--监听页面显示
*/ */
onShow: function () { onShow: function () {
this.setData({ // this.setData({
coupon: app.globalData.couponInfo // coupon: app.globalData.couponInfo
}) // })
// 获取补贴 // 获取补贴
// if (this.data.product.length == 1) { // if (this.data.product.length == 1) {
// commonApi.user_post("product/getProductAllowancePrice", { // commonApi.user_post("product/getProductAllowancePrice", {

2
pages/order/postOrder/index.wxml

@ -47,7 +47,7 @@
</view> </view>
</view> </view>
</view> </view>
<coupon id="coupon" wx:if="{{!kjId && !gp_id && flag!='mix'}}" money="{{showPrice + postFee}}" sku="{{sku_id}}"></coupon> <coupon bind:getNewCoupon = 'getNewCoupon' id="coupon" wx:if="{{!kjId && !gp_id && flag!='mix'}}" money="{{showPrice + postFee}}" sku="{{sku_id}}"></coupon>
<view style="height:113rpx"></view> <view style="height:113rpx"></view>
<view class="fixed-bottom" wx:if="{{product}}"> <view class="fixed-bottom" wx:if="{{product}}">
<view class="fixed-price-box" wx:if="{{!prizeId}}"><text>合计:</text><text <view class="fixed-price-box" wx:if="{{!prizeId}}"><text>合计:</text><text

11
pages/order/roadOrder/index.js

@ -20,7 +20,7 @@ Page({
remark:"", remark:"",
editId:null, editId:null,
price:0, price:0,
coupon:null, coupon:app.globalData.couponInfo,
sku_ids:"", sku_ids:"",
prizeId:null prizeId:null
}, },
@ -270,6 +270,12 @@ Page({
}) })
}, },
//获取最高优惠券
getNewCoupon(e){
this.setData({
coupon:e.detail
})
},
// 一日游合同确认签字 // 一日游合同确认签字
// ondayConfirm:function(){ // ondayConfirm:function(){
// let linkmans = this.data.linkmans,tourist_info=[],sku=this.data.sku; // let linkmans = this.data.linkmans,tourist_info=[],sku=this.data.sku;
@ -324,9 +330,6 @@ Page({
* 生命周期函数--监听页面显示 * 生命周期函数--监听页面显示
*/ */
onShow: function () { onShow: function () {
this.setData({
coupon:app.globalData.couponInfo
})
if(this.data.editId){ if(this.data.editId){
// 如果是去编辑的 // 如果是去编辑的
let editId = this.data.editId; let editId = this.data.editId;

2
pages/order/roadOrder/index.wxml

@ -29,7 +29,7 @@
<input type="text" bindinput="inputRemark" placeholder="选填"></input> <input type="text" bindinput="inputRemark" placeholder="选填"></input>
</view> </view>
</view> </view>
<coupon money="{{price}}" sku="{{sku_ids}}"></coupon> <coupon bind:getNewCoupon = 'getNewCoupon' money="{{price}}" sku="{{sku_ids}}"></coupon>
<!-- <view class="user-box"> <!-- <view class="user-box">
<view class="user-item" style="border:none"> <view class="user-item" style="border:none">
<image style="width:32rpx" src="https://static.ticket.sz-trip.com/xcxImages/other/hetong.png" mode="widthFix"></image> <image style="width:32rpx" src="https://static.ticket.sz-trip.com/xcxImages/other/hetong.png" mode="widthFix"></image>

30
pages/order/scene/index.js

@ -16,7 +16,7 @@ Page({
remark: "", remark: "",
singlePrice: 0, singlePrice: 0,
type: null, type: null,
coupon: app.globalData.couponInfo, coupon:null,
isLogin: false, isLogin: false,
kjId: null, kjId: null,
gp_id: null, gp_id: null,
@ -36,8 +36,6 @@ Page({
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad: function (options) { onLoad: function (options) {
console.log(app.globalData.product);
console.log(options.isCar);
this.setData({ this.setData({
product: app.globalData.product, product: app.globalData.product,
type: options.type, type: options.type,
@ -83,13 +81,13 @@ Page({
title: '订单价格发生变化,请重新选择优惠券', title: '订单价格发生变化,请重新选择优惠券',
icon: 'none' icon: 'none'
}) })
if (!this.data.kjId && !this.data.gp_id && this.data.product.isGroup != 1) { // if (!this.data.kjId && !this.data.gp_id && this.data.product.isGroup != 1) {
this.couponCom.setNullCoupon() // this.couponCom.setNullCoupon()
} // }
app.globalData.couponInfo = null; // app.globalData.couponInfo = null;
this.setData({ // this.setData({
coupon: null // coupon: null
}) // })
} }
let productNum = linkmanList.length == 0 ? 1 : this.data.productNum > linkmanList.length ? this.data.productNum : linkmanList.length; let productNum = linkmanList.length == 0 ? 1 : this.data.productNum > linkmanList.length ? this.data.productNum : linkmanList.length;
if (this.data.gp_id) { if (this.data.gp_id) {
@ -361,6 +359,12 @@ Page({
}) })
this.changePrice() this.changePrice()
}, },
//获取最高优惠券
getNewCoupon(e){
this.setData({
coupon:e.detail
})
},
/** /**
* 生命周期函数--监听页面初次渲染完成 * 生命周期函数--监听页面初次渲染完成
@ -385,9 +389,9 @@ Page({
} }
}) })
} }
this.setData({ // this.setData({
coupon: app.globalData.couponInfo // coupon: app.globalData.couponInfo
}) // })
// 获取补贴 // 获取补贴
// if (this.data.product) { // if (this.data.product) {
// commonApi.user_post("product/getProductAllowancePrice", { // commonApi.user_post("product/getProductAllowancePrice", {

2
pages/order/scene/index.wxml

@ -35,7 +35,7 @@
</view> </view>
</view> </view>
<coupon wx:if="{{!kjId && !gp_id && type!='activity' && product && product.isGroup!=1 && isCar=='single'}}" id="coupon" <coupon bind:getNewCoupon = 'getNewCoupon' wx:if="{{!kjId && !gp_id && type!='activity' && product && product.isGroup!=1 && isCar=='single'}}" id="coupon"
money="{{singlePrice * productNum}}" sku="{{product.sku.id}}"></coupon> money="{{singlePrice * productNum}}" sku="{{product.sku.id}}"></coupon>
<view class="box" wx:if="{{type!='activity' && product && product.isGroup!=1}}"> <view class="box" wx:if="{{type!='activity' && product && product.isGroup!=1}}">

Loading…
Cancel
Save