Forráskód Böngészése

客服:完善商品消息发送

puhui999 1 éve
szülő
commit
b630d26d4b

+ 13 - 27
pages/chat/components/chatBox.vue

@@ -91,16 +91,16 @@
                   ></su-image>
                 </view>
               </template>
-              <!--              <template v-if="item.contentType === KeFuMessageContentTypeEnum.PRODUCT">-->
-              <!--                <GoodsItem-->
-              <!--                  :goodsData="item.content.item"-->
-              <!--                  @tap="-->
-              <!--                  sheep.$router.go('/pages/goods/index', {-->
-              <!--                    id: item.content.item.id,-->
-              <!--                  })-->
-              <!--                "-->
-              <!--                />-->
-              <!--              </template>-->
+              <template v-if="item.contentType === KeFuMessageContentTypeEnum.PRODUCT">
+                <GoodsItem
+                  :goodsData="JSON.parse(item.content)"
+                  @tap="
+                    sheep.$router.go('/pages/goods/index', {
+                      id: JSON.parse(item.content).id,
+                    })
+                  "
+                />
+              </template>
               <!--              <template v-if="item.contentType === KeFuMessageContentTypeEnum.ORDER">-->
               <!--                <OrderItem-->
               <!--                  from="msg"-->
@@ -133,8 +133,9 @@
 </template>
 
 <script setup>
-  import { nextTick, onMounted,onBeforeUnmount, reactive, ref, unref } from 'vue';
+  import { nextTick, onBeforeUnmount, onMounted, reactive, ref, unref } from 'vue';
   import { onLoad } from '@dcloudio/uni-app';
+  import GoodsItem from './goods.vue';
   import sheep from '@/sheep';
   import KeFuApi from '@/sheep/api/promotion/kefu';
   import { isEmpty } from '@/sheep/helper/utils';
@@ -175,22 +176,6 @@
   };
   defineExpose({ getMessageList });
 
-  const poller = ref(null) // TODO puhui999: 轮训定时器,暂时模拟 websocket
-  onMounted(() => {
-    // TODO puhui999: 轮训相关,功能完善后移除
-    if (!poller.value) {
-      poller.value = setInterval(() => {
-        getMessageList(1)
-      }, 1000)
-    }
-  })
-  // TODO puhui999: 轮训相关,功能完善后移除
-  onBeforeUnmount(() => {
-    if (!poller.value) {
-      return
-    }
-    clearInterval(poller.value)
-  })
   const scrollTop = ref(0); // 当前滚动区域距离顶部的距离
   const currentTop = ref(0);
   const showGoBottom = ref(false);
@@ -232,6 +217,7 @@
 
   // 虚拟列表展示可视区域的数据
   const includePage = index => {
+    console.log(visiblePagesList.value, index);
     return visiblePagesList.value.indexOf(index) > -1;
   };
 

+ 5 - 6
pages/chat/components/goods.vue

@@ -1,15 +1,15 @@
 <template>
   <view class="goods ss-flex">
-    <image class="image" :src="sheep.$url.cdn(goodsData.image)" mode="aspectFill"> </image>
+    <image class="image" :src="sheep.$url.cdn(goodsData.picUrl)" mode="aspectFill"> </image>
     <view class="ss-flex-1">
       <view class="title ss-line-2">
-        {{ goodsData.title }}
+        {{ goodsData.spuName }}
       </view>
-      <view v-if="goodsData.subtitle" class="subtitle ss-line-1">
-        {{ goodsData.subtitle }}
+      <view v-if="goodsData.introduction" class="subtitle ss-line-1">
+        {{ goodsData.introduction }}
       </view>
       <view class="price ss-m-t-8">
-        ¥{{ isArray(goodsData.price) ? goodsData.price[0] : goodsData.price }}
+        ¥{{ goodsData.price }}
       </view>
     </view>
   </view>
@@ -17,7 +17,6 @@
 
 <script setup>
   import sheep from '@/sheep';
-  import { isArray } from 'lodash';
 
   const props = defineProps({
     goodsData: {

+ 3 - 4
pages/chat/components/select-popup.vue

@@ -14,11 +14,11 @@
         <view
           class="item"
           v-for="item in state.pagination.data"
-          :key="item"
+          :key="item.id"
           @tap="emits('select', { type: mode, data: item })"
         >
           <template v-if="mode == 'goods'">
-            <GoodsItem :goodsData="item.goods" />
+            <GoodsItem :goodsData="item" />
           </template>
           <template v-if="mode == 'order'">
             <OrderItem :orderData="item" />
@@ -32,7 +32,6 @@
 
 <script setup>
   import { reactive, watch } from 'vue';
-  import sheep from '@/sheep';
   import _ from 'lodash';
   import GoodsItem from './goods.vue';
   import OrderItem from './order.vue';
@@ -83,7 +82,7 @@
             page,
             list_rows,
           });
-    let orderList = _.concat(state.pagination.data, res.data.data);
+    let orderList = _.concat(state.pagination.data, res.data.list);
     state.pagination = {
       ...res.data,
       data: orderList,

+ 8 - 10
pages/chat/index.vue

@@ -118,19 +118,17 @@
           content: res.data,
         };
         break;
-      // TODO puhui999: 还需要重构
       case 'goods':
         msg = {
           contentType: KeFuMessageContentTypeEnum.PRODUCT,
-          content: {
-            item: {
-              id: data.goods.id,
-              title: data.goods.title,
-              image: data.goods.image,
-              price: data.goods.price,
-              stock: data.goods.stock,
-            },
-          },
+          content: JSON.stringify({
+            id: data.id,
+            spuName: data.spuName,
+            picUrl: data.picUrl,
+            price: data.price,
+            introduction: data.introduction,
+            stock: data.stock,
+          })
         };
         break;
       case 'order':