From f203e270d3fe46c4cb8d663964ccd39a715980ad Mon Sep 17 00:00:00 2001 From: yvan.ni Date: Sat, 3 Jun 2023 09:50:08 +0800 Subject: [PATCH] 拼团的商品详情页面的优化 --- packageA/pages/goodsInfo/goodsInfo.js | 424 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- packageA/pages/goodsInfo/goodsInfo.wxml | 2 +- 2 files changed, 200 insertions(+), 226 deletions(-) diff --git a/packageA/pages/goodsInfo/goodsInfo.js b/packageA/pages/goodsInfo/goodsInfo.js index d90e6d7..fb8d33c 100644 --- a/packageA/pages/goodsInfo/goodsInfo.js +++ b/packageA/pages/goodsInfo/goodsInfo.js @@ -216,17 +216,13 @@ Page({ }, //------初始化加载---------- - onLoad: function(t) { + onLoad:function(t) { + self = this; + this.setData({ + options: t, + }); - console.log("11111111"); - - self = this; - - this.setData({ - options: t, - }); - var ee = this, that = ee, th = ee, @@ -249,11 +245,11 @@ Page({ if(gid_str.length>1){ first_leader=gid_str[1]; } - //-- 如果有room_id的获取 -- - if(gid_str.length>2 && gid_str[2]) { - room_id=gid_str[2]; - room_user_share=1; - }; + //-- 如果有room_id的获取 -- + if(gid_str.length>2 && gid_str[2]) { + room_id=gid_str[2]; + room_user_share=1; + }; }; ee.setData({ gid: gid}); @@ -326,43 +322,10 @@ Page({ //------几人评价------- //n.init(th, "", "comments"); - - th.requestCardNum(), wx.pageScrollTo && th.setData({ + wx.pageScrollTo && th.setData({ supportPageScroll: !0 }); - //计算等级价相关 - // var swithc_list = e.switch_list; - // var sw_arr = JSON.parse(swithc_list); - // //---如果后台又开等级卡的开关--- - // if (sw_arr.rank_switch && sw_arr.rank_switch == "2") { - // th.setData({ rank_switch: true }); - // //---回调卡的列表--- - // th.getPlusCardType(function (ob) { - // th.setData({ card_list: ob.card_list }); - // var ti = setInterval(function () { - // var user = getApp().globalData.userInfo; - // if (!user) return false; - // clearInterval(ti); - // if (user.card_field && user['card_expiredate']) { - // var str = user['card_expiredate'].replace(/-/g, '/'); - // var end = new Date(str); - // end = Date.parse(end) / 1000; - // var now = ut.gettimestamp(); - // //--- 判断是等级会员,且在有效期范围内 --- - // if (user.card_field && now < end) { - // var card_name = ob.name_map.get(user.card_field); - // //if(card_name.length>6) card_name=card_name.substring(0,6); - - // var is_near_date = 0; - // if (end - now < 60 * 60 * 30 * 24) is_near_date = 1; //如果小于30天 - // th.setData({ card_field: user.card_field, card_name: card_name, card_list: ob.card_list, is_near_date: is_near_date }); - // } - // } - // }, 500) - // }) - // } - }, 1); //获取用户设备信息,屏幕宽度 @@ -587,7 +550,6 @@ Page({ } }; - this.getTaohe(); // if (th.data.is_closecoupon != 1 && (!th.data.fir_quan || th.data.fir_quan.length<=0)) { // //----获取详情页的券的数量---- @@ -647,199 +609,211 @@ Page({ // gid 在onload阶段已经保存在this.data中 onShow: function() { - getApp().check_can_share(); + getApp().check_can_share(); var that=this;var th=this; var ee = this,gid = this.data.gid, i = getApp().request; - this.data.is_timer = 1; - //获取用户的默认门店 - th.check_guide(()=>{ - getApp().get_user_store(function(e) { - console.log('get_user_store'); - console.log("999999999"); + //判断是不是要跳转到拼团服务卡 + getApp().check_go_fw(gid,function (act,url){ + if(act){ + wx.redirectTo({ + url:url + }) + return false; + } - if(!e) { - th.data.fir_def_store={}; //赋值空对象 - return false; - } + th.data.is_timer = 1; + //获取用户的默认门店 + th.check_guide(()=>{ + getApp().get_user_store(function(e) { + console.log('get_user_store'); + console.log("999999999"); - console.log("000000"); - if(getApp().globalData.is_dj_pk) th.setData({has_def:1}) + if(!e) { + th.data.fir_def_store={}; //赋值空对象 + return false; + } - var ee=JSON.parse(JSON.stringify(e)); + console.log("000000"); + if(getApp().globalData.is_dj_pk) th.setData({has_def:1}) - console.log(e); + var ee=JSON.parse(JSON.stringify(e)); - //--定时器推迟一下-- - setTimeout(function () { - if(!th.data.data){ - return false; - } - var ser_card=th.data.data; - //--如果默认门店不在等级卡的默认们店以内 - if(ser_card.storageId!=null && ser_card.storageId!="" && ser_card.storageId.indexOf(ee.keyid)==-1){ - ee.is_no_dis=1; - } - var appd=getApp().globalData; - var w_time = setInterval(function() { - if (that.data.is_get_local_ok == 0) return false; - clearInterval(w_time); - var distance = null; - var e=JSON.parse(JSON.stringify(ee)); - - //如果有开启近距离的话,同时距离优不一样了 - if (that.data.lat != null) { - //如果经纬度有变化的话 - if(e && appd.lat==that.data.lat && appd.lon==that.data.lon && e.distance>0 ){ - that.data.fir_def_store=e; - that.setData({ - def_pick_store: e, - sto_sele_name: e.pickup_name, - sto_sele_id: e.pickup_id, - sto_sele_distr: e.distr_type, - sto_sele_keyid:e.keyid, - }) - }else{ - //要用接口是获取距离,js的计算不准 - getApp().request.promiseGet("/api/weshop/pickup/list",{ - data:{store_id:os.stoid,pickup_id:e.pickup_id,lat:th.data.lat,lon: th.data.lon, is_pos: 1}, - }).then(res=>{ - if(ut.ajax_ok(res)){ - e=res.data.data.pageData[0]; - if (e){ - e.is_no_dis=ee.is_no_dis; - appd.pk_store=e; - that.data.fir_def_store=e; - - console.log('get_user_store--2'); - console.log(e); - - that.setData({ - def_pick_store: e, - sto_sele_name: e.pickup_name, - sto_sele_id: e.pickup_id, - sto_sele_distr: e.distr_type, - sto_sele_keyid:e.keyid, - }) - } - - } - }) - } - - //e.distance = distance; - appd.lat=that.data.lat; - appd.lon=that.data.lon; - - } else { - if (e) { - - - console.log('get_user_store3---'); - console.log(e); - - e.distance = null; - that.data.fir_def_store=e; - that.setData({ - def_pick_store: e, - sto_sele_name: e.pickup_name, - sto_sele_id: e.pickup_id, - sto_sele_distr: e.distr_type, - sto_sele_keyid:e.keyid, - }) - } - } - }, 500) - },1500) + console.log(e); - }); - }) + //--定时器推迟一下-- + setTimeout(function () { + if(!th.data.data){ + return false; + } + var ser_card=th.data.data; + //--如果默认门店不在等级卡的默认们店以内 + if(ser_card.storageId!=null && ser_card.storageId!="" && ser_card.storageId.indexOf(ee.keyid)==-1){ + ee.is_no_dis=1; + } + + var appd=getApp().globalData; + var w_time = setInterval(function() { + if (that.data.is_get_local_ok == 0) return false; + clearInterval(w_time); + var distance = null; + var e=JSON.parse(JSON.stringify(ee)); + + //如果有开启近距离的话,同时距离优不一样了 + if (that.data.lat != null) { + //如果经纬度有变化的话 + if(e && appd.lat==that.data.lat && appd.lon==that.data.lon && e.distance>0 ){ + that.data.fir_def_store=e; + that.setData({ + def_pick_store: e, + sto_sele_name: e.pickup_name, + sto_sele_id: e.pickup_id, + sto_sele_distr: e.distr_type, + sto_sele_keyid:e.keyid, + }) + }else{ + //要用接口是获取距离,js的计算不准 + getApp().request.promiseGet("/api/weshop/pickup/list",{ + data:{store_id:os.stoid,pickup_id:e.pickup_id,lat:th.data.lat,lon: th.data.lon, is_pos: 1}, + }).then(res=>{ + if(ut.ajax_ok(res)){ + e=res.data.data.pageData[0]; + if (e){ + e.is_no_dis=ee.is_no_dis; + appd.pk_store=e; + that.data.fir_def_store=e; + + console.log('get_user_store--2'); + console.log(e); + + that.setData({ + def_pick_store: e, + sto_sele_name: e.pickup_name, + sto_sele_id: e.pickup_id, + sto_sele_distr: e.distr_type, + sto_sele_keyid:e.keyid, + }) + } + + } + }) + } + + //e.distance = distance; + appd.lat=that.data.lat; + appd.lon=that.data.lon; + + } else { + if (e) { + + + console.log('get_user_store3---'); + console.log(e); + + e.distance = null; + that.data.fir_def_store=e; + that.setData({ + def_pick_store: e, + sto_sele_name: e.pickup_name, + sto_sele_id: e.pickup_id, + sto_sele_distr: e.distr_type, + sto_sele_keyid:e.keyid, + }) + } + } + }, 500) + },1500) + + }); + }) + + th.wait_for_store_config(); + + i.get("/api/weshop/serviceCard/get/" + o.stoid + "/" + ee.data.gid, { + failRollback: !0, + success: function(t) { + if (t.data.code == 0) { + // console.log('GET pic and video'); + if(t.data.data.listServiceVideos && t.data.data.listServiceVideos[0] && t.data.data.listServiceVideos[0].video_url) { + that.setData({ + mapurl: t.data.data.listServiceVideos[0].video_url, + }); + }; + if(t.data.data.listServiceVideos && t.data.data.listServiceVideos[0] && t.data.data.listServiceVideos[0].video_img) { + that.setData({ + mapurl_f_img: t.data.data.listServiceVideos[0].video_img, + }); + }; + if(t.data.data.listServiceImages) { + that.setData({ + gallery: t.data.data.listServiceImages, + }); + }; + if(t.data.data.listServiceItem) { + that.setData({ + listServiceItem: t.data.data.listServiceItem, + }); + }; + that.setData({ + 'data.goods_name': t.data.data.serviceName, + 'data.shop_price': t.data.data.money, + 'data.show_price': t.data.data.show_price, + 'data.validDays': t.data.data.validDays, + 'data.serviceContent': t.data.data.serviceContent, + 'data.image_url': t.data.data.imgUrl, + 'data.goods_id': t.data.data.id, + 'data.id': t.data.data.id, + 'data.sales_sum': t.data.data.sales_sum, + 'data.storageId':t.data.data.storageId, + 'data.service_sn':t.data.data.serviceSn, + 'data.listServiceVideos': t.data.data.listServiceVideos, + // gallery: t.data.data.listServiceImages, + // mapurl: t.data.data.listServiceVideos[0].video_url, + // mapurl_f_img: t.data.data.listServiceVideos[0].video_img, + //listServiceItem: t.data.data.listServiceItem, + }); + + this.getTaohe(); + + // console.log('0xxxxx999999', t.data.data); + //-----商品详情--- + if(!t.data.data.serviceContent) t.data.data.serviceContent=" "; + a.wxParse("content", "html", ut.format_content(t.data.data.serviceContent), ee, 6); + e.wxParseAddFullImageUrl(ee, "content"); + + //获取重表 + getApp().promiseGet("/api/weshop/serviceItem/list",{ + data:{store_id:o.stoid,service_id:t.data.data.id} + }).then(res=>{ + if(res.data.code==0){ + var list=res.data.data; + that.setData({service_list:list}) + } + }) + + } else { + wx.showModal({ + title: t.data.msg, + showCancel: !1, + complete: function() { + wx.navigateBack(); + } + }); + }; + } + }); + + th.data.enterAddressPage && (this.data.enterAddressPage = !1); + th.get_sto(); + }) - this.wait_for_store_config(); - i.get("/api/weshop/serviceCard/get/" + o.stoid + "/" + ee.data.gid, { - failRollback: !0, - success: function(t) { - if (t.data.code == 0) { - // console.log('GET pic and video'); - if(t.data.data.listServiceVideos && t.data.data.listServiceVideos[0] && t.data.data.listServiceVideos[0].video_url) { - that.setData({ - mapurl: t.data.data.listServiceVideos[0].video_url, - }); - }; - if(t.data.data.listServiceVideos && t.data.data.listServiceVideos[0] && t.data.data.listServiceVideos[0].video_img) { - that.setData({ - mapurl_f_img: t.data.data.listServiceVideos[0].video_img, - }); - }; - if(t.data.data.listServiceImages) { - that.setData({ - gallery: t.data.data.listServiceImages, - }); - }; - if(t.data.data.listServiceItem) { - that.setData({ - listServiceItem: t.data.data.listServiceItem, - }); - }; - that.setData({ - 'data.goods_name': t.data.data.serviceName, - 'data.shop_price': t.data.data.money, - 'data.show_price': t.data.data.show_price, - 'data.validDays': t.data.data.validDays, - 'data.serviceContent': t.data.data.serviceContent, - 'data.image_url': t.data.data.imgUrl, - 'data.goods_id': t.data.data.id, - 'data.id': t.data.data.id, - 'data.sales_sum': t.data.data.sales_sum, - 'data.storageId':t.data.data.storageId, - 'data.service_sn':t.data.data.serviceSn, - 'data.listServiceVideos': t.data.data.listServiceVideos, - // gallery: t.data.data.listServiceImages, - // mapurl: t.data.data.listServiceVideos[0].video_url, - // mapurl_f_img: t.data.data.listServiceVideos[0].video_img, - //listServiceItem: t.data.data.listServiceItem, - }); - - // console.log('0xxxxx999999', t.data.data); - //-----商品详情--- - if(!t.data.data.serviceContent) t.data.data.serviceContent=" "; - a.wxParse("content", "html", ut.format_content(t.data.data.serviceContent), ee, 6); - e.wxParseAddFullImageUrl(ee, "content"); - - //获取重表 - getApp().promiseGet("/api/weshop/serviceItem/list",{ - data:{store_id:o.stoid,service_id:t.data.data.id} - }).then(res=>{ - if(res.data.code==0){ - var list=res.data.data; - that.setData({service_list:list}) - } - }) - - - } else { - wx.showModal({ - title: t.data.msg, - showCancel: !1, - complete: function() { - wx.navigateBack(); - } - }); - }; - } - }); - - - - this.data.enterAddressPage && (this.data.enterAddressPage = !1); - this.get_sto(); diff --git a/packageA/pages/goodsInfo/goodsInfo.wxml b/packageA/pages/goodsInfo/goodsInfo.wxml index e0858a4..affdb9a 100644 --- a/packageA/pages/goodsInfo/goodsInfo.wxml +++ b/packageA/pages/goodsInfo/goodsInfo.wxml @@ -4,7 +4,7 @@ - + -- libgit2 0.21.4