Explorar o código

feat:调整积分商城的商品分类接口和商品字段修改

xyh hai 5 meses
pai
achega
594e899ebb

+ 37 - 86
src/api/shop.js

@@ -7,37 +7,6 @@ export function getShopType(data) {
         url: '/product/category/list',
         data
     });
-
-    let res = {
-        "code": 200,
-        "msg": "操作成功",
-        "data": [
-            {
-                "parentId": 1,
-                "parentName": "商品",
-                "childId": 2,
-                "childCode": "1001",
-                "childName": "休闲",
-                "childSort": 1
-            },
-            {
-                "parentId": 1,
-                "parentName": "商品",
-                "childId": 3,
-                "childCode": "1002",
-                "childName": "日用",
-                "childSort": 2
-            },
-            {
-                "parentId": 1,
-                "parentName": "商品",
-                "childId": 4,
-                "childCode": "1003",
-                "childName": "娱乐",
-                "childSort": 3
-            }
-        ]
-    }
 }
 // 积分商品列表
 export function getPointShopList(data) {
@@ -45,80 +14,62 @@ export function getPointShopList(data) {
     return new Promise((resolve, reject) => {
         setTimeout(() => {
             const mockData = {
-                code: 200,
-                message: 'success',
-                data: {
-                    list: [
+                "code": 200,
+                "msg": "操作成功",
+                "data": {
+                    "records": [
                         {
                             id: 1,
-                            name: '广誉源会员定制玻璃杯',
-                            price: '10元+1000积分',
-                            value: '100',
+                            name: '广誉源会员定制玻璃杯1',
+                            pricePoint: '10元+1000积分',
+                            priceMoney: '100',
                             sales: 10,
-                            image: 'https://test.baoxianzhanggui.com/nightFragrance/profile/upload/2025/01/03/b43f6087c815cdab8828eb68529d96bc73203b941ab71e-xrpfmn_fw1200webp_20250103175413A002.png'
+                            productMainImage: 'https://test.baoxianzhanggui.com/nightFragrance/profile/upload/2025/01/03/b43f6087c815cdab8828eb68529d96bc73203b941ab71e-xrpfmn_fw1200webp_20250103175413A002.png'
                         },
                         {
                             id: 2,
-                            name: '广誉源会员定制保温杯',
-                            price: '20元+2000积分',
-                            value: '200',
-                            sales: 20,
-                            image: 'https://test.baoxianzhanggui.com/nightFragrance/profile/upload/2025/01/03/b43f6087c815cdab8828eb68529d96bc73203b941ab71e-xrpfmn_fw1200webp_20250103175413A002.png'
+                            name: '广誉源会员定制玻璃杯2',
+                            pricePoint: '10元+1000积分',
+                            priceMoney: '100',
+                            sales: 10,
+                            productMainImage: 'https://test.baoxianzhanggui.com/nightFragrance/profile/upload/2025/01/03/b43f6087c815cdab8828eb68529d96bc73203b941ab71e-xrpfmn_fw1200webp_20250103175413A002.png'
                         },
                         {
                             id: 3,
-                            name: '广誉源会员定制雨伞',
-                            price: '15元+1500积分',
-                            value: '150',
-                            sales: 15,
-                            image: 'https://test.baoxianzhanggui.com/nightFragrance/profile/upload/2025/01/03/b43f6087c815cdab8828eb68529d96bc73203b941ab71e-xrpfmn_fw1200webp_20250103175413A002.png'
+                            name: '广誉源会员定制玻璃杯3',
+                            pricePoint: '10元+1000积分',
+                            priceMoney: '100',
+                            sales: 10,
+                            productMainImage: 'https://test.baoxianzhanggui.com/nightFragrance/profile/upload/2025/01/03/b43f6087c815cdab8828eb68529d96bc73203b941ab71e-xrpfmn_fw1200webp_20250103175413A002.png'
                         },
                         {
                             id: 4,
-                            name: '广誉源会员定制笔记本',
-                            price: '5元+500积分',
-                            value: '50',
-                            sales: 5,
-                            image: 'https://test.baoxianzhanggui.com/nightFragrance/profile/upload/2025/01/03/b43f6087c815cdab8828eb68529d96bc73203b941ab71e-xrpfmn_fw1200webp_20250103175413A002.png'
-                        },
-                        {
-                            id: 6,
                             name: '广誉源会员定制玻璃杯',
-                            price: '10元+1000积分',
-                            value: '100',
+                            pricePoint: '10元+1000积分',
+                            priceMoney: '100',
                             sales: 10,
-                            image: 'https://test.baoxianzhanggui.com/nightFragrance/profile/upload/2025/01/03/b43f6087c815cdab8828eb68529d96bc73203b941ab71e-xrpfmn_fw1200webp_20250103175413A002.png'
+                            productMainImage: 'https://test.baoxianzhanggui.com/nightFragrance/profile/upload/2025/01/03/b43f6087c815cdab8828eb68529d96bc73203b941ab71e-xrpfmn_fw1200webp_20250103175413A002.png'
                         },
                         {
-                            id: 7,
-                            name: '广誉源会员定制保温杯',
-                            price: '20元+2000积分',
-                            value: '200',
-                            sales: 20,
-                            image: 'https://test.baoxianzhanggui.com/nightFragrance/profile/upload/2025/01/03/b43f6087c815cdab8828eb68529d96bc73203b941ab71e-xrpfmn_fw1200webp_20250103175413A002.png'
-                        },
-                        {
-                            id: 8,
-                            name: '广誉源会员定制雨伞',
-                            price: '15元+1500积分',
-                            value: '150',
-                            sales: 15,
-                            image: 'https://test.baoxianzhanggui.com/nightFragrance/profile/upload/2025/01/03/b43f6087c815cdab8828eb68529d96bc73203b941ab71e-xrpfmn_fw1200webp_20250103175413A002.png'
+                            id: 5,
+                            name: '广誉源会员定制玻璃杯',
+                            pricePoint: '10元+1000积分',
+                            priceMoney: '100',
+                            sales: 10,
+                            productMainImage: 'https://test.baoxianzhanggui.com/nightFragrance/profile/upload/2025/01/03/b43f6087c815cdab8828eb68529d96bc73203b941ab71e-xrpfmn_fw1200webp_20250103175413A002.png'
                         },
-                        {
-                            id: 9,
-                            name: '广誉源会员定制笔记本',
-                            price: '5元+500积分',
-                            value: '50',
-                            sales: 5,
-                            image: 'https://test.baoxianzhanggui.com/nightFragrance/profile/upload/2025/01/03/b43f6087c815cdab8828eb68529d96bc73203b941ab71e-xrpfmn_fw1200webp_20250103175413A002.png'
-                        }
                     ],
-                    total: 9,
-                    page: data.page || 1,
-                    pageSize: data.pageSize || 10
+                    "total": 2,
+                    "size": 10,
+                    "current": 1,
+                    "orders": [],
+                    "optimizeCountSql": true,
+                    "searchCount": true,
+                    "countId": null,
+                    "maxLimit": null,
+                    "pages": 1
                 }
-            };
+            }
             resolve(mockData);
         }, 800);
     });

+ 2 - 2
src/common/config.js

@@ -4,8 +4,8 @@ const h5Url = '/nightFragrance/#';
 const staticUrl = 'https://life.baoxianzhanggui.com/pro-img/nightFragrance';
 
 // 正式环境
-// let baseUrl = 'https://test.baoxianzhanggui.com/nightFragrance';
-let baseUrl = 'http://192.168.0.49:8087'
+let baseUrl = 'https://test.baoxianzhanggui.com/nightFragrance';
+//let baseUrl = 'http://192.168.0.49:8087'
 // let baseUrl = 'https://8c55-171-118-90-51.ngrok-free.app'
 
 if (process.env.NODE_ENV == 'development') {

+ 60 - 59
src/points/components/product-list/product-list.vue

@@ -1,62 +1,63 @@
 <template>
   <view class="product-list-container">
     <u-sticky bgColor="#ffffff">
-    <!-- 商品列表头部 -->
-    <view class="product-header">
-      <view class="title-text" :class="{ 'hide': isSticky }"><text>精选好物</text>兑换</view>
-      <u-search placeholder="搜索" v-model="keyword" :showAction="false" :class="{ 'expand': isSticky }"></u-search>
-    </view>
+      <!-- 商品列表头部 -->
+      <view class="product-header">
+        <view class="title-text" :class="{ 'hide': isSticky }"><text>精选好物</text>兑换</view>
+        <u-search placeholder="搜索" v-model="keyword" :showAction="false" :class="{ 'expand': isSticky }"></u-search>
+      </view>
     
-    <!-- 分类标签 -->
-    <u-tabs 
-      :list="categories" 
-      :current="activeCategoryIndex"
-      @change="handleCategoryChange"
-      lineWidth="30"
-      lineColor="#20CAC2"
-      :activeStyle="{
-            color: '#303133',
-            fontWeight: 'bold',
-            transform: 'scale(1.05)'
-        }"
-      :inactiveStyle="{
-            color: '#606266',
-            transform: 'scale(1)'
-        }"
-      itemStyle="padding:0 43rpx; height: 72rpx;font-size:28rpx"
-      class="category-tabs"
-    ></u-tabs>
+      <!-- 分类标签 -->
+      <u-tabs
+        :list="categories"
+        :current="activeCategoryIndex"
+        @change="handleCategoryChange"
+        lineWidth="30"
+        :scrollable="categories.length > 5 ? true : false"
+        lineColor="#20CAC2"
+        :activeStyle="{
+              color: '#303133',
+              fontWeight: 'bold',
+              transform: 'scale(1.05)'
+          }"
+        :inactiveStyle="{
+              color: '#606266',
+              transform: 'scale(1)'
+          }"
+        itemStyle="padding:0 43rpx; height: 72rpx;font-size:28rpx"
+        class="category-tabs"
+      ></u-tabs>
     
