Authored by zhangwenxue

商品详情: 添加窗口同步关闭事件

@@ -69,6 +69,7 @@ export default { @@ -69,6 +69,7 @@ export default {
69 } 69 }
70 }, 70 },
71 hide() { 71 hide() {
  72 + this.$emit('hide');
72 this.isVisible = false; 73 this.isVisible = false;
73 }, 74 },
74 maskClick() { 75 maskClick() {
1 <template> 1 <template>
2 - <action-sheet @hidden="onHidden" ref="popup"> 2 + <action-sheet @hidden="onHidden" @hide="onHide" ref="popup">
3 <div class="activity-sheet"> 3 <div class="activity-sheet">
4 <h3>活动详情</h3> 4 <h3>活动详情</h3>
5 <div class="list" > 5 <div class="list" >
6 <cube-scroll ref="activityListScroll" :data="list"> 6 <cube-scroll ref="activityListScroll" :data="list">
7 <ul> 7 <ul>
8 <li v-for="(item, idx) in list" :key="idx"> 8 <li v-for="(item, idx) in list" :key="idx">
9 - <div class="activityName"><span>{{item.promotionTypeStr}}</span> {{item.activityName}}</div> 9 + <div class="activity-name"><span>{{item.promotionTypeStr}}</span> {{item.activityName}}</div>
10 <div class="sub">{{item.startTimeStr}}-{{item.endTimeStr}}</div> 10 <div class="sub">{{item.startTimeStr}}-{{item.endTimeStr}}</div>
11 </li> 11 </li>
12 </ul> 12 </ul>
@@ -41,6 +41,9 @@ export default { @@ -41,6 +41,9 @@ export default {
41 onHidden() { 41 onHidden() {
42 this.$emit('hidden'); 42 this.$emit('hidden');
43 }, 43 },
  44 + onHide() {
  45 + this.$emit('hide');
  46 + },
44 } 47 }
45 }; 48 };
46 </script> 49 </script>
@@ -89,7 +92,7 @@ export default { @@ -89,7 +92,7 @@ export default {
89 border-bottom: 1px solid #ccc; 92 border-bottom: 1px solid #ccc;
90 } 93 }
91 94
92 - .activityName { 95 + .activity-name {
93 font-size: 28px; 96 font-size: 28px;
94 font-weight: bold; 97 font-weight: bold;
95 } 98 }
1 <template> 1 <template>
2 <action-sheet position="right" ref="popup" 2 <action-sheet position="right" ref="popup"
3 @hidden="onHidden" 3 @hidden="onHidden"
  4 + @hide="onHide"
