From 729fe41f30d34972672b9829e21c55398fd408d5 Mon Sep 17 00:00:00 2001 From: zpc Date: Fri, 18 Apr 2025 15:42:40 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/config.js | 62 +++++++++++++++++++++++++++----------------- common/request.js | 17 +++++++++--- pages/mall/index.vue | 18 ++++++++++--- 3 files changed, 66 insertions(+), 31 deletions(-) diff --git a/common/config.js b/common/config.js index 23f5428..53b43a0 100644 --- a/common/config.js +++ b/common/config.js @@ -8,28 +8,30 @@ import RequestManager from '@/common/request.js' let configData = null; let isLoading = false; let loadPromise = null; +const wx_version = "100"; const defaultConfig = { - "good_type": [{"value":0,"sort_order":0,"is_show":1,"name":"全部","pay_wechat":1,"pay_balance":1,"pay_currency":1,"pay_currency2":1,"pay_coupon":1,"is_deduction":1},{"value":1,"sort_order":1,"is_show":0,"name":"一番赏","pay_wechat":1,"pay_balance":1,"pay_currency":1,"pay_currency2":1,"pay_coupon":1,"is_deduction":1},{"value":2,"sort_order":2,"is_show":1,"name":"无限赏","pay_wechat":1,"pay_balance":1,"pay_currency":1,"pay_currency2":1,"pay_coupon":1,"is_deduction":1},{"value":3,"sort_order":3,"is_show":0,"name":"擂台赏","pay_wechat":1,"pay_balance":1,"pay_currency":1,"pay_currency2":1,"pay_coupon":1,"is_deduction":1},{"value":5,"sort_order":4,"is_show":0,"name":"积分赏","pay_wechat":0,"pay_balance":0,"pay_currency":0,"pay_currency2":1,"pay_coupon":1,"is_deduction":0},{"value":6,"sort_order":5,"is_show":1,"name":"限时活动","pay_wechat":1,"pay_balance":1,"pay_currency":1,"pay_currency2":1,"pay_coupon":1,"is_deduction":1},{"value":8,"sort_order":6,"is_show":1,"name":"领主赏","pay_wechat":1,"pay_balance":1,"pay_currency":1,"pay_currency2":1,"pay_coupon":1,"is_deduction":1},{"value":9,"sort_order":7,"is_show":0,"name":"连击赏","pay_wechat":1,"pay_balance":1,"pay_currency":1,"pay_currency2":1,"pay_coupon":1,"is_deduction":1},{"value":10,"sort_order":8,"is_show":0,"name":"商城赏","pay_wechat":1,"pay_balance":0,"pay_currency":0,"pay_currency2":1,"pay_coupon":0,"is_deduction":0},{"value":11,"sort_order":9,"is_show":0,"name":"自制赏","pay_wechat":1,"pay_balance":1,"pay_currency":1,"pay_currency2":1,"pay_coupon":1,"is_deduction":1},{"value":15,"sort_order":15,"is_show":0,"name":"福利屋","pay_wechat":1,"pay_balance":1,"pay_currency":0,"pay_currency2":0,"pay_coupon":0,"is_deduction":0},{"value":16,"sort_order":16,"is_show":1,"name":"翻倍赏","pay_wechat":1,"pay_balance":1,"pay_currency":1,"pay_currency2":1,"pay_coupon":1,"is_deduction":1},{"value":17,"sort_order":17,"is_show":0,"name":"外卖盒子","pay_wechat":1,"pay_balance":1,"pay_currency":0,"pay_currency2":0,"pay_coupon":0,"is_deduction":0}], + "good_type": [{ "value": 0, "sort_order": 0, "is_show": 1, "name": "全部", "pay_wechat": 1, "pay_balance": 1, "pay_currency": 1, "pay_currency2": 1, "pay_coupon": 1, "is_deduction": 1 }, { "value": 1, "sort_order": 1, "is_show": 0, "name": "一番赏", "pay_wechat": 1, "pay_balance": 1, "pay_currency": 1, "pay_currency2": 1, "pay_coupon": 1, "is_deduction": 1 }, { "value": 2, "sort_order": 2, "is_show": 1, "name": "无限赏", "pay_wechat": 1, "pay_balance": 1, "pay_currency": 1, "pay_currency2": 1, "pay_coupon": 1, "is_deduction": 1 }, { "value": 3, "sort_order": 3, "is_show": 0, "name": "擂台赏", "pay_wechat": 1, "pay_balance": 1, "pay_currency": 1, "pay_currency2": 1, "pay_coupon": 1, "is_deduction": 1 }, { "value": 5, "sort_order": 4, "is_show": 0, "name": "积分赏", "pay_wechat": 0, "pay_balance": 0, "pay_currency": 0, "pay_currency2": 1, "pay_coupon": 1, "is_deduction": 0 }, { "value": 6, "sort_order": 5, "is_show": 1, "name": "限时活动", "pay_wechat": 1, "pay_balance": 1, "pay_currency": 1, "pay_currency2": 1, "pay_coupon": 1, "is_deduction": 1 }, { "value": 8, "sort_order": 6, "is_show": 1, "name": "领主赏", "pay_wechat": 1, "pay_balance": 1, "pay_currency": 1, "pay_currency2": 1, "pay_coupon": 1, "is_deduction": 1 }, { "value": 9, "sort_order": 7, "is_show": 0, "name": "连击赏", "pay_wechat": 1, "pay_balance": 1, "pay_currency": 1, "pay_currency2": 1, "pay_coupon": 1, "is_deduction": 1 }, { "value": 10, "sort_order": 8, "is_show": 0, "name": "商城赏", "pay_wechat": 1, "pay_balance": 0, "pay_currency": 0, "pay_currency2": 1, "pay_coupon": 0, "is_deduction": 0 }, { "value": 11, "sort_order": 9, "is_show": 0, "name": "自制赏", "pay_wechat": 1, "pay_balance": 1, "pay_currency": 1, "pay_currency2": 1, "pay_coupon": 1, "is_deduction": 1 }, { "value": 15, "sort_order": 15, "is_show": 0, "name": "福利屋", "pay_wechat": 1, "pay_balance": 1, "pay_currency": 0, "pay_currency2": 0, "pay_coupon": 0, "is_deduction": 0 }, { "value": 16, "sort_order": 16, "is_show": 1, "name": "翻倍赏", "pay_wechat": 1, "pay_balance": 1, "pay_currency": 1, "pay_currency2": 1, "pay_coupon": 1, "is_deduction": 1 }, { "value": 17, "sort_order": 17, "is_show": 0, "name": "外卖盒子", "pay_wechat": 1, "pay_balance": 1, "pay_currency": 0, "pay_currency2": 0, "pay_coupon": 0, "is_deduction": 0 }], "app_setting": { - "key": "app_setting", - "app_name": "友达赏", - "purchase_popup": "1", - "exchange_times": "2", - "balance_name": "钻石", - "balance_icon": "https://image.zfunbox.cn/app/icons/20250412/a482b527477e74f8a18ec02ebc7f0b4e.png", - "currency1_name": "UU币", - "currency1_icon": "https://image.zfunbox.cn/app/icons/20250412/3d1741965e9439372d1ce101bd110616.png", - "currency2_name": "达达券", - "currency2_icon": "https://image.zfunbox.cn/app/icons/20250412/19a9f69011fd82c85ab0df3a064a309c.png", - "win_audio": "https://image.zfunbox.cn/app/20250407/14ba53d367e1d131a344c6fd5cc0e28e.mp3", - "applet_version": "v1.0.3", - "sign_in_spend_limit": "1", - "waimai_box_id": "1049", - "daily_free_draw_id": "1050", - "cabinet_exchange_limit": "0", - "daily_coupon_limit": "0", - "update_time": 1744550962 -} + "key": "app_setting", + "app_name": "友达赏", + "purchase_popup": "1", + "exchange_times": "2", + "balance_name": "钻石", + "balance_icon": "https://image.zfunbox.cn/app/icons/20250412/a482b527477e74f8a18ec02ebc7f0b4e.png", + "currency1_name": "UU币", + "currency1_icon": "https://image.zfunbox.cn/app/icons/20250412/3d1741965e9439372d1ce101bd110616.png", + "currency2_name": "达达券", + "currency2_icon": "https://image.zfunbox.cn/app/icons/20250412/19a9f69011fd82c85ab0df3a064a309c.png", + "win_audio": "https://image.zfunbox.cn/app/20250407/14ba53d367e1d131a344c6fd5cc0e28e.mp3", + "applet_version": "v1.0.3", + "sign_in_spend_limit": "1", + "waimai_box_id": "1049", + "daily_free_draw_id": "1050", + "cabinet_exchange_limit": "0", + "daily_coupon_limit": "0", + "update_time": 1744550962 + }, + version: "100" }; // 配置类 @@ -72,12 +74,12 @@ class ConfigManager { success(res) { if (res.confirm) { console.log('开始重启'); - wx.restartMiniProgram({path:"/pages/shouye/index"}); + wx.restartMiniProgram({ path: "/pages/shouye/index" }); // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启 //updateManager.applyUpdate(); - + //#ifdef MP-WEIXIN - + //#endif } }, @@ -133,7 +135,7 @@ class ConfigManager { } else { configData = defaultConfig; } - + } return key in configData ? configData[key] : defaultConfig[key]; } @@ -229,6 +231,18 @@ class ConfigManager { } return key in appSetting ? appSetting[key] : null; } + + /** + * 获取版本号 + * @returns {Boolean} 是否为微信版本 + */ + static GetVersion() { + let version = this.get('version'); + if (version == wx_version) { + return true; + } + return false; + } } export default ConfigManager; \ No newline at end of file diff --git a/common/request.js b/common/request.js index 26e256f..a2885de 100644 --- a/common/request.js +++ b/common/request.js @@ -5,6 +5,7 @@ import EnvConfig from '@/common/env.js' import md5 from 'js-md5' +import ConfigManager from '@/common/config.js' class RequestManager { /** @@ -21,6 +22,16 @@ class RequestManager { 'api/warehouse_send_record' ] + + // 白名单URL列表 + const whitelistUrls2 = [ + 'login_record', + ] + let iswx = ConfigManager.GetVersion(); + + if (!iswx) { + return whitelistUrls2.some(whiteItem => url.indexOf(whiteItem) > -1) + } // 检查URL是否包含白名单中的任一项 return whitelistUrls.some(whiteItem => url.indexOf(whiteItem) > -1) } @@ -47,7 +58,7 @@ class RequestManager { * @returns {Promise} 返回请求Promise */ static request(param, backpage, backtype) { - + return new Promise((resolve, reject) => { // 参数检查 if (!param || typeof param !== 'object') { @@ -102,7 +113,7 @@ class RequestManager { const hostRegex = /^(?:https?:\/\/)?([^\/]+)/i const matches = requestUrl.match(hostRegex) const host = matches && matches[1] ? matches[1] : 'localhost' - + let header = {} // 添加签名和防重放攻击参数 @@ -246,7 +257,7 @@ class RequestManager { } console.log(requestUrl); if (RequestManager.isUrlInWhitelist(requestUrl)) { - + reject(res.data) return; } diff --git a/pages/mall/index.vue b/pages/mall/index.vue index 85aebc8..f24ea04 100644 --- a/pages/mall/index.vue +++ b/pages/mall/index.vue @@ -3,10 +3,12 @@ - - + + + - + @@ -137,7 +139,9 @@