Browse Source

优惠券修改

master
jiazhipeng 6 months ago
parent
commit
5108b2e698
  1. 46
      pages/order/components/coupon/index.js
  2. 2
      pages/order/components/coupon/index.wxml
  3. 51
      pages/order/coupon/index.js
  4. 15
      pages/order/coupon/index.wxml
  5. 26
      pages/order/coupon/index.wxss
  6. 2
      pages/order/orderList/index.js
  7. 2
      pages/order/orderList/index.wxml
  8. 9
      pages/order/scene/index.js
  9. 2
      pages/user/cartlist/list.js

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

@ -26,7 +26,11 @@ Component({
})
}
}
}
},
sourceFrom: {
type:String,
value:""
},
},
/**
@ -63,9 +67,45 @@ Component({
})
this.triggerEvent('getNewCoupon',null);
}else{
commonApi.user_post('coupon/use_max_coupon_list',{
let postList = app.globalData.postProduct || []
let ticketList = app.globalData.list || []
let signleProduct = app.globalData.product || null
let listData = []
if (this.properties.sourceFrom == 'cart') {
postList.forEach(v=>{
listData.push({
sku_id: v.sku.id,
price: v.sku.price,
sell_price: v.sku.price,
num: v.productNum,
})
})
ticketList.forEach(v=>{
listData.push({
sku_id: v.sku.id,
price: v.sku.price,
sell_price: v.sku.price,
num: v.num,
use_date: v.time&&v.time.sale_date?v.time.sale_date:''
})
})
} else {
if (signleProduct) {
listData.push({
sku_id: signleProduct.sku.id,
price: signleProduct.sku.price,
sell_price: signleProduct.sku.price,
num: signleProduct.productNum,
use_date: signleProduct.date&&signleProduct.date.date?signleProduct.date.date:''
})
}
}
commonApi.user_post('coupon/use_max_coupon_listv2',{
money:this.data.money,
sku_ids:this.data.sku
sku_ids:this.data.sku,
cart_data: listData
}).then(res=>{
if (app.globalData.couponInfo&&app.globalData.couponInfo.hasOwnProperty('SubCoupon')) {
this.setData({

2
pages/order/components/coupon/index.wxml

@ -1,5 +1,5 @@
<!--pages/order/components/coupon/index.wxml-->
<navigator url="/pages/order/coupon/index?money={{money}}&sku={{sku}}" class="box">
<navigator url="/pages/order/coupon/index?money={{money}}&sku={{sku}}&sourceFrom={{sourceFrom}}" class="box">
<view class="box-title">
<view style="flex:1">优惠券</view>
<view wx:if="{{coupon}}">

51
pages/order/coupon/index.js

@ -9,7 +9,9 @@ Page({
*/
data: {
list:[],
moreFlag:true
moreFlag:true,
productList: [],
},
/**
@ -17,13 +19,53 @@ Page({
*/
onLoad: function (options) {
console.log(app.globalData.postProduct,app.globalData.list,app.globalData.product)
let sourceFrom = options.sourceFrom
let postList = app.globalData.postProduct || []
let ticketList = app.globalData.list || []
let signleProduct = app.globalData.product || null
let listData = []
if (sourceFrom == 'cart') {
postList.forEach(v=>{
listData.push({
sku_id: v.sku.id,
price: v.sku.price,
sell_price: v.sku.price,
num: v.productNum,
})
})
ticketList.forEach(v=>{
listData.push({
sku_id: v.sku.id,
price: v.sku.price,
sell_price: v.sku.price,
num: v.num,
use_date: v.time&&v.time.sale_date?v.time.sale_date:''
})
})
} else {
if (signleProduct) {
listData.push({
sku_id: signleProduct.sku.id,
price: signleProduct.sku.price,
sell_price: signleProduct.sku.price,
num: signleProduct.productNum,
use_date: signleProduct.date&&signleProduct.date.date?signleProduct.date.date:''
})
}
}
this.setData({
productList: listData
})
this.getList(options)
},
getList:function(options){
if(!this.data.moreFlag) return
commonApi.user_post('coupon/use_coupon_listv3',{
money:options.money,
sku_ids:options.sku
sku_ids:options.sku,
cart_data: this.data.productList
}).then(res=>{
res.data.map(item=>{
item.selected = false;
@ -36,9 +78,10 @@ Page({
},
//获取最高优惠
getMaxC(options){
commonApi.user_post('coupon/use_max_coupon_list',{
commonApi.user_post('coupon/use_max_coupon_listv2',{
money:options.money,
sku_ids:options.sku
sku_ids:options.sku,
cart_data: this.data.productList
}).then(res=>{
console.log(app.globalData.couponInfo);

15
pages/order/coupon/index.wxml

@ -1,7 +1,8 @@
<!--pages/order/coupon/index.wxml-->
<title title="优惠券"></title>
<view wx:if="{{list.length>0}}">
<view class="coupon-item" wx:for="{{list}}">
<view class="coupon-item-box" wx:for="{{list}}">
<view class="coupon-item" >
<view class="money" wx:if="{{item.activity.discount_type == 'pricebreak'}}">{{item.activity.money/100}}</view>
<view class="money1" wx:else>
{{item.activity.fold}}
@ -10,8 +11,18 @@
<view>{{item.activity.name}}</view>
<view class="couon-date" wx:if="{{item.end_time}}">{{item.end_time}}到期</view>
</view>
<view class="iconfont icon-{{item.selected?'gou':'quan'}}" bindtap="selectIt" data-index="{{index}}"></view>
<view wx:if="{{item.can_use}}" class="iconfont icon-{{item.selected?'gou':'quan'}}" bindtap="selectIt" data-index="{{index}}"></view>
<view class="couon-date" wx:else>不可用</view>
</view>
<view class="no-reason" wx:if="{{!item.can_use}}">
<view style="color: #D62828;margin-bottom: 8rpx;">不可用原因</view>
<view>{{item.reason}}</view>
</view>
</view>
<view class="btn" bindtap="submit">确定</view>
</view>
<view class="common-empty" wx:if="{{list.length==0}}" style="z-index:-1;top:0">

26
pages/order/coupon/index.wxss

@ -2,20 +2,27 @@
page {
background: #f6f6f6;
}
.coupon-item-box{
width: 700rpx;
margin: 26rpx auto;
background: white;
border-radius: 7rpx;
box-sizing: border-box;
padding:0 26rpx;
}
.coupon-item {
width: 100%;
display: flex;
align-items: center;
justify-content: space-between;
margin: 26rpx;
background: white;
border-radius: 7rpx;
height: 136rpx;
padding-right: 27rpx;
}
.coupon-item .money {
color: #D62828;
font-size: 67rpx;
width: 187rpx;
width: 147rpx;
text-align: center;
font-weight: 500;
flex-shrink: 0;
@ -69,3 +76,12 @@ page {
font-weight: 500;
text-align: center;
}
.no-reason{
width: 100%;
border-top: 1px dashed #e0e0e0;
padding: 20rpx 0;
color: #666;
font-size: 24rpx;
box-sizing: border-box;
}

2
pages/order/orderList/index.js

@ -41,7 +41,7 @@ Page({
// showCoupon: (app.globalData.list || []).length<=0,
// linkmanList: app.globalData.linkmanList
})
console.log('-------------',this.data.ticketList);
console.log('-------------',this.data.ticketList, this.data.goodsList);
// debugger
let price = 0, sku_id = [] ,postFee= 0;
app.globalData.postProduct.map(item => {

2
pages/order/orderList/index.wxml

@ -56,7 +56,7 @@
<view style="flex-shrink:0">订单备注:</view>
<input type="text" bindinput="inputRemark" data-index="{{index}}" placeholder="选填"></input>
</view> -->
<coupon bind:getNewCoupon = 'getNewCoupon' id="coupon" wx:if="{{showCoupon && !kjId && !gp_id}}" money="{{showPrice + postFee}}" sku="{{sku_id}}"></coupon>
<coupon bind:getNewCoupon = 'getNewCoupon' id="coupon" wx:if="{{showCoupon && !kjId && !gp_id}}" money="{{showPrice + postFee}}" sku="{{sku_id}}" sourceFrom="cart"></coupon>
<view class="fixed-bottom">
<view class="fixed-price-box">

9
pages/order/scene/index.js

@ -370,13 +370,14 @@ Page({
changeDate: function (e) {
console.log('打印',e);
let sku_id = e.detail.sku_id;
app.globalData.product.date = e.detail
this.setData({
showDate:true
})
// debugger
// this.showAllPrice()
this.totalPrice(e.detail.price)
if (e.detail.price != this.data.singlePrice && this.data.coupon) {
if (this.data.coupon) {
wx.showToast({
title: '订单价格发生变化,请重新选择优惠券',
icon: 'none'
@ -386,7 +387,12 @@ Page({
singlePrice:e.detail.price
})
if (!this.data.kjId && !this.data.gp_id && this.data.product.isGroup != 1 && this.data.type!='museum') {
try {
this.couponCom = this.selectAllComponents("#coupon")[0];
this.couponCom.setNullCoupon()
} catch (e) {
}
}
app.globalData.couponInfo = null;
}
@ -415,6 +421,7 @@ Page({
this.setData({
time: e.detail
})
},
changeAllowance: function () {
this.setData({

2
pages/user/cartlist/list.js

@ -396,7 +396,9 @@ Page({
app.globalData.index = 0
app.globalData.productPrice = 0
app.globalData.ticketPrice = 0
app.globalData.product = null
this.data.productType = ''
console.log(app.globalData)
},
/**

Loading…
Cancel
Save