-    <!-- 排序选项 -->
-    <view class="sort-options">
-      <view 
-        v-for="(sort, index) in sortOptions" 
-        :key="index"
-        class="sort-option"
-        @click="switchSort(sort.key)"
-      >
-        <text :class="['sort-text', { active: activeSort === sort.key }]">{{ sort.name }}</text>
-        <view v-if="['price','sales'].includes(sort.key)" style="margin-top: -8rpx;">
-          <ImageItem src="/static/points/arrow-up.png" v-if="activeSort === sort.key && sortDirection === 'asc'"></ImageItem>
-          <ImageItem src="/static/points/arrow-down.png" v-else-if="activeSort === sort.key && sortDirection === 'desc'"></ImageItem>
-          <ImageItem src="/static/points/details.png" v-else></ImageItem>
+      <!-- 排序选项 -->
+      <view class="sort-options">
+        <view
+          v-for="(sort, index) in sortOptions"
+          :key="index"
+          class="sort-option"
+          @click="switchSort(sort.key)"
+        >
+          <text :class="['sort-text', { active: activeSort === sort.key }]">{{ sort.name }}</text>
+          <view v-if="['price','sales'].includes(sort.key)" style="margin-top: -8rpx;">
+            <ImageItem src="/static/points/arrow-up.png" v-if="activeSort === sort.key && sortDirection === 'asc'"></ImageItem>
+            <ImageItem src="/static/points/arrow-down.png" v-else-if="activeSort === sort.key && sortDirection === 'desc'"></ImageItem>
+            <ImageItem src="/static/points/details.png" v-else></ImageItem>
+          </view>
         </view>
       </view>
