From 456f0e8461421ec99a9dd62497e00984dbc05f01 Mon Sep 17 00:00:00 2001 From: caichunsheng Date: Tue, 27 Sep 2022 18:22:54 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B9=BF=E5=91=8A,=E5=A4=9A=E4=BA=A7=E5=93=81?= =?UTF-8?q?=E5=B1=95=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/component/TitleHeader.js | 12 ++++--- pages/index/index.js | 10 +++--- pages/info/sceneProductInfo/index.js | 47 ++++++++++++++------------ pages/info/sceneProductInfo/index.wxml | 33 +++++++++++++++++- 4 files changed, 69 insertions(+), 33 deletions(-) diff --git a/pages/component/TitleHeader.js b/pages/component/TitleHeader.js index 06a72a9..1bb59d9 100644 --- a/pages/component/TitleHeader.js +++ b/pages/component/TitleHeader.js @@ -75,15 +75,17 @@ Component({ }) } else if (pages[pages.length-1].route.indexOf('orderList') != -1){ + console.log(11111); 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[pages.length-1].route.indexOf('scene') != -1){ + // console.log(22222); + // 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 0f20cc1..92c95fa 100644 --- a/pages/index/index.js +++ b/pages/index/index.js @@ -371,7 +371,7 @@ Page({ event: e.currentTarget.dataset.event }, 1) } - let url = e.currentTarget.dataset.url; + let url = e.currentTarget.dataset.tdata.url; app.globalData.weburl = url; wx.navigateTo({ url: "/pages/pbService/web/index" @@ -490,7 +490,7 @@ Page({ if ((item.tdata.url.indexOf('http://') != -1 || item.tdata.url.indexOf('https://') != -1) && item.tdata.url.indexOf('m.cloud.sz-trip.com') == -1) { // 外部h5 console.log(item.tdata) - app.globalData.weburl = item.tdata; + app.globalData.weburl = item.tdata.url; wx.navigateTo({ url: "/pages/pbService/web/index" }) @@ -510,7 +510,7 @@ Page({ url: url, }) } else { - app.globalData.weburl = item.tdata; + app.globalData.weburl = item.tdata.url; wx.navigateTo({ url: "/pages/pbService/web/index" }) @@ -655,7 +655,7 @@ Page({ if ((item.tdata.url.indexOf('http://') != -1 || item.tdata.url.indexOf('https://') != -1) && item.tdata.url.indexOf('m.cloud.sz-trip.com') == -1) { // 外部h5 console.log(item.tdata) - app.globalData.weburl = item.tdata; + app.globalData.weburl = item.tdata.url; wx.navigateTo({ url: "/pages/pbService/web/index" }) @@ -675,7 +675,7 @@ Page({ url: url, }) } else { - app.globalData.weburl = item.tdata; + app.globalData.weburl = item.tdata.url; wx.navigateTo({ url: "/pages/pbService/web/index" }) diff --git a/pages/info/sceneProductInfo/index.js b/pages/info/sceneProductInfo/index.js index 41e4c81..0b8bfa8 100644 --- a/pages/info/sceneProductInfo/index.js +++ b/pages/info/sceneProductInfo/index.js @@ -25,13 +25,14 @@ Page({ showAllowance: false, allowance_data:null, //购物车数量 - producNum: 1, - skuIndex: 0, - aniSkuIndex: -1, - cartCount: 0, - cartImgInfo: null, - cartTop: 0, - top: 0 + producNum: 1, + skuIndex: 0, + aniSkuIndex: -1, + cartCount: 0, + cartImgInfo: null, + cartTop: 0, + top: 0, + skuList:[],//立即预定的列表 }, /** @@ -96,7 +97,16 @@ Page({ this.setData({ info: res.data }) + var arr = [] console.log(this.data.info); + res.data.product.forEach(item => { + item.sku.forEach(itemB=>{ + arr.push(itemB) + }) + }); + this.setData({ + skuList:arr + }) util.pagePoint({ event: 'scene_view', param: { type: res.data.type, id: res.data.id } }, 1) this.BroswerRecord() }) @@ -118,7 +128,6 @@ Page({ this.setData({ ask: res.data.rows }) - console.log(res) }) // 获取评价列表 commonApi._post("scene/get_comment", { @@ -171,7 +180,6 @@ Page({ }, like: function () { let id = this.data.id, isLike = Number(this.data.isLike); - console.log(isLike) commonApi.user_post(isLike != 1 ? "scene/scene_collection" : "scene/scene_cancel_collection", { scene_id: id }).then(res => { @@ -237,14 +245,12 @@ Page({ // }) // }, 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 = [] @@ -261,16 +267,20 @@ Page({ 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} + // 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} + let sku = {sku:this.data.skuList[this.data.skuIndex]},product = {product: e.currentTarget.dataset.product} + app.globalData.product = {...sku,...product} + console.log(this.data.skuIndex); + console.log(app.globalData.product); // app.globalData.product = e.currentTarget.dataset; wx.navigateTo({ url: '/pages/order/scene/index', }) }else { + console.log('111'); commonApi.user_post("cart/add_sku", { - sku_id: this.data.info.product[0].sku[this.data.skuIndex].id, + sku_id: this.data.skuList[this.data.skuIndex].id, num: this.data.producNum }).then(res => { if (res.code == 1) { @@ -280,7 +290,6 @@ Page({ }) }) // 加动效 - console.log(this.data.skuIndex) this.setData({ skuFlag: null, aniSkuIndex: this.data.skuIndex, @@ -573,7 +582,6 @@ Page({ }, //加入购物车 showCart: function () { - console.log(this.data) if (this.data.info.product[0].sku.length == 0) { wx.showToast({ title: '该产品未设置规格,不能加购', @@ -586,7 +594,6 @@ Page({ }) let that = this wx.createSelectorQuery().select('#skuImg').boundingClientRect(function (res) { - console.log(res) that.setData({ cartImgInfo: 'top:' + res.top + 'px;left:' + res.left + 'px;' }) @@ -646,7 +653,6 @@ Page({ */ onShow: function () { commonApi.user_post('cart/get_list', {}).then(res => { - console.log(res,res.data) this.setData({ cartCount: res.data.length }) @@ -661,15 +667,12 @@ Page({ commonApi.user_post("product/getProductAllowancePrice", { product_code: this.data.product[0].product.product_code }).then(resTwo => { - console.log(resTwo) if (resTwo && resTwo.code == 1) { this.setData({ allowance_data: resTwo.data }) let spread_price = Number(this.data.allowance_data.discount_limit_price - this.data.allowance_data.user_used_price) let sInfo = this.data.product[0].sku - console.log(9999, this.data.allowance_data.discount_rate / 100 * sInfo.price) - console.log(9999, spread_price) if (spread_price > 0) { if (spread_price < this.data.allowance_data.discount_rate / 100 * sInfo.price) { this.setData({ diff --git a/pages/info/sceneProductInfo/index.wxml b/pages/info/sceneProductInfo/index.wxml index 4ff2b60..c592eca 100644 --- a/pages/info/sceneProductInfo/index.wxml +++ b/pages/info/sceneProductInfo/index.wxml @@ -79,7 +79,7 @@ {{cartCount}} - + + + + + + + + + {{skuList[skuIndex].price/100}} + + 补贴价:¥{{ (1 - allowance_data.discount_rate / 100) * info.sku[skuIndex].price / 100 }} + + 已选择:{{skuList[skuIndex].sku_name}} + + + + {{item.sku_name}} + + + 数量 + + {{producNum}} + + + + + {{skuFlag=='cart'?'确认':'立即购买'}} + + 该商品已下架 + +