diff --git a/pages/info/postProductInfo/index.js b/pages/info/postProductInfo/index.js index 375cb58..b1d3001 100644 --- a/pages/info/postProductInfo/index.js +++ b/pages/info/postProductInfo/index.js @@ -68,15 +68,15 @@ Page({ }) // 获取补贴 - // commonApi.user_post("product/getProductAllowancePrice", { - // product_code: res.data.product_code - // }).then(resTwo => { - // if (resTwo) { - // this.setData({ - // allowance_data: resTwo.data - // }) - // } - // }) + commonApi.user_post("product/getProductAllowancePrice", { + product_code: res.data.product_code + }).then(resTwo => { + if (resTwo && resTwo.code == 1) { + this.setData({ + allowance_data: resTwo.data + }) + } + }) this.BroswerRecord() }) // 获取评价列表 diff --git a/pages/info/postProductInfo/index.wxml b/pages/info/postProductInfo/index.wxml index 55e21d5..ffba8d8 100644 --- a/pages/info/postProductInfo/index.wxml +++ b/pages/info/postProductInfo/index.wxml @@ -20,7 +20,7 @@ 补贴价 - {{ allowance_data.mini_price / 100 }} + ¥{{ allowance_data.mini_price / 100 }}起 单品最高补贴{{ allowance_data.max_price / 100 }}元 @@ -107,7 +107,9 @@ - {{info.sku[skuIndex].price/100}} + {{info.sku[skuIndex].price/100}} + 补贴价:¥{{ (1 - allowance_data.discount_rate / 100) * info.sku[skuIndex].price / 100 }} + 已选择:{{info.sku[skuIndex].sku_name}} diff --git a/pages/info/postProductInfo/index.wxss b/pages/info/postProductInfo/index.wxss index e33b657..fb4e2d2 100644 --- a/pages/info/postProductInfo/index.wxss +++ b/pages/info/postProductInfo/index.wxss @@ -20,7 +20,7 @@ page { background: white; position: relative; z-index: 1; - margin-top: -20rpx; + margin-top: -60rpx; padding: 20rpx 40rpx; } @@ -483,12 +483,26 @@ page { 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 { @@ -743,15 +757,18 @@ page { } .allowance-box { - height: 114rpx; - background-image: url("/static/images/detail/allowanceBacTwo.png"); - padding: 20rpx 10rpx; - font-size: 18rpx; + height: 113rpx; + background: url("https://sz-qd.oss-cn-hangzhou.aliyuncs.com/uploads/20220602/7762b9c4be5adac1f3d0ab5228569821.png"); + background-size: 100% auto; + background-repeat: no-repeat; + padding: 30rpx 30rpx 10rpx; + font-size: 24rpx; color: #FFFFFF; margin-top: -60rpx; position: relative; display: flex; justify-content: start; + align-items: baseline; } .allowance-box .com-price { diff --git a/pages/order/postOrder/index.js b/pages/order/postOrder/index.js index 0dcae05..cbc5fe4 100644 --- a/pages/order/postOrder/index.js +++ b/pages/order/postOrder/index.js @@ -7,16 +7,19 @@ Page({ * 页面的初始数据 */ data: { - product:[], - showPrice:0, - from:null, - address:null, - postFee:0, - coupon:null, - sku_id:'', - kjId:null, - gp_id:null, - prizeId:null + product: [], + showPrice: 0, + from: null, + address: null, + postFee: 0, + coupon: null, + sku_id: '', + kjId: null, + gp_id: null, + prizeId: null, + select_allowance: false, + allowance_data: null, + allowance_price: 0, }, /** @@ -24,196 +27,210 @@ Page({ */ onLoad: function (options) { this.setData({ - from:options.from, - kjId:app.globalData.kjId, - gp_id:app.globalData.gp_id || app.globalData.team_id, - prizeId:wx.getStorageSync('prizeId') + from: options.from, + kjId: app.globalData.kjId, + gp_id: app.globalData.gp_id || app.globalData.team_id, + prizeId: wx.getStorageSync('prizeId') }) - let price = 0,sku_id=[]; - app.globalData.postProduct.map(item=>{ - if(!app.globalData.kjId && !this.data.gp_id){ + 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){ + else if (this.data.gp_id) { price = price + item.sku.event_price * item.productNum; } sku_id.push(item.sku.id) }) this.setData({ - product:app.globalData.postProduct, - showPrice:app.globalData.kjId?0:price, - sku_id:sku_id.join(",") + product: app.globalData.postProduct, + showPrice: app.globalData.kjId ? 0 : price, + sku_id: sku_id.join(",") }) - if(!this.data.kjId && !this.data.gp_id){ + if (!this.data.kjId && !this.data.gp_id) { this.couponCom = this.selectAllComponents("#coupon")[0]; } - }, - inputRemark:function(e){ - let index = e.currentTarget.dataset.index,product = this.data.product; + inputRemark: function (e) { + let index = e.currentTarget.dataset.index, product = this.data.product; product[index].remark = e.detail.value; this.setData({ - product:product + product: product }) }, - setAddress:function(e){ + setAddress: function (e) { this.setData({ - address:e.detail + address: e.detail }) this.getPostFee() }, - minus:function(e){ - let index = e.currentTarget.dataset.index,product = this.data.product; + minus: function (e) { + let index = e.currentTarget.dataset.index, product = this.data.product; let productNum = product[index].productNum; - if(productNum<=1) return; - + if (productNum <= 1) return; + product[index].productNum--; this.setData({ - product:product, - coupon:null + product: product, + coupon: null }) this.getPostFee() this.changePrice() }, - add:function(e){ - let index = e.currentTarget.dataset.index,product = this.data.product; - product[index].productNum = product[index].productNum+1; + add: function (e) { + let index = e.currentTarget.dataset.index, product = this.data.product; + product[index].productNum = product[index].productNum + 1; this.setData({ - product:product, - coupon:null + product: product, + coupon: null }) this.getPostFee() this.changePrice() }, - changePrice:function(){ - let product = this.data.product,price=0; - product.map(item=>{ + 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){ + 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){ + if (!this.data.kjId && !this.data.gp_id) { this.couponCom.setNullCoupon() } this.setData({ - coupon:null + coupon: null }) } this.setData({ - showPrice:app.globalData.kjId?0:price + showPrice: app.globalData.kjId ? 0 : price }) }, - order:function(){ - if(!this.data.address){ + order: function () { + if (!this.data.address) { wx.showToast({ title: '请选择收货地址!', - icon:'none' + icon: 'none' }) return; } - let product = this.data.product,product_list=[]; - product.map(item=>{ + let product = this.data.product, product_list = []; + product.map(item => { let productItem = { - type:item.product.type, - product_id:item.product.id, - sku_id:item.sku.id, - post:this.data.address.id, - product_num:item.productNum, - remark:item.remark + type: item.product.type, + product_id: item.product.id, + sku_id: item.sku.id, + post: this.data.address.id, + product_num: item.productNum, + remark: item.remark } product_list.push(productItem) }) let data = { - source:"WECHATXCX", - product_list:product_list, - coupon: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 + source: "WECHATXCX", + product_list: product_list, + coupon: 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 }; - if(app.globalData.from){ + if (this.data.select_allowance) data.is_allowance = 1 + if (app.globalData.from) { data.system_name = app.globalData.from; } - if(app.globalData.retailId){ + if (app.globalData.retailId) { data.commission_code = app.globalData.retailId; app.globalData.retailId = null; } - if(this.data.prizeId){ + if (this.data.prizeId) { data.lottery_id = this.data.prizeId } - if(app.globalData.category_id){ + 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){ + commonApi.user_post("order/create", { + data: JSON.stringify(data) + }).then(res => { + if (app.globalData.kjId) { app.globalData.kjId = null; this.setData({ - kjId:null + kjId: null }) this.onLoad({}) } app.globalData.gp_id = null; app.globalData.team_id = null; this.setData({ - gp_id:null + gp_id: null }) this.onLoad({}); }) }, - getPostFee:function(){ - if(!this.data.address) return; - let product = this.data.product,list=[],that = this; - product.map(item=>{ - list.push(commonApi.user_post("order/get_post_price",{ - sku_id:item.sku.id, - num:item.productNum, - consignee_id:that.data.address.id + getPostFee: function () { + if (!this.data.address) return; + let product = this.data.product, list = [], that = this; + product.map(item => { + list.push(commonApi.user_post("order/get_post_price", { + sku_id: item.sku.id, + num: item.productNum, + consignee_id: that.data.address.id })) }) // 获取邮费 - Promise.all(list).then(res=>{ - let postFee = 0,flag = true; - res.map((item,index)=>{ - if(item.data.price<0) flag = false; - postFee = postFee+Number(item.data.price); + Promise.all(list).then(res => { + let postFee = 0, flag = true; + res.map((item, index) => { + if (item.data.price < 0) flag = false; + postFee = postFee + Number(item.data.price); product[index].postFee = item.data.price; }) - if(!flag){ + if (!flag) { wx.showToast({ title: '该地区不发货', - icon:'none' + icon: 'none' }) - product.map(item=>{ + product.map(item => { item.postFee = 0; }) postFee = 0; } - if(this.data.coupon && this.data.postFee!=postFee){ + if (this.data.coupon && this.data.postFee != postFee) { wx.showToast({ title: '订单价格发生变化,请重新选择优惠券', icon: 'none' }) app.globalData.couponInfo = null; - if(!this.data.kjId && !this.data.gp_id){ + if (!this.data.kjId && !this.data.gp_id) { this.couponCom.setNullCoupon() } this.setData({ - coupon:null + coupon: null }) } this.setData({ - postFee:postFee, - product:product + postFee: postFee, + product: product }) }) }, + /** + * 选择补贴 + */ + selectAllowance: function () { + this.setData({ + select_allowance: !this.data.select_allowance + }) + this.changePrice() + }, + /** * 生命周期函数--监听页面初次渲染完成 */ @@ -226,8 +243,41 @@ Page({ */ onShow: function () { this.setData({ - coupon:app.globalData.couponInfo + coupon: app.globalData.couponInfo }) + // 获取补贴 + if (this.data.product.length == 1) { + 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({ + allowance_price: spread_price + }) + } else { + this.setData({ + allowance_price: this.data.allowance_data.discount_rate / 100 * sInfo.price + }) + } + this.changePrice() + } else { + this.setData({ + allowance_price: 0 + }) + } + } + }) + } }, /** @@ -242,8 +292,8 @@ Page({ */ onUnload: function () { this.setData({ - kjId:null, - gp_id:null + kjId: null, + gp_id: null }); app.globalData.kjId = null; app.globalData.gp_id = null; diff --git a/pages/order/postOrder/index.wxml b/pages/order/postOrder/index.wxml index d973e7f..37a6c25 100644 --- a/pages/order/postOrder/index.wxml +++ b/pages/order/postOrder/index.wxml @@ -36,11 +36,23 @@ 小计:{{item.sku.price * item.productNum /100}} + + + 惠民补贴 + + -¥{{allowance_price / 100}} + + + + - 合计:¥{{((showPrice + postFee - (coupon?coupon.activity.money:0))>0?(showPrice + postFee - (coupon?coupon.activity.money:0)):0)/100}} + 合计:¥{{((showPrice + postFee - (coupon?coupon.activity.money:0))>0?(showPrice + postFee - (coupon?coupon.activity.money:0)):0)/100}} + 合计:¥{{postFee?(0+postFee)/100:0}} 提交订单 \ No newline at end of file diff --git a/pages/order/postOrder/index.wxss b/pages/order/postOrder/index.wxss index f9450d7..d70b647 100644 --- a/pages/order/postOrder/index.wxss +++ b/pages/order/postOrder/index.wxss @@ -2,11 +2,13 @@ page { background: #f6f6f6; } + .box { margin: 30rpx 25rpx; background: white; border-radius: 9rpx; } + .box-title { height: 113rpx; margin: 0 20rpx; @@ -16,6 +18,30 @@ page { display: flex; align-items: center; } + +.allowance { + justify-content: space-between; +} + +.allowance>view:nth-child(2) { + display: flex; + align-items: center; +} + +.allowance image { + width: 40rpx; + height: 40rpx; + margin-left: 10rpx; +} + +.allowance .border { + width: 30rpx; + height: 30rpx; + border-radius: 50%; + border: 4rpx solid #0B98BE; + margin-left: 10rpx; +} + .coupon-btn { width: 138rpx; line-height: 56rpx; @@ -25,12 +51,14 @@ page { font-size: 28rpx; color: #000; } + .skuinfo { display: flex; justify-content: space-between; padding: 30rpx 20rpx; margin-bottom: 30rpx; } + .skuinfo image { flex-shrink: 0; width: 174rpx; @@ -38,10 +66,12 @@ page { border-radius: 7rpx; margin-right: 23rpx; } + .right-info { flex: 1; width: 400rpx; } + .sku-name { font-size: 32rpx; line-height: 47rpx; @@ -51,6 +81,7 @@ page { justify-content: space-between; align-items: center; } + .info-tips { display: flex; justify-content: space-between; @@ -58,22 +89,27 @@ page { font-size: 27rpx; color: #666; } + .info-tips .price { font-size: 33rpx; color: #000; flex: 1; margin-left: 10rpx; } + .info-tips .price text { font-size: 24rpx; } + .info-tips .iconfont { font-size: 26rpx; } + .box-title .iconfont { font-size: 28rpx; flex-shrink: 0; } + .number-box { font-size: 29rpx; font-weight: 500; @@ -86,14 +122,17 @@ page { text-align: center; margin: 0 20rpx; } + .line { margin: 0 20rpx; background: #ccc; height: 1rpx; } + .topbox .box-title { border-top: 1rpx solid #ccc; } + .box-title input { flex: 1; display: block; @@ -102,6 +141,7 @@ page { margin-left: 15rpx; font-weight: 400; } + .fixed-bottom { position: fixed; left: 0; @@ -115,6 +155,7 @@ page { z-index: 2; box-shadow: 0px 0px 16rpx 0px rgba(6, 0, 1, 0.1); } + .fixed-btn { width: 320rpx; line-height: 113rpx; @@ -124,6 +165,7 @@ page { font-size: 36rpx; font-weight: 500; } + .fixed-price-box { margin-left: 25rpx; flex-shrink: 0; @@ -131,11 +173,13 @@ page { color: #333; font-weight: 500; } + .fixed-price-box .price { color: #D62828; font-size: 36rpx; margin-left: 10rpx; } + .all-money-box { margin: 0 20rpx; display: flex; @@ -146,15 +190,19 @@ page { border-top: 1rpx solid #ccc; color: #000; } + .all-money-box text { color: #D62828; } + .all-money-box .unit { font-size: 24rpx; } + .all-money-box .s-price { font-size: 33rpx; } + .header-title { font-size: 31rpx; font-weight: 500; diff --git a/utils/https.js b/utils/https.js index c10da7b..1e2e477 100644 --- a/utils/https.js +++ b/utils/https.js @@ -1,14 +1,14 @@ var app = getApp(); import util from "../utils/util" // import userApi from "../utils/https/user.js"; -const baseUrl = "https://test.api.cloud.sz-trip.com/api/"; -// const baseUrl = "https://api.cloud.sz-trip.com/api/"; -const orders = ['','weight','distance','sale_number','sale_price','price']; +// const baseUrl = "https://test.api.cloud.sz-trip.com/api/"; +const baseUrl = "https://api.cloud.sz-trip.com/api/"; +const orders = ['', 'weight', 'distance', 'sale_number', 'sale_price', 'price']; //封装GET请求 -function _get(url,data) { +function _get(url, data) { //为了用户体验,加一个loading效果 wx.showLoading({ title: '加载中', mask: true }); - url = baseUrl+url; + url = baseUrl + url; // 如果有order // if(data && data.order){ // data.order = orders[data.order]; @@ -27,7 +27,7 @@ function _get(url,data) { wx.showToast({ title: res.data.msg, icon: "none", - duration:2000 + duration: 2000 }) } resolved(res.data); @@ -42,7 +42,7 @@ function _get(url,data) { wx.request(obj) }) } -function back(){ +function back() { const pages = getCurrentPages(); if (pages.length <= 1) { wx.switchTab({ @@ -56,7 +56,7 @@ function back(){ } } //封装POST请求 -function _post(url,data={}) { +function _post(url, data = {}) { //为了用户体验,加一个loading效果 wx.showLoading({ title: '加载中', mask: true }); url = baseUrl + url; @@ -81,21 +81,21 @@ function _post(url,data={}) { // icon: "none", // }) // } - if(url.indexOf('product/get_product_detail')!=-1){ + if (url.indexOf('product/get_product_detail') != -1) { // 如果是产品详情的话 需要加埋点 - _post('browse/ProductStatistics',{ - uuid:wx.getStorageSync('uuid'), - product_id:res.data.data.id, - product_name:res.data.data.title, - type:res.data.data.type + _post('browse/ProductStatistics', { + uuid: wx.getStorageSync('uuid'), + product_id: res.data.data.id, + product_name: res.data.data.title, + type: res.data.data.type }) util.pagePoint({ - event:'product_view', - param:{ - type:res.data.data.type, - id:res.data.data.id + event: 'product_view', + param: { + type: res.data.data.type, + id: res.data.data.id } - },1) + }, 1) } resolved(res.data); } @@ -103,55 +103,55 @@ function _post(url,data={}) { rejected(res.data); } }, - fail: (err) => {wx.hideLoading();rejected(err)} + fail: (err) => { wx.hideLoading(); rejected(err) } } wx.request(obj) }) } -function user_post(url,data={},type){ - if(wx.getStorageSync('authCode')){ +function user_post(url, data = {}, type) { + if (wx.getStorageSync('authCode')) { // 如果有授权码的话 用授权码去获取下用户信息 - return new Promise((resolved,rejected)=>{ - _post("/uservice/user/loginWithUserCenterAuthCode",{ - auth_code:wx.getStorageSync('authCode') - }).then(res=>{ + return new Promise((resolved, rejected) => { + _post("/uservice/user/loginWithUserCenterAuthCode", { + auth_code: wx.getStorageSync('authCode') + }).then(res => { wx.removeStorageSync('authCode') - if(res && res.data){ + if (res && res.data) { wx.setStorageSync('jstrip_userid', res.data.id) wx.setStorageSync('jstrip_token', res.data.token) wx.setStorageSync('jstrip_userInfo', res.data) } - user_post_new(url,data,type).then(res=>{ + user_post_new(url, data, type).then(res => { resolved(res) - }).catch(err=>{ + }).catch(err => { rejected(err) }) - }).catch(err=>{ + }).catch(err => { wx.removeStorageSync('authCode') - user_post_new(url,data,type).then(res=>{ + user_post_new(url, data, type).then(res => { resolved(res) - }).catch(err=>{ + }).catch(err => { rejected(err) }) }) }) - + } else { - return user_post_new(url,data,type) + return user_post_new(url, data, type) } } -function user_post_new(url,data={},type){ +function user_post_new(url, data = {}, type) { console.log(type) - var token = wx.getStorageSync("jstrip_token"),userId = wx.getStorageSync("jstrip_userid"); + var token = wx.getStorageSync("jstrip_token"), userId = wx.getStorageSync("jstrip_userid"); //为了用户体验,加一个loading效果 wx.showLoading({ title: '加载中', mask: true }); url = baseUrl + url; var header = Object.assign({ - token:token, - userId:userId - },{ + token: token, + userId: userId + }, { 'context-type': 'application/json' }) // 如果有order @@ -165,7 +165,7 @@ function user_post_new(url,data={},type){ return new Promise((resolved, rejected) => { // 判断是否登录 // 没有登录就跳转到登录页面 - if (!token || !userId){ + if (!token || !userId) { wx.hideLoading(); // 去登陆 console.log("去登陆去登陆去登陆去登陆去登陆去登陆去登陆") @@ -177,12 +177,12 @@ function user_post_new(url,data={},type){ const obj = { url, data, - method: type?type:'POST', + method: type ? type : 'POST', header: header, success: (res) => { wx.hideLoading(); - console.log(url,url.indexOf('team_order/apply_post')!=-1) - if(url.indexOf('user/getJumpThirdAppCode')!=-1){ + console.log(url, url.indexOf('team_order/apply_post') != -1) + if (url.indexOf('user/getJumpThirdAppCode') != -1) { } else if (res.data.code == 401) { @@ -192,7 +192,7 @@ function user_post_new(url,data={},type){ wx.removeStorageSync("jstrip_userInfo"); checkLogin(); } - else if(res.data.code==4005){ + else if (res.data.code == 4005) { wx.navigateTo({ url: '/pages/user/verify/index', }) @@ -200,33 +200,37 @@ function user_post_new(url,data={},type){ } else if (res.data.code != 1 && res.data.msg) { // 不出现提示语 - if(url.indexOf('actonline/video_act/getRaffle')!=-1 || url.indexOf('team_order/apply_post')!=-1 && type=='get'){ + const noToast = [ + 'actonline/video_act/getRaffle', + 'getProductAllowancePrice' + ] + if (noToast.indexOf(url) || url.indexOf('team_order/apply_post') != -1 && type == 'get') { } - else if(url.indexOf('actonline/act_online/vote')!=-1 && res.data.code==0){ + else if (url.indexOf('actonline/act_online/vote') != -1 && res.data.code == 0) { wx.showToast({ title: res.data.msg, icon: "none", - duration:2000 + duration: 2000 }) } - else if(url.indexOf('actonline/act_online/vote')==-1){ + else if (url.indexOf('actonline/act_online/vote') == -1) { wx.showToast({ - title: res.data.msg==='身份证号码错误'?'身份证和姓名不匹配':res.data.msg, + title: res.data.msg === '身份证号码错误' ? '身份证和姓名不匹配' : res.data.msg, icon: "none", - duration:2000 + duration: 2000 }) } - + } - if(res.statusCode == 200){ - if(url.indexOf('/order/create')!=-1 && res.data.code==1 && res.data.data){ + if (res.statusCode == 200) { + if (url.indexOf('/order/create') != -1 && res.data.code == 1 && res.data.data) { // 下单成功 wx.removeStorageSync('prizeId') - if(res.data.data.pay_status==1){ + if (res.data.data.pay_status == 1) { // 0元直接付款成功 wx.navigateTo({ - url:"/pages/order/payresult/index?tid="+res.data.data.order_id + url: "/pages/order/payresult/index?tid=" + res.data.data.order_id }) // util.gotoOrder(res.data.data) // // wx.navigateTo({ @@ -235,38 +239,38 @@ function user_post_new(url,data={},type){ } else { wx.navigateTo({ - url: '/pages/order/pay/index?id='+res.data.data.order_id, + url: '/pages/order/pay/index?id=' + res.data.data.order_id, }) } - if(wx.getStorageSync('order_from')){ + if (wx.getStorageSync('order_from')) { util.pagePoint({ - event:wx.getStorageSync('order_from') - },1) + event: wx.getStorageSync('order_from') + }, 1) } wx.removeStorageSync('order_from') } - else if(url.indexOf('/order/create')!=-1 && res.data.msg=='您有正在进行中或待支付的拼团,请查看拼团订单'){ + else if (url.indexOf('/order/create') != -1 && res.data.msg == '您有正在进行中或待支付的拼团,请查看拼团订单') { setTimeout(() => { wx.navigateTo({ url: '/pages/user/order/list', }) }, 1000); } - if(url.indexOf('product/get_product_detail')!=-1){ + if (url.indexOf('product/get_product_detail') != -1) { // 如果是产品详情的话 需要加埋点 - _post('browse/ProductStatistics',{ - uuid:wx.getStorageSync('uuid'), - product_id:res.data.data.id, - product_name:res.data.data.title, - type:res.data.data.type + _post('browse/ProductStatistics', { + uuid: wx.getStorageSync('uuid'), + product_id: res.data.data.id, + product_name: res.data.data.title, + type: res.data.data.type }) util.pagePoint({ - event:'product_view', - param:{ - type:res.data.data.type, - id:res.data.data.id + event: 'product_view', + param: { + type: res.data.data.type, + id: res.data.data.id } - },1) + }, 1) } resolved(res.data); } @@ -292,11 +296,11 @@ const set_logininfo = r => { if (getCurrentPages().length != 0) { //刷新当前页面的数据 let item = getCurrentPages()[getCurrentPages().length - 1]; - if(item.route.indexOf('login')!=-1){ + if (item.route.indexOf('login') != -1) { item = getCurrentPages()[getCurrentPages().length - 2]; item.onLoad(item.__displayReporter.query) } - else if(item.route=='pages/index/index'){ + else if (item.route == 'pages/index/index') { // 首页只可能去获取苏康码 item.gotoSkm(); } @@ -309,7 +313,7 @@ const set_logininfo = r => { const checkLogin = () => { // 判断是否已经授权过 let page = getCurrentPages(); - if(page[page.length-1].route!='pages/login/index') { + if (page[page.length - 1].route != 'pages/login/index') { wx.navigateTo({ url: '/pages/login/index', }) @@ -333,7 +337,7 @@ const checkLogin = () => { } // r.data.isBind是false的时候去绑定手机号 该用户没有注册过 // 已经注册的用户返回userinfo - else if (r.data.isBindMobile === 0 && page[page.length-1].route!='pages/user/bindtel/index') { + else if (r.data.isBindMobile === 0 && page[page.length - 1].route != 'pages/user/bindtel/index') { wx.navigateTo({ url: '/pages/user/bindtel/index?regToken=' + encodeURIComponent(r.data.openid), }) @@ -343,7 +347,7 @@ const checkLogin = () => { title: '网络请求失败', icon: 'none' }) - console.log(err,"666666") + console.log(err, "666666") back() }) } @@ -352,15 +356,15 @@ const checkLogin = () => { }) } else { - if(page[page.length-1].route!='pages/login/index') { + if (page[page.length - 1].route != 'pages/login/index') { wx.navigateTo({ url: '/pages/login/index', }) } } }, - fail:err=>{ - + fail: err => { + } }) }