goodtail.vue
11.6 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
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
<template>
<view class="content">
<view class="goodtailtop">
<image :src="goodtail.image" mode=""></image>
</view>
<view class="tailbox boxsizing" v-if="type==1">
<view class="tailname">
{{goodtail.name}}
</view>
<view class="tailhezi flextwo">
<view class="tailhezileft flexone">
<view class="saleprice">¥{{goodtail.goods_price}}</view>
<view class="huiyuanprice">会员价:¥{{goodtail.vip_price}}</view>
</view>
<view class="heziright flexone">
<view class="heziprice stock">库存:{{goodtail.flour_goods_spec.stock_num}}件</view>
<view class="heziprice">已售{{goodtail.sales}}件</view>
</view>
</view>
</view>
<view class="tailbox boxsizing" v-else-if="type==2">
<view class="tailname">
{{goodtail.name}}
</view>
<view class="tailhezi flextwo">
<view class="tailhezileft flexone">
<view class="saleprice">¥{{goodtail.score_goods_spec.goods_price}}</view>
<!-- <view class="huiyuanprice">会员价:¥{{goodtail.vip_price}}</view> -->
</view>
<view class="heziright flexone">
<view class="heziprice stock">库存:{{goodtail.score_goods_spec.stock_num}}件</view>
<view class="heziprice">已售{{goodtail.sales}}件</view>
</view>
</view>
</view>
<view class="tailbox boxsizing" v-else>
<view class="tailname">
<text class='miaobox'>限时秒杀</text>
商品名称商品名称商品名称商品名称商品名称商品名称商品名称商品名称
</view>
<view class="tailhezi flextwo">
<view class="tailhezileft flexone">
<view class="saleprice">¥288</view>
<view class="oldprice">¥450</view>
</view>
</view>
<view class='miaodu flextwo'>
<view class="miaoduleft">
<view class="miaotiao">
已抢购60%
</view>
</view>
<view class="miaoright flexone">
<view class="distance">距离结束还剩</view>
<view class="remaintime">23</view>
<view class="dian">:</view>
<view class="remaintime">53</view>
<view class="dian">:</view>
<view class="remaintime">42</view>
</view>
</view>
</view>
<view class="send">
{{item.postage}}
<!-- 包邮 店铺满100元包邮 -->
</view>
<view class="tapnav flextwo">
<view class="tapnavitem " :class="selnav==1?'tapnavactive':''" @click="navtap" :data-id="1">详情</view>
<view class="tapnavitem" :class="selnav==2?'tapnavactive':''" @click="navtap" :data-id="2">评论(200)</view>
</view>
<view class="goodetailbox" v-if="selnav==1">
<rich-text :nodes="goodtail.content"></rich-text>
</view>
<view class="goodcomment" v-else>
<view class="goodcommentop flexone">
<view class="topitem">全部(60万)</view>
<view class="topitem">好评(16万)</view>
<view class="topitem">中评(10万)</view>
<view class="topitem">差评(600)</view>
</view>
<view class="commentlist">
<view class="jianintro photobox" bindtap="comdetail">
<view class="comtop flextwo">
<view class="comleft">
<image src="../../static/userpic.png"></image>
</view>
<view class="comright">
<view class="comrtop">
<view class="usertop flextwo">
<view class="comrname">皖湘情</view>
<view class="comdate">2019年10月12日</view>
</view>
<view class="star starone flexone">
<view class="staritem">
<image src="../../static/starredk.png"></image>
</view>
<view class="staritem">
<image src="../../static/starredk.png"></image>
</view>
<view class="staritem">
<image src="../../static/starredk.png"></image>
</view>
<view class="staritem">
<image src="../../static/starredk.png"></image>
</view>
<view class="staritem">
<image src="../../static/starredk.png"></image>
</view>
<view class="staritem">
<image src="../../static/starred.png"></image>
</view>
</view>
</view>
</view>
</view>
<view class="commenttext">
太给力了!!要加紧学习了啊太给力了!!要加紧学习了啊太给力了!!要加紧学习了啊
</view>
<view class="commentimg flexone">
<view class="commentimgitem">
<image src="../../static/shop.png" mode=""></image>
</view>
<view class="commentimgitem">
<image src="../../static/shop.png" mode=""></image>
</view>
<view class="commentimgitem">
<image src="../../static/shop.png" mode=""></image>
</view>
</view>
</view>
</view>
</view>
<!-- 底部购物车 -->
<view class='cartbot flextwo'>
<view class='cartbotleft'>
<view class='cartimg'>
<image src="../../static/cartche.png" mode=""></image>
<view class="cartnum">32</view>
</view>
</view>
<view class='cartbotright flexone'>
<view class="addcarbtn" @click="addcart">加入购物车</view>
<view class="buynowbtn" @click="buynow">立即抢购</view>
</view>
</view>
<!-- 属性弹出层 -->
<view class='register' v-if="shuwrap">
<view class="shuxingwrap">
<view class="goodtailtopk flex">
<view class="shuxingimg">
<view class="shusmallimg">
<image :src="goodtail.image" mode=""></image>
</view>
</view>
<view class='shuright'>
<view class="shutop flex">
<view class="shuname">{{goodtail.name}}
</view>
<view class="shucha" @click="hideshu">
<image src="../../static/goodtaicha.png" mode=""></image>
</view>
</view>
<view class="saleprice">¥{{goodtail.goodp_price}}</view>
</view>
</view>
<view v-for="(item,parindex) in specarr" :key="parindex" >
<view class="weightbox">
<view class="weight">{{item.spec_name}}</view>
<view class="weightlsit flexone">
<!-- witemactive -->
<view class="weightlsititem" :class="item.selindex==childindex?'witemactive':''" v-for="(itemk,childindex) in item.spec_value" :key="childindex" @click.stop="selspec(parindex,childindex)" >{{itemk.spec_value}}</view>
</view>
</view>
</view>
<view class="weightbox flextwo">
<view class="weight">数量</view>
<view class="weightnumk flexone">
<view class="weightnumkleft leftk" @click="reducenum">
<image src="../../static/reduceimg.png" mode=""></image>
</view>
<view class="detailnum">{{cartnumber}}</view>
<view class="weightnumkleft rightk" @click="addnum">
<image src="../../static/addimg.png" mode=""></image>
</view>
</view>
</view>
<view class="addcarbtnk flexthree">
<!-- <view class="addcarbtnkleft">加入购物车</view> -->
<view class="addcarbtnkright" @click="sure">确定</view>
</view>
</view>
</view>
</view>
</template>
<script>
import app from "../../App.vue";
export default {
data() {
return {
sel: 2,
shuwrap:false,
goodid:'',
type:"", //type 1 面访商城 2 积分商城
goodtail:'',
tapnavactive:'',
selnav:1,
sel:1,
// 商品规格
specarr:[],
// 商品规格id
spec_sku_id:[],
addtype:'',//1 加入购物车 2立即购买
cartnumber:1,
arr:[],
}
},
onLoad(options) {
console.log(options)
this.goodid=options.id,
this.type=options.type;
if(this.type==1){
this.getgoodtail();
}else{
this.getjifengoodtail();
}
},
methods: {
hideshu(){
this.shuwrap=false
},
// 顶部导航切换
navtap(e){
this.selnav=e.currentTarget.dataset.id
},
// 数量加减
reducenum(){
this.cartnumber=this.cartnumber-1;
if(this.cartnumber==0){
uni.showToast({
title:'不能再减少了',
icon:"none"
})
this.cartnumber=1
}else{
this.cartnumber=this.cartnumber
}
},
addnum(){
this.cartnumber=this.cartnumber+1;
console.log(this.cartnumber)
this.cartnumber=this.cartnumber
},
//获取面坊商品详情
getgoodtail(){
let that = this;
var url = 'flour_goods/get_flour_goods_detail';
var params = {
flour_goods_id: that.goodid,
}
app.post(url, params).then((res) => {
console.log(res);
that.goodtail=res.data.data
}).catch((err) => {
})
},
// 获取积分商城商品详情
getjifengoodtail(){
console.log(4334)
let that = this;
var url = 'score_goods/get_score_goods_detail';
var params = {
score_goods_id: that.goodid,
}
console.log(params)
app.post(url, params).then((res) => {
console.log(res);
that.goodtail=res.data.data
}).catch((err) => {
console.log(err)
})
},
// 加入购物车
addcart(){
this.shuwrap=true;
this.getspecs();
this.addtype=1
},
// 立即购买
buynow(){
this.shuwrap=true;
this.getspecs();
this.addtype=2
},
//获取商品规格
getspecs(){
let that = this;
var url = 'score_goods/get_spec_sku1';
var params = {
score_goods_id: that.goodid,
}
console.log(params)
app.post(url, params).then((res) => {
console.log(res);
that.specarr=res.data.data;
that.specarr.forEach(function(value,index,array){
value.selindex=-1;
value.selid='';
value.spec_value.forEach(function(valuek,indexk,arrayk){
valuek.sel=false
})
})
that.specarr=that.specarr;
console.log(JSON.stringify(this.specarr))
}).catch((err) => {
console.log(err)
})
},
// 选择商品规格
selspec(parindex,childindex){
let newspecarr=this.specarr;
newspecarr[parindex].spec_value[childindex].sel=!newspecarr[parindex].spec_value[childindex].sel;
newspecarr[parindex].selindex=childindex;
newspecarr[parindex].selid=newspecarr[parindex].spec_value[childindex].id
this.arr.push(newspecarr[parindex].spec_value[childindex].id);
// console.log(this.spec_sku_id)
this.specarr=newspecarr;
// console.log(this.specarr[parindex].spec_value[childindex].sel)
console.log(JSON.stringify(this.specarr))
},
sure(){
if(this.addtype==1){
this.addcartk();
}else{
this.buynowk()
}
},
// 加入购物车
addcartk(){
let that = this;
let newspec_sku_id=[]
that.specarr.forEach(function(value,index,array){
newspec_sku_id.push(value.selid)
})
that.spec_sku_id=newspec_sku_id
var url = 'car/join_car';
var params = {
type:this.type,
goods_id:this.goodid,
spec_sku_id:that.spec_sku_id.join(","),
number: that.cartnumber,
}
console.log(params)
app.post(url, params).then((res) => {
console.log(res);
}).catch((err) => {
console.log(err)
})
},
// 立即购买
buynowk(){
let that = this;
let newspec_sku_id=[]
that.specarr.forEach(function(value,index,array){
newspec_sku_id.push(value.selid)
})
that.spec_sku_id=newspec_sku_id
var url = 'car/join_car';
var params = {
type:this.type,
goods_id:this.goodid,
spec_sku_id:that.spec_sku_id.join(","),
number: that.cartnumber,
}
console.log(params)
app.post(url, params).then((res) => {
console.log(res);
}).catch((err) => {
console.log(err)
})
}
}
}
</script>
<style>
@import url('../../base/nearshop');
@import url('../../base/homepage');
.huiyuanprice {
margin-left: 28rpx
}
.tapnav {
padding: 32rpx 126rpx;
box-sizing: border-box;
}
</style>