diff --git a/pages/goods/goodsInfo/goodsInfo.js b/pages/goods/goodsInfo/goodsInfo.js index 5304f48..d1215c1 100644 --- a/pages/goods/goodsInfo/goodsInfo.js +++ b/pages/goods/goodsInfo/goodsInfo.js @@ -272,6 +272,9 @@ Page({ prom_type = t.prom_type, prom_id = t.prom_id; //活动ID + var share_openid= t.share_openid; + + self = this; //检查测肤 @@ -370,6 +373,10 @@ Page({ //如果是会员分享过来的要记录 if (room_user_share) getApp().globalData.room_user_share = room_user_share; + + if(share_openid){ + this.get_room_share_guide(share_openid); + } } var c_guide_id = t.c_guide_id; @@ -532,6 +539,34 @@ Page({ }, + async get_room_share_guide(share_openid){ + + var url="/api/weshop/users/page"; + var first_leader=0; + + //调用接口判断是不是会员 + await getApp().request.promiseGet(url, { + data:{stoid:os.stoid,weapp_openid:share_openid} + }).then(res => { + if (ut.ajax_ok(res)) { + first_leader=res.data.data.pageData[0].user_id; + getApp().globalData.guide_id = res.data.data.id; + } + }) + + if(!first_leader) return false; + + getApp().globalData.first_leader = first_leader; + + //调用接口判断是不是会员 + await getApp().request.promiseGet("/api/weshop/shoppingGuide/get/" + os.stoid + "/" + first_leader, {}).then(res => { + if (res.data.code == 0) { + getApp().globalData.guide_id = res.data.data.id; + } + }) + + }, + //--- 设置一下默认库存的数量 ---- set_def_storage(ee) { var that = this, th = this; @@ -5052,25 +5087,25 @@ Page({ context.setFillStyle('#f2f1f6'); context.rect(0, 0, 554 * unit, 899 * unit); context.fill(); - + // 2.商城名称 let shopName = this.data.sto_sele_name_1; context.setTextAlign('center'); context.setFontSize(26 * unit); context.setFillStyle('black'); context.fillText(shopName, 277 * unit, 60 * unit); - + // 3.推荐来源 let fromText = `来自${getApp().globalData.userInfo.nickname}的推荐`; context.setTextAlign('center'); context.setFontSize(22 * unit); context.setFillStyle('#96959a'); context.fillText(fromText, 277 * unit, 105 * unit); - + // 4.海报背景 context.setFillStyle('white'); context.fillRect(37 * unit, 157 * unit, 480 * unit, 673 * unit); - + // 5.商品图片 // 图片的x坐标 let bg_x = 37 * unit @@ -5092,88 +5127,107 @@ Page({ context.clip() context.drawImage(img, bg_x, bg_y, bg_w, bg_h); context.restore(); - + // 6.强烈推荐 - let src = ''; - context.beginPath(); - if(type == 0) { // 普通 - src = '../../../images/share/q_tj.png'; - context.drawImage(src, 54 * unit, 648 * unit, 85 * unit, 30 * unit); - context.setFontSize(16 * unit) - context.setFillStyle("white") - context.setTextAlign('left'); - context.fillText('强烈推荐', 64 * unit, 668 * unit); - }; - if(type == 1) { // 秒杀 - src = '../../../images/share/miao_share.png'; - context.drawImage(src, 54 * unit, 648 * unit, 200 * unit, 36 * unit); - context.setTextAlign('left'); - }; - if(type == 2) { // 商家和会员团 - src = '../../../images/share/ct_num.png'; - context.drawImage(src, 54 * unit, 648 * unit, 120 * unit, 30 * unit); - context.setTextAlign('left'); - - let ct_num = self.data.prom_act.ct_num; - context.setFontSize(16 * unit) - context.font = 'normal'; - context.setFillStyle("red") - if (ct_num < 10) { - context.fillText(ct_num + "人拼团", 100 * unit, 670 * unit); - } else { - context.fillText(ct_num + "人拼团", 96 * unit, 670 * unit); - } - context.setFontSize(22 * unit) - context.fillText("已拼" + self.data.prom_act.buy_num + "份", 186 * unit, 672 * unit); - }; - if(type == 3) { // 阶梯团 - let list = self.data.prom_act.ct_rylist; - for (let i = 0; i < list.length; i++) { - let item = list[i]; - let wi = i * 90 * unit; - context.font = 'normal'; - context.setTextAlign('left'); - context.setFontSize(16 * unit) - context.setFillStyle("red") - context.fillText("¥", 50 * unit + wi, 680 * unit); - context.setFontSize(22 * unit) - let pri = parseFloat(item.price).toFixed(2); - context.fillText(pri, 66 * unit + wi, 680 * unit); - context.setFillStyle("gray") - context.fillText("满" + item.rynum + "人", 50 * unit + wi, 716 * unit); - } - }; - + let src = ''; + context.beginPath(); + if (type == 0) { // 普通 + src = '../../../images/share/q_tj.png'; + context.drawImage(src, 54 * unit, 648 * unit, 85 * unit, 30 * unit); + context.setFontSize(16 * unit) + context.setFillStyle("white") + context.setTextAlign('left'); + context.fillText('强烈推荐', 64 * unit, 668 * unit); + } + + if (type == 1) { // 秒杀 + src = '../../../images/share/miao_share.png'; + context.drawImage(src, 54 * unit, 648 * unit, 200 * unit, 36 * unit); + context.setTextAlign('left'); + } + + if (type == 2) { // 商家和会员团 + src = '../../../images/share/ct_num.png'; + context.drawImage(src, 54 * unit, 648 * unit, 120 * unit, 30 * unit); + context.setTextAlign('left'); + + let ct_num = self.data.prom_act.ct_num; + context.setFontSize(16 * unit) + context.font = 'normal'; + context.setFillStyle("red") + if (ct_num < 10) { + context.fillText(ct_num + "人拼团", 100 * unit, 670 * unit); + } else { + context.fillText(ct_num + "人拼团", 96 * unit, 670 * unit); + } + context.setFontSize(22 * unit) + context.fillText("已拼" + self.data.prom_act.buy_num + "份", 186 * unit, 672 * unit); + } + + if (type == 3) { // 阶梯团 + let list = self.data.prom_act.ct_rylist; + for (let i = 0; i < list.length; i++) { + let item = list[i]; + let wi = i * 90 * unit; + context.font = 'normal'; + context.setTextAlign('left'); + context.setFontSize(16 * unit) + context.setFillStyle("red") + context.fillText("¥", 50 * unit + wi, 680 * unit); + context.setFontSize(22 * unit) + let pri = parseFloat(item.price).toFixed(2); + context.fillText(pri, 66 * unit + wi, 680 * unit); + + var wp= 62 * unit + wi+ ut.measureText('¥' + pri, 32 * unit); + var hp=735 * unit + self.draw_pos_price(context,wp,hp,self.data.data.market_price,unit); + + context.setFillStyle("gray") + context.fillText("满" + item.rynum + "人", 50 * unit + wi, 716 * unit); + } + } + + // 7.商品价格 - if(type != 3) { - let price = this.data.data.shop_price; - if (this.data.card_field && this.data.data[this.data.card_field]) { - price = this.data.data[this.data.card_field]; - } - if (this.data.prom_act) price = this.data.prom_price; - price = parseFloat(price).toFixed(2); - context.setFontSize(32 * unit); - context.setFillStyle('#DE1117'); - if (this.data.prom_type == 4 && this.data.prom_integral){ - context.fillText(this.data.prom_integral+'积分+¥' + price, 54 * unit, 735 * unit); - }else{ - context.fillText('¥' + price, 54 * unit, 735 * unit); - } - + if (type != 3) { + let price = this.data.data.shop_price; + if (this.data.card_field && this.data.data[this.data.card_field]) { + price = this.data.data[this.data.card_field]; + } + if (this.data.prom_act) price = this.data.prom_price; + price = parseFloat(price).toFixed(2); + context.setFontSize(32 * unit); + context.setFillStyle('#DE1117'); + if (this.data.prom_type == 4 && this.data.prom_integral) { + context.fillText(this.data.prom_integral + '积分+¥' + price, 54 * unit, 735 * unit); + + var wp= 62 * unit+ut.measureText(this.data.prom_integral + '积分+¥' + price, 32 * unit); + var hp=735 * unit + this.draw_pos_price(context,wp,hp,this.data.data.market_price,unit); + + } else { + context.fillText('¥' + price, 54 * unit, 735 * unit); + + var wp= 62 * unit+ut.measureText('¥' + price, 32 * unit); + var hp=735 * unit + this.draw_pos_price(context,wp,hp,this.data.data.market_price,unit); + + } + + + } + + // 8.商品标题 + context.setFontSize(20 * unit); + context.setFillStyle('#898989'); + getApp().draw_Text(context, this.data.data.goods_name, 54 * unit, 800 * unit, 240 * unit, 280 * unit, unit, 1); - }; - - // 8.商品标题 - context.setFontSize(20 * unit); - context.setFillStyle('#898989'); - getApp().draw_Text(context, this.data.data.goods_name, 54 * unit, 800 * unit, 240 * unit, 280 * unit, unit, 1); - // 9.小程序码 context.drawImage(vpath, 375 * unit, 660 * unit, 120 * unit, 120 * unit); context.setFontSize(16 * unit); context.setFillStyle('#777'); context.fillText('长按识别二维码', 378 * unit, 810 * unit); - + // 10.竖线 context.beginPath(); context.setFillStyle('#eee'); @@ -5181,6 +5235,27 @@ Page({ context.fill(); }, + //---市场价划掉--- + draw_pos_price(context,w,h,market_price,unit){ + + if(!this.data.sys_switch) return false; + if(!this.data.sys_switch.is_retail_price) return false; + + context.setFillStyle("gray") + context.setFontSize(22 * unit) + var pri0 = "¥" + market_price.toFixed(2); + context.fillText(pri0, w, h); + + var c_h=h-6; + context.setStrokeStyle('gray'); + context.setLineWidth(1 * unit); + context.moveTo(w - 5, c_h); + context.lineTo(w + ut.measureText(pri0, 22 * unit) + 5, c_h); + context.stroke(); + + }, + + //--定义的保存图片方法,分享团--- saveImageToPhotosAlbum: function () { @@ -5267,10 +5342,10 @@ Page({ // var erm_x = parseFloat(th.data.poster.ewm_x) * 2; // var erm_y = parseFloat(th.data.poster.ewm_y) * 2; // context.drawImage(vpath, erm_x * unit, erm_y * unit, 136 * unit, 136 * unit); - // th.drawPoster(context, unit, th.data.share_goods_img, vpath); + }; - // th.drawPoster(context, unit, th.data.share_goods_img, vpath); + //-- 是自定义海报的情况下 -- @@ -5347,30 +5422,44 @@ Page({ pri0 = th.data.prom_price; pri0 = parseFloat(pri0).toFixed(2); var wd1 = th.data.screenWidth - ut.measureText(pri0, 31 * unit) - 25; - context.fillText("¥", wd1 - 15, 185 * unit); + + if(th.data.prom_type!=4) + context.fillText("¥", wd1 - 15, 185 * unit); + context.setFontSize(31 * unit) - // if(th.data.prom_type==4){ - // context.fillText(th.data.prom_integral+'积分'+pri0, wd1, 185 * unit); - // }else{ - // context.fillText(pri0, wd1, 185 * unit); - // } - context.fillText(pri0, wd1, 185 * unit); + var pri_str=pri0; + if(th.data.prom_type==4){ + pri_str=''; + if(th.data.prom_integral) pri_str=th.data.prom_integral+'积分'; + if (pri0 && th.data.prom_integral) { + pri_str += "+"; + } + if (pri0) { + pri_str += pri0; + } + + wd1 = th.data.screenWidth - ut.measureText(pri_str, 31 * unit) - 20; + } + context.fillText(pri_str, wd1, 185 * unit); //---市场价划掉--- - /*-- - context.setFillStyle("gray") - context.setFontSize(22 * unit) - pri0 = "¥" + th.data.data.market_price.toFixed(2); - var wd2 = th.data.screenWidth - ut.measureText(pri0, 22 * unit) - 25; - context.fillText(pri0, wd2, 213 * unit); - - context.setStrokeStyle('gray'); - context.setLineWidth(1 * unit); - context.moveTo(wd2 - 5, 206 * unit); - context.lineTo(wd2 + ut.measureText(pri0, 22 * unit) + 5, 206 * unit); - context.stroke();--*/ - - } else if ( ( type == 4 && type != 0 && type != 1 && type != 2 && type != 3)) { + // context.setFillStyle("gray") + // context.setFontSize(22 * unit) + // pri0 = "¥" + th.data.data.market_price.toFixed(2); + // var wd2 = th.data.screenWidth - ut.measureText(pri0, 22 * unit) - 25; + // context.fillText(pri0, wd2, 213 * unit); + // + // context.setStrokeStyle('gray'); + // context.setLineWidth(1 * unit); + // context.moveTo(wd2 - 5, 206 * unit); + // context.lineTo(wd2 + ut.measureText(pri0, 22 * unit) + 5, 206 * unit); + // context.stroke(); + + var wp= 62 * unit + wi+ ut.measureText(pri_str, 32 * unit); + var hp=735 * unit + th.draw_pos_price(context,wp,hp,self.data.data.market_price,unit); + + } else if (type == 4 ) { context.setFillStyle("black"); context.setFontSize(21.3 * unit) getApp().draw_Text(context, share_title, @@ -5395,31 +5484,51 @@ Page({ context.setFillStyle("red"); context.fillText(text, 38 * unit, 235 * unit); + //---市场价划掉--- + // context.setFillStyle("gray") + // context.setFontSize(22 * unit) + // pri0 = "¥" + th.data.data.market_price.toFixed(2); + // var wd2 = th.data.screenWidth - ut.measureText(pri0, 22 * unit) - 25; + // context.fillText(pri0, wd2, 213 * unit); + // + // context.setStrokeStyle('gray'); + // context.setLineWidth(1 * unit); + // context.moveTo(wd2 - 5, 206 * unit); + // context.lineTo(wd2 + ut.measureText(pri0, 22 * unit) + 5, 206 * unit); + // context.stroke(); + + + + var wp= 62 * unit + wi+ ut.measureText(text, 32 * unit); + var hp=735 * unit + th.draw_pos_price(context,wp,hp,self.data.data.market_price,unit); + + } //---中间大图--- if ( th.data.share_b_img || (type != 0 && type != 1 && type != 2 && type != 3)) { - context.drawImage(th.data.share_goods_img, 70 * unit, 250 * unit, 408 * unit, 408 * unit); + context.drawImage(th.data.share_goods_img, 70 * unit, 240 * unit, 408 * unit, 408 * unit); } - ; + //---自定义海报 产品质量保证 - if(th.data.share_b_img && th.data.poster.show_quality==1 ){ + if(th.data.share_b_img && th.data.poster.show_quality==1 && type!=4){ var g_path = "../../../images/share/s_gou.png"; - context.drawImage(g_path, 56 * unit, 670 * unit, 22 * unit, 22 * unit); + context.drawImage(g_path, 56 * unit, 650 * unit, 22 * unit, 22 * unit); context.setFillStyle("red") context.setFontSize(18 * unit) - context.fillText("正品保证", 84 * unit, 690 * unit); + context.fillText("正品保证", 84 * unit, 670 * unit); - context.drawImage(g_path, 218 * unit, 670 * unit, 22 * unit, 22 * unit); + context.drawImage(g_path, 218 * unit, 650 * unit, 22 * unit, 22 * unit); context.setFillStyle("red") context.setFontSize(18 * unit) - context.fillText("纯实体店", 246 * unit, 690 * unit); + context.fillText("纯实体店", 246 * unit, 670 * unit); - context.drawImage(g_path, 388 * unit, 670 * unit, 22 * unit, 22 * unit); + context.drawImage(g_path, 388 * unit, 650 * unit, 22 * unit, 22 * unit); context.setFillStyle("red") context.setFontSize(18 * unit) - context.fillText("官方验证", 420 * unit, 690 * unit); + context.fillText("官方验证", 420 * unit, 670 * unit); } //-------大图后面就不一样了----------- @@ -5447,6 +5556,26 @@ Page({ context.drawImage(vpath, 380 * unit, 736 * unit, 120 * unit, 120 * unit); break;//普通商品的展示 case 4: + + if(th.data.share_b_img && th.data.poster.show_quality==1 && type!=4){ + var g_path = "../../../images/share/s_gou.png"; + context.drawImage(g_path, 56 * unit, 660 * unit, 22 * unit, 22 * unit); + context.setFillStyle("red") + context.setFontSize(18 * unit) + context.fillText("正品保证", 84 * unit, 680 * unit); + + context.drawImage(g_path, 218 * unit, 660 * unit, 22 * unit, 22 * unit); + context.setFillStyle("red") + context.setFontSize(18 * unit) + context.fillText("纯实体店", 246 * unit, 680 * unit); + + context.drawImage(g_path, 388 * unit, 660 * unit, 22 * unit, 22 * unit); + context.setFillStyle("red") + context.setFontSize(18 * unit) + context.fillText("官方验证", 420 * unit, 680 * unit); + } + + // 中间的几个字 if (th.data.poster && parseInt(th.data.poster.style) == 2) { if (parseInt(th.data.poster.show_quality)) { @@ -5524,7 +5653,7 @@ Page({ //---二维吗图--- context.drawImage(vpath, 390 * unit, 726 * unit, 136 * unit, 136 * unit); } - ; + break; case 1: //秒杀商品的展示 @@ -5533,8 +5662,8 @@ Page({ } //---画线--- context.setLineWidth(1 * unit) - context.moveTo(32 * unit, 670 * unit) - context.lineTo(520 * unit, 670 * unit) + context.moveTo(32 * unit, 690 * unit) + context.lineTo(520 * unit, 690 * unit) context.stroke(); //画秒杀的图片 @@ -5569,8 +5698,8 @@ Page({ } //---画线--- context.setLineWidth(1 * unit) - context.moveTo(32 * unit, 670 * unit) - context.lineTo(520 * unit, 670 * unit) + context.moveTo(32 * unit, 690 * unit) + context.lineTo(520 * unit, 690 * unit) context.stroke(); //---文字--- context.setFillStyle("black") @@ -5617,8 +5746,8 @@ Page({ } //---画线--- context.setLineWidth(1 * unit) - context.moveTo(32 * unit, 670 * unit) - context.lineTo(520 * unit, 670 * unit) + context.moveTo(32 * unit, 690 * unit) + context.lineTo(520 * unit, 690 * unit) context.stroke(); //---文字--- context.setFillStyle("black") @@ -5739,7 +5868,6 @@ Page({ } } - ; //把画板内容绘制成图片,并回调 画板图片路径 @@ -5835,17 +5963,17 @@ Page({ videoContext.play(); }, 500) - }, + }, //加载更多是靠这个函数 onReachBottom: function () { - if (this.data.activeCategoryId == 2) { - if (!this.data.comments_no_more) this.requestComments_new(); - } + if (this.data.activeCategoryId == 2) { + if (!this.data.comments_no_more) this.requestComments_new(); + } - var goods_list = this.selectComponent("#goods_list"); //组件的id - if (goods_list) goods_list.get_list(); - }, + var goods_list = this.selectComponent("#goods_list"); //组件的id + if (goods_list) goods_list.get_list(); + }, //--获取头像的本地缓存,回调写法-- get_head_temp: function (tt, func) { diff --git a/pages/goods/goodsInfo/goodsInfo.wxml b/pages/goods/goodsInfo/goodsInfo.wxml index 8997ae4..12c288a 100644 --- a/pages/goods/goodsInfo/goodsInfo.wxml +++ b/pages/goods/goodsInfo/goodsInfo.wxml @@ -125,7 +125,7 @@ {{prom_price}} - 零售价:¥{{filters.toFix(data.market_price,2)}} + 零售价:¥{{filters.toFix(data.market_price,2)}} ¥{{filters.toFix(data.shop_price,2)}} @@ -312,26 +312,12 @@ 零售价:¥{{filters.toFix(data.market_price,2)}} - - - ¥{{filters.toFix(data.shop_price,2)}} - + + + - - - - {{filters.toFix(data.shop_price,2)}} - - 零售价:¥{{filters.toFix(data.market_price,2)}} - - - - ¥{{filters.toFix(data.shop_price,2)}} - - - diff --git a/pages/index/index/index.js b/pages/index/index/index.js index 329ac5c..53bfc68 100644 --- a/pages/index/index/index.js +++ b/pages/index/index/index.js @@ -230,7 +230,11 @@ Page({ } }) - + + var share_openid= tt.share_openid; + if(share_openid){ + this.get_room_share_guide(share_openid); + } //调用底部导航 //getApp().globalData.url=th.data.url @@ -238,6 +242,36 @@ Page({ }, + + async get_room_share_guide(share_openid){ + + var url="/api/weshop/users/page"; + var first_leader=0; + + //调用接口判断是不是会员 + await getApp().request.promiseGet(url, { + data:{stoid:os.stoid,weapp_openid:share_openid} + }).then(res => { + if (ut.ajax_ok(res)) { + first_leader=res.data.data.pageData[0].user_id; + getApp().globalData.guide_id = res.data.data.id; + } + }) + + if(!first_leader) return false; + + getApp().globalData.first_leader = first_leader; + + //调用接口判断是不是会员 + await getApp().request.promiseGet("/api/weshop/shoppingGuide/get/" + os.stoid + "/" + first_leader, {}).then(res => { + if (res.data.code == 0) { + getApp().globalData.guide_id = res.data.data.id; + } + }) + + }, + + async onload_init() { var th = this; await this.init_load();