-
Notifications
You must be signed in to change notification settings - Fork 110
/
App.vue
91 lines (89 loc) · 2 KB
/
App.vue
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
<script>
import { baseURL } from '@/common/utils/config'
export default {
onLaunch: function () {
// #ifdef APP-PLUS
this.update()
// #endif
const userInfo = uni.getStorageSync('userInfo')
if (userInfo) this.$store.commit('SET_USERINFO', userInfo)
// #ifndef MP-WEIXIN
this.getInfo()
// #endif
// #ifdef MP-WEIXIN
this.$store.dispatch('getShopId', this.appid)
// #endif
},
onShow: function () {
//console.log('App Show')
},
onHide: function () {
//console.log('App Hide')
},
methods: {
getInfo () {
this.$store.dispatch("getAppid", this.appid).then(res => {
if (res) this.$store.dispatch('getShopId', this.appid)
})
},
update () {
let server = `${baseURL}/smallroutine/program/updataver`
let req = {
appid: plus.runtime.appid,
version: plus.runtime.version
}
console.log(JSON.stringify(req))
uni.request({
url: server,
data: req,
method: 'post',
success: res => {
console.log(JSON.stringify(res))
if (res.statusCode === 200 && res.data.rsp.status === 1) {
uni.showModal({
title: "更新提示",
content: res.data.rsp.note,
confirmText: '更新',
success: rst => {
if (rst.confirm) {
uni.downloadFile({
url: res.data.rsp.url,
success: files => {
if (files.statusCode === 200) {
plus.runtime.openFile(files.tempFilePath, {}, () => {
uni.showToast({
title: '安装失败',
icon: 'none'
})
})
}
},
fail: err => {
plus.nativeUI.alert('下载更新文件失败')
}
})
}
}
})
}
}
})
}
},
data () {
return {
baseURL: baseURL
}
}
}
</script>
<style lang="less">
@import './common/css/uni.css';
uni-page-body, page {
background-color: #f6f6f6;
font-size: 30upx;
width: 100%;
}
img,image{
}
</style>