Просмотр исходного кода

feat:对接订单列表接口

xyh 5 месяцев назад
Родитель
Сommit
8151aa714c
2 измененных файлов с 44 добавлено и 195 удалено
  1. 9 0
      src/api/points.js
  2. 35 195
      src/points/order/orderList.vue

+ 9 - 0
src/api/points.js

@@ -52,4 +52,13 @@ export function getPointTaskList(data) {
         url: '/user/point/activity/page',
         url: '/user/point/activity/page',
         data
         data
     });
     });
+}
+
+//积分订单列表
+export function getPointOrderList(data) {
+    return request({
+        method: 'get',
+        url: '/product/order/list',
+        data
+    });
 }
 }

+ 35 - 195
src/points/order/orderList.vue

@@ -1,154 +1,10 @@
 <script>
 <script>
+import {getPointDetails, getPointOrderList} from '@/api/points'
 export default {
 export default {
   name: "orderList",
   name: "orderList",
   data(){
   data(){
     return {
     return {
-      orderList: [
-        {
-          id: 1,
-          time: '2026-1-26 10:00:00',
-          status: 'pending',
-          statusText: '待发货',
-          product: {
-            name: '广誉源会员定制玻璃杯',
-            spec: '大号,白色',
-            price: 10,
-            points: 1000
-          }
-        },
-        {
-          id: 2,
-          time: '2026-1-26 10:00:00',
-          status: 'shipped',
-          statusText: '已发货',
-          product: {
-            name: '广誉源会员定制玻璃杯',
-            spec: '大号,白色',
-            price: 10,
-            points: 1000
-          }
-        },
-        {
-          id: 3,
-          time: '2026-1-26 10:00:00',
-          status: 'delivered',
-          statusText: '已收货',
-          product: {
-            name: '广誉源会员定制玻璃杯',
-            spec: '大号,白色',
-            price: 10,
-            points: 1000
-          }
-        },
-        {
-          id: 4,
-          time: '2026-1-26 10:00:00',
-          status: 'pending',
-          statusText: '待发货',
-          product: {
-            name: '广誉源会员定制玻璃杯',
-            spec: '大号,白色',
-            price: 10,
-            points: 1000
-          }
-        },
-        {
-          id: 5,
-          time: '2026-1-26 10:00:00',
-          status: 'shipped',
-          statusText: '已发货',
-          product: {
-            name: '广誉源会员定制玻璃杯',
-            spec: '大号,白色',
-            price: 10,
-            points: 1000
-          }
-        },
-        {
-          id: 6,
-          time: '2026-1-26 10:00:00',
-          status: 'delivered',
-          statusText: '已收货',
-          product: {
-            name: '广誉源会员定制玻璃杯',
-            spec: '大号,白色',
-            price: 10,
-            points: 1000
-          }
-        },
-        {
-          id: 7,
-          time: '2026-1-26 10:00:00',
-          status: 'pending',
-          statusText: '待发货',
-          product: {
-            name: '广誉源会员定制玻璃杯',
-            spec: '大号,白色',
-            price: 10,
-            points: 1000
-          }
-        },
-        {
-          id: 8,
-          time: '2026-1-26 10:00:00',
-          status: 'shipped',
-          statusText: '已发货',
-          product: {
-            name: '广誉源会员定制玻璃杯',
-            spec: '大号,白色',
-            price: 10,
-            points: 1000
-          }
-        },
-        {
-          id: 9,
-          time: '2026-1-26 10:00:00',
-          status: 'delivered',
-          statusText: '已收货',
-          product: {
-            name: '广誉源会员定制玻璃杯',
-            spec: '大号,白色',
-            price: 10,
-            points: 1000
-          }
-        },
-        {
-          id: 10,
-          time: '2026-1-26 10:00:00',
-          status: 'pending',
-          statusText: '待发货',
-          product: {
-            name: '广誉源会员定制玻璃杯',
-            spec: '大号,白色',
-            price: 10,
-            points: 1000
-          }
-        },
-        {
-          id: 11,
-          time: '2026-1-26 10:00:00',
-          status: 'shipped',
-          statusText: '已发货',
-          product: {
-            name: '广誉源会员定制玻璃杯',
-            spec: '大号,白色',
-            price: 10,
-            points: 1000
-          }
-        },
-        {
-          id: 12,
-          time: '2026-1-26 10:00:00',
-          status: 'delivered',
-          statusText: '已收货',
-          product: {
-            name: '广誉源会员定制玻璃杯',
-            spec: '大号,白色',
-            price: 10,
-            points: 1000
-          }
-        }
-      ],
+      orderList: [],
       // 加载状态
       // 加载状态
       loading: false,
       loading: false,
       // 是否有更多数据
       // 是否有更多数据
@@ -159,56 +15,40 @@ export default {
     }
     }
   },
   },
   onReady() {
   onReady() {
-    // 初始获取数据
-    // 这里可以添加获取订单列表的逻辑
+    this.getListOrder();
   },
   },
   methods:{
   methods:{
-    loadMore(){
-      if (this.loading || !this.hasMore) return
-      
+    async getListOrder(isLoadMore = false) {
       this.loading = true
       this.loading = true
-      this.page++
-      
-      // 模拟加载数据
-      setTimeout(() => {
-        // 模拟新数据
-        const newOrders = [
-          {
-            id: this.orderList.length + 1,
-            time: '2026-1-26 10:00:00',
-            status: 'pending',
-            statusText: '待发货',
-            product: {
-              name: '广誉源会员定制玻璃杯',
-              spec: '大号,白色',
-              price: 10,
-              points: 1000
-            }
-          },
-          {
-            id: this.orderList.length + 2,
-            time: '2026-1-26 10:00:00',
-            status: 'shipped',
-            statusText: '已发货',
-            product: {
-              name: '广誉源会员定制玻璃杯',
-              spec: '大号,白色',
-              price: 10,
-              points: 1000
-            }
+      try {
+        const res = await getPointOrderList({
+          current: this.page,
+          size: this.pageSize,
+          openId: uni.getStorageSync('wx_copenid')
+        })
+        const {data} = res;
+        if (data.code === 200) {
+          if (isLoadMore) {
+            // 加载更多数据
+            this.orderList = [...this.orderList, ...data.data.records]
+          } else {
+            // 初始加载数据
+            this.orderList = data.data.records
           }
           }
-        ]
-        
-        // 添加新数据
-        this.orderList = [...this.orderList, ...newOrders]
-        
-        // 模拟没有更多数据
-        if (this.page >= 3) {
-          this.hasMore = false
+          // 判断是否还有更多数据
+          this.hasMore = this.orderList.length < data.data.total
         }
         }
-        
+      } catch (error) {
+        console.error('获取积分明细失败:', error)
+      } finally {
         this.loading = false
         this.loading = false
-      }, 1000)
+      }
+    },
+    loadMore(){
+      if (this.loading || !this.hasMore) return
+      this.loading = true
+      this.page++
+      this.getListOrder(true)
     },
     },
     viewDetail(order){
     viewDetail(order){
       uni.navigateTo({
       uni.navigateTo({
@@ -224,14 +64,14 @@ export default {
     <u-list @scrolltolower="loadMore" style="height:calc(100vh - 100rpx)">
     <u-list @scrolltolower="loadMore" style="height:calc(100vh - 100rpx)">
       <u-list-item v-for="(item, index) in orderList" :key="item.id" class="order-item">
       <u-list-item v-for="(item, index) in orderList" :key="item.id" class="order-item">
         <view class="order-header">
         <view class="order-header">
-          <text class="order-time">下单时间: {{ item.time }}</text>
-          <text class="order-status" :class="item.status">{{ item.statusText }}</text>
+          <text class="order-time">下单时间: {{ item.createTime }}</text>
+          <text class="order-status" :class="item.status">{{ item.orderStatusName }}</text>
         </view>
         </view>
         <view class="order-body">
         <view class="order-body">
           <view class="product-info">
           <view class="product-info">
-            <text class="product-name">{{ item.product.name }}</text>
-            <text class="product-spec">{{ item.product.spec }}</text>
-            <text class="product-price">¥{{ item.product.price }}+{{ item.product.points }}积分</text>
+            <text class="product-name">{{ item.productName }}</text>
+            <text class="product-spec">{{ item.totalAmount }}</text>
+            <text class="product-price">¥{{ item.productId }}+{{ item.productId }}积分</text>
           </view>
           </view>
           <button class="detail-button" @click="viewDetail(item)">查看详情</button>
           <button class="detail-button" @click="viewDetail(item)">查看详情</button>
         </view>
         </view>