From 531f29b7be6bbaf894ccce994a205e347a380510 Mon Sep 17 00:00:00 2001 From: zpc Date: Sun, 6 Jul 2025 14:00:09 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E7=99=BB=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/platform/BasePlatform.js | 25 +- common/platform/NewWebAppPlatform.js | 40 +- common/server/user.js | 15 +- common/webapp.js | 23 + main.js | 1 + manifest.json | 4 +- pages/other/about.vue | 3 +- pages/shouye/index.vue | 4 +- pages/user/bangdingweb.vue | 1 - pages/user/change.vue | 516 ++++++------ pages/user/index.vue | 14 +- pages/user/login.vue | 1043 +++++++++++++++--------- pages/user/tui-guang.vue | 1133 +++++++++++++------------- 13 files changed, 1609 insertions(+), 1213 deletions(-) diff --git a/common/platform/BasePlatform.js b/common/platform/BasePlatform.js index bbc29f8..4d28840 100644 --- a/common/platform/BasePlatform.js +++ b/common/platform/BasePlatform.js @@ -177,22 +177,15 @@ class BasePlatform { ]; if (uni.getStorageSync('token') != null && uni.getStorageSync('token') != "") { + m.push({ id: 8, show: true, - title: '注销账号', - icon: 'my/s10.png', - path: '/pages/user/cancel-account-page', - handler: this.navigateToPath.bind(this) - }), - m.push({ - id: 8, - show: true, - title: '退出登录', - icon: 'my/exit.png', - path: '', - handler: this.handleLogout.bind(this) - }) + title: '退出登录', + icon: 'my/exit.png', + path: '', + handler: this.handleLogout.bind(this) + }) } const customServiceMenu = { id: 10, @@ -262,6 +255,12 @@ class BasePlatform { getPrivacyAgreement() { navigateTo('/pages/guize/guize', { type: 5 }) } + /** + * 获取功能权限 + */ + getPermission(functionName) { + return true; + } } export default BasePlatform; \ No newline at end of file diff --git a/common/platform/NewWebAppPlatform.js b/common/platform/NewWebAppPlatform.js index 935093e..8622dfd 100644 --- a/common/platform/NewWebAppPlatform.js +++ b/common/platform/NewWebAppPlatform.js @@ -1,13 +1,33 @@ import BasePlatform from './BasePlatform'; import H5Platform from './H5Platform'; import { webAppPay } from '@/common/webapp.js' +import { parseQueryString } from '@/common/util' - +function versionToNumber(versionString) { + // 移除所有点号并转换为数字 + return parseInt(versionString.split('.').join(''), 10); +} class NewWebAppPlatform extends H5Platform { constructor() { super(); this.code = 'WEB_APP_ANDROID'; this.env = 'web_app'; + this.app_version = 100; + + let location = window.location.href; + const params = parseQueryString(location); + if (params['version'] != null) { + uni.setStorageSync('app_version', params['version']); + let _appversion = params['version'] ?? "1.0.0"; + if (_appversion.indexOf(".") > -1) { + _appversion = versionToNumber(_appversion); + this.app_version = _appversion; + } + + } + if (params['os'] != null) { + uni.setStorageSync('app_os', params['os']); + } } share({ title, desc, image, url }) { console.log(`H5分享:${title} - ${desc}`); @@ -83,5 +103,23 @@ class NewWebAppPlatform extends H5Platform { getVersion() { return uni.getStorageSync('version') == '' ? '1.0.0' : uni.getStorageSync('version'); } + + /** + * 获取功能权限 + */ + getPermission(functionName) { + const appPermission = { + wxLogin: 101 + }; + let _functionVersion = appPermission[functionName]; + + + if (_functionVersion != null) { + //如果当前app权限大于等于功能权限版本,则返回true + console.log('验证功能权限', functionName, _functionVersion, this.app_version, this.app_version >= _functionVersion); + return this.app_version >= _functionVersion; + } + return false; + } } export default NewWebAppPlatform; \ No newline at end of file diff --git a/common/server/user.js b/common/server/user.js index 903f659..475b8f9 100644 --- a/common/server/user.js +++ b/common/server/user.js @@ -15,4 +15,17 @@ export const getUserInfo = async () => { } else { return null; } -}; \ No newline at end of file +}; + +/** + * 微信APP登录 + * @param {String} unionId 微信APP unionId + * @param {String} nickname 微信APP 昵称 + * @param {String} headimg 微信APP 头像 + * @param {Number} pid 推广码 + * @returns {Promise} 是否成功 + */ +export const wxAppLogin = async (unionId, nickname, headimg, pid = 0) => { + const res = await RequestManager.post('/wx_app_login', { unionId, nickname, headimg, pid }); + return res; +} \ No newline at end of file diff --git a/common/webapp.js b/common/webapp.js index 9e1d0c8..792bf90 100644 --- a/common/webapp.js +++ b/common/webapp.js @@ -33,6 +33,11 @@ window.yds_postMessage = function (data) { return; } console.log('回调不存在'); + return; + } + if (_ydsApp.callback[data.callback]) { + _ydsApp.callback[data.callback](data.data); + delete _ydsApp.callback[data.callback]; } } //返回按钮 @@ -77,4 +82,22 @@ export const webAppPageUrl = (url, isHome) => { data: { page: url, isHome: isHome }, } }) +} + +export const sendWxAppLogin = () => { + return new Promise((resolve, reject) => { + if (!window.ydsApp) { + reject('ydsApp未加载'); + return; + } + let callback = generateRandomString(16); + _ydsApp.callback[callback] = resolve; + ydsApp.postMessage({ + data: { + action: 'wxAppLogin', + data: {}, + callback: callback + } + }); + }); } \ No newline at end of file diff --git a/main.js b/main.js index 6f197d4..ec4e2ad 100644 --- a/main.js +++ b/main.js @@ -5,6 +5,7 @@ import common from '@/common/common.js' // #ifdef H5 import { home } from '@/common/webapp.js' import ydsMixin from '@/common/ydsmixin.js' +console.log(window.location.href); // #endif import { gotopage diff --git a/manifest.json b/manifest.json index 6a57b02..57cba19 100644 --- a/manifest.json +++ b/manifest.json @@ -188,7 +188,9 @@ "enable" : false }, "devServer" : { - "https" : false + "https" : true, + "port" : 3001, + "disableHostCheck" : true }, "template" : "index.html" }, diff --git a/pages/other/about.vue b/pages/other/about.vue index 4af538d..1a76efa 100644 --- a/pages/other/about.vue +++ b/pages/other/about.vue @@ -94,7 +94,6 @@ export default { // 检查测试模式缓存 if (this.userinfo != null && this.userinfo.ut == 2) { - // 从缓存中读取测试模式状态 const testMode = uni.getStorageSync('test_mode_status'); if (testMode) { @@ -111,9 +110,9 @@ export default { } }, handleIconClick() { + if (this.userinfo && this.userinfo.ut == 2) { const now = new Date().getTime(); - // 如果是首次点击或者超过2秒重置计数 if (this.clickCount === 0 || now - this.lastClickTime > 2000) { this.clickCount = 1; diff --git a/pages/shouye/index.vue b/pages/shouye/index.vue index 810ddf6..c182043 100644 --- a/pages/shouye/index.vue +++ b/pages/shouye/index.vue @@ -30,8 +30,6 @@ - 今日推荐 @@ -50,7 +48,7 @@ - + diff --git a/pages/user/bangdingweb.vue b/pages/user/bangdingweb.vue index d1032fa..16e7d2d 100644 --- a/pages/user/bangdingweb.vue +++ b/pages/user/bangdingweb.vue @@ -1,6 +1,5 @@ \ No newline at end of file diff --git a/pages/user/index.vue b/pages/user/index.vue index 23d1475..f896b8a 100644 --- a/pages/user/index.vue +++ b/pages/user/index.vue @@ -157,6 +157,7 @@ \ No newline at end of file diff --git a/pages/user/tui-guang.vue b/pages/user/tui-guang.vue index 73ca99c..982d59a 100644 --- a/pages/user/tui-guang.vue +++ b/pages/user/tui-guang.vue @@ -119,380 +119,357 @@ \ No newline at end of file