entry-detail.vue
6.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
<template>
<LayoutApp :title="title" :class="classes">
<ScrollView ref="scroll" :options="scrollOption" @pulling-up="onPullingUp" @pulling-down="onPullingDown">
<div class="order-page">
<!-- <div class="title">出售中</div>-->
<!--商品详情-->
<div class="product" @click="onClickProduct">
<div class="pro-img">
<ImgSize :src="productInfo.imageUrl" :width="200"></ImgSize>
</div>
<div class="pro-info">
<p class="pro-name">{{productInfo.productName}}</p>
<p class="stock-info">
<!-- <Logo :text="`有货UFO`" class="logo-wrapper"></Logo>-->
<p class="stock-text">{{productInfo.colorName}}, {{productInfo.sizeNum}}个尺码, {{productInfo.storageNum}}个商品库存<p>
</p>
</div>
</div>
<!--尺码列表-->
<ProductList
ref="productList"
:skcs="skcs"
@on-change-price="onChangePrice"
@on-no-sale="onNoSale"
></ProductList>
</div>
</ScrollView>
<ModalUnstock
v-if="modalLoad"
ref="modalUnstock"
@on-no-sale="onNoSaleSure"
></ModalUnstock>
<ModalPrice
v-if="modalLoad"
ref="modalPrice"
@on-change-price="onChangePriceSure"
></ModalPrice>
</LayoutApp>
</template>
<script>
import LayoutApp from '../../../components/layout/layout-app';
import ScrollView from '../../../components/layout/scroll-view';
import Logo from './components/logo';
import {createNamespacedHelpers} from 'vuex';
import ImgSize from '../../../components/img-size';
import ProductList from './components/product-list';
import Modal from './components/modal';
import ModalUnstock from './components/modal-unstock';
import {get} from 'lodash';
import ModalPrice from './components/modal-price';
const {mapState, mapActions, mapMutations} = createNamespacedHelpers('order/priceChange')
export default {
components: {ModalPrice, ModalUnstock, Modal, ProductList, ImgSize, ScrollView, LayoutApp, Logo},
name: 'PriceChange',
data() {
return {
title: '订单',
classes: {},
scrollOption: {
pullDownRefresh: {
threshold: 70,
stop: 90
},
observeDOM: false,
pullUpLoad: false // 关闭了上拉加载
},
page: 1,
modalLoad: false,
pageSize: 50,
};
},
asyncData({store, router}) {
// 测试用orderId 10000064 10001026 10001266 10000072
return store.dispatch('order/priceChange/fetchProduct', {productId: router.params.orderId, refresh: true});
},
mounted() {
this.modalLoad = true;
},
computed: {
...mapState(['productInfo', 'skcs']),
},
methods: {
...mapMutations(['MERGE_CHANGEPRICE_DATA']),
...mapActions(['fetchProduct', 'postNoSale', 'postChangePrice']),
async onPullingUp() {
const beginCount = this.skcs.length;
const result = await this.fetchProduct({
productId: this.$route.params.orderId,
page: this.page + 1,
pageSize: this.pageSize
});
console.log(result);
const afterCount = this.skcs.length;
if (afterCount > beginCount) {
this.page++;
}
const noMore = get(result, 'data.data', []).length;
this.$refs.scroll.forceUpdate(noMore > 0);
},
onPullingDown() {
this.page = 1;
this.fetchProduct({
productId: this.$route.params.orderId,
page: 1,
pageSize: this.pageSize,
refresh: true
}).then(() => {
this.$refs.scroll.forceUpdate();
});
},
/**
* 刷新商品及尺码信息
* @param isNoSale 是否为点击不卖了之后的刷新
* @returns {Promise<void>}
*/
async refreshProduct(isNoSale) {
const result = await this.fetchProduct({
productId: this.$route.params.orderId,
page: this.page,
pageSize: this.pageSize,
refresh: true
});
if (isNoSale && !get(result, 'data.productInfo')) {
this.$yoho.finishPage({});
}
},
onClickProduct() {
this.$router.push({
name: 'ProductDetail',
params: {
productId: this.productInfo.productId
}
});
},
onChangePrice(skc) {
this.$refs.modalPrice.show({skc, product: this.productInfo});
},
onNoSale(skc) {
this.$refs.modalUnstock.show({skc});
},
async onNoSaleSure({skc, num}) { // 商品下架确认
console.log(skc, num);
const result = await this.postNoSale({
product_id: this.productInfo.productId,
storage_id: skc.storageId,
old_price: skc.price,
num: num,
skupType: skc.attributes
});
if (result.code === 200) {
this.$refs.modalUnstock.hide();
this.$createToast({
txt: '下架成功',
type: 'correct'
}).show();
this.refreshProduct(true);
} else {
this.$createToast({
txt: result.message || '下架失败',
type: 'warn'
}).show();
}
},
async onChangePriceSure({skc, price}) {
console.log(skc, price);
const result = await this.postChangePrice({
product_id: this.productInfo.productId,
storage_id: skc.storageId,
new_price: price,
old_price: skc.price,
num: skc.storageNum,
skupType: skc.attributes
});
if (result && result.code === 200) {
this.$refs.modalPrice.hide();
this.$createToast({
txt: '调价成功',
type: 'success'
}).show();
this.refreshProduct();
} else {
this.$createToast({
txt: result.message || '调价失败',
type: 'warn',
}).show();
}
}
}
};
</script>
<style lang="scss" scoped>
.order-page {
position: relative;
width: 100%;
/*height: 100%;*/
-webkit-font-smoothing: antialiased;
.title {
line-height: 82px;
font-size: 68px;
font-weight: bold;
padding: 2px 40px 0 40px;
}
.product {
margin: 20px auto;
padding: 0 30px;
height: 200px;
display: flex;
.pro-img {
width: 200px;
height: 200px;
overflow: hidden;
display: flex;
align-items: center;
img {
width: 100%;
height: auto;
}
}
.logo-wrapper {
position: absolute;
left: 0;
top: 4px;
transform: scale(0.95);
}
.pro-info {
padding: 44px 40px 0 40px;
line-height: 32px;
overflow: hidden;
.pro-name {
font-size: 24px;
color: #999;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
.stock-info {
position: relative;
color: #000;
margin-top: 24px;
}
.stock-text {
/*text-indent: 128px;*/
font-size: 28px;
font-weight: 600;
line-height: 44px;
}
}
}
}
</style>