diff --git a/app.js b/app.js index c5cd544..aff7f56 100644 --- a/app.js +++ b/app.js @@ -143,6 +143,12 @@ App({ safeBottom:0, product:null, postProduct:[], + ticketProduct:[], + index: 0, + createDate: null, + list: [], + productPrice: 0, + ticketPrice: 0, productState:{ "WAIT_PAYMENT":"待付款", "WAIT_CONFIRM":"待确认", diff --git a/app.json b/app.json index 01f9bfb..b4201fa 100644 --- a/app.json +++ b/app.json @@ -176,6 +176,7 @@ "pages/culture/index", "pages/culture/info/index", "pages/user/logout/index", + "pages/order/orderList/index", "pages/user/linkman/add/index", "pages/user/address/add/index", "pages/user/linkman/index" diff --git a/app.wxss b/app.wxss index 960acbe..6469318 100644 --- a/app.wxss +++ b/app.wxss @@ -31,7 +31,7 @@ page{ position: relative; z-index: 1; width: 80%; - max-height: 100%; + max-height: 1000rpx; background: white; border-radius: 12rpx; overflow-y: auto; diff --git a/pages/component/TitleHeader.js b/pages/component/TitleHeader.js index eba9f53..06a72a9 100644 --- a/pages/component/TitleHeader.js +++ b/pages/component/TitleHeader.js @@ -53,6 +53,9 @@ Component({ // wx.uma.trackEvent(this.properties.clickid) // } const pages = getCurrentPages(); + if(pages[pages.length-1].route.indexOf('linkman/add')==-1){ + app.globalData.index = app.globalData.index -1 + } if(pages[pages.length-1].route.indexOf('login')!=-1 || pages[pages.length-1].route.indexOf('bindTel')!=-1){ // 如果是登录页面的返回需要返回两层 if(pages.length>2){ @@ -66,6 +69,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){ wx.navigateBack({ delta: 1 diff --git a/pages/index/index.js b/pages/index/index.js index 9e70108..bfadf57 100644 --- a/pages/index/index.js +++ b/pages/index/index.js @@ -248,6 +248,7 @@ Page({ util.gotoDetail(item) }, gotoPath: function (e) { + console.log(e) if (e.currentTarget.dataset.event) { this.pagePoint({ event: e.currentTarget.dataset.event }, 1) } diff --git a/pages/info/museumInfo/index.wxss b/pages/info/museumInfo/index.wxss index 2b8e000..5b7184c 100644 --- a/pages/info/museumInfo/index.wxss +++ b/pages/info/museumInfo/index.wxss @@ -70,7 +70,7 @@ display: flex; align-items: center; justify-content: space-around; - z-index: 2; + z-index: 3; } .fixed-btn .btn { diff --git a/pages/info/postProductInfo/index.js b/pages/info/postProductInfo/index.js index f5a2632..303fc76 100644 --- a/pages/info/postProductInfo/index.js +++ b/pages/info/postProductInfo/index.js @@ -45,6 +45,7 @@ Page({ }) // 获取购物车按钮的位置 wx.createSelectorQuery().select('#cart').boundingClientRect(function (res) { + console.log(res) that.setData({ cartTop: res.top }) @@ -242,6 +243,8 @@ Page({ }) }, order: function () { + app.globalData.postProduct = [] + app.globalData.list = [] if (this.data.skuFlag == 'order') { util.pagePoint({ event: 'product_order', diff --git a/pages/info/postProductInfo/index.wxml b/pages/info/postProductInfo/index.wxml index 595326b..7166da8 100644 --- a/pages/info/postProductInfo/index.wxml +++ b/pages/info/postProductInfo/index.wxml @@ -3,7 +3,7 @@ + class="headimg{{aniSkuIndex==index?' active':''}}" src="{{info.headimg}}" mode="aspectFill"> diff --git a/pages/info/sceneProductInfo/index.js b/pages/info/sceneProductInfo/index.js index 0e12985..c3c5a2d 100644 --- a/pages/info/sceneProductInfo/index.js +++ b/pages/info/sceneProductInfo/index.js @@ -24,6 +24,14 @@ Page({ showShareFlag: false, showAllowance: false, allowance_data:null, + //购物车数量 + producNum: 1, + skuIndex: 0, + aniSkuIndex: -1, + cartCount: 0, + cartImgInfo: null, + cartTop: 0, + top: 0 }, /** @@ -155,7 +163,6 @@ Page({ scene_id: id }).then(res => { if (res.code == 1) { - console.log(isLike) wx.showToast({ title: '操作成功', }) @@ -196,25 +203,96 @@ Page({ bookingInfo: null }) }, - order: function (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', + // 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) { + 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 (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; + 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({ + url: '/pages/order/scene/index', + }) + }else { + commonApi.user_post("cart/add_sku", { + sku_id: this.data.info.product[0].sku[this.data.skuIndex].id, + num: this.data.producNum + }).then(res => { + if (res.code == 1) { + commonApi.user_post('cart/get_list', {}).then(res => { + this.setData({ + cartCount: res.data.length + }) + }) + // 加动效 + console.log(this.data.skuIndex) + this.setData({ + skuFlag: null, + aniSkuIndex: this.data.skuIndex, + cartImgInfo: null + }) + setTimeout(() => { + this.setData({ + aniSkuIndex: -1 + }) + wx.showModal({ + title: "提示", + content: "去购物车结算?", + success: function (res) { + if (res.confirm) { + wx.navigateTo({ + url: '/pages/user/cartlist/list', + }) + } + } + }) + }, 650) + } + }) + } + }, pagePoint: function (e) { util.pagePoint({ event: e.currentTarget.dataset.event, @@ -480,6 +558,59 @@ Page({ ctx.fillText(row[b], x, y + b * 40 * ratio, canvasWidth); } }, + //加入购物车 + showCart: function () { + console.log(this.data) + if (this.data.info.product[0].sku.length == 0) { + wx.showToast({ + title: '该产品未设置规格,不能加购', + icon: 'none' + }) + return; + } + this.setData({ + skuFlag: "cart" + }) + let that = this + wx.createSelectorQuery().select('#skuImg').boundingClientRect(function (res) { + console.log(res) + that.setData({ + cartImgInfo: 'top:' + res.top + 'px;left:' + res.left + 'px;' + }) + }).exec() + + }, + hideSku: function () { + this.setData({ + skuFlag: null, + cartImgInfo: null + }) + }, + //加减数量 + minus: function () { + if (this.data.producNum == 1) return; + this.setData({ + producNum: this.data.producNum - 1 + }) + }, + add: function () { + this.setData({ + producNum: this.data.producNum + 1 + }) + }, + //立即预定 + showOrder: function () { + if (this.data.info.product[0].sku.length == 0) { + wx.showToast({ + title: '该产品未设置规格,不能购买', + icon: 'none' + }) + return; + } + this.setData({ + skuFlag: 'order' + }) + }, /** * 生命周期函数--监听页面初次渲染完成 @@ -501,6 +632,12 @@ Page({ * 生命周期函数--监听页面显示 */ onShow: function () { + commonApi.user_post('cart/get_list', {}).then(res => { + console.log(res,res.data) + this.setData({ + cartCount: res.data.length + }) + }) if (!wx.getStorageSync('jstrip_token')) { return; } diff --git a/pages/info/sceneProductInfo/index.wxml b/pages/info/sceneProductInfo/index.wxml index 678e2ba..a2d5f8d 100644 --- a/pages/info/sceneProductInfo/index.wxml +++ b/pages/info/sceneProductInfo/index.wxml @@ -1,7 +1,10 @@ + - + + + + + + + + + 客服 + + + + 收藏 + + + + 加入购物车 + 立即预订 + 该商品已下架 + + + + + + {{cartCount}} + + + + + + + + + {{info.product[0].sku[skuIndex].price/100}} + + 补贴价:¥{{ (1 - allowance_data.discount_rate / 100) * info.sku[skuIndex].price / 100 }} + + 已选择:{{info.product[0].sku[skuIndex].sku_name}} + + + + {{item.sku_name}} + + + 数量 + + {{producNum}} + + + + + {{skuFlag=='cart'?'确认':'立即购买'}} + + 该商品已下架 diff --git a/pages/info/sceneProductInfo/index.wxss b/pages/info/sceneProductInfo/index.wxss index 08e01c8..bac3e07 100644 --- a/pages/info/sceneProductInfo/index.wxss +++ b/pages/info/sceneProductInfo/index.wxss @@ -333,7 +333,7 @@ page { font-size: 28rpx; } -.icon-xin, +/* .icon-xin, .icon-shoucang { position: absolute; right: 100rpx; @@ -346,7 +346,7 @@ page { color: #fff; font-size: 36rpx; z-index: 1; -} +} */ .icon-shoucang { color: #D62828; @@ -382,7 +382,6 @@ page { margin-left: 10rpx; } - .mask-content { position: absolute; left: 0; @@ -536,4 +535,264 @@ page { .mask-allowance .mask-content .rule-title { text-align: center; margin-bottom: 20rpx; +} + +.fixed-bottom { + position: fixed; + left: 0; + right: 0; + bottom: 0; + height: 140rpx; + background: white; + display: flex; + align-items: center; + box-shadow: 0px 0px 16rpx 0px rgba(6, 0, 1, 0.1); + padding: 0 40rpx; + color: #666666; + font-size: 23rpx; + justify-content: space-between; + text-align: center; +} + +.fixed-bottom .iconfont { + font-size: 34rpx; + line-height: 40rpx; +} + +.btns { + color: #fff; + font-size: 32rpx; + font-weight: 500; + border-radius: 39rpx; + text-align: center; + display: flex; + align-items: center; + justify-content: center; +} + +.btns .btn { + width: 216rpx; + line-height: 78rpx; + background: #D62828; +} + +.btns .btn:nth-child(1) { + margin-right: 3rpx; + border-radius: 39rpx 0 0 39rpx; +} + +.btns .btn:nth-child(2) { + border-radius: 0 39rpx 39rpx 0; +} + +.btns .btn.disable { + background: #ccc; +} + +.mask-content { + position: absolute; + left: 0; + right: 0; + bottom: 0; + width: 100%; +} + +.mask-content .icon-close { + position: absolute; + right: 40rpx; + top: 40rpx; +} + +.sku-info-box { + margin: 50rpx 40rpx; + display: flex; + justify-content: space-between; +} + +.sku-info-box image { + width: 218rpx; + height: 180rpx; + border-radius: 13rpx; + display: block; + margin-right: 40rpx; + flex-shrink: 0; +} + +.sku-info { + flex: 1; +} + +.sku-price { + font-size: 40rpx; + font-weight: 500; + color: #D62828; + margin: 20rpx 0; + display: flex; + justify-content: flex-start; + align-items: center; +} + +.sku-price::before { + content: "¥"; + font-weight: 400; + font-size: 27rpx; + vertical-align: baseline; +} + +.sku-price view { + font-size: 24rpx; + color: #FFFFFF; + background-color: #D62828; + border-radius: 22rpx; + line-height: 44rpx; + margin-left: 7rpx; + padding: 0 20rpx; +} + +.sku-name { + font-size: 27rpx; + color: #666666; +} + +.sku-names { + display: flex; + font-size: 29rpx; + color: #333; + margin: 0 40rpx; + text-align: center; + flex-wrap: wrap; + margin-bottom: 20rpx; +} + +.sku-name-item { + background: #EFEFEF; + border: 1rpx solid #EFEFEF; + width: 318rpx; + line-height: 77rpx; + border-radius: 14rpx; + margin-bottom: 25rpx; + margin-right: 10rpx; +} + +.sku-name-item:nth-child(2n) { + margin-right: 0; +} + +.sku-name-item.active { + color: #0B898E; + border-color: #0B898E; + background: rgba(11, 137, 142, 0.1); +} + +.number-box { + display: flex; + align-items: center; + border-top: 1rpx solid #ccc; + justify-content: space-between; + margin: 0 40rpx; + padding: 40rpx 0; +} + +.number-box text { + flex: 1; + font-size: 29rpx; + color: #333; +} + +.number-box view { + border: 1rpx solid #666; + border-radius: 7rpx; + text-align: center; + width: 67rpx; + line-height: 67rpx; + font-size: 33rpx; + color: #000; +} + +.number-box view.disable { + border-color: #ccc; + color: #999; +} + +.number-box view.number { + width: 94rpx; + margin: 0 15rpx; +} + +.btn-box { + height: 138rpx; + background: #FFFFFF; + box-shadow: 0px 0px 16rpx 0px rgba(6, 0, 1, 0.1); + display: flex; + align-items: center; + justify-content: center; + position: fixed; + left: 0; + right: 0; + bottom: 0; +} + +.mask-btn { + width: 670rpx; + line-height: 78rpx; + background: #D62828; + border-radius: 39rpx; + color: #fff; + text-align: center; + font-size: 33rpx; + font-weight: 500; +} + +.mask-btn.disable { + background: #ccc; +} + +/* 购物车 */ +.cart-box { + position: fixed; + display: flex; + align-items: center; + justify-content: center; + width: 80rpx; + height: 80rpx; + background: #FFFFFF; + box-shadow: 0px 0px 20rpx 0px rgba(0, 0, 0, 0.2); + border-radius: 50%; + right: 20rpx; + bottom: 166rpx; +} + +.cart-box image { + display: block; + width: 49rpx; +} + +.cart-num { + width: 26rpx; + border: 1rpx solid; + border-radius: 50%; + line-height: 26rpx; + text-align: center; + font-size: 23rpx; + color: #D20000; + position: absolute; + right: -2rpx; + top: -5rpx; +} + +.headimg { + position: fixed; + z-index: 3; + left: -218rpx; + width: 218rpx; + height: 180rpx; + top: 0; +} + +.headimg.active { + transition: left .6s linear, top .6s cubic-bezier(0.5, -0.5, 1, 1), width .6s ease, height .6s ease; + width: 80rpx; + height: 80rpx; + left: 650rpx; + border-radius: 50%; } \ No newline at end of file diff --git a/pages/order/components/contact/index.js b/pages/order/components/contact/index.js index 709e918..57ad8ab 100644 --- a/pages/order/components/contact/index.js +++ b/pages/order/components/contact/index.js @@ -219,8 +219,10 @@ Component({ wx.hideLoading() }, selectIt:function(e){ + console.log(e,app.globalData.product) let item = e.currentTarget.dataset.item,linkmanList = this.data.linkmanList,num = 0,traveller_limit_num = this.properties.maxNum!=-1?this.properties.maxNum:(app.globalData.product.sku.sku_model && app.globalData.product.sku.sku_model.limit_type!=0?app.globalData.product.sku.sku_model.traveller_limit_num:-1); // 先计算出全部选中的出行人 + console.log(111) linkmanList.map(linkman=>{ if(linkman.selected==1){ num++; diff --git a/pages/order/orderList/index.js b/pages/order/orderList/index.js new file mode 100644 index 0000000..30cc91c --- /dev/null +++ b/pages/order/orderList/index.js @@ -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 () { + + } +}) \ No newline at end of file diff --git a/pages/order/orderList/index.json b/pages/order/orderList/index.json new file mode 100644 index 0000000..e7c6ece --- /dev/null +++ b/pages/order/orderList/index.json @@ -0,0 +1,6 @@ +{ + "usingComponents": { + "title":"/pages/component/TitleHeader", + "coupon":"../components/coupon/index" + } +} \ No newline at end of file diff --git a/pages/order/orderList/index.wxml b/pages/order/orderList/index.wxml new file mode 100644 index 0000000..fe628a0 --- /dev/null +++ b/pages/order/orderList/index.wxml @@ -0,0 +1,63 @@ + + + + + + {{item.product.title}} + + + ¥{{item.sku.price/100}} + + + + + {{item.sku.sku_name}} + + + X{{item.productNum}} + + + + + 运费 + + + ¥{{item.postFee/100 || 0}} + + + + + + + + + {{item.product.title}} + + + ¥{{item.sku.price/100}} + + + + + {{item.sku.sku_name}} + + + X{{item.num}} + + + + + + + 订单备注: + + + + + + + 合计: + ¥{{((showPrice + postFee - (coupon?coupon.activity.money:0))>0?(showPrice + postFee - (coupon?coupon.activity.money:0)):0)/100}} + + 下一步 + \ No newline at end of file diff --git a/pages/order/orderList/index.wxss b/pages/order/orderList/index.wxss new file mode 100644 index 0000000..42bac92 --- /dev/null +++ b/pages/order/orderList/index.wxss @@ -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; + +} \ No newline at end of file diff --git a/pages/order/postOrder/index.js b/pages/order/postOrder/index.js index 3ed318c..cb20054 100644 --- a/pages/order/postOrder/index.js +++ b/pages/order/postOrder/index.js @@ -21,6 +21,7 @@ Page({ allowance_data: null, allowance_price: 0, showAllowance: false, + flag:null, }, /** @@ -31,7 +32,8 @@ Page({ from: options.from, kjId: app.globalData.kjId, gp_id: app.globalData.gp_id || app.globalData.team_id, - prizeId: wx.getStorageSync('prizeId') + prizeId: wx.getStorageSync('prizeId'), + flag:options.flag }) let price = 0, sku_id = []; app.globalData.postProduct.map(item => { @@ -51,6 +53,7 @@ Page({ if (!this.data.kjId && !this.data.gp_id) { this.couponCom = this.selectAllComponents("#coupon")[0]; } + console.log(this.data.showPrice) }, changeAllowance: function () { this.setData({ @@ -142,7 +145,7 @@ Page({ let data = { source: "WECHATXCX", product_list: product_list, - coupon: this.data.coupon ? this.data.coupon.id : null, + coupon_id: this.data.coupon ? this.data.coupon.id : null, originate_order_id: this.data.kjId, gp_id: app.globalData.gp_id, team_id: app.globalData.team_id @@ -161,23 +164,32 @@ Page({ if (app.globalData.category_id) { data.category_id = app.globalData.category_id; } - commonApi.user_post("order/create", { - data: JSON.stringify(data) - }).then(res => { - if (app.globalData.kjId) { - app.globalData.kjId = null; - this.setData({ - kjId: null - }) - this.onLoad({}) - } - app.globalData.gp_id = null; - app.globalData.team_id = null; - this.setData({ - gp_id: null - }) - this.onLoad({}); - }) + if(!app.globalData.list){ + commonApi.user_post("order/create", { + data: JSON.stringify(data) + }).then(res => { + if (app.globalData.kjId) { + app.globalData.kjId = null; + this.setData({ + kjId: null + }) + this.onLoad({}) + } + app.globalData.gp_id = null; + app.globalData.team_id = null; + this.setData({ + gp_id: null + }) + 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?flag='+this.data.flag, + }) + } }, getPostFee: function () { if (!this.data.address) return; diff --git a/pages/order/postOrder/index.wxml b/pages/order/postOrder/index.wxml index ee1f9f6..6c3ab93 100644 --- a/pages/order/postOrder/index.wxml +++ b/pages/order/postOrder/index.wxml @@ -29,8 +29,8 @@ 运费 {{item.postFee?(item.postFee==0?'包邮':(item.postFee/100)):item.sku.sku_model.post_template_name}} - - 订单备注: + + 订单备注: @@ -47,14 +47,14 @@ - + 合计:¥{{((showPrice + postFee - (coupon?coupon.activity.money:0))>0?(showPrice + postFee - (coupon?coupon.activity.money:0)):0)/100}} 合计:¥{{postFee?(0+postFee)/100:0}} - 提交订单 + 下一步 diff --git a/pages/order/scene/index.js b/pages/order/scene/index.js index 2c1a7ff..34f21b9 100644 --- a/pages/order/scene/index.js +++ b/pages/order/scene/index.js @@ -26,17 +26,21 @@ Page({ showAllowance: false, allowance_data: null, allowance_price: 0, + pIndex: 0, + flag:null, }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { + console.log(app.globalData.product) this.setData({ type: options.type, kjId: app.globalData.kjId, gp_id: app.globalData.gp_id || app.globalData.team_id, - prizeId: wx.getStorageSync('prizeId') + prizeId: wx.getStorageSync('prizeId'), + flag:options.flag }) if (!app.globalData.product) { util.back(); @@ -46,7 +50,11 @@ Page({ this.setData({ 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({ product: app.globalData.product, singlePrice: this.data.gp_id ? app.globalData.product.sku.event_price : app.globalData.product.sku.price @@ -96,6 +104,7 @@ Page({ this.setData({ productNum: this.data.productNum + 1 }) + this.data.product.num = this.data.productNum this.changePrice() }, minus: function () { @@ -114,6 +123,7 @@ Page({ productNum: (this.data.productNum - 1), coupon: null }) + this.data.product.num = this.data.productNum this.changePrice() }, changeDate: function (e) { @@ -163,6 +173,7 @@ Page({ this.setData({ singlePrice: app.globalData.kjId ? 0 : price }) + }, 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; @@ -238,27 +249,52 @@ Page({ postData.team_name = this.data.groupName postData.type = 1; } - - commonApi.user_post(service, postData).then(res => { - if (app.globalData.kjId) { - this.setData({ - kjId: null - }); - app.globalData.kjId = null; - } - if (app.globalData.gp_id) { - this.setData({ - gp_id: null - }); - app.globalData.gp_id = null; - } - if (res.code == 1 && app.globalData.product.isGroup == 1) { - // 团购跳转到团购详情 - wx.navigateTo({ - url: '/pages/info/groupOrderInfo/index?id=' + res.data.order_id + '&from=order' - }) - } - }) + 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.redirectTo({ + url: '/pages/order/scene/index?flag='+ this.data.flag, + }) + 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 => { + if (app.globalData.kjId) { + this.setData({ + kjId: null + }); + app.globalData.kjId = null; + } + if (app.globalData.gp_id) { + this.setData({ + gp_id: null + }); + app.globalData.gp_id = null; + } + if (res.code == 1 && app.globalData.product.isGroup == 1) { + // 团购跳转到团购详情 + wx.navigateTo({ + url: '/pages/info/groupOrderInfo/index?id=' + res.data.order_id + '&from=order' + }) + } + }) + } + } }, // 活动预约 activityOrder: function () { @@ -311,6 +347,11 @@ Page({ * 生命周期函数--监听页面显示 */ onShow: function () { + console.log(this.data.flag); + if(app.globalData.list.length != 0){ + app.globalData.product = app.globalData.list[app.globalData.index] + } + console.log(app.globalData.product) if (!this.data.isLogin) { commonApi.user_post("token/check").then(res => { if (res.code == 1) { diff --git a/pages/order/scene/index.wxml b/pages/order/scene/index.wxml index 393ea3d..79c3f8d 100644 --- a/pages/order/scene/index.wxml +++ b/pages/order/scene/index.wxml @@ -34,10 +34,10 @@ - - + 订单备注 @@ -50,7 +50,7 @@ 合计:¥{{((singlePrice * productNum - (coupon?coupon.activity.money:0))>0?(singlePrice * productNum - (coupon?coupon.activity.money:0)):0)/ 100}} - 提交订单 + 下一步 立即预约 diff --git a/pages/user/cartlist/list.js b/pages/user/cartlist/list.js index e557389..d6a16bb 100644 --- a/pages/user/cartlist/list.js +++ b/pages/user/cartlist/list.js @@ -16,7 +16,9 @@ Page({ menuWidth:width - rect.right + rect.width + 6, list:[], allChecked:false, - allPrice:0 + allPrice:0, + productType:'', + flag:false,//判断订单是否同时有商品和票 }, /** @@ -25,9 +27,14 @@ Page({ onLoad: function (options) { this.getList(); }, + gotoDetail:function(e){ + console.log(e) + let item = e.currentTarget.dataset.item.product; + util.gotoDetail(item,1); + }, getList:function(){ commonApi.user_post("cart/get_list",{ - + // type: '1' }).then(res=>{ this.setData({ list:res.data @@ -107,28 +114,51 @@ Page({ util.pagePoint({ event:'cart_order' },1) - let list = this.data.list,price=0,product=[]; + let list = this.data.list,price=0,product=[],product1=[] list.map(item=>{ if(item.checked){ - item.product.type="post"; - product.push({ - product:item.product, - sku:item.sku, - productNum:item.num - }) + // item.product.type="post"; + if(item.product.type == 'post'){ + product.push({ + product:item.product, + sku:item.sku, + productNum:item.num + }) + }else{ + product1.push(item) + app.globalData.list = product1 + } + if(item.product.type.includes('post')){ + this.data.productType = 'post' + } } }) - if(product.length==0) { + if(product.length==0 && product1.length==0) { wx.showToast({ title: '请先选择产品', icon: 'none' }) return; } + if (product.length>0 && product1.length>0) { + this.setData({ + flag: 'mix' + }) + } app.globalData.postProduct = product; - wx.navigateTo({ - url: '/pages/order/postOrder/index?from=cart', - }) + if(app.globalData.list){ + app.globalData.product = app.globalData.list[app.globalData.index] + } + if(this.data.productType == 'post'){ + console.log(this.data.flag); + wx.navigateTo({ + url: '/pages/order/postOrder/index?from=cart&flag='+this.data.flag, + }) + }else{ + wx.navigateTo({ + url: '/pages/order/scene/index', + }) + } }, touchStart(e){//移动前点击的位置 console.log(e) @@ -212,6 +242,12 @@ Page({ util.pagePoint({ event:'cart_view' },1) + app.globalData.list = null + app.globalData.createDate = null + app.globalData.index = 0 + app.globalData.productPrice = 0 + app.globalData.ticketPrice = 0 + this.data.productType = '' }, /** diff --git a/pages/user/cartlist/list.wxml b/pages/user/cartlist/list.wxml index 21284c7..cc7a05c 100644 --- a/pages/user/cartlist/list.wxml +++ b/pages/user/cartlist/list.wxml @@ -5,7 +5,7 @@ - + {{item.product.title}} diff --git a/project.private.config.json b/project.private.config.json index 684d82c..d03db11 100644 --- a/project.private.config.json +++ b/project.private.config.json @@ -6,9 +6,10 @@ "miniprogram": { "list": [ { - "name": "精彩回顾", - "pathName": "pages/pbService/activity/index", - "query": "id=4407", + "name": "首页", + "pathName": "pages/index/index", + "query": "", + "launchMode": "default", "scene": null }, { @@ -48,9 +49,10 @@ "scene": null }, { - "name": "pages/pbService/web/index", - "pathName": "pages/pbService/web/index", - "query": "id=10973", + "name": "pages/order/orderList/index", + "pathName": "pages/order/orderList/index", + "query": "", + "launchMode": "default", "scene": null }, {