selfNav.vue
11.3 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
310
311
312
313
314
<template>
<div>
<div class="person-bg">
<svg class="demo__top-svgBg" viewBox="0 0 366 256">
<g class="svgBg__objects">
<path class="svgBg__bg svgBg__bg1" fill="#86D7DB" d="M0,143 88,107 224,153 348,109 366,123 366,256 0,256z" />
<path class="svgBg__bg svgBg__bg2" fill="#3C929A" d="M0,156 106,136 272,172 342,124 366,144 366,256 0,256z" />
<path class="svgBg__bg svgBg__bg3" fill="#416175" d="M0,170 62,160 235,148 305,145 366,153 366,256 0,256z" />
<g class="svgBg__tree svgBg__tree-1 m--left" data-id="1">
<path class="svgBg__tree-leafs svgBg__tree-part" fill="#389296" d="M54,127 C77,127 62,95 54,63 C46,95 31,127 54,127" />
<path class="svgBg__tree-trunk svgBg__tree-part" d="M56,147 Q55,115 54,83 Q53,115 52,146" />
</g>
<g class="svgBg__tree svgBg__tree-2 m--left" data-id="2">
<path class="svgBg__tree-leafs svgBg__tree-part" fill="#389296" d="M67,124 C90,124 75,92 67,59 C59,92 44,124 67,124" />
<path class="svgBg__tree-trunk svgBg__tree-part" d="M69,144 Q68,112 67,80 Q66,112 65,143" />
</g>
<g class="svgBg__tree svgBg__tree-3 m--right" data-id="3">
<path class="svgBg__tree-leafs svgBg__tree-part" fill="#389296" d="M264,129 C287,129 272,97 264,64 C256,97 241,129 264,129" />
<path class="svgBg__tree-trunk svgBg__tree-part" d="M266,149 Q265,117 264,85 Q263,117 262,148" />
</g>
<g class="svgBg__tree svgBg__tree-4 m--right" data-id="4">
<path class="svgBg__tree-leafs svgBg__tree-part" fill="#207277" d="M287,128 C310,128 295,96 287,63 C279,96 264,128 287,128" />
<path class="svgBg__tree-trunk svgBg__tree-part" d="M289,148 Q288,116 287,84 Q286,116 285,147" />
</g>
<g class="svgBg__tree svgBg__tree-5 m--right" data-id="5">
<path class="svgBg__tree-leafs svgBg__tree-part" fill="#389296" d="M313,128 C336,128 321,96 313,63 C305,96 290,128 313,128" />
<path class="svgBg__tree-trunk svgBg__tree-part" d="M315,148 Q314,116 313,84 Q312,116 311,147" />
</g>
</g>
</svg>
<div class="person-ifo">
<div class="person-pic" :style="{backgroundImage:'url('+this.headPicUrl+')',backgroundSize:'100%'}"></div>
<ul class="person-con">
<li>手机号:{{ userPhone}}</li>
<li style="height: 20px;"></li>
<li>账户余额: <span>¥{{(acctBalance/100).toFixed(2)}}</span></li>
<!--<li>我的卡券:<span>{{ couponNum }}张</span></li>-->
</ul>
</div>
</div>
<mt-cell is-link v-for="i in menuList" :title="i.name" @click.native="toMemu(i.path)" :key="i.name"></mt-cell>
<!--<mt-cell title="车辆管理" is-link></mt-cell>-->
<!--<mt-cell title="停车记录" is-link></mt-cell>-->
<!--<mt-cell title="建议反馈" is-link></mt-cell>-->
<div class="leftRightPadding" style="margin-top: 34px" v-show="loginShow">
<mt-button type="primary" size="large" @click="loginHandle">{{ loginTxt }}</mt-button>
</div>
</div>
</template>
<script>
import {
getOpenIdByCode,
getTokenByOpenId,
queryUserInfo,
queryCustPersonBaseInfo,
logout
} from "@/api/selfNav/selfNav";
export default {
name: "selfNav",
data() {
return {
menuList: [
{ name: "停车缴费", path: "plateNumber" },
{ name: "会员卡", path: "Cards" },
{ name: "车辆管理", path: "myCars" },
{ name: "发票管理", path: "eInvoiceWrap" },
{ name: "停车记录", path: "parkNotes" },
{ name: "建议反馈", path: "suggestionBack" }
],
webAppCode: "", // 071hQo0w34xoYX21CP2w3RRw7U1hQo02
couponNum: 0, // 卡券数量
acctBalance: 0, // 账户余额
userPhone: "--",// 账户手机号
headPicUrl: require("@/assets/images/mySelf/photoBG.png"),// 用户图像
loginTxt: "绑定手机", // 退出账户
loginShow:true
// headPicUrl:headPic
};
},
created() {
// this.$vux.loading.show({
// text: "数据加载中..."
// });
if (this.$utils.clientBrowser() == "微信") {
this.webAppCode = this.getCode();
}
},
mounted() {
let that = this;
if(sessionStorage.getItem("wx_openId")){
this.getTokenByOpenId(sessionStorage.getItem("wx_openId"));
// this.getinfoself()
}else{
if (this.webAppCode) {
this.getopenid();
}
}
},
methods: {
// 获取code
getCode() {
var appID = this.$utils.myVxAppId;
var code = this.getUrlParam("code");
var local = window.location.href;
if (code == null || code === "") {
window.location.href = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + appID + "&redirect_uri=" + encodeURIComponent(local) + "&response_type=code&scope=snsapi_userinfo&state=1#wechat_redirect";
} else {
return code;
}
},
getUrlParam(name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
if (r != null) return unescape(r[2]);
return null;
},
// 获取openid
getopenid() {
let jsondata = {
appId: this.$utils.myVxAppId,
code: this.webAppCode
};
getOpenIdByCode(jsondata).then(data => {
console.log(data);
if (data.code == "0") {
let openid = data.data;
sessionStorage.setItem("wx_openId", openid);
console.log("用户 openid " + openid);
this.getTokenByOpenId(openid);
}else{
this.$vux.toast.text(data.message, "top");
}
});
},
// 获取token
getTokenByOpenId(openid) {
let that = this
var jsondata = {
openid: openid,
deviceInfo: this.$utils.myDeviceInfo
};
getTokenByOpenId(jsondata).then(data => {
console.log("执行获取token的接口 " + JSON.stringify(data));
if (data.code == 0) {
console.log("用户 token " + data.data.token);
let _token = data.data.token;
console.log('getTokenByOpenId获取到的'+_token)
sessionStorage.setItem("wx_Token", data.data.token);
// alert(data.data.token)
sessionStorage.setItem("WXPhone", data.data.phoneNum);
that.getinfoself(); //获取用户信息
} else {
this.$vux.toast.text(data.message, "top");
}
this.$vux.loading.hide();
});
},
//获取用户信息
getinfoself() {
// alert('token是:'+sessionStorage.getItem("wx_Token"))
let jsondata = this.$utils.commonParams();
console.log(jsondata)
jsondata.sign = this.$utils.signObject(jsondata);
queryUserInfo(jsondata).then(data => {
this.$vux.loading.hide();
console.log("获取用户信息 " + JSON.stringify(data));
if (data.code == "0") {
var datas = data.data;
this.couponNum = datas.couponNum;//卡券数量
var openAcctType = datas.openAcctType;//是否开通账户 1 开通 0 未开通
var msgPushState = datas.msgPushState;//是否开启消息推送 1 是 0否
// this.userPhone = datas.phone;//手机号
var carCount = datas.carCount;//绑定车牌数量
this.acctBalance = datas.acctBalance;//账户余额 单位:分
var orderCount = datas.orderCount;//停车记录
var pettyPayAmount = datas.pettyPayAmount;//小额免密支付金额
var acctScoreBalance = datas.acctScoreBalance;//积分账户余额 单位:个
var pettyPayState = datas.pettyPayState;//用户是否开启小额免密支付 1是 0否
var yjstatus = datas.openAcctDepositType;//是否交了押金
var yjjine = datas.acctDepositBalance;//Yjjine
var headPicUrl = "";//头像
var custNickname = "";//昵称
var phone = "";//昵称
this.userPhone = data.data.phone;//昵称
this.loginShow = false
// this.queryCustPersonBaseInfo(); //获取手机号和头像
} else {
this.$vux.toast.text(data.message, "top");
}
});
},
//获取手机号和头像
queryCustPersonBaseInfo() {
let jsondata = this.$utils.commonParams()
jsondata.sign = this.$utils.signObject(jsondata);
queryCustPersonBaseInfo(jsondata).then(data => {
// this.userPhone = datas.phone;//手机号
console.log('获取用户手机头像'+JSON.stringify(data))
if (data.code == "0") {
if(data.data.headPicUrl){
this.headPicUrl = data.data.headPicUrl;//头像
}else{
this.headPicUrl = require("@/assets/images/mySelf/photoBG.png");
}
var custNickname = data.data.custNickname;//昵称
this.userPhone = data.data.userPhone;//昵称
// this.loginTxt = "退出登陆";
this.loginShow = false
} else {
this.$vux.toast.text(data.message, "top");
}
});
},
// 注册登陆或者退出登陆
loginHandle() {
if (this.loginTxt == "退出登陆") {
let jsondata = {};
let obj = {
token: sessionStorage.getItem("wx_Token")
};
jsondata = Object.assign(obj, this.$utils.commonParams());
jsondata.sign = this.$utils.signObject(jsondata);
logout(jsondata).then(data => {
console.log("执行获取token的接口 " + JSON.stringify(data));
if (data.code == 0) {
sessionStorage.setItem("wx_Token", null);
sessionStorage.setItem("WXPhone", null);
this.couponNum = 0; // 卡券数量
this.acctBalance = 0; // 账户余额
this.userPhone = "--";// 账户手机号
this.headPicUrl = require("@/assets/images/mySelf/photoBG.png");// 用户图像
this.loginTxt = "绑定手机"; // 退出账户
this.$router.push({
path: "binDing"
});
} else {
this.$vux.toast.text(data.message, "top");
}
});
} else {
this.$router.push({
path: "binDing"
});
}
},
// 前往各个子页面
toMemu(path) {
let _token = sessionStorage.getItem("wx_Token");
if (_token) {
if(path=='plateNumber'){
window.location.href = 'http://wxgzh.renniting.cn/wechatwuxi/WUXIZLYH/GZH/index.html'
// http://wxgzh.renniting.cn/wechatwuxi/WUXIZLYH/GZH/index.html#/selfNav
}else{
this.$router.push({
path: path
})
}
} else {
this.$vux.toast.text("请先绑定手机号", "top");
this.$router.push({
path: "binDing"
});
}
}
}
};
</script>
<style scoped lang="scss">
.person-bg {
height: 160px;
background: -webkit-linear-gradient(#7BCECA, #82D3CB);
background: linear-gradient(#7BCECA, #82D3CB);
}
.person-ifo {
padding: $commonLeftRightPadding;
padding-top: 45px;
display: flex;
/*color: #ffbfbf;*/
position: absolute;
top: 0;
left: 0;
.person-pic {
width: 64px;
height: 64px;
margin-right: 15px;
background: url("../../assets/images/mySelf/photoBG.png") no-repeat;
}
}
.person-con {
span {
font-size: 16px;
font-weight: bold;
}
}
.mint-cell {
border-bottom: 1px solid #EFEDED;
}
</style>