Commit 72064277 by 李伟康

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

2 parents 961d5788 37ba75e4
......@@ -59,4 +59,4 @@
.icon-tool-finish { width: 60rpx; height: 60rpx; background-position: -526rpx -964rpx;}
.icon-tool-pay { width: 60rpx; height: 60rpx; background-position: -601rpx -964rpx;}
.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
.icon-visible { width: 40rpx; height: 40rpx; background-position: -1105rpx -668rpx;}
......@@ -30,100 +30,143 @@
<script type="text/ecmascript-6">
import checkUpdate from "@/uni_modules/uni-upgrade-center-app/utils/check-update-nvue.js";
export default {
name: 'SettingBox',
data () {
return {
version: '',
deviceId:''
}
},
mounted () {
this.version = plus?.runtime?.version || '1.0.0'
const {deviceId} = uni.getDeviceInfo()
this.deviceId = deviceId
},
methods: {
copyText() {
uni.setClipboardData({
data: this.deviceId,
success: function() {
uni.showToast({
title: '复制成功',
icon: 'success'
});
}
});
},
async handleCheck() {
try {
await checkUpdate()
this.close()
} catch (error) {
name: 'SettingBox',
data() {
return {
version: '',
deviceId: ''
}
},
mounted() {
this.version = plus?.runtime?.version || '1.0.0'
const {
deviceId
} = uni.getDeviceInfo()
this.deviceId = deviceId
},
methods: {
copyText() {
uni.setClipboardData({
data: this.deviceId,
success: function() {
uni.showToast({
title: '复制成功',
icon: 'success'
});
}
});
},
/** 比较版本号的大小
**/
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({
title: '目前已是最新版本',
duration: 2000,
icon: 'none'
});
}
},
open () {
this.$refs.popup.open("center");
},
close () {
this.$refs.popup.close()
},
changeAccount () {
uni.reLaunch({
url: '/pages/common/accountItems'
})
},
// 退出
logout () {
let _this = this
uni.showModal({
title: '温馨提示',
content: '是否退出当前账号?',
confirmColor: '#347BFF',
async success (res) {
if (res.confirm) {
_this.$emit('stopAudio')
try {
uni.showLoading({
mask: true
})
const { code, message } = await uni.$api.userApi.logout(),
userInfo = uni.$storage.get("userInfo")
console.log(code)
if (code == 0) {
uni.$storage.rm("userInfo");
uni.$storage.rm("sessionId");
uni.$storage.rm("noSignInUuid");
setTimeout(() => {
uni.hideLoading()
uni.reLaunch({
url: `/pages/common/login?mobile=${userInfo.phone}`,
});
}, 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}`
})
}
}
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() {
this.$refs.popup.open("center");
},
close() {
this.$refs.popup.close()
},
changeAccount() {
uni.reLaunch({
url: '/pages/common/accountItems'
})
},
// 退出
logout() {
let _this = this
uni.showModal({
title: '温馨提示',
content: '是否退出当前账号?',
confirmColor: '#347BFF',
async success(res) {
if (res.confirm) {
_this.$emit('stopAudio')
try {
uni.showLoading({
mask: true
})
const {
code,
message
} = await uni.$api.userApi.logout(),
userInfo = uni.$storage.get("userInfo")
console.log(code)
if (code == 0) {
uni.$storage.rm("userInfo");
uni.$storage.rm("sessionId");
uni.$storage.rm("noSignInUuid");
setTimeout(() => {
uni.hideLoading()
uni.reLaunch({
url: `/pages/common/login?mobile=${userInfo.phone}`,
});
}, 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>
......@@ -139,6 +182,7 @@ export default {
align-items: center;
justify-content: center;
flex-direction: column;
.close {
position: absolute;
width: 120rpx;
......@@ -147,20 +191,24 @@ export default {
right: 0;
justify-content: center;
}
.app-info {
flex-direction: column;
font-size: 32rpx;
color: #333333;
.sprite-icon {
margin-bottom: 12rpx;
box-shadow: 0 0 24rpx 0 #3682ef33;
border-radius: 40rpx;
}
.version {
margin-top: 8rpx;
font-size: 24rpx;
color: #999999;
}
.check-box {
width: 120rpx;
padding: 10rpx 0rpx 4rpx;
......@@ -173,8 +221,10 @@ export default {
box-sizing: border-box;
}
}
.btn-box {
margin-top: 120rpx;
.btn {
width: 384rpx;
height: 64rpx;
......@@ -186,25 +236,30 @@ export default {
color: #3b73ff;
margin-bottom: 16rpx;
}
.logout {
background: #ffffff;
color: #333333;
border: 2rpx solid #e8e8e8;
}
}
.a {
font-size: 24rpx;
color: #2c66f7;
margin: 48rpx 0 16rpx;
}
.icp {
font-size: 24rpx;
color: #999999;
}
.app-code {
font-size: 24rpx;
color: #999999;
line-height: 40rpx;
.icon-clone {
width: 24rpx;
height: 24rpx;
......
......@@ -130,10 +130,6 @@ export default {
setTimeout(() => {
this.scrollTop = 0
}, 100);
}
},
show (n) {
if (n) {
const { storageKey } = this,
insuranceList = uni.getStorageSync(storageKey)
if (insuranceList) {
......@@ -141,6 +137,11 @@ export default {
this.insuranceList = JSON.parse(JSON.stringify(insuranceList))
this.flag = true
}
}
},
show (n) {
if (n) {
this.getMerchantInsuranceList()
}
},
......@@ -258,8 +259,8 @@ export default {
return processedString
},
choose(item, index) {
if(this.isPreview) return
choose (item, index) {
if (this.isPreview) return
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中使用
const PACKAGE_INFO_KEY = '__package_info__'
export default function() {
// #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)
export default function (e) {
// #ifdef APP-PLUS
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)
}
})
/**
* 提示升级二
* 官方适配的升级弹窗,可自行替换资源适配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
// #endif
}
/**
* 使用 uni.showModal 升级
*/
function updateUseModal(packageInfo) {
const {
title, // 标题
contents, // 升级内容
is_mandatory, // 是否强制更新
url, // 安装包下载地址
platform, // 安装包平台
type // 安装包类型
} = packageInfo;
const {
title, // 标题
contents, // 升级内容
is_mandatory, // 是否强制更新
url, // 安装包下载地址
platform, // 安装包平台
type // 安装包类型
} = packageInfo
let isWGT = type === 'wgt'
let isiOS = !isWGT ? platform.includes('iOS') : false;
let confirmText = isiOS ? '立即跳转更新' : '立即下载更新'
let isWGT = type === 'wgt'
let isiOS = !isWGT ? platform.includes('iOS') : false
let confirmText = isiOS ? '立即跳转更新' : '立即下载更新'
return uni.showModal({
title,
content: contents,
showCancel: !is_mandatory,
confirmText,
success: res => {
if (res.cancel) return;
return uni.showModal({
title,
content: contents,
showCancel: !is_mandatory,
confirmText,
success: res => {
if (res.cancel) return
// 安装包下载
if (isiOS) {
plus.runtime.openURL(url);
return;
}
// 安装包下载
if (isiOS) {
plus.runtime.openURL(url)
return
}
uni.showToast({
title: '后台下载中……',
duration: 1000
});
uni.showToast({
title: '后台下载中……',
duration: 1000
})
// wgt 和 安卓下载更新
downloadTask = uni.downloadFile({
url,
success: res => {
if (res.statusCode !== 200) {
console.error('下载安装包失败', err);
return;
}
// 下载好直接安装,下次启动生效
plus.runtime.install(res.tempFilePath, {
force: false
}, () => {
if (is_mandatory) {
//更新完重启app
plus.runtime.restart();
return;
}
uni.showModal({
title: '安装成功是否重启?',
success: res => {
if (res.confirm) {
//更新完重启app
plus.runtime.restart();
}
}
});
}, err => {
uni.showModal({
title: '更新失败',
content: err
.message,
showCancel: false
});
});
}
});
}
});
// wgt 和 安卓下载更新
downloadTask = uni.downloadFile({
url,
success: res => {
if (res.statusCode !== 200) {
console.error('下载安装包失败', err)
return
}
// 下载好直接安装,下次启动生效
plus.runtime.install(
res.tempFilePath,
{
force: false
},
() => {
if (is_mandatory) {
//更新完重启app
plus.runtime.restart()
return
}
uni.showModal({
title: '安装成功是否重启?',
success: res => {
if (res.confirm) {
//更新完重启app
plus.runtime.restart()
}
}
})
},
err => {
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!