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