|
@@ -17,6 +17,7 @@
|
|
|
<u-cell-group>
|
|
|
<u-cell-item icon="file-text" icon-size="40" :icon-style="{color:'#ffaa00'}" index="0" @click="toPage" title="服务协议及隐私政策"></u-cell-item>
|
|
|
<u-cell-item v-if="hasLogin" icon="lock" icon-size="38" :icon-style="{color:'#00aaff'}" index="1" @click="toPage" title="修改密码"></u-cell-item>
|
|
|
+ <u-cell-item icon="error-circle" icon-size="38" :icon-style="{color:'#aaaaff'}" :value="version" @click="checkUpdate" title="版本检查"></u-cell-item>
|
|
|
</u-cell-group>
|
|
|
</view>
|
|
|
<view class="user-list quit">
|
|
@@ -34,6 +35,7 @@
|
|
|
return {
|
|
|
hasLogin: false,
|
|
|
userData: {},
|
|
|
+ version: '' // 小程序版本
|
|
|
};
|
|
|
},
|
|
|
onShow() {
|
|
@@ -55,6 +57,7 @@
|
|
|
}
|
|
|
},
|
|
|
onLoad() {
|
|
|
+ this.getVersion()
|
|
|
// 开启分享
|
|
|
uni.showShareMenu({
|
|
|
withShareTicket: true,
|
|
@@ -62,6 +65,46 @@
|
|
|
})
|
|
|
},
|
|
|
methods:{
|
|
|
+ // 获取当前小程序版本
|
|
|
+ getVersion(){
|
|
|
+ const accountInfo = uni.getAccountInfoSync();
|
|
|
+ this.version = accountInfo.miniProgram.version
|
|
|
+ // console.log(accountInfo,accountInfo.miniProgram.appId,'ppppppppp'); // 小程序 appId
|
|
|
+ },
|
|
|
+ // 检查更新
|
|
|
+ checkUpdate(){
|
|
|
+ if (uni.canIUse('getUpdateManager')) {
|
|
|
+ const updateManager = uni.getUpdateManager()
|
|
|
+ updateManager.onCheckForUpdate(function (res) {
|
|
|
+ console.log('onCheckForUpdate====', res)
|
|
|
+ // 请求完新版本信息的回调
|
|
|
+ if (res.hasUpdate) {
|
|
|
+ console.log('res.hasUpdate====')
|
|
|
+ updateManager.onUpdateReady(function () {
|
|
|
+ uni.showModal({
|
|
|
+ title: '更新提示',
|
|
|
+ content: '新版本已经准备好,是否重启应用?',
|
|
|
+ success: function (res) {
|
|
|
+ console.log('success====', res)
|
|
|
+ // res: {errMsg: "showModal: ok", cancel: false, confirm: true}
|
|
|
+ if (res.confirm) {
|
|
|
+ // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
|
|
|
+ updateManager.applyUpdate()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ })
|
|
|
+ updateManager.onUpdateFailed(function () {
|
|
|
+ // 新的版本下载失败
|
|
|
+ uni.showModal({
|
|
|
+ title: '已经有新版本了哟~',
|
|
|
+ content: '新版本已经上线啦~,请您删除当前小程序,重新搜索打开哟~'
|
|
|
+ })
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
// 获取用户信息
|
|
|
getUserInfo(){
|
|
|
getUserInfo().then(res => {
|