3f535f30
杨鑫
'初始'
|
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
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
|
</view>
</view>
</view>
</view>
<view class="spellpersonnel-box">
<view class="bgBox flex-items-plus flex-column">
<view class="flex-items flex-sp-around flex-row-plus mar-right-20">
<view class="flex-column flex-items-plus mar-left-20" v-for="(item,index) in inviteSpell.personList" :key="index">
<image v-if="index == 0" class="head-icon border-FF7 z-index-0" :src="item.headImage"></image>
<image v-else class="head-icon " :src="item.headImage"></image>
<view v-if="index == 0" class="fs18 colonel-box">团长</view>
</view>
<view v-for="ritem in remainPerson">
<view class="replenish-icon flex-items-plus mar-left-20">?</view>
</view>
</view>
<view v-if="remainPerson !== 0">
<view class="mar-top-50 font-color-333">还差<label class="font-color-C5AA7B">{{remainPerson}}</label>人成团,距结束还剩{{hou}}:{{min}}:{{sec}}</view>
<view v-if="type == 1" @click="shareClick" class="offered-but font-color-FFF flex-items-plus mar-top-60">邀请好友拼单</view>
<view v-if="type == 0" @click="getOffered" class="offered-but font-color-FFF flex-items-plus mar-top-60">立即参团</view>
<view v-if="type == 1" @click="goinvitePoster" class="poster-but flex-items-plus mar-top-40">生成邀请海报</view>
</view>
</view>
</view>
<view class="spellrule flex-items-plus flex-column mar-top-20">
<view class="flex-row-plus">
<view class="flex-row-plus flex-items-plus text-align">
<view class="dot1"></view>
<view class="dot2"></view>
<view class="dot3"></view>
</view>
<label class="fs28 mar-left-20">拼团玩法</label>
<view class="flex-row-plus flex-items-plus text-align mar-left-10">
<view class="dot3"></view>
<view class="dot2"></view>
<view class="dot1"></view>
</view>
</view>
<view class="mar-top-40">
<u-steps :list="numList" mode="number" :current="-1"></u-steps>
</view>
</view>
<!-- 商品详情 -->
<u-popup class="goosDetailshow-box" v-model="goosDetailshowFlag" mode="bottom" border-radius="14">
<view>
<view class="detailImg-box flex-row-plus">
<image class="detailImg" :src="skuImg"></image>
<view class="flex-column-plus mar-left-40">
<view class="font-color-C5AA7B">
<label class="fs24">¥</label>
<label class="fs36 mar-left-10">{{skuPrice}}</label>
</view>
<label class="fs24 font-color-999 mar-top-20">库存 {{stockNumber}} 件</label>
<label class="fs24 mar-top-20">已选</label>
</view>
</view>
<view class="color-box flex-column-plus">
<view v-for="(attritem,index) in skuProdList.names" :key="index">
<label class="fs24 font-color-999">{{attritem.skuName}}</label>
<view class="colorName-box">
<view class="pad-bot-30" v-for="(attrRes, resIndex) in attritem.values" :key="resIndex">
<label class="colorName" :class="{'colorName-on' :subIndex[index] == resIndex}" @click="colorActiveClick(attrRes,index,resIndex)">{{attrRes.skuValue}}</label>
</view>
</view>
</view>
</view>
<view class="goodsNum-box flex-row-plus flex-sp-between">
<label class="font-color-999 fs24">数量</label>
<view class="goodsNum">
<label class="subtract" @click="numSub">-</label>
<label class="goodsNumber" v-model="buyNum">{{buyNum}}</label>
<label class="add" @click="numAdd">+</label>
</view>
</view>
<view class="goosDetailbut-box flex-items-plus" :style="{'padding-bottom':(isIphone===true? 50:20)+'rpx'}">
<view class="joinbuyBut" @click="getGroupSettlement(2)">确定</view>
</view>
</view>
</u-popup>
<shareSpell ref="shareSpell" @shareCancel='shareCancel' :url="url" :urlParms="urlParms" :img="inviteSpell.image" title="好友邀请您来拼单啦">
</shareSpell>
</view>
</template>
<script>
const NET = require('../../utils/request')
const API = require('../../config/api')
import shareSpell from '@/component/share.vue'
import ClipboardJS from "clipboard"
export default {
data() {
return {
numList: [{
name: '选择商品 完成下单'
}, {
name: '支付开团 或参团'
}, {
name: '邀请好友 参与拼团'
}, {
name: '人满成团 失败退款'
}, ],
collageId:0,
orderId:0,
type:0,
inviteSpell:{},
personLen:0,
remainPerson:0,
hou: "00",
min: "00",
sec: "00",
timeOut:undefined,
goosDetailshowFlag: false,
productId:0,
skuId:0,
shopGroupWorkId:0,
buyNum:1,
skuProdId:0,
skuImg:'',
skuPrice:0,
stockNumber:0,
skuProdList:{},
isIphone: "",
selectArr: [], // 存放被选中的值
subIndex: [], // 是否选中 因为不确定是多规格还是单规格,所以这里定义数组来判断
attrItemIdArr: [], //存放被选中的id
shopId:0,
attrList: [],
productDetail:{},
userInfo: {},
url: '',
shareTitle: '',
showJoinGroup: false,
showGroupText: '立即参团',
urlParms: ''
};
},
components:{
shareSpell
},
onShareAppMessage: function(res) {
var that = this;
//console.log('res=====',res);
if (res.from === 'button') {
//console.log('来自页面内转发按钮');
} else if (res.from === 'menu'){
//console.log('右上角菜单转发按钮');
}
this.url = '/pages_category_page1/goodsModule/inviteSpell?collageId='
+ this.collageId +'&orderId='+ this.orderId+'&type=0'+'&productId='+this.productId+'&skuId='+this.skuId+'&shopGroupWorkId='+this.shopGroupWorkId
this.shareTitle = `【仅剩${this.remainPerson}个名额】我${this.inviteSpell.price}元拼了${this.inviteSpell.productName}`
// 返回数据
return {
title: that.shareTitle,
path: that.url,
success: function(res) {
// 转发成功,可以把当前页面的链接发送给后端,用于记录当前页面被转发了多少次或其他业务
wx.request({
url: app.buildUrl("/member/share"),
data: {
url: utils.getCurrentPageUrlWithArgs()
},
success: function(res) {
//console.log('成功');
}
});
},
fail: function(res) {
// 转发失败
}
}
},
onUnload() {
if(this.timeOut){
clearTimeout(this.timeOut)
}
},
onShow(){
//判断是否登录
let item = {}
if(uni.getStorageSync('storage_key')){
item = uni.getStorageSync('storage_key');
}
if(JSON.stringify(item) == '{}'){
let data = {
collageId : this.collageId,
orderId : this.orderId,
productId : this.productId,
skuId : this.skuId,
type : this.type,
}
uni.setStorageSync("inviteSpell",data)
// uni.navigateTo({
// url:'../../pages_category_page2/userModule/accountLogin?inviteSpell=1'
// })
}else{
this.userInfo = uni.getStorageSync('storage_userInfo')
}
this.getInviteSpell()
},
onLoad(options) {
console.log(options,'options')
this.isIphone = getApp().globalData.isIphone;
let item = getApp().globalData.inviteSpellShareIte
if (item) {
this.collageId = parseInt(item.collageId)
this.orderId = parseInt(item.orderId)
this.productId = parseInt(item.productId)
this.skuId = parseInt(item.skuId)
this.shopGroupWorkId = parseInt(item.shopGroupWorkId)
getApp().globalData.inviteSpellShareItem = undefined
} else {
this.collageId = parseInt(options.collageId)
this.orderId = parseInt(options.orderId)
this.productId = parseInt(options.productId)
this.skuId = parseInt(options.skuId)
this.shopGroupWorkId = parseInt(options.shopGroupWorkId)
}
// #ifdef MP-WEIXIN
this.url = '/pages_category_page1/goodsModule/inviteSpell?collageId=' +
this.collageId + '&orderId=' + this.orderId + '&productId=' + this.productId + '&skuId=' + this.skuId +
'&shopGroupWorkId=' + this.shopGroupWorkId
this.urlParms = this.collageId + '&orderId=' + this.orderId + '&productId=' + this.productId + '&skuId=' + this.skuId +
'&shopGroupWorkId=' + this.shopGroupWorkId
// #endif
// #ifndef MP-WEIXIN
this.url = '/h5/#/pages_category_page1/goodsModule/inviteSpell?collageId=' +
this.collageId + '&orderId=' + this.orderId + '&productId=' + this.productId + '&skuId=' + this.skuId +
'&shopGroupWorkId=' + this.shopGroupWorkId
// #endif
},
methods:{
getOffered(){
this.goosDetailshowFlag = true
},
//拼团下单
getGroupSettlement(type){
uni.removeStorageSync("skuItemDTOList")
let data={}
data= {
collageId:this.collageId,
number:this.buyNum,
productId:this.productId,
shopId:this.shopId,
skuId:this.skuProdId,
shopGroupWorkId:this.shopGroupWorkId,
type:type
}
uni.setStorageSync('skuItemList',data)
this.goosDetailshowFlag = false
this.buyNum = 1
uni.navigateTo({
url: '../orderModule/orderConfirm?type=1',
})
},
//获取商品详情
queryProductDetail() {
NET.request(API.QueryProductDetail,
{
shopId:this.shopId,
productId:this.productId,
skuId:this.skuId,
terminal:1
},
"GET").then(res => {
this.productDetail = res.data
for (let i = 0; i < res.data.attrList.length; i++) {
this.subIndex[i] = 0
}
this.attrItemIdArr[0] = res.data.attrList[0].attrValueList[0].id
}).catch(res => {
})
},
getProductSku(){
NET.request(API.QueryProductSku, {
skuId:this.skuId,
productId:this.productId
}, 'GET').then(res => {
this.skuProdList = res.data
this.attrList = res.data.names
this.attrValueList = res.data.names[0].values
//渲染商详之后,默认先选中第一个规格
this.colorActiveClick(this.attrValueList[0],0,0)
this.skuProdId = this.skuId
this.skuImg = res.data.image
this.skuPrice = res.data.price
this.stockNumber = res.data.stockNumber
this.shopId = res.data.shopId
}).catch(res => {
})
},
// 数量减
numSub() {
if (this.buyNum > 1) {
this.buyNum = this.buyNum - 1
} else {
uni.showToast({
title: '亲!至少一件哦!',
icon: "none"
})
}
},
// 数量加
numAdd() {
if(this.buyNum < this.stockNumber){
this.buyNum = this.buyNum + 1
}else{
uni.showToast({
title: '库存不足!',
icon: "none"
})
}
},
//颜色选中事件
colorActiveClick(res, index, resIndex) {
let t = this;
t.selectArr[index] = res;
t.subIndex[index] = resIndex;
t.attrItemIdArr[index] = res.valueCode
t.checkItem();
t.checkItemDataClick(t.attrItemIdArr)
},
checkItem() {
var self = this;
var option = self.attrList;
var result = []; // 定义数组存储被选中的值
for (let i in option) {
result[i] = self.selectArr[i] ? self.selectArr[i] : "";
if (!self.subIndex[i]) {
self.subIndex[i] = 0
}
if (!self.attrItemIdArr[i]) {
self.attrItemIdArr[i] = option[i].values[0].valueCode
}
}
for (let i in option) {
var last = result[i]; // 把选中的值存放到字符串last去
for (let k in option[i].item) {
result[i] = option[i].item[k].name; // 赋值,存在直接覆盖,不存在往里面添加name值
}
result[i] = last; // 还原,目的是记录点下去那个值,避免下一次执行循环时避免被覆盖
}
self.$forceUpdate(); // 重绘
},
checkItemDataClick(attrItemIdArr) {
let attrkey = ''
for(let i =0;i<attrItemIdArr.length;i++){
attrkey += attrItemIdArr[i]+','
}
attrkey = attrkey.substring(0,attrkey.length - 1)
let mapinfo = this.skuProdList.map
for (var key in mapinfo){
if(attrkey == key){
this.skuProdId = mapinfo[key].skuId
this.skuImg = mapinfo[key].skuImg
this.skuPrice = mapinfo[key].price
this.stockNumber = mapinfo[key].stockNumber
}
}
},
shareClick(){
this.$refs.shareSpell.shareShow = true
},
shareCancel(){
this.$refs.shareSpell.shareShow = false
},
goinvitePoster(){
console.log(this.inviteSpell, 'test')
let data = {
image:this.inviteSpell.image,
headImage:this.inviteSpell.headImage,
productName:this.inviteSpell.productName,
person:this.inviteSpell.person,
originalPrice:this.inviteSpell.originalPrice,
price:this.inviteSpell.price,
collageId:this.collageId,
productId:this.productId,
skuId:this.skuId,
orderId:this.orderId
}
uni.navigateTo({
url:'invitePoster?data='+ JSON.stringify(data)
})
},
getInviteSpell(){
// uni.showLoading({
// mask: true,
// title: '加载中...',
// })
NET.request(API.getInviteSpell, {
collageId:this.collageId,
orderId: this.orderId
}, 'POST').then(res => {
this.inviteSpell = res.data
this.type = 0
this.inviteSpell.personList.forEach(item=>{
if(item.buyerUserId === this.userInfo.buyerUserId){
this.type = 1
}
})
this.personLen = res.data.personList.length
this.remainPerson = res.data.person - this.personLen
this.dateformat(res.data.time)
this.countDown()
uni.hideLoading()
}).catch(res => {
uni.hideLoading()
})
},
//时分秒换算
dateformat(micro_second) {
// 总秒数
let second = Math.floor(micro_second / 1000);
// 天数
let day = Math.floor(second / 3600 / 24);
// 小时
let hr = Math.floor(second / 3600 % 24);
// 分钟
let min = Math.floor(second / 60 % 60);
// 秒
let sec = Math.floor(second % 60);
this.hou = hr
this.min = min
this.sec = sec
},
countDown(){
let timeOut = setTimeout(() => {
let hou = parseInt(this.hou);
let min = parseInt(this.min);
let sec = parseInt(this.sec);
let netxSec = sec - 1;
let netxMin = min
let netxHou = hou;
if (netxHou == 0 && netxMin == 0 && netxSec == -1) {
clearTimeout(timeOut)
// uni.switchTab({
// url:'../../pages/tabbar/index/index'
// })
} else {
if (netxSec == -1) {
netxSec = 59
netxMin = netxMin - 1;
}
if (netxMin == -1) {
netxMin = 59
netxHou = netxHou - 1
}
if (netxHou == -1) {
netxHou = 23
}
this.hou = this.timeFormat(netxHou),
this.min = this.timeFormat(netxMin),
this.sec = this.timeFormat(netxSec),
this.timeOut = timeOut
this.countDown();
}
}, 1000)
},
timeFormat(param) { //小于10的格式化函数
return param < 10 ? '0' + param : param;
},
}
}
</script>
<style lang="scss">
page{background-color: #F7F7F7;}
.copy-color{
display: flex;
justify-content: center;
align-items:center;
flex-direction: column;
}
.inviteSpell-con{
|