From 5e5cdb226df130dca9bb8081ed6722431ef2bd3c Mon Sep 17 00:00:00 2001 From: luo <17530855@qq.com> Date: Tue, 27 Sep 2022 16:52:08 +0800 Subject: [PATCH] OA单优化 售前分享 --- packageC/pages/presell/goodsInfo/goodsInfo.js | 1629 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 1 file changed, 1187 insertions(+), 442 deletions(-) diff --git a/packageC/pages/presell/goodsInfo/goodsInfo.js b/packageC/pages/presell/goodsInfo/goodsInfo.js index 8d11ff7..32ff65a 100644 --- a/packageC/pages/presell/goodsInfo/goodsInfo.js +++ b/packageC/pages/presell/goodsInfo/goodsInfo.js @@ -7,7 +7,7 @@ var ut = require("../../../../utils/util.js"), oo = s.globalData, o = s.globalData.setting, os = o; -//评价加载更多 +//评价加载更多 var more = function (e) { return e && e.__esModule ? e : { default: e @@ -250,13 +250,13 @@ Page({ share_hidden: false, pre_arr: null, - - hiddenCS: true, + + hiddenCS: true, }, //------初始化加载---------- onLoad: function (t) { - self = this; + self = this; var ee = this, that = ee, th = ee, pre_id = t.pre_id, gid = t.goods_id, @@ -264,8 +264,8 @@ Page({ first_leader = t.first_leader, room_id = t.room_id, room_user_share = t.room_user_share; //如果是会员分享带有room_id的话,那么接下来会员分享就不传room_id - //检查测肤 - getApp().check_skin_face(t,0,gid); + //检查测肤 + getApp().check_skin_face(t, 0, gid); //-- 自定义海报 -- getApp().request.promiseGet("/api/weshop/goods/poster/page", { @@ -314,7 +314,7 @@ Page({ } this.setData({ - gid:gid,pre_id:pre_id,presell_id:presell_id + gid: gid, pre_id: pre_id, presell_id: presell_id }) if (first_leader) { @@ -569,24 +569,24 @@ Page({ fir_quan = res1.data.data.pageData; }) } - //过滤不是本商品的单品优惠券------------------- - if(fir_quan.length > 0 ){ - let goodInfo = ee.data.data - for (let index = fir_quan.length-1; index >= 0; index--) { - if (fir_quan[index].useobjecttype==20) { //判断是单品优惠券 - if (fir_quan[index].useobjectno != goodInfo.goods_sn) { - fir_quan.splice(index,1) - } - } - } - } - let arr=[] - let length = fir_quan.length - if (length <= 3) { - arr=fir_quan - }else{ - arr=fir_quan.splice(0,3); + //过滤不是本商品的单品优惠券------------------- + if (fir_quan.length > 0) { + let goodInfo = ee.data.data || {} + for (let index = fir_quan.length - 1; index >= 0; index--) { + if (fir_quan[index].useobjecttype == 20) { //判断是单品优惠券 + if (fir_quan[index].useobjectno != goodInfo.goods_sn) { + fir_quan.splice(index, 1) + } } + } + } + let arr = [] + let length = fir_quan.length + if (length <= 3) { + arr = fir_quan + } else { + arr = fir_quan.splice(0, 3); + } //--------获取视频图片--------- await getApp().request.promiseGet("/api/weshop/goodsVideos/get/" + os.stoid + "/" + ee.data.gid, { 1: 1 @@ -614,7 +614,7 @@ Page({ //---展示--- onShow: function () { - getApp().check_can_share(); + getApp().check_can_share(); var goods_list = null, th = this, that = this; //-- 如果是预览图片,页面不重新更新 -- @@ -689,8 +689,8 @@ Page({ //-- 把商品的赋值 -- ee.data.fir_goods = JSON.parse(JSON.stringify(t.data.data)); - ee.data.sele_g_id=t.data.data.goods_id; - ee.data.sele_g=t.data.data; + ee.data.sele_g_id = t.data.data.goods_id; + ee.data.sele_g = t.data.data; //获取用户的默认门店 getApp().get_user_store(function (e) { @@ -698,7 +698,7 @@ Page({ th.data.fir_def_store = {}; //赋值空对象 return false; } - if(getApp().globalData.is_dj_pk) th.setData({has_def:1}) + if (getApp().globalData.is_dj_pk) th.setData({ has_def: 1 }) var ee = JSON.parse(JSON.stringify(e)); @@ -1062,7 +1062,7 @@ Page({ newd.goods_price = th.data.prom_price; newd.member_goods_price = th.data.prom_price, - newd.prom_type = 8; + newd.prom_type = 8; newd.prom_id = o.prom_id; if (o.store_count <= 0) return s.my_warnning("库存已为空!", 0, th); @@ -1101,8 +1101,8 @@ Page({ return s.my_warnning("库存不足!", 0, th); } - if (item.goods_num + th.data.goodsInputNum >th.data.pre_arr.presell_sumqty-th.data.pre_arr.buy_goodnum) { - return s.my_warnning("库存不足!", 0, th); + if (item.goods_num + th.data.goodsInputNum > th.data.pre_arr.presell_sumqty - th.data.pre_arr.buy_goodnum) { + return s.my_warnning("库存不足!", 0, th); } var updata = { @@ -1173,10 +1173,10 @@ Page({ app.set_b_now(e); //如果是全额付款的话 - if(this.data.presellForm.presell_type==1){ - getApp().goto("/packageC/pages/presell/cart/cart2") - }else{ - getApp().goto("/packageC/pages/presell/cart/cart2_pre"); + if (this.data.presellForm.presell_type == 1) { + getApp().goto("/packageC/pages/presell/cart/cart2") + } else { + getApp().goto("/packageC/pages/presell/cart/cart2_pre"); } }, @@ -1230,8 +1230,8 @@ Page({ } var e = th.data.sele_g.store_count; - var e2=th.data.pre_arr.presell_sumqty-th.data.pre_arr.buy_goodnum; - if(e2 { + getApp().request.promiseGet("/api/weshop/goods/getGoodsPromList/" + os.stoid + "/" + th.data.sele_g.goods_id + "/0" + "/" + getApp().globalData.user_id, {}).then(res => { if (res.data.code == 0) { var r_data = res.data.data; th.data.prom_goods = r_data.promGoodsLists; @@ -1461,38 +1461,38 @@ Page({ contactService: function () { getApp().com_call(this); }, - - // 获取客服电话 - getTel() { - return new Promise((resolve, reject) => { - s.getConfig(function (t) { - if (t.store_tel == undefined) { - getApp().request.get("/api/weshop/store/get/" + os.stoid, { - isShowLoading: 1, - data: {}, - success: function (rs) { - getApp().globalData.config = rs.data.data; - if (rs.data.data.store_tel == null && rs.data.data.store_tel == undefined) { - getApp().my_warnning("商家未设置电话", 0, th); - return false; - } - self.setData({ - store_tel: rs.data.data.store_tel, - }); - // s.confirmBox("请联系客服:" + rs.data.data.store_tel); - } - }) - } else { - self.setData({ - store_tel: t.store_tel, - }); - // s.confirmBox("请联系客服:" + t.store_tel); - }; - resolve(); - }); - }); - }, - + + // 获取客服电话 + getTel() { + return new Promise((resolve, reject) => { + s.getConfig(function (t) { + if (t.store_tel == undefined) { + getApp().request.get("/api/weshop/store/get/" + os.stoid, { + isShowLoading: 1, + data: {}, + success: function (rs) { + getApp().globalData.config = rs.data.data; + if (rs.data.data.store_tel == null && rs.data.data.store_tel == undefined) { + getApp().my_warnning("商家未设置电话", 0, th); + return false; + } + self.setData({ + store_tel: rs.data.data.store_tel, + }); + // s.confirmBox("请联系客服:" + rs.data.data.store_tel); + } + }) + } else { + self.setData({ + store_tel: t.store_tel, + }); + // s.confirmBox("请联系客服:" + t.store_tel); + }; + resolve(); + }); + }); + }, + //-------获取购物车数量---------- requestCardNum: function () { var t = this; @@ -1532,7 +1532,7 @@ Page({ b[i] = this.data.iurl + e[i]; } this.data.show_prew_img = 1; - getApp().pre_img2(b,t) + getApp().pre_img2(b, t) }, @@ -1543,16 +1543,16 @@ Page({ b[i] = this.data.iurl + e[i]; } this.data.show_prew_img = 1; - getApp().pre_img2(b,t) + getApp().pre_img2(b, t) }, previewGoodsCommentImgs: function (t) { var e = this, a = this.data.data.comment[t.currentTarget.dataset.cidx].img; - getApp().globalData.no_clear=1; + getApp().globalData.no_clear = 1; a = a.map(function (t) { return e.data.url + t; - }), getApp().pre_img2(a,t); + }), getApp().pre_img2(a, t); this.data.show_prew_img = 1; }, closePromModal: function () { @@ -1567,19 +1567,20 @@ Page({ }, //--点击分享事件--- - onShareAppMessage: function (t) { getApp().globalData.no_clear=1; + onShareAppMessage: function (t) { + getApp().globalData.no_clear = 1; var th = this; - var price = th.data.pre_arr.presell_price; + var price = th.data.pre_arr.presell_price; var img = th.data.data.original_img; - var title = th.data.presellForm.share_title; + var title = th.data.presellForm.share_title; if (!title) title = th.data.prom_act.title; if (th.data.prom_type == 4) title = th.data.prom_act.name; //if (th.data.presellForm.share_img) // img = th.data.iurl + th.data.presellForm.share_img; - var url = "/packageC/pages/presell/goodsInfo/goodsInfo?goods_id=" + th.data.gid+"&pre_id="+th.data.pre_arr.id; + var url = "/packageC/pages/presell/goodsInfo/goodsInfo?goods_id=" + th.data.gid + "&pre_id=" + th.data.pre_arr.id; if (getApp().globalData.user_id) { url += "&first_leader=" + getApp().globalData.user_id; } @@ -1597,13 +1598,13 @@ Page({ path: url, imageUrl: img, }; - + ob.title += '\n' + th.data.presellForm.share_remark; - - - console.log(ob,888); - + + console.log(ob, 888); + + return ob; }, @@ -1626,22 +1627,22 @@ Page({ //----------装载同一活动中的商品---------- async get_sku(stoid, gd, g_id, is_normal, func) { - var tt = this, arrdata = null; - var now = ut.gettimestamp(); - var rq_data={ - store_id: o.stoid, - sku: gd.sku, - more_spec: gd.more_spec, - isonsale: 1, - is_on_sale: 1, - pageSize: 500, - orderField: 'gg_ordid,goods_spec,sort', - prom_type: 8, - }; + var tt = this, arrdata = null; + var now = ut.gettimestamp(); + var rq_data = { + store_id: o.stoid, + sku: gd.sku, + more_spec: gd.more_spec, + isonsale: 1, + is_on_sale: 1, + pageSize: 500, + orderField: 'gg_ordid,goods_spec,sort', + prom_type: 8, + }; - if(tt.data.presellForm && tt.data.presellForm.id){ - rq_data.prom_id=tt.data.presellForm.id; - } + if (tt.data.presellForm && tt.data.presellForm.id) { + rq_data.prom_id = tt.data.presellForm.id; + } await getApp().request.promiseGet("/api/weshop/goods/page", { data: rq_data @@ -1772,31 +1773,31 @@ Page({ //选择了不同的规格的时候要判断是不是有活动正在进行中 async sele_spec_chech_activity() { - var prom = null, goodsinfo = this.data.sele_g, th = this; - - var all_pre_goods=th.data.all_pre_goods; - if(all_pre_goods){ - var userInfo = getApp().globalData.userInfo; - var pre_data = { store_id: os.stoid, is_end: 0, timetype: 1, isuse: 1, goods_id: th.data.gid }; - if (userInfo) { - pre_data.user_id = userInfo.user_id; - } - await getApp().request.promiseGet("/api/weshop/marketing/marketingPresellList/page", { - data: pre_data, - }).then(e => { - if (e.data.code == 0 && e.data.data.pageData && e.data.data.pageData.length > 0) { - all_pre_goods=e.data.data.pageData; - th.data.all_pre_goods=e.data.data.pageData; - } - }) + var prom = null, goodsinfo = this.data.sele_g, th = this; + + var all_pre_goods = th.data.all_pre_goods; + if (all_pre_goods) { + var userInfo = getApp().globalData.userInfo; + var pre_data = { store_id: os.stoid, is_end: 0, timetype: 1, isuse: 1, goods_id: th.data.gid }; + if (userInfo) { + pre_data.user_id = userInfo.user_id; } - - var idx=all_pre_goods.findIndex(function (ele) { - return ele.goods_id==goodsinfo.goods_id; + await getApp().request.promiseGet("/api/weshop/marketing/marketingPresellList/page", { + data: pre_data, + }).then(e => { + if (e.data.code == 0 && e.data.data.pageData && e.data.data.pageData.length > 0) { + all_pre_goods = e.data.data.pageData; + th.data.all_pre_goods = e.data.data.pageData; + } }) - var pre_arr =all_pre_goods[idx]; - th.setData({ pre_arr: pre_arr }) - th.data.prom_buy_limit=pre_arr.vip_butyqty; + } + + var idx = all_pre_goods.findIndex(function (ele) { + return ele.goods_id == goodsinfo.goods_id; + }) + var pre_arr = all_pre_goods[idx]; + th.setData({ pre_arr: pre_arr }) + th.data.prom_buy_limit = pre_arr.vip_butyqty; }, @@ -1887,7 +1888,7 @@ Page({ th.setData({ all_pick_list: e.data.data.pageData }); //--获取线下库存,而且不是新的门店规则, 同时是普通购买的时候,或者同时不能是活动,秒杀,拼团,积分购 预售-- - if (th.data.sales_rules == 2 && !th.data.is_newsales_rules && ((th.data.prom_type != 1 && th.data.prom_type != 6 && th.data.prom_type != 4 && th.data.prom_type !=8 ) || is_normal == 1)) { + if (th.data.sales_rules == 2 && !th.data.is_newsales_rules && ((th.data.prom_type != 1 && th.data.prom_type != 6 && th.data.prom_type != 4 && th.data.prom_type != 8) || is_normal == 1)) { setTimeout(function () { th.deal_pickup_dline(e); }, 800) @@ -1923,15 +1924,15 @@ Page({ success: function (ee) { if (ee.data.code == 0) { - var check_all_cate=0; - if (ee.data.data && ee.data.data.pageData && ee.data.data.pageData.length > 0){ - for(let i in ee.data.data.pageData){ - let item=ee.data.data.pageData[i]; - if(item.is_show==1){ - check_all_cate=1;break - } - } + var check_all_cate = 0; + if (ee.data.data && ee.data.data.pageData && ee.data.data.pageData.length > 0) { + for (let i in ee.data.data.pageData) { + let item = ee.data.data.pageData[i]; + if (item.is_show == 1) { + check_all_cate = 1; break + } } + } if (check_all_cate) { @@ -1940,29 +1941,29 @@ Page({ var newarr = new Array(); var qita = new Array(); - var is_del_pk=0; + var is_del_pk = 0; //----要进行门店分组-------- for (var i = 0; i < sto_arr.length; i++) { //找一下这个门店有没有在分类数组内 var find2 = 0, find2name = "", sort = 0; - is_del_pk=0; + is_del_pk = 0; for (var m = 0; m < sto_cate.length; m++) { - if (sto_arr[i].category_id == sto_cate[m].cat_id) { - if (sto_cate[m].is_show != 1) { - is_del_pk = 1; - sto_arr.splice(i, 1); - i--; - } else { - find2 = sto_cate[m].cat_id; - find2name = sto_cate[m].cat_name; - sort = sto_cate[m].sort; - is_del_pk = 0; - } - break; + if (sto_arr[i].category_id == sto_cate[m].cat_id) { + if (sto_cate[m].is_show != 1) { + is_del_pk = 1; + sto_arr.splice(i, 1); + i--; + } else { + find2 = sto_cate[m].cat_id; + find2name = sto_cate[m].cat_name; + sort = sto_cate[m].sort; + is_del_pk = 0; } + break; + } } - if(is_del_pk) continue; + if (is_del_pk) continue; if (newarr.length > 0) { var find = 0; @@ -2008,17 +2009,17 @@ Page({ } - var def_arr = new Array(); - //-- 开始就看10个门店 -- - for (var k = 0; k < 10; k++) { - if (k == sto_arr.length) break; - def_arr.push(sto_arr[k]); - } + var def_arr = new Array(); + //-- 开始就看10个门店 -- + for (var k = 0; k < 10; k++) { + if (k == sto_arr.length) break; + def_arr.push(sto_arr[k]); + } - th.setData({ - def_pickpu_list: def_arr, - pickpu_list: ee.data.data.pageData - }); + th.setData({ + def_pickpu_list: def_arr, + pickpu_list: ee.data.data.pageData + }); //门店分类要排序下 function compare(property) { return function (a, b) { @@ -2042,15 +2043,15 @@ Page({ } - var sd={ - all_sto: newarr, - is_show_sto_cat:1 - } - if(!sto_arr || sto_arr.length<=10){ - sd.is_show_sto_cat=-1; - sd.only_pk=sto_arr; - } - th.setData(sd); + var sd = { + all_sto: newarr, + is_show_sto_cat: 1 + } + if (!sto_arr || sto_arr.length <= 10) { + sd.is_show_sto_cat = -1; + sd.only_pk = sto_arr; + } + th.setData(sd); } else { th.setData({ @@ -2399,21 +2400,21 @@ Page({ } } else { - //活动已结束,全部设置为'00' - obj = { - day: '00', - hou: '00', - min: '00', - sec: '00' - } - th.setData({ - prom_time_text: '活动已经结束:', - prom_st: 3 - }) - th.setData({ - djs: obj - }); - return false; + //活动已结束,全部设置为'00' + obj = { + day: '00', + hou: '00', + min: '00', + sec: '00' + } + th.setData({ + prom_time_text: '活动已经结束:', + prom_st: 3 + }) + th.setData({ + djs: obj + }); + return false; } @@ -2427,56 +2428,56 @@ Page({ //-------------获取购买数量的总函数---------------- - get_buy_num: function (gd, func) { - var map = this.data.g_buy_num, - th = this, - user_id = getApp().globalData.user_id; - if (user_id == null) { - map.set(gd.goods_id, 0); + get_buy_num: function (gd, func) { + var map = this.data.g_buy_num, + th = this, + user_id = getApp().globalData.user_id; + if (user_id == null) { + map.set(gd.goods_id, 0); + th.setData({ + g_buy_num: map, + prom_buy_num: 0, + }); + "function" == typeof func && func(); + return false; + } + + if (map.has(gd.goods_id)) { + "function" == typeof func && func(); + } else { + //----获取商品购买数---- + getApp().request.get("/api/weshop/ordergoods/getUserBuyGoodsNum", { + data: { + store_id: os.stoid, + user_id: user_id, + goods_id: gd.goods_id, + }, + success: function (t) { + if (t.data.code == 0) { + var g_buy_num = t.data.data.goodsbuynum; + map.set(gd.goods_id, g_buy_num); th.setData({ - g_buy_num: map, - prom_buy_num: 0, + g_buy_num: map, }); - "function" == typeof func && func(); - return false; - } - - if (map.has(gd.goods_id)) { - "function" == typeof func && func(); - } else { - //----获取商品购买数---- - getApp().request.get("/api/weshop/ordergoods/getUserBuyGoodsNum", { - data: { - store_id: os.stoid, - user_id: user_id, - goods_id: gd.goods_id, - }, - success: function (t) { - if (t.data.code == 0) { - var g_buy_num = t.data.data.goodsbuynum; - map.set(gd.goods_id, g_buy_num); - th.setData({ - g_buy_num: map, - }); - getApp().request.get("/api/weshop/order/orderPresell/countBuyGoodsSum",{ - data: {store_id: os.stoid, user_id: user_id, goods_id: gd.goods_id, prom_id: gd.prom_id}, - success: function (e) { - if (e.data.code == 0) { - th.setData({prom_buy_num: e.data.data.sumgoodsnum}) - "function" == typeof func && func(); - } else { - th.setData({prom_buy_num: 0,}) - "function" == typeof func && func(); - } - - } - }); - - } + getApp().request.get("/api/weshop/order/orderPresell/countBuyGoodsSum", { + data: { store_id: os.stoid, user_id: user_id, goods_id: gd.goods_id, prom_id: gd.prom_id }, + success: function (e) { + if (e.data.code == 0) { + th.setData({ prom_buy_num: e.data.data.sumgoodsnum }) + "function" == typeof func && func(); + } else { + th.setData({ prom_buy_num: 0, }) + "function" == typeof func && func(); } + + } }); + + } } - }, + }); + } + }, //--拼单推荐的显示--- tj_Click: function (e) { @@ -2488,7 +2489,7 @@ Page({ //-------跳转pt商品------- go_to_nopay: function () { - var th =this,url = "/pages/user/order_detail/order_detail?order_id=" + th.data.buy_order.order_id; + var th = this, url = "/pages/user/order_detail/order_detail?order_id=" + th.data.buy_order.order_id; getApp().goto(url); }, @@ -2635,12 +2636,12 @@ Page({ //过滤不是本商品的单品优惠券 if (quan_list.length > 0) { let goodInfo = th.data.data - for (let index = quan_list.length-1; index >= 0; index--) { - if (quan_list[index].useobjecttype==20) { //判断是单品优惠券 + for (let index = quan_list.length - 1; index >= 0; index--) { + if (quan_list[index].useobjecttype == 20) { //判断是单品优惠券 if (quan_list[index].useobjectno != goodInfo.goods_sn) { - quan_list.splice(index,1) + quan_list.splice(index, 1) } - } + } } } //------------------------ @@ -2740,7 +2741,13 @@ Page({ } }) }, - + saveImageFn(){ + if(this.data.share_b_img){ + this.saveImageToPhotosAlbum() + }else{ + this.saveImageToPhotosAlbumDef() + } + }, //--定义的保存图片方法,分享团--- saveImageToPhotosAlbum: function () { //--先判断会员状态-- @@ -3066,7 +3073,608 @@ Page({ } }); }, + //--定义的保存图片方法,分享团--- + saveImageToPhotosAlbumDef: function () { + //--先判断会员状态-- + var user_info = getApp().globalData.userInfo; + if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) { + //getApp().my_warnning("请先登录",0,this); + wx.navigateTo({url: '/packageE/pages/togoin/togoin',}) + return false; + } + + if (this.data.share_hidden) { + this.setData({share_hidden: false,}); + }; + + //类型 0普通商品 1秒杀商品 2商家和会员团 3阶梯团 4阶梯团 + var type = this.data.prom_type; + console.log('商品类型-----'); + console.log(type); + // if (type == 2) type = -1; + if (type == 4) type = 0; + if (type == 8) type = 0; + if (type == 2) type = 0; + if (type == 6) type = 2; // 6拼团 2团购 + if (type == 10) type = -1; + + + if (this.data.prom_act && this.data.prom_act.kttype == 3) type = 3; + console.log('商品类型。。。。。'); + console.log(type); + wx.showLoading({title: '生成中...',}) + var that = this, th = that; + //设置画板显示,才能开始绘图 + that.setData({ + canvasHidden: false + }) + + var app = getApp(); + var unit = that.data.screenWidth / 750 * 1.35; //基础单位, + var path2 = that.data.data.original_img; + var scene = th.data.gid + ""; + scene += "." + th.data.sele_g.prom_type + "." + th.data.sele_g.prom_id; + + var user_id = getApp().globalData.user_id ? getApp().globalData.user_id : 0; + if (user_id > 0) { + scene += "_" + user_id; + } + //-- 如果不是会员分享过来的要分享给别人 -- + if (getApp().globalData.room_id && th.data.data.goods_id == getApp().globalData.room_goods_id && !getApp().globalData.room_user_share) { + //固定房间是第3个字符 + if (!user_id) scene += "_0"; + scene += "_" + getApp().globalData.room_id; + } + + ///二微码 + var path3 = os.url + "/api/wx/open/app/user/getWeAppEwm/" + + os.stoid + "?sceneValue=" + scene + "&pageValue=packageC/pages/presell/goodsInfo/goodsInfo"; + + console.log(path3); + + + // 读取文件成功则OK-- + wx.getImageInfo({ + src: path3, + success: function (res) { + // 回调写法 + th.get_head_temp(th.get_goods_temp, function () { + var vpath = res.path; + var context = wx.createCanvasContext('share'); + // 先画背景 + var pg_path = "../../../../images/share/share_bg.png"; + + //-- 如果有自定义海报的时候,判断背景的图片 -- + if (th.data.share_b_img) { + pg_path = th.data.share_b_img; + } + // context.drawImage(pg_path, 0, 0, 554 * unit, 899 * unit); + console.log('海报类型-----') + console.log(type); + + if ( !th.data.share_b_img && (type == 0 || type == 1 || type == 2 || type == 3 )){ // 如果是普通商品,绘制新海报 + th.drawPoster(context, unit, th.data.share_goods_img, vpath, type); + } else { + context.drawImage(pg_path, 0, 0, 554 * unit, 899 * unit); + // 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); + + + //-- 是自定义海报的情况下 -- + if (th.data.share_b_img || (type != 0 && type != 1 && type != 2 && type != 3)) { + + if (th.data.poster && parseInt(th.data.poster.style) == 2) { + //在线上分享人的情况下 + if (parseInt(th.data.poster.show_headpic)) { + //获取坐标 + var x = parseFloat(th.data.poster.head_x) * 2; + var y = parseFloat(th.data.poster.head_y) * 2; + var x1 = (x + 90) * unit; + var y1 = (y + 50) * unit; + //--昵称--- + context.setFontSize(24 * unit) + context.setFillStyle("black") + context.fillText(app.globalData.userInfo.nickname, x1, y1); + var width = 24 * app.globalData.userInfo.nickname.length * unit + 4 * unit; + //强烈推荐 改许程 + var tj_path = "../../../../images/share/q_tj.png"; + context.drawImage(tj_path, x1 + width, y1 - 22 * unit, 85 * unit, 30 * unit); + context.setFontSize(16 * unit); + context.setLineJoin('round'); //交点设置成圆角 + context.setFillStyle("white"); + context.fillText('强烈推荐', x1 + width + 8 * unit, y1 - 1 * unit); + + //context.setFillStyle("black") + //context.setFontSize(24 * unit) + //context.fillText(getApp().globalData.config.store_name, 40 * unit, 130 * unit); + } + } else { + //--昵称--- + context.setFontSize(24 * unit); + context.setFillStyle("black"); + context.fillText(app.globalData.userInfo.nickname, 152 * unit, 76 * unit); + var width = 24 * app.globalData.userInfo.nickname.length * unit + 2 * unit; + //强烈推荐 改许程 + var tj_path = "../../../../images/share/q_tj.png"; + context.drawImage(tj_path, 152 * unit + width, 54 * unit, 85 * unit, 30 * unit); + context.setFontSize(16 * unit); + context.setLineJoin('round'); //交点设置成圆角 + context.setFillStyle("white"); + context.fillText('强烈推荐', 149 * unit + width + 15 * unit, 75 * unit); + } + + }; + + + var share_title = th.data.data.goods_name; + if (th.data.prom_type == 1 || th.data.prom_type == 2 || th.data.prom_type == 6 || th.data.prom_type == 4) { + share_title = th.data.prom_act.share_title; + if (!share_title) share_title = th.data.prom_act.title; + if (th.data.prom_type == 4) share_title = th.data.prom_act.name; + } + + //---产品名称--- + //文本换行 参数:1、canvas对象,2、文本 3、距离左侧的距离 4、距离顶部的距离 5、6、文本的宽度 + if (th.data.share_b_img || (type != 4 && type != 0 && type != 1 && type != 2 && type != 3)) { + context.setFillStyle("black"); + context.setFontSize(21.3 * unit) + getApp().draw_Text(context, share_title, + 38 * unit, 180 * unit, 200 * unit, 279 * unit, unit); + + //------产品的价格------- + context.setFontSize(23 * unit) + context.setFillStyle("red") + + var pri0 = th.data.data.shop_price; + if (th.data.card_field && th.data.data[th.data.card_field]) { + pri0 = th.data.data[th.data.card_field]; + } + + if (th.data.prom_act) + 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); + context.setFontSize(31 * unit) + context.fillText(pri0, 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("black"); + context.setFontSize(21.3 * unit) + getApp().draw_Text(context, share_title, + 38 * unit, 170 * unit, 20 * unit, 300 * unit, unit); + //------ 产品的价格 ----- + var pri0 = th.data.prom_act.addmoney; + var integral = th.data.prom_act.integral; + var text = ""; + if (integral) { + text = integral + "积分"; + } + if (pri0 && integral) { + text += "+"; + } + if (pri0) { + text += "¥" + pri0; + } + + if (!pri0 && !integral) { + text = "0积分"; + } + context.setFillStyle("red"); + context.fillText(text, 38 * unit, 235 * 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); + } + ; + + //---自定义海报 产品质量保证 + if(th.data.share_b_img && th.data.poster.show_quality==1 ){ + var g_path = "../../../../images/share/s_gou.png"; + context.drawImage(g_path, 56 * unit, 670 * unit, 22 * unit, 22 * unit); + context.setFillStyle("red") + context.setFontSize(18 * unit) + context.fillText("正品保证", 84 * unit, 690 * unit); + + context.drawImage(g_path, 218 * unit, 670 * unit, 22 * unit, 22 * unit); + context.setFillStyle("red") + context.setFontSize(18 * unit) + context.fillText("纯实体店", 246 * unit, 690 * unit); + + context.drawImage(g_path, 388 * unit, 670 * unit, 22 * unit, 22 * unit); + context.setFillStyle("red") + context.setFontSize(18 * unit) + context.fillText("官方验证", 420 * unit, 690 * unit); + + } + //-------大图后面就不一样了----------- + switch (type) { + case 0: + if(!th.data.share_b_img){ + break + } + //---画线--- + context.setLineWidth(1 * unit) + context.moveTo(32 * unit, 710 * unit) + context.lineTo(520 * unit, 710 * unit) + context.stroke(); + //---文字--- + context.setFillStyle("black") + context.setFontSize(22 * unit) + // 原来start ---> + context.fillText("优惠乐翻天,精彩就在你身边", 40 * unit, 776 * unit); + context.fillText("长按识别二维码,立即开始抢购", 40 * unit, 826 * unit); + // <--- 原来end + // context.fillText("优惠乐翻天,精彩就在你身边", 40 * unit, 816 * unit); + // context.setFontSize(18 * unit) + // context.fillText("长按识别二维码,立即开始抢购", 40 * unit, 850 * unit); + //---二维吗图--- + context.drawImage(vpath, 380 * unit, 736 * unit, 120 * unit, 120 * unit); + break;//普通商品的展示 + case 4: + // 中间的几个字 + if (th.data.poster && parseInt(th.data.poster.style) == 2) { + if (parseInt(th.data.poster.show_quality)) { + var g_path = "../../../../images/share/s_gou.png"; + context.drawImage(g_path, 56 * unit, 670 * unit, 22 * unit, 22 * unit); + context.setFillStyle("red") + context.setFontSize(18 * unit) + context.fillText("正品保证", 84 * unit, 690 * unit); + + context.drawImage(g_path, 218 * unit, 670 * unit, 22 * unit, 22 * unit); + context.setFillStyle("red") + context.setFontSize(18 * unit) + context.fillText("纯实体店", 246 * unit, 690 * unit); + + context.drawImage(g_path, 388 * unit, 670 * unit, 22 * unit, 22 * unit); + context.setFillStyle("red") + context.setFontSize(18 * unit) + context.fillText("官方验证", 420 * unit, 690 * unit); + } + + } else { + var g_path = "../../../../images/share/s_gou.png"; + context.drawImage(g_path, 56 * unit, 670 * unit, 22 * unit, 22 * unit); + context.setFillStyle("red") + context.setFontSize(18 * unit) + context.fillText("正品保证", 84 * unit, 690 * unit); + + context.drawImage(g_path, 218 * unit, 670 * unit, 22 * unit, 22 * unit); + context.setFillStyle("red") + context.setFontSize(18 * unit) + context.fillText("纯实体店", 246 * unit, 690 * unit); + + context.drawImage(g_path, 388 * unit, 670 * unit, 22 * unit, 22 * unit); + context.setFillStyle("red") + context.setFontSize(18 * unit) + context.fillText("官方验证", 420 * unit, 690 * unit); + } + + + //---画线--- + context.setLineWidth(1 * unit) + context.moveTo(32 * unit, 710 * unit) + context.lineTo(520 * unit, 710 * unit) + context.stroke(); + + //---文字--- + context.setFillStyle("black") + context.setFontSize(22 * unit) + + if (type == 0 || type == -1) { + // 原来start ---> + context.setFontSize(24 * unit) + context.fillText(th.data.sto_sele_name_1, 40 * unit, 766 * unit); + + context.setFontSize(22 * unit) + context.fillText("优惠乐翻天,精彩就在你身边", 40 * unit, 806 * unit); + context.fillText("长按识别二维码,立即开始抢购", 40 * unit, 846 * unit); + + } else { + context.setFontSize(24 * unit) + context.fillText(th.data.sto_sele_name_1, 40 * unit, 766 * unit); + context.setFontSize(22 * unit) + context.fillText("长按识别二维码", 40 * unit, 806 * unit); + context.fillText("立即开始兑换", 40 * unit, 846 * unit); + + } + + //---二维吗图--- + //-- 自定义海报 -- + if (th.data.share_b_img || th.data.poster) { + 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); + } else { + //---二维吗图--- + context.drawImage(vpath, 390 * unit, 726 * unit, 136 * unit, 136 * unit); + } + ; + + break; + case 1: //秒杀商品的展示 + if(!th.data.share_b_img){ + break + } + //---画线--- + context.setLineWidth(1 * unit) + context.moveTo(32 * unit, 670 * unit) + context.lineTo(520 * unit, 670 * unit) + context.stroke(); + + //画秒杀的图片 + var miaos_path = '../../../../images/share/miao_share.png'; + context.drawImage(miaos_path, 43 * unit, 700 * unit, 222 * unit, 40 * unit); + + context.setFillStyle("black") + context.setFontSize(24 * unit) + context.fillText(th.data.sto_sele_name_1, 40 * unit, 786 * unit); + //---文字--- + context.setFontSize(22 * unit) + context.setFillStyle("black") + context.fillText("特惠好物,限时秒杀", 40 * unit, 826 * unit); + context.fillText("长按识别二维码,立即开始抢购", 40 * unit, 866 * unit); + + + //---二维吗图--- + //-- 自定义海报 -- + if (th.data.share_b_img || th.data.poster) { + 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, 135 * unit, 135 * unit); + } else { + //---二维吗图--- + context.drawImage(vpath, 390 * unit, 726 * unit, 135 * unit, 135 * unit); + } + break; + + case 2: //会员团和商家团的展示 + if(!th.data.share_b_img){ + break + } + //---画线--- + context.setLineWidth(1 * unit) + context.moveTo(32 * unit, 670 * unit) + context.lineTo(520 * unit, 670 * unit) + context.stroke(); + //---文字--- + context.setFillStyle("black") + context.setFontSize(24 * unit) + context.fillText(th.data.sto_sele_name_1, 40 * unit, 720 * unit); + + //绘制成团图片 + var ct_img = "../../../../images/share/ct_num.png"; + context.drawImage(ct_img, 40 * unit, 740 * unit, 120 * unit, 30 * unit); + var ct_num = th.data.prom_act.ct_num; + context.setFontSize(14 * unit) + context.font = 'normal'; + context.setFillStyle("red") + if (ct_num < 10) { + context.fillText(ct_num + "人拼团", 92 * unit, 760 * unit); + } else { + context.fillText(ct_num + "人拼团", 86 * unit, 760 * unit); + } + context.setFontSize(22 * unit) + context.fillText("已拼" + th.data.prom_act.buy_num + "份", 166 * unit, 763 * unit); + + context.setFillStyle("gray") + context.fillText("快来和我一起拼团吧!", 40 * unit, 806 * unit); + context.setFillStyle("black") + context.font = 'normal bold 18px sans-serif'; + context.setFontSize(21.3 * unit) + context.fillText("长按识别二维码,立即参团", 40 * unit, 836 * unit); + + + //---二维吗图--- + //-- 自定义海报 -- + if (th.data.share_b_img || th.data.poster) { + 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); + } else { + //---二维吗图--- + context.drawImage(vpath, 390 * unit, 726 * unit, 136 * unit, 136 * unit); + } + break + case 3: //阶梯团的展示 + if(!th.data.share_b_img){ + break + } + //---画线--- + context.setLineWidth(1 * unit) + context.moveTo(32 * unit, 670 * unit) + context.lineTo(520 * unit, 670 * unit) + context.stroke(); + //---文字--- + context.setFillStyle("black") + context.setFontSize(24 * unit) + context.fillText(th.data.sto_sele_name_1, 40 * unit, 720 * unit); + + //---绘制中间阶梯的价格--- + var list = th.data.prom_act.ct_rylist; + for (var i = 0; i < list.length; i++) { + var item = list[i]; + var wi = i * 90 * unit; + context.font = 'normal'; + context.setFontSize(16 * unit) + context.setFillStyle("red") + context.fillText("¥", 40 * unit + wi, 756 * unit); + context.setFontSize(22 * unit) + var pri = parseFloat(item.price).toFixed(2); + context.fillText(pri, 56 * unit + wi, 756 * unit); + context.setFillStyle("gray") + context.fillText("满" + item.rynum + "人", 40 * unit + wi, 786 * unit); + } + //----------------下面部分---------------- + + context.setFillStyle("black") + context.fillText("快来和我一起拼团吧!", 40 * unit, 820 * unit); + //context.font = 'normal bold 18px sans-serif'; + context.setFontSize(21 * unit) + context.fillText("长按识别二维码,立即参团", 40 * unit, 850 * unit); + + + //-- 自定义海报 -- + if (th.data.share_b_img || th.data.poster) { + 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); + } else { + //---二维吗图--- + context.drawImage(vpath, 390 * unit, 726 * unit, 136 * unit, 136 * unit); + } + break + + + case -1: //秒杀商品的展示 + //---画线--- + context.setLineWidth(1 * unit) + context.moveTo(32 * unit, 670 * unit) + context.lineTo(520 * unit, 670 * unit) + context.stroke(); + + + context.setFillStyle("black") + context.setFontSize(24 * unit) + context.fillText(th.data.sto_sele_name_1, 40 * unit, 744 * unit); + //---文字--- + context.setFontSize(22 * unit) + context.setFillStyle("black") + context.fillText("长按识别二维码", 40 * unit, 800 * unit); + context.fillText("立即开始抢购", 40 * unit, 846 * unit); + + + //---二维吗图--- + //-- 自定义海报 -- + if (th.data.share_b_img || th.data.poster) { + 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, 135 * unit, 135 * unit); + } else { + //---二维吗图--- + context.drawImage(vpath, 390 * unit, 726 * unit, 135 * unit, 135 * unit); + } + break; + + + } + + + //--- 如果是自定义海报的时候 --- + if ( th.data.share_b_img || (type != 0 && type != 1 && type != 2 && type != 3)) { + + if (th.data.poster && parseInt(th.data.poster.style) == 2) { + + //如果显示会员信息的话 + if (parseInt(th.data.poster.show_headpic)) { + //获取坐标 + var x = parseFloat(th.data.poster.head_x) * 2; + var y = parseFloat(th.data.poster.head_y) * 2; + //---绘制圆形要放在最后---- + context.save(); + context.beginPath(); + var h_x = x * unit; + var h_y = y * unit; + var h_r = 40 * unit; + var cx = h_x + h_r; + var cy = h_y + h_r; + context.arc(cx, cy, h_r, 0, Math.PI * 2, false); + context.closePath(); + context.fill(); + context.clip(); + context.drawImage(th.data.share_head, h_x, h_y, h_r * 2, h_r * 2); + context.restore(); + } + + } else { + //---绘制圆形要放在最后---- + context.save(); + context.beginPath(); + var h_x = 60 * unit; + var h_y = 24 * unit; + var h_r = 40 * unit; + var cx = h_x + h_r; + var cy = h_y + h_r; + context.arc(cx, cy, h_r, 0, Math.PI * 2, false); + context.closePath(); + context.fill(); + context.clip(); + context.drawImage(th.data.share_head, h_x, h_y, h_r * 2, h_r * 2); + context.restore(); + } + + } + ; + + + //把画板内容绘制成图片,并回调 画板图片路径 + context.draw(false, function () { + setTimeout(function () { + wx.canvasToTempFilePath({ + x: 0, + y: 0, + width: 750, + height: 1217, + destWidth: 1.2 * 750 * 750 / that.data.screenWidth, + destHeight: 1.2 * 1217 * 750 / that.data.screenWidth, + canvasId: 'share', + success: function (res) { + + that.setData({ + shareImgPath: res.tempFilePath, + canvasHidden: true + }) + + if (!res.tempFilePath) { + wx.showModal({ + title: '提示', + content: '图片绘制中,请稍后重试', + showCancel: false + }) + return false; + } + + that.setData({ + showPoster: true, + }); + wx.hideLoading(); + } + }) + }, 500) + + }); + }); + }, + fail: function (res) { + console.log(res); + wx.hideLoading(); + + } + }); + }, //文本换行 参数:1、canvas对象,2、文本 3、距离左侧的距离 4、距离顶部的距离 5、6、文本的宽度 draw_Text: function (ctx, str, leftWidth, initHeight, titleHeight, canvasWidth, unit) { @@ -3095,7 +3703,144 @@ Page({ } } }, + drawPoster(context, unit, img, vpath, type) { + // 1.灰色背景 + 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 + // 图片的y坐标 + let bg_y = 157 * unit + // 图片宽度 + let bg_w = 480 * unit + // 图片高度 + let bg_h = 474 * unit + // 图片圆角 + let bg_r = 4 + // 绘制海报背景图片圆角 + context.save() + context.beginPath() + context.arc(bg_x + bg_r, bg_y + bg_r, bg_r, Math.PI, Math.PI * 1.5) + context.arc(bg_x + bg_w - bg_r, bg_y + bg_r, bg_r, Math.PI * 1.5, Math.PI * 2) + context.arc(bg_x + bg_w, bg_y + bg_h, bg_r, 0, Math.PI * 0.5) + context.arc(bg_x, bg_y + bg_h, 0, Math.PI * 0.5, Math.PI) + 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); + } + }; + + // 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{ + if(this.data.prom_type ==8){ + price = this.data.presellList.presell_price + context.fillText('¥' + price, 54 * unit, 735 * unit); + }else{ + context.fillText('¥' + price, 54 * unit, 735 * 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); + + // 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'); + context.rect(354 * unit, 670 * unit, 1 * unit, 130 * unit); + context.fill(); + }, // ----视频图片---- // 图片计数器 swiperChange: function (e) { @@ -3181,7 +3926,7 @@ Page({ tt(); return false; } - var img_url = ee.data.data.original_img; + var img_url = ee.data.data.original_img; //var img_url = ee.data.presellForm.share_img; //img_url?img_url:ee.data.data.original_img; @@ -3196,8 +3941,8 @@ Page({ fail: function (res) { //获取默认空白图 wx.getImageInfo({ - src: ee.data.iurl+'/miniapp/images/default_g_img.gif', - success: function(res) { + src: ee.data.iurl + '/miniapp/images/default_g_img.gif', + success: function (res) { ee.data.share_goods_img = res.path; //分享的图片不能用网络的 tt(); } @@ -3241,22 +3986,22 @@ Page({ getHistoryBuy() { let _this = this; let req_data = { - store_id: os.stoid, - goods_id: this.data.gid, - pay_status: 1, - rndid: 1 + store_id: os.stoid, + goods_id: this.data.gid, + pay_status: 1, + rndid: 1 }; getApp().request.promiseGet('/api/weshop/ordergoods/list', { - data: req_data, + data: req_data, }) - .then(res => { - if (ut.ajax_ok(res)) { - _this.setData({ - historyBuyInfo: res.data.data.pageData, - }) - } - }) -}, + .then(res => { + if (ut.ajax_ok(res)) { + _this.setData({ + historyBuyInfo: res.data.data.pageData, + }) + } + }) + }, //--调用更新阶梯团的接口-- update_jiti: function (id) { @@ -3284,8 +4029,8 @@ Page({ var bconfig = th.data.bconfig; //如果开启了,则不在选择门店 - if(this.data.sys_switch.is_pricing_open_store && getApp().globalData.pk_store){ - return false; + if (this.data.sys_switch.is_pricing_open_store && getApp().globalData.pk_store) { + return false; } if (!th.data.only_pk && !th.data.def_pickpu_list) { @@ -3909,7 +4654,7 @@ Page({ onShareTimeline() { - getApp().globalData.no_clear=1; + getApp().globalData.no_clear = 1; var store_name = getApp().globalData.config ? getApp().globalData.config.store_name : ''; if (!store_name) store_name = getApp().globalData.setting.appName; @@ -3924,10 +4669,10 @@ Page({ }, clickShare() { - if(!getApp().globalData.user_id){ - getApp().goto("/packageE/pages/togoin/togoin"); - return false; - } + if (!getApp().globalData.user_id) { + getApp().goto("/packageE/pages/togoin/togoin"); + return false; + } this.setData({ share_hidden: true, }); }, @@ -3958,206 +4703,206 @@ Page({ }, //获取预售的信息 - async get_pre_prom(func) { - var th = this; - var presell_id = null; - var pre_arr = null; - - if (!th.data.pre_id) { - var presell_id = th.data.presell_id; - var url = "/api/weshop/marketing/marketingPresellList/list" - var rd = { - store_id: os.stoid, - presell_id: presell_id, - goods_id: th.data.gid - } - //------获取预售从表---------- - await getApp().request.promiseGet(url, { - data: rd - }).then(res => { - if (res.data.code == 0 && res.data.data && res.data.data.length > 0) { - var arr = res.data.data[0]; - presell_id = arr.presell_id; - th.setData({ - presellList: arr, - }) - } - }) + async get_pre_prom(func) { + var th = this; + var presell_id = null; + var pre_arr = null; - } else { - //------获取预售从表---------- - await getApp().request.promiseGet("/api/weshop/marketing/marketingPresellList/get/" + os.stoid + "/" + th.data.pre_id, {}).then(res => { - if (res.data.code == 0 && res.data.data) { - var arr = res.data.data; - presell_id = arr.presell_id; - th.setData({ - presellList: arr, - }) - } - }) + if (!th.data.pre_id) { + var presell_id = th.data.presell_id; + var url = "/api/weshop/marketing/marketingPresellList/list" + var rd = { + store_id: os.stoid, + presell_id: presell_id, + goods_id: th.data.gid + } + //------获取预售从表---------- + await getApp().request.promiseGet(url, { + data: rd + }).then(res => { + if (res.data.code == 0 && res.data.data && res.data.data.length > 0) { + var arr = res.data.data[0]; + presell_id = arr.presell_id; + th.setData({ + presellList: arr, + }) } + }) - if (!presell_id) { - wx.showToast({title: "未找到活动商品", icon: 'none', duration: 3000}); - ut.wx_back(); - return false; + } else { + //------获取预售从表---------- + await getApp().request.promiseGet("/api/weshop/marketing/marketingPresellList/get/" + os.stoid + "/" + th.data.pre_id, {}).then(res => { + if (res.data.code == 0 && res.data.data) { + var arr = res.data.data; + presell_id = arr.presell_id; + th.setData({ + presellList: arr, + }) } + }) + } - var gnext=1; - //------获取预售主表---------- - await getApp().request.promiseGet(`/api/weshop/marketing/marketingPresellForm/get/${os.stoid}/${presell_id}`, {}).then(res => { - if (res.data.code == 0 && res.data.data) { - var act_data = res.data.data; - if (act_data.is_end) { - wx.showToast({title: "活动已经结束", icon: 'none', duration: 3000}); - setTimeout(function () { - ut.wx_back(); - }, 2000) - gnext=0; - return false; - } - if (act_data.isuse == 0) { - wx.showToast({title: "活动未启用", icon: 'none', duration: 3000}); - setTimeout(function () { - ut.wx_back(); - }, 2000) - gnext=0; - return false; - } - - var err_txt="活动定金时间已经结束"; - var end_time = act_data.end_time; - if (act_data.presell_type == 1) { - err_txt="活动时间已经结束"; - } - if (end_time < ut.gettimestamp()) { - wx.showToast({title:err_txt, icon: 'none', duration: 3000}); - setTimeout(function () { - getApp().goto("/pages/index/index/index"); - }, 2000) - gnext=0; - return false; - } - - if (act_data.presell_type == 0) { - end_time = act_data.pay_enddate; - err_txt="活动尾款时间已经结束"; - } - if (end_time < ut.gettimestamp()) { - wx.showToast({title:err_txt, icon: 'none', duration: 3000}); - setTimeout(function () { - ut.wx_back(); - }, 2000) - gnext=0; - return false; - } - - if (act_data.start_time > ut.gettimestamp()) { - wx.showToast({title:"活动还未开始", icon: 'none', duration: 3000}); - setTimeout(function () { - ut.wx_back(); - }, 2000) - gnext=0; - return false; - } + if (!presell_id) { + wx.showToast({ title: "未找到活动商品", icon: 'none', duration: 3000 }); + ut.wx_back(); + return false; + } - th.setData({ - presellForm: res.data.data, - }); - th.countDown(res.data.data.end_time) - } - }) + var gnext = 1; + //------获取预售主表---------- + await getApp().request.promiseGet(`/api/weshop/marketing/marketingPresellForm/get/${os.stoid}/${presell_id}`, {}).then(res => { + if (res.data.code == 0 && res.data.data) { + var act_data = res.data.data; + if (act_data.is_end) { + wx.showToast({ title: "活动已经结束", icon: 'none', duration: 3000 }); + setTimeout(function () { + ut.wx_back(); + }, 2000) + gnext = 0; + return false; + } + if (act_data.isuse == 0) { + wx.showToast({ title: "活动未启用", icon: 'none', duration: 3000 }); + setTimeout(function () { + ut.wx_back(); + }, 2000) + gnext = 0; + return false; + } - if(!gnext){ - return false; + var err_txt = "活动定金时间已经结束"; + var end_time = act_data.end_time; + if (act_data.presell_type == 1) { + err_txt = "活动时间已经结束"; + } + if (end_time < ut.gettimestamp()) { + wx.showToast({ title: err_txt, icon: 'none', duration: 3000 }); + setTimeout(function () { + getApp().goto("/pages/index/index/index"); + }, 2000) + gnext = 0; + return false; } - var userInfo = getApp().globalData.userInfo; - var pre_data = {store_id: os.stoid, is_end: 0, timetype: 1, isuse: 1, prom_type: 8, prom_id: presell_id,pageSize:1000}; - if (userInfo) { - pre_data.user_id = userInfo.user_id; + if (act_data.presell_type == 0) { + end_time = act_data.pay_enddate; + err_txt = "活动尾款时间已经结束"; } - await getApp().request.promiseGet("/api/weshop/marketing/marketingPresellList/page", { - data: pre_data, - }).then(e => { - if (e.data.code == 0 && e.data.data.pageData && e.data.data.pageData.length > 0) { - - th.data.all_pre_goods = e.data.data.pageData; - var idx = e.data.data.pageData.findIndex(function (ele) { - return ele.id == th.data.presellList.id; - }) - - pre_arr = e.data.data.pageData[idx]; - th.setData({pre_arr: pre_arr,show:1}) - th.data.prom_buy_limit = pre_arr.vip_butyqty; - } - }) - if (!pre_arr) { - wx.showToast({title: "当前会员身份不符或者时间已过期,无法参与", icon: 'none', duration: 3000}); - setTimeout(function () { - ut.wx_back(); - }, 2000) - return false; + if (end_time < ut.gettimestamp()) { + wx.showToast({ title: err_txt, icon: 'none', duration: 3000 }); + setTimeout(function () { + ut.wx_back(); + }, 2000) + gnext = 0; + return false; } - if (func) { - func(); + + if (act_data.start_time > ut.gettimestamp()) { + wx.showToast({ title: "活动还未开始", icon: 'none', duration: 3000 }); + setTimeout(function () { + ut.wx_back(); + }, 2000) + gnext = 0; + return false; } - }, - con_weixin:function () { - getApp().con_wx(this); - }, - - // 预览海报 - previewPoster() { - getApp().globalData.no_clear=1; - wx.previewImage({ - current: this.data.shareImgPath, // 当前显示图片的http链接 - urls: [this.data.shareImgPath] ,// 需要预览的图片http链接列表 - }); - }, - - - click_contact:function () { - getApp().globalData.no_clear=1; - }, - - //打开客服操作菜单 - openCS() { - // 判断会员状态 - let user_info = getApp().globalData.userInfo; - if (user_info == null || user_info.mobile == undefined || user_info.mobile == '' || user_info.mobile == null) { - wx.navigateTo({ - url: '/packageE/pages/togoin/togoin', - }) - return false; - }; - // csType/在线客服设置: - // 0关闭(如果有设置热线电话,则显示拨打热线电话)、 - // 1小程序客服、 - // 2企业微信客服 - if(this.data.sys_switch) { - let csType = this.data.sys_switch.weapp_customertype; - if(csType == 0) { - // 拨打电话号码 - this.contactService(); - } else { - this.getTel() - .then(() => { - self.setData({ - hiddenCS: false, - }); - }); - }; - }; - - }, - - //关闭客服操作菜单 - closeCS() { - this.setData({ - hiddenCS: true, - }); - }, + th.setData({ + presellForm: res.data.data, + }); + th.countDown(res.data.data.end_time) + } + }) + + if (!gnext) { + return false; + } + + var userInfo = getApp().globalData.userInfo; + var pre_data = { store_id: os.stoid, is_end: 0, timetype: 1, isuse: 1, prom_type: 8, prom_id: presell_id, pageSize: 1000 }; + if (userInfo) { + pre_data.user_id = userInfo.user_id; + } + await getApp().request.promiseGet("/api/weshop/marketing/marketingPresellList/page", { + data: pre_data, + }).then(e => { + if (e.data.code == 0 && e.data.data.pageData && e.data.data.pageData.length > 0) { + + th.data.all_pre_goods = e.data.data.pageData; + var idx = e.data.data.pageData.findIndex(function (ele) { + return ele.id == th.data.presellList.id; + }) + + pre_arr = e.data.data.pageData[idx]; + th.setData({ pre_arr: pre_arr, show: 1 }) + th.data.prom_buy_limit = pre_arr.vip_butyqty; + } + }) + if (!pre_arr) { + wx.showToast({ title: "当前会员身份不符或者时间已过期,无法参与", icon: 'none', duration: 3000 }); + setTimeout(function () { + ut.wx_back(); + }, 2000) + return false; + } + if (func) { + func(); + } + }, + + con_weixin: function () { + getApp().con_wx(this); + }, + + // 预览海报 + previewPoster() { + getApp().globalData.no_clear = 1; + wx.previewImage({ + current: this.data.shareImgPath, // 当前显示图片的http链接 + urls: [this.data.shareImgPath],// 需要预览的图片http链接列表 + }); + }, + + + click_contact: function () { + getApp().globalData.no_clear = 1; + }, + + //打开客服操作菜单 + openCS() { + // 判断会员状态 + let user_info = getApp().globalData.userInfo; + if (user_info == null || user_info.mobile == undefined || user_info.mobile == '' || user_info.mobile == null) { + wx.navigateTo({ + url: '/packageE/pages/togoin/togoin', + }) + return false; + }; + // csType/在线客服设置: + // 0关闭(如果有设置热线电话,则显示拨打热线电话)、 + // 1小程序客服、 + // 2企业微信客服 + if (this.data.sys_switch) { + let csType = this.data.sys_switch.weapp_customertype; + if (csType == 0) { + // 拨打电话号码 + this.contactService(); + } else { + this.getTel() + .then(() => { + self.setData({ + hiddenCS: false, + }); + }); + }; + }; + + }, + + //关闭客服操作菜单 + closeCS() { + this.setData({ + hiddenCS: true, + }); + }, }); -- libgit2 0.21.4