Commit 72064277 by 李伟康

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

2 parents 961d5788 37ba75e4
...@@ -59,4 +59,4 @@ ...@@ -59,4 +59,4 @@
.icon-tool-finish { width: 60rpx; height: 60rpx; background-position: -526rpx -964rpx;} .icon-tool-finish { width: 60rpx; height: 60rpx; background-position: -526rpx -964rpx;}
.icon-tool-pay { width: 60rpx; height: 60rpx; background-position: -601rpx -964rpx;} .icon-tool-pay { width: 60rpx; height: 60rpx; background-position: -601rpx -964rpx;}
.icon-total { width: 32rpx; height: 32rpx; background-position: -664rpx -853rpx;} .icon-total { width: 32rpx; height: 32rpx; background-position: -664rpx -853rpx;}
.icon-visible { width: 40rpx; height: 40rpx; background-position: -1105rpx -668rpx;}
\ No newline at end of file \ No newline at end of file
.icon-visible { width: 40rpx; height: 40rpx; background-position: -1105rpx -668rpx;}
...@@ -30,100 +30,143 @@ ...@@ -30,100 +30,143 @@
<script type="text/ecmascript-6"> <script type="text/ecmascript-6">
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 {
this.deviceId = deviceId deviceId
}, } = uni.getDeviceInfo()
methods: { this.deviceId = deviceId
copyText() { },
uni.setClipboardData({ methods: {
data: this.deviceId, copyText() {
success: function() { uni.setClipboardData({
uni.showToast({ data: this.deviceId,
title: '复制成功', success: function() {
icon: 'success' uni.showToast({
}); title: '复制成功',
} icon: 'success'
}); });
}, }
async handleCheck() { });
try { },
await checkUpdate() /** 比较版本号的大小
this.close() **/
} catch (error) { 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() {
const {
textList,
tempFileURL,
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
}, }
open () { this.close()
this.$refs.popup.open("center"); const e = {
}, result: {
close () { "is_silently": false,
this.$refs.popup.close() "is_mandatory": true,
}, "name": "",
changeAccount () { "title": "",
uni.reLaunch({ "contents": textList.join('\n'),
url: '/pages/common/accountItems' "version": version,
}) "url": tempFileURL,
}, "stable_publish": true,
// 退出 },
logout () { }
let _this = this checkUpdate(e)
uni.showModal({ },
title: '温馨提示', open() {
content: '是否退出当前账号?', this.$refs.popup.open("center");
confirmColor: '#347BFF', },
async success (res) { close() {
if (res.confirm) { this.$refs.popup.close()
_this.$emit('stopAudio') },
try { changeAccount() {
uni.showLoading({ uni.reLaunch({
mask: true url: '/pages/common/accountItems'
}) })
const { code, message } = await uni.$api.userApi.logout(), },
userInfo = uni.$storage.get("userInfo") // 退出
console.log(code) logout() {
if (code == 0) { let _this = this
uni.$storage.rm("userInfo"); uni.showModal({
uni.$storage.rm("sessionId"); title: '温馨提示',
uni.$storage.rm("noSignInUuid"); content: '是否退出当前账号?',
setTimeout(() => { confirmColor: '#347BFF',
uni.hideLoading() async success(res) {
uni.reLaunch({ if (res.confirm) {
url: `/pages/common/login?mobile=${userInfo.phone}`, _this.$emit('stopAudio')
}); try {
}, 500) uni.showLoading({
} else throw message mask: true
} catch (error) { })
console.log(error) const {
uni.hideLoading() code,
uni.showToast({ message
title: error, } = await uni.$api.userApi.logout(),
icon: "none", userInfo = uni.$storage.get("userInfo")
}); console.log(code)
} if (code == 0) {
} uni.$storage.rm("userInfo");
} uni.$storage.rm("sessionId");
}) uni.$storage.rm("noSignInUuid");
}, setTimeout(() => {
jump (type) { uni.hideLoading()
let url = type == 'icp' ? 'https://beian.miit.gov.cn/' : 'https://img01.glsx.com.cn/weapp/resource/saas/app/privacy.html' uni.reLaunch({
uni.navigateTo({ url: `/pages/common/login?mobile=${userInfo.phone}`,
url: `/pages/common/webview?url=${url}` });
}) }, 500)
} } else throw message
} } catch (error) {
console.log(error)
uni.hideLoading()
uni.showToast({
title: error,
icon: "none",
});
}
}
}
})
},
jump(type) {
let url = type == 'icp' ? 'https://beian.miit.gov.cn/' :
'https://img01.glsx.com.cn/weapp/resource/saas/app/privacy.html'
uni.navigateTo({
url: `/pages/common/webview?url=${url}`
})
}
}
} }
</script> </script>
...@@ -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) => { uni.setStorageSync(PACKAGE_INFO_KEY, e.result)
callCheckVersion().then(async (e) => { uni.navigateTo({
if (!e.result) return; url: `/uni_modules/uni-upgrade-center-app/pages/upgrade-popup?local_storage_key=${PACKAGE_INFO_KEY}`,
const { fail: err => {
code, console.error('更新弹框跳转失败', err)
message, uni.removeStorageSync(PACKAGE_INFO_KEY)
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)
/** // #endif
* 提示升级二
* 官方适配的升级弹窗,可自行替换资源适配UI风格
*/
uni.setStorageSync(PACKAGE_INFO_KEY, e.result)
uni.navigateTo({
url: `/uni_modules/uni-upgrade-center-app/pages/upgrade-popup?local_storage_key=${PACKAGE_INFO_KEY}`,
fail: (err) => {
console.error('更新弹框跳转失败', err)
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
} }
/** /**
* 使用 uni.showModal 升级 * 使用 uni.showModal 升级
*/ */
function updateUseModal(packageInfo) { function updateUseModal(packageInfo) {
const { const {
title, // 标题 title, // 标题
contents, // 升级内容 contents, // 升级内容
is_mandatory, // 是否强制更新 is_mandatory, // 是否强制更新
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({
title, title,
content: contents, content: contents,
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(
force: false res.tempFilePath,
}, () => { {
if (is_mandatory) { force: false
//更新完重启app },
plus.runtime.restart(); () => {
return; if (is_mandatory) {
} //更新完重启app
uni.showModal({ plus.runtime.restart()
title: '安装成功是否重启?', return
success: res => { }
if (res.confirm) { uni.showModal({
//更新完重启app title: '安装成功是否重启?',
plus.runtime.restart(); success: res => {
} if (res.confirm) {
} //更新完重启app
}); plus.runtime.restart()
}, err => { }
uni.showModal({ }
title: '更新失败', })
content: err },
.message, err => {
showCancel: false uni.showModal({
}); title: '更新失败',
}); content: err.message,
} showCancel: false
}); })
} }
}); )
}
})
}
})
} }
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!