dxz1228 2 роки тому
батько
коміт
e72f6303e8

+ 26 - 34
src/components/CXBSkuPopup/CXBSkuPopup.vue

@@ -25,9 +25,9 @@ const props = defineProps({
25 25
       return []
26 26
     }
27 27
   },
28
-  isTo:{
29
-    type:Number,
30
-    required:true
28
+  isTo: {
29
+    type: Number,
30
+    required: true
31 31
   }
32 32
 })
33 33
 
@@ -54,25 +54,6 @@ const onConfirm = () => {
54 54
   emit(CONFIRM_EVENT)
55 55
 }
56 56
 
57
-//定义点击规格展示状态
58
-const isQr=ref(false)    //确认 加入购物车-立即购买规格出现
59
-const isDh=ref(false)    //兑换 立即兑换页面规格出现
60
-const isTwo=ref(false)   //点击大仓规格 出现双按钮
61
-
62
-//监听传入的规格
63
-watch(()=>props.isTo,()=>{
64
-  if(props.isTo as number ===1){
65
-    isQr.value = true
66
-  }
67
-  if(props.isTo as number ===2){
68
-    isQr.value = true
69
-  }
70
-  if(props.isTo as number ===3 ){
71
-    isTwo.value=true
72
-  }
73
-},
74
-{immediate:true}
75
-)
76 57
 
77 58
 const onCancel = () => {
78 59
   // show.value = false
@@ -102,27 +83,30 @@ const skuList = computed(() => {
102 83
 
103 84
 onMounted(() => {
104 85
   emit('selected:item', currentSku)
105
-  
86
+
106 87
 })
107 88
 
108 89
 function handleSelectedSku(skuItem: any) {
109 90
   currentSku.value = skuItem
110 91
   console.log('我是数据', currentSku.value);
111
- 
92
+
112 93
   emit('selected:item', currentSku)
113 94
 }
114 95
 function handleClose() {
115 96
   showValue.value = false
116
-  
97
+
117 98
   emit(CLOSE_EVENT)
118 99
 }
119 100
 
120 101
 function handleAddCart() {
121 102
   emit('submit')
122 103
 }
123
-// function handleSelectedSku(item) {
124
-//
125
-// }
104
+function handleBuyNow() {
105
+  emit('subBuy')
106
+}
107
+function handleJiaCart() {
108
+  emit('subAdd')
109
+}
126 110
 
127 111
 function handleCountChange(value) {
128 112
   emit('count-change', value)
@@ -197,23 +181,25 @@ function handleCountChange(value) {
197 181
         </div>
198 182
       </div>
199 183
 
200
-      <div class="px-3 pb-10" v-if="isQr" >
184
+      <div class="px-3 pb-10" v-if="isTo == 1">
201 185
         <FButton @click="handleAddCart" size="small" :exClass="['!bg-primary', 'rounded-full', 'text-white']" block>
202 186
           确定
203 187
         </FButton>
204 188
 
205 189
       </div>
206
-      <div class="px-3 pb-10" v-if="isDh" >
190
+      <div class="px-3 pb-10" v-if="isTo == 3">
207 191
         <FButton @click="handleAddCart" size="small" :exClass="['!bg-primary', 'rounded-full', 'text-white']" block>
208 192
           立即兑换
209 193
         </FButton>
210 194
 
211 195
       </div>
212
-      <div class="px-3 pb-10"  v-if="isTwo" >
213
-        <FButton @click="handleAddCart" size="small" :exClass="['!bg-primary', 'rounded-full', 'text-white']" block>
196
+      <div class="flex box_1 flex-row justify-between text-sm text-white gap-3 pr-3" v-if="isTo == 2">
197
+        <FButton @click="handleJiaCart" size="small"
198
+          :exClass="['bg-[#FFA319] rounded-full w-1/3 flex justify-center items-center h-9']" block>
214 199
           加入购物车
215 200
         </FButton>
216
-        <FButton @click="handleAddCart" size="small" :exClass="['!bg-primary', 'rounded-full', 'text-white']" block>
201
+        <FButton @click="handleBuyNow" size="small"
202
+          :exClass="['bg-[#F94032] rounded-full w-1/3 flex justify-center items-center h-9']" block>
217 203
           立即购买
218 204
         </FButton>
219 205
 
@@ -221,4 +207,10 @@ function handleCountChange(value) {
221 207
     </div>
222 208
 
223 209
   </FPopup>
224
-</template>
210
+</template>
211
+<style scoped>
212
+.box_1 {
213
+  margin-bottom: 40rpx;
214
+  border-top:1px solid #b6b9c0
215
+}
216
+</style>

+ 2 - 0
src/components/FButton/FButton.vue

@@ -6,6 +6,8 @@ const props = defineProps(buttonProps)
6 6
 const emit = defineEmits(buttonEmits)
7 7
 
8 8
 const { disabled, clickHandler } = useButton(props, emit)
9
+console.log(props);
10
+
9 11
 </script>
10 12
 
11 13
 <template>

+ 100 - 6
src/pages/store/product/detail.vue

@@ -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-->

+ 8 - 8
src/pages/to-coupon/to-coupon.vue

@@ -28,27 +28,27 @@ const isShow = ref(true)
28 28
 
29 29
 .block_1 {
30 30
 	width: 100%;
31
-	height: 9px;
31
+	height: 18rpx;
32 32
 	background-size: 100% 100%;
33 33
 }
34 34
 
35 35
 .image_2 {
36
-	width: 103px;
37
-	height: 103px;
36
+	width:206rpx;
37
+	height:206rpx;
38 38
 	display: block;
39
-	margin-top: 200px;
40
-	margin-bottom: 20px;
39
+	margin-top: 400rpx;
40
+	margin-bottom: 40rpx;
41 41
 }
42 42
 
43 43
 .text_3 {
44
-	height: 15px;
44
+	height: 30rpx;
45 45
 	overflow-wrap: break-word;
46 46
 	color: rgba(51, 51, 51, 1);
47
-	font-size: 15px;
47
+	font-size: 30rpx;
48 48
 	font-weight: NaN;
49 49
 	text-align: center;
50 50
 	white-space: nowrap;
51
-	line-height: 15px;
51
+	line-height: 30rpx;
52 52
 	
53 53
 }
54 54