diff --git a/app.js b/app.js index 7c1ebd8..fc1f971 100644 --- a/app.js +++ b/app.js @@ -2,7 +2,7 @@ var t = require("setting.js"), o = require("./utils/auth.js"), a = require("./ut var os = t; var regeneratorRuntime = require('./utils/runtime.js'); var api = require("./api/api.js") -// import { pluginGD } from './utils/ai_config/config' + //公共方法和变量 App({ @@ -221,21 +221,6 @@ App({ }, - // overShare:function() { - // // 监听路由切换 - // wx.onAppRoute(function(res) { - // console.log('route',res) - // let pages = getCurrentPages() - // let view = pages[pages.length - 1] - // if(view) { - // wx.showShareMenu({ - // withShareTicket:true, - // menus:['shareAppMessage','shareTimeline'] - // }) - // } - // }) - // }, - //---初始化第三方---- initExt: function () { var tt = t; @@ -267,14 +252,6 @@ App({ if (null == s.globalData.userInfo) { return o.auth(t); } - /*--- - a.get("/api/user/userInfo", { - isShowLoading: void 0 === i || i, - success: function(o) { - s.globalData.userInfo = o.data.result, s.globalData.userInfo.head_pic = e.getFullUrl(s.globalData.userInfo.head_pic), - "function" == typeof t && t(s.globalData.userInfo, s.globalData.wechatUser); - } - });--*/ } }, //----------------获取配置参数-------------------- @@ -390,7 +367,6 @@ App({ }); }, showWarning: function (t, o, a, e) { - //var imghost=this.globalData.setting.imghost; !a && (a = 1500), void 0 === e && (e = !0), wx.showToast({ title: t, mask: e, @@ -510,7 +486,7 @@ App({ wx.navigateTo({ url: url, }) //跳到tabbar页 } } - //wx.navigateTo({ url: url, }) //跳到非tabbar页 + }, //显示提示,word提示内容,type 0失败,提示 1成功 @@ -663,11 +639,6 @@ App({ num += e.data.data.pageData[i].goods_num; } } - /*--- - wx.setTabBarBadge({ //tabbar右上角添加文本 - index: 2, ////tabbar下标 - text: '' + num //显示的内容 - });--*/ //-- 读取服务卡的数量 -- that.promiseGet("/api/weshop/cartService/page", { data: { @@ -1075,7 +1046,133 @@ App({ return parseFloat((parseFloat(first_money)+parseFloat(second_money)+parseFloat(third_money)).toFixed(2)); } } - } + }, + + + // 保存图片到手机 + savePic(th) { + console.log('保存图片'); + var self = th; + // 获取用户的当前设置,返回值中有小程序已经向用户请求过的权限 + this.getSetting().then((res) => { + // 判断用户是否授权了保存到相册的权限,如果没有发起授权 + if (!res.authSetting['scope.writePhotosAlbum']) { + this.authorize().then(() => { + // 同意授权后保存下载文件 + this.saveImage(self.data.shareImgPath,th) + .then(() => { + self.setData({ + showPoster: false + }); + }); + }) + } else { + // 如果已经授权,保存下载文件 + this.saveImage(self.data.shareImgPath) + .then(() => { + self.setData({ + showPoster: false + }); + }); + } + + }) + }, + + // 获取用户已经授予了哪些权限 + getSetting() { + return new Promise((resolve, reject) => { + wx.getSetting({ + success: res => { + resolve(res) + } + }) + }) + }, + // 发起首次授权请求 + authorize() { + // isFirst 用来记录是否为首次发起授权, + // 如果首次授权拒绝后,isFirst赋值为1 + let isFirst = wx.getStorageSync('isFirst') || 0; + return new Promise((resolve, reject) => { + wx.authorize({ + scope: 'scope.writePhotosAlbum', + // 同意授权 + success: () => { + resolve(); + }, + // 拒绝授权,这里是用户拒绝授权后的回调 + fail: res => { + if (isFirst === 0) { + wx.setStorageSync('isFirst', 1); + wx.showToast({ + title: '保存失败', + icon: 'none', + duration: 1000 + }) + } + console.log('拒绝授权'); + reject(); + } + }) + }) + }, + // 保存图片到系统相册 + saveImage(saveUrl,th) { + var self = th; + return new Promise((resolve, reject) => { + wx.saveImageToPhotosAlbum({ + filePath: saveUrl, + success: (res) => { + wx.showToast({ + title: '保存成功', + duration: 1000, + }); + self.setData({ + showPlaybill: 'true' + }); + resolve(); + }, + fail: () => { + wx.showToast({ + title: '保存失败', + duration: 1000, + }); + } + }) + }) + }, + + //文本换行 参数:1、canvas对象,2、文本 3、距离左侧的距离 4、距离顶部的距离 5、6、文本的宽度 + draw_Text: function (ctx, str, leftWidth, initHeight, titleHeight, canvasWidth, unit, lineNum) { + var lineWidth = 0; + var lastSubStrIndex = 0; //每次开始截取的字符串的索引 + var han = 0; + for (let i = 0; i < str.length; i++) { + if(lineNum) { + if(han == lineNum) return; + }; + if (han == 2) return; + //lineWidth += ctx.measureText(str[i]).width; + lineWidth += ut.measureText(str[i], 21.3 * unit); + if (lineWidth > canvasWidth) { + han++; + + if (han == 2 || han == lineNum) + ctx.fillText(str.substring(lastSubStrIndex, i) + '...', leftWidth, initHeight); //绘制截取部分 + else + ctx.fillText(str.substring(lastSubStrIndex, i), leftWidth, initHeight); + + initHeight += 22; //22为字体的高度 + lineWidth = 0; + lastSubStrIndex = i; + titleHeight += 20; + } + if (i == str.length - 1) { //绘制剩余部分 + ctx.fillText(str.substring(lastSubStrIndex, i + 1), leftWidth, initHeight); + } + }; + }, }); diff --git a/app.json b/app.json index 52ba41b..e515f34 100644 --- a/app.json +++ b/app.json @@ -145,7 +145,6 @@ "pages/user/Change_phone/Change_phone", "pages/zuhegou/index/index", "pages/zuhegou/list/list", - "pages/user/binding_info/binding_info", "pages/user/choice_guide/choice_guide", "pages/video/index", "pages/boxes-list/boxes-list", diff --git a/app.wxss b/app.wxss index 3bacdb3..15a67ae 100644 --- a/app.wxss +++ b/app.wxss @@ -742,14 +742,14 @@ background: #ffe3e2; /* 图标字体(ty) */ -@font-face { - font-family: 'iconfont'; /* Project id 2054717 */ - src: url('//at.alicdn.com/t/font_2054717_7asl31h61km.woff2?t=1648457743336') format('woff2'), +/* @font-face { */ + /* font-family: 'iconfont'; */ /* Project id 2054717 */ + /* src: url('//at.alicdn.com/t/font_2054717_7asl31h61km.woff2?t=1648457743336') format('woff2'), url('//at.alicdn.com/t/font_2054717_7asl31h61km.woff?t=1648457743336') format('woff'), url('//at.alicdn.com/t/font_2054717_7asl31h61km.ttf?t=1648457743336') format('truetype'); -} +} */ -.icon-zhibo:before { +/* .icon-zhibo:before { content: "\e623"; } @@ -800,6 +800,69 @@ background: #ffe3e2; font-style: normal; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; +} */ + +@font-face { + font-family: "iconfont"; /* Project id 2054717 */ + src: url('//at.alicdn.com/t/c/font_2054717_k2sfcuqycll.woff2?t=1661217430593') format('woff2'), + url('//at.alicdn.com/t/c/font_2054717_k2sfcuqycll.woff?t=1661217430593') format('woff'), + url('//at.alicdn.com/t/c/font_2054717_k2sfcuqycll.ttf?t=1661217430593') format('truetype'); +} + +.iconfont { + font-family: "iconfont" !important; + font-size: 16px; + font-style: normal; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +.icon-shangjiantou:before { + content: "\e791"; +} + +.icon-zhibo:before { + content: "\e623"; +} + +.icon-dianhua:before { + content: "\e64b"; +} + +.icon-kefu1:before { + content: "\e651"; +} + +.icon-infofill:before { + content: "\e6e6"; +} + +.icon-geren:before { + content: "\e71d"; +} + +.icon-tupian:before { + content: "\e997"; +} + +.icon-wenhao:before { + content: "\e72d"; +} + +.icon-suoxiao:before { + content: "\e7af"; +} + +.icon-yanjing-kai:before { + content: "\e6f9"; +} + +.icon-yanjing-guan:before { + content: "\e6fa"; +} + +.icon-fangda:before { + content: "\e662"; } .icon-checked:before { @@ -826,6 +889,10 @@ background: #ffe3e2; content: "\e6ca"; } +.icon-xingyungou:before { + content: "\e622"; +} + .icon-luck:before { content: "\e621"; } @@ -838,7 +905,6 @@ background: #ffe3e2; content: "\e6b4"; } - .icon-fenlei:before { content: "\e628"; } @@ -846,6 +912,7 @@ background: #ffe3e2; .icon-arrowup:before { content: "\e61e"; } + .icon-aixin:before { content: "\e8c3"; } @@ -878,13 +945,14 @@ background: #ffe3e2; content: "\e614"; } +.icon-erweimafenxiang:before { + content: "\e613"; +} .icon-zhiwen:before { content: "\e6aa"; } - - .icon-guan:before { content: "\e612"; } @@ -897,8 +965,6 @@ background: #ffe3e2; content: "\e611"; } - - .icon-zhuanpan:before { content: "\e642"; } @@ -955,6 +1021,14 @@ background: #ffe3e2; content: "\e61d"; } +.icon-shangjia:before { + content: "\e6e5"; +} + +.icon-xiajia:before { + content: "\e6e4"; +} + .icon-shaixuan:before { content: "\e68a"; } @@ -975,7 +1049,6 @@ background: #ffe3e2; content: "\e638"; } - .icon-sousuo:before { content: "\e618"; } @@ -1016,14 +1089,6 @@ background: #ffe3e2; content: "\e609"; } -.icon-shangjia:before { - content: "\e6e5"; -} - -.icon-xiajia:before { - content: "\e6e4"; -} - .icon-yongjin:before { content: "\e60c"; } @@ -1048,14 +1113,6 @@ background: #ffe3e2; content: "\e65e"; } -.icon-yihexiao:before { - content: "\e726"; -} - -.icon-daihexiao:before { - content: "\e727"; -} - .icon-meirong2:before { content: "\e861"; } @@ -1133,12 +1190,10 @@ background: #ffe3e2; } .icon-arrow_right:before { - /* > */ content: "\e61f"; } .icon-arrow_down:before { - content: "\e600"; } @@ -1148,3 +1203,4 @@ background: #ffe3e2; + diff --git a/components/diy_goodsGroup/diy_goodsGroup.js b/components/diy_goodsGroup/diy_goodsGroup.js index 3bd0a80..980be53 100644 --- a/components/diy_goodsGroup/diy_goodsGroup.js +++ b/components/diy_goodsGroup/diy_goodsGroup.js @@ -139,8 +139,8 @@ Component({ this.data.g_id = nav_item.data; var arr = []; - for (var i = 0; i < this.data.g_id.length; i += this.data.goodscount) { - arr.push(this.data.g_id.slice(i, i + this.data.goodscount)); + for (var i = 0; i < this.data.g_id.length; i += parseInt(this.data.goodscount)) { + arr.push(this.data.g_id.slice(i, i + parseInt(this.data.goodscount))); } this.data.firist_type_data = arr; this.init(this.data.classstyle_id, this.data.wgroup); diff --git a/packageB/pages/user/binding_info/binding_info.js b/packageB/pages/user/binding_info/binding_info.js deleted file mode 100644 index 13d389a..0000000 --- a/packageB/pages/user/binding_info/binding_info.js +++ /dev/null @@ -1,66 +0,0 @@ -// packageB/pages/user/binding_info/binding_info.js -Page({ - - /** - * 页面的初始数据 - */ - data: { - - }, - - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - - }, - - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady: function () { - - }, - - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { - getApp().check_can_share(); - }, - - /** - * 生命周期函数--监听页面隐藏 - */ - onHide: function () { - - }, - - /** - * 生命周期函数--监听页面卸载 - */ - onUnload: function () { - - }, - - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh: function () { - - }, - - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom: function () { - - }, - - /** - * 用户点击右上角分享 - */ - onShareAppMessage: function () { getApp().globalData.no_clear=1 - - } -}) \ No newline at end of file diff --git a/packageB/pages/user/binding_info/binding_info.json b/packageB/pages/user/binding_info/binding_info.json deleted file mode 100644 index 8835af0..0000000 --- a/packageB/pages/user/binding_info/binding_info.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "usingComponents": {} -} \ No newline at end of file diff --git a/packageB/pages/user/binding_info/binding_info.wxml b/packageB/pages/user/binding_info/binding_info.wxml deleted file mode 100644 index 7861b3d..0000000 --- a/packageB/pages/user/binding_info/binding_info.wxml +++ /dev/null @@ -1,2 +0,0 @@ - -packageB/pages/user/binding_info/binding_info.wxml diff --git a/packageB/pages/user/binding_info/binding_info.wxss b/packageB/pages/user/binding_info/binding_info.wxss deleted file mode 100644 index 80927e4..0000000 --- a/packageB/pages/user/binding_info/binding_info.wxss +++ /dev/null @@ -1 +0,0 @@ -/* packageB/pages/user/binding_info/binding_info.wxss */ \ No newline at end of file diff --git a/packageC/pages/luckyGo/luckyGo_cart_ct/luckyGo_cart_ct.js b/packageC/pages/luckyGo/luckyGo_cart_ct/luckyGo_cart_ct.js index a446e4e..791e62c 100644 --- a/packageC/pages/luckyGo/luckyGo_cart_ct/luckyGo_cart_ct.js +++ b/packageC/pages/luckyGo/luckyGo_cart_ct/luckyGo_cart_ct.js @@ -630,7 +630,7 @@ Page({ if (back_data && back_data['is_by_all'] && (!back_data.no_free_goods || back_data.no_free_goods.indexOf(item.goods_id) == -1)) { - if (item['exp_sum_type'] == 2) { + if (item['exp_sum_type'] == 2 && back_data.weight_free > 0) { if (goods_weight < 0) goods_weight = 0; goods_weight += item['weight'] * item['buynum']; cut_good_weight += item['weight'] * item['buynum']; diff --git a/packageC/pages/presell/cart/cart.js b/packageC/pages/presell/cart/cart.js index 4d8c024..445639e 100644 --- a/packageC/pages/presell/cart/cart.js +++ b/packageC/pages/presell/cart/cart.js @@ -1913,7 +1913,7 @@ Page({ if (back_data && back_data['is_by_all'] && (!back_data.no_free_goods || back_data.no_free_goods.indexOf(item.goods_id) == -1)) { - if (item['exp_sum_type'] == 2) { + if (item['exp_sum_type'] == 2 && back_data.weight_free > 0) { if (goods_weight < 0) goods_weight = 0; goods_weight += item['weight'] * item['buynum']; cut_good_weight += item['weight'] * item['buynum']; diff --git a/packageC/pages/presell/cart/cart2.js b/packageC/pages/presell/cart/cart2.js index 0280add..102d2f7 100644 --- a/packageC/pages/presell/cart/cart2.js +++ b/packageC/pages/presell/cart/cart2.js @@ -769,7 +769,7 @@ Page({ if (back_data && back_data['is_by_all'] && (!back_data.no_free_goods || back_data.no_free_goods.indexOf(item.goods_id) == -1)) { - if (item['exp_sum_type'] == 2) { + if (item['exp_sum_type'] == 2 && back_data.weight_free > 0) { if (goods_weight < 0) goods_weight = 0; cut_good_weight += item['weight'] * item['buynum']; goods_weight += item['weight'] * item['buynum']; diff --git a/packageC/pages/presell/cart/cart2_pre.js b/packageC/pages/presell/cart/cart2_pre.js index 8c92d21..e9b2809 100644 --- a/packageC/pages/presell/cart/cart2_pre.js +++ b/packageC/pages/presell/cart/cart2_pre.js @@ -391,7 +391,7 @@ Page({ let item = data[i]; if (back_data && back_data['is_by_all'] && (!back_data.no_free_goods || back_data.no_free_goods.indexOf(item.goods_id) == -1)) { - if (item['exp_sum_type'] == 2) { + if (item['exp_sum_type'] == 2 && back_data.weight_free > 0) { goods_weight += item['weight'] * item['buynum']; cut_good_weight += item['weight'] * item['buynum']; } diff --git a/packageC/pages/presell/cart/juchi_part.wxml b/packageC/pages/presell/cart/juchi_part.wxml index 8dcad6b..ff4271b 100644 --- a/packageC/pages/presell/cart/juchi_part.wxml +++ b/packageC/pages/presell/cart/juchi_part.wxml @@ -1,23 +1,4 @@ - - - - - - - - - - - - - - - - - - - - + \ No newline at end of file diff --git a/pages/cart/cart2/cart2.js b/pages/cart/cart2/cart2.js index 42b4f98..0baf088 100644 --- a/pages/cart/cart2/cart2.js +++ b/pages/cart/cart2/cart2.js @@ -2007,7 +2007,7 @@ Page({ if (back_data && back_data['is_by_all'] && (!back_data.no_free_goods || back_data.no_free_goods.indexOf(item[j].goods_id) == -1)) { - if (item[j]['exp_sum_type'] == 2) { + if (item[j]['exp_sum_type'] == 2 && back_data.weight_free>0) { if (goods_weight < 0) goods_weight = 0; cut_good_weight += item[j]['weight'] * item[j]['goods_num']; goods_weight += item[j]['weight'] * item[j]['goods_num']; @@ -2533,7 +2533,7 @@ Page({ if (back_data && back_data['is_by_all'] && (!back_data.no_free_goods || back_data.no_free_goods.indexOf(item.goods_id) == -1)) { - if (item['exp_sum_type'] == 2) { + if (item['exp_sum_type'] == 2 && back_data.weight_free>0) { if (goods_weight < 0) goods_weight = 0; goods_weight += item['weight'] * item['buynum']; cut_good_weight += item['weight'] * item['buynum']; @@ -2565,7 +2565,7 @@ Page({ case 3: if (goods_piece < 0) goods_piece = 0; //累积商品数量 - goods_piece += item['buynum']; + goods_piece += parseInt(item['buynum']) ; break; } } diff --git a/pages/cart/cart2/juchi_part.wxml b/pages/cart/cart2/juchi_part.wxml index 8dcad6b..ff4271b 100644 --- a/pages/cart/cart2/juchi_part.wxml +++ b/pages/cart/cart2/juchi_part.wxml @@ -1,23 +1,4 @@ - - - - - - - - - - - - - - - - - - - - + \ No newline at end of file diff --git a/pages/cart/cart2_inte/cart2_inte.js b/pages/cart/cart2_inte/cart2_inte.js index c72737e..8148f77 100644 --- a/pages/cart/cart2_inte/cart2_inte.js +++ b/pages/cart/cart2_inte/cart2_inte.js @@ -525,7 +525,7 @@ Page({ if (back_data && back_data['is_by_all'] && (!back_data.no_free_goods || back_data.no_free_goods.indexOf(item.goods_id) == -1) ) { - if (item['exp_sum_type'] == 2) { + if (item['exp_sum_type'] == 2 && back_data.weight_free > 0) { if (goods_weight < 0) goods_weight = 0; goods_weight += item['weight'] * item['buynum']; cut_good_weight += item['weight'] * item['buynum']; diff --git a/pages/cart/cart2_pt/cart2_pt.js b/pages/cart/cart2_pt/cart2_pt.js index 9faac8c..145b114 100644 --- a/pages/cart/cart2_pt/cart2_pt.js +++ b/pages/cart/cart2_pt/cart2_pt.js @@ -553,7 +553,7 @@ Page({ if (back_data && back_data['is_by_all'] && (!back_data.no_free_goods || back_data.no_free_goods.indexOf(item.goods_id) == -1)) { - if (item['exp_sum_type'] == 2) { + if (item['exp_sum_type'] == 2 && back_data.weight_free > 0) { if (goods_weight < 0) goods_weight = 0; cut_good_weight += item['weight'] * item['buynum']; goods_weight += item['weight'] * item['buynum']; diff --git a/pages/cart/cart_wk/cart_wk.js b/pages/cart/cart_wk/cart_wk.js index 07a1950..ddca7b3 100644 --- a/pages/cart/cart_wk/cart_wk.js +++ b/pages/cart/cart_wk/cart_wk.js @@ -625,7 +625,7 @@ Page({ if (back_data && back_data['is_by_all'] && (!back_data.no_free_goods || back_data.no_free_goods.indexOf(item.goods_id) == -1)) { - if (item['exp_sum_type'] == 2) { + if (item['exp_sum_type'] == 2 && back_data.weight_free > 0) { if (goods_weight < 0) goods_weight = 0; goods_weight += item['weight'] * item['buynum']; cut_good_weight += item['weight'] * item['buynum']; diff --git a/pages/giftpack/giftpacklist/giftpacklist.js b/pages/giftpack/giftpacklist/giftpacklist.js index ab9c63d..e2f275f 100644 --- a/pages/giftpack/giftpacklist/giftpacklist.js +++ b/pages/giftpack/giftpacklist/giftpacklist.js @@ -1,608 +1,636 @@ var e = getApp(), - a = e.globalData.setting, - os = a, - t = e.request, - d = e.globalData; + a = e.globalData.setting, + os = a, + t = e.request, + d = e.globalData; var ut = require("../../../utils/util.js"); var com = require("../public/buy_com.js"); Page({ - data: { - url: a.url, //接口网址 - iurl: a.imghost, //图片前缀网址 - isBuy: 0, - getGiftID: '', //礼包id - giftImage: '', - giftTitle: '', - giftDate: '', - giftPrice: '', - giftIntegral: '', - giftPosPrice: '', - giftQty: '', - giftRemark: '', - giftType: '', - actTitle: '', - getUrl: '', - wareCard: [], - orderSn: "", //订单编号 - lbId: "", - code: "", //核销码 - c_state: "0", //判断是否已经使用, 0正常 1已使用 2已过期 - is_lb: 0, //是否有礼包 - default_color: null, - first_leader: e.globalData.first_leader || 0, // 推荐人ID - - //门店相关 - ismend: 0, - is_sec_mend: 0, - sto_sele_name: "", //选中的门店名称 - sto_sele_id: "", //选中的门店id - sto_sele_distr: "", //选择的门店的配送方式 - is_show_sto_cat: 1, //是否显示门店分类 - only_pk: null, - all_sto: null, - sec_sto: null, //选择了的门店分类 - pickpu_list: null, //读出的所有门店list - def_pickpu_list: null, //一开始5个门店list - sec_pick_index: 0, //第二级门店选择ID - fir_pick_index: 0, //第一级门店选择ID - all_pick_list: null,//所有的门店先记录起来 - - select_store: 0, //选择更多 - index: 1, - more_store: 0, //选择门店 - sort_store: 0, //门店分类 - choice_sort_store: 0, //选择分类门店 - new_user: 0, //新用户 - - def_pick_store: null, // 默认的门店 - fir_def_store: null, //客户默认的门店的 - lat: null, //维度 - lon: null, //经度 - - is_get_local_ok: 0, //获取坐标是否完成 - region_name: "门店分类", //区域的名字 - is_gps: 1, - open_ind_store: 0, //哪里打开的门店列表的控制属性 - default_store: {}, //创建添加默认门店地址的对象 - - store:0, - openSpecModal:0 - }, - onLoad: function (options) { - - var th=this; - - this.setData({ - params:options, - }) - - getApp().getConfig2(function (e) { - var json_d = JSON.parse(e.switch_list); - th.setData({ - bconfig: e, - sys_switch:json_d - }); - }) - }, - init(){ - let options = this.data?.params; // this.data == null ? undefined:this.data.params - var th = this; - this.setData({ - getUserID: d.user_id, - getStorageID: a.stoid, - }) - this.setData({ - isBuy: options.isBuy, - getGiftID: options.lbId, - orderSn: options.orderSn, - flag: options.flag, // 如果从商品详情页的促销处点击专享礼包跳转到此页,则flag为1 - }) - if (options.lbId) th.data.lbId = options.lbId; - //-- 获取分享人的ID -- - var first_leader = options.first_leader || getApp().globalData.first_leader; - if (first_leader) { - this.setData({ - first_leader, - }) - //-- user_id代过来免登录 -- - getApp().globalData.first_leader = first_leader; - //调用接口判断是不是会员 - getApp().request.promiseGet("/api/weshop/shoppingGuide/get/" + os.stoid + "/" + first_leader, {}).then(res => { - if (res.data.code == 0) { - getApp().globalData.guide_id = res.data.data.id; - } - }) - } - th.close(); - - - if(this.data.flag == 1) { - this.getZxlbDetails(); - } else { - if (this.data.isBuy == 0) { - this.GetMyGiftList(); - } else if (this.data.isBuy == 1) { - this.GetBuyGiftList(); - }; - }; - }, - - onShow: function () { - getApp().check_can_share(); - 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.init(); - }) - }, - GetBuyPrice: function (e) { - var that = this.data; - var th = this; - //如果还没有开始的话 - if (th.data.isStart != 1) { - getApp().my_warnning("活动还没有开始", 0, th); - return false; - } - - this.data.payMoney=th.data.sele_g.payMoney; - th.setData({ buyType:2 }) - if(th.data.sele_g.is_pickup){ - th.setData({ - openSpecModal:1 + data: { + url: a.url, //接口网址 + iurl: a.imghost, //图片前缀网址 + isBuy: 0, + getGiftID: '', //礼包id + giftImage: '', + giftTitle: '', + giftDate: '', + giftPrice: '', + giftIntegral: '', + giftPosPrice: '', + giftQty: '', + giftRemark: '', + giftType: '', + actTitle: '', + getUrl: '', + wareCard: [], + orderSn: "", //订单编号 + lbId: "", + code: "", //核销码 + c_state: "0", //判断是否已经使用, 0正常 1已使用 2已过期 + is_lb: 0, //是否有礼包 + default_color: null, + first_leader: e.globalData.first_leader || 0, // 推荐人ID + + //门店相关 + ismend: 0, + is_sec_mend: 0, + sto_sele_name: "", //选中的门店名称 + sto_sele_id: "", //选中的门店id + sto_sele_distr: "", //选择的门店的配送方式 + is_show_sto_cat: 1, //是否显示门店分类 + only_pk: null, + all_sto: null, + sec_sto: null, //选择了的门店分类 + pickpu_list: null, //读出的所有门店list + def_pickpu_list: null, //一开始5个门店list + sec_pick_index: 0, //第二级门店选择ID + fir_pick_index: 0, //第一级门店选择ID + all_pick_list: null,//所有的门店先记录起来 + + select_store: 0, //选择更多 + index: 1, + more_store: 0, //选择门店 + sort_store: 0, //门店分类 + choice_sort_store: 0, //选择分类门店 + new_user: 0, //新用户 + + def_pick_store: null, // 默认的门店 + fir_def_store: null, //客户默认的门店的 + lat: null, //维度 + lon: null, //经度 + + is_get_local_ok: 0, //获取坐标是否完成 + region_name: "门店分类", //区域的名字 + is_gps: 1, + open_ind_store: 0, //哪里打开的门店列表的控制属性 + default_store: {}, //创建添加默认门店地址的对象 + + store: 0, + openSpecModal: 0, + + sto_sele_name_1: '', + share_goods_img:'', //礼包的分享图 + canvasHidden:true, + + screenWidth: 0 + }, + onLoad: function (options) { + + var th = this; + + this.setData({ + params: options, }) - }else{ - var my_confirm = th.selectComponent("#my_confirm"); //组件的id - my_confirm.open( - "是否确定购买该礼包", - "取消", - "确定", - function () { - my_confirm.open_cancel(0); - }, - function () { - my_confirm.open_cancel(0); - com.buy_libao(th) - } - ) - } + getApp().getConfig(function (e) { + th.setData({sto_sele_name_1: e.store_name}) + }) + getApp().getConfig2(function (e) { + var json_d = JSON.parse(e.switch_list); + th.setData({ + bconfig: e, + sys_switch: json_d + }); + }) + //获取用户设备信息,屏幕宽度 + wx.getSystemInfo({ + success: res => { + th.setData({ + screenWidth: res.screenWidth + }) + } + }); + }, + init() { + let options = this.data?.params; // this.data == null ? undefined:this.data.params + var th = this; + this.setData({ + getUserID: d.user_id, + getStorageID: a.stoid, + }) - }, - GetBuyIntegral: function (e) { - var that = this.data; - var th = this; + if(!options.lbId && options.scene){ + var gid_str = decodeURIComponent(options.scene); + gid_str = gid_str.split("_"); - //如果还没有开始的话 - if (th.data.isStart != 1) { - getApp().my_warnning("活动还没有开始", 0, th); - return false; - } + options.lbId=gid_str[0]; + options.first_leader=gid_str[1]; + options.isBuy=1; + } - th.setData({ buyType:1 }); - if(th.data.sele_g.is_pickup){ - th.setData({ - openSpecModal:1 + + this.setData({ + isBuy: options.isBuy, + getGiftID: options.lbId, + orderSn: options.orderSn, + flag: options.flag, // 如果从商品详情页的促销处点击专享礼包跳转到此页,则flag为1 }) - }else { - var my_confirm = th.selectComponent("#my_confirm"); //组件的id - my_confirm.open( - "是否确定兑换该礼包", - "取消", - "确定", - function () { - my_confirm.open_cancel(0); - }, - function () { - my_confirm.open_cancel(0); - com.buy_libao(th) - }) - } - - - - - }, - - GetMyGiftList: function () { - var _this = this; - var th = this; - getApp().request.get('/api/weshop/marketing/my/giftbag/detail/get', { - isShowLoading: true, - data: { - "storeId": a.stoid, //商家ID - "userId": d.user_id, //用户ID - "orderSn": th.data.orderSn - }, - success: function (res) { - if (res.data.code == 0) { - th.setData({ - giftImage: th.data.iurl + res.data.data.lbUrl, - giftTitle: res.data.data.giftTitle, - default_color: res.data.data.bgcolor - }) - - if(res.data.data.iswarelbtype==1) { - th.setData({iswarelbtype:1}) - } - - if (!res.data.data.giftRemark || res.data.data.giftRemark == '') { - th.setData({ - giftRemark: '暂无详情......' + if (options.lbId) th.data.lbId = options.lbId; + //-- 获取分享人的ID -- + var first_leader = options.first_leader || getApp().globalData.first_leader; + if (first_leader) { + this.setData({ + first_leader, }) - } else { - th.setData({ - giftRemark: res.data.data.giftRemark.replace(/\ { + if (res.data.code == 0) { + getApp().globalData.guide_id = res.data.data.id; + } }) - } - - //---获取日期的时间戳--- - var t_endtime = res.data.data.endTime; - t_endtime = t_endtime.replace(/-/g, '/'); - var t_date = new Date(t_endtime) / 1000; - var t_now = ut.gettimestamp(); - - var t_starttime = res.data.data.starTime; - t_starttime = t_starttime.replace(/-/g, '/'); - var t_sdate = new Date(t_starttime) / 1000; - - if (res.data.data.goodsUseState) th.setData({ - c_state: 1 - }) - else if (t_date <= t_now) + } + th.close(); + + + if (this.data.flag == 1) { + this.getZxlbDetails(); + } else { + if (this.data.isBuy == 0) { + this.GetMyGiftList(); + } else if (this.data.isBuy == 1) { + this.GetBuyGiftList(); + } + + } + + }, + + onShow: function () { + getApp().check_can_share(); + 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.init(); + }) + }, + GetBuyPrice: function (e) { + var that = this.data; + var th = this; + //如果还没有开始的话 + if (th.data.isStart != 1) { + getApp().my_warnning("活动还没有开始", 0, th); + return false; + } + + this.data.payMoney = th.data.sele_g.payMoney; + th.setData({buyType: 2}) + if (th.data.sele_g.is_pickup) { th.setData({ - c_state: 2 + openSpecModal: 1 }) - else if (t_sdate > t_now) + } else { + var my_confirm = th.selectComponent("#my_confirm"); //组件的id + my_confirm.open( + "是否确定购买该礼包", + "取消", + "确定", + function () { + my_confirm.open_cancel(0); + }, + function () { + my_confirm.open_cancel(0); + com.buy_libao(th) + } + ) + } + + + }, + GetBuyIntegral: function (e) { + var that = this.data; + var th = this; + + //如果还没有开始的话 + if (th.data.isStart != 1) { + getApp().my_warnning("活动还没有开始", 0, th); + return false; + } + + th.setData({buyType: 1}); + if (th.data.sele_g.is_pickup) { th.setData({ - c_state: -1 + openSpecModal: 1 }) - th.setData({ - giftDate: res.data.data.endTime, - giftPosPrice: res.data.data.giftPosPrice, - giftQty: res.data.data.giftQty, - giftIntegral: res.data.data.payIntegral, - giftPrice: res.data.data.payMoney, - giftType: res.data.data.actType, - actTitle: res.data.data.actTitle, - wareCard: res.data.data.wareCard, - lbId: res.data.data.lbId - }) - //判断是否有礼包 - for (var i = 0; i < res.data.data.wareCard.length; i++) { - if (res.data.data.wareCard[i].lbType == 1) { - th.setData({ - is_lb: 1 - }) - break; + } else { + var my_confirm = th.selectComponent("#my_confirm"); //组件的id + my_confirm.open( + "是否确定兑换该礼包", + "取消", + "确定", + function () { + my_confirm.open_cancel(0); + }, + function () { + my_confirm.open_cancel(0); + com.buy_libao(th) + }) + } + + + }, + + GetMyGiftList: function () { + var _this = this; + var th = this; + getApp().request.get('/api/weshop/marketing/my/giftbag/detail/get', { + isShowLoading: true, + data: { + "storeId": a.stoid, //商家ID + "userId": d.user_id, //用户ID + "orderSn": th.data.orderSn + }, + success: function (res) { + if (res.data.code == 0) { + th.setData({ + giftImage: th.data.iurl + res.data.data.lbUrl, + giftTitle: res.data.data.giftTitle, + default_color: res.data.data.bgcolor + }) + + if (res.data.data.iswarelbtype == 1) { + th.setData({iswarelbtype: 1}) + } + + if (!res.data.data.giftRemark || res.data.data.giftRemark == '') { + th.setData({ + giftRemark: '暂无详情......' + }) + } else { + th.setData({ + giftRemark: res.data.data.giftRemark.replace(/\ t_now) + th.setData({ + c_state: -1 + }) + th.setData({ + giftDate: res.data.data.endTime, + giftPosPrice: res.data.data.giftPosPrice, + giftQty: res.data.data.giftQty, + giftIntegral: res.data.data.payIntegral, + giftPrice: res.data.data.payMoney, + giftType: res.data.data.actType, + actTitle: res.data.data.actTitle, + wareCard: res.data.data.wareCard, + lbId: res.data.data.lbId + }) + //判断是否有礼包 + for (var i = 0; i < res.data.data.wareCard.length; i++) { + if (res.data.data.wareCard[i].lbType == 1) { + th.setData({ + is_lb: 1 + }) + break; + } + } + + if (res.data.data.pickup_id) { + getApp().request.get("/api/weshop/pickup/get/" + os.stoid + "/" + res.data.data.pickup_id, { + success: function (res) { + if (res.data.code == 0) { + th.setData({pick_up: res.data.data}); + } + } + }); + + } + + + } else { + getApp().my_warnning(res.data.msg, 0, th); + return false; + } } - } + }); - if(res.data.data.pickup_id){ - getApp().request.get("/api/weshop/pickup/get/"+os.stoid+"/"+res.data.data.pickup_id,{ - success: function (res) { - if(res.data.code==0){ - th.setData({pick_up:res.data.data}); - } - } - }); + }, + GetBuyGiftList: function () { + var _this2 = this; + var th = this.data; + getApp().request.get('/api/weshop/marketing/giftbag/detail/get', { + isShowLoading: true, + data: { + "storeId": a.stoid, //商家ID + "userId": d.user_id, //用户ID + "giftBagId": th.getGiftID + }, + success: function success(res) { + if (res.data.code == 0) { + _this2.setData({ + giftImage: th.iurl + res.data.data.lbUrl, + giftTitle: res.data.data.giftTitle, + default_color: res.data.data.bgcolor + }) + if (res.data.data.giftRemark == '') { + _this2.setData({ + giftRemark: '暂无详情......' + }) + } else { + _this2.setData({ + giftRemark: res.data.data.giftRemark.replace(/\ 0) { + scene += "_" + user_id; + } + ///二微码 + var path3 = os.url + "/api/wx/open/app/user/getWeAppEwm/" + + os.stoid + "?sceneValue=" + scene + "&pageValue=pages/giftpack/giftpacklist/giftpacklist"; + + console.log("11111"); + console.log(path3); + + // 读取文件成功则OK-- + wx.getImageInfo({ + src: path3, + success: function (res) { + th.get_goods_temp(function () { + var vpath = res.path; + var context = wx.createCanvasContext('share'); + th.drawPoster(context, unit, th.data.share_goods_img, vpath, 0); + + //把画板内容绘制成图片,并回调 画板图片路径 + context.draw(false, function () { + setTimeout(function () { + wx.canvasToTempFilePath({ + x: 0, + y: 0, + width: 750, + height: 1217, + destWidth: 1.2 * 750 * 750 / that.data.screenWidth, + destHeight: 1.2 * 1217 * 750 / that.data.screenWidth, + canvasId: 'share', + success: function (res) { + + + console.log(res.tempFilePath) + + that.setData({ + shareImgPath: res.tempFilePath, + canvasHidden: true + }) + + if (!res.tempFilePath) { + wx.showModal({ + title: '提示', + content: '图片绘制中,请稍后重试', + showCancel: false + }) + return false; + } + + that.setData({ + showPoster: true, + }); + wx.hideLoading(); + } + }) + }, 800) + + }); + }) + }, + fail: function (res) { + console.log(res); + wx.hideLoading(); + + } + }); + }, + + //-- 小程序绘制海报 -- + drawPoster(context, unit, img, vpath, type) { + // 1.灰色背景 + context.setFillStyle('#f2f1f6'); + context.rect(0, 0, 554 * unit, 899 * unit); + context.fill(); + + // 2.商城名称 + let shopName = this.data.sto_sele_name_1; + context.setTextAlign('center'); + context.setFontSize(26 * unit); + context.setFillStyle('black'); + context.fillText(shopName, 277 * unit, 60 * unit); + + // 3.推荐来源 + let fromText = `来自${getApp().globalData.userInfo.nickname}的推荐`; + context.setTextAlign('center'); + context.setFontSize(22 * unit); + context.setFillStyle('#96959a'); + context.fillText(fromText, 277 * unit, 105 * unit); + + // 4.海报背景 + context.setFillStyle('white'); + context.fillRect(37 * unit, 157 * unit, 480 * unit, 673 * unit); + + // 5.商品图片 + // 图片的x坐标 + let bg_x = 37 * unit + // 图片的y坐标 + let bg_y = 157 * unit + // 图片宽度 + let bg_w = 480 * unit + // 图片高度 + let bg_h = 474 * unit + // 图片圆角 + let bg_r = 4 + // 绘制海报背景图片圆角 + context.save() + context.beginPath() + context.arc(bg_x + bg_r, bg_y + bg_r, bg_r, Math.PI, Math.PI * 1.5) + context.arc(bg_x + bg_w - bg_r, bg_y + bg_r, bg_r, Math.PI * 1.5, Math.PI * 2) + context.arc(bg_x + bg_w, bg_y + bg_h, bg_r, 0, Math.PI * 0.5) + context.arc(bg_x, bg_y + bg_h, 0, Math.PI * 0.5, Math.PI) + context.clip() + context.drawImage(img, bg_x, bg_y, bg_w, bg_h); + context.restore(); + + // 6.强烈推荐 + let src = ''; + context.beginPath(); + if (type == 0) { // 普通 + src = '../../../images/share/q_tj.png'; + context.drawImage(src, 54 * unit, 648 * unit, 85 * unit, 30 * unit); + context.setFontSize(16 * unit) + context.setFillStyle("white") + context.setTextAlign('left'); + context.fillText('强烈推荐', 64 * unit, 668 * unit); + } + + + let price = this.data.giftPrice; + let giftIntegral = this.data.giftIntegral; + context.setFontSize(32 * unit); + context.setFillStyle('#DE1117'); + + var price_txt=""; + if(price || giftIntegral){ + if(price){ + price_txt='¥' + price; + if(giftIntegral) price_txt+='+'; + } + if(giftIntegral) price_txt+=giftIntegral+'积分'; + }else{ + price_txt="¥0"; + } + + context.fillText(price_txt, 54 * unit, 735 * unit); + + + // 8.商品标题 + context.setFontSize(20 * unit); + context.setFillStyle('#898989'); + getApp().draw_Text(context, this.data.giftTitle, 54 * unit, 800 * unit, 240 * unit, 280 * unit, unit, 1); + + // 9.小程序码 + context.drawImage(vpath, 375 * unit, 660 * unit, 120 * unit, 120 * unit); + context.setFontSize(16 * unit); + context.setFillStyle('#777'); + context.fillText('长按识别二维码', 378 * unit, 810 * unit); + + // 10.竖线 + context.beginPath(); + context.setFillStyle('#eee'); + context.rect(354 * unit, 670 * unit, 1 * unit, 130 * unit); + context.fill(); + }, + + //--获取商品图片的本地缓存,回调写法-- + get_goods_temp: function (tt) { + var ee = this; + if (ee.data.share_goods_img) { + tt(); + return false; + } + var img_url = ee.data.giftImage; + //获取商品是分享图信息 + wx.getImageInfo({ + src: img_url, + success: function (res) { + //res.path是网络图片的本地地址 + ee.data.share_goods_img = res.path; + tt(); + }, + fail: function (res) { + ee.data.share_goods_img = "../../../images/share/default_g_img.gif"; //分享的图片不能用网络的 + tt(); + } + }); + }, + + closePoster() { + this.setData({ + showPoster: false, + }); + }, + // 保存图片到手机 + savePic() { + getApp().savePic(this); + }, + // 预览海报 + previewPoster() { + getApp().globalData.no_clear=1; + wx.previewImage({ + current: this.data.shareImgPath, // 当前显示图片的http链接 + urls: [this.data.shareImgPath] ,// 需要预览的图片http链接列表 + }); + }, diff --git a/pages/giftpack/giftpacklist/giftpacklist.json b/pages/giftpack/giftpacklist/giftpacklist.json index a97fd58..0841c16 100644 --- a/pages/giftpack/giftpacklist/giftpacklist.json +++ b/pages/giftpack/giftpacklist/giftpacklist.json @@ -4,6 +4,7 @@ "warn": "/components/long_warn/long_warn", "my_confirm": "/components/my_confirm/my_confirm", "qr_code": "/components/qr_code/qr_code", - "nav_b": "/components/nav_b/nav_b" + "nav_b": "/components/nav_b/nav_b", + "share": "/components/share/share" } } \ No newline at end of file diff --git a/pages/giftpack/giftpacklist/giftpacklist.wxml b/pages/giftpack/giftpacklist/giftpacklist.wxml index 4e9be14..504c821 100644 --- a/pages/giftpack/giftpacklist/giftpacklist.wxml +++ b/pages/giftpack/giftpacklist/giftpacklist.wxml @@ -9,7 +9,15 @@ - {{giftTitle}} + {{giftTitle}} + + + + + 分享 + + + @@ -17,6 +25,7 @@ {{"活动开始时间:"+giftStart}} + {{"兑换结束时间:"+giftDate}} @@ -34,6 +43,8 @@ + + {{"¥"+giftPrice}} @@ -46,6 +57,10 @@ {{actTitle}} + + + + @@ -209,4 +224,26 @@ - \ No newline at end of file + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/pages/giftpack/giftpacklist/giftpacklist.wxss b/pages/giftpack/giftpacklist/giftpacklist.wxss index 9fb4397..2e26421 100644 --- a/pages/giftpack/giftpacklist/giftpacklist.wxss +++ b/pages/giftpack/giftpacklist/giftpacklist.wxss @@ -26,6 +26,7 @@ .top_title.data-v-3a5b7e36 { font-size: 30rpx; margin-bottom: 10rpx; + position: relative; } .top_time.data-v-3a5b7e36 { @@ -38,6 +39,7 @@ color: #d61b30; margin-top: 30rpx; margin-bottom: 5rpx; + position: relative; } .top_foot.data-v-3a5b7e36 { @@ -244,3 +246,7 @@ page.data-v-3a5b7e36 { .foot_button_intalge.data-v-3a5b7e36.gray{ background-color: #aaa; } +.xc-share-frame { + position: absolute; right:0; top: -10rpx; +} + diff --git a/pages/goods/goodsInfo/buy_pt.wxml b/pages/goods/goodsInfo/buy_pt.wxml index 2de1ba1..c12dd00 100644 --- a/pages/goods/goodsInfo/buy_pt.wxml +++ b/pages/goods/goodsInfo/buy_pt.wxml @@ -98,16 +98,6 @@ - - - - - - - - - -