Showing
5 changed files
with
124 additions
and
58 deletions
@@ -3,7 +3,7 @@ | @@ -3,7 +3,7 @@ | ||
3 | <!-- 公共组件-每个页面必须引入 --> | 3 | <!-- 公共组件-每个页面必须引入 --> |
4 | <public-module></public-module> | 4 | <public-module></public-module> |
5 | <view class="headBox"> | 5 | <view class="headBox"> |
6 | - <!-- #ifdef MP --> | 6 | + <!-- #ifdef MP || APP-PLUS --> |
7 | <!-- 登录 --> | 7 | <!-- 登录 --> |
8 | <view class="u-flex u-p-l-30 u-p-r-20 u-p-t-75 u-p-b-30"> | 8 | <view class="u-flex u-p-l-30 u-p-r-20 u-p-t-75 u-p-b-30"> |
9 | <block v-if="userInfo.isToken"> | 9 | <block v-if="userInfo.isToken"> |
@@ -17,8 +17,6 @@ | @@ -17,8 +17,6 @@ | ||
17 | </view> | 17 | </view> |
18 | </view> | 18 | </view> |
19 | <view @click="openPersonalInfo" style="color:#FFFFFF;font-size: 14px;" v-if="userInfo.phoneNumber">{{ userInfo.phoneNumber | phone }}</view> | 19 | <view @click="openPersonalInfo" style="color:#FFFFFF;font-size: 14px;" v-if="userInfo.phoneNumber">{{ userInfo.phoneNumber | phone }}</view> |
20 | - <view v-else><text style="color:#FFFFFF;font-size: 14px;">手机号:未绑定</text></view> | ||
21 | - <view v-if="userInfo.isToken" @click="clearAccountFunc(userInfo)" class="detail"><text class="text">解绑</text></view> | ||
22 | </view> | 20 | </view> |
23 | </block> | 21 | </block> |
24 | <block v-else> | 22 | <block v-else> |
@@ -30,37 +28,9 @@ | @@ -30,37 +28,9 @@ | ||
30 | <view v-if="!userInfo.isToken" @click="clickAccountFunc" class="detail"><text class="text">绑定账号</text></view> | 28 | <view v-if="!userInfo.isToken" @click="clickAccountFunc" class="detail"><text class="text">绑定账号</text></view> |
31 | </view> | 29 | </view> |
32 | </block> | 30 | </block> |
33 | - <view v-if="userInfo.isToken"><u-icon name="arrow-right" color="white" size="13"></u-icon></view> | 31 | + <view v-if="userInfo.isToken" @click="openPersonalInfo"><u-icon name="arrow-right" color="white" size="13"></u-icon></view> |
34 | </view> | 32 | </view> |
35 | - <!-- #endif --> | ||
36 | - <!-- #ifndef MP --> | ||
37 | <!-- 登录 --> | 33 | <!-- 登录 --> |
38 | - <view class="u-flex u-p-l-30 u-p-r-20 u-p-t-75 u-p-b-30"> | ||
39 | - <block v-if="userInfo.isToken"> | ||
40 | - <view @click="openPersonalInfo" class="u-m-r-20"> | ||
41 | - <image class="avatar" mode="aspectFill" :src="userInfo.avatar || userInfo.avatarUrl || '/static/default.png'"></image> | ||
42 | - </view> | ||
43 | - <view @click="openPersonalInfo" class="u-flex-1"> | ||
44 | - <view class="nickName u-flex"> | ||
45 | - <view class="name u-m-r-10" v-if="userInfo.realName || userInfo.nickName"> | ||
46 | - <text style="#FFFFFF;font-size: 18px;">{{ userInfo.realName || userInfo.nickName }}</text> | ||
47 | - </view> | ||
48 | - </view> | ||
49 | - <view style="color:#FFFFFF;font-size: 14px;" v-if="userInfo.phoneNumber">{{ userInfo.phoneNumber | phone }}</view> | ||
50 | - <view v-else><text style="color:#FFFFFF;font-size: 14px;">手机号:未绑定</text></view> | ||
51 | - </view> | ||
52 | - </block> | ||
53 | - <block v-else> | ||
54 | - <view class="u-m-r-20" @click="openLoginFunc"> | ||
55 | - <view class="avatar u-flex" style="justify-content: center"><u-icon name="account-fill" color="black" size="30"></u-icon></view> | ||
56 | - </view> | ||
57 | - <view class="u-flex-1"> | ||
58 | - <view @click="openLoginFunc" class="u-font-lg login-btn">登录</view> | ||
59 | - <view v-if="userInfo.isToken == '' || userInfo.isToken == null" @click="clickAccountFunc" style="color: black" class="detail">绑定账号</view> | ||
60 | - </view> | ||
61 | - </block> | ||
62 | - <view><u-icon name="arrow-right" color="black" size="13"></u-icon></view> | ||
63 | - </view> | ||
64 | <!-- #endif --> | 34 | <!-- #endif --> |
65 | </view> | 35 | </view> |
66 | <view class="u-flex my-nav"> | 36 | <view class="u-flex my-nav"> |
@@ -195,7 +165,6 @@ export default { | @@ -195,7 +165,6 @@ export default { | ||
195 | if (e.obj != null) { | 165 | if (e.obj != null) { |
196 | const params = JSON.parse(decodeURIComponent(e.obj)); | 166 | const params = JSON.parse(decodeURIComponent(e.obj)); |
197 | this.thirdObj = params; | 167 | this.thirdObj = params; |
198 | - console.log(this.thirdObj); | ||
199 | } | 168 | } |
200 | }, | 169 | }, |
201 | computed: { | 170 | computed: { |
@@ -223,7 +192,8 @@ export default { | @@ -223,7 +192,8 @@ export default { | ||
223 | }, | 192 | }, |
224 | openPersonalInfo() { | 193 | openPersonalInfo() { |
225 | let obj = { | 194 | let obj = { |
226 | - data: this.userInfo | 195 | + data: this.userInfo, |
196 | + third: this.thirdObj | ||
227 | }; | 197 | }; |
228 | uni.navigateTo({ | 198 | uni.navigateTo({ |
229 | url: '/publicLoginSubPage/other/set?data=' + JSON.stringify(obj) | 199 | url: '/publicLoginSubPage/other/set?data=' + JSON.stringify(obj) |
@@ -290,7 +260,8 @@ export default { | @@ -290,7 +260,8 @@ export default { | ||
290 | } | 260 | } |
291 | }) | 261 | }) |
292 | .catch(e => { | 262 | .catch(e => { |
293 | - uni.$u.toast(e.data?.message); | 263 | + uni.$u.toast(e.data?.msg || e.data?.message); |
264 | + this.show = false; | ||
294 | }); | 265 | }); |
295 | } else { | 266 | } else { |
296 | const phoneRegular = /^1\d{10}$/; | 267 | const phoneRegular = /^1\d{10}$/; |
@@ -349,7 +320,8 @@ export default { | @@ -349,7 +320,8 @@ export default { | ||
349 | this.saveUserInfo(); | 320 | this.saveUserInfo(); |
350 | }) | 321 | }) |
351 | .catch(e => { | 322 | .catch(e => { |
352 | - uni.$u.toast(e.data?.message); | 323 | + uni.$u.toast(e.data?.msg || e.data?.message); |
324 | + this.show = false; | ||
353 | }); | 325 | }); |
354 | } | 326 | } |
355 | }, | 327 | }, |
@@ -439,18 +411,6 @@ export default { | @@ -439,18 +411,6 @@ export default { | ||
439 | } | 411 | } |
440 | } | 412 | } |
441 | }); | 413 | }); |
442 | - }, | ||
443 | - clearAccountFunc(e) { | ||
444 | - //解绑 | ||
445 | - let httpData = { | ||
446 | - appUserId: e.userId, | ||
447 | - thirdUserId: this.thirdObj.thirdUserId | ||
448 | - }; | ||
449 | - uni.$u.http.delete('/yt/third', httpData).then(res => { | ||
450 | - if (res) { | ||
451 | - this.getCodeState(); //开始倒计时 | ||
452 | - } | ||
453 | - }); | ||
454 | } | 414 | } |
455 | } | 415 | } |
456 | }; | 416 | }; |
@@ -45,10 +45,24 @@ | @@ -45,10 +45,24 @@ | ||
45 | </u-form-item> | 45 | </u-form-item> |
46 | </u--form> | 46 | </u--form> |
47 | </view> | 47 | </view> |
48 | - <view class="basic-bottom"><button class="submit" size="default" @click="onSubmitFunc" :style="{ background: PrimaryColor }">确认</button></view> | 48 | + <view class="basic-bottom u-flex"> |
49 | + <view class="item" v-if="info.data.isToken"><button class="submit" size="default" @click="clearAccountFunc" :style="{ background: InfoColor }">解绑</button></view> | ||
50 | + <view class="item" style="margin-right: 60rpx;"><button class="submit" size="default" @click="onSubmitFunc" :style="{ background: PrimaryColor }">确认</button></view> | ||
51 | + </view> | ||
49 | <!-- #ifdef MP --> | 52 | <!-- #ifdef MP --> |
50 | <view class="u-m-t-40"><text style="visibility: hidden;">#</text></view> | 53 | <view class="u-m-t-40"><text style="visibility: hidden;">#</text></view> |
51 | <!-- #endif --> | 54 | <!-- #endif --> |
55 | + <!-- 解绑账号 --> | ||
56 | + <view> | ||
57 | + <u-popup bgColor="transparent" :overlay="true" :show="showBind" mode="bottom"> | ||
58 | + <view class="u-flex logout-main"> | ||
59 | + <view class="main"><text style="color: #999999">是否需要解绑?</text></view> | ||
60 | + <view @click="confrimBind(info)" class="main"><text style="color: #f95e5a">是</text></view> | ||
61 | + <view class="main1"><text @click="showBind = false" style="color: #3478f7">否</text></view> | ||
62 | + </view> | ||
63 | + </u-popup> | ||
64 | + </view> | ||
65 | + <!-- 解绑账号 --> | ||
52 | </view> | 66 | </view> |
53 | </template> | 67 | </template> |
54 | 68 | ||
@@ -56,7 +70,9 @@ | @@ -56,7 +70,9 @@ | ||
56 | export default { | 70 | export default { |
57 | data() { | 71 | data() { |
58 | return { | 72 | return { |
59 | - PrimaryColor: '#0079fe', //主题色 | 73 | + showBind: false, |
74 | + PrimaryColor: '#377DFF', //主题色 | ||
75 | + InfoColor: '#E3E4E5', //主题色 | ||
60 | myInfoModel: { | 76 | myInfoModel: { |
61 | userInfo: { | 77 | userInfo: { |
62 | realName: '', | 78 | realName: '', |
@@ -117,12 +133,14 @@ export default { | @@ -117,12 +133,14 @@ export default { | ||
117 | trigger: ['change', 'blur'] | 133 | trigger: ['change', 'blur'] |
118 | } | 134 | } |
119 | ] | 135 | ] |
120 | - } | 136 | + }, |
137 | + info: {} | ||
121 | }; | 138 | }; |
122 | }, | 139 | }, |
123 | onLoad(e) { | 140 | onLoad(e) { |
124 | if (e.data !== null) { | 141 | if (e.data !== null) { |
125 | let params = JSON.parse(e.data); | 142 | let params = JSON.parse(e.data); |
143 | + this.info = params; | ||
126 | this.myInfoModel.userInfo.realName = params.data.realName; | 144 | this.myInfoModel.userInfo.realName = params.data.realName; |
127 | this.myInfoModel.userInfo.phoneNumber = params.data.phoneNumber; | 145 | this.myInfoModel.userInfo.phoneNumber = params.data.phoneNumber; |
128 | this.myInfoModel.userInfo.username = params.data.username; | 146 | this.myInfoModel.userInfo.username = params.data.username; |
@@ -133,6 +151,31 @@ export default { | @@ -133,6 +151,31 @@ export default { | ||
133 | } | 151 | } |
134 | }, | 152 | }, |
135 | methods: { | 153 | methods: { |
154 | + confrimBind(e) { | ||
155 | + if (e) { | ||
156 | + //解绑 | ||
157 | + let httpData = { | ||
158 | + appUserId: e.data?.userId, | ||
159 | + thirdUserId: e.third?.thirdUserId | ||
160 | + }; | ||
161 | + uni.$u.http.delete('/yt/third', httpData).then(res => { | ||
162 | + if (res) { | ||
163 | + uni.showToast({ | ||
164 | + title: '解绑成功' | ||
165 | + }); | ||
166 | + this.showBind = false; | ||
167 | + } else { | ||
168 | + uni.showToast({ | ||
169 | + title: '解绑失败' | ||
170 | + }); | ||
171 | + this.showBind = false; | ||
172 | + } | ||
173 | + }); | ||
174 | + } | ||
175 | + }, | ||
176 | + clearAccountFunc() { | ||
177 | + this.showBind = true; | ||
178 | + }, | ||
136 | // 修改头像 | 179 | // 修改头像 |
137 | upAvatar() { | 180 | upAvatar() { |
138 | var that = this; | 181 | var that = this; |
@@ -46,6 +46,30 @@ | @@ -46,6 +46,30 @@ | ||
46 | padding-left: 15rpx; | 46 | padding-left: 15rpx; |
47 | } | 47 | } |
48 | .basic-bottom { | 48 | .basic-bottom { |
49 | - width: 500rpx; | ||
50 | - margin-left: 86rpx; | 49 | + width: 750rpx; |
50 | + justify-content: space-between; | ||
51 | + .item { | ||
52 | + width: 318rpx; | ||
53 | + } | ||
54 | +} | ||
55 | + | ||
56 | +.logout-main { | ||
57 | + flex-direction: column; | ||
58 | + height: 300rpx; | ||
59 | + margin: 30rpx 40rpx; | ||
60 | + background: #f5f5f5; | ||
61 | + border-radius: 20rpx; | ||
62 | + .main { | ||
63 | + width: 669rpx; | ||
64 | + height: 100rpx; | ||
65 | + border-bottom: 1rpx solid #d6d6d6; | ||
66 | + text-align: center; | ||
67 | + line-height: 86rpx; | ||
68 | + } | ||
69 | + .main1 { | ||
70 | + width: 669rpx; | ||
71 | + height: 100rpx; | ||
72 | + text-align: center; | ||
73 | + line-height: 86rpx; | ||
74 | + } | ||
51 | } | 75 | } |
@@ -37,7 +37,7 @@ | @@ -37,7 +37,7 @@ | ||
37 | </template> | 37 | </template> |
38 | 38 | ||
39 | <script> | 39 | <script> |
40 | -import { mapMutations } from 'vuex'; | 40 | +import { mapMutations, mapActions } from 'vuex'; |
41 | import { loginApp } from '@/config/login'; | 41 | import { loginApp } from '@/config/login'; |
42 | import baseUrl from '@/config/baseUrl.js'; | 42 | import baseUrl from '@/config/baseUrl.js'; |
43 | import WXBizDataCrypt from '@/config/WXBizDataCrypt.js'; | 43 | import WXBizDataCrypt from '@/config/WXBizDataCrypt.js'; |
@@ -70,6 +70,12 @@ export default { | @@ -70,6 +70,12 @@ export default { | ||
70 | this.openid = res.data.openid; | 70 | this.openid = res.data.openid; |
71 | this.session_key = res.data.session_key; | 71 | this.session_key = res.data.session_key; |
72 | } | 72 | } |
73 | + }, | ||
74 | + complete: e => { | ||
75 | + if (e.data.errcode != null) { | ||
76 | + return; | ||
77 | + // return uni.$u.toast('获取用户唯一id失败'); | ||
78 | + } | ||
73 | } | 79 | } |
74 | }); | 80 | }); |
75 | } else { | 81 | } else { |
@@ -80,14 +86,19 @@ export default { | @@ -80,14 +86,19 @@ export default { | ||
80 | }, | 86 | }, |
81 | methods: { | 87 | methods: { |
82 | ...mapMutations(['setUserInfo']), | 88 | ...mapMutations(['setUserInfo']), |
89 | + ...mapActions(['updateBadgeTotal']), | ||
83 | //微信授权登录 | 90 | //微信授权登录 |
84 | //#ifdef MP | 91 | //#ifdef MP |
85 | onAuthorization(e) { | 92 | onAuthorization(e) { |
93 | + /** | ||
94 | + * 注意:通过wx.getUserProfile并不能获取用户的openid,openid是唯一识别用户的标识, | ||
95 | + * 所以最好在用户授权登录时就获取。调用wx.login()获取 | ||
96 | + */ | ||
86 | wx.getUserProfile({ | 97 | wx.getUserProfile({ |
87 | - desc: '获取用户信息', | 98 | + desc: '获取用户授权信息', |
88 | success: res => { | 99 | success: res => { |
89 | if (res) { | 100 | if (res) { |
90 | - //微信官方自带解密(node) | 101 | + //微信官方自带解密(node.js实现) |
91 | let pc = new WXBizDataCrypt(appId, this.session_key); | 102 | let pc = new WXBizDataCrypt(appId, this.session_key); |
92 | let data = pc.decryptData(res.encryptedData, res.iv); | 103 | let data = pc.decryptData(res.encryptedData, res.iv); |
93 | let obj = { | 104 | let obj = { |
@@ -100,11 +111,12 @@ export default { | @@ -100,11 +111,12 @@ export default { | ||
100 | .get(`/yt/third/login/${this.openid}`) | 111 | .get(`/yt/third/login/${this.openid}`) |
101 | .then(res => { | 112 | .then(res => { |
102 | if (res.token == '' || res.token == null) { | 113 | if (res.token == '' || res.token == null) { |
103 | - //需要绑定,跳转我的页面 | 114 | + //需要绑定,跳转我的页面进行绑定,显示绑定按钮 |
104 | uni.reLaunch({ | 115 | uni.reLaunch({ |
105 | url: '/pages/personal/personal' | 116 | url: '/pages/personal/personal' |
106 | }); | 117 | }); |
107 | } else { | 118 | } else { |
119 | + // 不需要绑定 | ||
108 | // 储存登录信息 | 120 | // 储存登录信息 |
109 | let resObj = { | 121 | let resObj = { |
110 | refreshToken: res.refreshToken, | 122 | refreshToken: res.refreshToken, |
@@ -122,12 +134,17 @@ export default { | @@ -122,12 +134,17 @@ export default { | ||
122 | icon: 'none' | 134 | icon: 'none' |
123 | }); | 135 | }); |
124 | this.saveUserInfo(); | 136 | this.saveUserInfo(); |
137 | + this.getAlarmTotalData(); | ||
125 | } | 138 | } |
126 | }) | 139 | }) |
127 | .catch(e => { | 140 | .catch(e => { |
128 | uni.$u.toast(e.data?.message); | 141 | uni.$u.toast(e.data?.message); |
129 | }); | 142 | }); |
130 | - // #ifdef APP-PLUS||MP | 143 | + /** |
144 | + * 有些时候uni.navigatorBack({})没有返回到上级页面 | ||
145 | + * 才使用uni.reLaunch()进行跳转 | ||
146 | + */ | ||
147 | + // #ifdef MP | ||
131 | setTimeout(() => { | 148 | setTimeout(() => { |
132 | uni.reLaunch({ | 149 | uni.reLaunch({ |
133 | url: '/pages/personal/personal?obj=' + encodeURIComponent(JSON.stringify(obj)) | 150 | url: '/pages/personal/personal?obj=' + encodeURIComponent(JSON.stringify(obj)) |
@@ -147,6 +164,14 @@ export default { | @@ -147,6 +164,14 @@ export default { | ||
147 | } | 164 | } |
148 | }); | 165 | }); |
149 | }, | 166 | }, |
167 | + getAlarmTotalData() { | ||
168 | + uni.$u.http.get('/yt/homepage/app').then(res => { | ||
169 | + if (res) { | ||
170 | + //异步实时更新告警徽标数 | ||
171 | + this.updateBadgeTotal(res.totalAlarm.activedAlarm); | ||
172 | + } | ||
173 | + }); | ||
174 | + }, | ||
150 | onSubmitFunc() { | 175 | onSubmitFunc() { |
151 | if (this.loginForm.username == '') { | 176 | if (this.loginForm.username == '') { |
152 | return uni.$u.toast('请输入登录账号~'); | 177 | return uni.$u.toast('请输入登录账号~'); |
@@ -199,6 +224,7 @@ export default { | @@ -199,6 +224,7 @@ export default { | ||
199 | // #endif | 224 | // #endif |
200 | }); | 225 | }); |
201 | this.saveUserInfo(); | 226 | this.saveUserInfo(); |
227 | + this.getAlarmTotalData(); | ||
202 | } | 228 | } |
203 | }) | 229 | }) |
204 | .catch(e => { | 230 | .catch(e => { |
@@ -172,6 +172,19 @@ button { | @@ -172,6 +172,19 @@ button { | ||
172 | font-weight: 400; | 172 | font-weight: 400; |
173 | color: #2f384e; | 173 | color: #2f384e; |
174 | } | 174 | } |
175 | +//筛选字体颜色 | ||
176 | +.select-text { | ||
177 | + font-size: 13px; | ||
178 | + font-family: PingFangSC-Regular, PingFang SC; | ||
179 | + font-weight: 400; | ||
180 | + color: #377dff !important; | ||
181 | +} | ||
182 | +.un-select-text { | ||
183 | + font-size: 13px; | ||
184 | + font-family: PingFangSC-Regular, PingFang SC; | ||
185 | + font-weight: 400; | ||
186 | + color: #333333 !important; | ||
187 | +} | ||
175 | // 定义flex等分 | 188 | // 定义flex等分 |
176 | @for $i from 0 through 12 { | 189 | @for $i from 0 through 12 { |
177 | .u-flex-#{$i} { | 190 | .u-flex-#{$i} { |