|
|
@@ -64,7 +64,7 @@ const state = reactive({
|
|
64
|
64
|
shareImage: '',
|
|
65
|
65
|
})
|
|
66
|
66
|
const detail: any = ref(null)
|
|
67
|
|
-const isTo= ref(0)
|
|
|
67
|
+const isTo= ref(3)
|
|
68
|
68
|
let isShow = ref(false)
|
|
69
|
69
|
onShow(() => {
|
|
70
|
70
|
uni.showLoading({
|
|
|
@@ -132,7 +132,8 @@ function loadProductDetail() {
|
|
132
|
132
|
// console.log(res);
|
|
133
|
133
|
if (res.status === 200) {
|
|
134
|
134
|
detail.value = res.data
|
|
135
|
|
-
|
|
|
135
|
+ console.log('我是detail',detail.value);
|
|
|
136
|
+
|
|
136
|
137
|
state.shareImage = detail.value.image
|
|
137
|
138
|
if (res && res.mer_id && res.mer_id === '148') {
|
|
138
|
139
|
if (detail.value && detail.value.price) {
|
|
|
@@ -296,6 +297,7 @@ function onSelectedSku(item :any) {
|
|
296
|
297
|
}
|
|
297
|
298
|
|
|
298
|
299
|
function handleAddCart() {
|
|
|
300
|
+ isTo.value=1
|
|
299
|
301
|
state.isShowSku = true
|
|
300
|
302
|
state.flag = 2
|
|
301
|
303
|
|
|
|
@@ -317,12 +319,14 @@ function handleCreateShopping() {
|
|
317
|
319
|
if (res.cart_id) {
|
|
318
|
320
|
// console.log(state.flag)
|
|
319
|
321
|
if (state.flag == '1' || state.flag == '3') {
|
|
|
322
|
+ isTo.value=state.flag
|
|
|
323
|
+ console.log(isTo.value)
|
|
320
|
324
|
uni.navigateTo({
|
|
321
|
325
|
url: `/pages/order-confirm/index?cartId=${res.cart_id}&type=${state.flag}&product_id=${detail.value.product_id}`
|
|
322
|
326
|
})
|
|
323
|
|
- } else {
|
|
324
|
|
- uni.$emit('cart-reload')
|
|
|
327
|
+ } else if(state.flag == '2') {
|
|
325
|
328
|
isTo.value=1
|
|
|
329
|
+ uni.$emit('cart-reload')
|
|
326
|
330
|
loadProductDetail()
|
|
327
|
331
|
uni.showToast({
|
|
328
|
332
|
title: '添加购物车成功',
|
|
|
@@ -352,6 +356,90 @@ function handleCreateShopping() {
|
|
352
|
356
|
|
|
353
|
357
|
})
|
|
354
|
358
|
}
|
|
|
359
|
+function handleBuyshow() {
|
|
|
360
|
+ console.log('我是detail数据',detail.value)
|
|
|
361
|
+ createShopping({
|
|
|
362
|
+ product_id: detail.value.product_id,
|
|
|
363
|
+ // product_attr_unique: JSON.stringify(state.currentSku),
|
|
|
364
|
+ product_attr_unique: state.currentSku.unique,
|
|
|
365
|
+ cart_num: state.cartNum,
|
|
|
366
|
+ is_new: (state.flag === '1' || state.flag === '3') ? '1' : '0'
|
|
|
367
|
+ }).then(res => {
|
|
|
368
|
+ console.log('resres',res)
|
|
|
369
|
+
|
|
|
370
|
+ if (res.cart_id) {
|
|
|
371
|
+ uni.navigateTo({
|
|
|
372
|
+ url: `/pages/order-confirm/index?cartId=${res.cart_id}&type=${state.flag}&product_id=${detail.value.product_id}`
|
|
|
373
|
+ })
|
|
|
374
|
+ }
|
|
|
375
|
+ }).catch(error => {
|
|
|
376
|
+ if (error === '会员礼包不能加入购物车') {
|
|
|
377
|
+ return uni.showToast({
|
|
|
378
|
+ title: error,
|
|
|
379
|
+ icon: 'none'
|
|
|
380
|
+ })
|
|
|
381
|
+ } else if (error === '库存不足') {
|
|
|
382
|
+ return uni.showToast({
|
|
|
383
|
+ title: error,
|
|
|
384
|
+ icon: 'none'
|
|
|
385
|
+ })
|
|
|
386
|
+ }
|
|
|
387
|
+ else {
|
|
|
388
|
+ return uni.navigateTo({
|
|
|
389
|
+ url: '/pages/user/login/index'
|
|
|
390
|
+ })
|
|
|
391
|
+ }
|
|
|
392
|
+
|
|
|
393
|
+ })
|
|
|
394
|
+}
|
|
|
395
|
+function handleAddshow() {
|
|
|
396
|
+ // console.log(state.flag)
|
|
|
397
|
+ console.log('我是detail数据', detail.value)
|
|
|
398
|
+ createShopping({
|
|
|
399
|
+ product_id: detail.value.product_id,
|
|
|
400
|
+ // product_attr_unique: JSON.stringify(state.currentSku),
|
|
|
401
|
+ product_attr_unique: state.currentSku.unique,
|
|
|
402
|
+ cart_num: state.cartNum,
|
|
|
403
|
+ is_new: (state.flag === '1' || state.flag === '3') ? '1' : '0'
|
|
|
404
|
+ }).then(res => {
|
|
|
405
|
+ console.log('resres', res)
|
|
|
406
|
+
|
|
|
407
|
+ if (res.cart_id) {
|
|
|
408
|
+ // console.log(state.flag)
|
|
|
409
|
+ uni.$emit('cart-reload')
|
|
|
410
|
+ loadProductDetail()
|
|
|
411
|
+ uni.showToast({
|
|
|
412
|
+ title: '添加购物车成功',
|
|
|
413
|
+ icon: 'none'
|
|
|
414
|
+ })
|
|
|
415
|
+ loadCartCount()
|
|
|
416
|
+ state.isShowSku = false
|
|
|
417
|
+ }
|
|
|
418
|
+ }).catch(error => {
|
|
|
419
|
+ if (error === '会员礼包不能加入购物车') {
|
|
|
420
|
+ return uni.showToast({
|
|
|
421
|
+ title: error,
|
|
|
422
|
+ icon: 'none'
|
|
|
423
|
+ })
|
|
|
424
|
+ } else if (error === '库存不足') {
|
|
|
425
|
+ return uni.showToast({
|
|
|
426
|
+ title: error,
|
|
|
427
|
+ icon: 'none'
|
|
|
428
|
+ })
|
|
|
429
|
+ }
|
|
|
430
|
+ else {
|
|
|
431
|
+ return uni.navigateTo({
|
|
|
432
|
+ url: '/pages/user/login/index'
|
|
|
433
|
+ })
|
|
|
434
|
+ }
|
|
|
435
|
+
|
|
|
436
|
+ })
|
|
|
437
|
+}
|
|
|
438
|
+// 规格显示双按钮
|
|
|
439
|
+function handleTwobtn(){
|
|
|
440
|
+ isTo.value=2
|
|
|
441
|
+ state.isShowSku = !state.isShowSku
|
|
|
442
|
+}
|
|
355
|
443
|
|
|
356
|
444
|
/**
|
|
357
|
445
|
*
|
|
|
@@ -378,6 +466,7 @@ function handleOrderConfirm(flag: '1' | '2' | '3') {
|
|
378
|
466
|
})
|
|
379
|
467
|
|
|
380
|
468
|
state.flag = flag
|
|
|
469
|
+ isTo.value=flag
|
|
381
|
470
|
state.isShowSku = true
|
|
382
|
471
|
// if (is148Merchant.value) {
|
|
383
|
472
|
// state.isNew = '1'
|
|
|
@@ -607,7 +696,7 @@ onPageScroll((page) => {
|
|
607
|
696
|
</div>
|
|
608
|
697
|
</div>
|
|
609
|
698
|
|
|
610
|
|
- <FCell arrow @tap="state.isShowSku = !state.isShowSku">
|
|
|
699
|
+ <FCell arrow @tap="handleTwobtn">
|
|
611
|
700
|
<template #title>
|
|
612
|
701
|
<div class="flex items-center" v-if="state.currentSku">
|
|
613
|
702
|
<div class="font-bold">规格:</div>
|
|
|
@@ -773,13 +862,18 @@ onPageScroll((page) => {
|
|
773
|
862
|
<div v-else @click="handleOrderConfirm('1')">立即购买</div>
|
|
774
|
863
|
</div>
|
|
775
|
864
|
</div>
|
|
|
865
|
+ <!-- <div class="flex flex-row text-sm text-white gap-2 pr-3">
|
|
|
866
|
+ <div class="bg-[#F94032] rounded-full w-25 flex justify-center items-center h-9">
|
|
|
867
|
+ <div @click="handleOrderConfirm('1')">立即抢购</div>
|
|
|
868
|
+ </div>
|
|
|
869
|
+ </div> -->
|
|
776
|
870
|
</div>
|
|
777
|
871
|
|
|
778
|
872
|
|
|
779
|
873
|
</div>
|
|
780
|
874
|
|
|
781
|
875
|
<CXBSkuPopup v-model:show="state.isShowSku" :detail="detail" @selected:item="onSelectedSku"
|
|
782
|
|
- @submit="handleCreateShopping" @count-change="handleCountChange"
|
|
|
876
|
+ @submit="handleCreateShopping" @count-change="handleCountChange" @subBuy="handleBuyshow" @subAdd="handleAddshow"
|
|
783
|
877
|
:isTo="isTo"
|
|
784
|
878
|
/>
|
|
785
|
879
|
<!-- <nut-sku-->
|