Преглед изворни кода

feat:积分订单列表修改返回结构

xyh пре 5 месеци
родитељ
комит
28e565a5ef

+ 19 - 0
src/api/pointOrder.js

@@ -0,0 +1,19 @@
+import request from "@/utils/request.js";
+
+//积分订单列表
+export function getPointOrderList(data) {
+    return request({
+        method: 'get',
+        url: '/product/order/list',
+        data
+    });
+}
+
+//积分订单详情
+export function getPointOrderInfo(data) {
+    return request({
+        method: 'get',
+        url: '/product/order/detail',
+        data
+    });
+}

+ 0 - 9
src/api/points.js

@@ -53,12 +53,3 @@ export function getPointTaskList(data) {
         data
     });
 }
-
-//积分订单列表
-export function getPointOrderList(data) {
-    return request({
-        method: 'get',
-        url: '/product/order/list',
-        data
-    });
-}

+ 5 - 11
src/points/components/task-list/task-list.vue

@@ -18,7 +18,6 @@
             <view class="task-icon">
               <ImageItem :src="getTaskIcon(task.taskName)" />
             </view>
-
             <view class="task-info">
               <view class="task-name">{{ task.taskName }}</view>
               <view class="task-reward">
@@ -32,21 +31,16 @@
             <button 
               :class="Number(task.completedCount) >= Number(task.triggerValue) ? 'task-btn' : 'no-task-btn'"
               @click.stop="handleTask(task)"
-              :disabled="Number(task.completedCount) >= Number(task.triggerValue)"
-            >
+              :disabled="Number(task.completedCount) >= Number(task.triggerValue)">
               {{Number(task.completedCount) >= Number(task.triggerValue) ? '已完成' : '去完成' }}
             </button>
           </view>
         </view>
       </view>
-      <view class="more-tasks" @click="handleMoreTasks">
-        赚更多积分 >
-      </view>
+      <view class="more-tasks" @click="handleMoreTasks">赚更多积分 ></view>
     </view>
     <!-- 空状态 -->
-    <view v-else class="task-list-empty">
-     暂无任务活动
-    </view>
+    <view v-else class="task-list-empty">暂无任务活动</view>
   </view>
 </template>
 
