From 78b3b094899b7653128ff9dbd480b486a0677422 Mon Sep 17 00:00:00 2001 From: linju <8432241+linjuDcloud@user.noreply.gitee.com> Date: Tue, 20 Apr 2021 22:30:19 +0800 Subject: [PATCH] 123 --- baseapp.config.js | 4 +- common/appInit.js | 10 +- pages/ucenter/ucenter.vue | 95 ++++++++++--------- .../utils/check-update.js | 9 +- 4 files changed, 62 insertions(+), 56 deletions(-) diff --git a/baseapp.config.js b/baseapp.config.js index ccb2ffd..d04ae80 100644 --- a/baseapp.config.js +++ b/baseapp.config.js @@ -1,6 +1,6 @@ module.exports = { "h5":{ - "url":"https://static-76ce2c5e-31c7-4d81-8fcf-ed1541ecbc6e.bspapp.com" + "url":"https://static-76ce2c5e-31c7-4d81-8fcf-ed1541ecbc6e.bspapp.com" // 前端网页托管的域名 }, "mp":{ "weixin":{ @@ -13,7 +13,7 @@ module.exports = { "/pages/ucenter/settings/settings", "/uni_modules/uni-login-page/pages/index/pwd-retrieve" ], - "login":["univerify","password","weixin","apple","code"] + "login":["univerify","smsCode","username","weixin","apple"] //默认就是短信验证码登陆 }, "about":{ "appName":"base-app", diff --git a/common/appInit.js b/common/appInit.js index 4dece03..afb7c3f 100644 --- a/common/appInit.js +++ b/common/appInit.js @@ -48,12 +48,12 @@ export default function() { } //控制登陆优先级 if(url=='/uni_modules/uni-login-page/pages/index/index'){ - //一键登录(univerify)、密码登陆(password)、快捷登录&验证码登陆(!univerify&password) + //一键登录(univerify)、密码登陆(username)、快捷登录&验证码登陆(!univerify&password) if(login[0]=='univerify'){ // console.log(e.url,url); if(e.url==url){ e.url+= '?' } e.url += "univerify_first=true" - }else if(login[0]=='password'){ + }else if(login[0]=='username'){ e.url = "/uni_modules/uni-login-page/pages/pwd-login/pwd-login" }else{ //默认即是 @@ -120,11 +120,11 @@ function initAppVersion() { }).appVersion = { ...currentVersion, appid, - hasNew:true + hasNew:false } // 检查更新小红点 - callCheckVersion() - .then(res=>{ + callCheckVersion().then(res=>{ + console.log('检查是否有可以更新的版本',res); if(res.result.code>0){ // 有新版本 getApp({ diff --git a/pages/ucenter/ucenter.vue b/pages/ucenter/ucenter.vue index 7200b16..a4ffd32 100644 --- a/pages/ucenter/ucenter.vue +++ b/pages/ucenter/ucenter.vue @@ -3,7 +3,7 @@ - {{login ? userInfo.username||userInfo.mobile : '未登录'}} + {{login ? userInfo.nickname||userInfo.username||userInfo.mobile : '未登录'}} @@ -30,7 +30,8 @@ mapGetters, mapMutations } from 'vuex'; - import checkUpdate from '@/uni_modules/uni-upgrade-center-app/utils/check-update'; + import checkUpdate from '@/uni_modules/uni-upgrade-center-app/utils/check-update'; + import callCheckVersion from '@/uni_modules/uni-upgrade-center-app/utils/call-check-version'; export default { data() { return { @@ -57,53 +58,56 @@ } ], ucenterList: [ + [ + // #ifdef APP-PLUS + { + title: '去评分', + event: 'gotoMarket' + }, + // #endif + { + title: '阅读过的文章', + to: '' + }, { + title: '我的积分', + to: '' + }], [{ - title: '阅读过的文章', - to: '' + title: '问题与反馈', + to: '/uni_modules/uni-feedback/pages/opendb-feedback/list' // /pages/ucenter/uni-feedback/uni-feedback uni_modules/uni-feedback/pages/opendb-feedback/list }, { - title: '我的积分', - to: '' - }], - [ - //#ifdef APP-PLUS - { - title: '检查更新', - rightText: `V${getApp().appVersion.version}_${getApp().appVersion.versionCode}`, - event: 'checkVersion', - showBadge: true - }, - { - title:'去评分', - event:'gotoMarket' - }, - //#endif - { - title: '问题与反馈', - to: '/uni_modules/uni-feedback/pages/opendb-feedback/list' // /pages/ucenter/uni-feedback/uni-feedback uni_modules/uni-feedback/pages/opendb-feedback/list - },{ - title: '关于', - to: '/pages/ucenter/about/about' - } - ] + title: '关于', + to: '/pages/ucenter/about/about' + }] ] } }, + onLoad() { + this.ucenterList[this.ucenterList.length - 1].unshift( + { + title: '检查更新', + rightText: this.appVersion.version+'-'+this.appVersion.versionCode, + event: 'checkVersion', + showBadge: this.appVersion.hasNew + } + ) + }, computed: { ...mapGetters({ userInfo: 'user/info', login: 'user/hasLogin' - }) - }, - onReady() { - + }), + appVersion() { + return getApp().appVersion + } }, methods: { ...mapMutations({ logout: 'user/logout' }), - toSettings(){ + toSettings() { uni.navigateTo({ - url:"/pages/ucenter/settings/settings" + url: "/pages/ucenter/settings/settings" }) }, /** @@ -114,8 +118,9 @@ this[item.event](); } }, - checkVersion() { - checkUpdate(); + async checkVersion() { + console.log(await callCheckVersion()); + checkUpdate() }, goLogin() { if (!this.login) { @@ -132,27 +137,27 @@ }, tapGrid(index) { uni.showToast({ - title: '你点击了,第' + (index+1) + '个', + title: '你点击了,第' + (index + 1) + '个', icon: 'none' }); }, /** * 去应用市场评分 */ - gotoMarket(){ + gotoMarket() { // #ifdef APP-PLUS if (uni.getSystemInfoSync().platform == "ios") { // 这里填写appstore应用id let appstoreid = 'id1417078253'; - plus.runtime.openURL("itms-apps://" + 'itunes.apple.com/cn/app/wechat/'+appstoreid+'?mt=8'); + plus.runtime.openURL("itms-apps://" + 'itunes.apple.com/cn/app/wechat/' + appstoreid + '?mt=8'); } if (uni.getSystemInfoSync().platform == "android") { var Uri = plus.android.importClass("android.net.Uri"); - var uri = Uri.parse("market://details?id=" + plus.runtime.appid ); - var Intent = plus.android.importClass('android.content.Intent'); - var intent = new Intent(Intent.ACTION_VIEW, uri); - var main = plus.android.runtimeMainActivity(); - main.startActivity(intent); + var uri = Uri.parse("market://details?id=" + plus.runtime.appid); + var Intent = plus.android.importClass('android.content.Intent'); + var intent = new Intent(Intent.ACTION_VIEW, uri); + var main = plus.android.runtimeMainActivity(); + main.startActivity(intent); } // #endif } @@ -299,4 +304,4 @@ /* #endif */ background-color: #DD524D; } - + diff --git a/uni_modules/uni-upgrade-center-app/utils/check-update.js b/uni_modules/uni-upgrade-center-app/utils/check-update.js index 46f69f1..dcb5027 100644 --- a/uni_modules/uni-upgrade-center-app/utils/check-update.js +++ b/uni_modules/uni-upgrade-center-app/utils/check-update.js @@ -5,9 +5,8 @@ const PACKAGE_INFO_KEY = '__package_info__' export default function() { - return // #ifdef APP-PLUS - callCheckVersion().then(async (e) => { + callCheckVersion().then(async (e) => { if (!e.result) return; const { code, @@ -17,7 +16,7 @@ export default function() { platform, // 安装包平台 type // 安装包类型 } = e.result; - + // 此处逻辑仅为实例,可自行编写 if (code > 0) { // 腾讯云和阿里云下载链接不同,需要处理一下,阿里云会原样返回 @@ -65,7 +64,9 @@ export default function() { } else if (code < 0) { // TODO 云函数报错处理 console.error(message) - } + } + + }).catch(err => { // TODO 云函数报错处理 console.error(err.message) -- GitLab