Browse Source

首页和商品接口对接

viczhq 2 weeks ago
parent
commit
f194cd2199

File diff suppressed because it is too large
+ 483 - 365
package-lock.json


+ 11 - 3
project.private.config.json

@@ -2,20 +2,28 @@
2 2
   "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
3 3
   "projectname": "%E9%B1%BC%E5%B8%82",
4 4
   "setting": {
5
-    "compileHotReLoad": false
5
+    "compileHotReLoad": false,
6
+    "urlCheck": false
6 7
   },
7 8
   "libVersion": "3.6.4",
8 9
   "condition": {
9 10
     "miniprogram": {
10 11
       "list": [
11 12
         {
12
-          "name": "pages/infoEdit/index",
13
-          "pathName": "pages/productSub/infoEdit/index",
13
+          "name": "pages/memberSub/productManagement/index",
14
+          "pathName": "pages/memberSub/productManagement/index",
14 15
           "query": "",
15 16
           "launchMode": "default",
16 17
           "scene": null
17 18
         },
18 19
         {
20
+          "name": "pages/infoEdit/index",
21
+          "pathName": "pages/indexSub/productDetail/index",
22
+          "query": "id=100",
23
+          "launchMode": "default",
24
+          "scene": null
25
+        },
26
+        {
19 27
           "name": "pages/productManagement/index",
20 28
           "pathName": "pages/productManagement/index",
21 29
           "query": "",

+ 2 - 2
src/api/config.js

@@ -1,6 +1,6 @@
1 1
 // 配置请求对象
2 2
 // 本地调试 dev 开发阶段
3
-// export const baseUrl = "https://test-openai.fyshark.com";//测试
4
-export const baseUrl = "https://openai.fyshark.com";//正式
3
+export const baseUrl = "http://101.126.135.47:8000";//测试
4
+// export const baseUrl = "https://openai.fyshark.com";//正式
5 5
 
6 6
 

+ 65 - 40
src/api/request.js

@@ -1,47 +1,72 @@
1 1
 import Taro from '@tarojs/taro';
2
-import ttappid from '../../project.tt.json'//抖音
3
-import wxappid from '../../project.config.json'//微信
2
+import ttappid from '../../project.tt.json'; // 抖音
3
+import wxappid from '../../project.config.json'; // 微信
4 4
 import { baseUrl } from './config';
5 5
 
6
-
7
-export default (options = {
8
-  method: 'GET',
9
-  data: {}
10
-}) => {
11
-
12
-  // 必传参数
13
-  const request_data = {
14
-    session_key: Taro.getStorageSync('session_key') || ''//缓存取值
15
-  };
6
+const getAppId = () => {
16 7
   if (process.env.TARO_ENV === 'weapp') {
17
-    request_data['appid'] = wxappid.appid
8
+    return wxappid.appid;
18 9
   } else if (process.env.TARO_ENV === 'tt') {
19
-    request_data['appid'] = ttappid.appid
10
+    return ttappid.appid;
20 11
   }
21
-  return Taro.request({
22
-    url: baseUrl + options.url,
23
-    data: {
24
-      ...request_data,
25
-      ...options.data,
26
-    },
27
-    header: {
28
-      'Content-Type': 'application/json',
29
-      'accept': 'application/json'
30
-    },
31
-    method: options.method.toUpperCase(),
32
-  }).then(res => {
33
-    const {
34
-      code,
35
-      data
36
-    } = res;
37
-    if (code == 200) {
38
-      return data;
39
-    } else {
40
-      Taro.showToast({
41
-        title: `${res.msg}~`,
42
-        icon: 'none',
43
-        mask: true,
44
-      });
12
+  return '';
13
+};
14
+
15
+export default async (options = { method: 'GET', data: {} }) => {
16
+  const request_data = {
17
+    session_key: Taro.getStorageSync('session_key') || '', // 缓存取值
18
+    appid: getAppId(),
19
+  };
20
+
21
+  try {
22
+    const res = await Taro.request({
23
+      url: baseUrl + options.url,
24
+      data: {
25
+        ...request_data,
26
+        ...options.data,
27
+      },
28
+      header: {
29
+        'Content-Type': 'application/json',
30
+        accept: 'application/json',
31
+      },
32
+      method: options.method.toUpperCase(),
33
+    });
34
+
35
+    const { code, data, msg } = res.data;
36
+    switch (code) {
37
+      case 200:
38
+        return data;
39
+      case 400:
40
+        Taro.showToast({
41
+          title: '传参有误',
42
+          icon: 'none',
43
+          mask: true,
44
+        });
45
+        throw new Error('传参有误');
46
+      case 422:
47
+        Taro.showToast({
48
+          title: 'Validation Error',
49
+          icon: 'none',
50
+          mask: true,
51
+        });
52
+        throw new Error('Validation Error');
53
+      case 500:
54
+        Taro.showToast({
55
+          title: '需要登录',
56
+          icon: 'none',
57
+          mask: true,
58
+        });
59
+        throw new Error('需要登录');
60
+      default:
61
+        Taro.showToast({
62
+          title: `${msg || '请求失败'}`,
63
+          icon: 'none',
64
+          mask: true,
65
+        });
66
+        throw new Error(msg || '请求失败');
45 67
     }
46
-  });
47
-};
68
+  } catch (error) {
69
+    console.error('请求错误:', error);
70
+    return Promise.reject(error);
71
+  }
72
+};

+ 6 - 4
src/components/ProductCard/index.jsx

@@ -5,15 +5,17 @@ import './index.less'
5 5
 const ProductCard = ({ product }) => {
6 6
   return (
7 7
     <View onClick={() => Taro.navigateTo({ url: `/pages/indexSub/productDetail/index?id=${product.id}` })} className='product-card'>
8
-      <Image className='product-img' src={product.imageUrl} mode='widthFix' />
8
+      <Image className='product-img' src={product.image_url} mode='aspectFill' />
9 9
       <View className='product-content'>
10
-        <Text className='title'>{product.name}</Text>
10
+        <Text className='title'>{product.item_title}</Text>
11 11
         <View className='price-row'>
12 12
           <Text className='price'>
13 13
             <Text className='currency'>¥</Text>
14
-            {product.price}
14
+            {product.reserve_price}
15 15
           </Text>
16
-          <Text className='original-price'>¥{product.originalPrice}</Text>
16
+          {
17
+            product.original_price!='0.00'&&<Text className='original-price'>¥{product.original_price}</Text>
18
+          }
17 19
         </View>
18 20
       </View>
19 21
     </View>

+ 0 - 1
src/components/ProductCard/index.less

@@ -13,7 +13,6 @@
13 13
         .product-img {
14 14
             width: 100%;
15 15
             height: 324px;
16
-            background-color: red;
17 16
         }
18 17
 
19 18
         .product-content {

+ 3 - 2
src/components/index/CategoryList/index.jsx

@@ -1,13 +1,14 @@
1 1
 import { View, Image, Text } from "@tarojs/components";
2 2
 import "./index.less";
3 3
 
4
-const CategoryList = ({ categoryList }) => {
4
+const CategoryList = (props) => {
5
+  const { categoryList } = props; //分类列表引用
5 6
   return (
6 7
     <View className="category-wrap">
7 8
       <View className="category-list">
8 9
         {categoryList.map(item => (
9 10
           <View key={item.id} className="category-item">
10
-            <Image className="category-icon" src={item.icon} mode="aspectFit" />
11
+            <Image className="category-icon" src={item.img} mode="aspectFit" />
11 12
             <Text className="category-name">{item.name}</Text>
12 13
           </View>
13 14
         ))}

+ 1 - 1
src/components/index/CategoryList/index.less

@@ -10,7 +10,7 @@
10 10
     padding: 25px 17px 22px 17px;
11 11
     
12 12
     .category-item {
13
-      width: 20%;
13
+      width: 96px;
14 14
       display: flex;
15 15
       flex-direction: column;
16 16
       align-items: center;

+ 40 - 50
src/components/index/OperationArea/index.jsx

@@ -2,71 +2,61 @@ import { View, Text, Image } from "@tarojs/components";
2 2
 import Taro from "@tarojs/taro";
3 3
 import "./index.less";
4 4
 
5
-const OperationArea = () => {
6
-  // 模拟商品数据
7
-  const seckillProducts = [
8
-    {
9
-      id: 1,
10
-      name: "商品1",
11
-      price: 20.20,
12
-      originalPrice: 30.00,
13
-      image: "商品图片地址1"
14
-    },
15
-    {
16
-      id: 2,
17
-      name: "商品2",
18
-      price: 25.50,
19
-      originalPrice: 35.00,
20
-      image: "商品图片地址2"
21
-    },
22
-    {
23
-      id: 3,
24
-      name: "商品3",
25
-      price: 15.80,
26
-      originalPrice: 28.00,
27
-      image: "商品图片地址3"
28
-    }
29
-  ];
30
-
5
+const OperationArea = ({ recommend }) => {
31 6
   // 添加跳转方法
32 7
   const handleNavigate = (type) => {
33
-    if (type === 'seckill') {
8
+    if (type === "鱼市秒杀") {
34 9
       Taro.navigateTo({
35
-        url: '/pages/indexSub/seckillIndex/index'
10
+        url: "/pages/indexSub/seckillIndex/index",
36 11
       });
37
-    } else if (type === 'highCommission') {
38
-
12
+    } else if (type === "高佣专项") {
39 13
     }
40 14
   };
41 15
 
42 16
   return (
43
-    <View className="operation-wrap" >
44
-      <View className="operation-item" onClick={() => handleNavigate('seckill')}>
45
-        <View className="title">限时秒杀</View>
46
-        <View className="product-list">
47
-          {seckillProducts.map(product => (
48
-            <View key={product.id} className="product-item">
49
-              <Image className="product-img" src={product.image} mode="aspectFill" />
50
-              <View className="price-wrap">
51
-                <View className="current-price">
52
-                  <Text className="symbol">¥</Text>
53
-                  <Text className="number">{product.price.toFixed(2)}</Text>
17
+    <View className="operation-wrap">
18
+      {recommend.map((item, index) => (
19
+        <View
20
+          key={index}
21
+          className="operation-item"
22
+          onClick={() => handleNavigate(item.tag.name)}
23
+        >
24
+          <View className="title-wrap">
25
+            <Text className="title">{item.tag.name}</Text>
26
+            {/* <Text className="tag">高佣金必囤爆品</Text> */}
27
+          </View>
28
+          <View className="product-list">
29
+            {item.goods &&
30
+              item.goods.map((product, productIndex) => (
31
+                <View key={productIndex} className="product-item">
32
+                  <Image
33
+                    className="product-img"
34
+                    src={product.image_url}
35
+                    mode="aspectFill"
36
+                  />
37
+                  <View className="price-wrap">
38
+                    <View className="current-price">
39
+                      <Text className="symbol">¥</Text>
40
+                      <Text className="number">{product.reserve_price}</Text>
41
+                    </View>
42
+                    <Text className="original-price">
43
+                      ¥{product.original_price}
44
+                    </Text>
45
+                  </View>
54 46
                 </View>
55
-                <Text className="original-price">¥{product.originalPrice.toFixed(2)}</Text>
56
-              </View>
57
-            </View>
58
-          ))}
47
+              ))}
48
+          </View>
59 49
         </View>
60
-      </View>
61
-      <View className="operation-item" onClick={() => handleNavigate('highCommission')}>
50
+      ))}
51
+
52
+      {/* <View className="operation-item" onClick={() => handleNavigate('highCommission')}>
62 53
         <View className="title-wrap">
63 54
           <Text className="title">高佣专项</Text>
64 55
           <Text className="tag">高佣金必囤爆品</Text>
65 56
         </View>
66
-        {/* 这里可以添加高佣专项的具体内容 */}
67
-      </View>
57
+      </View> */}
68 58
     </View>
69 59
   );
70 60
 };
71 61
 
72
-export default OperationArea; 
62
+export default OperationArea;

+ 1 - 3
src/components/index/OperationArea/index.less

@@ -47,8 +47,7 @@
47 47
             justify-content: space-between;
48 48
 
49 49
             .product-item {
50
-                flex: 1;
51
-                margin-right: 10px;
50
+                width: 100px;
52 51
                 text-align: center;
53 52
 
54 53
                 &:last-child {
@@ -59,7 +58,6 @@
59 58
                     width: 100%;
60 59
                     height: 99px;
61 60
                     border-radius: 8px;
62
-                    background-color: red;
63 61
                 }
64 62
 
65 63
                 .price-wrap {

+ 97 - 62
src/components/index/ProductList/index.jsx

@@ -1,69 +1,55 @@
1
-import React, { useState, useEffect } from "react";
1
+import React, {
2
+  useState,
3
+  useEffect,
4
+  forwardRef,
5
+  useImperativeHandle,
6
+} from "react";
2 7
 import { View, Text, Image } from "@tarojs/components";
3
-import { AtCheckbox } from "taro-ui";
8
+import { AtCheckbox, AtActivityIndicator } from "taro-ui";
4 9
 import Taro from "@tarojs/taro";
5 10
 import "./index.less";
6 11
 import joinStoreBg from "../../../images/index/jionStore.png";
12
+import joinStoreAc from "../../../images/index/joinStoreAc.png";
7 13
 import saveMoneyBg from "../../../images/index/save-money.png";
8 14
 import shareEarnBg from "../../../images/index/share-earn.png";
9 15
 import seckillIcon from "../../../images/seckill/seckillIcon.png";
10
-const ProductList = (props) => {
11
-  const { isSeckill } = props; //是否是秒杀产品引用
12
-  const { isManagement } = props; //是否是管理产品引用
13
-  const { isManagementStatus } = props; //是否是管理状态引用
14
-  const { isProductClassify } = props; //是否是分类产品引用
15
-  const { isSelectAll } = props; //是否是全选
16
-  const [selectedProducts, setSelectedProducts] = useState([]); // 管理选中的商品列表
17
-  // 模拟商品数据
18
-  const products = [
19
-    {
20
-      id: 1,
21
-      image:
22
-        "https://img-s-msn-com.akamaized.net/tenant/amp/entityid/AA1saL6x.img?w=768&h=411&m=6",
23
-      name: "这是一个商品名称这是一个商品名称这是一个商品名称这是一个商品名称这是一个商品名称",
24
-      price: 99.99,
25
-      originalPrice: 199.99,
26
-      saveMoney: 10,
27
-      shareEarn: 20,
28
-    },
29
-    {
30
-      id: 2,
31
-      image:
32
-        "https://img-s-msn-com.akamaized.net/tenant/amp/entityid/AA1saL6x.img?w=768&h=411&m=6",
33
-      name: "这是一个商品名称这是一个商品名称这是一个商品名称这是一个商品名称这是一个商品名称",
34
-      price: 99.99,
35
-      originalPrice: 199.99,
36
-      saveMoney: 10,
37
-      shareEarn: 20,
38
-    },
39
-    {
40
-      id: 3,
41
-      image:
42
-        "https://img-s-msn-com.akamaized.net/tenant/amp/entityid/AA1saL6x.img?w=768&h=411&m=6",
43
-      name: "这是一个商品名称这是一个商品名称这是一个商品名称这是一个商品名称这是一个商品名称",
44
-      price: 99.99,
45
-      originalPrice: 199.99,
46
-      saveMoney: 10,
47
-      shareEarn: 20,
48
-    },
49
-  ];
16
+const ProductList = forwardRef((props, ref) => {
17
+  const {
18
+    productList, // 商品列表数据
19
+    loading, // 加载状态
20
+    isSeckill, // 是否秒杀
21
+    isManagement, // 是否管理
22
+    isManagementStatus, // 是否管理状态
23
+    isProductClassify, // 是否分类
24
+    isSelectAll, // 是否全选
25
+    onAddProduct, // 添加商品方法
26
+    onDeleteProductSelect, // 删除商品选中id数组
27
+  } = props;
28
+
29
+  const [selectedProducts, setSelectedProducts] = useState([]); // 商品选择状态
30
+
31
+  // 监听选中状态变化
32
+  useEffect(() => {
33
+    // 每当 selectedProducts 变化时,调用父组件的回调
34
+    onDeleteProductSelect && onDeleteProductSelect(selectedProducts);
35
+  }, [selectedProducts]);
36
+
50 37
   // 跳转产品详情
51 38
   const toDetail = (id) => {
52 39
     if (isManagementStatus) {
53 40
       selectProduct(id);
54
-    } else if (isProductClassify) {
55
-      return;
56 41
     } else {
57 42
       Taro.navigateTo({
58 43
         url: `/pages/indexSub/productDetail/index?id=${id}`,
59 44
       });
60 45
     }
61 46
   };
47
+
62 48
   // 监听 isSelectAll 的变化
63 49
   useEffect(() => {
64 50
     if (isSelectAll) {
65 51
       // 如果 isSelectAll 为 true,选中所有商品
66
-      setSelectedProducts(products.map((product) => product.id));
52
+      setSelectedProducts(productList.map((product) => product.id));
67 53
     } else {
68 54
       // 如果 isSelectAll 为 false,取消所有选中
69 55
       setSelectedProducts([]);
@@ -82,6 +68,16 @@ const ProductList = (props) => {
82 68
       }
83 69
     });
84 70
   };
71
+  // 添加商品
72
+  const addProduct = (productId, is_collected) => {
73
+    // 是否添加到我的商店(is_collected:为true已添加)
74
+    if(is_collected){
75
+      return;
76
+    }else{
77
+      // 调用父组件的方法
78
+      onAddProduct && onAddProduct(productId);
79
+    }
80
+  };
85 81
   return (
86 82
     <View className="product-list-wrap">
87 83
       {isSeckill && (
@@ -90,7 +86,7 @@ const ProductList = (props) => {
90 86
           <Text>每日疯抢 限时秒杀</Text>
91 87
         </View>
92 88
       )}
93
-      {products.map((product, index) => (
89
+      {productList.map((product, index) => (
94 90
         <View key={product.id}>
95 91
           <View onClick={() => toDetail(product.id)} className="product-item">
96 92
             {isManagement && isManagementStatus && (
@@ -103,7 +99,7 @@ const ProductList = (props) => {
103 99
             <View className="right">
104 100
               <Image
105 101
                 className="product-img"
106
-                src={product.image}
102
+                src={product.image_url}
107 103
                 mode="aspectFill"
108 104
               />
109 105
               <View className="product-info">
@@ -114,23 +110,39 @@ const ProductList = (props) => {
114 110
                   <Text className="self-tag">
115 111
                     {!isSeckill ? "自营" : "鱼市秒杀"}
116 112
                   </Text>
117
-                  {product.name}
113
+                  {product.item_title}
118 114
                 </View>
119 115
                 <View className="price-line">
120 116
                   <View className="price-info">
121 117
                     <Text className="symbol">¥</Text>
122
-                    <Text className="price">{product.price}</Text>
123
-                    <Text className="original-price">
124
-                      ¥{product.originalPrice}
125
-                    </Text>
118
+                    <Text className="price">{product.reserve_price}</Text>
119
+                    {product.original_price != "0.00" && (
120
+                      <Text className="original-price">
121
+                        ¥{product.original_price}
122
+                      </Text>
123
+                    )}
126 124
                   </View>
127 125
                   {!isSeckill && !isManagement && (
128
-                    <View className="add-btn">
129
-                      <Image
130
-                        className="join-store-bg"
131
-                        src={joinStoreBg}
132
-                        mode="aspectFit"
133
-                      />
126
+                    <View
127
+                      onClick={(e) => {
128
+                        e.stopPropagation();
129
+                        addProduct(product.id,product.is_collected);
130
+                      }}
131
+                      className="add-btn"
132
+                    >
133
+                      {product.is_collected ? (
134
+                        <Image
135
+                          className="join-store-bg"
136
+                          src={joinStoreBg}
137
+                          mode="aspectFit"
138
+                        />
139
+                      ) : (
140
+                        <Image
141
+                          className="join-store-bg"
142
+                          src={joinStoreAc}
143
+                          mode="aspectFit"
144
+                        />
145
+                      )}
134 146
                       <Text className="btn-text">加入小店</Text>
135 147
                     </View>
136 148
                   )}
@@ -140,29 +152,52 @@ const ProductList = (props) => {
140 152
                     <Image className="bg" src={saveMoneyBg} mode="aspectFit" />
141 153
                     <View className="content">
142 154
                       <Text className="label">自购省</Text>
143
-                      <Text className="money">¥{product.saveMoney}</Text>
155
+                      <Text className="money">
156
+                        ¥{product.estimated_commission}
157
+                      </Text>
144 158
                     </View>
145 159
                   </View>
146 160
                   <View className="share-earn">
147 161
                     <Image className="bg" src={shareEarnBg} mode="aspectFit" />
148 162
                     <View className="content">
149 163
                       <Text className="label">分享赚</Text>
150
-                      <Text className="money">¥{product.shareEarn}</Text>
164
+                      <Text className="money">
165
+                        ¥{product.estimated_commission}
166
+                      </Text>
151 167
                     </View>
152 168
                   </View>
153 169
                 </View>
154 170
               </View>
155 171
             </View>
156 172
           </View>
157
-          {index !== products.length - 1 && <View className="divider"></View>}
173
+          {index !== productList.length - 1 && (
174
+            <View className="divider"></View>
175
+          )}
158 176
         </View>
159 177
       ))}
178
+      {loading && (
179
+        <View className="loading">
180
+          <AtActivityIndicator
181
+            isOpened={loading}
182
+            mode="center"
183
+            color="#fdf764"
184
+          />
185
+        </View>
186
+      )}
160 187
     </View>
161 188
   );
162
-};
189
+});
163 190
 
164 191
 ProductList.defaultProps = {
165 192
   isSeckill: false,
193
+  productList: [],
194
+  loading: false,
195
+  isManagement: false,
196
+  isManagementStatus: false,
197
+  isProductClassify: false,
198
+  isSelectAll: false,
199
+  onAddProduct: () => {}, // 添加商品方法
200
+  onDeleteProductSelect: () => {}, // 删除商品选中id数组
166 201
 };
167 202
 
168 203
 export default ProductList;

+ 6 - 1
src/components/index/ProductList/index.less

@@ -189,4 +189,9 @@
189 189
       margin-right: 10px;
190 190
     }
191 191
   }
192
-}
192
+  .loading{
193
+    width: 100%;
194
+    position: relative;
195
+    height: 60px;  
196
+  }
197
+}

BIN
src/images/mine/avatar.png


+ 107 - 71
src/pages/index/index.jsx

@@ -2,6 +2,7 @@ import Taro from "@tarojs/taro"; // 导入 Taro
2 2
 import { Component } from "react";
3 3
 import { View, Image, Swiper, SwiperItem, Text } from "@tarojs/components";
4 4
 import { AtTabs } from "taro-ui";
5
+import { getHomeData,getProductList } from "../../service";
5 6
 import "./index.less";
6 7
 import SearchBar from "../../components/index/SearchBar"; //搜索框
7 8
 import CategoryList from "../../components/index/CategoryList"; //分类列表
@@ -15,6 +16,7 @@ export default class Index extends Component {
15 16
   state = {
16 17
     value: "",
17 18
     current: 0, // 添加当前选中的tab索引
19
+    homeData: {}, // 首页数据
18 20
     tabList: [
19 21
       // 添加模拟的tab数据
20 22
       { title: "推荐" },
@@ -28,50 +30,48 @@ export default class Index extends Component {
28 30
       { title: "食品" },
29 31
       { title: "母婴" },
30 32
     ],
31
-    bannerList: [
32
-      {
33
-        id: 1,
34
-        img: "https://img-s-msn-com.akamaized.net/tenant/amp/entityid/AA1saL6x.img?w=768&h=411&m=6",
35
-      },
36
-      {
37
-        id: 2,
38
-        img: "https://img-s-msn-com.akamaized.net/tenant/amp/entityid/AA1saL6x.img?w=768&h=411&m=6",
39
-      },
40
-      {
41
-        id: 3,
42
-        img: "https://img-s-msn-com.akamaized.net/tenant/amp/entityid/AA1saL6x.img?w=768&h=411&m=6",
43
-      },
44
-    ],
45
-    categoryList: [
46
-      { id: 1, icon: "购物袋图标URL", name: "超市" },
47
-      { id: 2, icon: "手机图标URL", name: "数码" },
48
-      { id: 3, icon: "衣服图标URL", name: "服饰" },
49
-      { id: 4, icon: "生鲜图标URL", name: "生鲜" },
50
-      { id: 5, icon: "美妆图标URL", name: "美妆" },
51
-      { id: 6, icon: "家电图标URL", name: "家电" },
52
-      { id: 7, icon: "餐具图标URL", name: "餐厨" },
53
-      { id: 8, icon: "书本图标URL", name: "图书" },
54
-      { id: 9, icon: "药品图标URL", name: "医药" },
55
-      { id: 10, icon: "更多图标URL", name: "更多" },
56
-    ],
33
+    bannerList: [],
34
+    productList: [], // 添加商品列表
35
+    page: 1,         // 添加页码
36
+    totalPages: 1,   // 添加总页数
37
+    loading: false   // 添加加载状态
57 38
   };
58
-
39
+  // 获取首页数据
40
+  getHomeData = async () => {
41
+    const res = await getHomeData();
42
+    res.tags = res.tags.split(",").map((title) => ({ title }));
43
+    this.setState({ homeData: res });
44
+  };
45
+  // 搜索框值改变
59 46
   handleChange(value) {
60 47
     this.setState({ value });
61 48
   }
62
-  // 添加tab切换处理函数
49
+  // 修改 tab 切换处理函数
63 50
   handleClick(value) {
64 51
     this.setState({
65 52
       current: value,
53
+    }, () => {
54
+      // 跳转到列表顶部
55
+      Taro.createSelectorQuery()
56
+      .select('.product-list-wrap') 
57
+      .boundingClientRect()
58
+      .exec(res => {
59
+        if (res[0]) {
60
+          const top = res[0].top;
61
+          Taro.pageScrollTo({
62
+            scrollTop: top-40, 
63
+            duration: 300  
64
+          });
65
+        } else {
66
+          console.warn('未找到 .product-list-wrap 元素');
67
+        }
68
+      });
66 69
     });
67 70
   }
68
-  componentDidMount() {}
69
-
70
-  componentWillUnmount() {}
71
-
72
-  componentDidShow() {}
73
-
74
-  componentDidHide() {}
71
+  componentDidShow() {
72
+    this.getHomeData(); //获取首页数据
73
+    this.getProductList(true); //获取商品列表
74
+  }
75 75
 
76 76
   // 添加回到顶部方法
77 77
   handleBackTop = () => {
@@ -81,15 +81,46 @@ export default class Index extends Component {
81 81
     });
82 82
   };
83 83
 
84
+  // 页面上拉触底
85
+  onReachBottom = () => {
86
+    const { page, totalPages, loading } = this.state;
87
+    if (page < totalPages && !loading) {
88
+      this.setState(
89
+        prevState => ({ page: prevState.page + 1 }),
90
+        () => this.getProductList()
91
+      );
92
+    }
93
+  };
94
+
95
+  // 获取商品列表
96
+  getProductList = async (isRefresh) => {
97
+    const { page } = this.state;
98
+    this.setState({ loading: true });
99
+    
100
+    const res = await getProductList({
101
+      tag_name: "",
102
+      page,
103
+      page_size: 10,
104
+    });
105
+
106
+    this.setState(prevState => ({
107
+      productList: isRefresh ? res.goods_list : [...prevState.productList, ...res.goods_list],
108
+      totalPages: res.total_pages,
109
+      loading: false
110
+    }));
111
+  };
112
+
84 113
   render() {
114
+    const { homeData, productList, loading } = this.state;
85 115
     return (
86 116
       <View className="index">
87 117
         <View
88 118
           className="header"
89
-          style={{ paddingTop: Taro.navigationBarHeight  + "px" }}
119
+          style={{ paddingTop: Taro.navigationBarHeight + "px" }}
90 120
         >
91 121
           <View className="header-content">
92 122
             <Image
123
+              mode="heightFix"
93 124
               className="header-img"
94 125
               src="https://video-img.fyshark.com/1731495433480WechatIMG674.jpg"
95 126
             />
@@ -102,12 +133,15 @@ export default class Index extends Component {
102 133
           />
103 134
           {/* tab分类 */}
104 135
           <View className="tabs-list">
105
-            <AtTabs
106
-              current={this.state.current}
107
-              scroll
108
-              tabList={this.state.tabList}
109
-              onClick={this.handleClick.bind(this)}
110
-            />
136
+            {homeData.tags && (
137
+              <AtTabs
138
+                current={this.state.current}
139
+                scroll
140
+                tabList={homeData.tags}
141
+                onClick={this.handleClick.bind(this)}
142
+              />
143
+            )}
144
+
111 145
             <View className="tab-more">
112 146
               <Image className="tab-more-img" />
113 147
             </View>
@@ -122,49 +156,51 @@ export default class Index extends Component {
122 156
               indicatorColor="#e8e8e8"
123 157
               indicatorActiveColor="#ffffff"
124 158
             >
125
-              {this.state.bannerList.map((item) => (
126
-                <SwiperItem className="banner-item" key={item.id}>
127
-                  <Image
128
-                    className="banner-img"
129
-                    src={item.img}
130
-                    mode="aspectFill"
131
-                  />
132
-                </SwiperItem>
133
-              ))}
159
+              {homeData.banner &&
160
+                homeData.banner.map((item) => (
161
+                  <SwiperItem className="banner-item" key={item.id}>
162
+                    <Image
163
+                      className="banner-img"
164
+                      src={item.img}
165
+                      mode="aspectFill"
166
+                    />
167
+                  </SwiperItem>
168
+                ))}
134 169
             </Swiper>
135 170
           </View>
136 171
         </View>
137 172
         {/* 分类列表组件 */}
138
-        <CategoryList categoryList={this.state.categoryList} />
173
+        {homeData.icon && <CategoryList categoryList={homeData.icon} />}
139 174
         {/* 运营区域 */}
140
-        <OperationArea />
175
+        {homeData.recommend && <OperationArea recommend={homeData.recommend} />}
141 176
         {/* 邀请人推荐 */}
142
-        <RecommendList />
177
+        {/* <RecommendList /> */}
143 178
         {/* 商品列表 */}
144
-        <ProductList />
145
-
179
+        <View className="product-list-wrap">
180
+          <ProductList
181
+          productList={productList}
182
+            loading={loading}
183
+          />
184
+          <ProductList
185
+          productList={productList}
186
+            loading={loading}
187
+          />
188
+        </View>
146 189
         {/* 添加浮动按钮 */}
147 190
         <View className="float-buttons">
148 191
           <View
149 192
             className="float-btn"
150
-            onClick={()=>Taro.navigateTo({url:"/pages/memberSub/storeManagement/index"})}
193
+            onClick={() =>
194
+              Taro.navigateTo({
195
+                url: `/pages/memberSub/storeManagement/index?isManager=${true}`,
196
+              })
197
+            }
151 198
           >
152
-            <Image
153
-              className="my-shop-bg"
154
-              src={myStoreIcon}
155
-              mode="aspectFit"
156
-            />
199
+            <Image className="my-shop-bg" src={myStoreIcon} mode="aspectFit" />
157 200
             <Text>我的{"\n"}小店</Text>
158 201
           </View>
159
-          <View
160
-            className="float-btn"
161
-            onClick={this.handleBackTop}
162
-          >
163
-            <Image
164
-              className="back-top"
165
-              src={backTopIcon}
166
-              mode="aspectFit"
167
-            />
202
+          <View className="float-btn" onClick={this.handleBackTop}>
203
+            <Image className="back-top" src={backTopIcon} mode="aspectFit" />
168 204
           </View>
169 205
         </View>
170 206
       </View>

+ 4 - 1
src/pages/index/index.less

@@ -40,7 +40,7 @@
40 40
       margin-top: 24px;
41 41
       display: flex;
42 42
       height: 40px;
43
-
43
+      overflow: hidden;
44 44
       .tab-more {
45 45
         width: 90px;
46 46
         display: flex;
@@ -60,6 +60,9 @@
60 60
         height: 100%;
61 61
         text-align: left;
62 62
       }
63
+      .at-tabs__header::-webkit-scrollbar {
64
+        display: none; /* 隐藏滚动条 */
65
+      }
63 66
 
64 67
       .at-tabs__item {
65 68
         color: #000;

+ 50 - 50
src/pages/indexSub/productDetail/index.jsx

@@ -1,6 +1,7 @@
1 1
 import { Component } from "react";
2 2
 import { View, Text, Swiper, SwiperItem, Image } from "@tarojs/components";
3 3
 import { AtIcon } from "taro-ui";
4
+import { getProductDetail, getProductLikeList } from "../../../service";
4 5
 import "./index.less";
5 6
 import Taro from "@tarojs/taro";
6 7
 import productDetailIcon from "../../../images/productDetail/productDetailIcon.png";
@@ -15,47 +16,30 @@ export default class Index extends Component {
15 16
   state = {
16 17
     isShare: false, //是否是分享
17 18
     isOpened: false, //是否打开弹窗
18
-    productList: [
19
-      {
20
-        id: 1,
21
-        name: "青岛大虾",
22
-        price: 99.9,
23
-        originalPrice: 159.9,
24
-        image: "https://example.com/img1.jpg",
25
-        sales: 1234,
26
-        tag: "热销",
27
-      },
28
-      {
29
-        id: 2,
30
-        name: "三文鱼刺身",
31
-        price: 158,
32
-        originalPrice: 198,
33
-        image: "https://example.com/img2.jpg",
34
-        sales: 856,
35
-        tag: "新品",
36
-      },
37
-      {
38
-        id: 3,
39
-        name: "帝王蟹",
40
-        price: 299,
41
-        originalPrice: 399,
42
-        image: "https://example.com/img3.jpg",
43
-        sales: 566,
44
-        tag: "限时",
45
-      },
46
-    ],
19
+    productDetail: [], //商品详情
20
+    productLikeList:[],//推荐商品列表
47 21
   };
48
-
49
-  componentWillMount() {}
50
-
51
-  componentDidMount() {}
52
-
53
-  componentWillUnmount() {}
54
-
55
-  componentDidShow() {}
56
-
57
-  componentDidHide() {}
58
-
22
+  // 获取产品详情的方法
23
+  fetchProductDetails = async (id) => {
24
+    const res = await getProductDetail({
25
+      goods_id: id,
26
+    });
27
+    this.setState({
28
+      productDetail: res,
29
+    });
30
+  };
31
+  // 获取猜你喜欢列表
32
+  getProductLikeList = async () => {
33
+    const res = await getProductLikeList();
34
+    this.setState({
35
+      productLikeList:res
36
+    })
37
+  };
38
+  componentDidMount() {
39
+    const { id } = Taro.getCurrentInstance().router.params;
40
+    this.fetchProductDetails(id); //获取产品详情
41
+    this.getProductLikeList(); //获取猜你喜欢列表
42
+  }
59 43
   // 复制商品编号
60 44
   handleCopy = (text) => {
61 45
     Taro.setClipboardData({
@@ -94,6 +78,7 @@ export default class Index extends Component {
94 78
   };
95 79
 
96 80
   render() {
81
+    const { productDetail } = this.state;
97 82
     return (
98 83
       <View
99 84
         className="index"
@@ -106,10 +91,16 @@ export default class Index extends Component {
106 91
         )}
107 92
         {/* 轮播图 */}
108 93
         <Swiper className="swiper" autoplay circular>
109
-          <SwiperItem>
110
-            <Image className="swiper-img" src="图片地址1" mode="aspectFill" />
111
-          </SwiperItem>
112
-          {/* 可以添加更多 SwiperItem */}
94
+          {productDetail.images &&
95
+            productDetail.images.map((imageObj, index) => (
96
+              <SwiperItem key={index}>
97
+                <Image
98
+                  className="swiper-img"
99
+                  src={imageObj.img}
100
+                  mode="aspectFill"
101
+                />
102
+              </SwiperItem>
103
+            ))}
113 104
         </Swiper>
114 105
 
115 106
         {/* 商品详情模块 */}
@@ -117,7 +108,7 @@ export default class Index extends Component {
117 108
           {/* 商品名称 */}
118 109
           <Text className="product-name">
119 110
             <Text className="self-tag">自营</Text>
120
-            商品名称
111
+            {productDetail.item_title}
121 112
           </Text>
122 113
 
123 114
           {/* 价格和标签行 */}
@@ -126,13 +117,19 @@ export default class Index extends Component {
126 117
             <View className="price-box">
127 118
               <Text className="current-price">
128 119
                 <Text className="currency">¥</Text>
129
-                299
120
+                {productDetail.reserve_price}
130 121
               </Text>
131
-              <Text className="original-price">¥399</Text>
122
+              {productDetail.original_price != "0.00" && (
123
+                <Text className="original-price">
124
+                  ¥{productDetail.original_price}
125
+                </Text>
126
+              )}
132 127
             </View>
133 128
             {/* 标签区域 */}
134 129
             <View className="tag-box">
135
-              <Text className="tag">分享赚¥1.51</Text>
130
+              <Text className="tag">
131
+                分享赚¥{productDetail.estimated_commission}
132
+              </Text>
136 133
             </View>
137 134
           </View>
138 135
 
@@ -172,7 +169,7 @@ export default class Index extends Component {
172 169
         </View>
173 170
         {/* 猜你喜欢产品列表 */}
174 171
         <View className="product-card-list">
175
-          {this.state.productList.map((product) => (
172
+          {this.state.productLikeList.map((product) => (
176 173
             <ProductCard key={product.id} product={product} />
177 174
           ))}
178 175
         </View>
@@ -189,7 +186,10 @@ export default class Index extends Component {
189 186
                   <Image src={share} mode="aspectFit" />
190 187
                   <Text className="bottom-buy-text">分享赚</Text>
191 188
                 </View>
192
-                <View className="bottom-buy-right-share">
189
+                <View
190
+                  onClick={this.handleBuy}
191
+                  className="bottom-buy-right-share"
192
+                >
193 193
                   <Image src={selfBuy} mode="aspectFit" />
194 194
                   <Text className="bottom-buy-text">自购省</Text>
195 195
                 </View>

+ 0 - 1
src/pages/indexSub/productDetail/index.less

@@ -6,7 +6,6 @@
6 6
     .swiper {
7 7
         width: 100%;
8 8
         height: 730px;
9
-        background-color: red;
10 9
         .swiper-img {
11 10
             width: 100%;
12 11
             height: 100%;

+ 27 - 21
src/pages/member/index.jsx

@@ -1,6 +1,7 @@
1 1
 import { Component } from "react";
2 2
 import { View, Text, Image } from "@tarojs/components";
3 3
 import { AtIcon } from "taro-ui";
4
+import {getVipInfo} from '../../service'
4 5
 import Taro from "@tarojs/taro";
5 6
 import "./index.less";
6 7
 import vip from "../../images/member/vip.png";
@@ -10,17 +11,22 @@ import warning from "../../images/member/warning.png";
10 11
 import withdrawable from "../../images/member/withdrawable.png";
11 12
 import order from "../../images/member/order.png";
12 13
 export default class Index extends Component {
13
-  componentWillMount() {}
14
-
15
-  componentDidMount() {}
16
-
17
-  componentWillUnmount() {}
18
-
19
-  componentDidShow() {}
20
-
21
-  componentDidHide() {}
14
+  state={
15
+    vipInfo:{},//会员信息 
16
+  }
17
+  // 获取会员首页数据
18
+  getVipInfo = async () =>{
19
+    const res = await getVipInfo()
20
+    this.setState({
21
+      vipInfo:res
22
+    })
23
+  }
24
+  componentDidShow() {
25
+    this.getVipInfo() //获取会员首页数据
26
+  }
22 27
 
23 28
   render() {
29
+    const {vipInfo} = this.state
24 30
     return (
25 31
       <View className="member">
26 32
         <View className="member-bg"></View>
@@ -28,9 +34,9 @@ export default class Index extends Component {
28 34
           {/* 会员信息卡 */}
29 35
           <View className="member-info-card">
30 36
             <View className="member-info-card-header">
31
-              <Image className="avatar" src="" />
37
+              {vipInfo.users && <Image className="avatar" src={vipInfo.users.icon} mode="aspectFill" />}
32 38
               <View className="member-info-card-header-text">
33
-                <Text className="user-name">会员</Text>
39
+                {vipInfo.users && <Text className="user-name">{vipInfo.users.channel_name}</Text>}
34 40
                 <View className="member-info-card-header-text-level">
35 41
                   <Text className="level-text">店长</Text>
36 42
                   <Image className="level-icon" src={vip} />
@@ -44,16 +50,16 @@ export default class Index extends Component {
44 50
             </View>
45 51
           </View>
46 52
           {/* 预估收益 */}
47
-          <View className="estimated-income">
53
+          {vipInfo.earnings && <View className="estimated-income">
48 54
             <Text className="estimated-income-title">预估收益</Text>
49 55
             <View className="estimated-income-content">
50 56
               <View className="income-item">
51
-                <Text className="amount">0.00</Text>
57
+                <Text className="amount">{vipInfo.earnings.store_earnings_now}</Text>
52 58
                 <Text className="label">今日预估收益</Text>
53 59
               </View>
54 60
               <View className="divider"></View>
55 61
               <View className="income-item">
56
-                <Text className="amount">0.00</Text>
62
+                <Text className="amount">{vipInfo.earnings.store_earnings_all}</Text>
57 63
                 <Text className="label">累计收益</Text>
58 64
               </View>
59 65
             </View>
@@ -61,7 +67,7 @@ export default class Index extends Component {
61 67
               收益详情
62 68
               <Image className="to-detail" src={toDetail} />
63 69
             </view>
64
-          </View>
70
+            </View>}
65 71
           {/* 可提现金额 */}
66 72
           <View className="withdrawable-amount">
67 73
             <View className="withdrawable-amount-header">
@@ -70,7 +76,7 @@ export default class Index extends Component {
70 76
             </View>
71 77
             <View className="withdrawable-amount-content">
72 78
               <View className="left">
73
-                <Text className="amount">¥0.00</Text>
79
+                {vipInfo.draw_money && <Text className="amount">¥{vipInfo.draw_money.store_earnings_now}</Text>}
74 80
                 <View className="warning-icon-box">
75 81
                   <Image className="warning-icon" src={warning} />
76 82
                   <Text className="warning-text">未完成提现认证</Text>
@@ -91,20 +97,20 @@ export default class Index extends Component {
91 97
                 <AtIcon value='chevron-right' size='10' color='#A1A1A1'></AtIcon>
92 98
               </View>
93 99
             </View>
94
-            <View className="today-order-content">
100
+            {vipInfo.order && <View className="today-order-content">
95 101
               <View className="order-item">
96 102
                 <Text className="label">订单总量</Text>
97
-                <Text className="amount">0</Text>
103
+                <Text className="amount">{vipInfo.order.order_all}</Text>
98 104
               </View>
99 105
               <View className="order-item">
100 106
                 <Text className="label">推广订单</Text>
101
-                <Text className="amount">0</Text>
107
+                <Text className="amount">{vipInfo.order.order_promotion}</Text>
102 108
               </View>
103 109
               <View className="order-item">
104 110
                 <Text className="label">购买历史</Text>
105
-                <Text className="amount">0</Text>
111
+                <Text className="amount">{vipInfo.order.order_pay}</Text>
106 112
               </View>
107
-            </View>
113
+            </View>}
108 114
           </View>
109 115
         </View>
110 116
       </View>

+ 0 - 1
src/pages/member/index.less

@@ -38,7 +38,6 @@
38 38
                 width: 170px;
39 39
                 height: 170px;
40 40
                 border-radius: 50%;
41
-                background-color: red;
42 41
             }
43 42
 
44 43
             .member-info-card-header-text {

+ 51 - 3
src/pages/memberSub/productClassify/index.jsx

@@ -3,8 +3,8 @@ import { View, Text } from "@tarojs/components";
3 3
 import { AtTabs, AtTabsPane } from "taro-ui";
4 4
 import "./index.less";
5 5
 import Taro from "@tarojs/taro";
6
-import ProductList from '../../../components/index/ProductList'
7
-
6
+import ProductList from "../../../components/index/ProductList";
7
+import { getBrowseShopProductList,addShopProduct } from "../../../service";
8 8
 export default class Index extends Component {
9 9
   state = {
10 10
     current: 0, // 当前选中的标签页索引
@@ -14,12 +14,60 @@ export default class Index extends Component {
14 14
       { title: "选项3" },
15 15
       { title: "选项4" },
16 16
     ], // 标签页列表
17
+    productList: [], // 商品列表
18
+    page: 1, //页数
19
+    loading: false, //加载状态
20
+    totalPages: 1, // 添加总页数
17 21
   };
18 22
   handleClick(value) {
19 23
     this.setState({
20 24
       current: value,
21 25
     });
22 26
   }
27
+  componentDidMount() {
28
+    this.getBrowseShopProductList();
29
+  }
30
+  // 获取商品列表
31
+  getBrowseShopProductList = async (isAdd=false) => {
32
+    const { page } = this.state;
33
+    this.setState({ loading: true });
34
+
35
+    const res = await getBrowseShopProductList({
36
+      tag_name: "",
37
+      page,
38
+      page_size: 10,
39
+    });
40
+
41
+    this.setState((prevState) => ({
42
+      productList:isAdd ?  res.goods_list: [...prevState.productList, ...res.goods_list],
43
+      totalPages: res.total_pages,
44
+      loading: false,
45
+    }));
46
+  };
47
+  // 添加商品
48
+  onAddProduct = (productId) => {
49
+    addShopProduct({
50
+      goods_ids: [productId],
51
+    }).then(res => {
52
+      if(res.success==true){
53
+        this.getBrowseShopProductList(true);
54
+        Taro.showToast({
55
+          title: '添加成功',
56
+          icon: 'none',
57
+        });
58
+      }
59
+    });
60
+  };
61
+  // 页面上拉触底
62
+  onReachBottom = () => {
63
+    const { page, totalPages, loading } = this.state;
64
+    if (page < totalPages && !loading) {
65
+      this.setState(
66
+        (prevState) => ({ page: prevState.page + 1 }),
67
+        () => this.getBrowseShopProductList()
68
+      );
69
+    }
70
+  };
23 71
   render() {
24 72
     return (
25 73
       <View className="index">
@@ -31,7 +79,7 @@ export default class Index extends Component {
31 79
           {this.state.tabList.map((tab, index) => (
32 80
             <AtTabsPane current={this.state.current} index={index} key={index}>
33 81
               <View className="tab-content">
34
-                <ProductList isProductClassify={true} />
82
+                <ProductList loading={this.state.loading} productList={this.state.productList} isProductClassify={true} onAddProduct={this.onAddProduct} />
35 83
               </View>
36 84
             </AtTabsPane>
37 85
           ))}

+ 0 - 1
src/pages/memberSub/productClassify/index.less

@@ -1,5 +1,4 @@
1 1
 .index {
2
-    min-height: 100vh;
3 2
     background-color: #f9f9f9;
4 3
     padding-bottom: 100px;
5 4
     padding-top: 80px;

+ 126 - 11
src/pages/memberSub/productManagement/index.jsx

@@ -3,6 +3,7 @@ import { View, Picker, Image, Text } from "@tarojs/components";
3 3
 import { AtTabs, AtTabsPane, AtCheckbox } from "taro-ui";
4 4
 import Taro from "@tarojs/taro";
5 5
 import "./index.less";
6
+import { getMyShopList,deleteShopProduct,updateProductSort } from "../../../service";
6 7
 import ProductList from "../../../components/index/ProductList"; //商品列表
7 8
 import add from "../../../images/productManagement/add.png";
8 9
 import back from "../../../images/productManagement/back.png";
@@ -25,6 +26,31 @@ export default class Index extends Component {
25 26
         label: "全选",
26 27
       },
27 28
     ], //全选
29
+    productList: [], // 商品列表
30
+    page: 1, //页数
31
+    loading: false, //加载状态
32
+    totalPages: 1, // 添加总页数
33
+    selectedProducts: [], // 删除商品选中id数组
34
+  };
35
+  componentDidShow() {
36
+    this.getMyShopList(true);
37
+  }
38
+  // 获取商品列表
39
+  getMyShopList = async (isDelete) => {
40
+    const { page } = this.state;
41
+    this.setState({ loading: true });
42
+
43
+    const res = await getMyShopList({
44
+      tag_name: "",
45
+      page,
46
+      page_size: 10,
47
+    });
48
+
49
+    this.setState((prevState) => ({
50
+      productList: isDelete ? res.goods_list : [...prevState.productList, ...res.goods_list],
51
+      totalPages: res.total_pages,
52
+      loading: false,
53
+    }));
28 54
   };
29 55
   // tabs切换
30 56
   handleClick(value) {
@@ -39,11 +65,11 @@ export default class Index extends Component {
39 65
   };
40 66
   // 切换管理状态
41 67
   changeManagement = (type) => {
42
-    if(type === 'management'){
68
+    if (type === "management") {
43 69
       this.setState({
44 70
         isManagementStatus: true,
45 71
       });
46
-    }else{
72
+    } else {
47 73
       this.setState({
48 74
         isManagementStatus: false,
49 75
       });
@@ -53,9 +79,71 @@ export default class Index extends Component {
53 79
   handleChange(value) {
54 80
     this.setState({
55 81
       checkedList: value,
56
-      isSelectAll:!this.state.isSelectAll
82
+      isSelectAll: !this.state.isSelectAll,
57 83
     });
58 84
   }
85
+  // 删除商品
86
+  onDeleteProduct = async() => {
87
+    if(this.state.selectedProducts.length==0){
88
+      Taro.showToast({
89
+        title: '请选择商品',
90
+        icon: 'none',
91
+      });
92
+      return;
93
+    }
94
+   const res = await deleteShopProduct({
95
+      goods_ids: this.state.selectedProducts,
96
+    })
97
+    if(res.success==true){
98
+      this.getMyShopList(true);
99
+      Taro.showToast({
100
+        title: '删除成功',
101
+        icon: 'none',
102
+      });
103
+    }
104
+  };
105
+  // 更新商品排序
106
+  updateProductSort = async() => {
107
+    if(this.state.selectedProducts.length==0){
108
+      Taro.showToast({
109
+        title: '请选择商品',
110
+        icon: 'none',
111
+      });
112
+      return;
113
+    }else if(this.state.selectedProducts.length>1){
114
+      Taro.showToast({
115
+        title: '只能选择一个商品',
116
+        icon: 'none',
117
+      });
118
+      return;
119
+    }
120
+    const res = await updateProductSort({
121
+      goods_id: this.state.selectedProducts.join(','),
122
+    })
123
+    if(res.success=='排序完成'){
124
+      this.getMyShopList(true);
125
+      Taro.showToast({
126
+        title: '排序完成',
127
+        icon: 'none',
128
+      });
129
+    }
130
+  }
131
+  // 页面上拉触底
132
+  onReachBottom = () => {
133
+    const { page, totalPages, loading } = this.state;
134
+    if (page < totalPages && !loading) {
135
+      this.setState(
136
+        (prevState) => ({ page: prevState.page + 1 }),
137
+        () => this.getMyShopList()
138
+      );
139
+    }
140
+  };
141
+  // 添加处理选中商品的方法
142
+  onDeleteProductSelect = (selectedProducts) => {
143
+    // 可以将选中的商品保存到父组件的状态中
144
+    this.setState({ selectedProducts });
145
+  }
146
+
59 147
   render() {
60 148
     return (
61 149
       <View className="index">
@@ -90,7 +178,16 @@ export default class Index extends Component {
90 178
                   </View>
91 179
                 </View>
92 180
                 {/* 商品列表 */}
93
-                <ProductList isSelectAll={this.state.isSelectAll} isManagement={true} isManagementStatus={this.state.isManagementStatus}/>
181
+                {this.state.productList && (
182
+                  <ProductList
183
+                    productList={this.state.productList}
184
+                    isSelectAll={this.state.isSelectAll}
185
+                    isManagement={true}
186
+                    isManagementStatus={this.state.isManagementStatus}
187
+                    loading={this.state.loading}
188
+                    onDeleteProductSelect={this.onDeleteProductSelect}
189
+                  />
190
+                )}
94 191
               </View>
95 192
             </AtTabsPane>
96 193
           </AtTabs>
@@ -98,16 +195,29 @@ export default class Index extends Component {
98 195
         {/* 底部购买模块 */}
99 196
         {!this.state.isManagementStatus ? (
100 197
           <View className="bottom-buy">
101
-            <View onClick={() => Taro.navigateBack()} className="bottom-buy-left">
102
-              <Image  src={back} mode="aspectFit" />
198
+            <View
199
+              onClick={() => Taro.navigateBack()}
200
+              className="bottom-buy-left"
201
+            >
202
+              <Image src={back} mode="aspectFit" />
103 203
               <Text className="bottom-buy-text">返回店铺</Text>
104 204
             </View>
105 205
             <View className="bottom-buy-right">
106
-              <View onClick={() => this.changeManagement('management')} className="bottom-buy-right-self">
206
+              <View
207
+                onClick={() => this.changeManagement("management")}
208
+                className="bottom-buy-right-self"
209
+              >
107 210
                 <Image src={manger} mode="aspectFit" />
108 211
                 <Text className="bottom-buy-text">批量管理</Text>
109 212
               </View>
110
-              <View onClick={() => Taro.navigateTo({ url: '/pages/memberSub/productClassify/index' })} className="bottom-buy-right-share">
213
+              <View
214
+                onClick={() =>
215
+                  Taro.navigateTo({
216
+                    url: "/pages/memberSub/productClassify/index",
217
+                  })
218
+                }
219
+                className="bottom-buy-right-share"
220
+              >
111 221
                 <Image src={add} mode="aspectFit" />
112 222
                 <Text className="bottom-buy-text">添加商品</Text>
113 223
               </View>
@@ -124,17 +234,22 @@ export default class Index extends Component {
124 234
                 />
125 235
               </View>
126 236
               <View className="right">
127
-                <View className="item">
237
+                <View className="item" onClick={this.updateProductSort}>
128 238
                   <Image src={toTop} mode="aspectFit" />
129 239
                   <Text>移至顶部</Text>
130 240
                 </View>
131
-                <View className="item">
241
+                <View onClick={this.onDeleteProduct} className="item">
132 242
                   <Image src={deleteIcon} mode="aspectFit" />
133 243
                   <Text>删除</Text>
134 244
                 </View>
135 245
               </View>
136 246
             </View>
137
-            <View onClick={() => this.changeManagement('finish')} className="operation-product-bottom">完成</View>
247
+            <View
248
+              onClick={() => this.changeManagement("finish")}
249
+              className="operation-product-bottom"
250
+            >
251
+              完成
252
+            </View>
138 253
           </View>
139 254
         )}
140 255
       </View>

+ 71 - 52
src/pages/memberSub/storeManagement/index.jsx

@@ -2,6 +2,7 @@ import { Component } from "react";
2 2
 import { View, Text, Image } from "@tarojs/components";
3 3
 import { AtIcon } from "taro-ui";
4 4
 import "./index.less";
5
+import { getMyShopList, getMyShopDetail } from "../../../service";
5 6
 import storeManagement from "../../../images/storeManagement/storeManagement.png";
6 7
 import storeManagementIcon from "../../../images/storeManagement/storeManagementIcon.png";
7 8
 import ProductCard from "../../../components/ProductCard"; //卡片模块
@@ -10,54 +11,59 @@ import Taro from "@tarojs/taro";
10 11
 export default class Index extends Component {
11 12
   state = {
12 13
     isManager: true,
13
-    productList: [
14
-      {
15
-        id: 1,
16
-        name: "青岛大虾",
17
-        price: 99.9,
18
-        originalPrice: 159.9,
19
-        image: "https://example.com/img1.jpg",
20
-        sales: 1234,
21
-        tag: "热销",
22
-      },
23
-      {
24
-        id: 2,
25
-        name: "三文鱼刺身",
26
-        price: 158,
27
-        originalPrice: 198,
28
-        image: "https://example.com/img2.jpg",
29
-        sales: 856,
30
-        tag: "新品",
31
-      },
32
-      {
33
-        id: 3,
34
-        name: "帝王蟹",
35
-        price: 299,
36
-        originalPrice: 399,
37
-        image: "https://example.com/img3.jpg",
38
-        sales: 566,
39
-        tag: "限时",
40
-      },
41
-    ],
14
+    productList: [], //商品列表
15
+    shopDetail: {}, //店铺详情
16
+    page: 1, //页数
17
+    loading: false, //加载状态
18
+    totalPages: 1, // 添加总页数
42 19
   };
20
+  // 获取店铺详情
21
+  getMyShopDetail = async () => {
22
+    const res = await getMyShopDetail();
23
+    this.setState({
24
+      shopDetail: res,
25
+    });
26
+  };
27
+  // 获取商品列表
28
+  getMyShopList = async (isBack) => {
29
+    const { page } = this.state;
30
+    this.setState({ loading: true });
31
+
32
+    const res = await getMyShopList({
33
+      tag_name: "",
34
+      page,
35
+      page_size: 10,
36
+    });
43 37
 
44
-  componentWillMount() {}
38
+    this.setState((prevState) => ({
39
+      productList: isBack ? res.goods_list : [...prevState.productList, ...res.goods_list],
40
+      totalPages: res.total_pages,
41
+      loading: false,
42
+    }));
43
+  };
45 44
 
46
-  componentDidMount() {
45
+  componentDidShow() {
47 46
     const { router } = Taro.getCurrentInstance();
48 47
     const params = router.params;
49 48
     this.setState({
50
-      isManager: params.isManager,
49
+      isManager: params.isManager, //是否是店长
51 50
     });
51
+    this.getMyShopDetail(); //获取店铺详情
52
+    this.getMyShopList(true); //获取店铺数据
52 53
   }
53
-
54
-  componentWillUnmount() {}
55
-
56
-  componentDidShow() {}
57
-
58
-  componentDidHide() {}
54
+  // 页面上拉触底
55
+  onReachBottom = () => {
56
+    const { page, totalPages, loading } = this.state;
57
+    if (page < totalPages && !loading) {
58
+      this.setState(
59
+        (prevState) => ({ page: prevState.page + 1 }),
60
+        () => this.getMyShopList()
61
+      );
62
+    }
63
+  };
59 64
 
60 65
   render() {
66
+    const { shopDetail, productList } = this.state;
61 67
     return (
62 68
       <View className="index">
63 69
         {/* 头部卡片 */}
@@ -71,12 +77,16 @@ export default class Index extends Component {
71 77
           {/* 个人信息 */}
72 78
           <View className="user-info">
73 79
             <View className="avatar-wrapper">
74
-              <Image className="avatar" src="" />
80
+              <Image
81
+                className="avatar"
82
+                mode="aspectFill"
83
+                src={shopDetail.img_icon}
84
+              />
75 85
               <View className="change-avatar-btn">更换头像</View>
76 86
             </View>
77 87
             <View className="info-content">
78
-              <Text className="name">张三</Text>
79
-              <Text className="desc">这里是店铺介绍文字内容</Text>
88
+              <Text className="name">{shopDetail.store_name}</Text>
89
+              <Text className="desc">{shopDetail.store_intro}</Text>
80 90
             </View>
81 91
           </View>
82 92
         </View>
@@ -86,24 +96,33 @@ export default class Index extends Component {
86 96
             <Text className="title">店长推荐</Text>
87 97
             <Text className="icon"></Text>
88 98
           </View>
89
-          <View className="product-card-list">
90
-            {this.state.productList.map((product) => (
91
-              <ProductCard key={product.id} product={product} />
92
-            ))}
93
-          </View>
99
+          {productList && (
100
+            <View className="product-card-list">
101
+              {productList.map((product) => (
102
+                <ProductCard key={product.id} product={product} />
103
+              ))}
104
+            </View>
105
+          )}
94 106
           {/* 底部购买模块 */}
95 107
           {this.state.isManager && (
96 108
             <View className="bottom-buy">
97
-              <View className="bottom-buy-left">
109
+              {/* <View className="bottom-buy-left">
98 110
                 <Image src={storeManagementIcon} mode="aspectFit" />
99 111
                 <Text className="bottom-buy-text">浏览店铺</Text>
100
-              </View>
112
+              </View> */}
101 113
               <View className="bottom-buy-right">
102
-                <View className="bottom-buy-right-self">
114
+                {/* <View className="bottom-buy-right-self">
103 115
                   <Text className="bottom-buy-text">店铺模版</Text>
104
-                </View>
105
-                <View onClick={() => Taro.navigateTo({ url:'/pages/memberSub/productManagement/index' })} className="bottom-buy-right-share">
106
-                  <Text  className="bottom-buy-text">商品管理</Text>
116
+                </View> */}
117
+                <View
118
+                  onClick={() =>
119
+                    Taro.navigateTo({
120
+                      url: "/pages/memberSub/productManagement/index",
121
+                    })
122
+                  }
123
+                  className="bottom-buy-right-share"
124
+                >
125
+                  <Text className="bottom-buy-text">商品管理</Text>
107 126
                 </View>
108 127
               </View>
109 128
             </View>

+ 3 - 2
src/pages/memberSub/storeManagement/index.less

@@ -1,6 +1,7 @@
1 1
 .index {
2 2
     padding: 18px 16px 0 16px;
3 3
     box-sizing: border-box;
4
+    min-height: 100vh;
4 5
     background-color: #f9f9f9;
5 6
     padding-bottom: 150px;
6 7
     .header-card {
@@ -155,7 +156,7 @@
155 156
                 }
156 157
             }
157 158
             .bottom-buy-right {
158
-                width: 550px;
159
+                width: 100%;
159 160
                 height: 100%;
160 161
                 display: flex;
161 162
                 border-radius: 60px;
@@ -163,7 +164,7 @@
163 164
                 .bottom-buy-right-self,.bottom-buy-right-share{
164 165
                     line-height: 43px;
165 166
                     font-size: 30px;
166
-                    width: 50%;
167
+                    width: 100%;
167 168
                     display: flex;
168 169
                     justify-content: center;
169 170
                     align-items: center;

+ 10 - 2
src/pages/mine/index.jsx

@@ -2,10 +2,12 @@ import { Component } from 'react'
2 2
 import Taro from '@tarojs/taro'
3 3
 import { View, Text, Image } from '@tarojs/components'
4 4
 import { AtList, AtListItem } from "taro-ui"
5
+import {getUserInfo} from '../../service'
5 6
 import './index.less'
6 7
 import loginOut from '../../images/mine/loginOut.png'
7 8
 import edit from '../../images/mine/edit.png'
8 9
 import norm from '../../images/mine/norm.png'
10
+import avatar from '../../images/mine/avatar.png'
9 11
 export default class Index extends Component {
10 12
   handleLogout = () => {
11 13
     Taro.showModal({
@@ -22,13 +24,19 @@ export default class Index extends Component {
22 24
       }
23 25
     })
24 26
   }
25
-
27
+  getUserInfo = async () => {
28
+    const res = await getUserInfo();
29
+    console.log(res);
30
+  };
31
+  componentDidMount(){
32
+    this.getUserInfo()
33
+  }
26 34
   render () {
27 35
     return (
28 36
       <View className='index'>
29 37
         {/* 个人信息 */}
30 38
         <View className="info">
31
-          <Image src='' className="avatar" />
39
+          <Image src={avatar} className="avatar" />
32 40
           <View className="info-right">
33 41
             <View className='user-info'>
34 42
             <View className="name">张三</View>

+ 0 - 1
src/pages/mine/index.less

@@ -17,7 +17,6 @@
17 17
             height: 116px;
18 18
             border-radius: 50%;
19 19
             margin-right: 18px;
20
-            background-color: red;
21 20
         }
22 21
 
23 22
         .info-right {

+ 85 - 4
src/service/index.js

@@ -1,13 +1,94 @@
1 1
 //接口集成
2 2
 import Request from '../api/request';
3
-
4
-//接口请求
5
-export const login = data =>
3
+// ------------------------首页
4
+// 获取首页数据
5
+export const getHomeData = data =>
6 6
   Request({
7
-    url: '/api/login',
7
+    url: '/api/get_index_data',
8 8
     method: 'POST',
9 9
     data,
10 10
   });
11
+// 获取商品列表
12
+export const getProductList = data =>
13
+  Request({
14
+    url: '/api/get_goods_data_list',
15
+    method: 'POST',
16
+    data,
17
+  })
18
+// 获取商品详情
19
+export const getProductDetail = data =>
20
+  Request({
21
+    url: '/api/get_goods_data_detail',
22
+    method: 'POST',
23
+    data,
24
+  })
25
+// 获取猜你喜欢列表
26
+export const getProductLikeList = data =>
27
+  Request({
28
+    url: '/api/get_goods_data_list_like',
29
+    method: 'POST',
30
+    data,
31
+  })
32
+
33
+
34
+// -----------------------用户
35
+// 获取用户详情
36
+export const getUserInfo = data =>
37
+  Request({
38
+    url: '/user/user',
39
+    method: 'POST',
40
+    data,
41
+  })
42
+// ---------------------会员
43
+// 获取会员详情
44
+export const getVipInfo = data =>
45
+  Request({
46
+    url: '/vip/get_index_vip_data',
47
+    method: 'POST',
48
+    data,
49
+  })
50
+  // 获取我的店铺详情
51
+  export const getMyShopDetail = data =>
52
+  Request({
53
+    url: '/vip/get_store_detail',
54
+    method: 'POST',
55
+    data,
56
+  })
57
+  // 获取我的店铺数据
58
+  export const getMyShopList = data =>
59
+  Request({
60
+    url: '/vip/get_store_data_list',
61
+    method: 'POST',
62
+    data,
63
+  })
64
+  // 店铺添加指定商品
65
+  export const addShopProduct = data =>
66
+  Request({
67
+    url: '/vip/add_store_goods',
68
+    method: 'POST',
69
+    data,
70
+  })
71
+  // 删除店铺商品
72
+  export const deleteShopProduct = data =>
73
+  Request({
74
+    url: '/vip/delete_store_goods',
75
+    method: 'POST',
76
+    data,
77
+  })
78
+  // 获取浏览店铺的商品列表
79
+  export const getBrowseShopProductList = data =>
80
+  Request({
81
+    url: '/vip/get_goods_data_list_store',
82
+    method: 'POST',
83
+    data,
84
+  })
85
+  // 更新商品排序
86
+  export const updateProductSort = data =>
87
+  Request({
88
+    url: '/vip/update_goods_sort',
89
+    method: 'POST',
90
+    data,
91
+  })
11 92
 
12 93
 
13 94