mine.vue
8.28 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
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
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
<template>
<view class="container">
<u-navbar bgColor="#EA5504" :safeAreaInsetTop="true" placeholder v-show="!isScan">
<view class="" slot="left">
</view>
<view class="text-xl text-white" slot="center">
我的
</view>
<view class="flex align-center" slot="right" @click="loginOut">
<view class="text-white text">
退出
</view>
<view class="margin-left-sm">
<u-icon name="/static/images/mine/quit.png" color="#fff" size="15"></u-icon>
</view>
</view>
</u-navbar>
<view class="topContentCss" v-show="!isScan">
<!-- 个人信息面板 -->
<view class="flex justify-between topBarCss">
<view class="flex justify-between w80">
<view class="margin-left">
<u-avatar size="60" shape="circle" :src="user.imgSrc" ></u-avatar>
</view>
<view class="margin-left flex flex-direction">
<view class="text-xl text-bold">
{{user.fullname}}
</view>
<view class="margin-top-lg">
{{user.account}}
</view>
</view>
<view class="tagCss">
<u-tag :text="(user && user.userInfo && user.userInfo.fHylx)?user.userInfo.fHylx:'居民'"
color="#fff" iconColor="#fff" icon="/static/images/mine/sfjm.png" borderColor="#EF8043"
shape="circle" bgColor="#EF8043"></u-tag>
</view>
</view>
<view class="w30 flex align-end justify-between flex-direction">
<view class="chatCss">
<u-icon name="chat" size="30" color="#fff"></u-icon>
</view>
<view class="authCss flex align-center" @click="handleAuth">
<view class="margin-right-xs">
<u-image shape="circle" width="20px" height="20px"
src="/static/images/mine/auth.png"></u-image>
</view>
<view class="themeColor flex align-end text-sm">
{{ user.userInfo && user.userInfo.fSfsmrz || '否'}}
</view>
</view>
</view>
</view>
<!-- 数字面板 -->
<view class="flex justify-around margin-top-xl">
<view class="flex align-center flex-direction">
<view class="text-bold text-xl">
{{(user.stats && user.stats.aqyq) || '0'}}
</view>
<view class="text-sm margin-top-xs">
安全用气
</view>
</view>
<view class="flex align-center flex-direction" @click="goMyGasBottlePage">
<view class="text-bold text-xl">
{{(user.stats && user.stats.ydqp) || '0'}}
</view>
<view class="text-sm margin-top-xs">
已订气瓶
</view>
</view>
<view class="flex align-center flex-direction">
<view class="text-bold text-xl">
{{(user.stats && user.stats.yjje) || '0'}}
</view>
<view class="text-sm margin-top-xs">
押金金额
</view>
</view>
</view>
</view>
<view class="cardAreaCss" v-show="!isScan">
<!-- 气瓶卡片 -->
<gasCard :userInfo="user"></gasCard>
<!-- 订单卡片 -->
<orderCard></orderCard>
<!-- 常用应用卡片 -->
<commonApplications @selectItem="handleItem"></commonApplications>
</view>
<!-- app不支持$route -->
<!-- <TabBar :currentPagePath="this.$route.meta.pagePath"></TabBar> -->
<u-popup ref="LoginOutRef" :customStyle="{width:'80%',borderRadius:'15px'}" round="15" mode="center"
:show="LoginOutShow" @close="LoginOutClose" @open="LoginOutOpen">
<view class="userCardCss">
<view class="padding-tb text-xl text-center">
提示
</view>
<view class="padding-bottom text-gray text-center">
确认退出当前账号?
</view>
<view class="flex justify-center padding-bottom-lg" v-if="openAutoLogin">
<u-checkbox-group v-model="isAutoLogin" shape="circle" activeColor="#EA5504">
<u-checkbox size="15px" label="自动登录" name="y"></u-checkbox>
</u-checkbox-group>
</view>
<view class="flex">
<view class="w50">
<u-button :customStyle="{borderRadius:'0 0 0 15px'}" @click="LoginOutShow = false">取消</u-button>
</view>
<view class="w50">
<u-button :customStyle="{color:'#EA5504',borderRadius:'0 0 15px 0'}"
@click="loginOutConfirm">确定</u-button>
</view>
</view>
</view>
</u-popup>
<TabBar :currentPagePath="'pages/mine/mine'"></TabBar>
<ScanCode ref="scanCode" v-show="isScan" @scanCode="getCode" @close="closeScanWindow"></ScanCode>
</view>
</template>
<script>
import gasCard from './components/gasCard'
import orderCard from './components/orderCard'
import commonApplications from './components/commonApplications'
export default {
components: {
gasCard,
orderCard,
commonApplications
},
props: {
},
data() {
return {
isScan: false,
user: {},
LoginOutShow: false,
isAutoLogin: [],
openAutoLogin: false,
}
},
computed: {
},
async onShow() {
this.isScan = false;
console.log('打印this.isScan', this.isScan)
await this.getInitData();
let isAutoLogin = uni.getStorageSync('isAutoLogin');
if (isAutoLogin) {
this.isAutoLogin = ['y'];
this.openAutoLogin = true;
} else {
this.isAutoLogin = [];
this.openAutoLogin = false;
}
},
async onLoad() {
// 因为头像缓存的是临时文件,应用首次加载时清除缓存让其重新请求图片存入缓存作为头像
uni.removeStorageSync('myAvatorImg');
},
methods: {
//获取用户的详细信息
async getInitData() {
const result = await this.$api.loginApi.getUserInfo({yhlx:'hy'});
let {
code,
value
} = result;
this.user = code == 200 ? {
...value
} : null;
console.log('打印this.user.photo', this.user.photo);
console.log(this.$store.state);
if (this.user.photo) {
// this.user.imgSrc = await this.$getPhotoUrl(this.user.photo);
let avatorImg = uni.getStorageSync('myAvatorImg');
console.log('打印this.user.photo', avatorImg);
if (avatorImg) {
this.user.imgSrc = avatorImg;
} else {
this.user.imgSrc = await this.$getPhotoUrl(this.user.photo);
uni.setStorageSync('myAvatorImg', this.user.imgSrc);
}
} else {
this.user.imgSrc = 'static/images/mine/avator.jpg';
}
uni.setStorageSync('userId', this.user.userInfo.id);
this.user = {
...this.user
}
console.log('用户信息', JSON.parse(JSON.stringify(this.user)));
},
// 实名认证
handleAuth(){
uni.navigateTo({
url:'/pages/mine/appList/realNameAuth/realNameMode'
})
},
handleItem() {
// 组件模式打开
// this.isScan = true;
// this.$refs.scanCode.open();
uni.navigateTo({
url: "/pages/scan/scanCode"
})
},
async getCode(code) {
let query = {
qptm: code
}
const result = await this.$api.gasApi.getDetailByQuery(query);
let {
state,
message
} = result;
this.$modal.closeLoading();
if (!state) {
uni.$u.toast(message)
return;
}
uni.navigateTo({
url: '/pages/mine/appList/gasInformation/gasInformation?qptm=' + code
})
},
closeScanWindow() {
console.log("触发关闭");
this.isScan = false;
},
goMyGasBottlePage() {
uni.navigateTo({
url: `/pages/mine/myGasBottle?type=ydqp`
})
},
LoginOutOpen() {
this.LoginOutShow = true;
},
LoginOutClose() {
this.LoginOutShow = false;
},
loginOutConfirm() {
// 清除自动登录信息
if (!this.isAutoLogin.length) {
uni.removeStorageSync('isAutoLogin');
uni.removeStorageSync('autoInformation');
}
this.$store.dispatch('LogOut').then(() => {
this.$tab.reLaunch('/pages/login');
})
},
loginOut() {
// this.LoginOutShow = true;
this.$modal.confirm('确认退出当前账号?', '提示').then(() => {
this.$store.dispatch('LogOut').then(() => {
this.$tab.reLaunch('/pages/login');
})
}).catch(() => {
console.log("取消");
});
}
}
}
</script>
<style lang="scss" scoped>
.topContentCss {
position: relative;
width: 100%;
height: 200px;
background: #EA5504;
border-radius: 0 0 30px 30px;
color: #fff;
.topBarCss {
height: 65px;
}
.authCss {
border-radius: 30px 0 0 30px;
background: #fff;
// width: 0px;
padding: 5px;
}
.chatCss {
// position: absolute;
// margin: -10px 0 0 -10px;
}
}
.cardAreaCss {
position: relative;
top: -50px;
color: #000;
}
/deep/.tagCss .u-tag {
// margin: 5px;
height: 25px;
padding: 0 10px !important;
}
/deep/.tagCss .u-tag__text {
margin-top: 1px;
}
</style>