Browse Source

门票类产品支持购物车

master
chenkainan 4 years ago
parent
commit
a4aed582a7
  1. 6
      app.js
  2. 3
      app.json
  3. 16
      pages/component/TitleHeader.js
  4. 2
      pages/info/postProductInfo/index.js
  5. 42
      pages/info/sceneProductInfo/index.js
  6. 86
      pages/order/orderList/index.js
  7. 5
      pages/order/orderList/index.json
  8. 57
      pages/order/orderList/index.wxml
  9. 53
      pages/order/orderList/index.wxss
  10. 10
      pages/order/postOrder/index.js
  11. 2
      pages/order/postOrder/index.wxml
  12. 41
      pages/order/scene/index.js
  13. 2
      pages/order/scene/index.wxml
  14. 35
      pages/user/cartlist/list.js
  15. 14
      project.private.config.json

6
app.js

@ -143,6 +143,12 @@ App({
safeBottom:0, safeBottom:0,
product:null, product:null,
postProduct:[], postProduct:[],
ticketProduct:[],
index: 0,
createDate: null,
list: [],
productPrice: 0,
ticketPrice: 0,
productState:{ productState:{
"WAIT_PAYMENT":"待付款", "WAIT_PAYMENT":"待付款",
"WAIT_CONFIRM":"待确认", "WAIT_CONFIRM":"待确认",

3
app.json

@ -175,7 +175,8 @@
"pages/group/info/index", "pages/group/info/index",
"pages/culture/index", "pages/culture/index",
"pages/culture/info/index", "pages/culture/info/index",
"pages/user/logout/index" "pages/user/logout/index",
"pages/order/orderList/index"
], ],
"requiredPrivateInfos": [ "requiredPrivateInfos": [
"getLocation", "getLocation",

16
pages/component/TitleHeader.js

@ -49,6 +49,7 @@ Component({
*/ */
methods: { methods: {
back:function(){ back:function(){
app.globalData.index = app.globalData.index -1
// if(this.properties.clickid){ // if(this.properties.clickid){
// wx.uma.trackEvent(this.properties.clickid) // wx.uma.trackEvent(this.properties.clickid)
// } // }
@ -66,6 +67,21 @@ Component({
}) })
} }
} }
else if (pages[pages.length-1].route.indexOf('cartlist') != -1){
wx.switchTab({
url: '/pages/user/user'
})
}
else if (pages[pages.length-1].route.indexOf('orderList') != -1){
wx.navigateTo({
url: '/pages/user/cartlist/list'
})
}
else if (pages[pages.length-1].route.indexOf('scene') != -1){
wx.reLaunch({
url: "/pages/user/cartlist/list"
})
}
else if (pages.length>1){ else if (pages.length>1){
wx.navigateBack({ wx.navigateBack({
delta: 1 delta: 1

2
pages/info/postProductInfo/index.js

@ -243,6 +243,8 @@ Page({
}) })
}, },
order: function () { order: function () {
app.globalData.postProduct = []
app.globalData.list = []
if (this.data.skuFlag == 'order') { if (this.data.skuFlag == 'order') {
util.pagePoint({ util.pagePoint({
event: 'product_order', event: 'product_order',

42
pages/info/sceneProductInfo/index.js

@ -203,8 +203,38 @@ Page({
bookingInfo: null bookingInfo: null
}) })
}, },
// order: function(e){
// console.log(e)
// if (e.currentTarget.dataset.disable == 1) return;
// util.pagePoint({
// event: 'scene_order',
// param: {
// type: this.data.info.type,
// id: this.data.info.id
// }
// }, 1)
// wx.setStorageSync('login_from', 'scene_order_login')
// wx.setStorageSync('order_from', 'scene_order_submit')
// app.globalData.couponInfo = null;
// app.globalData.retailId = this.data.retailId;
// // let sku = e.currentTarget.dataset.sku,product = e.currentTarget.dataset.product;
// app.globalData.product = e.currentTarget.dataset;
// wx.navigateTo({
// url: '/pages/order/scene/index',
// })
// },
selectSku: function (e) {
console.log(e)
let index = e.currentTarget.dataset.index;
this.setData({
skuIndex: index
})
},
order: function (e) { order: function (e) {
console.log(this.data.info,this.data.skuFlag) console.log(e,e.currentTarget.dataset.product.sku[this.data.skuIndex])
// console.log(this.data.info,this.data.skuFlag)
app.globalData.postProduct = []
app.globalData.list = []
if (this.data.skuFlag == 'order'){ if (this.data.skuFlag == 'order'){
if (e.currentTarget.dataset.disable == 1) return; if (e.currentTarget.dataset.disable == 1) return;
util.pagePoint({ util.pagePoint({
@ -219,7 +249,9 @@ Page({
app.globalData.couponInfo = null; app.globalData.couponInfo = null;
app.globalData.retailId = this.data.retailId; app.globalData.retailId = this.data.retailId;
// let sku = e.currentTarget.dataset.sku,product = e.currentTarget.dataset.product; // let sku = e.currentTarget.dataset.sku,product = e.currentTarget.dataset.product;
app.globalData.product = e.currentTarget.dataset; let sku = {sku:e.currentTarget.dataset.product.sku[this.data.skuIndex]},product = {product: e.currentTarget.dataset.product}
app.globalData.product = {...sku,...product}
// app.globalData.product = e.currentTarget.dataset;
wx.navigateTo({ wx.navigateTo({
url: '/pages/order/scene/index', url: '/pages/order/scene/index',
}) })
@ -579,12 +611,6 @@ Page({
skuFlag: 'order' skuFlag: 'order'
}) })
}, },
selectSku: function (e) {
let index = e.currentTarget.dataset.index;
this.setData({
skuIndex: index
})
},
/** /**
* 生命周期函数--监听页面初次渲染完成 * 生命周期函数--监听页面初次渲染完成

86
pages/order/orderList/index.js

@ -0,0 +1,86 @@
// pages/order/comment/index.js
let app = getApp()
import commonApi from "../../../utils/https/common"
Page({
/**
* 页面的初始数据
*/
data: {
goodsList: [],
ticketList: [],
productPrice: 0,
ticketPrice: 0
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
console.log(app.globalData.kjId)
this.setData({
goodsList: app.globalData.postProduct,
ticketList: app.globalData.list
})
console.log(this.data.goodsList,this.data.ticketList)
},
order: function (){
let service = "order/create", postData = {data: JSON.stringify(app.globalData.createDate)}
commonApi.user_post(service, postData).then(res => {
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
this.setData({
productPrice: app.globalData.productPrice,
ticketPrice: app.globalData.ticketPrice
})
console.log(app.globalData.productPrice,app.globalData.ticketPrice)
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})

5
pages/order/orderList/index.json

@ -0,0 +1,5 @@
{
"usingComponents": {
"title":"/pages/component/TitleHeader"
}
}

57
pages/order/orderList/index.wxml

@ -0,0 +1,57 @@
<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.product.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="fixed-bottom">
<view class="fixed-price-box">
<text>合计:</text>
<text class="price">¥{{productPrice + ticketPrice}}</text>
</view>
<view class="fixed-btn" bindtap="order">下一步</view>
</view>

53
pages/order/orderList/index.wxss

@ -0,0 +1,53 @@
page{
background: #f5f5f5;
}
.box{
width: 700rpx;
margin: 30rpx auto;
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;
}

10
pages/order/postOrder/index.js

@ -51,6 +51,7 @@ Page({
if (!this.data.kjId && !this.data.gp_id) { if (!this.data.kjId && !this.data.gp_id) {
this.couponCom = this.selectAllComponents("#coupon")[0]; this.couponCom = this.selectAllComponents("#coupon")[0];
} }
console.log(this.data.showPrice)
}, },
changeAllowance: function () { changeAllowance: function () {
this.setData({ this.setData({
@ -161,6 +162,7 @@ Page({
if (app.globalData.category_id) { if (app.globalData.category_id) {
data.category_id = app.globalData.category_id; data.category_id = app.globalData.category_id;
} }
if(!app.globalData.list){
commonApi.user_post("order/create", { commonApi.user_post("order/create", {
data: JSON.stringify(data) data: JSON.stringify(data)
}).then(res => { }).then(res => {
@ -178,6 +180,14 @@ Page({
}) })
this.onLoad({}); this.onLoad({});
}) })
}else{
app.globalData.productPrice = (this.data.showPrice + this.data.postFee - (this.data.coupon?this.data.coupon.activity.money:0))/100;
app.globalData.createDate = data
console.log(app.globalData.createDate)
wx.navigateTo({
url: '/pages/order/scene/index',
})
}
}, },
getPostFee: function () { getPostFee: function () {
if (!this.data.address) return; if (!this.data.address) return;

2
pages/order/postOrder/index.wxml

@ -54,7 +54,7 @@
class="price">¥{{((showPrice + postFee - (coupon?coupon.activity.money:0))>0?(showPrice + postFee - (coupon?coupon.activity.money:0)):0)/100}}</text> class="price">¥{{((showPrice + postFee - (coupon?coupon.activity.money:0))>0?(showPrice + postFee - (coupon?coupon.activity.money:0)):0)/100}}</text>
</view> </view>
<view class="fixed-price-box" wx:else><text>合计:</text><text class="price">¥{{postFee?(0+postFee)/100:0}}</text></view> <view class="fixed-price-box" wx:else><text>合计:</text><text class="price">¥{{postFee?(0+postFee)/100:0}}</text></view>
<view class="fixed-btn" bindtap="order">提交订单</view> <view class="fixed-btn" bindtap="order">下一步</view>
</view> </view>
<view class="mask mask-allowance" wx:if="{{showAllowance}}"> <view class="mask mask-allowance" wx:if="{{showAllowance}}">
<view bindtap="changeAllowance" class="mask-bg"></view> <view bindtap="changeAllowance" class="mask-bg"></view>

41
pages/order/scene/index.js

@ -26,12 +26,14 @@ Page({
showAllowance: false, showAllowance: false,
allowance_data: null, allowance_data: null,
allowance_price: 0, allowance_price: 0,
pIndex: 0
}, },
/** /**
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad: function (options) { onLoad: function (options) {
console.log(app.globalData.product)
this.setData({ this.setData({
type: options.type, type: options.type,
kjId: app.globalData.kjId, kjId: app.globalData.kjId,
@ -46,6 +48,10 @@ Page({
this.setData({ this.setData({
productNum: app.globalData.product.productNum < 1 ? 1 : app.globalData.product.productNum productNum: app.globalData.product.productNum < 1 ? 1 : app.globalData.product.productNum
}) })
}else{
this.setData({
productNum: app.globalData.product.num < 1 ? 1 : app.globalData.product.num
})
} }
this.setData({ this.setData({
product: app.globalData.product, product: app.globalData.product,
@ -96,6 +102,7 @@ Page({
this.setData({ this.setData({
productNum: this.data.productNum + 1 productNum: this.data.productNum + 1
}) })
this.data.product.num = this.data.productNum
this.changePrice() this.changePrice()
}, },
minus: function () { minus: function () {
@ -114,6 +121,7 @@ Page({
productNum: (this.data.productNum - 1), productNum: (this.data.productNum - 1),
coupon: null coupon: null
}) })
this.data.product.num = this.data.productNum
this.changePrice() this.changePrice()
}, },
changeDate: function (e) { changeDate: function (e) {
@ -163,6 +171,7 @@ Page({
this.setData({ this.setData({
singlePrice: app.globalData.kjId ? 0 : price singlePrice: app.globalData.kjId ? 0 : price
}) })
}, },
order: function () { order: function () {
let linkmanList = this.data.linkmanList, productNum = this.data.productNum, date = this.data.date, time = this.data.time, remark = this.data.remark, product = this.data.product; let linkmanList = this.data.linkmanList, productNum = this.data.productNum, date = this.data.date, time = this.data.time, remark = this.data.remark, product = this.data.product;
@ -238,7 +247,30 @@ Page({
postData.team_name = this.data.groupName postData.team_name = this.data.groupName
postData.type = 1; postData.type = 1;
} }
app.globalData.list[app.globalData.index] = this.data.product
app.globalData.ticketPrice += (this.data.singlePrice * this.data.productNum - (this.data.coupon?this.data.coupon.activity.money:0))/100;
if(app.globalData.list.length > app.globalData.index + 1){
if(app.globalData.createDate){
app.globalData.createDate.product_list.push(data.product_list[0])
}else{
app.globalData.createDate = data
}
app.globalData.index = app.globalData.index + 1
app.globalData.product = app.globalData.list[app.globalData.index]
wx.navigateTo({
url: '/pages/order/scene/index',
})
return
}else{
console.log(app.globalData.list.length,app.globalData.postProduct)
if(app.globalData.list.length > 1 || app.globalData.postProduct.length>0){
if(app.globalData.createDate){
app.globalData.createDate.product_list.push(data.product_list[0])
}
wx.redirectTo({
url: '/pages/order/orderList/index'
})
}else{
commonApi.user_post(service, postData).then(res => { commonApi.user_post(service, postData).then(res => {
if (app.globalData.kjId) { if (app.globalData.kjId) {
this.setData({ this.setData({
@ -259,6 +291,8 @@ Page({
}) })
} }
}) })
}
}
}, },
// 活动预约 // 活动预约
activityOrder: function () { activityOrder: function () {
@ -311,6 +345,11 @@ Page({
* 生命周期函数--监听页面显示 * 生命周期函数--监听页面显示
*/ */
onShow: function () { onShow: function () {
console.log(app.globalData.list,app.globalData.product,app.globalData.list.length)
if(app.globalData.list.length != 0){
app.globalData.product = app.globalData.list[app.globalData.index]
}
console.log(app.globalData.product)
if (!this.data.isLogin) { if (!this.data.isLogin) {
commonApi.user_post("token/check").then(res => { commonApi.user_post("token/check").then(res => {
if (res.code == 1) { if (res.code == 1) {

2
pages/order/scene/index.wxml

@ -50,7 +50,7 @@
<view class="fixed-price-box" wx:else><text>合计:</text><text <view class="fixed-price-box" wx:else><text>合计:</text><text
class="price">¥{{((singlePrice * productNum - (coupon?coupon.activity.money:0))>0?(singlePrice * productNum - (coupon?coupon.activity.money:0)):0)/ 100}}</text> class="price">¥{{((singlePrice * productNum - (coupon?coupon.activity.money:0))>0?(singlePrice * productNum - (coupon?coupon.activity.money:0)):0)/ 100}}</text>
</view> </view>
<view class="fixed-btn" bindtap="order">提交订单</view> <view class="fixed-btn" bindtap="order">下一步</view>
</view> </view>
<view class="fixed-bottom yuyue-box" wx:else> <view class="fixed-bottom yuyue-box" wx:else>
<view class="fixed-btn yuyue-btn" bindtap="order" wx:if="{{type=='museum'}}">立即预约</view> <view class="fixed-btn yuyue-btn" bindtap="order" wx:if="{{type=='museum'}}">立即预约</view>

35
pages/user/cartlist/list.js

@ -16,7 +16,8 @@ Page({
menuWidth:width - rect.right + rect.width + 6, menuWidth:width - rect.right + rect.width + 6,
list:[], list:[],
allChecked:false, allChecked:false,
allPrice:0 allPrice:0,
productType:''
}, },
/** /**
@ -108,22 +109,33 @@ Page({
}) })
}, },
order:function(){ order:function(){
console.log(this.data.productType)
app.globalData.couponInfo = null; app.globalData.couponInfo = null;
util.pagePoint({ util.pagePoint({
event:'cart_order' event:'cart_order'
},1) },1)
let list = this.data.list,price=0,product=[]; let list = this.data.list,price=0,product=[],product1=[]
list.map(item=>{ list.map(item=>{
if(item.checked){ if(item.checked){
item.product.type="post"; console.log(item)
// item.product.type="post";
if(item.product.type == 'post'){
product.push({ product.push({
product:item.product, product:item.product,
sku:item.sku, sku:item.sku,
productNum:item.num productNum:item.num
}) })
}else{
product1.push(item)
app.globalData.list = product1
}
if(item.product.type.includes('post')){
this.data.productType = 'post'
}
console.log(this.data.productType)
} }
}) })
if(product.length==0) { if(product.length==0 && product1.length==0) {
wx.showToast({ wx.showToast({
title: '请先选择产品', title: '请先选择产品',
icon: 'none' icon: 'none'
@ -131,9 +143,18 @@ Page({
return; return;
} }
app.globalData.postProduct = product; app.globalData.postProduct = product;
if(app.globalData.list){
app.globalData.product = app.globalData.list[app.globalData.index]
}
if(this.data.productType == 'post'){
wx.navigateTo({ wx.navigateTo({
url: '/pages/order/postOrder/index?from=cart', url: '/pages/order/postOrder/index?from=cart',
}) })
}else{
wx.navigateTo({
url: '/pages/order/scene/index',
})
}
}, },
touchStart(e){//移动前点击的位置 touchStart(e){//移动前点击的位置
console.log(e) console.log(e)
@ -217,6 +238,12 @@ Page({
util.pagePoint({ util.pagePoint({
event:'cart_view' event:'cart_view'
},1) },1)
app.globalData.list = null
app.globalData.createDate = null
app.globalData.index = 0
app.globalData.productPrice = 0
app.globalData.ticketPrice = 0
this.data.productType = ''
}, },
/** /**

14
project.private.config.json

@ -6,9 +6,10 @@
"miniprogram": { "miniprogram": {
"list": [ "list": [
{ {
"name": "精彩回顾", "name": "首页",
"pathName": "pages/pbService/activity/index", "pathName": "pages/index/index",
"query": "id=4407", "query": "",
"launchMode": "default",
"scene": null "scene": null
}, },
{ {
@ -48,9 +49,10 @@
"scene": null "scene": null
}, },
{ {
"name": "pages/pbService/web/index", "name": "pages/order/orderList/index",
"pathName": "pages/pbService/web/index", "pathName": "pages/order/orderList/index",
"query": "id=10973", "query": "",
"launchMode": "default",
"scene": null "scene": null
}, },
{ {

Loading…
Cancel
Save