Bladeren bron

feat: share toast 更新

Basil 2 jaren geleden
bovenliggende
commit
1aae3ba113

+ 18 - 1
src/components/ProductCard/ProductCard.vue

@@ -1,6 +1,8 @@
1 1
 <script lang="ts" setup>
2 2
 import type {ExtractPropTypes, PropType} from "vue";
3 3
 import type {ProductDetailModel} from "~/apis/model/storeModel";
4
+import {debounce} from "lodash-es";
5
+import {throttle} from "~/utils/throttle";
4 6
 
5 7
 const props = defineProps({
6 8
   item: {
@@ -12,11 +14,26 @@ const props = defineProps({
12 14
 const emit = defineEmits<{
13 15
   (e: 'click:item', value: ExtractPropTypes<typeof props>['item']): void
14 16
 }>()
17
+
18
+function handleClick() {
19
+  // debounce(() => {
20
+  //   emit('click:item', props.item)
21
+
22
+  throttle(() => {
23
+    // uni.navigateTo({
24
+    //   url: `/pages/store/product/detail?id=${item.product_id}`
25
+    // })
26
+    emit('click:item', props.item)
27
+
28
+  })
29
+  // }, 100)
30
+
31
+}
15 32
 </script>
16 33
 
17 34
 <template>
18 35
   <div
19
-      @tap.stop="emit('click:item', item)"
36
+      @tap.stop="handleClick"
20 37
       class="bg-white rounded-lg"
21 38
   >
22 39
     <image :src="item.image" mode="widthFix" 	:fade-in="true" class="rounded-t-lg  !w-full aspect-square" v-if="item.type == 5"></image>

+ 22 - 1
src/components/ProductList/ProductList.vue

@@ -2,6 +2,9 @@
2 2
 
3 3
 import ProductCard from "~/components/ProductCard/ProductCard.vue";
4 4
 import CXBEmpty from "~/components/CXBEmpty/CXBEmpty.vue";
5
+import {debounce} from "lodash-es";
6
+import {useThrottleFn} from "@vueuse/core";
7
+import {throttle} from "~/utils/throttle";
5 8
 
6 9
 const props = defineProps({
7 10
   list: {
@@ -14,11 +17,29 @@ const props = defineProps({
14 17
 })
15 18
 
16 19
 function handleClickItem(item) {
17
-  console.log(item)
20
+  // console.log(item)
18 21
   if (item.type === 5 || item.type === '5') {
22
+  // _.debounce(() => {
23
+  // debounce(() => {
24
+  // return useThrottleFn(() => {
25
+  //   uni.navigateTo({
26
+  //     url: `/pages/store/product/detail?id=${item.product_id}`
27
+  //   })
28
+  // }, 100)
29
+  //   throttle()
30
+
19 31
     uni.navigateTo({
20 32
       url: `/pages/store/product/detail?id=${item.product_id}`
21 33
     })
34
+    // throttle(() => {
35
+    //   uni.navigateTo({
36
+    //     url: `/pages/store/product/detail?id=${item.product_id}`
37
+    //   })
38
+    // })
39
+  // }, 200)
40
+
41
+  // })
42
+
22 43
   }
23 44
   // uni.navigateTo({
24 45
   // })

+ 15 - 0
src/pages/dacang/list/index.vue

@@ -26,7 +26,20 @@ const state = reactive({
26 26
 })
27 27
 
28 28
 const dacangStore = useDacangStore()
29
+onShareAppMessage(() => {
30
+  return {
31
+    title: `消费储蓄 保障未来`,
32
+    path: '/pages/dacang/list/index',
33
+    imageUrl: 'https://cdn.bjtdba.com/vod/image/2023-10-09/20231009202402136.png'
34
+  }
35
+})
29 36
 
37
+onShareTimeline(() => {
38
+  return {
39
+    title: `消费储蓄 保障未来`,
40
+    imageUrl: 'https://cdn.bjtdba.com/vod/image/2023-10-09/20231009202402136.png',
41
+  }
42
+})
30 43
 onLoad(async () => {
31 44
   state.tabs = [{store_category_id: '-1', cate_name: '全部'}]
32 45
   const classifyRes = await getDcProductClassify()
@@ -38,6 +51,8 @@ onLoad(async () => {
38 51
     }
39 52
   })
40 53
 })
54
+
55
+
41 56
 onShow(async (options) => {
42 57
   usePageStore.setPageConfig({
43 58
     currentPage: {

+ 18 - 7
src/pages/home/components/product-list.vue

@@ -9,6 +9,7 @@ import {
9 9
 import {DcProductModel} from "~/apis/model/dacang.model";
10 10
 import {PLATFORM_NAME} from "~/apis/model/common.model";
11 11
 import {encodeBase64} from "~/utils/http/helper";
12
+import {throttle} from "~/utils/throttle";
12 13
 
13 14
 const props = defineProps({
14 15
   list: {
@@ -34,15 +35,25 @@ function handleProductItemClick(
34 35
 
35 36
   function navigateToDetail(params) {
36 37
     let otherDetailUrl = `/pages/store/product/other`
37
-    return uni.navigateTo({
38
-      url: `${otherDetailUrl}?params=${params}`
39
-    })
38
+    // throttle(() => {
39
+
40
+      return uni.navigateTo({
41
+        url: `${otherDetailUrl}?params=${params}`
42
+      })
43
+    // })
40 44
   }
41 45
   // 大仓
42 46
   if (item.type === '5') {
43
-    uni.navigateTo({
44
-      url: `/pages/store/product/detail?id=${item.product_id}`
45
-    })
47
+    // throttle(() => {
48
+      // uni.navigateTo({
49
+      //   url: `/pages/store/product/detail?id=${item.product_id}`
50
+      // })
51
+      return uni.navigateTo({
52
+        url: `/pages/store/product/detail?id=${item.product_id}`
53
+      })
54
+
55
+    // })
56
+
46 57
   }
47 58
   // 京东
48 59
   if (item.type == 6) {
@@ -65,7 +76,7 @@ function handleProductItemClick(
65 76
     return navigateToDetail(encodeBase64(productParams))
66 77
   }
67 78
   // 淘宝
68
-  if (item.type == 5) {
79
+  if (item.type === 5) {
69 80
     const productParams: Partial<IProductDetail> = {
70 81
       platform: item.type,
71 82
       id: item.id,

+ 15 - 0
src/pages/home/index.vue

@@ -13,6 +13,7 @@ import CXBDialogSIgnIn from "~/components/CXBDialogSignIn/CXBDialogSIgnIn.vue";
13 13
 import CXBDialogSIgnInSucceed from "~/components/CXBDialogSignInSucceed/CXBDialogSIgnInSucceed.vue";
14 14
 import {CDN_URL} from "~/config/app";
15 15
 import CXBPrivacyPopup from "~/components/CXBPrivacyPopup/CXBPrivacyPopup.vue";
16
+import {getShareId} from "~/apis/product";
16 17
 // import CXBDialogSIgnIn from "~/components/CXBDialogSignIn/CXBDialogSIgnIn.vue";
17 18
 // import CXBDialogSIgnInSucceed from "~/components/CXBDialogSignInSucceed/CXBDialogSIgnInSucceed.vue";
18 19
 const userStore = useUserStore()
@@ -24,6 +25,20 @@ usePageStore.setPageConfig({
24 25
   }
25 26
 })
26 27
 
28
+onShareAppMessage(() => {
29
+  return {
30
+    title: `消费储蓄 保障未来`,
31
+    path: '/pages/home/index',
32
+    imageUrl: 'https://cdn.bjtdba.com/vod/image/2023-10-09/20231009202402136.png'
33
+  }
34
+})
35
+
36
+onShareTimeline(() => {
37
+  return {
38
+    title: `消费储蓄 保障未来`,
39
+    imageUrl: 'https://cdn.bjtdba.com/vod/image/2023-10-09/20231009202402136.png'
40
+  }
41
+})
27 42
 // const list = ref([])
28 43
 const state = reactive({
29 44
   yanglaojine: {},

+ 1 - 1
src/pages/order-confirm/index.vue

@@ -9,7 +9,7 @@ import FCell from "~/components/FCell/FCell.vue";
9 9
 import {encodePhone} from "~/utils";
10 10
 import {CDN_URL} from "~/config/app";
11 11
 import {useAddressStore} from "~/stores/addressStore";
12
-import {watchThrottled} from "@vueuse/core";
12
+import {useThrottle} from "@vueuse/core";
13 13
 import FField from "~/components/FField/FField.vue";
14 14
 const addressIcon = CDN_URL + '/static/assets/dingwi_220624.png'
15 15
 // const addressInfo = ref({})

+ 15 - 0
src/pages/store/home/index.vue

@@ -70,7 +70,22 @@ onLoad((options: any) => {
70 70
     // getStoreProductList()
71 71
   }
72 72
 })
73
+onShareAppMessage(() => {
74
+  return {
75
+    title: `消费储蓄 保障未来`,
76
+    path: '/pages/store/home/index?id=' + id.value,
77
+    imageUrl: 'https://cdn.bjtdba.com/vod/image/2023-10-09/20231009202402136.png'
78
+  }
79
+})
80
+
81
+onShareTimeline(() => {
82
+  return {
83
+    title: `消费储蓄 保障未来`,
84
+    imageUrl: 'https://cdn.bjtdba.com/vod/image/2023-10-09/20231009202402136.png',
85
+    query: `id=${id.value}`
73 86
 
87
+  }
88
+})
74 89
 const is148Merchant = computed(() => {
75 90
   return merchant.value && merchant.value.mer_id && merchant.value.mer_id == '148'
76 91
 })

+ 13 - 0
src/pages/store/nearby/index.vue

@@ -6,7 +6,20 @@ import CXBEmpty from "~/components/CXBEmpty/CXBEmpty.vue";
6 6
 import {USER_LATITUDE, USER_LONGITUDE} from "~/constants";
7 7
 const usePageStore = usePageStoreWidthOut()
8 8
 
9
+onShareAppMessage(() => {
10
+  return {
11
+    title: `消费储蓄 保障未来`,
12
+    path: '/pages/store/nearby/index',
13
+    imageUrl: 'https://cdn.bjtdba.com/vod/image/2023-10-09/20231009202402136.png'
14
+  }
15
+})
9 16
 
17
+onShareTimeline(() => {
18
+  return {
19
+    title: `消费储蓄 保障未来`,
20
+    imageUrl: 'https://cdn.bjtdba.com/vod/image/2023-10-09/20231009202402136.png'
21
+  }
22
+})
10 23
 const state = reactive({
11 24
   // 列表高度
12 25
   scrollHeight: 0,

+ 4 - 1
src/pages/store/product/detail.vue

@@ -15,9 +15,9 @@ import {
15 15
 } from "~/apis/model/product.model";
16 16
 import {DcProductModel} from "~/apis/model/dacang.model";
17 17
 import {CDN_URL} from "~/config/app";
18
-import {debounce} from "lodash-es";
19 18
 import dayjs from "dayjs";
20 19
 import {getShareId} from "~/apis/product";
20
+import {debounce} from "lodash-es";
21 21
 
22 22
 const usePageStore = usePageStoreWidthOut()
23 23
 
@@ -60,6 +60,7 @@ const state = reactive({
60 60
   isNew: '0',
61 61
   cartNum: 1,
62 62
   cartCount: NaN,
63
+  shareImage: '',
63 64
 })
64 65
 const detail: any = ref(null)
65 66
 
@@ -114,6 +115,7 @@ function loadProductDetail() {
114 115
     // console.log(res)
115 116
     detail.value = res
116 117
 
118
+    state.shareImage = detail.value.image
117 119
     if (res && res.mer_id && res.mer_id === '148') {
118 120
       if (detail.value && detail.value.price ) {
119 121
         detail.value.price = detail.value.price * 30
@@ -192,6 +194,7 @@ onShareTimeline(() => {
192 194
 
193 195
   return {
194 196
     title: `${detail.value.store_name}`,
197
+    imageUrl:  state.shareImage,
195 198
     query: `id=${state.id}&from=share&shareID=${state.shareId}`
196 199
   }
197 200
 

+ 47 - 9
src/pages/store/product/other.vue

@@ -20,11 +20,12 @@ import FButton from "~/components/FButton/FButton.vue";
20 20
 import CXBButton from "~/components/CXBButton/CXBButton.vue";
21 21
 import {debounce, merge} from "lodash-es";
22 22
 
23
-import { useDebounceFn } from '@vueuse/core';
23
+import {useDebounceFn} from '@vueuse/core';
24 24
 
25 25
 import dayjs from "dayjs";
26 26
 import {decodeBase64} from "~/utils/http/helper";
27 27
 import {CDN_URL} from "~/config/app";
28
+
28 29
 const discount_coupon_bg_220804Image = CDN_URL + '/static/assets/discount_coupon_bg_220804.png'
29 30
 const productId = ref('')
30 31
 //
@@ -73,6 +74,7 @@ onShow(() => {
73 74
 function mergeProductDetail(data: Partial<IProductDetail> = {}) {
74 75
   detail.value = merge(detail.value, data)
75 76
 }
77
+
76 78
 function loadProductDetail(product: Partial<IProductDetail>) {
77 79
   // 京东
78 80
   if (product.platform == 6) {
@@ -195,9 +197,10 @@ function loadProductDetail(product: Partial<IProductDetail>) {
195 197
 
196 198
   }
197 199
 }
200
+
198 201
 function handleBuyNow() {
199 202
   if (isSubmit.value) return
200
-  if(!userStore.uid) {
203
+  if (!userStore.uid) {
201 204
     isSubmit.value = true
202 205
 
203 206
     uni.navigateTo({
@@ -261,10 +264,42 @@ function handleBuyNow() {
261 264
       // console.log(detail.value.pddlink)
262 265
       // console.log(pddWx)
263 266
     } else {
264
-      return uni.showToast({
265
-        title: '商品维护中,请稍后再试',
266
-        icon: 'none'
267
+      console.log(detail.value?.platform)
268
+      let platformName = ''
269
+      let clipboardData = ''
270
+      if (detail.value?.platform === 5) {
271
+        platformName = '淘宝'
272
+        clipboardData = detail.value?.spreadUrl
273
+      }
274
+      if (detail.value?.platform === 9) {
275
+        platformName = '抖音'
276
+        clipboardData = detail.value?.dyZlink
277
+      }
278
+      if (detail.value?.platform == 2) {
279
+        platformName = '唯品会'
280
+        clipboardData = detail.value?.destUrl
281
+      }
282
+      if (detail.value?.platform == 3) {
283
+        platformName = '苏宁易购'
284
+        clipboardData = detail.value?.productUrlWap
285
+      }
286
+      // if (detail.value?.platform === 5) {
287
+      console.log(detail.value)
288
+      return uni.setClipboardData({
289
+        data: clipboardData,
290
+        success(res) {
291
+          return uni.showToast({
292
+            title: `链接已复制,去【${platformName}】打开即可。`,
293
+            icon: 'none'
294
+          })
295
+        }
267 296
       })
297
+
298
+      // }
299
+      // return uni.showToast({
300
+      //   title: '商品维护中,请稍后再试',
301
+      //   icon: 'none'
302
+      // })
268 303
     }
269 304
   }
270 305
   /*
@@ -312,8 +347,10 @@ const hasCoupon = computed(() => {
312 347
       <div>
313 348
         <div class="relative p-3 bg-white">
314 349
           <div class="flex gap-2 items-end">
315
-            <FPrice v-if="detail && detail.salePrice" :price="detail.salePrice" need-symbol :size="'large'" ex-class="!text-[24px]"/>
316
-            <FPrice v-if="detail && detail.price" :price="detail.price" :ex-class="'!text-gray'" need-symbol strike-through/>
350
+            <FPrice v-if="detail && detail.salePrice" :price="detail.salePrice" need-symbol :size="'large'"
351
+                    ex-class="!text-[24px]"/>
352
+            <FPrice v-if="detail && detail.price" :price="detail.price" :ex-class="'!text-gray'" need-symbol
353
+                    strike-through/>
317 354
           </div>
318 355
 
319 356
           <div class="font-bold py-2">{{ detail.title }}</div>
@@ -334,7 +371,8 @@ const hasCoupon = computed(() => {
334 371
             <div class="absolute top-2 left-15 h-full w-fit text-white"
335 372
             >
336 373
               <div class=" inline-flex justify-center items-end w-full py-2">
337
-                <div class="text-[28px]">{{ detail.coupon.amount }}</div> 元代金劵
374
+                <div class="text-[28px]">{{ detail.coupon.amount }}</div>
375
+                元代金劵
338 376
               </div>
339 377
               <div class="text-[10px]">使用期限:{{ detail.coupon.startTime }} -{{ detail.coupon.endTime }}</div>
340 378
             </div>
@@ -346,7 +384,7 @@ const hasCoupon = computed(() => {
346 384
           <div v-if="detail.mallName" class="p-3 font-bold">
347 385
             {{ detail.mallName }}
348 386
           </div>
349
-<!--          <mpHtml :content=""></mpHtml>-->
387
+          <!--          <mpHtml :content=""></mpHtml>-->
350 388
           <image v-for="(imgItem, index) in detail.images"
351 389
                  :key="index"
352 390
                  mode="widthFix"

+ 13 - 0
src/pages/vip/index.vue

@@ -129,7 +129,20 @@ const navBarStyle = computed(() => {
129 129
     paddingTop: `${statusBarHeight}px`,
130 130
   }
131 131
 })
132
+onShareAppMessage(() => {
133
+  return {
134
+    title: `消费储蓄 保障未来`,
135
+    path: '/pages/vip/index',
136
+    imageUrl: 'https://cdn.bjtdba.com/vod/image/2023-10-09/20231009202402136.png'
137
+  }
138
+})
132 139
 
140
+onShareTimeline(() => {
141
+  return {
142
+    title: `消费储蓄 保障未来`,
143
+    imageUrl: 'https://cdn.bjtdba.com/vod/image/2023-10-09/20231009202402136.png',
144
+  }
145
+})
133 146
 const state = reactive({
134 147
   currentPage: 1,
135 148
   pageSize: 10,

File diff suppressed because it is too large
+ 117 - 95
src/utils/http/pdd.json


+ 30 - 0
src/utils/throttle.ts

@@ -0,0 +1,30 @@
1
+
2
+let timer; let
3
+    flag
4
+/**
5
+ * 节流原理:在一定时间内,只能触发一次
6
+ *
7
+ * @param {Function} func 要执行的回调函数
8
+ * @param {Number} wait 延时的时间
9
+ * @param {Boolean} immediate 是否立即执行
10
+ * @return null
11
+ */
12
+export function throttle(func, wait = 500, immediate = true) {
13
+    if (immediate) {
14
+        if (!flag) {
15
+            flag = true
16
+            // 如果是立即执行,则在wait毫秒内开始时执行
17
+            typeof func === 'function' && func()
18
+            timer = setTimeout(() => {
19
+                flag = false
20
+            }, wait)
21
+        }
22
+    } else if (!flag) {
23
+        flag = true
24
+        // 如果是非立即执行,则在wait毫秒内的结束处执行
25
+        timer = setTimeout(() => {
26
+            flag = false
27
+            typeof func === 'function' && func()
28
+        }, wait)
29
+    }
30
+}