From 469e568c66408dfa62ce924568dd6cc7add19b0a Mon Sep 17 00:00:00 2001 From: Stormeye Wu Date: Tue, 28 May 2019 11:02:34 +0800 Subject: [PATCH] =?UTF-8?q?[=E6=9C=8B=E5=8F=8B=E5=9C=88=E5=88=86=E4=BA=AB]?= =?UTF-8?q?[=E4=BF=AE=E6=94=B9]:=E6=B7=BB=E5=8A=A0=E6=96=B0=E8=B7=AF?= =?UTF-8?q?=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ext.json | 18 ++++++++++++++---- utils/util.js | 19 +++++++++---------- 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/ext.json b/ext.json index 783ffc3..9fcb600 100644 --- a/ext.json +++ b/ext.json @@ -8,10 +8,20 @@ "etcpCallbackUrl": "https://ciformall.youlane.cn/api/carCallback/etcpPaidCallback", "ifHaveWebSocket": "0", "ifHaveCarModular": "1", - "imgOrgUrl": "https://iformall-net.s3.cn-northwest-1.amazonaws.com.cn", - "imgOrgUrl1": "https://s3.cn-northwest-1.amazonaws.com.cn", - "imgNewUrl": "https://ciformall.youlane.cn/img", - "imgNewUrl1": "https://ciformall.youlane.cn/img1" + "imgProxy": [ + { + "orgUrl": "https://iformall-net.s3.cn-northwest-1.amazonaws.com.cn", + "newUrl": "https://ciformall.youlane.cn/img" + }, + { + "orgUrl": "https://s3.cn-northwest-1.amazonaws.com.cn", + "newUrl": "https://ciformall.youlane.cn/img1" + }, + { + "orgUrl": "https://wx.qlogo.cn", + "newUrl": "https://ciformall.youlane.cn/img2" + } + ] }, "name": "富茂客官开发", "weappId": "wxea71200db93d756b", diff --git a/utils/util.js b/utils/util.js index 373748b..382de0b 100644 --- a/utils/util.js +++ b/utils/util.js @@ -2,10 +2,7 @@ var barcode = require("./barcode"); var qrcode = require("./qrcode"); const extConfig = wx.getExtConfigSync ? wx.getExtConfigSync() : {} -let imgOrgUrl = extConfig.attr.imgOrgUrl; -let imgOrgUrl1 = extConfig.attr.imgOrgUrl1; -let imgNewUrl = extConfig.attr.imgNewUrl; -let imgNewUrl1 = extConfig.attr.imgNewUrl1; +let imgProxy = extConfig.attr.imgProxy; const formatTime = (date, fmt) => { try { @@ -155,12 +152,14 @@ function isJSON(str) { } } function getProxyImgUrl(str) { - if (str.indexOf(imgOrgUrl) == 0) { - return str.replace(imgOrgUrl, imgNewUrl) - } else if(str.indexOf(imgOrgUrl1) == 0) { - return str.replace(imgOrgUrl1, imgNewUrl1) - } - return str + let str1 = str; + imgProxy.map(file=>{ + if (str.indexOf(file.orgUrl) == 0) { + str1 = str.replace(file.orgUrl, file.newUrl) + return + } + }) + return str1 } module.exports = { formatTime: formatTime,