diff --git a/app.js b/app.js index 7c34f27..dc1590b 100644 --- a/app.js +++ b/app.js @@ -428,10 +428,15 @@ App({ }) }, //获取场景值 判断是否是单页面 - is_Single_page() { + is_Single_page(_this,func) { let scene = wx.getLaunchOptionsSync().scene; //--判断是否是单页面-- - return scene == 1154? false:true; + if(scene !== 1154){ + typeof func =="function" && func.bind(_this)(); + }else{ + return false; + } + // return scene == 1154? false:true; }, diff --git a/packageA/pages/liveStream/liveStream.js b/packageA/pages/liveStream/liveStream.js index 158e0e5..b9ced4c 100644 --- a/packageA/pages/liveStream/liveStream.js +++ b/packageA/pages/liveStream/liveStream.js @@ -208,14 +208,13 @@ Page({ * 生命周期函数--监听页面加载 */ onLoad: function (options) { - self = this; - if(getApp().is_Single_page()){ + getApp().is_Single_page(this,function(){ app.isLogin().then(function(data) {//进入页面前已经授权登录成功 - self.setData({ + this.setData({ userInfo: data, }); }); - } + }) }, diff --git a/packageB/pages/luckactivity/luckinfo/luckinfo.js b/packageB/pages/luckactivity/luckinfo/luckinfo.js index 2acc288..f9370d2 100644 --- a/packageB/pages/luckactivity/luckinfo/luckinfo.js +++ b/packageB/pages/luckactivity/luckinfo/luckinfo.js @@ -1379,35 +1379,6 @@ Page({ }; }, 500); }; - // if(this.data.isImgOk) { - // setTimeout(function() { - // wx.hideLoading(); - // self.setData({ - // myimg: self.data.imgPath, - // hiddenCanvas: true, - // showMask: true, - // showPoster: true, - // }); - // }, 300); - - // } else { - // wx.showToast({ - // title: '生成失败,请重新点击', - // icon: 'none', - // }); - // }; - - // setTimeout(function() { - // // if(self.data.myimg) { - // if(self.data.imgPath) { - // wx.hideLoading(); - - // } else { - // console.log('没有生成图片!!!!!!', self.data.imgPath); - // }; - - // // } - // }, 300); }, closePoster() { diff --git a/packageB/pages/zuhegou/index/index.js b/packageB/pages/zuhegou/index/index.js index f21a4be..44dbb66 100644 --- a/packageB/pages/zuhegou/index/index.js +++ b/packageB/pages/zuhegou/index/index.js @@ -11,80 +11,80 @@ let imgDraw = { "height": "843px", "background": "https://mshopimg.yolipai.net/miniapp/images/zhg/bg-zuhegou.jpg", "views": [{ // 头像 - "type": "image", - "url": "https://desk-fd.zol-img.com.cn/t_s960x600c5/g5/M00/0F/08/ChMkJlauzXWIDrXBAAdCg2xP7oYAAH9FQOpVAIAB0Kb342.jpg", - "css": { - "width": "100px", - "height": "100px", - "top": "20px", - "left": "275px", - "borderRadius": "100px", - "mode": "scaleToFill", - "borderWidth": "2px", - "borderColor": "#fff", - } - }, - { //昵称 - "type": "text", - "text": "我是店铺名", - "css": { - "width": "650px", - "color": "#fff", - "top": "136px", - // "left": "137px", - "textAlign": "center", - "fontSize": "26px", - "maxLines": "1", - } - }, - { //10元任选3件 - "type": "text", - "text": "10元3件", - "css": { - "color": "#fff", - "width": "650px", - "top": "270px", - "fontSize": "70px", - "maxLines": "1", - "textAlign": "center", - "fontWeight": "bold", - } - }, - { //活动时间 - "type": "text", - "text": "活动时间:2021.07.06 - 2021.07.08", - "css": { - "color": "#333", - "width": "650px", - "top": "440px", - "fontSize": "26px", - "fontWeight": "normal", - "maxLines": "1", - "textAlign": "center" - } - }, - { // 码 - "type": "image", - "url": "https://desk-fd.zol-img.com.cn/t_s960x600c5/g5/M00/0F/08/ChMkJlauzXWIDrXBAAdCg2xP7oYAAH9FQOpVAIAB0Kb342.jpg", - "css": { - "color": "#000", - "width": "200px", - "height": "200px", - "top": "525px", - "left": "225px", - } - }, - { // 扫码提示 - "type": "text", - "text": "长按扫码即可参与活动", - "css": { - "color": "#666", - "width": "650px", - "top": "750px", - "fontSize": "26px", - "textAlign": "center" - } - }, + "type": "image", + "url": "https://desk-fd.zol-img.com.cn/t_s960x600c5/g5/M00/0F/08/ChMkJlauzXWIDrXBAAdCg2xP7oYAAH9FQOpVAIAB0Kb342.jpg", + "css": { + "width": "100px", + "height": "100px", + "top": "20px", + "left": "275px", + "borderRadius": "100px", + "mode": "scaleToFill", + "borderWidth": "2px", + "borderColor": "#fff", + } + }, + { //昵称 + "type": "text", + "text": "我是店铺名", + "css": { + "width": "650px", + "color": "#fff", + "top": "136px", + // "left": "137px", + "textAlign": "center", + "fontSize": "26px", + "maxLines": "1", + } + }, + { //10元任选3件 + "type": "text", + "text": "10元3件", + "css": { + "color": "#fff", + "width": "650px", + "top": "270px", + "fontSize": "70px", + "maxLines": "1", + "textAlign": "center", + "fontWeight": "bold", + } + }, + { //活动时间 + "type": "text", + "text": "活动时间:2021.07.06 - 2021.07.08", + "css": { + "color": "#333", + "width": "650px", + "top": "440px", + "fontSize": "26px", + "fontWeight": "normal", + "maxLines": "1", + "textAlign": "center" + } + }, + { // 码 + "type": "image", + "url": "https://desk-fd.zol-img.com.cn/t_s960x600c5/g5/M00/0F/08/ChMkJlauzXWIDrXBAAdCg2xP7oYAAH9FQOpVAIAB0Kb342.jpg", + "css": { + "color": "#000", + "width": "200px", + "height": "200px", + "top": "525px", + "left": "225px", + } + }, + { // 扫码提示 + "type": "text", + "text": "长按扫码即可参与活动", + "css": { + "color": "#666", + "width": "650px", + "top": "750px", + "fontSize": "26px", + "textAlign": "center" + } + }, ] }; @@ -123,7 +123,7 @@ Page({ * 生命周期函数--监听页面加载 */ onLoad: function (options) { - + console.log(options, 111); self = this; var the_id = options.id; @@ -154,228 +154,224 @@ Page({ } }) } - - //如果有会员的时候 - var userInfo = getApp().globalData.userInfo; - if (!userInfo) { - if(getApp().is_Single_page()){ - getApp().goto("/pages/togoin/togoin"); - return false; - } - } }, /** * 生命周期函数--监听页面显示 */ onShow: function () { - var th = this, - that = this, - ee = this; - this.data.is_timer = 1; - if (this.data.act) this.countDown(); - //如果有会员的时候 - var userInfo = getApp().globalData.userInfo; - if (userInfo) { - if (!th.data.is_get_act) { - //获取活动信息 - var url = "/api/weshop/prom/zhbuy/get/" + os.stoid + "/" + th.data.id + "/" + userInfo.user_id; - getApp().request.get(url, { - success: function (e) { - th.data.is_get_act = 1; - if (e.data.code == 0 && e.data.data) { - self.setData({ - act: e.data.data - }); - if (e.data.data.is_show != 1) { - th.setData({ - error: '活动未开启' - }); - return false; - } - if (ut.gettimestamp() < e.data.data.start_time) { - th.setData({ - error: '活动还未开始' + getApp().is_Single_page(this, function () { + var th = this, + that = this, + ee = this; + this.data.is_timer = 1; + if (this.data.act) this.countDown(); + //如果有会员的时候 + var userInfo = getApp().globalData.userInfo; + if (userInfo) { + if (!th.data.is_get_act) { + //获取活动信息 + var url = "/api/weshop/prom/zhbuy/get/" + os.stoid + "/" + th.data.id + "/" + userInfo.user_id; + getApp().request.get(url, { + success: function (e) { + th.data.is_get_act = 1; + if (e.data.code == 0 && e.data.data) { + self.setData({ + act: e.data.data }); - return false; - } - if (e.data.data.is_end == 0 && ut.gettimestamp() < e.data.data.end_time) { - //-- 获取商品列表 -- - self.get_list(); - self.countDown(); + if (e.data.data.is_show != 1) { + th.setData({ + error: '活动未开启' + }); + return false; + } + if (ut.gettimestamp() < e.data.data.start_time) { + th.setData({ + error: '活动还未开始' + }); + return false; + } + if (e.data.data.is_end == 0 && ut.gettimestamp() < e.data.data.end_time) { + //-- 获取商品列表 -- + self.get_list(); + self.countDown(); + } else { + th.setData({ + error: '活动已经过期' + }); + return false; + } } else { + th.data.is_get_act = 0; th.setData({ - error: '活动已经过期' + error: e.data.msg }); return false; } - } else { - th.data.is_get_act = 0; - th.setData({ - error: e.data.msg - }); - return false; } - } - }); - } - - //等待活动值 - this.waitfor2(10, 'list', function () { - if (!th.data.list) return false; - if (ut.gettimestamp() < th.data.act.start_time) { - return false; - } - if (th.data.act.is_end == 10 || ut.gettimestamp() >= th.data.act.end_time) { - return false; + }); } - //获取头像的分享 - th.get_head_temp(function () { - var txt = th.data.act.zhprice + "元" + th.data.act.zhbuyqty + "件"; - imgDraw.views[0].url = th.data.share_head; - imgDraw.views[1].text = userInfo.nickname; - imgDraw.views[2].text = txt; - - var start = ut.formar_no_full(th.data.act.start_time, '.'); - var end = ut.formar_no_full(th.data.act.end_time, '.'); - txt = "活动时间:" + start + " - " + end; - imgDraw.views[3].text = txt; - - var scene = th.data.id + ""; - var user_id = getApp().globalData.user_id; - scene += "_" + user_id; - ///二微码 - var path3 = os.url + "/api/wx/open/app/user/getWeAppEwm/" + - os.stoid + "?sceneValue=" + scene + "&pageValue=packageB/pages/zuhegou/index/index"; - wx.getImageInfo({ - src: path3, - success: function (res) { - var vpath = res.path; - imgDraw.views[4].url = vpath; - th.setData({ - imgDraw: imgDraw - }) - } - }) - }) - //获取用户的默认门店 - getApp().get_user_store(function (e) { - if (!e) { - th.data.fir_def_store = {}; //赋值空对象 + //等待活动值 + this.waitfor2(10, 'list', function () { + if (!th.data.list) return false; + if (ut.gettimestamp() < th.data.act.start_time) { + return false; + } + if (th.data.act.is_end == 10 || ut.gettimestamp() >= th.data.act.end_time) { return false; } + //获取头像的分享 + th.get_head_temp(function () { + var txt = th.data.act.zhprice + "元" + th.data.act.zhbuyqty + "件"; + imgDraw.views[0].url = th.data.share_head; + imgDraw.views[1].text = userInfo.nickname; + imgDraw.views[2].text = txt; + + var start = ut.formar_no_full(th.data.act.start_time, '.'); + var end = ut.formar_no_full(th.data.act.end_time, '.'); + txt = "活动时间:" + start + " - " + end; + imgDraw.views[3].text = txt; + + var scene = th.data.id + ""; + var user_id = getApp().globalData.user_id; + scene += "_" + user_id; + ///二微码 + var path3 = os.url + "/api/wx/open/app/user/getWeAppEwm/" + + os.stoid + "?sceneValue=" + scene + "&pageValue=packageB/pages/zuhegou/index/index"; + wx.getImageInfo({ + src: path3, + success: function (res) { + var vpath = res.path; + imgDraw.views[4].url = vpath; + th.setData({ + imgDraw: imgDraw + }) + } + }) + }) + //获取用户的默认门店 + getApp().get_user_store(function (e) { + if (!e) { + th.data.fir_def_store = {}; //赋值空对象 + return false; + } - var ee = JSON.parse(JSON.stringify(e)); - var appd = getApp().globalData; - //-- 等待定位系统的开启 -- - th.waitfor2(15, 'is_get_local_ok', function () { - if (!th.data.is_get_local_ok) return false; + var ee = JSON.parse(JSON.stringify(e)); + var appd = getApp().globalData; + //-- 等待定位系统的开启 -- + th.waitfor2(15, 'is_get_local_ok', function () { - 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.set_def_storage(e); - } else { - //要用接口是获取距离,js的计算不准 - getApp().request.promiseGet("/api/weshop/pickup/list", { - data: { - store_id: os.stoid, - pickup_id: e.pickup_id, - is_pos: 1, - lat: th.data.lat, - lon: th.data.lon - }, - }).then(res => { - if (res.data.code == 0) { - e = res.data.data.pageData[0]; - if (e) { - e.is_no_dis = ee.is_no_dis; - appd.pk_store = e; - that.set_def_storage(e); - } + if (!th.data.is_get_local_ok) return false; - } - }) - } - appd.lat = that.data.lat; - appd.lon = that.data.lon; - } else { - if (e) { - e.distance = null; - that.set_def_storage(e); - } - } - }) - }); + 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.set_def_storage(e); + } else { + //要用接口是获取距离,js的计算不准 + getApp().request.promiseGet("/api/weshop/pickup/list", { + data: { + store_id: os.stoid, + pickup_id: e.pickup_id, + is_pos: 1, + lat: th.data.lat, + lon: th.data.lon + }, + }).then(res => { + if (res.data.code == 0) { + e = res.data.data.pageData[0]; + if (e) { + e.is_no_dis = ee.is_no_dis; + appd.pk_store = e; + that.set_def_storage(e); + } - //----获取系统参数----- - getApp().getConfig2(function (e) { - ee.setData({ - bconfig: e, - sales_rules: e.sales_rules, - }); - //设置基本参数 - th.wait_for_store_config(e); - - var json_d = JSON.parse(e.switch_list); - ee.setData({ - store_config: e, - sys_switch: json_d, - is_closecoupon: json_d.is_closecoupon, - is_newsales_rules: json_d.is_newsales_rules, - is_open_offline: json_d.is_pricing_open, - sales_rules: e.sales_rules + } + }) + } + appd.lat = that.data.lat; + appd.lon = that.data.lon; + } else { + if (e) { + e.distance = null; + that.set_def_storage(e); + } + } + }) }); - //-- 计算等级价相关 -- - 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 + //----获取系统参数----- + getApp().getConfig2(function (e) { + ee.setData({ + bconfig: e, + sales_rules: e.sales_rules, }); - //---回调卡的列表--- - th.getPlusCardType(function (ob) { + //设置基本参数 + th.wait_for_store_config(e); + + var json_d = JSON.parse(e.switch_list); + ee.setData({ + store_config: e, + sys_switch: json_d, + is_closecoupon: json_d.is_closecoupon, + is_newsales_rules: json_d.is_newsales_rules, + is_open_offline: json_d.is_pricing_open, + sales_rules: e.sales_rules + }); + + //-- 计算等级价相关 -- + 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({ - card_list: ob.card_list + rank_switch: true }); - var user = getApp().globalData.userInfo; - if (!user) return false; - 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); - th.setData({ - card_field: user.card_field, - card_name: card_name, - card_list: ob.card_list - }); + //---回调卡的列表--- + th.getPlusCardType(function (ob) { + th.setData({ + card_list: ob.card_list + }); + var user = getApp().globalData.userInfo; + if (!user) return false; + 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); + th.setData({ + card_field: user.card_field, + card_name: card_name, + card_list: ob.card_list + }); + } } - } + //获取购物车的内容 + th.get_cart_val(e); + + }) + } else { //获取购物车的内容 th.get_cart_val(e); + } + }, 1); - }) - } else { - //获取购物车的内容 - th.get_cart_val(e); - } - }, 1); - - }) + }) - } + } else { + getApp().goto("/pages/togoin/togoin"); + return false; + } + }) }, onHide: function () { @@ -1898,7 +1894,7 @@ Page({ getApp().request.put("/api/weshop/cart/update", { data: updata, - success: function (t) {} + success: function (t) { } }); th.re_sum_price(); }) @@ -1975,7 +1971,7 @@ Page({ if (this.data.act.is_bzyh && zhqty_bz.length > 0) { if (zhqty_bz.length > 1) { let zhqty_bz_arr = []; - let zhqty_bz_flag=this.zhqty_bz_fun(zhqty_bz,be,zhqty_bz_arr); + let zhqty_bz_flag = this.zhqty_bz_fun(zhqty_bz, be, zhqty_bz_arr); if (zhqty_bz_flag) { for (let i = 0; i < zhqty_bz.length; i++) { @@ -1991,7 +1987,7 @@ Page({ } } } else { - zhqty_len=1; + zhqty_len = 1; let min_bz_num = Math.min.apply(Math, zhqty_bz_arr.map(function (o) { return o['num']; })); @@ -2015,9 +2011,9 @@ Page({ } bz_num_ok = be * vv.zhqty; } - - for(let i = 0; i < zhqty_bz.length; i++){ - let item1=zhqty_bz[i]; + + for (let i = 0; i < zhqty_bz.length; i++) { + let item1 = zhqty_bz[i]; for (let j = 0; j < be * item1['zhqty']; j++) { let index = no_in_arr.findIndex(i => { return item1.goods_id === i.goods_id @@ -2261,14 +2257,14 @@ Page({ }, - zhqty_bz_fun(zhqty_bz,be,zhqty_bz_arr){ - let zhqty_bz_flag =true; - for(let i=0;i num) { - zhqty_bz_flag=false; + zhqty_bz_flag = false; zhqty_bz_arr.push(item); // zhqty_bz.splice(i,1) } diff --git a/packageB/pages/zuhegou/preindex/index.js b/packageB/pages/zuhegou/preindex/index.js index d8bad75..ee9aacc 100644 --- a/packageB/pages/zuhegou/preindex/index.js +++ b/packageB/pages/zuhegou/preindex/index.js @@ -11,80 +11,80 @@ let imgDraw = { "height": "843px", "background": "https://mshopimg.yolipai.net/miniapp/images/zhg/bg-zuhegou.jpg", "views": [{ // 头像 - "type": "image", - "url": "https://desk-fd.zol-img.com.cn/t_s960x600c5/g5/M00/0F/08/ChMkJlauzXWIDrXBAAdCg2xP7oYAAH9FQOpVAIAB0Kb342.jpg", - "css": { - "width": "100px", - "height": "100px", - "top": "20px", - "left": "275px", - "borderRadius": "100px", - "mode": "scaleToFill", - "borderWidth": "2px", - "borderColor": "#fff", - } - }, - { //昵称 - "type": "text", - "text": "我是店铺名", - "css": { - "width": "650px", - "color": "#fff", - "top": "136px", - // "left": "137px", - "textAlign": "center", - "fontSize": "26px", - "maxLines": "1", - } - }, - { //10元任选3件 - "type": "text", - "text": "10元任选3件", - "css": { - "color": "#fff", - "width": "650px", - "top": "270px", - "fontSize": "70px", - "maxLines": "1", - "textAlign": "center", - "fontWeight": "bold", - } - }, - { //活动时间 - "type": "text", - "text": "活动时间:2021.07.06 - 2021.07.08", - "css": { - "color": "#333", - "width": "650px", - "top": "440px", - "fontSize": "26px", - "fontWeight": "normal", - "maxLines": "1", - "textAlign": "center" - } - }, - { // 码 - "type": "image", - "url": "https://desk-fd.zol-img.com.cn/t_s960x600c5/g5/M00/0F/08/ChMkJlauzXWIDrXBAAdCg2xP7oYAAH9FQOpVAIAB0Kb342.jpg", - "css": { - "color": "#000", - "width": "200px", - "height": "200px", - "top": "525px", - "left": "225px", - } - }, - { // 扫码提示 - "type": "text", - "text": "长按扫码即可参与活动", - "css": { - "color": "#666", - "width": "650px", - "top": "750px", - "fontSize": "26px", - "textAlign": "center" - } - }, + "type": "image", + "url": "https://desk-fd.zol-img.com.cn/t_s960x600c5/g5/M00/0F/08/ChMkJlauzXWIDrXBAAdCg2xP7oYAAH9FQOpVAIAB0Kb342.jpg", + "css": { + "width": "100px", + "height": "100px", + "top": "20px", + "left": "275px", + "borderRadius": "100px", + "mode": "scaleToFill", + "borderWidth": "2px", + "borderColor": "#fff", + } + }, + { //昵称 + "type": "text", + "text": "我是店铺名", + "css": { + "width": "650px", + "color": "#fff", + "top": "136px", + // "left": "137px", + "textAlign": "center", + "fontSize": "26px", + "maxLines": "1", + } + }, + { //10元任选3件 + "type": "text", + "text": "10元任选3件", + "css": { + "color": "#fff", + "width": "650px", + "top": "270px", + "fontSize": "70px", + "maxLines": "1", + "textAlign": "center", + "fontWeight": "bold", + } + }, + { //活动时间 + "type": "text", + "text": "活动时间:2021.07.06 - 2021.07.08", + "css": { + "color": "#333", + "width": "650px", + "top": "440px", + "fontSize": "26px", + "fontWeight": "normal", + "maxLines": "1", + "textAlign": "center" + } + }, + { // 码 + "type": "image", + "url": "https://desk-fd.zol-img.com.cn/t_s960x600c5/g5/M00/0F/08/ChMkJlauzXWIDrXBAAdCg2xP7oYAAH9FQOpVAIAB0Kb342.jpg", + "css": { + "color": "#000", + "width": "200px", + "height": "200px", + "top": "525px", + "left": "225px", + } + }, + { // 扫码提示 + "type": "text", + "text": "长按扫码即可参与活动", + "css": { + "color": "#666", + "width": "650px", + "top": "750px", + "fontSize": "26px", + "textAlign": "center" + } + }, ] }; @@ -153,229 +153,226 @@ Page({ } }) } - - //如果有会员的时候 - var userInfo = getApp().globalData.userInfo; - if (!userInfo) { - if(getApp().is_Single_page()){ - getApp().goto("/pages/togoin/togoin"); - return false; - } - } }, /** * 生命周期函数--监听页面显示 */ onShow: function () { - var th = this, - that = this, - ee = this; - this.data.is_timer = 1; - if (this.data.act) this.countDown(); - //如果有会员的时候 - var userInfo = getApp().globalData.userInfo; - if (userInfo) { - if (!th.data.is_get_act) { - //获取活动信息 - var url = "/api/weshop/prom/zhbuy/get/" + os.stoid + "/" + th.data.id + "/" + userInfo.user_id; - getApp().request.get(url, { - success: function (e) { - - th.data.is_get_act = 1; - if (e.data.code == 0 && e.data.data) { - self.setData({ - act: e.data.data - }); - if (e.data.data.is_show != 1) { - th.setData({ - error: '活动未开启' + getApp().is_Single_page(this, function () { + var th = this, + that = this, + ee = this; + this.data.is_timer = 1; + if (this.data.act) this.countDown(); + //如果有会员的时候 + var userInfo = getApp().globalData.userInfo; + if (userInfo) { + if (!th.data.is_get_act) { + //获取活动信息 + var url = "/api/weshop/prom/zhbuy/get/" + os.stoid + "/" + th.data.id + "/" + userInfo.user_id; + getApp().request.get(url, { + success: function (e) { + + th.data.is_get_act = 1; + if (e.data.code == 0 && e.data.data) { + self.setData({ + act: e.data.data }); - return false; - } - // if (ut.gettimestamp() < e.data.data.start_time) { - // th.setData({ - // error: '活动还未开始' - // }); - // return false; - // } - if (e.data.data.is_end == 0 && ut.gettimestamp() < e.data.data.end_time) { - //-- 获取商品列表 -- - self.get_list(); - self.countDown(); + if (e.data.data.is_show != 1) { + th.setData({ + error: '活动未开启' + }); + return false; + } + // if (ut.gettimestamp() < e.data.data.start_time) { + // th.setData({ + // error: '活动还未开始' + // }); + // return false; + // } + if (e.data.data.is_end == 0 && ut.gettimestamp() < e.data.data.end_time) { + //-- 获取商品列表 -- + self.get_list(); + self.countDown(); + } else { + th.setData({ + error: '活动已经过期' + }); + return false; + } } else { + th.data.is_get_act = 0; th.setData({ - error: '活动已经过期' + error: e.data.msg }); return false; } - } else { - th.data.is_get_act = 0; - th.setData({ - error: e.data.msg - }); - return false; } - } - }); - } - - //等待活动值 - this.waitfor2(10, 'list', function () { - if (!th.data.list) return false; - if (ut.gettimestamp() < th.data.act.start_time) { - return false; - } - if (th.data.act.is_end == 10 || ut.gettimestamp() >= th.data.act.end_time) { - return false; + }); } - //获取头像的分享 - th.get_head_temp(function () { - var txt = th.data.act.zhprice + "元任选" + th.data.act.zhbuyqty + "件"; - imgDraw.views[0].url = th.data.share_head; - imgDraw.views[1].text = userInfo.nickname; - imgDraw.views[2].text = txt; - - var start = ut.formar_no_full(th.data.act.start_time, '.'); - var end = ut.formar_no_full(th.data.act.end_time, '.'); - txt = "活动时间:" + start + " - " + end; - imgDraw.views[3].text = txt; - - var scene = th.data.id + ""; - var user_id = getApp().globalData.user_id; - scene += "_" + user_id; - ///二微码 - var path3 = os.url + "/api/wx/open/app/user/getWeAppEwm/" + - os.stoid + "?sceneValue=" + scene + "&pageValue=packageB/pages/zuhegou/index/index"; - wx.getImageInfo({ - src: path3, - success: function (res) { - var vpath = res.path; - imgDraw.views[4].url = vpath; - th.setData({ - imgDraw: imgDraw - }) - } - }) - }) - //获取用户的默认门店 - getApp().get_user_store(function (e) { - if (!e) { - th.data.fir_def_store = {}; //赋值空对象 + //等待活动值 + this.waitfor2(10, 'list', function () { + if (!th.data.list) return false; + if (ut.gettimestamp() < th.data.act.start_time) { return false; } + if (th.data.act.is_end == 10 || ut.gettimestamp() >= th.data.act.end_time) { + return false; + } + //获取头像的分享 + th.get_head_temp(function () { + var txt = th.data.act.zhprice + "元任选" + th.data.act.zhbuyqty + "件"; + imgDraw.views[0].url = th.data.share_head; + imgDraw.views[1].text = userInfo.nickname; + imgDraw.views[2].text = txt; + + var start = ut.formar_no_full(th.data.act.start_time, '.'); + var end = ut.formar_no_full(th.data.act.end_time, '.'); + txt = "活动时间:" + start + " - " + end; + imgDraw.views[3].text = txt; + + var scene = th.data.id + ""; + var user_id = getApp().globalData.user_id; + scene += "_" + user_id; + ///二微码 + var path3 = os.url + "/api/wx/open/app/user/getWeAppEwm/" + + os.stoid + "?sceneValue=" + scene + "&pageValue=packageB/pages/zuhegou/index/index"; + wx.getImageInfo({ + src: path3, + success: function (res) { + var vpath = res.path; + imgDraw.views[4].url = vpath; + th.setData({ + imgDraw: imgDraw + }) + } + }) + }) + //获取用户的默认门店 + getApp().get_user_store(function (e) { + if (!e) { + th.data.fir_def_store = {}; //赋值空对象 + return false; + } - var ee = JSON.parse(JSON.stringify(e)); - var appd = getApp().globalData; - //-- 等待定位系统的开启 -- - th.waitfor2(15, 'is_get_local_ok', function () { - if (!th.data.is_get_local_ok) return false; + var ee = JSON.parse(JSON.stringify(e)); + var appd = getApp().globalData; + //-- 等待定位系统的开启 -- + th.waitfor2(15, 'is_get_local_ok', function () { - 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.set_def_storage(e); - } else { - //要用接口是获取距离,js的计算不准 - getApp().request.promiseGet("/api/weshop/pickup/list", { - data: { - store_id: os.stoid, - pickup_id: e.pickup_id, - is_pos: 1, - lat: th.data.lat, - lon: th.data.lon - }, - }).then(res => { - if (res.data.code == 0) { - e = res.data.data.pageData[0]; - if (e) { - e.is_no_dis = ee.is_no_dis; - appd.pk_store = e; - that.set_def_storage(e); - } + if (!th.data.is_get_local_ok) return false; - } - }) - } - appd.lat = that.data.lat; - appd.lon = that.data.lon; - } else { - if (e) { - e.distance = null; - that.set_def_storage(e); - } - } - }) - }); + 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.set_def_storage(e); + } else { + //要用接口是获取距离,js的计算不准 + getApp().request.promiseGet("/api/weshop/pickup/list", { + data: { + store_id: os.stoid, + pickup_id: e.pickup_id, + is_pos: 1, + lat: th.data.lat, + lon: th.data.lon + }, + }).then(res => { + if (res.data.code == 0) { + e = res.data.data.pageData[0]; + if (e) { + e.is_no_dis = ee.is_no_dis; + appd.pk_store = e; + that.set_def_storage(e); + } - //----获取系统参数----- - getApp().getConfig2(function (e) { - ee.setData({ - bconfig: e, - sales_rules: e.sales_rules, - }); - //设置基本参数 - th.wait_for_store_config(e); - - var json_d = JSON.parse(e.switch_list); - ee.setData({ - store_config: e, - sys_switch: json_d, - is_closecoupon: json_d.is_closecoupon, - is_newsales_rules: json_d.is_newsales_rules, - is_open_offline: json_d.is_pricing_open, - sales_rules: e.sales_rules + } + }) + } + appd.lat = that.data.lat; + appd.lon = that.data.lon; + } else { + if (e) { + e.distance = null; + that.set_def_storage(e); + } + } + }) }); - //-- 计算等级价相关 -- - 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 + //----获取系统参数----- + getApp().getConfig2(function (e) { + ee.setData({ + bconfig: e, + sales_rules: e.sales_rules, }); - //---回调卡的列表--- - th.getPlusCardType(function (ob) { + //设置基本参数 + th.wait_for_store_config(e); + + var json_d = JSON.parse(e.switch_list); + ee.setData({ + store_config: e, + sys_switch: json_d, + is_closecoupon: json_d.is_closecoupon, + is_newsales_rules: json_d.is_newsales_rules, + is_open_offline: json_d.is_pricing_open, + sales_rules: e.sales_rules + }); + + //-- 计算等级价相关 -- + 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({ - card_list: ob.card_list + rank_switch: true }); - var user = getApp().globalData.userInfo; - if (!user) return false; - 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); - th.setData({ - card_field: user.card_field, - card_name: card_name, - card_list: ob.card_list - }); + //---回调卡的列表--- + th.getPlusCardType(function (ob) { + th.setData({ + card_list: ob.card_list + }); + var user = getApp().globalData.userInfo; + if (!user) return false; + 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); + th.setData({ + card_field: user.card_field, + card_name: card_name, + card_list: ob.card_list + }); + } } - } + //获取购物车的内容 + th.get_cart_val(e); + + }) + } else { //获取购物车的内容 th.get_cart_val(e); + } + }, 1); - }) - } else { - //获取购物车的内容 - th.get_cart_val(e); - } - }, 1); + }) - }) + } else { + getApp().goto("/pages/togoin/togoin"); + return false; + } + }) - } }, onHide: function () { @@ -1898,7 +1895,7 @@ Page({ getApp().request.put("/api/weshop/cart/update", { data: updata, - success: function (t) {} + success: function (t) { } }); th.re_sum_price(); }) @@ -1917,7 +1914,7 @@ Page({ var need_to_buy = 0; var data = this.data.list; var all_zhqty = 0; //所有商品要求起购数之后 - var zhqty_bz=[]; //超量 + var zhqty_bz = []; //超量 var no_in_arr = []; for (var i in data) { var item = data[i]; @@ -1968,28 +1965,28 @@ Page({ //看一下剩下的数量有没有满足组合购的要求,以及要不要倍增 if (this.data.act.is_bz && no_in_arr.length >= this.data.act.zhbuyqty) { - let zhqty_map=new map(); - //看一下是几倍 + let zhqty_map = new map(); + //看一下是几倍 var be = parseInt(no_in_arr.length / this.data.act.zhbuyqty); - if(this.data.act.is_bzyh && zhqty_bz.length > 0 ){ - for(let i=0;i 0) { + for (let i = 0; i < zhqty_bz.length; i++) { + let vv = zhqty_bz[i]; + let num = 0; + let bz_num = be * vv.zhqty; + for (let j = 0; j < no_in_arr.length; j++) { + let ii = no_in_arr[j]; + if (vv.goods_id === ii.goods_id) { num++; - zhqty_map.set('num',num); - zhqty_map.set('price',ii.price); + zhqty_map.set('num', num); + zhqty_map.set('price', ii.price); } - + } } } - if(bz_num <= num){ + if (bz_num <= num) { aprice += be * aprice; - let pop_num=(be * this.data.act.zhbuyqty)-bz_num; + let pop_num = (be * this.data.act.zhbuyqty) - bz_num; console.log(pop_num); for (var m = 0; m < pop_num; m++) { no_in_arr.pop(); diff --git a/packageC/pages/luckyGo/luckyGo_goodsInfo/luckyGo_goodsInfo.js b/packageC/pages/luckyGo/luckyGo_goodsInfo/luckyGo_goodsInfo.js index 1dbfbf4..7757199 100644 --- a/packageC/pages/luckyGo/luckyGo_goodsInfo/luckyGo_goodsInfo.js +++ b/packageC/pages/luckyGo/luckyGo_goodsInfo/luckyGo_goodsInfo.js @@ -8,7 +8,7 @@ var t = require("../../../../utils/util.js"), oo = s.globalData, o = s.globalData.setting, os = o; - + //评价加载更多 var more = function (e) { return e && e.__esModule ? e : { @@ -251,48 +251,48 @@ Page({ fir_goods: null, share_hidden: false, - - showRules: false, // 控制规则显示与隐藏 - showReward: false, //控制查看奖励显示与隐藏 - - typeArr: [{ - key: 'point', - name: '积分', - },{ - key: 'grow', - name: '成长值', - },{ - key: 'point', - name: '优惠券', - },{ - key: 'prestore_name', - name: '项目服务', - },{ - key: 'prestore_money', - name: '预存金额', - }], - - - luckGoInfo: {}, - showDetails: false, - num_success: 0, //成团已中商品数量 - isTimeUp: false, - - surplus: 0, - canBuy: false, - btnHidden: false, + + showRules: false, // 控制规则显示与隐藏 + showReward: false, //控制查看奖励显示与隐藏 + + typeArr: [{ + key: 'point', + name: '积分', + }, { + key: 'grow', + name: '成长值', + }, { + key: 'point', + name: '优惠券', + }, { + key: 'prestore_name', + name: '项目服务', + }, { + key: 'prestore_money', + name: '预存金额', + }], + + + luckGoInfo: {}, + showDetails: false, + num_success: 0, //成团已中商品数量 + isTimeUp: false, + + surplus: 0, + canBuy: false, + btnHidden: false, }, //------初始化加载---------- onLoad: function (t) { - + // console.log('onload'); - if(t && t.group_id) { - this.data.group_id = t.group_id; - }; - + if (t && t.group_id) { + this.data.group_id = t.group_id; + }; + + - var ee = this, that = ee, th = ee, @@ -303,45 +303,45 @@ Page({ prom_type = t.prom_type, prom_id = t.group_id; //活动ID - if(prom_type) { - // this.data.prom_type = prom_type; - // this.data.prom_id = prom_id; - this.setData({ - prom_type, - prom_id, - }); - } - - + if (prom_type) { + // this.data.prom_type = prom_type; + // this.data.prom_id = prom_id; + this.setData({ + prom_type, + prom_id, + }); + } + + //---获取手机地址坐标-- //--如果tg_id是空的话,分享回来-- - // console.log('扫描海报gid'); + // console.log('扫描海报gid'); if (gid == undefined || gid == null || gid == "") { var gid_str = decodeURIComponent(t.scene); gid_str = gid_str.split("_"); gid = gid_str[0]; - if(gid.indexOf('.')!=-1) { - var fir_arr=gid.split("."); - gid=fir_arr[0]; - prom_type=fir_arr[1]; - prom_id=fir_arr[2]; - // this.setData({ - // prom_type: prom_type, - // prom_id: prom_id, - // group_id: fir_arr[2], - // }); - this.data.prom_type=prom_type; - this.data.prom_id=prom_id; - this.data.group_id = fir_arr[2]; + if (gid.indexOf('.') != -1) { + var fir_arr = gid.split("."); + gid = fir_arr[0]; + prom_type = fir_arr[1]; + prom_id = fir_arr[2]; + // this.setData({ + // prom_type: prom_type, + // prom_id: prom_id, + // group_id: fir_arr[2], + // }); + this.data.prom_type = prom_type; + this.data.prom_id = prom_id; + this.data.group_id = fir_arr[2]; } 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]; @@ -351,7 +351,7 @@ Page({ } ee.setData({ gid: gid }); - + if (first_leader) { getApp().globalData.first_leader = first_leader; @@ -418,10 +418,10 @@ Page({ th.requestCardNum(), wx.pageScrollTo && th.setData({ supportPageScroll: !0 }); - - - - + + + + //计算等级价相关 var swithc_list = e.switch_list; @@ -496,7 +496,7 @@ Page({ } 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 }, + data: { store_id: os.stoid, pickup_id: e.pickup_id, lat: th.data.lat, lon: th.data.lon, is_pos: 1 }, }).then(res => { if (res.data.code == 0) { e = res.data.data.pageData[0]; @@ -532,15 +532,14 @@ Page({ //--先判断会员登陆状态-- var user_info = getApp().globalData.userInfo; if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) { - - if(getApp().is_Single_page()){ + + getApp().is_Single_page(th, function () { wx.navigateTo({ url: '/pages/togoin/togoin', - }) + }) return false; - } + }) } - }, @@ -636,7 +635,7 @@ Page({ } gallery = g; }) - + //------是否收藏---------- await getApp().request.promiseGet("/api/weshop/goodscollect/page", { data: { @@ -704,7 +703,7 @@ Page({ } } - if (th.data.is_closecoupon != 1 && (!th.data.fir_quan || th.data.fir_quan.length<=0)) { + if (th.data.is_closecoupon != 1 && (!th.data.fir_quan || th.data.fir_quan.length <= 0)) { //----获取详情页的券的数量---- await getApp().request.promiseGet("/api/weshop/prom/coupon/pageCouponList", { data: { @@ -728,16 +727,16 @@ Page({ mapurl_f_img = res1.data.data.video_img; } }) - - - - - - - - - - + + + + + + + + + + ee.setData({ gallery: gallery, @@ -754,7 +753,7 @@ Page({ //---展示--- onShow: async function () { - // console.log('onshow'); + // console.log('onshow'); var goods_list = null, th = this, that = this; var show_prew_img = this.data.show_prew_img if (show_prew_img) { @@ -764,57 +763,57 @@ Page({ // 判断活动是否暂停 //获取单个活动成团信息 - await getApp().request.promiseGet('/api/weshop/prom/luckyActivity/page', { - data: { - store_id: o.stoid, - is_end: 0, - timetype: 1, - id: this.data.group_id, - } - }).then(res => { - // console.log() - // console.log('判断活动是否暂停=======》', res.data.data); - if (res.data.code == 0) { - if(res.data.data.pageData && res.data.data.pageData.length == 0) { - let obj = { - day: '00', - hou: '00', - min: '00', - sec: '00' - }; - - th.setData({ - djs: obj, - isTimeUp: true, - }); - } else { - th.setData({ - luckGoInfo: res.data.data.pageData[0], - team_id: res.data.data.pageData[0].team_id, - luckGoMembers: [], - }); - - th.countDown(th.data.luckGoInfo.end_time, 0); - }; - - } else { + await getApp().request.promiseGet('/api/weshop/prom/luckyActivity/page', { + data: { + store_id: o.stoid, + is_end: 0, + timetype: 1, + id: this.data.group_id, + } + }).then(res => { + // console.log() + // console.log('判断活动是否暂停=======》', res.data.data); + if (res.data.code == 0) { + if (res.data.data.pageData && res.data.data.pageData.length == 0) { + let obj = { + day: '00', + hou: '00', + min: '00', + sec: '00' + }; + + th.setData({ + djs: obj, + isTimeUp: true, + }); + } else { + th.setData({ + luckGoInfo: res.data.data.pageData[0], + team_id: res.data.data.pageData[0].team_id, + luckGoMembers: [], + }); + + th.countDown(th.data.luckGoInfo.end_time, 0); + }; + + } else { // this.data.isTimeUp = true; - th.setData({ - isTimeUp: true, + th.setData({ + isTimeUp: true, }); - - }; - - + + }; + + }); - + // 活动暂停显示空白 if (this.data.isTimeUp) { wx.showModal({ title: '提示', content: '活动已经暂停', showCancel: false, - success: function(){ + success: function () { wx.navigateBack(); } }) @@ -883,18 +882,18 @@ Page({ }); } } - + //动态获取商品名称 wx.setNavigationBarTitle({ title: t.data.data.goods_name, }); - + //-- 把商品的赋值 -- ee.data.fir_goods = JSON.parse(JSON.stringify(t.data.data)); - if(ee.data.prom_type!=1 && ee.data.prom_type!=4 && ee.data.prom_type!=6) - ee.check_is_youhui(ee.data.gid); + if (ee.data.prom_type != 1 && ee.data.prom_type != 4 && ee.data.prom_type != 6) + ee.check_is_youhui(ee.data.gid); t.data.data.on_time = ut.formatTime(t.data.data.on_time, 'yyyy-MM-dd hh:mm:ss'); @@ -920,12 +919,12 @@ Page({ a.wxParse("content", "html", t.data.data.goods_content, ee, 6); e.wxParseAddFullImageUrl(ee, "content"); - if(ee.data.prom_type){ - //999 - t.data.data.prom_type=ee.data.prom_type; - t.data.data.prom_id=ee.data.prom_id; + if (ee.data.prom_type) { + //999 + t.data.data.prom_type = ee.data.prom_type; + t.data.data.prom_id = ee.data.prom_id; } - + ee.setData({ data: t.data.data, sele_g: t.data.data, @@ -938,7 +937,7 @@ Page({ //默认门店要拿下门店库存 // if (that.data.sales_rules == 2 && that.data.is_newsales_rules) { // //获取门店 - // ee.get_sto(1); + // ee.get_sto(1); // } else { // //获取门店 @@ -1024,112 +1023,112 @@ Page({ this.data.enterAddressPage && (this.data.enterAddressPage = !1); - //获取单个活动已成团数量 - getApp().request.get(`/api/weshop/prom/luckyTeam/getCtNum/${o.stoid}/${this.data.group_id}`, { - success: function (res) { - if(res.data.code == 0) { - th.setData({ - group_num: res.data.data, - }); - } - } - }); - - - //获取单个活动中奖记录 - getApp().request.promiseGet('/api/weshop/prom/luckyOrder/page', { - data: { - store_id: os.stoid, - team_status: 2, - goods_id: this.data.gid, - rndid: 1, - } - }).then(res => { - if (res.data.code == 0) { - th.setData({ - luckGoWinners: res.data.data.pageData, - }); - } - }); - - - //获取单个活动成团已中商品数量 - let url_num_success = `/api/weshop/prom/luckyOrder/countActNum/${os.stoid}/${this.data.group_id}`; - getApp().request.get(url_num_success, { - success: function (res) { - if (res.data.code == 0) { - console.log('成团已中商品数量汇总',res.data.data); - th.setData({ - num_success: res.data.data, - }); - } - } - }); - - - - - - // 获取购买次数,判断是否已经超出限购 - // {store_id}/{user_id}/{aid} - let get_aid = this.data.prom_id || this.data.luckGoInfo.id; - await getApp().request.get('/api/weshop/prom/luckyOrder/countActNum/' + os.stoid + '/' + oo.user_id + '/' + get_aid, { - success: function (res) { - if(res.data.code == 0) { - console.log(oo.user_id, '判断是否超出限购,获取购买次数', res, ); - // th.setData({ - // num_joined: res.data.data, - // }); - let num_joined = res.data.data; - let group_join_num = th.data.luckGoInfo.group_join_num; - let canBuy = num_joined >= group_join_num ? false : true; - th.setData({ - canBuy, - }); - // console.log('canBuy', th.data.canBuy); - }; - }, - }); - - - //获取参团成员 - await getApp().request.promiseGet('/api/weshop/prom/luckyOrder/page', { - data: { - store_id: o.stoid, - team_id: th.data.team_id, - } - }).then(res => { - if (res.data.code == 0) { - // console.log(th.data.team_id,'参团成员===============》', res.data.data.pageData); - th.setData({ - luckGoMembers: res.data.data.pageData, - }); - } - }); - - var p1 = new Promise((resolve, reject) => { + //获取单个活动已成团数量 + getApp().request.get(`/api/weshop/prom/luckyTeam/getCtNum/${o.stoid}/${this.data.group_id}`, { + success: function (res) { + if (res.data.code == 0) { + th.setData({ + group_num: res.data.data, + }); + } + } + }); + + + //获取单个活动中奖记录 + getApp().request.promiseGet('/api/weshop/prom/luckyOrder/page', { + data: { + store_id: os.stoid, + team_status: 2, + goods_id: this.data.gid, + rndid: 1, + } + }).then(res => { + if (res.data.code == 0) { + th.setData({ + luckGoWinners: res.data.data.pageData, + }); + } + }); + + + //获取单个活动成团已中商品数量 + let url_num_success = `/api/weshop/prom/luckyOrder/countActNum/${os.stoid}/${this.data.group_id}`; + getApp().request.get(url_num_success, { + success: function (res) { + if (res.data.code == 0) { + console.log('成团已中商品数量汇总', res.data.data); + th.setData({ + num_success: res.data.data, + }); + } + } + }); + + + + + + // 获取购买次数,判断是否已经超出限购 + // {store_id}/{user_id}/{aid} + let get_aid = this.data.prom_id || this.data.luckGoInfo.id; + await getApp().request.get('/api/weshop/prom/luckyOrder/countActNum/' + os.stoid + '/' + oo.user_id + '/' + get_aid, { + success: function (res) { + if (res.data.code == 0) { + console.log(oo.user_id, '判断是否超出限购,获取购买次数', res,); + // th.setData({ + // num_joined: res.data.data, + // }); + let num_joined = res.data.data; + let group_join_num = th.data.luckGoInfo.group_join_num; + let canBuy = num_joined >= group_join_num ? false : true; + th.setData({ + canBuy, + }); + // console.log('canBuy', th.data.canBuy); + }; + }, + }); + + + //获取参团成员 + await getApp().request.promiseGet('/api/weshop/prom/luckyOrder/page', { + data: { + store_id: o.stoid, + team_id: th.data.team_id, + } + }).then(res => { + if (res.data.code == 0) { + // console.log(th.data.team_id,'参团成员===============》', res.data.data.pageData); + th.setData({ + luckGoMembers: res.data.data.pageData, + }); + } + }); + + var p1 = new Promise((resolve, reject) => { // 检查幸运购活动商品库存 getApp().request.get("/api/weshop/activitylist/getActLen/" + o.stoid + "/9/" + this.data.group_id, { - success: function(res) { + success: function (res) { //console.log('当前幸运购活动的剩余库存', res.data.data); - if(res.data.code == 0) { + if (res.data.code == 0) { th.setData({ // 剩余库存量 surplus: res.data.data, }); - }; + }; resolve(); } }); - + }); - + var p2 = new Promise((resolve, reject) => { // 检查是否已经参团购买 getApp().request.get("/api/weshop/prom/luckyOrder/getUserOrderInfo/" + o.stoid + "/" + oo.user_id + "/" + this.data.group_id, { - success: function(res) { + success: function (res) { console.log('当前幸运购活动是否已经参团', res.data.code); - if(res.data.code == 0) { + if (res.data.code == 0) { th.setData({ showDetails: true, buyInfo: res.data.data, @@ -1142,52 +1141,52 @@ Page({ resolve(); } }); - + }); - + Promise.all([p1, p2]).then(res => { th.setData({ btnHidden: true, }); }); - - - console.log('hidddddnnnnnnnn------>>>>', this.data.btnHidden, this.data.isTimeUp) - + + + console.log('hidddddnnnnnnnn------>>>>', this.data.btnHidden, this.data.isTimeUp) + }, - - - - // 页面卸载 + + + + // 页面卸载 onUnload: function () { for (var i = 1; i < 100; i++) { clearInterval(i); } }, - - // 页面隐藏 + + // 页面隐藏 onHide: function () { this.data.is_timer = 0; for (var i = 1; i < 100; i++) { clearInterval(i); } }, - - // 点击顶部选项卡 + + // 点击顶部选项卡 tabClick: function (t) { var e = t.currentTarget.id; this.setData({ activeCategoryId: e - }), - 1 == e ? this.tabGoodsContent() : 2 == e && this.tabComment(); + }), + 1 == e ? this.tabGoodsContent() : 2 == e && this.tabComment(); }, - - - // 点击评价选项卡下的各评价按钮 + + + // 点击评价选项卡下的各评价按钮 tabClick3: function (t) { var e = this; if (t.currentTarget.id != this.data.activeCategoryId3) { @@ -1200,7 +1199,7 @@ Page({ } }, - // 滚动到顶部 + // 滚动到顶部 doScrollTop: function () { wx.pageScrollTo({ scrollTop: 0 @@ -1283,9 +1282,9 @@ Page({ th.setData({ open_ind_store: ind }); - - - th.add_cart_func(t); + + + th.add_cart_func(t); }, @@ -1450,9 +1449,9 @@ Page({ goods_name: o.goods_name, goods_sn: o.goods_sn, sku: o.sku, - prom_id:th.data.luckGoInfo.id, + prom_id: th.data.luckGoInfo.id, // prom_type:th.data.sele_g.prom_type, - prom_type:9, + prom_type: 9, }; //---是不是从收藏夹出来的--- @@ -1620,7 +1619,7 @@ Page({ add_cart_next(e, t, a, o, newd, CanOutQty) { var th = this, i = getApp().request; //---如果商品不是积分购和拼团,要判断一个是否要进行等级价的判断------ - if ((o.prom_type != 1 || o.prom_id<=0) && ((o.prom_type != 6 && o.prom_type != 4) || th.data.is_normal)) { + if ((o.prom_type != 1 || o.prom_id <= 0) && ((o.prom_type != 6 && o.prom_type != 4) || th.data.is_normal)) { var conf = th.data.bconfig; if (conf.switch_list && getApp().globalData.userInfo['card_field'] && getApp().globalData.userInfo['card_expiredate']) { var s_list = JSON.parse(conf.switch_list); @@ -1783,7 +1782,7 @@ Page({ // this.data.shippingCost < 0 || this.data.select.stock <= 0 || (Object.assign(e, { // action: "buy_now" // }), - var th = this; + var th = this; this.setData({ openSpecModal: 0, openSpecModal_inte: 0, @@ -1791,15 +1790,15 @@ Page({ openSpecModal_pt: 0, }) - // if (e.prom_type == 9) { - // s.set_b_now(e); - // // var url = ''; - // var url = "/pages/cart/cart2/cart2?is_bnow=1&goods_id=" + e.goods_id; - // getApp().goto(url); - // } else - - // if(e.prom_type == 9){ - if(true){ + // if (e.prom_type == 9) { + // s.set_b_now(e); + // // var url = ''; + // var url = "/pages/cart/cart2/cart2?is_bnow=1&goods_id=" + e.goods_id; + // getApp().goto(url); + // } else + + // if(e.prom_type == 9){ + if (true) { //要判断积分购的普通购买有没有参加优惠活动 if (e.is_normal == 1) { this.check_nor_promgood(e.goods_id, function (res) { @@ -1807,28 +1806,28 @@ Page({ e.prom_type = 3; e.prom_id = res.cat_id; } else { - e.prom_type = 0; - // e.prom_id = 0; - } + e.prom_type = 0; + // e.prom_id = 0; + } s.set_b_now(e); /*-- wx.redirectTo({ url: "/pages/cart/cart2/cart2?is_bnow=1&goods_id=" + e.goods_id, });--*/ - - // console.log('11111111111111111111111111======》'); + + // console.log('11111111111111111111111111======》'); // getApp().goto("/packageC/pages/luckyGo/luckyGo_cart/luckyGo_cart?is_bnow=1&goods_id=" + e.goods_id); - getApp().goto("/packageC/pages/luckyGo/luckyGo_cart/luckyGo_cart?is_bnow=1&group_id=" + th.data.group_id +"&goods_id=" + e.goods_id + "&alert=" + th.data.luckGoInfo.lc_alert); + getApp().goto("/packageC/pages/luckyGo/luckyGo_cart/luckyGo_cart?is_bnow=1&group_id=" + th.data.group_id + "&goods_id=" + e.goods_id + "&alert=" + th.data.luckGoInfo.lc_alert); }) } else { - //console.log('222222222222222222222222222222======》'); + //console.log('222222222222222222222222222222======》'); //s.set_b_now(e); /*-- wx.redirectTo({ url: "/pages/cart/cart2/cart2?is_bnow=1&goods_id=" + e.goods_id, });--*/ - //getApp().goto("/packageC/pages/luckyGo/luckyGo_cart_ct/luckyGo_cart_ct?is_bnow=1&goods_id=" + e.goods_id) + //getApp().goto("/packageC/pages/luckyGo/luckyGo_cart_ct/luckyGo_cart_ct?is_bnow=1&goods_id=" + e.goods_id) // getApp().goto("/packageC/pages/luckyGo/luckyGo_cart_ct/luckyGo_cart_ct?is_bnow=1&group_id=" + this.data.group_id +"&goods_id=" + e.goods_id + "&alert=" + this.data.luckGoInfo.lc_alert); } @@ -2054,36 +2053,36 @@ Page({ }) return false; } - - - - if(th.data.more_flash && open_store==1){ - th.setData({is_pop_more:1}); - }else{ - var ind = t.currentTarget.dataset.ind; - //回调。判断是不是优惠促销 - th.check_is_prom_goods(function () { - th.setData({ - openSpecModal: !0, - openSpecModal_ind: ind, - }); - //var is_open=th.data.config - th.get_off_price(); - }) - } - }, - open_next(){ - var th=this; + + + if (th.data.more_flash && open_store == 1) { + th.setData({ is_pop_more: 1 }); + } else { + var ind = t.currentTarget.dataset.ind; //回调。判断是不是优惠促销 th.check_is_prom_goods(function () { - th.setData({ - openSpecModal: !0, - openSpecModal_ind: 1, - is_pop_more:0 - }); - th.get_off_price(); + th.setData({ + openSpecModal: !0, + openSpecModal_ind: ind, + }); + //var is_open=th.data.config + th.get_off_price(); }) + } + }, + + open_next() { + var th = this; + //回调。判断是不是优惠促销 + th.check_is_prom_goods(function () { + th.setData({ + openSpecModal: !0, + openSpecModal_ind: 1, + is_pop_more: 0 + }); + th.get_off_price(); + }) }, //判断是不是优惠促销 @@ -2410,47 +2409,47 @@ Page({ // ob.title = text + " " + name; // } - // var title = th.data.sele_g.goods_name; - // var img = th.data.sele_g.original_img; - - // var url = `packageC/pages/luckyGo/luckyGo_goodsInfo/luckyGo_goodsInfo?goods_id=${th.data.sele_g.goods_id}&prom_type=9&group_id=${th.data.group_id}`; //当前页面url - // if (getApp().globalData.user_id) { - // url += "&first_leader=" + getApp().globalData.user_id; - // } - - // console.log(url) - - // var ob = { - // title: price + "元 " + title, - // path: url, - // imageUrl: img, - // }; - - // return ob; - - - var pagePath = `packageC/pages/luckyGo/luckyGo_goodsInfo/luckyGo_goodsInfo?goods_id=${this.data.sele_g.goods_id}&prom_type=9&group_id=${this.data.group_id}`; //当前页面url - // console.log('pagePath=====xxxxxx>', pagePath); - var imgPath = this.data.iurl + this.data.luckGoInfo.original_img; - if (pagePath.indexOf('/') != 0) { - pagePath = '/' + pagePath; - } - // if(getApp().globalData.user_id){ - - // if(pagePath.indexOf("?")>0){ - // pagePath+="&first_leader="+getApp().globalData.user_id; - // }else{ - // pagePath+="?first_leader="+getApp().globalData.user_id; - // } - // } - return { - title: "邀您一起参加幸运购", - path: pagePath, - imageUrl: imgPath, - } - - - + // var title = th.data.sele_g.goods_name; + // var img = th.data.sele_g.original_img; + + // var url = `packageC/pages/luckyGo/luckyGo_goodsInfo/luckyGo_goodsInfo?goods_id=${th.data.sele_g.goods_id}&prom_type=9&group_id=${th.data.group_id}`; //当前页面url + // if (getApp().globalData.user_id) { + // url += "&first_leader=" + getApp().globalData.user_id; + // } + + // console.log(url) + + // var ob = { + // title: price + "元 " + title, + // path: url, + // imageUrl: img, + // }; + + // return ob; + + + var pagePath = `packageC/pages/luckyGo/luckyGo_goodsInfo/luckyGo_goodsInfo?goods_id=${this.data.sele_g.goods_id}&prom_type=9&group_id=${this.data.group_id}`; //当前页面url + // console.log('pagePath=====xxxxxx>', pagePath); + var imgPath = this.data.iurl + this.data.luckGoInfo.original_img; + if (pagePath.indexOf('/') != 0) { + pagePath = '/' + pagePath; + } + // if(getApp().globalData.user_id){ + + // if(pagePath.indexOf("?")>0){ + // pagePath+="&first_leader="+getApp().globalData.user_id; + // }else{ + // pagePath+="?first_leader="+getApp().globalData.user_id; + // } + // } + return { + title: "邀您一起参加幸运购", + path: pagePath, + imageUrl: imgPath, + } + + + }, //-----图片失败,默认图片----- @@ -2526,12 +2525,12 @@ Page({ if (res.data.code == 0) prom = res.data.data; }) break - - case 8: - continue; case 8: - continue; + continue; + + case 8: + continue; } @@ -2656,14 +2655,14 @@ Page({ async sele_spec_chech_activity() { //---如果是活动的时候--- var prom = null, goodsinfo = this.data.sele_g, th = this; - var user_id=getApp().globalData.user_id; - if(!user_id) user_id=0; + var user_id = getApp().globalData.user_id; + if (!user_id) user_id = 0; if (goodsinfo.prom_type == 1) { - await getApp().request.promiseGet("/api/ms/flash_sale/getNew/" + os.stoid + "/" +user_id+"/"+ goodsinfo.prom_id, { + await getApp().request.promiseGet("/api/ms/flash_sale/getNew/" + os.stoid + "/" + user_id + "/" + goodsinfo.prom_id, { }).then(res => { if (res.data.code == 0) { - prom = res.data.data; - prom.price=prom.user_price; + prom = res.data.data; + prom.price = prom.user_price; } }) } @@ -2689,11 +2688,11 @@ Page({ var now = ut.gettimestamp(); if (prom) { - var t1=prom.start_time; - var prom_st=1; - if(prom.show_time){ - t1=prom.show_time; - if(prom.start_time>now) prom_st=0; + var t1 = prom.start_time; + var prom_st = 1; + if (prom.show_time) { + t1 = prom.show_time; + if (prom.start_time > now) prom_st = 0; } if (prom.is_end == 0 && prom.end_time > now && t1 < now) { th.setData({ @@ -2704,37 +2703,37 @@ Page({ prom_start_time: prom.start_time, prom_st: prom_st, prom_act: prom, - prom_id:prom.id + prom_id: prom.id }) - //却换图片 - th.init(goodsinfo.goods_id); - var newTime = ut.gettimestamp(); - var endTime2 = prom.end_time; - var endTime1 = prom.start_time; + //却换图片 + th.init(goodsinfo.goods_id); + var newTime = ut.gettimestamp(); + var endTime2 = prom.end_time; + var endTime1 = prom.start_time; - this.data.is_timer=0; + this.data.is_timer = 0; - setTimeout(function () { - th.data.is_timer=1; - if (endTime1 > newTime) { - th.setData({ - prom_time_text: '距秒杀开始还有' - }) - th.countDown(th.data.luckGoInfo.end_time, 0); - } else { - if (endTime2 > newTime) { - th.setData({ - prom_time_text: '距秒杀结束还有', - prom_st: 1 - }) - th.countDown(th.data.luckGoInfo.end_time); - } - } + setTimeout(function () { + th.data.is_timer = 1; + if (endTime1 > newTime) { + th.setData({ + prom_time_text: '距秒杀开始还有' + }) + th.countDown(th.data.luckGoInfo.end_time, 0); + } else { + if (endTime2 > newTime) { + th.setData({ + prom_time_text: '距秒杀结束还有', + prom_st: 1 + }) + th.countDown(th.data.luckGoInfo.end_time); + } + } - },1000) + }, 1000) - return false; + return false; } } //---设置普通商品--- @@ -3241,32 +3240,32 @@ Page({ //--------检查是否活动,活动是否开始,或者是否结束------- async check_prom(gid, prom_type, prom_id) { - var ee = this,th = ee; - var user_id=getApp().globalData.user_id; - if(!user_id) user_id=0; + var ee = this, th = ee; + var user_id = getApp().globalData.user_id; + if (!user_id) user_id = 0; - if (prom_type == 3 || prom_type == 0 || prom_type == 2 || prom_type == 5 || prom_type == 7|| prom_type == 9) { + if (prom_type == 3 || prom_type == 0 || prom_type == 2 || prom_type == 5 || prom_type == 7 || prom_type == 9) { this.setData({ - prom_type: 0,isshow: 1, + prom_type: 0, isshow: 1, }); return false; } - if (prom_type == 1 && prom_id==0){ - this.setData({ - prom_type: 0,isshow: 1, - }); + if (prom_type == 1 && prom_id == 0) { + this.setData({ + prom_type: 0, isshow: 1, + }); - //获取门店 - this.get_sto(); - this.get_sku(o.stoid, this.data.data, gid); - this.check_has_flash(); - return false; + //获取门店 + this.get_sto(); + this.get_sku(o.stoid, this.data.data, gid); + this.check_has_flash(); + return false; } //if (prom_type != 3 && prom_type!=0){ //---判断秒杀---- - if (prom_type == 1 && prom_id>0) { + if (prom_type == 1 && prom_id > 0) { //-------判断活动是否抢光--------- await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" + os.stoid + "/" + prom_type + "/" + prom_id, { 1: 1 @@ -3278,7 +3277,7 @@ Page({ prom_r_null: 1 }); //拿取价格并且判断时间-- - getApp().request.get("/api/ms/flash_sale/getNew/" +os.stoid + "/" +user_id+"/"+ prom_id, { + getApp().request.get("/api/ms/flash_sale/getNew/" + os.stoid + "/" + user_id + "/" + prom_id, { success: function (t) { if (t.data.code != 0) { ee.setData({ @@ -3356,51 +3355,51 @@ Page({ //如果是进行中的话 if (endTime1 < newTime) { - //-- 获取秒杀活动的多少规格 -- - ee.get_more_flahs(function (list) { - if (list && list.length > 1) { - - var n_item = list[0]; - var ind = list.findIndex(function (ele) { - return ele.goods_id == ee.data.data.goods_id; - }) - if (ind < 0) return false; - if (ind > 0) { - n_item = JSON.parse(JSON.stringify(list[ind])); - list.splice(ind, 1); - list.unshift(n_item); - } - - ee.data.sele_g.viplimited = n_item.viplimited; - ee.data.data.viplimited = n_item.viplimited; - - var gb = 1; - //-- 显示多规格 -- - for (let i in list) { - let item = list[i]; - var gg = ""; - if (item.goods_spec == "null" || item.goods_spec == null) item.goods_spec = ""; - if (item.goods_color == "null" || item.goods_color == null) item.goods_color = ""; - - if (item.goods_spec != "" && item.goods_color != "") { - gg = item.goods_spec + "/" + item.goods_color; - } else if (item.goods_spec != "" || item.goods_color != "") { - gg = item.goods_spec + item.goods_color; - } else { - gg = "规格" + gb; - gb++; - } - item.gg = gg; - item.prom_id = item.prom_id; - item.prom_type = 1; - } + //-- 获取秒杀活动的多少规格 -- + ee.get_more_flahs(function (list) { + if (list && list.length > 1) { - ee.setData({ - sku_g: list, - }); + var n_item = list[0]; + var ind = list.findIndex(function (ele) { + return ele.goods_id == ee.data.data.goods_id; + }) + if (ind < 0) return false; + if (ind > 0) { + n_item = JSON.parse(JSON.stringify(list[ind])); + list.splice(ind, 1); + list.unshift(n_item); + } + ee.data.sele_g.viplimited = n_item.viplimited; + ee.data.data.viplimited = n_item.viplimited; + + var gb = 1; + //-- 显示多规格 -- + for (let i in list) { + let item = list[i]; + var gg = ""; + if (item.goods_spec == "null" || item.goods_spec == null) item.goods_spec = ""; + if (item.goods_color == "null" || item.goods_color == null) item.goods_color = ""; + + if (item.goods_spec != "" && item.goods_color != "") { + gg = item.goods_spec + "/" + item.goods_color; + } else if (item.goods_spec != "" || item.goods_color != "") { + gg = item.goods_spec + item.goods_color; + } else { + gg = "规格" + gb; + gb++; } - }) + item.gg = gg; + item.prom_id = item.prom_id; + item.prom_type = 1; + } + + ee.setData({ + sku_g: list, + }); + + } + }) } } @@ -3736,35 +3735,35 @@ Page({ min: this.timeFormat(min), sec: this.timeFormat(sec) } - // console.log('cd'); + // console.log('cd'); } else { - - - - obj = { - day: '00', - hou: '00', - min: '00', - sec: '00' - } - - th.setData({ - djs: obj, - isTimeUp: true, - }); - // console.log('i am here'); - return false; + + + + obj = { + day: '00', + hou: '00', + min: '00', + sec: '00' + } + + th.setData({ + djs: obj, + isTimeUp: true, + }); + // console.log('i am here'); + return false; } - - // ---- - - - - - th.setData({ - djs: obj - }); - // ---- + + // ---- + + + + + th.setData({ + djs: obj + }); + // ---- setTimeout(function () { th.countDown(endTime) }, 1000); @@ -3799,12 +3798,12 @@ Page({ success: function (t) { if (t.data.code == 0) { var g_buy_num = t.data.data.goodsbuynum; - - //如果是秒杀的时候 - if(th.data.prom_type==0 && gd.prom_type == 1 ){ - gd.prom_type= 0; - } - + + //如果是秒杀的时候 + if (th.data.prom_type == 0 && gd.prom_type == 1) { + gd.prom_type = 0; + } + if (gd.prom_type == 1 || gd.prom_type == 2 || gd.prom_type == 4 || gd.prom_type == 6) { //----获取活动购买数---- getApp().request.get("/api/weshop/ordergoods/getUserBuyGoodsNum", { @@ -3861,7 +3860,7 @@ Page({ }, //--点击弹起拼单-- - // ind == 1 为普通购买 + // ind == 1 为普通购买 openSpecModel_pt: function (e) { this.setData({ open_ind_store: 9, goodsInputNum: 1 }); @@ -3879,125 +3878,125 @@ Page({ page: 1 } }).then(res => { - if(res.data.code == 0){ - if (res.data.data.total > 0) { - // 待支付订单页面 - wx.showModal({ - title: "您已经购买了该商品待支付中", - success: function (a) { - if (a.confirm) { - switOn = false; - wx.navigateTo({ - url: "/packageC/pages/luckyGo/luckyGo_order/luckyGo_order?order_id=" + res.data.data.pageData[0]['order_id'] - }); - } + if (res.data.code == 0) { + if (res.data.data.total > 0) { + // 待支付订单页面 + wx.showModal({ + title: "您已经购买了该商品待支付中", + success: function (a) { + if (a.confirm) { + switOn = false; + wx.navigateTo({ + url: "/packageC/pages/luckyGo/luckyGo_order/luckyGo_order?order_id=" + res.data.data.pageData[0]['order_id'] + }); } - }); - } else { - //--先判断会员状态-- - var user_info = getApp().globalData.userInfo; - if (user_info == null || user_info.mobile == undefined || user_info.mobile == '' || user_info.mobile == null) { - wx.navigateTo({ - url: '/pages/togoin/togoin', - }) - return false; - }; + } + }); + } else { + //--先判断会员状态-- + var user_info = getApp().globalData.userInfo; + if (user_info == null || user_info.mobile == undefined || user_info.mobile == '' || user_info.mobile == null) { + wx.navigateTo({ + url: '/pages/togoin/togoin', + }) + return false; + }; - var th = this; - var ind = parseInt(e.currentTarget.dataset.ind); - - console.log('当前ind========>>>>', ind); - - //ind == 1是普通购买 - if (ind == 1) { - //如果拼单的sku data是空的,就要先获取一下 - if (th.data.sku_g_pt) { - th.get_sto(1); - th.setData({ - is_normal: ind, - openSpecModal_pt: 1 - }); - } else { - th.get_sto(1); - th.get_sku(o.stoid, th.data.data, th.data.gid, 1, function () { - th.setData({ - is_normal: ind, - openSpecModal_pt: 1 - }); - }); - + var th = this; + var ind = parseInt(e.currentTarget.dataset.ind); + + console.log('当前ind========>>>>', ind); + + //ind == 1是普通购买 + if (ind == 1) { + //如果拼单的sku data是空的,就要先获取一下 + if (th.data.sku_g_pt) { + th.get_sto(1); + th.setData({ + is_normal: ind, + openSpecModal_pt: 1 + }); + } else { + th.get_sto(1); + th.get_sku(o.stoid, th.data.data, th.data.gid, 1, function () { th.setData({ is_normal: ind, openSpecModal_pt: 1 }); - }; - th.check_is_youhui(th.data.gid, 1); - } else { + }); - // //拼单商品从这里进,先判断有没有买过商品, - // getApp().request.get("/api/weshop/order/page", { - // data: { - // // pt_prom_id: th.data.prom_act.id, - // user_id: oo.user_id, - // store_id: os.stoid, - // pageSize: 1, - // page: 1 - // }, - // success: function (e) { - // //--跳转到已经购买的情况-- - // if (e.data.data.pageData.length > 0) { - // var odr = e.data.data.pageData[0]; - // //还未支付 - // if (odr.pt_status == 0 && (odr.order_status == 1 || odr.order_status == 0)) { - // wx.showModal({ - // title: "您已经购买了该商品待支付中", - // success: function (a) { - // if (a.confirm) { - // wx.navigateTo({ - // url: "/pages/user/order_detail/order_detail?order_id=" + odr.order_id, - // }); - // } - // } - // }); - // } else if (odr.pt_status == 1 && odr.order_status == 1) { - - // if (this.data.is_go_to_team_show) return false; - // this.data.is_go_to_team_show = 1; - // wx.showLoading(); - - // /*--- - // wx.redirectTo({ - // url: "/pages/team/team_success/team_success?ordersn=" + odr.order_sn, - // });--*/ - // getApp().goto("/pages/team/team_success/team_success?ordersn=" + odr.order_sn); - - // } else { - // th.setData({ - // is_normal: ind, - // openSpecModal_pt: 1 - // }); - // } - - // } else { - // th.setData({ - // is_normal: ind, - // openSpecModal_pt: 1 - // }); - // } - // } - // }); - th.get_sto(1); th.setData({ - is_normal: 0, + is_normal: ind, openSpecModal_pt: 1 }); - - } + }; + th.check_is_youhui(th.data.gid, 1); + } else { + + // //拼单商品从这里进,先判断有没有买过商品, + // getApp().request.get("/api/weshop/order/page", { + // data: { + // // pt_prom_id: th.data.prom_act.id, + // user_id: oo.user_id, + // store_id: os.stoid, + // pageSize: 1, + // page: 1 + // }, + // success: function (e) { + // //--跳转到已经购买的情况-- + // if (e.data.data.pageData.length > 0) { + // var odr = e.data.data.pageData[0]; + // //还未支付 + // if (odr.pt_status == 0 && (odr.order_status == 1 || odr.order_status == 0)) { + // wx.showModal({ + // title: "您已经购买了该商品待支付中", + // success: function (a) { + // if (a.confirm) { + // wx.navigateTo({ + // url: "/pages/user/order_detail/order_detail?order_id=" + odr.order_id, + // }); + // } + // } + // }); + // } else if (odr.pt_status == 1 && odr.order_status == 1) { + + // if (this.data.is_go_to_team_show) return false; + // this.data.is_go_to_team_show = 1; + // wx.showLoading(); + + // /*--- + // wx.redirectTo({ + // url: "/pages/team/team_success/team_success?ordersn=" + odr.order_sn, + // });--*/ + // getApp().goto("/pages/team/team_success/team_success?ordersn=" + odr.order_sn); + + // } else { + // th.setData({ + // is_normal: ind, + // openSpecModal_pt: 1 + // }); + // } + + // } else { + // th.setData({ + // is_normal: ind, + // openSpecModal_pt: 1 + // }); + // } + // } + // }); + th.get_sto(1); + th.setData({ + is_normal: 0, + openSpecModal_pt: 1 + }); + } - } + + } }); - + @@ -4005,9 +4004,9 @@ Page({ //-----------------拼单生成方法--------------------- addCart_pt: function () { - this.setData({ - openSpecModal_pt: 0, - }); + this.setData({ + openSpecModal_pt: 0, + }); if (this.data.is_normal == 0) { //看一下有没有起购数,如果有起购数,要计算起购数 // var qnum = parseFloat(th.data.prom_act.minbuynum); @@ -4049,7 +4048,7 @@ Page({ // return false; // } // } - + //---判断商品是否超出活动限购,拼团的普通购买不计算活动的限购--- // if (th.data.prom_buy_num != -1 && th.data.prom_buy_limit > 0 && th.data.is_normal != 1) { // if (th.data.goodsInputNum + th.data.prom_buy_num > th.data.prom_buy_limit) { @@ -4098,7 +4097,7 @@ Page({ sto_sele_name: "" }); if (th.data.sto_sele_name == "") return s.my_warnning("请选择门店", 0, th); - + //--------------此时操作的数据------------ var newd = { goods_id: o.goods_id, @@ -4171,11 +4170,11 @@ Page({ } } - - // else if (th.data.prom_type == 3) { - // newd.prom_type = 0; - // newd.prom_id = 0; - // } + + // else if (th.data.prom_type == 3) { + // newd.prom_type = 0; + // newd.prom_id = 0; + // } newd['pick_name'] = th.data.sto_sele_name; newd['pick_dis'] = th.data.sto_sele_distr; @@ -4189,25 +4188,25 @@ Page({ newd['prom_type'] = 0; newd['prom_id'] = e.act_id; } - console.log('aaaaa'); - newd['prom_type'] = 0; + console.log('aaaaa'); + newd['prom_type'] = 0; th.buyNow(newd); }); } else { - // 点击立即参团 - th.buyNow_pt(newd); - }; + // 点击立即参团 + th.buyNow_pt(newd); + }; }) }, //----------立即购买_pt----------- buyNow_pt: function (e) { s.set_b_now(e); wx.navigateTo({ - url: "/packageC/pages/luckyGo/luckyGo_cart_ct/luckyGo_cart_ct?is_bnow=1&group_id=" + this.data.group_id + "&goods_id=" + e.goods_id + "&alert=" + this.data.luckGoInfo.lc_alert + '&goods_price=' + this.data.luckGoInfo.group_price/100 + '&is_show=' + this.data.luckGoInfo.is_show, + url: "/packageC/pages/luckyGo/luckyGo_cart_ct/luckyGo_cart_ct?is_bnow=1&group_id=" + this.data.group_id + "&goods_id=" + e.goods_id + "&alert=" + this.data.luckGoInfo.lc_alert + '&goods_price=' + this.data.luckGoInfo.group_price / 100 + '&is_show=' + this.data.luckGoInfo.is_show, }); - - // getApp().goto("/packageC/pages/luckyGo/luckyGo_cart/luckyGo_cart?is_bnow=1&group_id=" + th.data.group_id +"&goods_id=" + e.goods_id + "&alert=" + th.data.luckGoInfo.lc_alert); + + // getApp().goto("/packageC/pages/luckyGo/luckyGo_cart/luckyGo_cart?is_bnow=1&group_id=" + th.data.group_id +"&goods_id=" + e.goods_id + "&alert=" + th.data.luckGoInfo.lc_alert); }, //-------跳转pt商品------- @@ -4529,95 +4528,95 @@ Page({ } }) }, - - - drawPoster(context, unit, img, vpath) { - // 1.灰色背景 - context.setFillStyle('#f2f1f6'); - context.rect(0,0,554*unit,899*unit); - context.fill(); - // 2.商城名称 - let shopName = this.data.sto_sele_name_1; - // let shopNameLen = context.measureText(shopName); - // let x_shopNameLen = (554 - shopNameLen.width)/2*unit; - // console.log('11111111111111',shopNameLen,x_shopNameLen); - context.setTextAlign('center'); - context.setFontSize(26*unit); - context.setFillStyle('black'); - context.fillText(shopName, 277*unit, 60*unit); - // // 3.推荐来源 - let fromText = `来自${getApp().globalData.userInfo.nickname}的推荐`; - // let fromTextLen = context.measureText(fromText); - // let x_fromText = (375 - fromTextLen.width)/2; - // console.log('222222',fromTextLen,x_fromText); - context.setTextAlign('center'); - context.setFontSize(22*unit); - context.setFillStyle('#96959a'); - context.fillText(fromText, 277*unit, 105*unit); - // 4.海报背景 - // context.beginPath(); - // context.setStrokeStyle('#f2f1f6'); - context.setFillStyle('white'); - context.fillRect(37*unit, 157*unit, 480*unit, 673*unit); - // context.stroke(); - // context.fill(); - // 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.强烈推荐 - // context.beginPath(); - let tj_path = "../../../../images/share/q_tj.png"; - context.beginPath() - context.drawImage(tj_path, 54*unit, 648*unit, 85*unit, 30*unit); - context.setFontSize(16*unit) - context.setLineJoin('round'); //交点设置成圆角 - context.setFillStyle("white") - context.setTextAlign('left'); - context.fillText('强烈推荐', 64*unit, 672*unit); - // 7.商品价格 - let price = '¥' + this.data.data.shop_price; - // if (th.data.prom_act) - // pri0 = th.data.prom_act.price; - context.setFontSize(32*unit); - context.setFillStyle('#DE1117'); - context.fillText(price, 54*unit, 730*unit); - // 8.商品标题 - context.setFontSize(20*unit); - context.setFillStyle('#898989'); - this.draw_Text(context, this.data.data.goods_name, - 54*unit, 770*unit, 240*unit, 240*unit, unit); - // 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(); - - }, - - + + + drawPoster(context, unit, img, vpath) { + // 1.灰色背景 + context.setFillStyle('#f2f1f6'); + context.rect(0, 0, 554 * unit, 899 * unit); + context.fill(); + // 2.商城名称 + let shopName = this.data.sto_sele_name_1; + // let shopNameLen = context.measureText(shopName); + // let x_shopNameLen = (554 - shopNameLen.width)/2*unit; + // console.log('11111111111111',shopNameLen,x_shopNameLen); + context.setTextAlign('center'); + context.setFontSize(26 * unit); + context.setFillStyle('black'); + context.fillText(shopName, 277 * unit, 60 * unit); + // // 3.推荐来源 + let fromText = `来自${getApp().globalData.userInfo.nickname}的推荐`; + // let fromTextLen = context.measureText(fromText); + // let x_fromText = (375 - fromTextLen.width)/2; + // console.log('222222',fromTextLen,x_fromText); + context.setTextAlign('center'); + context.setFontSize(22 * unit); + context.setFillStyle('#96959a'); + context.fillText(fromText, 277 * unit, 105 * unit); + // 4.海报背景 + // context.beginPath(); + // context.setStrokeStyle('#f2f1f6'); + context.setFillStyle('white'); + context.fillRect(37 * unit, 157 * unit, 480 * unit, 673 * unit); + // context.stroke(); + // context.fill(); + // 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.强烈推荐 + // context.beginPath(); + let tj_path = "../../../../images/share/q_tj.png"; + context.beginPath() + context.drawImage(tj_path, 54 * unit, 648 * unit, 85 * unit, 30 * unit); + context.setFontSize(16 * unit) + context.setLineJoin('round'); //交点设置成圆角 + context.setFillStyle("white") + context.setTextAlign('left'); + context.fillText('强烈推荐', 64 * unit, 672 * unit); + // 7.商品价格 + let price = '¥' + this.data.data.shop_price; + // if (th.data.prom_act) + // pri0 = th.data.prom_act.price; + context.setFontSize(32 * unit); + context.setFillStyle('#DE1117'); + context.fillText(price, 54 * unit, 730 * unit); + // 8.商品标题 + context.setFontSize(20 * unit); + context.setFillStyle('#898989'); + this.draw_Text(context, this.data.data.goods_name, + 54 * unit, 770 * unit, 240 * unit, 240 * unit, unit); + // 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(); + + }, + + //--定义的保存图片方法,分享团--- saveImageToPhotosAlbum: function () { @@ -4630,16 +4629,16 @@ Page({ } if (this.data.share_hidden) { - this.setData({ share_hidden: false,}); + this.setData({ share_hidden: false, }); }; //类型 0普通商品 1秒杀商品 2商家和会员团 3阶梯团 4阶梯团 9幸运购 var type = 9; - console.log('type',type); + console.log('type', type); if (type == 6) type = 2; if (this.data.prom_act && this.data.prom_act.kttype == 3) type = 3; - wx.showLoading({ title: '生成中...',}) + wx.showLoading({ title: '生成中...', }) var that = this, th = that; //设置画板显示,才能开始绘图 that.setData({ @@ -4650,8 +4649,8 @@ Page({ 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.luckGoInfo.id; - // th.data.sele_g.prom_id + scene += "." + th.data.sele_g.prom_type + "." + th.data.luckGoInfo.id; + // th.data.sele_g.prom_id var user_id = getApp().globalData.user_id ? getApp().globalData.user_id : 0; if (user_id > 0) { @@ -4664,13 +4663,13 @@ Page({ scene += "_" + getApp().globalData.room_id; } ///二微码 - var path3 = os.url + "/api/wx/open/app/user/getWeAppEwm/" + - os.stoid + "?sceneValue=" + scene + "&pageValue=packageC/pages/luckyGo/luckyGo_goodsInfo/luckyGo_goodsInfo"; + var path3 = os.url + "/api/wx/open/app/user/getWeAppEwm/" + + os.stoid + "?sceneValue=" + scene + "&pageValue=packageC/pages/luckyGo/luckyGo_goodsInfo/luckyGo_goodsInfo"; // var path3 = os.url + "/api/wx/open/app/user/getWeAppEwm/" + // os.stoid + "?sceneValue=" + scene + "&pageValue=packageC/pages/luckyGo/luckyGo_goodsInfo/luckyGo_goodsInfo"; - console.log('path3......',path3); - + console.log('path3......', path3); + // 读取文件成功则OK-- wx.getImageInfo({ @@ -4685,86 +4684,86 @@ Page({ // context.fillStyle="#FFFFFF"; // context.fillRect(0,0,554 * unit, 899 * unit); - - // if(type == 0) { - // this.drawPoster(context); - // return false; - // }; - + + // if(type == 0) { + // this.drawPoster(context); + // return false; + // }; + //-- 如果有自定义海报的时候,判断背景的图片 -- if (th.data.share_b_img) { pg_path = th.data.share_b_img; } // context.drawImage(pg_path, 0, 0, 554 * unit, 899 * unit); - - - if(type == 0) { // 如果是普通商品,绘制新海报 - th.drawPoster(context, unit, th.data.share_goods_img, vpath); - } else { - context.drawImage(pg_path, 0, 0, 554 * unit, 899 * unit); - }; - - // th.drawPoster(context, unit, th.data.share_goods_img, vpath); - + + + if (type == 0) { // 如果是普通商品,绘制新海报 + th.drawPoster(context, unit, th.data.share_goods_img, vpath); + } else { + context.drawImage(pg_path, 0, 0, 554 * unit, 899 * unit); + }; + + // th.drawPoster(context, unit, th.data.share_goods_img, vpath); + //-- 是自定义海报的情况下 -- - if(type != 0) { - - - - 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, 60 * unit); - var width = 24 * app.globalData.userInfo.nickname.length * unit + 2 * unit; - //强烈推荐 改许程 - // var tj_path = "../../../../images/share/q_tj.png"; - // let txt_gn = th.data.luckGoInfo.group_num + '人团'; - // let width_gn = ut.measureText(txt_gn, 15); - // context.drawImage(tj_path, 152 * unit + width, 54 * unit, (width_gn + 20) * unit, 30 * unit); - // context.setFontSize(16 * unit); - // context.setLineJoin('round'); //交点设置成圆角 - // context.setFillStyle("white"); - // context.fillText(txt_gn, 149 * unit + width + 15 * unit, 75 * unit); - // 发出幸运购活动邀请 - context.setFillStyle("#7f7f7f") - context.setFontSize(21.3 * unit) - context.fillText("向您发出幸运购邀请", 152 * unit, 90 * unit); - - } - - }; - - - - var share_title = th.data.data.goods_name; + if (type != 0) { + + + + 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, 60 * unit); + var width = 24 * app.globalData.userInfo.nickname.length * unit + 2 * unit; + //强烈推荐 改许程 + // var tj_path = "../../../../images/share/q_tj.png"; + // let txt_gn = th.data.luckGoInfo.group_num + '人团'; + // let width_gn = ut.measureText(txt_gn, 15); + // context.drawImage(tj_path, 152 * unit + width, 54 * unit, (width_gn + 20) * unit, 30 * unit); + // context.setFontSize(16 * unit); + // context.setLineJoin('round'); //交点设置成圆角 + // context.setFillStyle("white"); + // context.fillText(txt_gn, 149 * unit + width + 15 * unit, 75 * unit); + // 发出幸运购活动邀请 + context.setFillStyle("#7f7f7f") + context.setFontSize(21.3 * unit) + context.fillText("向您发出幸运购邀请", 152 * unit, 90 * unit); + + } + + }; + + + + var share_title = th.data.data.goods_name; if (th.data.prom_type == 1 || 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; @@ -4784,8 +4783,8 @@ Page({ context.setFillStyle("red") - var pri0 = th.data.luckGoInfo.group_price/100; - // console.log('pri0========>>>>>', pri0); + var pri0 = th.data.luckGoInfo.group_price / 100; + // console.log('pri0========>>>>>', pri0); // if (th.data.prom_act) // pri0 = th.data.prom_act.price; pri0 = parseFloat(pri0).toFixed(2); @@ -4793,13 +4792,13 @@ Page({ context.fillText("¥", wd1 - 15, 185 * unit); context.setFontSize(31 * unit) context.fillText(pri0, wd1, 185 * unit); - - var tj_path = "../../../../images/share/q_tj.png"; - context.drawImage(tj_path, 315 * unit, 158 * unit, 85 * unit, 30 * unit); - context.setLineJoin('round'); //交点设置成圆角 - context.setFontSize(18 * unit); - context.setFillStyle("white"); - context.fillText('参团价', 330 * unit, 179 * unit); + + var tj_path = "../../../../images/share/q_tj.png"; + context.drawImage(tj_path, 315 * unit, 158 * unit, 85 * unit, 30 * unit); + context.setLineJoin('round'); //交点设置成圆角 + context.setFontSize(18 * unit); + context.setFillStyle("white"); + context.fillText('参团价', 330 * unit, 179 * unit); //---市场价划掉--- context.setFillStyle("gray") @@ -4814,7 +4813,7 @@ Page({ context.lineTo(wd2 + ut.measureText(pri0, 22 * unit) + 5, 206 * unit); context.stroke(); - } else if(type == 4 && type != 0) { + } else if (type == 4 && type != 0) { context.setFillStyle("black"); context.setFontSize(21.3 * unit) th.draw_Text(context, share_title, @@ -4834,12 +4833,12 @@ Page({ } //---中间大图--- - if(type != 0) { - context.drawImage(th.data.share_goods_img, 70 * unit, 250 * unit, 408 * unit, 408 * unit); - }; - - - + if (type != 0) { + context.drawImage(th.data.share_goods_img, 70 * unit, 250 * unit, 408 * unit, 408 * unit); + }; + + + //-------大图后面就不一样了----------- switch (type) { case 0: break;//普通商品的展示 @@ -5052,130 +5051,130 @@ Page({ context.drawImage(vpath, 390 * unit, 726 * unit, 136 * unit, 136 * unit); } break; - - - case 9: - - //---画线--- - context.setLineWidth(1 * unit) - context.moveTo(32 * unit, 680 * unit) - context.lineTo(520 * unit, 680 * unit) - context.stroke(); - - //---文字--- - context.setFillStyle("black") - context.setFontSize(24 * unit) - context.font = 'normal bold 18px'; - context.fillText(th.data.sto_sele_name_1, 40 * unit, 720 * unit); - - //还差N人,即可成团 - let group_num = th.data.luckGoInfo.group_num; - let num_joined = th.data.luckGoInfo.num; - let delta1 = group_num - num_joined; - let width_delta1 = ut.measureText(delta1, 15); - context.setFillStyle("black"); - context.setFontSize(21.3 * unit); - context.fillText(group_num + "人团,还差", 40 * unit, 772 * unit); - context.setFillStyle("#FF6768"); - context.setFontSize(21.3 * unit); - context.fillText(delta1, 160 * unit, 772 * unit); - context.setFillStyle("black"); - context.setFontSize(21.3 * unit); - context.fillText("人,即可成团", (170 + width_delta1) * unit, 772 * unit); - - // N人得商品,N人全额退款 - let group_win = th.data.luckGoInfo.group_win; - let delta2 = group_num - group_win; - let width_delta2 = ut.measureText(delta2, 16); - let width_groupNum = ut.measureText(group_num, 15); - let width_groupWin = ut.measureText(group_win, 15); - context.setFillStyle("#FF6768"); - context.setFontSize(21.3 * unit); - context.fillText(group_win, 40 * unit, 806 * unit); - context.setFillStyle("black"); - context.setFontSize(21.3 * unit); - context.fillText("人得商品,", (54 + width_groupWin) * unit, 806 * unit); - context.setFillStyle("#FF6768"); - context.setFontSize(21.3 * unit); - context.fillText(delta2, 160 * unit, 806 * unit); - context.setFillStyle("black"); - context.setFontSize(21.3 * unit); - context.fillText("人全额退款", (170 + width_delta2) * unit, 806 * unit); - - // 并得帮团惊喜礼品 - context.setFillStyle("black") - context.setFontSize(21.3 * unit) - context.fillText("并得帮团", 40 * unit, 840 * unit); - context.setFillStyle("#FF6768") - context.setFontSize(21.3 * unit) - context.fillText("惊喜礼品", 130 * unit, 840 * unit); - context.setFillStyle("black") - context.setFontSize(21.3 * unit) - context.fillText("!", 220 * unit, 840 * unit); - - - //---二维吗图--- - //-- 自定义海报 -- - if (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 9: + + //---画线--- + context.setLineWidth(1 * unit) + context.moveTo(32 * unit, 680 * unit) + context.lineTo(520 * unit, 680 * unit) + context.stroke(); + + //---文字--- + context.setFillStyle("black") + context.setFontSize(24 * unit) + context.font = 'normal bold 18px'; + context.fillText(th.data.sto_sele_name_1, 40 * unit, 720 * unit); + + //还差N人,即可成团 + let group_num = th.data.luckGoInfo.group_num; + let num_joined = th.data.luckGoInfo.num; + let delta1 = group_num - num_joined; + let width_delta1 = ut.measureText(delta1, 15); + context.setFillStyle("black"); + context.setFontSize(21.3 * unit); + context.fillText(group_num + "人团,还差", 40 * unit, 772 * unit); + context.setFillStyle("#FF6768"); + context.setFontSize(21.3 * unit); + context.fillText(delta1, 160 * unit, 772 * unit); + context.setFillStyle("black"); + context.setFontSize(21.3 * unit); + context.fillText("人,即可成团", (170 + width_delta1) * unit, 772 * unit); + + // N人得商品,N人全额退款 + let group_win = th.data.luckGoInfo.group_win; + let delta2 = group_num - group_win; + let width_delta2 = ut.measureText(delta2, 16); + let width_groupNum = ut.measureText(group_num, 15); + let width_groupWin = ut.measureText(group_win, 15); + context.setFillStyle("#FF6768"); + context.setFontSize(21.3 * unit); + context.fillText(group_win, 40 * unit, 806 * unit); + context.setFillStyle("black"); + context.setFontSize(21.3 * unit); + context.fillText("人得商品,", (54 + width_groupWin) * unit, 806 * unit); + context.setFillStyle("#FF6768"); + context.setFontSize(21.3 * unit); + context.fillText(delta2, 160 * unit, 806 * unit); + context.setFillStyle("black"); + context.setFontSize(21.3 * unit); + context.fillText("人全额退款", (170 + width_delta2) * unit, 806 * unit); + + // 并得帮团惊喜礼品 + context.setFillStyle("black") + context.setFontSize(21.3 * unit) + context.fillText("并得帮团", 40 * unit, 840 * unit); + context.setFillStyle("#FF6768") + context.setFontSize(21.3 * unit) + context.fillText("惊喜礼品", 130 * unit, 840 * unit); + context.setFillStyle("black") + context.setFontSize(21.3 * unit) + context.fillText("!", 220 * unit, 840 * unit); + + + //---二维吗图--- + //-- 自定义海报 -- + if (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; } //--- 如果是自定义海报的时候 --- - if(type != 0) { - - 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(); - } - - }; - + if (type != 0) { + + 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(); + } + + }; + //把画板内容绘制成图片,并回调 画板图片路径 @@ -5413,7 +5412,7 @@ Page({ // } // }) }, - + // 选择门店 choice_store: function (ee) { var th = this; @@ -5429,7 +5428,7 @@ Page({ getApp().confirmBox("门店库存不足", null, 25000, !1); return false; } - + if (th.data.def_pickpu_list && !th.data.def_pickpu_list.length) { getApp().confirmBox("门店库存不足", null, 25000, !1); return false; @@ -5489,7 +5488,7 @@ Page({ }) } }, - + //关闭选择门店 close_popup: function (e) { var th = this; @@ -5541,7 +5540,7 @@ Page({ sort_store: function () { }, - + // 返回按钮 returns: function () { this.setData({ @@ -5549,7 +5548,7 @@ Page({ choice_sort_store: 0 }); }, - + //---选择分类门店--- choice_sort_store: function (e) { var index = e.currentTarget.dataset.index; @@ -5683,7 +5682,7 @@ Page({ } else { th.setData({ - // openSpecModal_pt: 1, + // openSpecModal_pt: 1, store: 0, choice_sort_store: 0, sort_store: 0 @@ -5693,7 +5692,7 @@ Page({ th.get_off_price(); }) }, - + //---点击二级之后的选择--- choose_for_store: function (e) { var index_c = e.currentTarget.dataset.ind; @@ -5704,7 +5703,7 @@ Page({ }) }, - + //把选择的门店设置成默认的门店def_pick set_def_pick: function (e) { var th = this; @@ -5904,11 +5903,11 @@ Page({ go_plus: function () { getApp().goto("/pages/user/plus/plus"); }, - + go_card_info: function () { getApp().goto("/pages/user/cardinfo/cardinfo"); }, - + //-- 根据ID拿出门店 -- get_pick_from_list(pid) { var all_pick_list = this.data.all_pick_list; @@ -6137,7 +6136,7 @@ Page({ this.get_sto(0) this.setData({ openSpecModal_inte: 1, goodsInputNum: 1 }); }, - + //-- 积分购普通购买 -- go_pay_integral_normal: function () { var th = this; @@ -6262,236 +6261,236 @@ Page({ // }) // }, - //获取更多秒杀 - // get_more_flahs: async function (func) { - // var f_more=false; - // var user_id=getApp().globalData.user_id; - // if(!user_id) user_id=0; - - // var url="/api/weshop/goods/listSkuFlash?store_id="+os.stoid+"&goods_id="+this.data.data.goods_id+"&user_id="+user_id; - // //获取秒杀的多规格 - // await getApp().request.promiseGet(url, {}).then(res=>{ - // if(res.data.code==0 && res.data.data && res.data.data.length>0){ - // f_more=res.data.data; - // } - // }) - // if(!f_more) { - // func(false); - // return false; - // } - // //-- 秒杀的价格要更新 -- - // for(let i in f_more){ - - // let item=f_more[i]; - // f_more[i].prom_id=item.act_id; - // f_more[i].prom_type=1; - // if(item.goods_id==this.data.data.goods_id){ - // continue; - // } - // var url="/api/ms/flash_sale/getNew/"+os.stoid+"/"+user_id+"/"+item.act_id; - // await getApp().request.promiseGet(url, {}).then(rs=>{ - // if(rs.data.code==0){ - // f_more[i].price=rs.data.data.user_price; + //获取更多秒杀 + // get_more_flahs: async function (func) { + // var f_more=false; + // var user_id=getApp().globalData.user_id; + // if(!user_id) user_id=0; + + // var url="/api/weshop/goods/listSkuFlash?store_id="+os.stoid+"&goods_id="+this.data.data.goods_id+"&user_id="+user_id; + // //获取秒杀的多规格 + // await getApp().request.promiseGet(url, {}).then(res=>{ + // if(res.data.code==0 && res.data.data && res.data.data.length>0){ + // f_more=res.data.data; + // } + // }) + // if(!f_more) { + // func(false); + // return false; + // } + // //-- 秒杀的价格要更新 -- + // for(let i in f_more){ + + // let item=f_more[i]; + // f_more[i].prom_id=item.act_id; + // f_more[i].prom_type=1; + // if(item.goods_id==this.data.data.goods_id){ + // continue; + // } + // var url="/api/ms/flash_sale/getNew/"+os.stoid+"/"+user_id+"/"+item.act_id; + // await getApp().request.promiseGet(url, {}).then(rs=>{ + // if(rs.data.code==0){ + // f_more[i].price=rs.data.data.user_price; + + // } + // }) + // } + // func(f_more); - // } - // }) + // }, + + //-- 判断是否有秒杀 -- ccc + check_has_flash: function () { + // var th=this; + // var url="/api/weshop/activitylist/getGoodActInfo"; + // var req_data={ + // store_id:os.stoid,goodsidlist:this.data.data.goods_id,is_detail:1 + // }; + // //获取秒杀的多规格 + // getApp().request.promiseGet(url, {data:req_data}).then(res=>{ + // if(res.data.code==0 && res.data.data && res.data.data.length){ + // th.setData({more_flash:res.data.data}); // } - // func(f_more); - - // }, - - //-- 判断是否有秒杀 -- ccc - check_has_flash:function () { - // var th=this; - // var url="/api/weshop/activitylist/getGoodActInfo"; - // var req_data={ - // store_id:os.stoid,goodsidlist:this.data.data.goods_id,is_detail:1 - // }; - // //获取秒杀的多规格 - // getApp().request.promiseGet(url, {data:req_data}).then(res=>{ - // if(res.data.code==0 && res.data.data && res.data.data.length){ - // th.setData({more_flash:res.data.data}); - // } - // }) - }, + // }) + }, - //-- 跳转到秒杀商品详情页 -- ccc - go_more_flash:function (e) { - // var prom_id=e.currentTarget.dataset.id; - // var goods_id=this.data.data.goods_id; - // var url="/pages/goods/goodsInfo/goodsInfo?goods_id="+goods_id+"&prom_id="+prom_id+"&prom_type=1"; - // getApp().goto(url); - }, + //-- 跳转到秒杀商品详情页 -- ccc + go_more_flash: function (e) { + // var prom_id=e.currentTarget.dataset.id; + // var goods_id=this.data.data.goods_id; + // var url="/pages/goods/goodsInfo/goodsInfo?goods_id="+goods_id+"&prom_id="+prom_id+"&prom_type=1"; + // getApp().goto(url); + }, - close_pop_more:function () { - this.setData({is_pop_more:0}) - }, + close_pop_more: function () { + this.setData({ is_pop_more: 0 }) + }, + + con_weixin: function () { + var url = this.data.sys_switch.weapp_customertype_url; + var id = this.data.sys_switch.weapp_customertype_appid; + wx.openCustomerServiceChat({ + extInfo: { url: url }, + corpId: id, + success(res) { } + }) + }, + + + // 显示幸运购规则 + showRules: function () { + this.setData({ + showRules: true, + }); + }, + + // 关闭幸运购规则 + closeRules: function () { + this.setData({ + showRules: false, + }); + }, + + // 跳转 + go: function (e) { + var url = e.currentTarget.dataset.url; + getApp().goto(url); + }, + + // 查看奖励 + showReward: function () { + + this.getPrizes(this.data.luckGoInfo.type); + + }, + + // 关闭奖励 + closeReward: function () { + this.setData({ + showReward: false, + }); + }, + + + // 获取优惠券奖励和服务项目奖励 + getPrizes: function (type) { + // let currentItem = this.data.list.pageData[currentItemIndex]; + // let type = type; + let self = this; + let app = getApp(); + // 分割type字符串 + let typeArr = this.splitStringToArr(type); + let prizesArr = []; + let promiseArr = []; + typeArr.forEach(function (item) { + + let obj = {}; + obj.type = item; + + let promise = new Promise((resolve, reject) => { + switch (item) { + case 1: { //积分 + obj.name = '积分'; + obj.num = 'point'; + prizesArr.push(obj); + resolve(); + break; + }; + case 2: { //成长值 + obj.name = '成长值'; + obj.num = 'grow'; + prizesArr.push(obj); + resolve(); + break; + }; + case 3: { //优惠券 + app.request.promiseGet('/api/weshop/prom/luckyCoupon/page', { + data: { + store_id: os.stoid, + aid: self.data.luckGoInfo.id, + } + }).then(res => { + if (res.data.code == 0) { + obj.couponList = res.data.data.pageData; + prizesArr.push(obj); + resolve(); + }; + }); + break; + }; + case 4: { //服务项目 + app.request.promiseGet('/api/weshop/prom/luckyService/page', { + data: { + store_id: os.stoid, + aid: self.data.luckGoInfo.id, + } + }).then(res => { + if (res.data.code == 0) { + obj.serviceList = res.data.data.pageData; + prizesArr.push(obj); + resolve(); + }; + }); + break; + }; + case 5: { //预存金额 + obj.name = 'prestore_name'; + obj.num = 'prestore_money'; + prizesArr.push(obj); + resolve(); + break; + }; + }; + }); + + promiseArr.push(promise); + + + Promise.all(promiseArr).then(() => { + self.setData({ + prizesArr, + showReward: true, + }); + }); + + + + }); + + + + }, + + // 将type字符串分割成数组 + splitStringToArr: function (typeStr) { + var index; + var newTypeArr = []; + var typeStrArr = typeStr.split(','); + typeStrArr.forEach(function (item) { + index = parseInt(item); + newTypeArr.push(index); + }); + // console.log('newTypeArr', newTypeArr); + return newTypeArr; + }, + + + //弹出活动已经结束 + timeUp() { + wx.showToast({ + title: '本商品活动已经结束!', + icon: 'none', + }); + }, + + + // 预览海报 + previewPoster() { + wx.previewImage({ + current: this.data.shareImgPath, // 当前显示图片的http链接 + urls: [this.data.shareImgPath],// 需要预览的图片http链接列表 + }); + }, - con_weixin:function () { - var url=this.data.sys_switch.weapp_customertype_url; - var id=this.data.sys_switch.weapp_customertype_appid; - wx.openCustomerServiceChat({ - extInfo: {url: url}, - corpId: id, - success(res) {} - }) - }, - - - // 显示幸运购规则 - showRules: function() { - this.setData({ - showRules: true, - }); - }, - - // 关闭幸运购规则 - closeRules: function() { - this.setData({ - showRules: false, - }); - }, - - // 跳转 - go: function (e) { - var url = e.currentTarget.dataset.url; - getApp().goto(url); - }, - - // 查看奖励 - showReward: function() { - - this.getPrizes(this.data.luckGoInfo.type); - - }, - - // 关闭奖励 - closeReward: function() { - this.setData({ - showReward: false, - }); - }, - - - // 获取优惠券奖励和服务项目奖励 - getPrizes: function(type) { - // let currentItem = this.data.list.pageData[currentItemIndex]; - // let type = type; - let self = this; - let app = getApp(); - // 分割type字符串 - let typeArr = this.splitStringToArr(type); - let prizesArr = []; - let promiseArr = []; - typeArr.forEach(function(item) { - - let obj = {}; - obj.type = item; - - let promise = new Promise((resolve, reject) => { - switch(item) { - case 1: { //积分 - obj.name = '积分'; - obj.num = 'point'; - prizesArr.push(obj); - resolve(); - break; - }; - case 2: { //成长值 - obj.name = '成长值'; - obj.num = 'grow'; - prizesArr.push(obj); - resolve(); - break; - }; - case 3: { //优惠券 - app.request.promiseGet('/api/weshop/prom/luckyCoupon/page', { - data: { - store_id: os.stoid, - aid: self.data.luckGoInfo.id, - } - }).then(res => { - if(res.data.code == 0) { - obj.couponList = res.data.data.pageData; - prizesArr.push(obj); - resolve(); - }; - }); - break; - }; - case 4: { //服务项目 - app.request.promiseGet('/api/weshop/prom/luckyService/page', { - data: { - store_id: os.stoid, - aid: self.data.luckGoInfo.id, - } - }).then(res => { - if(res.data.code == 0) { - obj.serviceList = res.data.data.pageData; - prizesArr.push(obj); - resolve(); - }; - }); - break; - }; - case 5: { //预存金额 - obj.name = 'prestore_name'; - obj.num = 'prestore_money'; - prizesArr.push(obj); - resolve(); - break; - }; - }; - }); - - promiseArr.push(promise); - - - Promise.all(promiseArr).then(()=> { - self.setData({ - prizesArr, - showReward: true, - }); - }); - - - - }); - - - - }, - - // 将type字符串分割成数组 - splitStringToArr: function(typeStr) { - var index; - var newTypeArr = []; - var typeStrArr = typeStr.split(','); - typeStrArr.forEach(function(item) { - index = parseInt(item); - newTypeArr.push(index); - }); - // console.log('newTypeArr', newTypeArr); - return newTypeArr; - }, - - - //弹出活动已经结束 - timeUp() { - wx.showToast({ - title: '本商品活动已经结束!', - icon: 'none', - }); - }, - - - // 预览海报 - previewPoster() { - wx.previewImage({ - current: this.data.shareImgPath, // 当前显示图片的http链接 - urls: [this.data.shareImgPath] ,// 需要预览的图片http链接列表 - }); - }, - }); diff --git a/packageC/pages/presell/goodsInfo/goodsInfo.js b/packageC/pages/presell/goodsInfo/goodsInfo.js index 753d4eb..284314f 100644 --- a/packageC/pages/presell/goodsInfo/goodsInfo.js +++ b/packageC/pages/presell/goodsInfo/goodsInfo.js @@ -252,9 +252,6 @@ Page({ //------初始化加载---------- onLoad: function (t) { - if(!getApp().is_Single_page()){ - return false; - } var ee = this, that = ee, th = ee, pre_id = t.pre_id, gid = t.goods_id, diff --git a/pages/giftpack/buygiftpack/giftpackbuy.js b/pages/giftpack/buygiftpack/giftpackbuy.js index 2990aa3..93f7af1 100644 --- a/pages/giftpack/buygiftpack/giftpackbuy.js +++ b/pages/giftpack/buygiftpack/giftpackbuy.js @@ -77,14 +77,14 @@ Page({ }, onShow: function () { //--先判断会员状态-- - var user_info = getApp().globalData.userInfo; - if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) { - if(getApp().is_Single_page()){ - getApp().goto('/pages/togoin/togoin'); - return false; + getApp().is_Single_page(this,function(){ + var user_info = getApp().globalData.userInfo; + if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) { + getApp().goto('/pages/togoin/togoin'); + return false; } - } - this.getList(); + this.getList(); + }) }, //购买礼包 diff --git a/pages/giftpack/giftpacklist/giftpacklist.js b/pages/giftpack/giftpacklist/giftpacklist.js index 0792604..b5eaf11 100644 --- a/pages/giftpack/giftpacklist/giftpacklist.js +++ b/pages/giftpack/giftpacklist/giftpacklist.js @@ -60,21 +60,19 @@ Page({ }, onShow: function () { - //--先判断会员状态-- - var user_info = getApp().globalData.userInfo; - if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) { - if(getApp().is_Single_page()){ + getApp().is_Single_page(this,function () { + //--先判断会员状态-- + var user_info = getApp().globalData.userInfo; + if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) { getApp().goto('/pages/togoin/togoin'); return false; } - } - - if (this.data.isBuy == 0) { - this.GetMyGiftList(); - } else { - this.GetBuyGiftList(); - } - + if (this.data.isBuy == 0) { + this.GetMyGiftList(); + } else { + this.GetBuyGiftList(); + } + }) }, GetBuyPrice: function (e) { var that = this.data; diff --git a/pages/giftpack/mygiftpack/mygiftpack.js b/pages/giftpack/mygiftpack/mygiftpack.js index f893a97..bb6574b 100644 --- a/pages/giftpack/mygiftpack/mygiftpack.js +++ b/pages/giftpack/mygiftpack/mygiftpack.js @@ -74,16 +74,15 @@ Page({ }, onShow: function() { //--先判断会员状态-- - var user_info = getApp().globalData.userInfo; - if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) { - if(getApp().is_Single_page()){ - getApp().goto('/pages/togoin/togoin'); - return false; + getApp().is_Single_page(this,function () { + var user_info = getApp().globalData.userInfo; + if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) { + getApp().goto('/pages/togoin/togoin'); + return false; } - // getApp().goto('/pages/togoin/togoin'); - // return false; - } - this.getList(); + this.getList(); + }) + }, getList: function() { diff --git a/pages/user/assistance/assistance.js b/pages/user/assistance/assistance.js index 5637522..1d13f42 100644 --- a/pages/user/assistance/assistance.js +++ b/pages/user/assistance/assistance.js @@ -28,17 +28,17 @@ Page({ timer: "", //任务列表的定时器 s_num: "", //多少人已经领取任务 page: 1, //我的任务的当前页 - - imageUrl:'', - btn_color:'', - bg_color:'', - font_color:'', + + imageUrl: '', + btn_color: '', + bg_color: '', + font_color: '', }, /** * 生命周期函数--监听页面加载 */ - onLoad: function(options) { + onLoad: function (options) { var th = this; var nav_b = th.selectComponent("#nav_b"); //组件的id nav_b.set_name("助力", "/pages/user/assistance/assistance"); @@ -48,36 +48,33 @@ Page({ /** * 生命周期函数--监听页面显示 */ - onShow: function() { - + onShow: function () { //--先判断会员状态-- - var user_info = getApp().globalData.userInfo; - if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) { - if(getApp().is_Single_page()){ + getApp().is_Single_page(this, function () { + var user_info = getApp().globalData.userInfo; + if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) { getApp().goto('/pages/togoin/togoin'); return false; } - } + // 助力活动 + this.assistance(); + }) + }, - var th = this; - // 助力活动 - this.assistance(); + print() { + var user_id = getApp().globalData.user_id; + var store_id = os.stoid; + + getApp().request.promiseGet("/api/weshop/marketing/help/act/judge", { + data: { + storeId: store_id, + userId: user_id + } + }).then(res => { + console.log('res', res); + }); }, - - print() { - var user_id = getApp().globalData.user_id; - var store_id = os.stoid; - - getApp().request.promiseGet("/api/weshop/marketing/help/act/judge", { - data: { - storeId: store_id, - userId: user_id - } - }).then(res => { - console.log('res', res); - }); - }, - + // 助力活动 assistance() { var th = this; @@ -96,10 +93,10 @@ Page({ th.setData({ zl_act: help_data, help_id: help_data.id, - btn_color: help_data.btn_color, - bg_color: help_data.bg_color, - font_color: help_data.font_color, - imageUrl: help_data.imageUrl, + btn_color: help_data.btn_color, + bg_color: help_data.bg_color, + font_color: help_data.font_color, + imageUrl: help_data.imageUrl, }); if (th.data.help_id != "" && th.data.help_id != null) { //我的任务 @@ -112,11 +109,11 @@ Page({ storeId: store_id } }) - }else - getApp().my_warnning("暂无此活动或您不符合商家设置的会员参与对象,无法参与!", 0, th); + } else + getApp().my_warnning("暂无此活动或您不符合商家设置的会员参与对象,无法参与!", 0, th); return ut.null_promise(); }).then(res => { - if ( res && res.data &&res.data.code == 0) + if (res && res.data && res.data.code == 0) th.setData({ s_num: res.data.data.countAll }) @@ -126,13 +123,13 @@ Page({ }, //--点击获取用户任务列表--会员的任务列表 - get_list: function() { + get_list: function () { var th = this; var page = th.data.page; - if(page==1)th.data.zl_user_list=[]; + if (page == 1) th.data.zl_user_list = []; var help_id = this.data.help_id; - var r=Math.random()*100; + var r = Math.random() * 100; t.request.get("/api/weshop/marketing/help/help/user/page", { isShowLoading: true, data: { @@ -141,9 +138,9 @@ Page({ helpId: help_id, page: page, pageSize: 5, - r:r, + r: r, }, - success: function(res) { + success: function (res) { clearTimeout(th.data.timer); if (!th.data.is_load) @@ -182,17 +179,17 @@ Page({ }, //-----跳转到领取礼包的页面------ - go_task: function() { + go_task: function () { var th = this; var help_id = th.data.help_id; - if (!help_id){ - getApp().my_warnning("暂无此活动或您不符合商家设置的会员参与对象,无法参与!", 0, th); - return false; - } + if (!help_id) { + getApp().my_warnning("暂无此活动或您不符合商家设置的会员参与对象,无法参与!", 0, th); + return false; + } getApp().goto("/pages/user/assistance/task_assistance?help_id=" + help_id); }, - switch_head: function(e) { + switch_head: function (e) { var th = this; var index = e.currentTarget.dataset.index; //获取当前选择的是任务还是活动说明 var switch_head = th.data.switch_head; //0任务,1活动说明 @@ -204,50 +201,50 @@ Page({ }, //关闭导航 - close: function() { + close: function () { var th = this; var nav_b = th.selectComponent("#nav_b"); //组件的id nav_b.close_box(); }, // 领取礼包 - get_libao: function(e) { + get_libao: function (e) { var help_id = e.currentTarget.dataset.help_id;//活动id var taskId = e.currentTarget.dataset.taskid;//任务id var id = e.currentTarget.dataset.id;//用于跳到礼包详情一键全部领取用的任务id - getApp().goto("/pages/user/assistance/giftpacklist?help_id=" + help_id + "&is_libao=" + 1 + "&taskId=" + taskId+"&id="+id); + getApp().goto("/pages/user/assistance/giftpacklist?help_id=" + help_id + "&is_libao=" + 1 + "&taskId=" + taskId + "&id=" + id); }, //查看礼包id - select_libao: function(e) { + select_libao: function (e) { var orderSn = e.currentTarget.dataset.ordersn; //订单号 getApp().goto("/pages/user/assistance/giftpacklist?orderSn=" + orderSn); }, //---查看任务--- - go_to_task:function (e) { + go_to_task: function (e) { var help_id = this.data.help_id; - var taskid=e.currentTarget.dataset.taskid; - getApp().goto("/pages/user/assistance/task_assistance?help_id=" + help_id+"&taskid="+taskid); + var taskid = e.currentTarget.dataset.taskid; + getApp().goto("/pages/user/assistance/task_assistance?help_id=" + help_id + "&taskid=" + taskid); + }, + + onShareAppMessage(res) { + if (res.from === 'button') { + // 来自页面内转发按钮 + console.log(res.target) + } + return { + // title: '自定义转发标题', + } + }, + + onShareTimeline() { + var store_name = getApp().globalData.config ? getApp().globalData.config.store_name : ''; + if (!store_name) + store_name = getApp().globalData.setting.appName; + return { + title: '好友助力-' + store_name, + } }, - - onShareAppMessage(res) { - if (res.from === 'button') { - // 来自页面内转发按钮 - console.log(res.target) - } - return { - // title: '自定义转发标题', - } - }, - - onShareTimeline() { - var store_name=getApp().globalData.config?getApp().globalData.config.store_name:''; - if(!store_name) - store_name=getApp().globalData.setting.appName; - return { - title: '好友助力-' + store_name, - } - }, })