-
Notifications
You must be signed in to change notification settings - Fork 73
/
Copy pathApp.vue
230 lines (220 loc) · 5.16 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
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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
<script>
const WXAUTH = require('@/common/wxauth.js')
export default {
globalData: {
h5Domain: 'https://xxxx.com',
goLogin: false,
subDomain: 'hdldzpd', // 改为你自己的专属域名
merchantId: 29, // 改为你自己的商户ID
version: '1.0.0',
sysconfigkeys: 'mallName', // 需要批量读取的系统参数
wxpayOpenAppId: 'xxxxx', // 微信开放平台的移动端应用appID
openAlipayProvider: false, // 是否开通支付宝支付
addressLevel: 3, // 省市区到3级还是4级,可选 3 或者 4
},
onLaunch: function() {
// https://www.yuque.com/apifm/nu0f75/cdqz1n
this.$wxapi.setMerchantId(this.globalData.merchantId)
this.$wxapi.init(this.globalData.subDomain)
const _this = this
// 1.1.0版本之前关于http拦截器代码,已平滑移动到/common/http.interceptor.js中
// 注意,需要在/main.js中实例化Vue之后引入如下(详见文档说明):
// import httpInterceptor from '@/common/http.interceptor.js'
// Vue.use(httpInterceptor, app)
// process.env.VUE_APP_PLATFORM 为通过js判断平台名称的方法,结果分别如下:
/**
* h5,app-plus(nvue下也为app-plus),mp-weixin,mp-alipay......
*/
this.checkForUpdate(); // 检查新版本
this.queryConfigBatch();
},
onShow(e) {
if (e && e.query && e.query.inviter_id) {
this.$u.vuex('referrer', e.query.inviter_id)
}
if (e && e.query && e.query.kjJoinUid) {
this.$u.vuex('kjJoinUid', e.query.kjJoinUid)
}
if (e && e.query && e.query.code) {
// 微信登陆
this.wxmpLogin(e.query.code)
return
} else {
this.autoLogin()
}
},
onHide: function() {
// console.log('App Hide,app不再展现在前台')
},
onPageNotFound(e) {
// 页面不存在 {path: '/1212', query: {a: '123'}, isEntryPage: true}
console.error(e)
},
methods: {
async queryConfigBatch() {
const sysconfigkeys = this.globalData.sysconfigkeys
if (!sysconfigkeys) {
return
}
// https://www.yuque.com/apifm/nu0f75/dis5tl
const res = await this.$wxapi.queryConfigBatch(sysconfigkeys)
if (res.code == 0) {
const sysconfigMap = {}
res.data.forEach(config => {
sysconfigMap[config.key] = config.value
})
this.$u.vuex('sysconfigMap', sysconfigMap)
}
},
checkForUpdate() {
// #ifdef MP
const updateManager = uni.getUpdateManager();
updateManager.onCheckForUpdate(function(res) {
// 请求完新版本信息的回调
console.log(res.hasUpdate);
});
updateManager.onUpdateReady(function(res) {
uni.showModal({
title: '更新提示',
content: '新版本已经准备好,是否重启应用?',
success(res) {
if (res.confirm) {
// 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
updateManager.applyUpdate();
}
}
});
});
updateManager.onUpdateFailed(function(res) {
// 新的版本下载失败
});
// #endif
// #ifdef APP-PLUS
// APP 自动更新
// #endif
},
async autoLogin(force) {
// 自动登陆
// #ifdef MP-WEIXIN
const isLogined = await WXAUTH.checkHasLogined()
if (!isLogined) {
await WXAUTH.authorize()
}
setTimeout(() => {
uni.$emit('loginOK', {})
}, 500)
// #endif
},
}
}
</script>
<style lang="scss">
/*每个页面公共css */
@import "@/uni_modules/uview-ui/index.scss";
.price-score {
position: relative;
display: flex;
color: #e64340;
font-size: 38rpx;
text {
padding: 0 6rpx;
font-size: 28rpx;
}
.item {
padding: 0 8rpx;
display: flex;
align-items: center;
}
.original {
margin-left: 32rpx;
color: #aaa;
text-decoration: line-through
}
.score-icon {
width: 28rpx;
height: 28rpx;
padding: 0 6rpx;
}
}
.goods-title-tag {
display: inline-flex !important;
margin-right: 24rpx;
}
.goods-title {
color: #333;
font-size: 28rpx;
}
.pt16 {
padding-top: 16rpx !important;
}
.submit-btn {
padding: 32rpx;
}
.form-box {
padding: 32rpx;
}
.mt32 {
margin-top: 32rpx;
}
.label-title{
font-size:28rpx;
font-weight: bold;
color:#000000;
padding: 30rpx;
display: flex;
align-items: center;
.icon {
width: 6rpx;
height: 30rpx;
background: linear-gradient(360deg, #FFAD56 0%, #FF8A46 100%);
margin-right: 8rpx;
}
}
// 背景以及头部公用样式
.container {
background-image:url('https://dcdn.it120.cc/2022/09/18/2e08ed01-8433-4ba4-8f78-1ef128216f77.jpg');
min-width: 100vw;
min-height: 100vh;
}
.user-info {
padding: 180rpx 64rpx 0 64rpx;
display: flex;
align-items: center;
position: relative;
.avatar {
width: 160rpx;
height: 160rpx;
border-radius: 50%;
overflow: hidden;
flex-shrink: 0;
}
.info {
margin-left: 32rpx;
.nick {
font-size: 48rpx;
font-weight: bold;
}
.level {
display: flex;
margin-top: 24rpx;
text {
font-size: 28rpx;
line-height: 56rpx;
color: #2979ff;
}
}
}
}
.back {
position: absolute;
left: 32rpx;
display: flex;
flex-direction: column;
justify-content: center;
z-index: 999;
}
.h32 {
width: 100vw;
height: 32rpx;
}
</style>