index.vue
4.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
<template>
<view class="h-page">
<view class="p-t">
<image src="../../static/common/version_bg.png" style="width: 750rpx;height: 334rpx;" mode=""></image>
<view class="p-t-inner">
<image src="../../static/common/version_logo.png" style="width: 116rpx;height: 116rpx" mode=""></image>
<text class="p-text">{{ t('app.title.appTips') }}</text>
</view>
</view>
<view class="p-c">
<!-- <view class="p-c-item" @tap="handleUpdateApp"> -->
<view class="p-c-item" @tap="handleUpdateApp">
<view class="p-c-item-title">{{ t('app.common.versionUpdate') }}</view>
<!-- #ifdef APP-PLUS -->
<view class="needs-update" v-if="needsUpdate"></view>
<!-- #endif -->
<view class="p-c-item-desc">v{{currentVersion}}</view>
<uv-icon name="arrow-right" v-if="needsUpdate" size="22rpx" color="#90949D"></uv-icon>
</view>
</view>
<view class="copyright">{{ copyRightText }}</view>
</view>
</template>
<script setup>
import {
onLoad
} from '@dcloudio/uni-app'
import {
compareVersions
} from '@/utils'
import {
computed,
ref
} from 'vue'
import {
t,initI18n
} from '@/plugins/index.js'
import appUpdate from '@/uni_modules/wczd-app-update/js_sdk/app-update.js'
const copyRightText = computed(()=>{
// #ifdef APP-PLUS
return t('app.common.rightsReserved').replace('{company}',t('login.companyName'))
// #endif
return t('app.common.rightsReserved',{ company:t('login.companyName') })
})
const updatePopupParam =(()=>{
const findNewVersion = 'TaskNotice.haveNewVersion'
const immediatelyUpgrade = 'TaskNotice.updateNow'
const temporarilyUpgrade = 'TaskNotice.noUpdate'
const versionUpdate = 'app.common.versionUpdate'
return {
findNewVersion,
immediatelyUpgrade,
temporarilyUpgrade,
versionUpdate,
}
})
const handleUpdateApp = () => {
const param = updatePopupParam()
if (needsUpdate.value) {
// #ifdef APP-PLUS
// 需要传入 发现新版本 立即升级 暂不升级 版本更新 的国际化字段
appUpdate({
...updateInfo.value,
...param,
})
// #endif
}
}
const updateInfo = ref({})
const currentVersion = ref('0.0.0')
const needsUpdate = ref(false)
onLoad(() => {
initI18n();
uni.setNavigationBarTitle({
title: t('app.common.versionDescription')
})
const systemInfo = uni.getSystemInfoSync()
currentVersion.value = systemInfo.appWgtVersion || systemInfo.appVersion || '0.0.0'
uni.request({
url: 'https://retail.europe.vion-cloud.com/report/app/lastest/version',
method: 'GET',
header: {
'Authorization': uni.getStorageSync('Authorization')
},
success(response) {
const res = response.data
if (res.code === 200) {
const systemInfo = uni.getSystemInfoSync()
const data = res.data || {}
// 接口版本大于当前版本 显示小红点
needsUpdate.value = compareVersions(data.version, currentVersion.value) > 0
const downUrlMap = {
// 'android': 'https://store.keliuyun.com/download/app/vStore.apk',
'android': 'https://retail.europe.vion-cloud.com/download/app/CVA_YAP.apk',
'ios': 'https://apps.apple.com/cn/app/id6752882316', // vstore
}
updateInfo.value = {
platform: systemInfo.platform, // 'android' || 'ios'
updateContent: data.remark,
downUrl: downUrlMap[systemInfo.platform] || '',
version: data.version,
force: !!data.isForce,
mainColor: '387CF5',
}
}
}
})
})
</script>
<style lang="scss" scoped>
@import '@/styles/col.scss';
.h-page {
/* #ifndef H5 */
min-height: 100vh;
/* #endif */
/* #ifdef H5 */
min-height: calc(100vh - 44px);
/* #endif */
background-color: #F2F3F6;
.p-t {
margin-bottom: 94rpx;
position: relative;
.p-t-inner {
position: absolute;
left: 0;
top: 0;
width: 750rpx;
height: 334rpx;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
.p-text {
padding-top: 30rpx;
font-size: 32rpx;
color: #fff;
font-family: DingTalk_JinBuTi!important;
}
}
}
.p-c {
border-top: 2rpx solid rgba(225, 228, 234, 0.7);
}
.copyright {
width: 750rpx;
text-align: center;
font-size: 22rpx;
color: #656A72;
position: fixed;
left: 0;
bottom: 22rpx;
}
}
</style>