-    </view>
     </u-sticky>
     <!-- 商品列表 -->
     <u-loading-icon text="加载中" textSize="18" v-if="status === 'loading' && products.length <= 0" style="margin-top: 200rpx;"/>
     <view class="product-grid" v-else-if="products.length > 0">
       <view class="product-item" v-for="(product, index) in products" :key="index">
         <view class="product-image">
-          <ImageItem :src="product.image" mode="aspectFill"/>
+          <ImageItem :src="product.productMainImage" mode="aspectFill"/>
         </view>
         <view class="product-info">
           <u--text class="product-name" :lines="1" :text="product.name"></u--text>
-          <text class="product-price">{{ product.price }}</text>
+          <text class="product-price">{{ product.pricePoint }}</text>
           <view class="product-details">
             <view class="product-detail">
-              <text class="product-value">价值{{ product.value }}元</text>
+              <text class="product-value">价值{{ product.priceMoney }}元</text>
               <text class="product-sales">销量{{ product.sales }}</text>
             </view>
             <button class="exchange-btn" @click="handleExchange(product)">
@@ -93,21 +94,14 @@ export default {
       // 搜索关键词
       keyword: '',
       // 分类数据
-      categories: [
-        { key: 'all', name: '全部' },
-        { key: 'leisure', name: '休闲' },
-        { key: 'entertainment', name: '娱乐' },
-        { key: 'daily', name: '日用品' },
-        { key: 'other', name: '其他' }
-      ],
+      activeCategory: 'all',
+      categories: [],
       // 排序选项
       sortOptions: [
         { key: '综合', name: '综合' },
         { key: 'price', name: '价格' },
         { key: 'sales', name: '销量' }
       ],
-      // 当前选中的分类和排序
-      activeCategory: 'all',
       activeSort: '综合',
       sortDirection: '',
       // 商品数据
@@ -140,8 +134,18 @@ export default {
   },
   methods: {
     //获取分类
-    getTypeShop(){
-      const res = getShopType();
+    async getTypeShop() {
+      const res = await getShopType();
+      const {data} = res.data;
+      this.categories = [
+        { key: 'all', name: '全部' },
+          ...data.map(item => {
+            return {
+              name:item.childName,
+              key:item.childCode
+            }
+          })
+      ]
     },
     // 获取吸顶元素的初始位置
     getStickyTop() {
@@ -166,10 +170,9 @@ export default {
     loadData() {
       this.status = 'loading'
       this.fetchProducts(1).then(res => {
-        console.log(res)
         if (res.code === 200) {
-          this.products = res.data.list
-          this.hasMore = res.data.list.length === this.pageSize
+          this.products = res.data.records
+          this.hasMore = res.data.records.length === this.pageSize
           this.status = this.hasMore ? 'more' : 'nomore'
         } else {
           this.status = 'error'
@@ -221,13 +224,11 @@ export default {
     // 加载更多
     loadMore() {
       if (this.status === 'loading' || !this.hasMore) return
-      
       this.status = 'loading'
       this.page++
-      
       this.fetchProducts(this.page).then(res => {
         if (res.code === 200) {
-          const newProducts = res.data.list
+          const newProducts = res.data.records
           this.products = [...this.products, ...newProducts]
           this.hasMore = newProducts.length === this.pageSize
           this.status = this.hasMore ? 'more' : 'nomore'
@@ -255,7 +256,7 @@ export default {
   border-radius: 20rpx 20rpx 0 0;
   padding-bottom: 32rpx;
   margin-top: -20rpx;
-  overflow: hidden;
+  overflow: clip;
   .product-header {
     display: flex;
     justify-content: space-between;

+ 5 - 4
src/points/pointInfo/billPage.vue

@@ -150,16 +150,17 @@ export default {
           pageSize: this.pageSize,
           opType: this.activeTab
         })
-        if (res.code === 200) {
+        const {data} = res;
+        if (data.code === 200) {
           if (isLoadMore) {
             // 加载更多数据
-            this.pointRecords = [...this.pointRecords, ...res.rows]
+            this.pointRecords = [...this.pointRecords, ...data.data.records]
           } else {
             // 初始加载数据
-            this.pointRecords = res.rows
+            this.pointRecords = data.data.records
           }
           // 判断是否还有更多数据
-          this.hasMore = this.pointRecords.length < res.total
+          this.hasMore = this.pointRecords.length < data.data.total
         }
       } catch (error) {
         console.error('获取积分明细失败:', error)

+ 14 - 7
src/points/pointInfo/taskList.vue

@@ -15,7 +15,7 @@
         <text class="points-value">{{ completedTask }}</text>
         <text class="points-label">已完成任务</text>
       </view>
-      <view class="points-item">
+      <view class="points-item" @click="handleServiceTask">
         <text class="points-value">{{ pendingTasks }}</text>
         <text class="points-label">待完成任务</text>
       </view>
@@ -100,6 +100,7 @@
 import ImageItem from "@/components/swiper/components/image.vue";
 import { mapState } from 'vuex';
 import {getPointTaskList} from '@/api/points'
+import { handleServiceShare } from '@/utils/share'
 export default {
   name: "taskList",
   components: {ImageItem},
@@ -182,7 +183,6 @@ export default {
     // 处理任务
     handleTask(task) {
       if (task.completedCount >= task.triggerValue) return;
-
       if (task.taskName.includes('订单')) {
         this.taskConfig.order.action();
       } else if (task.taskName.includes('商户')) {
@@ -215,7 +215,13 @@ export default {
     },
     // 处理服务号任务
     handleServiceTask() {
-      // 服务号任务处理逻辑
+      // 调用微信服务号分享功能
+      handleServiceShare({
+        title: '广誉远 - 关注服务号',
+        desc: '关注广誉远服务号,获取更多积分和优惠',
+        link: window.location.href,
+        imgUrl: '/static/points/task_wx.png'
+      });
     },
     // 处理账号充值任务
     handleRechargeTask() {
@@ -240,13 +246,14 @@ export default {
           type: this.activeTab,
           cityCode: uni.getStorageSync('selectCitycode'),
         })
-        if (res.code === 200) {
+        const {data} = res;
+        if (data.code === 200) {
           if (isLoadMore) {
-            this.tasks = [...this.tasks, ...res.rows]
+            this.tasks = [...this.tasks, ...data.data.records]
           } else {
-            this.tasks = res.rows
+            this.tasks = data.data.records
           }
-          this.hasMore = this.tasks.length < res.total
+          this.hasMore = this.tasks.length < data.data.total
         }
         this.loading = false