From 72d65e45871dad51ee380b8252f05118f2eadf77 Mon Sep 17 00:00:00 2001 From: yvan.ni <765199919@qq.com> Date: Sat, 2 Nov 2019 09:20:59 +0800 Subject: [PATCH] 等级卡购买,等级卡分享 的购买流程实现 --- pages/getphone/getphone.js | 15 ++++++++++++--- pages/user/index/index.js | 61 +++++++++++++++++++++++++++++++++++-------------------------- pages/user/index/index.wxml | 10 +++++----- pages/user/index/index.wxss | 4 ++-- pages/user/plus/plus.js | 599 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- pages/user/plus/plus.json | 5 +++-- pages/user/plus/plus.wxml | 93 ++++++++++++++------------------------------------------------------------------------------- pages/user/plus/plus.wxss | 5 +++-- utils/pay2.js | 40 ++++++++++++++++++++++++++++++++++++++++ 9 files changed, 331 insertions(+), 501 deletions(-) create mode 100644 utils/pay2.js diff --git a/pages/getphone/getphone.js b/pages/getphone/getphone.js index bd9b15e..6896cac 100644 --- a/pages/getphone/getphone.js +++ b/pages/getphone/getphone.js @@ -4,6 +4,13 @@ Page({ store:null, imghots: os.imghost, }, + + onLoad: function (options) { + //--判断是否有接受到邀请人的ID-- + if(options.first_leader){ + this.setData({first_leader:options.first_leader}); + } + }, onShow:function(){ var th=this,app = getApp(); var sessionKey = getApp().globalData.sessionKey; @@ -16,11 +23,8 @@ Page({ wx.navigateTo({ url: '/pages/togoin/togoin', }) return false; } - var user_info=getApp().globalData.userInfo; - console.log("getphone"); - console.log(user_info); if(user_info!=null && user_info.mobile!=undefined && user_info.mobile!="" && user_info.mobile!=null){ wx.navigateBack({ @@ -72,6 +76,11 @@ Page({ iv: e.iv, store_id: getApp().globalData.setting.stoid, }; + //--如果有邀请人的时候-- + if(th.data.first_leader){ + dd.first_leader=th.data.first_leader; + } + console.log(dd); app.request.get("/api/weshop/users/thirdLogin", { data: dd, diff --git a/pages/user/index/index.js b/pages/user/index/index.js index 5e32622..6d28ef2 100644 --- a/pages/user/index/index.js +++ b/pages/user/index/index.js @@ -12,25 +12,26 @@ Page({ * 页面的初始数据 */ data: { - length:150, - iurl: s.imghost, - defaultAvatar:s.imghost+"/miniapp/images/no-head.jpg", - userInfo:null, - toji:null, //统计相关 - txmon:0, - byquan: 0, - yuer: 0, - - currentPage:1, - recommend_list:[], - tc_hide: true, - sw_index:0, - qy_list:null, - gradeId:null, - is_init:0, - - cz_val:0, - full_cz_val:0, + length:150, + iurl: s.imghost, + defaultAvatar:s.imghost+"/miniapp/images/no-head.jpg", + userInfo:null, + toji:null, //统计相关 + txmon:0, + byquan: 0, + yuer: 0, + + currentPage:1, + recommend_list:[], + tc_hide: true, + sw_index:0, + qy_list:null, + gradeId:null, + is_init:0, + + cz_val:0, + full_cz_val:0, + is_dengji:0, //是不是等级 }, /** @@ -186,16 +187,24 @@ Page({ /*-- 获取 --*/ th.requestRecommend(); + + /*-------系统是否开通等级卡,会员是等级卡-----*/ + getApp().getConfig2(function (e) { + var t_swi=e.switch_list; + if(t_swi) t_swi=JSON.parse(t_swi) + if(parseInt(t_swi.rank_switch)==2){ + var userInfo=th.data.userInfo; + if(userInfo.card_field!=null && userInfo.card_field!=undefined && userInfo.card_field!="" ){ + th.setData({is_dengji:1}) + }else{ + th.setData({is_dengji:2}) + } + } + }) + } }); - /*-------系统是否开通等级卡,会员是等级卡-----*/ - getApp().getConfig2(function (e) { - var t_swi=e.switch_list; - if(t_swi) t_swi=JSON.parse(t_swi) - if(t_swi.rank_switch==2){ - } - }) }, //判断会员是后有改服务项目 diff --git a/pages/user/index/index.wxml b/pages/user/index/index.wxml index 77ee902..4a407f1 100644 --- a/pages/user/index/index.wxml +++ b/pages/user/index/index.wxml @@ -63,11 +63,11 @@ - + - 加入会员 - 预计可省345元 + 加入plus会员 + 预计可省3031元 立即开通 @@ -180,9 +180,9 @@ 联系客服 - + - 等级会员 + plus会员 diff --git a/pages/user/index/index.wxss b/pages/user/index/index.wxss index 15ef3d5..8f09d15 100644 --- a/pages/user/index/index.wxss +++ b/pages/user/index/index.wxss @@ -156,7 +156,7 @@ height: 84rpx; .xc-add-member .xc-icon{ width: 30rpx; height: 30rpx; - margin-left:50rpx; + margin-left:40rpx; } .xc-add-member .member{ @@ -172,7 +172,7 @@ height: 84rpx; .xc-add-member .xc-opening-button{ width: 120rpx; - margin-left:180rpx; + margin-left:140rpx; } .xc-opening{ diff --git a/pages/user/plus/plus.js b/pages/user/plus/plus.js index 5455892..aec9b0e 100644 --- a/pages/user/plus/plus.js +++ b/pages/user/plus/plus.js @@ -1,27 +1,18 @@ -var e = function(e) { - return e && e.__esModule ? e : { - default: e - }; - }(require("../../../utils/LoadMore.js")), - t = getApp(), +var t = getApp(), a = t.request, o = t.globalData.setting, os = o, i = require("../../../utils/util.js"), ut = i, s = require("../../../utils/common.js"), - w = require("../../../utils/wxParse/wxParse.js"), - n = new e.default(); -var regeneratorRuntime = require('../../../utils/runtime.js'); -var api = require('../../../api/api.js'); -//wx.downloadFile把线上地址设为本地地址 -Page({ + w = require("../../../utils/wxParse/wxParse.js"),t_pay = require("../../../utils/pay2.js"); + var regeneratorRuntime = require('../../../utils/runtime.js'); +Page({ /** * 页面的初始数据 */ data: { - images: [o.imghost + "/miniapp/images/plus/card_one.jpg", o.imghost + "/miniapp/images/plus/card_two.jpg", o.imghost + "/miniapp/images/plus/card_three.jpg"], currentId: 0, url: o.imghost, screenWidth: 0, @@ -31,422 +22,266 @@ Page({ is_plusCard: "",//卡的列表 imagePath: "", is_pulscardname: "",//plus会员的名字 - is_card:0,//用于判断是否是续费页和购买页面 0不是puls会员 - content:"",//等级卡规则 + is_card: 0,//用于判断是否是续费页和购买页面 0不是puls会员 + content: "",//等级卡规则 is_card_rule: "",//等级卡规则判断用 + is_show: 0, //页面要加载完才能显示 + open_yq: 0, //显示打开邀请码的弹窗 + by_index:null, //购买卡的下班 + + isyaoqingma:0, //是否邀请码 + is_salesman:0, //是否营业员 + inp_recommon: null, //输入的邀请码 + inp_serviceman: null, //输入的营业员 + is_fengxiang: 0, //是不是分享过来的 + def_recommon: null, //分享人的手机号 + def_serviceman: null, //分享人的营业员 + fir_leader:0, + }, - swiperChange: function(e) { + swiperChange: function (e) { var currentId = e.detail.current; this.setData({ currentId: currentId }) - }, /** * 生命周期函数--监听页面加载 */ - onLoad: function(options) { - console.log(111); - var that = this; - getApp().request.get("/api/weshop/users/get/" + os.stoid + "/" + getApp().globalData.user_id, { - success: function (res) { - var user_information=res.data.data; - console.log(res, "会员个人信息"); - //判断是是不是会员 - if (user_information == null || user_information == ""){ - - } - //判断是是不是plus会员 - if (user_information.card_field == null || user_information.card_fiel == "") { - that.setData({ is_card:1}); - - } - if (user_information.card_expiredate == null || user_information.card_expiredate == ""){ - - } - - } - }); - - - + onLoad: function (options) { + var that = this; + var store_id=getApp().globalData.setting.stoid; //获取用户设备信息,屏幕宽度 wx.getSystemInfo({ success: res => { - that.setData({ - screenWidth: res.screenWidth - }) + that.setData({screenWidth: res.screenWidth}) } }) - this.getPlusCardType(); - this.saveImageToPhotosAlbum(); - this.puls_user(); - //-----------商家配置信息----- 等级卡规则------------ - - getApp().request.get("/api/weshop/storeconfig/get/"+ os.stoid, { + var fir_leader = options.scene; + that.setData({fir_leader:fir_leader}) + if (fir_leader != null && fir_leader != undefined && fir_leader != "") { + var r_url="/api/weshop/plus/vip/mem/list?storeId=" + store_id + "&userId=" + fir_leader + getApp().request.get(r_url, { + success: function (res) { + var is_ok = 1; + if (res.data.code == -1) { + getApp().my_warnning("未找到分享会员", 0, that); + is_ok = 0; + that.back_user(); + } + var user_information = res.data.data[0]; + if (user_information['GradeCardID'] == null || user_information['GradeCardID'] == "" || user_information['GradeCardID'] == undefined) { + getApp().my_warnning("分享会员不是plus会员", 0, that); + is_ok = 0; + that.back_user(); + } + //--获取当前的时间-- + var now = ut.gettimestamp(); + if (user_information['ExpiryDate']) { + var str = user_information['ExpiryDate'].replace(/-/g, '/'); + var end = new Date(str); + end = Date.parse(end) / 1000; + if (end < now) { + getApp().my_warnning("分享plus会员已经过期", 0, that); + is_ok = 0; + that.back_user(); + } + } else { + getApp().my_warnning("分享plus会员已经过期", 0, that); + is_ok = 0; + that.back_user(); + } + if (is_ok == 1) { + that.setData({def_recommon: user_information.MobileTel, def_serviceman: user_information.StaffNo,is_fengxiang:1}) + //--先判断会员状态-- + 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/getphone/getphone?first_leader='+fir_leader, }) + return false; + } + } + } + }); + } + + //-----------商家配置信息----- 等级卡规则,是否又开邀请码,营业员------------ + getApp().request.get("/api/weshop/storeconfig/get/" + store_id, { success: function (res) { - var is_cardrule=res.data.data.cardrules; + var is_cardrule = res.data.data.cardrules; + var switch_list= res.data.data.switch_list; + var swi_arr=JSON.parse(switch_list); + w.wxParse("content", "html", is_cardrule, that, 6); - - console.log("等级卡规则8888888888888", is_cardrule); that.setData({ - is_card_rule: is_cardrule + is_card_rule: is_cardrule, + isyaoqingma:parseInt(swi_arr.isyaoqingma), + is_salesman:parseInt(swi_arr.is_staffno) }); } }); }, - //-----Plus会员获取----------- - puls_user: function () { - var th = this; - getApp().request.get("/api/weshop/plus/vip/mem/list", { - data: { - storeId: os.stoid, - userId: getApp().globalData.user_id, - }, - success: function (su) { - if (su.data.code == 0) { - var cardname = su.data.data[0].MemCardName; - console.log("卡的名字", cardname); - th.setData({ pulscardname: cardname }); - } - } - }); + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + this.getPlusCardType(); }, + /** + * 生命周期函数--监听页面隐藏 + */ + onHide: function () { + }, + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom: function () { + var goods_list = this.selectComponent("#goods_list"); //组件的id + goods_list.get_list(); + }, - - - //获取卡类 - getPlusCardType: function(e) { + //--- 获取卡类列表 --- + getPlusCardType: function (e) { var storid = o.stoid; var th = this; getApp().request.promiseGet("/api/weshop/plus/vip/mem/bership/list?" + "storeId=" + storid, {}).then(res => { var plusCard = res.data.data; var arr = [1219, 2089, 3031]; - for(var i = 0; i < plusCard.length;i++){ - plusCard[i].free=arr[i]; + var new_arr = new Array(); + for (var i = 0; i < plusCard.length; i++) { + //plusCard[i].free=arr[i]; + var item = {"fee": plusCard[i].CardFee, 'index': i} + new_arr.push(item); + } + //根據距離遠近排序,越近在前面,升序 + new_arr.sort(function (a, b) { + if (a.fee < b.fee) { + return -1; + } else if (a.fee == b.fee) { + return 0; + } else { + return 1; + } + }); + //---给数组添加立省多少钱--- + for (i = 0; i < plusCard.length; i++) { + for (var j = 0; j < new_arr.length; j++) { + if (i == new_arr[j].index) { + plusCard[i].free = arr[j]; + break; + } + } } - th.setData({ - is_plusCard: plusCard + is_plusCard: plusCard, is_show: 1 }) - }) + var goods_list = th.selectComponent("#goods_list"); //组件的id + goods_list.get_list(); - }, - /** - * 生命周期函数--监听页面初次渲染完成 - */ - saveImageToPhotosAlbum: function() { - wx.showLoading({ - title: '生成中...', }) + }, + + //--开通会员---接受前端index,弹起窗口--- + Opening: function (e) { var th = this; - var unit = th.data.screenWidth / 750 * 1.35; - const ctx = wx.createCanvasContext('myCanvas'); - //设置画板显示,才能开始绘图 - th.setData({ + th.data.by_index = e.currentTarget.dataset.ind; + + if (th.data.is_fengxiang) { + th.buy_card(); + } else { + //--如果后台都没有勾邀请码,营业员,立即购买-- + if (!th.data.isyaoqingma && !th.data.is_salesman) {th.buy_card(); return false;} + th.setData({open_yq: 1}) + } + }, - canvasHidden: false + //--立即购买卡-- + buy_card: async function () { + var th = this; + var is_card = 0; + //--商家是不是有等级卡功能,开通的人数是不是够用,开通是时间是不是到期-- + await getApp().request.promiseGet("/api/weshop/plus/plus/card/register", + {data: {storeId: os.stoid}}).then(res => { + if (res.data.code == 0) is_card = 1; }) - ctx.drawImage("../../../images/plus/share/mackground.png", 0, 0, 554 * unit, 930 * unit); - ctx.setFontSize(26 * unit); - ctx.setFillStyle("rgb(0,0,0)"); - ctx.fillText("钱巧玲", 155 * unit, 75 * unit, 200 * unit); - - var tj_path = "../../../images/userinfo/q_tj.png"; - ctx.drawImage(tj_path, 385 * unit, 45 * unit, 90 * unit, 30 * unit); - ctx.setFontSize(18 * unit); - ctx.setFillStyle("rgb(255,255,255)"); - ctx.fillText("强烈推荐", 394 * unit, 65 * unit); - - ctx.setStrokeStyle("rgb(255,255,255)"); - ctx.setLineDash([5 * unit, 5 * unit], 5 * unit); - ctx.beginPath(); - ctx.moveTo(0, 125 * unit); - ctx.lineTo(554 * unit, 125 * unit); - ctx.stroke(); - - var x = 55 * unit, - y = 165 * unit, - w = 444 * unit, - h = 220 * unit, - r = 14 * unit; - ctx.save(); - // 开始绘制 - ctx.beginPath(); - // 因为边缘描边存在锯齿,最好指定使用 transparent 填充 - // 这里是使用 fill 还是 stroke都可以,二选一即可 - ctx.setFillStyle('rgb(237,188,150)') - // ctx.setStrokeStyle('transparent') - // 左上角 - ctx.arc(x + r, y + r, r, Math.PI, Math.PI * 1.5) - - // border-top - ctx.moveTo(x + r, y) - ctx.lineTo(x + w - r, y) - ctx.lineTo(x + w, y + r) - // 右上角 - ctx.arc(x + w - r, y + r, r, Math.PI * 1.5, Math.PI * 2) - - // border-right - ctx.lineTo(x + w, y + h - r) - ctx.lineTo(x + w - r, y + h) - // 右下角 - ctx.arc(x + w - r, y + h - r, r, 0, Math.PI * 0.5) - - // border-bottom - ctx.lineTo(x + r, y + h) - ctx.lineTo(x, y + h - r) - // 左下角 - ctx.arc(x + r, y + h - r, r, Math.PI * 0.5, Math.PI) - - // border-left - ctx.lineTo(x, y + r) - ctx.lineTo(x + r, y) - - // 这里是使用 fill 还是 stroke都可以,二选一即可,但是需要与上面对应 - ctx.fill() - - ctx.clip(); //画了圆 再剪切 原始画布中剪切任意形状和尺寸。一旦剪切了某个区域,则所有之后的绘图都会被限制在被剪切的区域内 - ctx.drawImage("../../../images/plus/share/one.jpg", x, y, 444 * unit, 220 * unit); // 推进去图片 - ctx.restore(); //恢复之前保存的绘图上下文 恢复之前保存的绘图上下午即状态 可以继续绘制 - - ctx.beginPath(); - // 卡图片 - // ctx.drawImage("../../../images/plus/share/one.jpg", 55 * unit, 165 * unit, 444 * unit, 220 * unit,); - ctx.setFontSize(26 * unit); - ctx.setFillStyle("rgb(237,188,150)"); - ctx.fillText("PLUSI会员", 80 * unit, 215 * unit); - ctx.setFontSize(18 * unit); - ctx.setFillStyle("rgb(237,188,150)"); - ctx.fillText("开通会员年卡仅199元", 80 * unit, 240 * unit); - - ctx.drawImage("../../../images/plus/share/privilege_o.png", 80 * unit, 343 * unit, 20 * unit, 20 * unit); - - ctx.setFontSize(14 * unit); - ctx.setFillStyle("rgb(237,188,150)"); - ctx.fillText("根据大家购买数据,您成为超级会员预计可省¥3031元", 105 * unit, 360 * unit); - - ctx.rect(70 * unit, 425 * unit, 182 * unit, 1 * unit); - ctx.setFillStyle('rgb(218,194,169)'); - ctx.fill(); - - ctx.drawImage("../../../images/plus/share/square.png", 267 * unit, 420 * unit, 13 * unit, 13 * unit); - - ctx.beginPath(); - ctx.rect(295 * unit, 425 * unit, 182 * unit, 1 * unit); - ctx.setFillStyle('rgb(218,194,169)'); - ctx.fill(); - - ctx.drawImage("../../../images/plus/share/square.png", 80 * unit, 470 * unit, 10 * unit, 10 * unit); - ctx.setFontSize(24 * unit); - ctx.setFillStyle("rgb(198,165,126)"); - ctx.fillText("超级VIP权益", 100 * unit, 475 * unit); - - ctx.setFontSize(20 * unit); - ctx.setFillStyle("rgb(198,165,126)"); - ctx.fillText("超级会员专属权益", 100 * unit, 505 * unit); - ctx.drawImage("../../../images/plus/share/Ancrown.png", 355 * unit, 440 * unit, 65 * unit, 65 * unit); - - ctx.rect(85 * unit, 530 * unit, 375 * unit, 1 * unit) - ctx.setFillStyle('rgb(218,194,169)') - ctx.fill(); - - ctx.drawImage("../../../images/plus/share/square.png", 80 * unit, 575 * unit, 10 * unit, 10 * unit); - ctx.setFontSize(24 * unit); - ctx.setFillStyle("rgb(198,165,126)"); - ctx.fillText("超级VIP标识", 100 * unit, 580 * unit); - - ctx.setFontSize(20 * unit); - ctx.setFillStyle("rgb(198,165,126)"); - ctx.fillText("彰显尊贵身份的象征", 100 * unit, 610 * unit); - ctx.drawImage("../../../images/plus/share/Identification.png", 355 * unit, 548 * unit, 65 * unit, 65 * unit); - - ctx.rect(85 * unit, 635 * unit, 375 * unit, 1 * unit); - ctx.setFillStyle('rgb(218,194,169)'); - ctx.fill(); - - ctx.drawImage("../../../images/plus/share/square.png", 80 * unit, 695 * unit, 10 * unit, 10 * unit); - ctx.setFontSize(24 * unit); - ctx.setFillStyle("rgb(198,165,126)"); - ctx.fillText("超级VIP价格", 100 * unit, 695 * unit); - - ctx.setFontSize(20 * unit); - ctx.setFillStyle("rgb(198,165,126)"); - ctx.fillText("享受专属会员超低价", 100 * unit, 725 * unit); - ctx.drawImage("../../../images/plus/share/money.png", 355 * unit, 660 * unit, 65 * unit, 65 * unit); - - ctx.rect(85 * unit, 750 * unit, 375 * unit, 1 * unit) - ctx.setFillStyle('rgb(218,194,169)') - ctx.fill(); - - ctx.drawImage("../../../images/userinfo/user_head.jpg", 100 * unit, 780 * unit, 110 * unit, 110 * unit); - - ctx.setFontSize(20 * unit); - ctx.setFillStyle("#000"); - ctx.fillText("解锁新权益 精彩享不停", 230 * unit, 825 * unit); - - ctx.setFontSize(20 * unit); - ctx.setFillStyle("#000"); - ctx.fillText("长按识别二维码,立即开通!", 230 * unit, 865 * unit); - - //---绘制圆形要放在最后---- - ctx.save(); - ctx.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; - ctx.arc(cx, cy, h_r, 0, Math.PI * 2, false); - ctx.closePath(); - ctx.fill(); - ctx.clip(); - ctx.drawImage("../../../images/userinfo/user_head.jpg", h_x, h_y, h_r * 2, h_r * 2); - ctx.restore(); - - var x = 345 * unit, - y = 190 * unit, - w = 105 * unit, - h = 30 * unit, - r = 14 * unit; - ctx.save(); - // 开始绘制 - ctx.beginPath(); - // 因为边缘描边存在锯齿,最好指定使用 transparent 填充 - // 这里是使用 fill 还是 stroke都可以,二选一即可 - ctx.setFillStyle('rgb(237,188,150)') - // ctx.setStrokeStyle('transparent') - // 左上角 - ctx.arc(x + r, y + r, r, Math.PI, Math.PI * 1.5) - - // border-top - ctx.moveTo(x + r, y) - ctx.lineTo(x + w - r, y) - ctx.lineTo(x + w, y + r) - // 右上角 - ctx.arc(x + w - r, y + r, r, Math.PI * 1.5, Math.PI * 2) - - // border-right - ctx.lineTo(x + w, y + h - r) - ctx.lineTo(x + w - r, y + h) - // 右下角 - ctx.arc(x + w - r, y + h - r, r, 0, Math.PI * 0.5) - - // border-bottom - ctx.lineTo(x + r, y + h) - ctx.lineTo(x, y + h - r) - // 左下角 - ctx.arc(x + r, y + h - r, r, Math.PI * 0.5, Math.PI) - - // border-left - ctx.lineTo(x, y + r) - ctx.lineTo(x + r, y) - - // 这里是使用 fill 还是 stroke都可以,二选一即可,但是需要与上面对应 - ctx.fill() - // ctx.stroke() - ctx.closePath() - // 剪切 - ctx.clip(); - - ctx.setFontSize(18 * unit); - ctx.setFillStyle("#000"); - ctx.fillText("立即开通", 362 * unit, 212 * unit); - - //绘制图片 - ctx.draw(false, - wx.canvasToTempFilePath({ - x: 0, - y: 0, - width: 750, - height: 930, - destWidth: 1.2 * 750 * 750 / th.data.screenWidth, - destHeight: 1.2 * 1217 * 750 / th.data.screenWidth, - canvasId: 'myCanvas', - success: function(res) { - console.log("sssssssssssssssssssssssss" + res.tempFilePath); - var tempFilePath = res.tempFilePath; - th.setData({ - imagePath: tempFilePath, - maskHidden: false, - canvasHidden: true - }); - wx.previewImage({ - urls: [res.tempFilePath], - }) - if (!res.tempFilePath) { - wx.showModal({ - title: '提示', - content: '图片绘制中,请稍后重试', - showCancel: false - }) + if (is_card == 0) getApp().my_warnning("请联系商家升级plus功能", 0, th); + var item = th.data.is_plusCard[th.data.by_index]; + var req = {}; + req.cardId = item.CardId; + req.rechargeType = 3; + //如果不是你导购,也不是等级会员分享 + if (th.data.is_fengxiang == 1) { + if (th.data.def_recommon) req.recommon = th.data.def_recommon + if (th.data.def_serviceman) req.serviceman = th.data.def_serviceman + } else { + //---后台要求要输入邀请码--- + if (th.data.isyaoqingma) { + if (!th.data.inp_recommon) { + getApp().my_warnning("请输入邀请码", 0, th); + return false; } - wx.hideLoading(); - } - - })) - - }, - /** - * 生命周期函数--监听页面显示 - */ - onShow: function() { - var goods_list = this.selectComponent("#goods_list"); //组件的id - goods_list.get_list(); - }, - - /** - * 生命周期函数--监听页面隐藏 - */ - onHide: function() { - + req.recommon = th.data.inp_recommon + } + //--后台要求要输入营业员-- + if (th.data.is_salesman) { + if (!th.data.inp_serviceman) { + getApp().my_warnning("请输入营业员", 0, th); + return false; + } + req.serviceman = th.data.inp_serviceman + } + } + req.storeId = os.stoid; + req.userId = getApp().globalData.user_id; + //--如果有邀请码,和营业员的情况下-- + if(req.recommon || req.serviceman ) { + var req_data = {storeId: os.stoid, userId: req.userId}; + if(req.recommon) req_data.inviteCode=req.recommon; + if(req.serviceman) req_data.staffNo=req.serviceman; + getApp().request.get("/api/weshop/plus/vip/mem/referee/code/check", { + data:req_data, + success:function(res){ + if(res.data.code==0) { + t_pay.pay(req, th.success, function () { + getApp().my_warnning("支付失败", 0, th); + }); + }else{ + getApp().my_warnning("支付失败", 0, th); + } + } + }) + }else{ + t_pay.pay(req, th.success, function () { + getApp().my_warnning("支付失败", 0, th); + }); + } }, - - /** - * 生命周期函数--监听页面卸载 - */ - onUnload: function() { - + //返回会员页面 + OpeningClose: function() { + this.setData({open_yq:0}); }, - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh: function() { - + //返回会员中心 + back_user:function () { + setTimeout(function () { + wx.reLaunch({url:"/pages/user/index/index"}); + },1000) }, - - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom: function() { - var goods_list = this.selectComponent("#goods_list"); //组件的id - goods_list.get_list(); - this.setData({ - j: true - }) + //--支付成功,跳转到等级卡续费页面-- + success:function () { + var u_url="/pages/user/cardinfo/cardinfo"; + wx.reLaunch({url:u_url}) }, - /** - * 用户点击右上角分享 - */ - onShareAppMessage: function() { - - }, - //开通会员 - Opening: function() { - this.setData({ - j: true - }) - }, - //返回会员页面 - OpeningClose: function() { - this.setData({ - j: false - }) + //--绑定邀请码的输入-- + b_input:function (e) { + var value=e.detail.value; + var name=e.currentTarget.dataset.name; + var ob={}; + ob[name]=value + this.setData(ob); } }) \ No newline at end of file diff --git a/pages/user/plus/plus.json b/pages/user/plus/plus.json index e763cd5..23e6f91 100644 --- a/pages/user/plus/plus.json +++ b/pages/user/plus/plus.json @@ -1,7 +1,8 @@ { "usingComponents": { "pop_txt": "/components/userqy_pop_up/userqy_pop_up", - "goods_recommend": "/components/goods_list/goods_list" + "goods_recommend": "/components/goods_list/goods_list", + "warn": "/components/long_warn/long_warn" }, - "navigationBarTitleText": "我的会员" + "navigationBarTitleText": "购买plus会员" } \ No newline at end of file diff --git a/pages/user/plus/plus.wxml b/pages/user/plus/plus.wxml index 68905c5..7393e98 100644 --- a/pages/user/plus/plus.wxml +++ b/pages/user/plus/plus.wxml @@ -1,9 +1,9 @@ + - @@ -11,20 +11,16 @@ - - - - {{item.CardName}} 开通会员年卡仅{{item.CardFee}}元 - 立即开通 + 立即开通 @@ -41,58 +37,6 @@ - - - - - - - - - PLUSI会员 - 开通会员年卡仅199元 - - 立即续费 - - - - - - - - - 正在享受PLUSI会员特权 - - - - 邀请新朋友 - - - - - - - - - - - - 已邀请 - 3人 - 可提现 - 66元 - - - - - 明细 - - 立即提现 - - - - - @@ -124,12 +68,9 @@ - - - + - @@ -141,9 +82,7 @@ - - - + 好物推荐 @@ -170,38 +109,39 @@ + - + - + 请完善下面信息 - + - + - - + - + - - + + 确认购买 @@ -213,9 +153,4 @@ - - - - - \ No newline at end of file diff --git a/pages/user/plus/plus.wxss b/pages/user/plus/plus.wxss index 22d930d..1d9c580 100644 --- a/pages/user/plus/plus.wxss +++ b/pages/user/plus/plus.wxss @@ -176,6 +176,7 @@ left: -40rpx; line-height: 45rpx; text-align: center; margin-top: 2rpx; + color: #666 } .Invitation { @@ -267,11 +268,10 @@ left: -40rpx; right: 0; bottom: 0; z-index: 11; - background: rgba(0, 0, 0, 0.4); + background: rgba(0, 0, 0, 0.6); width: 100%; height: 100%; } - .ddd { border-radius: 20rpx; } @@ -345,6 +345,7 @@ left: -40rpx; border-radius: 25rpx; color: rgb(255, 255, 255); margin: 55rpx 0rpx; + background-position: center;background-repeat: no-repeat;background-size: cover } .purchaseClose { diff --git a/utils/pay2.js b/utils/pay2.js new file mode 100644 index 0000000..a99a44c --- /dev/null +++ b/utils/pay2.js @@ -0,0 +1,40 @@ +var t = getApp(), n = t.request; + +module.exports = { + url: "/api/weshop/plus/create/plus/order", + pay: function(dd, succ,fail) { + var i = this; + n.post(this.url, { + data: dd, + success: function(t) { + if(t.data.code==0){ + i.weixinPay(t.data.data, succ,fail); + }else{ + "function" == typeof fail && fail(); + } + return false; + }, + fail: function() { + "function" == typeof fail && fail(); + }, + failStatus: function() { + "function" == typeof fail && fail(); + } + }); + }, + weixinPay: function(n, succ,fail) { + wx.requestPayment({ + timeStamp: String(n.timeStamp), + nonceStr: n.nonceStr, + package: n.packageValue, + signType: n.signType, + paySign: n.paySign, + success: function(n) { + "function" == typeof succ && succ(); + }, + fail: function(n) { + "function" == typeof fail && fail(); + } + }); + } +}; \ No newline at end of file -- libgit2 0.21.4