From 82221a1cf5ba8e88e7e3e0667b68709f4adadf9c Mon Sep 17 00:00:00 2001 From: cheng.xu Date: Sat, 2 Nov 2019 18:12:36 +0800 Subject: [PATCH] 等级卡续费 --- pages/user/cardinfo/cardinfo.js | 160 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------------------- pages/user/cardinfo/cardinfo.wxml | 6 ++++-- 2 files changed, 109 insertions(+), 57 deletions(-) diff --git a/pages/user/cardinfo/cardinfo.js b/pages/user/cardinfo/cardinfo.js index 0f064b5..68d2e73 100644 --- a/pages/user/cardinfo/cardinfo.js +++ b/pages/user/cardinfo/cardinfo.js @@ -47,6 +47,7 @@ Page({ cardid: "",//会员卡的id user_card: null,//会员买的卡 free:null,//分佣的数据 + expiryDate:"",//卡到期时间 }, @@ -176,9 +177,13 @@ Page({ }, }).then(res => { - var GradeCardID = res.data.data[0].GradeCardID + var GradeCardID = res.data.data[0].GradeCardID; + var expiryDate = res.data.data[0].ExpiryDate console.log(GradeCardID, "卡的id", res.data.data[0]); - ee.setData({cardid: GradeCardID}); + ee.setData({cardid: GradeCardID, + expiryDate: expiryDate + }); + }) //-----------会员分佣------------------- @@ -400,6 +405,10 @@ Page({ wx.showLoading({ title: '生成中...', }) + + this.setData({ + canvasHidden: false + }) var th = this; //设置画板显示,才能开始绘图 @@ -412,32 +421,28 @@ Page({ var img_Identification = th.data.img_Identification;//会员标识 var privilege_o = th.data.privilege_o;//勋章图片 var img_square=th.data.img_square; - console.log("user的会员资料", user); - console.log("最大的卡", big_card); - console.log("会员头像", card_ming); - console.log("缓存vip的价格", img_money); - console.log(" 会员标识", img_Ancrown); - console.log("/勋章图片", privilege_o); + var app = getApp(); var unit = th.data.screenWidth / 750 * 1.35; var scene = getApp().globalData.user_id; - console.log("二维码主键",scene); + console.log("用户头像", th.data.head_pic); ///二微码 - var vpath=""; + var path3 = os.url + "/api/wx/open/app/user/getWeAppEwm/" + - os.stoid + "?sceneValue=" + scene + "&pageValue=pages/user/plus/plus"; + os.stoid + "?sceneValue=" + scene + "&pageValue=pages/user/index/index"; wx.getImageInfo({ src: path3, success: function (res) { //回调写法 th.get_head_temp(th.get_goods_temp, function () { - vpath = res.path; - }) - } - }) + var vpath=res.path; + console.log("生成二维码", path3); //开启画布 const ctx = wx.createCanvasContext('myCanvas'); + + + //先画背景 ctx.drawImage("../../../images/plus/share/mackground.png", 0, 0, 554 * unit, 930 * unit); ctx.setFontSize(26 * unit); @@ -571,7 +576,7 @@ Page({ ctx.setFillStyle('rgb(218,194,169)') ctx.fill(); - ctx.drawImage(vpath, 100 * unit, 780 * unit, 110 * unit, 110 * unit); + ctx.drawImage(vpath, 100 * unit, 780 * unit, 110 * unit, 110 * unit); ctx.setFontSize(20 * unit); ctx.setFillStyle("#000"); @@ -593,7 +598,7 @@ Page({ ctx.closePath(); ctx.fill(); ctx.clip(); - ctx.drawImage(user_head, h_x, h_y, h_r * 2, h_r * 2); + ctx.drawImage(th.data.head_pic, h_x, h_y, h_r * 2, h_r * 2); ctx.restore(); var x = 345 * unit, @@ -641,66 +646,111 @@ Page({ 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) { - wx.hideLoading();//关闭生成中的方法 - th.data.is_loading=0; - - 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 - }) - } - - } - })) + function(){ + + setTimeout(function(){ + 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) { + wx.hideLoading();//关闭生成中的方法 + th.data.is_loading = 0; + console.log("生成的海报"); + console.log(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 + }) + } + + } + + }) + },500) + + + } + ) - + + }) + } + }) + + }, + + //--获取头像的本地缓存,回调写法-- + get_head_temp: function (tt, func) { + var ee = this; + console.log("获取头像", ee.data.head_pic); + if (ee.data.head_pic) { + tt(func); + return false; + } + //---获取分享图片的本地地址,头像和商品图片---- + var path2 = getApp().globalData.userInfo.head_pic; + if (path2 == "") { + ee.data.head_pic = "../../../images/share/hui_hear_pic.png"; + tt(func); + } else { + path2 = path2.replace("http://thirdwx.qlogo.cn", "https://wx.qlogo.cn"); + wx.getImageInfo({ + src: path2, + success: function (res) { + //res.path是网络图片的本地地址 + ee.data.head_pic= res.path; + tt(func);; + }, + fail: function (res) { + ee.data.head_pic= "../../../images/share/hui_hear_pic.png"; //分享的图片不能用网络的 + tt(func); + } + }); + } }, //--获取商品图片的本地缓存,回调写法-- get_goods_temp: function (tt) { var ee = this; - if (ee.data.share_goods_img) { + if (ee.data.head_pic) { tt(); return false; } //获取商品是分享图信息 wx.getImageInfo({ - src: ee.data.data.original_img, + src: ee.data.head_pic, success: function (res) { //res.path是网络图片的本地地址 - ee.data.share_goods_img = res.path; + ee.data.head_pic = res.path; tt(); }, fail: function (res) { - ee.data.share_goods_img = "../../../images/share/default_g_img.gif"; //分享的图片不能用网络的 + ee.data.head_pic = "../../../images/share/default_g_img.gif"; //分享的图片不能用网络的 tt(); } }); }, - /** * 生命周期函数--监听页面显示 */ diff --git a/pages/user/cardinfo/cardinfo.wxml b/pages/user/cardinfo/cardinfo.wxml index e51c42d..c02dddc 100644 --- a/pages/user/cardinfo/cardinfo.wxml +++ b/pages/user/cardinfo/cardinfo.wxml @@ -1,4 +1,6 @@ + + @@ -10,7 +12,7 @@ {{user_card.CardName}} - 会员将在{{user_card.ExpiryDate}}到期 + 会员将在{{filters.replace_time2(expiryDate)}}到期 立即续费 @@ -20,7 +22,7 @@ - + 正在享受{{user_card.CardName}}会员特权 -- libgit2 0.21.4