4 @shown="onShown" 5 @shown="onShown"
5 :panelStyle="{background: 'transparent', paddingLeft: '20%'}" 6 :panelStyle="{background: 'transparent', paddingLeft: '20%'}"
6 :hasBorderRadius="false" 7 :hasBorderRadius="false"
@@ -98,6 +99,9 @@ export default { @@ -98,6 +99,9 @@ export default {
98 onHidden() { 99 onHidden() {
99 this.$emit('hidden'); 100 this.$emit('hidden');
100 }, 101 },
  102 + onHide() {
  103 + this.$emit('hide');
  104 + },
101 onShown() { 105 onShown() {
102 // refresh list 106 // refresh list
103 if (this.$refs.scroll) { 107 if (this.$refs.scroll) {
1 <template> 1 <template>
2 - <action-sheet @hidden="onHidden" @shown="onShown" position="right" ref="popup" :full="true"> 2 + <action-sheet @hidden="onHidden" @hide="onHide" @shown="onShown" position="right" ref="popup" :full="true">
3 <div class="buy-sheet"> 3 <div class="buy-sheet">
4 <div class="header"> 4 <div class="header">
5 <div class="back-wrapper flex" @touchend="onBack"> 5 <div class="back-wrapper flex" @touchend="onBack">
@@ -77,6 +77,9 @@ export default { @@ -77,6 +77,9 @@ export default {
77 onHidden() { 77 onHidden() {
78 this.$emit('hidden'); 78 this.$emit('hidden');
79 }, 79 },
  80 + onHide() {
  81 + this.$emit('hide');
  82 + },
80 onShown() { 83 onShown() {
81 if (this.$refs.sizeList) { 84 if (this.$refs.sizeList) {
82 this.$refs.sizeList.refreshScroll(); 85 this.$refs.sizeList.refreshScroll();
1 <template> 1 <template>
2 - <action-sheet @hidden="onHidden" @shown="onShown" ref="popup"> 2 + <action-sheet @hidden="onHidden" @hide="onHide" @shown="onShown" ref="popup">
3 <div class="size-select-sheet"> 3 <div class="size-select-sheet">
4 <div class="select-size"> 4 <div class="select-size">
5 <div class="title" @click="hide">{{config.title}}<i class="cubeic-close"></i></div> 5 <div class="title" @click="hide">{{config.title}}<i class="cubeic-close"></i></div>
@@ -148,6 +148,9 @@ export default { @@ -148,6 +148,9 @@ export default {
148 onHidden() { 148 onHidden() {
149 this.$emit('hidden'); 149 this.$emit('hidden');
150 }, 150 },
  151 + onHide() {
  152 + this.$emit('hide');
  153 + },
151 onShown() { 154 onShown() {
152 if (this.$refs.sizeList) { 155 if (this.$refs.sizeList) {
153 this.$refs.sizeList.refreshScroll(); 156 this.$refs.sizeList.refreshScroll();
@@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
2 <div class="layout"> 2 <div class="layout">
3 <LayoutHeader class="layout-header" :show-back="true" :title="'\u200E'"></LayoutHeader> 3 <LayoutHeader class="layout-header" :show-back="true" :title="'\u200E'"></LayoutHeader>
4 <div class="layout-context fixscroll"> 4 <div class="layout-context fixscroll">
5 - <cube-scroll :data="imageList" ref="pageScroll"> 5 + <cube-scroll ref="pageScroll">
6 <div class="slide"> 6 <div class="slide">
7 <cube-slide ref="slide" :data="imageList"> 7 <cube-slide ref="slide" :data="imageList">
8 <cube-slide-item v-for="(item, index) in imageList" :key="index"> 8 <cube-slide-item v-for="(item, index) in imageList" :key="index">
@@ -80,16 +80,16 @@ @@ -80,16 +80,16 @@
80 <cube-button class="sell" @click="sell">出售</cube-button> 80 <cube-button class="sell" @click="sell">出售</cube-button>
81 <cube-button class="buy active" @click="buy">购买</cube-button> 81 <cube-button class="buy active" @click="buy">购买</cube-button>
82 </div> 82 </div>
83 - <buy-sheet v-if="showBidSheet" @hidden="onBidSheet" :productId="productId"/>  
84 - <size-request-sheet v-if="showSizeRequestSheet" @hidden="onSizeRequestHidden" :productId="productId"/> 83 + <buy-sheet v-if="showBidSheet" @hide="onBidSheetHide" :productId="productId"/>
  84 + <size-request-sheet v-if="showSizeRequestSheet" @hide="onSizeRequestHide" :productId="productId"/>
85 </div> 85 </div>
86 - <activity-list-sheet v-if="showActivitySheet" :list="activity" @hidden="onActivitySheetHidden"/> 86 + <activity-list-sheet v-if="showActivitySheet" :list="activity" @hide="onActivitySheetHide"/>
87 <size-select-sheet v-if="showSizeSelectSheet" 87 <size-select-sheet v-if="showSizeSelectSheet"
88 :list="sizeList" 88 :list="sizeList"
89 :product="productDetail" 89 :product="productDetail"
90 :image-list="imageList" 90 :image-list="imageList"
91 :config="selectSizeConfig" 91 :config="selectSizeConfig"
92 - @hidden="onSizeSelectSheetHidden" 92 + @hide="onSizeSelectSheetHide"
93 @select="onSelectTradeProduct" 93 @select="onSelectTradeProduct"
94 @add="onRequestSize"/> 94 @add="onRequestSize"/>
95 </div> 95 </div>
@@ -194,20 +194,25 @@ export default { @@ -194,20 +194,25 @@ export default {
194 194
195 // 在action-sheet显示控制与对应关闭方法 195 // 在action-sheet显示控制与对应关闭方法
196 this.actionSheetCloseMap = { 196 this.actionSheetCloseMap = {
197 - showActivitySheet: 'onActivitySheetHidden',  
198 - showBidSheet: 'onBidSheet',  
199 - showSizeSelectSheet: 'onSizeSelectSheetHidden',  
200 - showSizeRequestSheet: 'onSizeRequestHidden', 197 + showActivitySheet: 'onActivitySheetHide',
  198 + showBidSheet: 'onBidSheetHide',
  199 + showSizeSelectSheet: 'onSizeSelectSheetHide',
  200 + showSizeRequestSheet: 'onSizeRequestHide',
201 }; 201 };
202 }, 202 },
203 asyncData({store, router}) { 203 asyncData({store, router}) {
204 const productId = parseInt(router.params.productId, 10); 204 const productId = parseInt(router.params.productId, 10);
205 205
  206 + if (isNaN(productId)) {
  207 + throw new Error('无效的商品ID');
  208 + }
  209 +
206 return store.dispatch('product/fetchProductInfo', {productId}); 210 return store.dispatch('product/fetchProductInfo', {productId});
207 }, 211 },
208 activated() { 212 activated() {
209 this.$refs.pageScroll && this.$refs.pageScroll.scrollTo(0, 0, 0); 213 this.$refs.pageScroll && this.$refs.pageScroll.scrollTo(0, 0, 0);
210 this.loadData(this.productId); 214 this.loadData(this.productId);
  215 + this.refresh();
211 }, 216 },
212 beforeRouteUpdate(to, from ,next) { 217 beforeRouteUpdate(to, from ,next) {
213 if (this.historyBackGuard() === false) { 218 if (this.historyBackGuard() === false) {
@@ -236,7 +241,7 @@ export default { @@ -236,7 +241,7 @@ export default {
236 return true; 241 return true;
237 }, 242 },
238 refresh() { 243 refresh() {
239 - this.$refs.slide.refresh(); 244 + this.$refs.slide && this.$refs.slide.refresh && this.$refs.slide.refresh();
240 }, 245 },
241 sizeImg(src, width = 360, height = 72) { 246 sizeImg(src, width = 360, height = 72) {
242 if (src) { 247 if (src) {
@@ -312,12 +317,12 @@ export default { @@ -312,12 +317,12 @@ export default {
312 }, 317 },
313 318
314 // 关闭活动列表 319 // 关闭活动列表
315 - onActivitySheetHidden() { 320 + onActivitySheetHide() {
316 this.showActivitySheet = false; 321 this.showActivitySheet = false;
317 }, 322 },
318 323
319 // 选择尺寸 324 // 选择尺寸
320 - onSizeSelectSheetHidden() { 325 + onSizeSelectSheetHide() {
321 this.showSizeSelectSheet = false; 326 this.showSizeSelectSheet = false;
322 }, 327 },
323 328
@@ -424,7 +429,7 @@ export default { @@ -424,7 +429,7 @@ export default {
424 }, 429 },
425 430
426 // 添加尺寸关闭 431 // 添加尺寸关闭
427 - onSizeRequestHidden() { 432 + onSizeRequestHide() {
428 this.showSizeRequestSheet = false; 433 this.showSizeRequestSheet = false;
429 }, 434 },
430 435
@@ -434,7 +439,7 @@ export default { @@ -434,7 +439,7 @@ export default {
434 }, 439 },
435 440
436 // 购买 441 // 购买
437 - onBidSheet() { 442 + onBidSheetHide() {
438 this.showBidSheet = false; 443 this.showBidSheet = false;
439 }, 444 },
440 }, 445 },
@@ -576,7 +581,7 @@ export default { @@ -576,7 +581,7 @@ export default {
576 flex-direction: column; 581 flex-direction: column;
577 justify-content: center; 582 justify-content: center;
578 align-items: center; 583 align-items: center;
579 - overflow: hidden; 584 + overflow: Hide;
580 585
581 div { 586 div {
582 font-size: 28px; 587 font-size: 28px;