@@ -143,8 +137,8 @@ export default {
     handleServiceTask() {
       // 调用微信服务号分享功能
       handleServiceShare({
-        title: '广誉远 - 关注服务号',
-        desc: '关注广誉远服务号,获取更多积分和优惠',
+        title: '广誉远 - 关注服务号123123',
+        desc: '关注广誉远服务号,获取更多积分和优惠123123123',
         link: window.location.href,
         imgUrl: '/static/points/task_wx.png'
       });

+ 27 - 9
src/points/order/orderList.vue

@@ -1,5 +1,5 @@
 <script>
-import {getPointDetails, getPointOrderList} from '@/api/points'
+import {getPointOrderList} from '@/api/pointOrder'
 export default {
   name: "orderList",
   data(){
@@ -28,18 +28,34 @@ export default {
         })
         const {data} = res;
         if (data.code === 200) {
+          // 初始加载数据
+          data.data.records = data.data.records.map(item=>{
+            let skuspecStr = '';
+            try {
+              const skuspec = item?.skuspec;
+              if (skuspec && skuspec !== 'undefined' && skuspec !== 'null') {
+                const parsedSpec = JSON.parse(skuspec);
+                if (Array.isArray(parsedSpec)) {
+                  skuspecStr = parsedSpec.map(t=>t?.specValue).filter(Boolean).toString();
+                }
+              }
+            } catch (error) {
+              console.error('解析 skuspec 失败:', error);
+            }
+            return{
+              ...item,
+              skuspec: skuspecStr
+            }
+          })
           if (isLoadMore) {
-            // 加载更多数据
             this.orderList = [...this.orderList, ...data.data.records]
           } else {
-            // 初始加载数据
-            this.orderList = data.data.records
+            this.orderList = data.data.records;
           }
-          // 判断是否还有更多数据
           this.hasMore = this.orderList.length < data.data.total
         }
       } catch (error) {
-        console.error('获取积分明细失败:', error)
+        console.error('获取积分订单失败:', error)
       } finally {
         this.loading = false
       }
@@ -52,7 +68,7 @@ export default {
     },
     viewDetail(order){
       uni.navigateTo({
-        url: '/points/order/orderDetails?orderId=' + order.id,
+        url: '/points/order/orderDetails?orderNo=' + order.orderNo,
       });
     }
   }
@@ -70,8 +86,10 @@ export default {
         <view class="order-body">
           <view class="product-info">
             <text class="product-name">{{ item.productName }}</text>
-            <text class="product-spec">{{ item.totalAmount }}</text>
-            <text class="product-price">¥{{ item.productId }}+{{ item.productId }}积分</text>
+            <text class="product-spec">{{ item.skuspec }}</text>
+            <text class="product-price" v-if="item.paymentType == 1">{{ item.pointsUsed }}积分</text>
+            <text class="product-price" v-if="item.paymentType == 2">¥{{ item.totalAmount }}</text>
+            <text class="product-price" v-if="item.paymentType == 3">¥{{ item.totalAmount }}+{{ item.pointsUsed }}积分</text>
           </view>
           <button class="detail-button" @click="viewDetail(item)">查看详情</button>
         </view>

+ 0 - 1
src/points/pointInfo/billPage.vue

@@ -137,7 +137,6 @@ export default {
     // 加载更多数据
     loadMore() {
       if (this.loading || !this.hasMore) return
-      
       this.pageNum++
       this.fetchPointDetails(true)
     },

+ 140 - 0
src/utils/share.js

@@ -0,0 +1,140 @@
+// 微信服务号分享功能
+import wx from 'weixin-js-sdk'
+import {getSignature} from "@/api";
+
+/**
+ * 初始化微信 JS-SDK
+ * @param {Object} config - 微信 JS-SDK 配置参数
+ */
+export function initWechatSDK(config) {
+  if (typeof wx === 'undefined') {
+    console.error('微信 JS-SDK 未加载');
+    return;
+  }
+  
+  wx.config({
+    debug: false,
+    appId: config.appId,
+    timestamp: config.timestamp,
+    nonceStr: config.nonceStr,
+    signature: config.signature,
+    jsApiList: [
+      'updateAppMessageShareData',
+      'updateTimelineShareData',
+      'onMenuShareAppMessage',
+      'onMenuShareTimeline'
+    ]
+  });
+  
+  wx.ready(function() {
+    console.log('微信 JS-SDK 初始化成功');
+  });
+  
+  wx.error(function(res) {
+    console.error('微信 JS-SDK 初始化失败:', res);
+  });
+}
+
+/**
+ * 配置微信分享参数
+ * @param {Object} options - 分享配置选项
+ * @param {string} options.title - 分享标题
+ * @param {string} options.desc - 分享描述
+ * @param {string} options.link - 分享链接
+ * @param {string} options.imgUrl - 分享图标
+ */
+export function configWechatShare(options) {
+  if (typeof wx === 'undefined') {
+    console.error('微信 JS-SDK 未加载');
+    return;
+  }
+  
+  const { title, desc, link, imgUrl } = options;
+  
+  // 分享给朋友
+  wx.updateAppMessageShareData({
+    title: title,
+    desc: desc,
+    link: link,
+    imgUrl: imgUrl,
+    success: function() {
+      console.log('分享给朋友成功');
+    },
+    cancel: function() {
+      console.log('分享给朋友取消');
+    }
+  });
+  
+  // 分享到朋友圈
+  wx.updateTimelineShareData({
+    title: title,
+    link: link,
+    imgUrl: imgUrl,
+    success: function() {
+      console.log('分享到朋友圈成功');
+    },
+    cancel: function() {
+      console.log('分享到朋友圈取消');
+    }
+  });
+  
+  // 兼容旧版本
+  wx.onMenuShareAppMessage({
+    title: title,
+    desc: desc,
+    link: link,
+    imgUrl: imgUrl,
+    success: function() {
+      console.log('分享给朋友成功(旧版本)');
+    },
+    cancel: function() {
+      console.log('分享给朋友取消(旧版本)');
+    }
+  });
+  
+  wx.onMenuShareTimeline({
+    title: title,
+    link: link,
+    imgUrl: imgUrl,
+    success: function() {
+      console.log('分享到朋友圈成功(旧版本)');
+    },
+    cancel: function() {
+      console.log('分享到朋友圈取消(旧版本)');
+    }
+  });
+}
+
+/**
+ * 处理微信服务号分享
+ * @param {Object} shareData - 分享数据
+ */
+export async function handleServiceShare(shareData) {
+  // 这里可以根据实际需求,调用后端接口获取微信 JS-SDK 配置
+  const res = await getSignature()
+  // 假设已经获取到配置信息
+  const wxConfig = {
+    appId: res.data.appId, // 从后端获取
+    timestamp: res.data.timestamp, // 从后端获取
+    nonceStr: res.data.nonceStr, // 从后端获取
+    signature: res.data.signature // 从后端获取
+  };
+
+  // 初始化微信 JS-SDK
+  initWechatSDK(wxConfig);
+
+  // 配置分享参数
+  configWechatShare({
+    title: shareData.title || '广誉远 - 积分任务',
+    desc: shareData.desc || '完成任务获取积分,兑换好礼',
+    link: shareData.link || window.location.href,
+    imgUrl: shareData.imgUrl || '/static/points/point.png'
+  });
+
+  // 提示用户分享
+  uni.showToast({
+    title: '请点击右上角分享到微信',
+    icon: 'none',
+    duration: 2000
+  });
+}