Commit 72064277 by 李伟康

Merge branch 'SAAS+V4.44' into SAAS+V4.44.1

2 parents 961d5788 37ba75e4
...@@ -31,15 +31,17 @@ ...@@ -31,15 +31,17 @@
import checkUpdate from "@/uni_modules/uni-upgrade-center-app/utils/check-update-nvue.js"; import checkUpdate from "@/uni_modules/uni-upgrade-center-app/utils/check-update-nvue.js";
export default { export default {
name: 'SettingBox', name: 'SettingBox',
data () { data() {
return { return {
version: '', version: '',
deviceId:'' deviceId: ''
} }
}, },
mounted () { mounted() {
this.version = plus?.runtime?.version || '1.0.0' this.version = plus?.runtime?.version || '1.0.0'
const {deviceId} = uni.getDeviceInfo() const {
deviceId
} = uni.getDeviceInfo()
this.deviceId = deviceId this.deviceId = deviceId
}, },
methods: { methods: {
...@@ -54,44 +56,84 @@ export default { ...@@ -54,44 +56,84 @@ export default {
} }
}); });
}, },
/** 比较版本号的大小
**/
compareVersions(version1, version2) {
const v1 = version1.split('.').map(v => +v) // 转化成数字数组
const v2 = version2.split('.').map(v => +v)
const b1 = v1.every(v => !isNaN(v)) // 判断数组的每一项是否是数字
const b2 = v2.every(v => !isNaN(v)) // 如果不是则返回错误信息
if (!b1 || !b2) return '版本号错误,只能包含数字、.'
const len = Math.max(v1.length, v2.length)
for (let i = 0; i < len; i++) {
const num1 = v1[i] || 0
const num2 = v2[i] || 0
if (num1 > num2) return 1 // 如果版本号1大于版本号2,则输出1
if (num1 < num2) return -1 // 反之则输出 -1
}
// 如果版本号1 等于版本号2,则输出0
return 0
},
async handleCheck() { async handleCheck() {
try { const {
await checkUpdate() textList,
this.close() tempFileURL,
} catch (error) { version
} = uni.$storage.get('mock_data')
const res = this.compareVersions(this.version,version)
if(res > -1) {
uni.showToast({ uni.showToast({
title: '目前已是最新版本', title: '目前已是最新版本',
duration: 2000, duration: 2000,
icon: 'none' icon: 'none'
}); });
return
} }
this.close()
const e = {
result: {
"is_silently": false,
"is_mandatory": true,
"name": "",
"title": "",
"contents": textList.join('\n'),
"version": version,
"url": tempFileURL,
"stable_publish": true,
},
}
checkUpdate(e)
}, },
open () { open() {
this.$refs.popup.open("center"); this.$refs.popup.open("center");
}, },
close () { close() {
this.$refs.popup.close() this.$refs.popup.close()
}, },
changeAccount () { changeAccount() {
uni.reLaunch({ uni.reLaunch({
url: '/pages/common/accountItems' url: '/pages/common/accountItems'
}) })
}, },
// 退出 // 退出
logout () { logout() {
let _this = this let _this = this
uni.showModal({ uni.showModal({
title: '温馨提示', title: '温馨提示',
content: '是否退出当前账号?', content: '是否退出当前账号?',
confirmColor: '#347BFF', confirmColor: '#347BFF',
async success (res) { async success(res) {
if (res.confirm) { if (res.confirm) {
_this.$emit('stopAudio') _this.$emit('stopAudio')
try { try {
uni.showLoading({ uni.showLoading({
mask: true mask: true
}) })
const { code, message } = await uni.$api.userApi.logout(), const {
code,
message
} = await uni.$api.userApi.logout(),
userInfo = uni.$storage.get("userInfo") userInfo = uni.$storage.get("userInfo")
console.log(code) console.log(code)
if (code == 0) { if (code == 0) {
...@@ -117,8 +159,9 @@ export default { ...@@ -117,8 +159,9 @@ export default {
} }
}) })
}, },
jump (type) { jump(type) {
let url = type == 'icp' ? 'https://beian.miit.gov.cn/' : 'https://img01.glsx.com.cn/weapp/resource/saas/app/privacy.html' let url = type == 'icp' ? 'https://beian.miit.gov.cn/' :
'https://img01.glsx.com.cn/weapp/resource/saas/app/privacy.html'
uni.navigateTo({ uni.navigateTo({
url: `/pages/common/webview?url=${url}` url: `/pages/common/webview?url=${url}`
}) })
...@@ -139,6 +182,7 @@ export default { ...@@ -139,6 +182,7 @@ export default {
align-items: center; align-items: center;
justify-content: center; justify-content: center;
flex-direction: column; flex-direction: column;
.close { .close {
position: absolute; position: absolute;
width: 120rpx; width: 120rpx;
...@@ -147,20 +191,24 @@ export default { ...@@ -147,20 +191,24 @@ export default {
right: 0; right: 0;
justify-content: center; justify-content: center;
} }
.app-info { .app-info {
flex-direction: column; flex-direction: column;
font-size: 32rpx; font-size: 32rpx;
color: #333333; color: #333333;
.sprite-icon { .sprite-icon {
margin-bottom: 12rpx; margin-bottom: 12rpx;
box-shadow: 0 0 24rpx 0 #3682ef33; box-shadow: 0 0 24rpx 0 #3682ef33;
border-radius: 40rpx; border-radius: 40rpx;
} }
.version { .version {
margin-top: 8rpx; margin-top: 8rpx;
font-size: 24rpx; font-size: 24rpx;
color: #999999; color: #999999;
} }
.check-box { .check-box {
width: 120rpx; width: 120rpx;
padding: 10rpx 0rpx 4rpx; padding: 10rpx 0rpx 4rpx;
...@@ -173,8 +221,10 @@ export default { ...@@ -173,8 +221,10 @@ export default {
box-sizing: border-box; box-sizing: border-box;
} }
} }
.btn-box { .btn-box {
margin-top: 120rpx; margin-top: 120rpx;
.btn { .btn {
width: 384rpx; width: 384rpx;
height: 64rpx; height: 64rpx;
...@@ -186,25 +236,30 @@ export default { ...@@ -186,25 +236,30 @@ export default {
color: #3b73ff; color: #3b73ff;
margin-bottom: 16rpx; margin-bottom: 16rpx;
} }
.logout { .logout {
background: #ffffff; background: #ffffff;
color: #333333; color: #333333;
border: 2rpx solid #e8e8e8; border: 2rpx solid #e8e8e8;
} }
} }
.a { .a {
font-size: 24rpx; font-size: 24rpx;
color: #2c66f7; color: #2c66f7;
margin: 48rpx 0 16rpx; margin: 48rpx 0 16rpx;
} }
.icp { .icp {
font-size: 24rpx; font-size: 24rpx;
color: #999999; color: #999999;
} }
.app-code { .app-code {
font-size: 24rpx; font-size: 24rpx;
color: #999999; color: #999999;
line-height: 40rpx; line-height: 40rpx;
.icon-clone { .icon-clone {
width: 24rpx; width: 24rpx;
height: 24rpx; height: 24rpx;
......
...@@ -130,10 +130,6 @@ export default { ...@@ -130,10 +130,6 @@ export default {
setTimeout(() => { setTimeout(() => {
this.scrollTop = 0 this.scrollTop = 0
}, 100); }, 100);
}
},
show (n) {
if (n) {
const { storageKey } = this, const { storageKey } = this,
insuranceList = uni.getStorageSync(storageKey) insuranceList = uni.getStorageSync(storageKey)
if (insuranceList) { if (insuranceList) {
...@@ -141,6 +137,11 @@ export default { ...@@ -141,6 +137,11 @@ export default {
this.insuranceList = JSON.parse(JSON.stringify(insuranceList)) this.insuranceList = JSON.parse(JSON.stringify(insuranceList))
this.flag = true this.flag = true
} }
}
},
show (n) {
if (n) {
this.getMerchantInsuranceList() this.getMerchantInsuranceList()
} }
}, },
...@@ -258,8 +259,8 @@ export default { ...@@ -258,8 +259,8 @@ export default {
return processedString return processedString
}, },
choose(item, index) { choose (item, index) {
if(this.isPreview) return if (this.isPreview) return
this.insuranceList[index].checked = !item.checked this.insuranceList[index].checked = !item.checked
}, },
} }
......
function callCheckVersion() {
// #ifdef APP-PLUS
return new Promise((resolve, reject) => {
plus.runtime.getProperty(plus.runtime.appid, function(widgetInfo) {
let data = {
action: 'checkVersion',
appid: plus.runtime.appid,
appVersion: plus.runtime.version,
wgtVersion: widgetInfo.version
}
uniCloud.callFunction({
name: 'uni-upgrade-center',
data,
success: (e) => {
resolve(e)
},
fail: (error) => {
reject(error)
}
})
})
})
// #endif
// #ifndef APP-PLUS
return new Promise((resolve, reject) => {})
// #endif
}
// 推荐再App.vue中使用 // 推荐再App.vue中使用
const PACKAGE_INFO_KEY = '__package_info__' const PACKAGE_INFO_KEY = '__package_info__'
export default function() { export default function (e) {
// #ifdef APP-PLUS // #ifdef APP-PLUS
return new Promise((resolve, reject) => {
callCheckVersion().then(async (e) => {
if (!e.result) return;
const {
code,
message,
is_silently, // 是否静默更新
url, // 安装包下载地址
platform, // 安装包平台
type // 安装包类型
} = e.result;
// 此处逻辑仅为实例,可自行编写
if (code > 0) {
// 腾讯云和阿里云下载链接不同,需要处理一下,阿里云会原样返回
const {
fileList
} = await uniCloud.getTempFileURL({
fileList: [url]
});
if (fileList[0].tempFileURL)
e.result.url = fileList[0].tempFileURL;
resolve(e)
// 静默更新,只有wgt有
if (is_silently) {
uni.downloadFile({
url: e.result.url,
success: res => {
if (res.statusCode == 200) {
// 下载好直接安装,下次启动生效
plus.runtime.install(res.tempFilePath, {
force: false
});
}
}
});
return;
}
/**
* 提示升级一
* 使用 uni.showModal
*/
// return updateUseModal(e.result)
/**
* 提示升级二
* 官方适配的升级弹窗,可自行替换资源适配UI风格
*/
uni.setStorageSync(PACKAGE_INFO_KEY, e.result) uni.setStorageSync(PACKAGE_INFO_KEY, e.result)
uni.navigateTo({ uni.navigateTo({
url: `/uni_modules/uni-upgrade-center-app/pages/upgrade-popup?local_storage_key=${PACKAGE_INFO_KEY}`, url: `/uni_modules/uni-upgrade-center-app/pages/upgrade-popup?local_storage_key=${PACKAGE_INFO_KEY}`,
fail: (err) => { fail: err => {
console.error('更新弹框跳转失败', err) console.error('更新弹框跳转失败', err)
uni.removeStorageSync(PACKAGE_INFO_KEY) uni.removeStorageSync(PACKAGE_INFO_KEY)
} }
}) })
return
} else if (code < 0) {
// TODO 云函数报错处理
console.error(message)
return reject(e)
}
return resolve(e)
}).catch(err => {
// TODO 云函数报错处理
console.error(err.message)
reject(err)
})
});
// #endif // #endif
} }
...@@ -118,10 +26,10 @@ function updateUseModal(packageInfo) { ...@@ -118,10 +26,10 @@ function updateUseModal(packageInfo) {
url, // 安装包下载地址 url, // 安装包下载地址
platform, // 安装包平台 platform, // 安装包平台
type // 安装包类型 type // 安装包类型
} = packageInfo; } = packageInfo
let isWGT = type === 'wgt' let isWGT = type === 'wgt'
let isiOS = !isWGT ? platform.includes('iOS') : false; let isiOS = !isWGT ? platform.includes('iOS') : false
let confirmText = isiOS ? '立即跳转更新' : '立即下载更新' let confirmText = isiOS ? '立即跳转更新' : '立即下载更新'
return uni.showModal({ return uni.showModal({
...@@ -130,55 +38,59 @@ function updateUseModal(packageInfo) { ...@@ -130,55 +38,59 @@ function updateUseModal(packageInfo) {
showCancel: !is_mandatory, showCancel: !is_mandatory,
confirmText, confirmText,
success: res => { success: res => {
if (res.cancel) return; if (res.cancel) return
// 安装包下载 // 安装包下载
if (isiOS) { if (isiOS) {
plus.runtime.openURL(url); plus.runtime.openURL(url)
return; return
} }
uni.showToast({ uni.showToast({
title: '后台下载中……', title: '后台下载中……',
duration: 1000 duration: 1000
}); })
// wgt 和 安卓下载更新 // wgt 和 安卓下载更新
downloadTask = uni.downloadFile({ downloadTask = uni.downloadFile({
url, url,
success: res => { success: res => {
if (res.statusCode !== 200) { if (res.statusCode !== 200) {
console.error('下载安装包失败', err); console.error('下载安装包失败', err)
return; return
} }
// 下载好直接安装,下次启动生效 // 下载好直接安装,下次启动生效
plus.runtime.install(res.tempFilePath, { plus.runtime.install(
res.tempFilePath,
{
force: false force: false
}, () => { },
() => {
if (is_mandatory) { if (is_mandatory) {
//更新完重启app //更新完重启app
plus.runtime.restart(); plus.runtime.restart()
return; return
} }
uni.showModal({ uni.showModal({
title: '安装成功是否重启?', title: '安装成功是否重启?',
success: res => { success: res => {
if (res.confirm) { if (res.confirm) {
//更新完重启app //更新完重启app
plus.runtime.restart(); plus.runtime.restart()
} }
} }
}); })
}, err => { },
err => {
uni.showModal({ uni.showModal({
title: '更新失败', title: '更新失败',
content: err content: err.message,
.message,
showCancel: false showCancel: false
}); })
});
} }
}); )
} }
}); })
}
})
} }
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!