Browse Source
Reviewed-on: http://code.xmainc.com:3000/panyiping/jundaosuzhou_wechatxcx/pulls/1master
23 changed files with 960 additions and 96 deletions
@ -0,0 +1,150 @@ |
|||
// pages/order/comment/index.js
|
|||
let app = getApp() |
|||
import commonApi from "../../../utils/https/common" |
|||
Page({ |
|||
|
|||
/** |
|||
* 页面的初始数据 |
|||
*/ |
|||
data: { |
|||
goodsList: [], |
|||
ticketList: [], |
|||
productPrice: 0, |
|||
ticketPrice: 0, |
|||
product:"", |
|||
sku_id: '', |
|||
kjId: null, |
|||
gp_id: null, |
|||
showPrice: 0, |
|||
postFee: 0, |
|||
coupon:null, |
|||
select_allowance: false, |
|||
allowance_data: null, |
|||
allowance_price: 0, |
|||
}, |
|||
|
|||
/** |
|||
* 生命周期函数--监听页面加载 |
|||
*/ |
|||
onLoad: function (options) { |
|||
this.setData({ |
|||
goodsList: app.globalData.postProduct, |
|||
ticketList: app.globalData.list, |
|||
kjId: app.globalData.kjId, |
|||
gp_id: app.globalData.gp_id || app.globalData.team_id, |
|||
}) |
|||
console.log(app.globalData); |
|||
let price = 0, sku_id = []; |
|||
app.globalData.postProduct.map(item => { |
|||
if (!app.globalData.kjId && !this.data.gp_id) { |
|||
price = price + item.sku.price * item.productNum; |
|||
} |
|||
else if (this.data.gp_id) { |
|||
price = price + item.sku.event_price * item.productNum; |
|||
} |
|||
sku_id.push(item.sku.id) |
|||
}) |
|||
app.globalData.list.map(item => { |
|||
price = price + item.sku.price * item.num; |
|||
sku_id.push(item.sku.id) |
|||
}) |
|||
this.setData({ |
|||
showPrice: app.globalData.kjId ? 0 : price, |
|||
sku_id: sku_id.join(",") |
|||
}) |
|||
if (!this.data.kjId && !this.data.gp_id) { |
|||
this.couponCom = this.selectAllComponents("#coupon")[0]; |
|||
} |
|||
console.log(this.data.showPrice) |
|||
}, |
|||
order: function (){ |
|||
console.log(app.globalData.createDate); |
|||
app.globalData.createDate.coupon_id= this.data.coupon ? this.data.coupon.id : null; |
|||
let service = "order/create", postData = {data: JSON.stringify(app.globalData.createDate)} |
|||
commonApi.user_post(service, postData).then(res => { |
|||
|
|||
}) |
|||
}, |
|||
changePrice: function () { |
|||
let product = this.data.product, price = 0; |
|||
product.map(item => { |
|||
price = price + item.sku.price * item.productNum; |
|||
if (this.data.allowance_data && this.data.select_allowance && this.data.allowance_price) { |
|||
let spread_price = Number(this.data.allowance_data.discount_limit_price - this.data.allowance_data.user_used_price); |
|||
price -= this.data.allowance_price * item.productNum < spread_price ? this.data.allowance_price * item.productNum : spread_price |
|||
} |
|||
}) |
|||
if (this.data.coupon && this.data.showPrice != price) { |
|||
wx.showToast({ |
|||
title: '订单价格发生变化,请重新选择优惠券', |
|||
icon: 'none' |
|||
}) |
|||
app.globalData.couponInfo = null; |
|||
if (!this.data.kjId && !this.data.gp_id) { |
|||
this.couponCom.setNullCoupon() |
|||
} |
|||
this.setData({ |
|||
coupon: null |
|||
}) |
|||
} |
|||
this.setData({ |
|||
showPrice: app.globalData.kjId ? 0 : price |
|||
}) |
|||
}, |
|||
/** |
|||
* 生命周期函数--监听页面初次渲染完成 |
|||
*/ |
|||
onReady: function () { |
|||
|
|||
}, |
|||
inputRemark: function (e) { |
|||
app.globalData.createDate.product_list.map((item)=>{ |
|||
if (item.type.includes('post')) { |
|||
item.remark = e.detail.value; |
|||
} |
|||
}) |
|||
}, |
|||
/** |
|||
* 生命周期函数--监听页面显示 |
|||
*/ |
|||
onShow: function () { |
|||
this.setData({ |
|||
coupon: app.globalData.couponInfo |
|||
}) |
|||
}, |
|||
|
|||
/** |
|||
* 生命周期函数--监听页面隐藏 |
|||
*/ |
|||
onHide: function () { |
|||
|
|||
}, |
|||
|
|||
/** |
|||
* 生命周期函数--监听页面卸载 |
|||
*/ |
|||
onUnload: function () { |
|||
|
|||
}, |
|||
|
|||
/** |
|||
* 页面相关事件处理函数--监听用户下拉动作 |
|||
*/ |
|||
onPullDownRefresh: function () { |
|||
|
|||
}, |
|||
|
|||
/** |
|||
* 页面上拉触底事件的处理函数 |
|||
*/ |
|||
onReachBottom: function () { |
|||
|
|||
}, |
|||
|
|||
/** |
|||
* 用户点击右上角分享 |
|||
*/ |
|||
onShareAppMessage: function () { |
|||
|
|||
} |
|||
}) |
|||
@ -0,0 +1,6 @@ |
|||
{ |
|||
"usingComponents": { |
|||
"title":"/pages/component/TitleHeader", |
|||
"coupon":"../components/coupon/index" |
|||
} |
|||
} |
|||
@ -0,0 +1,63 @@ |
|||
<title title="订单列表"></title> |
|||
<view class="box" wx:if="{{goodsList.length != 0}}"> |
|||
<view wx:for="{{goodsList}}" wx:key="index"> |
|||
<view class="item-box"> |
|||
<view> |
|||
{{item.product.title}} |
|||
</view> |
|||
<view class="price"> |
|||
¥{{item.sku.price/100}} |
|||
</view> |
|||
</view> |
|||
<view class="item-box"> |
|||
<view> |
|||
{{item.sku.sku_name}} |
|||
</view> |
|||
<view> |
|||
X{{item.productNum}} |
|||
</view> |
|||
</view> |
|||
<view class="item-box"> |
|||
<view> |
|||
运费 |
|||
</view> |
|||
<view class="price"> |
|||
¥{{item.postFee/100 || 0}} |
|||
</view> |
|||
</view> |
|||
</view> |
|||
</view> |
|||
<view class="box" wx:if="{{ticketList.length != 0}}"> |
|||
<view wx:for="{{ticketList}}" wx:key="index"> |
|||
<view class="item-box"> |
|||
<view> |
|||
{{item.product.title}} |
|||
</view> |
|||
<view class="price"> |
|||
¥{{item.sku.price/100}} |
|||
</view> |
|||
</view> |
|||
<view class="item-box"> |
|||
<view> |
|||
{{item.sku.sku_name}} |
|||
</view> |
|||
<view> |
|||
X{{item.num}} |
|||
</view> |
|||
</view> |
|||
</view> |
|||
</view> |
|||
|
|||
<view class="box-title"> |
|||
<view style="flex-shrink:0">订单备注:</view> |
|||
<input type="text" bindinput="inputRemark" data-index="{{index}}" placeholder="选填"></input> |
|||
</view> |
|||
<coupon id="coupon" wx:if="{{!kjId && !gp_id && flag!='mix'}}" money="{{showPrice + postFee}}" sku="{{sku_id}}"></coupon> |
|||
|
|||
<view class="fixed-bottom"> |
|||
<view class="fixed-price-box"> |
|||
<text>合计:</text> |
|||
<text class="price">¥{{((showPrice + postFee - (coupon?coupon.activity.money:0))>0?(showPrice + postFee - (coupon?coupon.activity.money:0)):0)/100}}</text> |
|||
</view> |
|||
<view class="fixed-btn" bindtap="order">下一步</view> |
|||
</view> |
|||
@ -0,0 +1,64 @@ |
|||
page{ |
|||
background: #f5f5f5; |
|||
} |
|||
.box{ |
|||
margin: 30rpx 25rpx; |
|||
background: white; |
|||
padding: 20rpx; |
|||
} |
|||
.item-box{ |
|||
display: flex; |
|||
justify-content: space-between; |
|||
padding: 10rpx; |
|||
} |
|||
.price{ |
|||
color: #D62828; |
|||
} |
|||
.fixed-bottom { |
|||
position: fixed; |
|||
left: 0; |
|||
right: 0; |
|||
bottom: 0; |
|||
height: 113rpx; |
|||
display: flex; |
|||
align-items: center; |
|||
justify-content: space-between; |
|||
background: white; |
|||
z-index: 1; |
|||
box-shadow: 0px 0px 16rpx 0px rgba(6, 0, 1, 0.1); |
|||
} |
|||
.fixed-btn { |
|||
width: 320rpx; |
|||
line-height: 113rpx; |
|||
background: #D62828; |
|||
color: #fff; |
|||
text-align: center; |
|||
font-size: 36rpx; |
|||
font-weight: 500; |
|||
} |
|||
|
|||
.fixed-price-box { |
|||
margin-left: 25rpx; |
|||
flex-shrink: 0; |
|||
font-size: 29rpx; |
|||
color: #333; |
|||
font-weight: 500; |
|||
} |
|||
|
|||
.fixed-price-box .price { |
|||
color: #D62828; |
|||
font-size: 36rpx; |
|||
margin-left: 10rpx; |
|||
} |
|||
.box-title { |
|||
height: 113rpx; |
|||
padding: 0 20rpx; |
|||
font-size: 31rpx; |
|||
color: #000; |
|||
font-weight: 500; |
|||
display: flex; |
|||
align-items: center; |
|||
background-color: #fff; |
|||
margin: 30rpx 25rpx; |
|||
|
|||
} |
|||
Loading…
Reference in new issue