Commit 4cbdac62dda0baac275f0356e6c3768e3698d6f7
1 parent
308601d0
Exists in
master
feat: 清除缓存功能
Showing
2 changed files
with
82 additions
and
61 deletions
Show diff stats
src/views/Home/Home.vue
... | ... | @@ -3,13 +3,16 @@ |
3 | 3 | <div class="infomation"> |
4 | 4 | <div class="top"> |
5 | 5 | <div> |
6 | - <img class="head" :src="headImgUrl?headImgUrl:defaultHead" alt=""> | |
6 | + <img class="head" :src="headImgUrl ? headImgUrl : defaultHead" alt="" /> | |
7 | 7 | <div class="right"> |
8 | 8 | <!-- <p class="name">{{nicknameUser}}</p> --> |
9 | - <div class="name"><span>{{nicknameUser}}</span> | |
10 | - <div class="school" v-show="schoolNamesChoose" @click="changeSchool">{{schoolNamesChoose.schoolName}}<img src="@/assets/Travel/change.png" /></div> | |
9 | + <div class="name"> | |
10 | + <span>{{ nicknameUser }}</span> | |
11 | + <div class="school" v-show="schoolNamesChoose" @click="changeSchool"> | |
12 | + {{ schoolNamesChoose.schoolName }}<img src="@/assets/Travel/change.png" /> | |
13 | + </div> | |
11 | 14 | </div> |
12 | - <p class="phone">{{userInfo.phone}}</p> | |
15 | + <p class="phone">{{ userInfo.phone }}</p> | |
13 | 16 | </div> |
14 | 17 | </div> |
15 | 18 | <HomeScan></HomeScan> |
... | ... | @@ -24,20 +27,20 @@ |
24 | 27 | </div> |
25 | 28 | <van-icon name="arrow" /> |
26 | 29 | </div> |
27 | - <!-- <div class="item" @click="handleMyInfo"> | |
30 | + <div class="item" @click="handleClearCache"> | |
28 | 31 | <div class="left"> |
29 | 32 | <van-icon class="icon" name="user-circle-o" /> |
30 | - <span>个人信息</span> | |
33 | + <span>清除缓存</span> | |
31 | 34 | </div> |
32 | 35 | <van-icon name="arrow" /> |
33 | - </div> --> | |
36 | + </div> | |
34 | 37 | <div class="item" @click="handelElder"> |
35 | 38 | <div class="left"> |
36 | 39 | <van-icon class="icon" name="friends-o" /> |
37 | 40 | <span>长辈版</span> |
38 | 41 | </div> |
39 | 42 | <p> |
40 | - {{isElder?'已开启':'未开启'}} | |
43 | + {{ isElder ? '已开启' : '未开启' }} | |
41 | 44 | <van-icon name="arrow" /> |
42 | 45 | </p> |
43 | 46 | </div> |
... | ... | @@ -59,7 +62,7 @@ import HomeOrder from '@/views/Home/component/HomeOrder' |
59 | 62 | import HomeScan from '@/views/Home/component/HomeScan' |
60 | 63 | import Tabbar4 from '@/component/Tabbar4' |
61 | 64 | export default { |
62 | - data () { | |
65 | + data() { | |
63 | 66 | return { |
64 | 67 | centerNo: '', |
65 | 68 | userInfo: { |
... | ... | @@ -80,11 +83,11 @@ export default { |
80 | 83 | isElder: false, |
81 | 84 | showChildList: false, |
82 | 85 | showSchool: false, |
83 | - schoolNamesChoose: '' | |
86 | + schoolNamesChoose: '', | |
84 | 87 | } |
85 | 88 | }, |
86 | 89 | |
87 | - mounted () { | |
90 | + mounted() { | |
88 | 91 | const isElder = localStorage.getItem('isElder') |
89 | 92 | if (isElder) { |
90 | 93 | this.isElder = true |
... | ... | @@ -94,51 +97,51 @@ export default { |
94 | 97 | if (schoolNamesChoose) { |
95 | 98 | this.schoolNamesChoose = JSON.parse(schoolNamesChoose) |
96 | 99 | } |
97 | - this.centerNo = localStorage.getItem('centerNo'); | |
100 | + this.centerNo = localStorage.getItem('centerNo') | |
98 | 101 | this.getUserInfo() |
99 | 102 | this.againRZ() |
100 | - | |
101 | 103 | }, |
102 | 104 | computed: { |
103 | - schoolNames () { | |
105 | + schoolNames() { | |
104 | 106 | return this.$store.state.schoolName |
105 | - } | |
107 | + }, | |
106 | 108 | }, |
107 | 109 | methods: { |
108 | 110 | // 研学码 |
109 | - handleYanxue () { | |
111 | + handleYanxue() { | |
110 | 112 | this.$router.push({ name: 'YanxueCode' }) |
111 | 113 | }, |
112 | 114 | // 我的订单 |
113 | - handleOrder () { | |
115 | + handleOrder() { | |
114 | 116 | this.$router.push({ name: 'ServiceOrderXST' }) |
115 | 117 | }, |
116 | 118 | // 集团认证 |
117 | - handleGroup () { | |
118 | - this.$toast('暂未开放,敬请期待!'); | |
119 | + handleGroup() { | |
120 | + this.$toast('暂未开放,敬请期待!') | |
119 | 121 | }, |
120 | 122 | // 我的优惠券 |
121 | - handleMyCard () { | |
123 | + handleMyCard() { | |
122 | 124 | this.$router.push({ name: 'CardBoxXST' }) |
123 | 125 | }, |
124 | 126 | // 个人信息 |
125 | - handleMyInfo () { | |
127 | + handleMyInfo() { | |
126 | 128 | this.$router.push({ name: 'HomeUserInfo' }) |
127 | 129 | }, |
128 | 130 | // 合伙人中心 |
129 | - handlePartner () { | |
130 | - this.$toast('暂未开放,敬请期待!'); | |
131 | + handlePartner() { | |
132 | + this.$toast('暂未开放,敬请期待!') | |
131 | 133 | // this.$router.push({ name: 'Partner' }) |
132 | 134 | }, |
133 | 135 | // 点击长辈版 |
134 | - handelElder () { | |
136 | + handelElder() { | |
135 | 137 | if (this.isElder) { |
136 | - this.$dialog.confirm({ | |
137 | - title: '长辈版', | |
138 | - message: '超大字号,看的更清楚,长辈版,专为长辈设计', | |
139 | - confirmButtonColor: '#ee0a24', | |
140 | - confirmButtonText: '关闭长辈版模式' | |
141 | - }) | |
138 | + this.$dialog | |
139 | + .confirm({ | |
140 | + title: '长辈版', | |
141 | + message: '超大字号,看的更清楚,长辈版,专为长辈设计', | |
142 | + confirmButtonColor: '#ee0a24', | |
143 | + confirmButtonText: '关闭长辈版模式', | |
144 | + }) | |
142 | 145 | .then(() => { |
143 | 146 | // on confirm |
144 | 147 | this.isElder = false |
... | ... | @@ -147,14 +150,15 @@ export default { |
147 | 150 | }) |
148 | 151 | .catch(() => { |
149 | 152 | // on cancel |
150 | - }); | |
153 | + }) | |
151 | 154 | } else { |
152 | - this.$dialog.confirm({ | |
153 | - title: '长辈版', | |
154 | - message: '超大字号,看的更清楚,长辈版,专为长辈设计', | |
155 | - confirmButtonColor: '#3385FF', | |
156 | - confirmButtonText: '开启长辈版模式' | |
157 | - }) | |
155 | + this.$dialog | |
156 | + .confirm({ | |
157 | + title: '长辈版', | |
158 | + message: '超大字号,看的更清楚,长辈版,专为长辈设计', | |
159 | + confirmButtonColor: '#3385FF', | |
160 | + confirmButtonText: '开启长辈版模式', | |
161 | + }) | |
158 | 162 | .then(() => { |
159 | 163 | // on confirm |
160 | 164 | this.isElder = true |
... | ... | @@ -163,11 +167,25 @@ export default { |
163 | 167 | }) |
164 | 168 | .catch(() => { |
165 | 169 | // on cancel |
166 | - }); | |
170 | + }) | |
167 | 171 | } |
168 | 172 | }, |
173 | + // 清除缓存 | |
174 | + handleClearCache() { | |
175 | + this.$toast.loading({ | |
176 | + message: '正在清除', | |
177 | + duration: 1000, | |
178 | + forbidClick: true, | |
179 | + }) | |
180 | + setTimeout(() => { | |
181 | + this.$toast('清除成功') | |
182 | + localStorage.removeItem('schoolNamesChoose') | |
183 | + localStorage.removeItem('schoolNames') | |
184 | + this.getUserInfo() | |
185 | + }, 1000) | |
186 | + }, | |
169 | 187 | // 获取用户信息 |
170 | - getUserInfo () { | |
188 | + getUserInfo() { | |
171 | 189 | this.mgop({ |
172 | 190 | api: 'mgop.sz.hswsy.getPortalUserByNum', // 必须 |
173 | 191 | host: 'https://mapi.zjzwfw.gov.cn/', |
... | ... | @@ -178,18 +196,19 @@ export default { |
178 | 196 | // 'isTestUrl': '1' |
179 | 197 | }, |
180 | 198 | data: { |
181 | - "userNum": this.centerNo | |
199 | + userNum: this.centerNo, | |
182 | 200 | }, |
183 | - onSuccess: res => { | |
201 | + onSuccess: (res) => { | |
184 | 202 | console.log('getUserInfo', res) |
185 | 203 | if (res.data.code == 200) { |
186 | - let userInfo = res.data.data.userInfo; | |
187 | - this.userInfo = userInfo; | |
204 | + let userInfo = res.data.data.userInfo | |
205 | + this.userInfo = userInfo | |
188 | 206 | localStorage.setItem('userInfo', JSON.stringify(userInfo)) |
189 | 207 | if (userInfo.schoolNames || userInfo.schoolNames == [] || userInfo.schoolNames == 'null') { |
208 | + userInfo.schoolNames = userInfo.schoolNames.filter(n => n) | |
190 | 209 | localStorage.setItem('schoolNames', JSON.stringify(userInfo.schoolNames)) |
191 | 210 | this.$store.commit('changeSchool', userInfo.schoolNames) |
192 | - if (!localStorage.getItem('schoolNamesChoose')) { | |
211 | + if (!localStorage.getItem('schoolNamesChoose')||localStorage.getItem('schoolNamesChoose')=='null') { | |
193 | 212 | localStorage.setItem('schoolNamesChoose', JSON.stringify(userInfo.schoolNames[0])) |
194 | 213 | this.schoolNamesChoose = userInfo.schoolNames[0] |
195 | 214 | } |
... | ... | @@ -200,49 +219,49 @@ export default { |
200 | 219 | } |
201 | 220 | this.showChildList = true |
202 | 221 | }, |
203 | - onFail: err => { | |
222 | + onFail: (err) => { | |
204 | 223 | console.log('err', err) |
205 | - } | |
206 | - }); | |
224 | + }, | |
225 | + }) | |
207 | 226 | }, |
208 | - formatterTime (time) { | |
227 | + formatterTime(time) { | |
209 | 228 | if (time) { |
210 | 229 | return time.split(' ')[0] |
211 | 230 | } else { |
212 | 231 | return '' |
213 | 232 | } |
214 | 233 | }, |
215 | - complete () { | |
234 | + complete() { | |
216 | 235 | this.getUserInfo() |
217 | 236 | }, |
218 | 237 | //切换学校 |
219 | - changeSchool () { | |
238 | + changeSchool() { | |
220 | 239 | this.$router.push({ name: 'schoolFollow' }) |
221 | 240 | }, |
222 | 241 | //集团回调关闭页面 |
223 | - closeJT () { | |
242 | + closeJT() { | |
224 | 243 | this.showSchool = false |
225 | 244 | this.getUserInfo() |
226 | 245 | }, |
227 | 246 | //查看是否有集团认证 |
228 | - getRZ () { | |
247 | + getRZ() { | |
229 | 248 | // this.showSchool = true |
230 | 249 | this.$router.push({ name: 'schoolAttestation' }) |
231 | 250 | }, |
232 | 251 | //回跳重新认证 |
233 | - againRZ () { | |
252 | + againRZ() { | |
234 | 253 | let backRZ = localStorage.getItem('backRZ') |
235 | 254 | if (backRZ == 'true') { |
236 | 255 | this.showSchool = true |
237 | 256 | localStorage.setItem('backRZ', false) |
238 | 257 | } |
239 | - } | |
258 | + }, | |
240 | 259 | }, |
241 | 260 | components: { |
242 | 261 | Tabbar4, |
243 | 262 | HomeChildList, |
244 | 263 | HomeOrder, |
245 | - HomeScan | |
264 | + HomeScan, | |
246 | 265 | }, |
247 | 266 | } |
248 | 267 | </script> |
... | ... | @@ -255,7 +274,7 @@ export default { |
255 | 274 | .infomation { |
256 | 275 | width: 100%; |
257 | 276 | height: 320px; |
258 | - background: url("~@/assets/home/bg_kq.png"); | |
277 | + background: url('~@/assets/home/bg_kq.png'); | |
259 | 278 | background-size: 100%; |
260 | 279 | background-position: center; |
261 | 280 | .top { | ... | ... |
src/views/Travel/component/schoolAdd.vue
... | ... | @@ -110,13 +110,15 @@ export default { |
110 | 110 | this.yxAxios.get(`${this.proxyUrl}/prod/api/wx/${appid}/getUserInfo?unionId=${localStorage.getItem('unionId')}`).then((res) => { |
111 | 111 | this.$toast.clear() |
112 | 112 | if (res.data.code == 200) { |
113 | - localStorage.setItem('userInfo', JSON.stringify(res.data.data)) | |
113 | + let userInfo = res.data.data | |
114 | + localStorage.setItem('userInfo', JSON.stringify(userInfo)) | |
114 | 115 | |
115 | - if(res.data.data.schoolNames || res.data.data.schoolNames == [] || res.data.data.schoolNames == 'null') { | |
116 | - localStorage.setItem('schoolNames',JSON.stringify(res.data.data.schoolNames)) | |
117 | - this.$store.commit('changeSchool', res.data.data.schoolNames) | |
116 | + if(userInfo.schoolNames || userInfo.schoolNames == [] || userInfo.schoolNames == 'null') { | |
117 | + userInfo.schoolNames = userInfo.schoolNames.filter(n => n) | |
118 | + localStorage.setItem('schoolNames',JSON.stringify(userInfo.schoolNames)) | |
119 | + this.$store.commit('changeSchool', userInfo.schoolNames) | |
118 | 120 | if(!localStorage.getItem('schoolNamesChoose')) { |
119 | - localStorage.setItem('schoolNamesChoose',JSON.stringify(res.data.data.schoolNames[0])) | |
121 | + localStorage.setItem('schoolNamesChoose',JSON.stringify(userInfo.schoolNames[0])) | |
120 | 122 | } |
121 | 123 | }else { |
122 | 124 | localStorage.setItem('schoolNames',[]) | ... | ... |