Merge branch 'release/4.0' of http://git.yoho.cn/fe/yohoblk-wap into release/4.0
Showing
8 changed files
with
92 additions
and
4 deletions
@@ -12,6 +12,10 @@ yoho.ready(() => { | @@ -12,6 +12,10 @@ yoho.ready(() => { | ||
12 | yoho.showLoading(false); | 12 | yoho.showLoading(false); |
13 | 13 | ||
14 | $('.home').on('click', () => { | 14 | $('.home').on('click', () => { |
15 | - yoho.goBack(); | 15 | + if(yoho.isYohoBuy) { |
16 | + yoho.goNewBack(); | ||
17 | + } else { | ||
18 | + yoho.goBack(); | ||
19 | + } | ||
16 | }); | 20 | }); |
17 | }); | 21 | }); |
@@ -299,6 +299,23 @@ const yoho = { | @@ -299,6 +299,23 @@ const yoho = { | ||
299 | }, | 299 | }, |
300 | 300 | ||
301 | /** | 301 | /** |
302 | + * 新的返回上一级页面 | ||
303 | + * @param args {""} | ||
304 | + * @param success | ||
305 | + * @param fail | ||
306 | + */ | ||
307 | + goNewBack(args, success, fail) { | ||
308 | + if (this.isYohoBuy && window.yohoInterface) { | ||
309 | + window.yohoInterface.triggerEvent(success || nullFun, fail || nullFun, { | ||
310 | + method: 'go.newback', | ||
311 | + arguments: args | ||
312 | + }); | ||
313 | + } else { | ||
314 | + history.go(-1); | ||
315 | + } | ||
316 | + }, | ||
317 | + | ||
318 | + /** | ||
302 | * 联系电话 | 319 | * 联系电话 |
303 | * @param args {""} | 320 | * @param args {""} |
304 | * @param success | 321 | * @param success |
1 | <template> | 1 | <template> |
2 | <img v-if="lazy" v-lazy="currentSrc" alt="" :width="width" :height="height"> | 2 | <img v-if="lazy" v-lazy="currentSrc" alt="" :width="width" :height="height"> |
3 | - <img v-else :src="currentSrc" alt="" :width="width" :height="height"> | 3 | + <img v-else ref="image" :src="currentSrc" alt="" :width="width" :height="height"> |
4 | </template> | 4 | </template> |
5 | 5 | ||
6 | <script> | 6 | <script> |
@@ -27,6 +27,24 @@ export default { | @@ -27,6 +27,24 @@ export default { | ||
27 | } | 27 | } |
28 | return this.src; | 28 | return this.src; |
29 | } | 29 | } |
30 | + }, | ||
31 | + mounted() { | ||
32 | +// let timer; | ||
33 | +// let img = new Image(); | ||
34 | +// let maxRetry = 30 * 1000; | ||
35 | +// let start = Date.now(); | ||
36 | +// | ||
37 | +// timer = setInterval(() => { | ||
38 | +// img.src = this.$refs.image.src; | ||
39 | +// | ||
40 | +// if (!img.src) { | ||
41 | +// clearInterval(timer); | ||
42 | +// } | ||
43 | +// | ||
44 | +// if (img.complete || Date.now() - start > maxRetry) { | ||
45 | +// clearInterval(timer); | ||
46 | +// } | ||
47 | +// }, 3000); | ||
30 | } | 48 | } |
31 | }; | 49 | }; |
32 | </script> | 50 | </script> |
@@ -48,7 +48,22 @@ export default { | @@ -48,7 +48,22 @@ export default { | ||
48 | }, | 48 | }, |
49 | methods: { | 49 | methods: { |
50 | toggle(idx) { | 50 | toggle(idx) { |
51 | - this.$set(this.show, idx, !this.show[idx]); | 51 | + for (let i = 0; i < this.show.length; i++) { |
52 | + if (i !== idx) { | ||
53 | + this.$set(this.show, i, false); | ||
54 | + this.$set(this.sortClass, i, { | ||
55 | + 'icon-sort-up': false, | ||
56 | + 'icon-sort-down': true | ||
57 | + }); | ||
58 | + } else { | ||
59 | + this.$set(this.show, i, !this.show[idx]); | ||
60 | + this.$set(this.sortClass, i, { | ||
61 | + 'icon-sort-up': true, | ||
62 | + 'icon-sort-down': false | ||
63 | + }); | ||
64 | + } | ||
65 | + } | ||
66 | + | ||
52 | this.$set(this.sortClass, idx, { | 67 | this.$set(this.sortClass, idx, { |
53 | 'icon-sort-up': this.show[idx], | 68 | 'icon-sort-up': this.show[idx], |
54 | 'icon-sort-down': !this.show[idx] | 69 | 'icon-sort-down': !this.show[idx] |
@@ -40,6 +40,13 @@ export default { | @@ -40,6 +40,13 @@ export default { | ||
40 | computed: { | 40 | computed: { |
41 | ...mapState(['channel']), | 41 | ...mapState(['channel']), |
42 | }, | 42 | }, |
43 | + beforeRouteEnter (to, from, next) { | ||
44 | + next(vm => { | ||
45 | + if (vm.$yoho && vm.$yoho.isAndroid) { | ||
46 | + vm.$yoho.blkBackStatus(true); | ||
47 | + } | ||
48 | + }); | ||
49 | + }, | ||
43 | asyncData({store}) { | 50 | asyncData({store}) { |
44 | return store.dispatch(FETCH_ABOUT_REQUEST); | 51 | return store.dispatch(FETCH_ABOUT_REQUEST); |
45 | }, | 52 | }, |
@@ -67,6 +67,13 @@ | @@ -67,6 +67,13 @@ | ||
67 | return this.$store.state.channel[this.gender].floors; | 67 | return this.$store.state.channel[this.gender].floors; |
68 | } | 68 | } |
69 | }, | 69 | }, |
70 | + beforeRouteEnter (to, from, next) { | ||
71 | + next(vm => { | ||
72 | + if (vm.$yoho && vm.$yoho.isAndroid) { | ||
73 | + vm.$yoho.blkBackStatus(true); | ||
74 | + } | ||
75 | + }); | ||
76 | + }, | ||
70 | asyncData({store, router: to}) { | 77 | asyncData({store, router: to}) { |
71 | const gender = /\/channel\/men/.test(to.path) ? 'men' : 'women'; | 78 | const gender = /\/channel\/men/.test(to.path) ? 'men' : 'women'; |
72 | return store.dispatch(FETCH_CHANNEL_REQUEST, {gender}); | 79 | return store.dispatch(FETCH_CHANNEL_REQUEST, {gender}); |
@@ -2,9 +2,11 @@ import { | @@ -2,9 +2,11 @@ import { | ||
2 | FETCH_HOME_REQUEST, | 2 | FETCH_HOME_REQUEST, |
3 | FETCH_HOME_FAILURE, | 3 | FETCH_HOME_FAILURE, |
4 | FETCH_HOME_SUCCESS, | 4 | FETCH_HOME_SUCCESS, |
5 | + REFRESH_HOME_RESET, | ||
5 | FETCH_CHANNEL_REQUEST, | 6 | FETCH_CHANNEL_REQUEST, |
6 | FETCH_CHANNEL_SUCCESS, | 7 | FETCH_CHANNEL_SUCCESS, |
7 | FETCH_CHANNEL_FAILURE, | 8 | FETCH_CHANNEL_FAILURE, |
9 | + REFRESH_CHANNEL_RESET, | ||
8 | FETCH_ABOUT_REQUEST, | 10 | FETCH_ABOUT_REQUEST, |
9 | FETCH_ABOUT_SUCCESS, | 11 | FETCH_ABOUT_SUCCESS, |
10 | FETCH_ABOUT_FAILURE | 12 | FETCH_ABOUT_FAILURE |
@@ -22,7 +24,7 @@ export function createChannel() { | @@ -22,7 +24,7 @@ export function createChannel() { | ||
22 | return { | 24 | return { |
23 | state: { | 25 | state: { |
24 | home: {}, | 26 | home: {}, |
25 | - slider: {}, | 27 | + slider: [], |
26 | about: {}, | 28 | about: {}, |
27 | gender: 'men', | 29 | gender: 'men', |
28 | men: { | 30 | men: { |
@@ -50,6 +52,10 @@ export function createChannel() { | @@ -50,6 +52,10 @@ export function createChannel() { | ||
50 | state.home = result.data; | 52 | state.home = result.data; |
51 | state.slider = slider.data[0].data; | 53 | state.slider = slider.data[0].data; |
52 | }, | 54 | }, |
55 | + [REFRESH_HOME_RESET](state) { | ||
56 | + state.home = []; | ||
57 | + state.slider = []; | ||
58 | + }, | ||
53 | [FETCH_ABOUT_REQUEST](state) { | 59 | [FETCH_ABOUT_REQUEST](state) { |
54 | state.fetchingAbout = true; | 60 | state.fetchingAbout = true; |
55 | }, | 61 | }, |
@@ -67,6 +73,10 @@ export function createChannel() { | @@ -67,6 +73,10 @@ export function createChannel() { | ||
67 | [FETCH_CHANNEL_FAILURE](state) { | 73 | [FETCH_CHANNEL_FAILURE](state) { |
68 | state[state.gender].isFetching = false; | 74 | state[state.gender].isFetching = false; |
69 | }, | 75 | }, |
76 | + [REFRESH_CHANNEL_RESET](state) { | ||
77 | + state[state.gender].floors = []; | ||
78 | + state[state.gender].sort = []; | ||
79 | + }, | ||
70 | [FETCH_CHANNEL_SUCCESS](state, {data, sort, cache}) { | 80 | [FETCH_CHANNEL_SUCCESS](state, {data, sort, cache}) { |
71 | if (!cache) { | 81 | if (!cache) { |
72 | const keyCvt = { | 82 | const keyCvt = { |
@@ -96,6 +106,10 @@ export function createChannel() { | @@ -96,6 +106,10 @@ export function createChannel() { | ||
96 | } | 106 | } |
97 | 107 | ||
98 | commit(FETCH_HOME_REQUEST); | 108 | commit(FETCH_HOME_REQUEST); |
109 | + | ||
110 | + if (refresh) { | ||
111 | + commit(REFRESH_HOME_RESET); | ||
112 | + } | ||
99 | try { | 113 | try { |
100 | const getContent = this.$api.get('/api/resource/get', { | 114 | const getContent = this.$api.get('/api/resource/get', { |
101 | home_invalid_cache: Date.now(), | 115 | home_invalid_cache: Date.now(), |
@@ -121,6 +135,10 @@ export function createChannel() { | @@ -121,6 +135,10 @@ export function createChannel() { | ||
121 | commit(FETCH_CHANNEL_SUCCESS, {cache: true}); | 135 | commit(FETCH_CHANNEL_SUCCESS, {cache: true}); |
122 | return Promise.resolve(); | 136 | return Promise.resolve(); |
123 | } | 137 | } |
138 | + | ||
139 | + if (refresh) { | ||
140 | + commit(REFRESH_CHANNEL_RESET); | ||
141 | + } | ||
124 | try { | 142 | try { |
125 | let getSort = this.$api.get('/sort/list', { | 143 | let getSort = this.$api.get('/sort/list', { |
126 | home_invalid_cache: Date.now(), | 144 | home_invalid_cache: Date.now(), |
1 | export const FETCH_HOME_REQUEST = 'FETCH_HOME_REQUEST'; | 1 | export const FETCH_HOME_REQUEST = 'FETCH_HOME_REQUEST'; |
2 | export const FETCH_HOME_SUCCESS = 'FETCH_HOME_SUCCESS'; | 2 | export const FETCH_HOME_SUCCESS = 'FETCH_HOME_SUCCESS'; |
3 | export const FETCH_HOME_FAILURE = 'FETCH_HOME_FAILURE'; | 3 | export const FETCH_HOME_FAILURE = 'FETCH_HOME_FAILURE'; |
4 | +export const REFRESH_HOME_RESET = 'REFRESH_HOME_RESET'; | ||
4 | 5 | ||
5 | export const FETCH_CHANNEL_REQUEST = 'FETCH_CHANNEL_REQUEST'; | 6 | export const FETCH_CHANNEL_REQUEST = 'FETCH_CHANNEL_REQUEST'; |
6 | export const FETCH_CHANNEL_SUCCESS = 'FETCH_CHANNEL_SUCCESS'; | 7 | export const FETCH_CHANNEL_SUCCESS = 'FETCH_CHANNEL_SUCCESS'; |
7 | export const FETCH_CHANNEL_FAILURE = 'FETCH_CHANNEL_FAILURE'; | 8 | export const FETCH_CHANNEL_FAILURE = 'FETCH_CHANNEL_FAILURE'; |
9 | +export const REFRESH_CHANNEL_RESET = 'REFRESH_CHANNEL_RESET'; | ||
8 | 10 | ||
9 | export const FETCH_ABOUT_REQUEST = 'FETCH_ABOUT_REQUEST'; | 11 | export const FETCH_ABOUT_REQUEST = 'FETCH_ABOUT_REQUEST'; |
10 | export const FETCH_ABOUT_SUCCESS = 'FETCH_ABOUT_SUCCESS'; | 12 | export const FETCH_ABOUT_SUCCESS = 'FETCH_ABOUT_SUCCESS'; |
-
Please register or login to post a comment