From 47696d435c02d7687c326018e2ead060583a904c Mon Sep 17 00:00:00 2001 From: yvan.ni <765199919@qq.com> Date: Thu, 4 Jun 2020 10:40:53 +0800 Subject: [PATCH] 1.小程序顶部颜色 2. 会员二维吗64位加密 --- pages/index/index/index.js | 9 +++++++++ pages/template/index.js | 9 +++++++++ pages/user/index/index.js | 6 +++++- utils/util.js | 31 ++++++++++++++++++++++++++++++- 4 files changed, 53 insertions(+), 2 deletions(-) diff --git a/pages/index/index/index.js b/pages/index/index/index.js index 0f391f0..48e0915 100644 --- a/pages/index/index/index.js +++ b/pages/index/index/index.js @@ -204,6 +204,15 @@ Page({ isTemplate: 1, bgcolor_t: temp_data.bkcolor }); + + //---如果有设定顶部的颜色的时候-- + if(temp_data.top_color && temp_data.top_color!='null' ){ + wx.setNavigationBarColor({ + frontColor: '#ffffff', // 必写项 + backgroundColor: temp_data.top_color, // 必写项 + }) + } + } }) diff --git a/pages/template/index.js b/pages/template/index.js index af3ee7c..28870d2 100644 --- a/pages/template/index.js +++ b/pages/template/index.js @@ -51,6 +51,15 @@ Page({ isTemplate: 1, bgcolor_t: temp_data.bkcolor }); + + //---如果有设定顶部的颜色的时候-- + if(temp_data.top_color && temp_data.top_color!='null' ){ + wx.setNavigationBarColor({ + frontColor: '#ffffff', // 必写项 + backgroundColor: temp_data.top_color, // 必写项 + }) + } + } }) diff --git a/pages/user/index/index.js b/pages/user/index/index.js index 21c6845..ca7b64e 100644 --- a/pages/user/index/index.js +++ b/pages/user/index/index.js @@ -359,7 +359,11 @@ Page({ //------卡片的显示和关闭-------- show_tc: function() { if (!this.data.userInfo) return false; - qrcode('qrcode', this.data.userInfo.mobile, 480, 480, this); + //base64_encode($user.mobile.'|'.date('Y-m-d H:i:s') + var val= this.data.userInfo.mobile+"|"+ut.formatTime(); + val=ut.base64_encode(val); + + qrcode('qrcode', val, 480, 480, this); this.setData({ tc_hide: false, }); diff --git a/utils/util.js b/utils/util.js index d946b24..38900e8 100644 --- a/utils/util.js +++ b/utils/util.js @@ -371,7 +371,35 @@ function isContained(aa, bb) { return true; } - +//---base64位编码--- +function base64_encode (str) { // 编码,配合encodeURIComponent使用 + var c1, c2, c3; + var base64EncodeChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; + var i = 0, len = str.length, strin = ''; + while (i < len) { + c1 = str.charCodeAt(i++) & 0xff; + if (i == len) { + strin += base64EncodeChars.charAt(c1 >> 2); + strin += base64EncodeChars.charAt((c1 & 0x3) << 4); + strin += "=="; + break; + } + c2 = str.charCodeAt(i++); + if (i == len) { + strin += base64EncodeChars.charAt(c1 >> 2); + strin += base64EncodeChars.charAt(((c1 & 0x3) << 4) | ((c2 & 0xF0) >> 4)); + strin += base64EncodeChars.charAt((c2 & 0xF) << 2); + strin += "="; + break; + } + c3 = str.charCodeAt(i++); + strin += base64EncodeChars.charAt(c1 >> 2); + strin += base64EncodeChars.charAt(((c1 & 0x3) << 4) | ((c2 & 0xF0) >> 4)); + strin += base64EncodeChars.charAt(((c2 & 0xF) << 2) | ((c3 & 0xC0) >> 6)); + strin += base64EncodeChars.charAt(c3 & 0x3F) + } + return strin +} module.exports = { formatTime: function(e, r) { @@ -477,4 +505,5 @@ module.exports = { draw_circle:draw_circle,//绘制圆, mergeArray:mergeArray, //数组合并 isContained:isContained, //是否包含 + base64_encode:base64_encode //64位加密 }; -- libgit2 0.21.4