Ver código fonte

处理分享和其他接口

viczhq 1 semana atrás
pai
commit
0a726164c1

+ 14 - 7
project.private.config.json

@@ -10,6 +10,20 @@
10 10
     "miniprogram": {
11 11
       "list": [
12 12
         {
13
+          "name": "pages/productManagement/index",
14
+          "pathName": "pages/memberSub/storeManagement/index",
15
+          "query": "",
16
+          "launchMode": "default",
17
+          "scene": null
18
+        },
19
+        {
20
+          "name": "pages/indexSub/productDetail/index",
21
+          "pathName": "pages/indexSub/productDetail/index",
22
+          "query": "id=3074",
23
+          "launchMode": "default",
24
+          "scene": null
25
+        },
26
+        {
13 27
           "name": "pages/mineSub/userSpecification/index",
14 28
           "pathName": "pages/mineSub/userSpecification/index",
15 29
           "query": "",
@@ -78,13 +92,6 @@
78 92
           "query": "",
79 93
           "launchMode": "default",
80 94
           "scene": null
81
-        },
82
-        {
83
-          "name": "pages/productManagement/index",
84
-          "pathName": "pages/productManagement/index",
85
-          "query": "",
86
-          "launchMode": "default",
87
-          "scene": null
88 95
         }
89 96
       ]
90 97
     }

+ 3 - 1
src/app.config.js

@@ -46,8 +46,10 @@ export default defineAppConfig({
46 46
     navigationBarBackgroundColor: '#FFFFFF',
47 47
     navigationBarTitleText: '鱼市',
48 48
     navigationBarTextStyle: 'black',
49
-    backgroundColor: "#FFFFFF"
49
+    backgroundColor: "#FFFFFF",
50
+    onReachBottomDistance: 100
50 51
   },
52
+  lazyCodeLoading: "requiredComponents",
51 53
   tabBar: {
52 54
     color: "#000000",
53 55
     selectedColor: "#000000",

+ 1 - 1
src/app.js

@@ -5,7 +5,7 @@ import 'taro-ui/dist/style/index.scss'
5 5
 
6 6
 // 在 App 类外定义全局变量
7 7
 global.globalData = {
8
-  optionsData: {}  // 存储页面参数
8
+  optionsData: {},  // 存储页面参数
9 9
 }
10 10
 
11 11
 class App extends Component {

+ 16 - 4
src/components/Modal/index.jsx

@@ -1,10 +1,22 @@
1 1
 import { AtModal, AtModalContent } from "taro-ui";
2 2
 import { View, Image, Text } from "@tarojs/components";
3 3
 import "./index.less";
4
+import Taro from "@tarojs/taro";
4 5
 import selectStep from "../../images/productDetail/selectStep.png";
5 6
 import xianyu from "../../images/productDetail/xianyu.png";
6 7
 import stepThree from "../../images/productDetail/stepThree.png";
7 8
 export default function Modal(props) {
9
+  const { productPromotion } = props;
10
+  const handleCopyLink = () => {
11
+    Taro.setClipboardData({
12
+      data: productPromotion.short_tpwd,
13
+    }).then(() => {
14
+      Taro.showToast({
15
+        title: '口令已复制',
16
+        icon: 'success',
17
+      });
18
+    });
19
+  }
8 20
   return (
9 21
     <AtModal isOpened={props.isOpened} closeOnClickOverlay={true}>
10 22
       <AtModalContent>
@@ -16,7 +28,7 @@ export default function Modal(props) {
16 28
               <View className="step-item">
17 29
                 <View className="step-title">
18 30
                   <Text className="number">1</Text>
19
-                  <Text className="desc">第一步说明文字</Text>
31
+                  <Text className="desc">点击复制口令</Text>
20 32
                 </View>
21 33
                 <View className="step-box">
22 34
                     <View className="step-One">
@@ -28,7 +40,7 @@ export default function Modal(props) {
28 40
               <View className="step-item">
29 41
                 <View className="step-title">
30 42
                   <Text className="number">2</Text>
31
-                  <Text className="desc">第二步说明文字</Text>
43
+                  <Text className="desc">打开咸鱼APP</Text>
32 44
                 </View>
33 45
                 <View className="step-box">
34 46
                   <Image className="step-img-t" src={xianyu} />
@@ -38,7 +50,7 @@ export default function Modal(props) {
38 50
               <View className="step-item">
39 51
                 <View className="step-title">
40 52
                   <Text className="number">3</Text>
41
-                  <Text className="desc">第三步说明文字</Text>
53
+                  <Text className="desc">自动识别口令</Text>
42 54
                 </View>
43 55
                 <View className="step-box">
44 56
                   <Image mode="heightFix" className="step-img-three" src={stepThree} />
@@ -46,7 +58,7 @@ export default function Modal(props) {
46 58
               </View>
47 59
             </View>
48 60
             {/* 复制口令 */}
49
-            <View className="copy-link">
61
+            <View className="copy-link" onClick={handleCopyLink}>
50 62
                 复制口令
51 63
             </View>
52 64
           </View>

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

@@ -4,11 +4,11 @@
4 4
   .category-list {
5 5
     display: flex;
6 6
     flex-wrap: wrap;
7
-    justify-content: space-between;
7
+    // justify-content: space-between;
8 8
     background: #FFFFFF;
9 9
     border-radius: 20px;
10 10
     padding: 25px 17px 22px 17px;
11
-    
11
+    gap: 50px;
12 12
     .category-item {
13 13
       width: 96px;
14 14
       display: flex;

+ 32 - 17
src/components/index/ProductList/index.jsx

@@ -4,7 +4,7 @@ import React, {
4 4
   forwardRef,
5 5
   useImperativeHandle,
6 6
 } from "react";
7
-import { View, Text, Image } from "@tarojs/components";
7
+import { View, Text, Image, Button } from "@tarojs/components";
8 8
 import { AtCheckbox, AtActivityIndicator } from "taro-ui";
9 9
 import Taro from "@tarojs/taro";
10 10
 import "./index.less";
@@ -17,17 +17,18 @@ const ProductList = forwardRef((props, ref) => {
17 17
   const {
18 18
     productList, // 商品列表数据
19 19
     loading, // 加载状态
20
-    isSeckill, // 是否秒杀
21
-    isManagement, // 是否管理
20
+    isSeckill, // 是否秒杀页面使用
21
+    isManagement, // 是否管理页面使用
22 22
     isManagementStatus, // 是否管理状态
23
-    isProductClassify, // 是否分类
23
+    isProductClassify, // 是否分类页面使用
24 24
     isSelectAll, // 是否全选
25 25
     onAddProduct, // 添加商品方法
26 26
     onDeleteProductSelect, // 删除商品选中id数组
27
-  } = props;
27
+    isNoMore, // 是否没有更多
28
+    onShareProduct, // 分享商品方法
29
+    } = props;
28 30
 
29 31
   const [selectedProducts, setSelectedProducts] = useState([]); // 商品选择状态
30
-
31 32
   // 监听选中状态变化
32 33
   useEffect(() => {
33 34
     // 每当 selectedProducts 变化时,调用父组件的回调
@@ -42,12 +43,12 @@ const ProductList = forwardRef((props, ref) => {
42 43
       // 如果 isSelectAll 为 false,取消所有选中
43 44
       setSelectedProducts([]);
44 45
     }
45
-  }, [isSelectAll, productList]);
46
+  }, [isSelectAll]);
46 47
   // 定义 clearSelectedItems 方法
47 48
   useImperativeHandle(ref, () => ({
48 49
     clearSelectedItems: () => {
49 50
       setSelectedProducts([]);
50
-    }
51
+    },
51 52
   }));
52 53
 
53 54
   // 跳转产品详情
@@ -69,21 +70,27 @@ const ProductList = forwardRef((props, ref) => {
69 70
         // 如果已经选中,则取消选择
70 71
         return prevSelected.filter((id) => id !== productId);
71 72
       } else {
72
-        // 如果未选中,则添加到选中列
73
+        // 如果未选中,则添加到选中列
73 74
         return [...prevSelected, productId];
74 75
       }
75 76
     });
76 77
   };
77 78
   // 添加商品
78
-  const addProduct = (productId, is_collected) => {
79
+  const addProduct = (productId, is_collected, index) => {
79 80
     // 是否添加到我的商店(is_collected:为true已添加)
80 81
     if (is_collected) {
81 82
       return;
82 83
     } else {
83 84
       // 调用父组件的方法
84
-      onAddProduct && onAddProduct(productId);
85
+      onAddProduct && onAddProduct(productId, index);
85 86
     }
86 87
   };
88
+  // 分享商品 
89
+  const shareProduct = (product, e) => {
90
+    e.stopPropagation(); // 防止事件穿透
91
+    // 调用父组件的回调函数,传递商品信息
92
+    props.onShareProduct && props.onShareProduct(product);
93
+  };
87 94
   return (
88 95
     <View className="product-list-wrap">
89 96
       {isSeckill && (
@@ -114,7 +121,7 @@ const ProductList = forwardRef((props, ref) => {
114 121
                   style={{ WebkitBoxOrient: "vertical" }}
115 122
                 >
116 123
                   <Text className="self-tag">
117
-                    {!isSeckill ? "自营" : "鱼市杀"}
124
+                    {!isSeckill ? "自营" : "鱼市��杀"}
118 125
                   </Text>
119 126
                   {product.item_title}
120 127
                 </View>
@@ -132,7 +139,7 @@ const ProductList = forwardRef((props, ref) => {
132 139
                     <View
133 140
                       onClick={(e) => {
134 141
                         e.stopPropagation();
135
-                        addProduct(product.id, product.is_collected);
142
+                        addProduct(product.id, product.is_collected, index);
136 143
                       }}
137 144
                       className="add-btn"
138 145
                     >
@@ -166,10 +173,15 @@ const ProductList = forwardRef((props, ref) => {
166 173
                   <View className="share-earn">
167 174
                     <Image className="bg" src={shareEarnBg} mode="aspectFit" />
168 175
                     <View className="content">
169
-                      <Text className="label">分享赚</Text>
170
-                      <Text className="money">
171
-                        ¥{product.estimated_commission}
172
-                      </Text>
176
+                      <Button
177
+                        openType="share"
178
+                        onClick={(e) => shareProduct(product, e)} // 传递事件对象
179
+                      >
180
+                        <Text className="label">分享赚</Text>
181
+                        <Text className="money">
182
+                          ¥{product.estimated_commission}
183
+                        </Text>
184
+                      </Button>
173 185
                     </View>
174 186
                   </View>
175 187
                 </View>
@@ -191,6 +203,7 @@ const ProductList = forwardRef((props, ref) => {
191 203
           />
192 204
         </View>
193 205
       )}
206
+      {isNoMore && <View className="no-more">没有更多了~</View>}
194 207
     </View>
195 208
   );
196 209
 });
@@ -203,8 +216,10 @@ ProductList.defaultProps = {
203 216
   isManagementStatus: false,
204 217
   isProductClassify: false,
205 218
   isSelectAll: false,
219
+  isNoMore: false,
206 220
   onAddProduct: () => {}, // 添加商品方法
207 221
   onDeleteProductSelect: () => {}, // 删除商品选中id数组
222
+  onShareProduct: () => {}, // 分享商品方法
208 223
 };
209 224
 
210 225
 export default ProductList;

+ 39 - 3
src/components/index/ProductList/index.less

@@ -14,6 +14,7 @@
14 14
     .at-checkbox::before {
15 15
       content: none;
16 16
     }
17
+
17 18
     .at-checkbox__option-wrap {
18 19
       padding: 0 15px 0 0;
19 20
     }
@@ -162,6 +163,30 @@
162 163
             justify-content: center;
163 164
             font-size: 28px;
164 165
 
166
+            // 清除Button默认样式
167
+            Button {
168
+              padding: 0;
169
+              margin: 0;
170
+              background: none;
171
+              border: none;
172
+              line-height: normal;
173
+              height: 100%;
174
+              width: 100%;
175
+              display: flex;
176
+              flex-direction: column;
177
+              align-items: center;
178
+              justify-content: center;
179
+              font-size: 28px;
180
+              color: #FFFFFF;
181
+              &::after {
182
+                border: none;
183
+              }
184
+            }
185
+            .button-hover {
186
+              background-color: transparent !important; /* 移除背景高亮 */
187
+              box-shadow: none !important;             /* 移除可能的阴影 */
188
+            }
189
+
165 190
             .label,
166 191
             .money {
167 192
               line-height: 41px;
@@ -189,9 +214,20 @@
189 214
       margin-right: 10px;
190 215
     }
191 216
   }
192
-  .loading{
217
+
218
+  .loading {
193 219
     width: 100%;
194 220
     position: relative;
195
-    height: 60px;  
221
+    height: 60px;
222
+  }
223
+
224
+  .no-more {
225
+    width: 100%;
226
+    height: 60px;
227
+    text-align: center;
228
+    font-size: 20px;
229
+    line-height: 60px;
230
+    margin-top: 20px;
231
+    color: #999999;
196 232
   }
197
-}
233
+}

+ 2 - 1
src/pages/index/index.config.js

@@ -1,3 +1,4 @@
1 1
 export default definePageConfig({
2
-  navigationStyle: 'custom'
2
+  navigationStyle: 'custom',
3
+  enableShareAppMessage: true
3 4
 })

+ 27 - 8
src/pages/index/index.jsx

@@ -21,6 +21,7 @@ export default class Index extends Component {
21 21
     page: 1, // 添加页码
22 22
     totalPages: 1, // 添加总页数
23 23
     loading: false, // 添加加载状态
24
+    shareInfo: {}, // 分享信息
24 25
   };
25 26
   // 获取首页数据
26 27
   getHomeData = async () => {
@@ -87,7 +88,7 @@ export default class Index extends Component {
87 88
     const { page } = this.state;
88 89
     this.setState({ loading: true });
89 90
     const res = await getProductList({
90
-      tag_name:  this.state.homeData.tags[this.state.current].title,
91
+      tag_name: this.state.homeData.tags[this.state.current].title,
91 92
       page,
92 93
       page_size: 10,
93 94
     });
@@ -101,6 +102,24 @@ export default class Index extends Component {
101 102
     }));
102 103
   };
103 104
 
105
+  // 分享商品
106
+  handleShareProduct = (product) => {
107
+    this.setState({ shareInfo: product }, () => {
108
+      Taro.showShareMenu({
109
+        withShareTicket: true,
110
+        menus: ["shareAppMessage"],
111
+      });
112
+    });
113
+  };
114
+  // 配置分享内容
115
+  onShareAppMessage() {
116
+      let shareInfo = this.state.shareInfo;
117
+      return {
118
+        title: shareInfo.item_title,
119
+        path: `/pages/indexSub/productDetail/index?id=${shareInfo.id}&&isShare=${true}`,
120
+        imageUrl: shareInfo.image_url,
121
+      };
122
+  }
104 123
   render() {
105 124
     const { homeData, productList, loading } = this.state;
106 125
     return (
@@ -119,13 +138,9 @@ export default class Index extends Component {
119 138
           {/* 搜索框包裹盒子 */}
120 139
           <View
121 140
             className="search-bar-container"
122
-            onClick={() => Taro.navigateTo({ url: '/pages/search/index' })}
141
+            onClick={() => Taro.navigateTo({ url: "/pages/search/index" })}
123 142
           >
124
-            <SearchBar
125
-              value=""
126
-              disabled={true}
127
-              placeholder="点击搜索商品"
128
-            />
143
+            <SearchBar value="" disabled={true} placeholder="点击搜索商品" />
129 144
           </View>
130 145
           {/* tab分类 */}
131 146
           <View className="tabs-list">
@@ -173,7 +188,11 @@ export default class Index extends Component {
173 188
         {/* <RecommendList /> */}
174 189
         {/* 商品列表 */}
175 190
         <View className="product-list-wrap">
176
-          <ProductList productList={productList} loading={loading} />
191
+          <ProductList
192
+            productList={productList}
193
+            loading={loading}
194
+            onShareProduct={this.handleShareProduct}
195
+          />
177 196
         </View>
178 197
         {/* 添加浮动按钮 */}
179 198
         <View className="float-buttons">

+ 1 - 1
src/pages/indexSub/productDetail/index.config.js

@@ -1,3 +1,3 @@
1 1
 export default definePageConfig({
2
-  navigationStyle: 'custom'
2
+  navigationStyle: 'custom',
3 3
 })

+ 56 - 14
src/pages/indexSub/productDetail/index.jsx

@@ -1,7 +1,7 @@
1 1
 import { Component } from "react";
2
-import { View, Text, Swiper, SwiperItem, Image } from "@tarojs/components";
2
+import { View, Text, Swiper, SwiperItem, Image, Button } from "@tarojs/components";
3 3
 import { AtIcon } from "taro-ui";
4
-import { getProductDetail, getProductLikeList } from "../../../service";
4
+import { getProductDetail, getProductLikeList,getProductPromotion } from "../../../service";
5 5
 import "./index.less";
6 6
 import Taro from "@tarojs/taro";
7 7
 import productDetailIcon from "../../../images/productDetail/productDetailIcon.png";
@@ -14,29 +14,47 @@ import Modal from "../../../components/Modal"; //弹窗
14 14
 
15 15
 export default class Index extends Component {
16 16
   state = {
17
+    id: "", //商品id
17 18
     isShare: false, //是否是分享
18 19
     isOpened: false, //是否打开弹窗
19 20
     productDetail: [], //商品详情
20
-    productLikeList:[],//推荐商品列表
21
+    productLikeList: [], //推荐商品列表
22
+    productPromotion: [], //商品推广转链
21 23
   };
22 24
   // 获取产品详情的方法
23
-  fetchProductDetails = async (id) => {
25
+  fetchProductDetails = async (id) => { 
24 26
     const res = await getProductDetail({
25 27
       goods_id: id,
26 28
     });
27 29
     this.setState({
28 30
       productDetail: res,
31
+    },() => {
32
+      this.getProductPromotion(); //获取商品推广转链
29 33
     });
30 34
   };
31 35
   // 获取猜你喜欢列表
32 36
   getProductLikeList = async () => {
33 37
     const res = await getProductLikeList();
34 38
     this.setState({
35
-      productLikeList:res
36
-    })
39
+      productLikeList: res,
40
+    });
41
+  };
42
+  // 获取商品推广转链
43
+  getProductPromotion = async () => {
44
+    const res = await getProductPromotion({
45
+      goods_id: [this.state.id],
46
+      item_id: [this.state.productDetail.item_id],
47
+    });
48
+    this.setState({
49
+      productPromotion: res.alibaba_idle_affiliate_general_link_convert_response.result.result,
50
+    });
37 51
   };
38 52
   componentDidMount() {
39
-    const { id } = Taro.getCurrentInstance().router.params;
53
+    const { id, isShare } = Taro.getCurrentInstance().router.params;
54
+    this.setState({
55
+      id,
56
+      isShare,
57
+    });
40 58
     this.fetchProductDetails(id); //获取产品详情
41 59
     this.getProductLikeList(); //获取猜你喜欢列表
42 60
   }
@@ -62,18 +80,35 @@ export default class Index extends Component {
62 80
 
63 81
   // 立即购买
64 82
   handleBuy = () => {
65
-    console.log(111);
66
-
67 83
     this.setState({
68 84
       isOpened: true,
69 85
     });
70 86
   };
71
-
87
+  // 分享
88
+  handleShare = () => {
89
+    // 只显示分享菜单
90
+    Taro.showShareMenu({
91
+      withShareTicket: true,
92
+      menus: ['shareAppMessage']
93
+    });
94
+  };
95
+  // 配置分享内容
96
+  onShareAppMessage() {
97
+    return {
98
+      title: this.state.productDetail.item_title,
99
+      path: `/pages/indexSub/productDetail/index?id=${this.state.id}&&isShare=${this.state.isShare}`,
100
+      imageUrl: this.state.productDetail.images[0].img
101
+    }
102
+  }
72 103
   // 添加返回方法
73 104
   handleBack = () => {
74 105
     const pages = Taro.getCurrentPages();
75 106
     if (pages.length > 1) {
76 107
       Taro.navigateBack();
108
+    } else {
109
+      Taro.switchTab({
110
+        url: "/pages/index/index",
111
+      });
77 112
     }
78 113
   };
79 114
 
@@ -102,7 +137,6 @@ export default class Index extends Component {
102 137
               </SwiperItem>
103 138
             ))}
104 139
         </Swiper>
105
-
106 140
         {/* 商品详情模块 */}
107 141
         <View className="product-info">
108 142
           {/* 商品名称 */}
@@ -138,7 +172,9 @@ export default class Index extends Component {
138 172
 
139 173
           {/* 商品编号行 */}
140 174
           <View className="product-number-row">
141
-            <Text className="number-label">商品编号:{productDetail.goods_number}</Text>
175
+            <Text className="number-label">
176
+              商品编号:{productDetail.goods_number}
177
+            </Text>
142 178
             <Text
143 179
               className="copy-btn"
144 180
               onClick={() => this.handleCopy("123456")}
@@ -182,9 +218,14 @@ export default class Index extends Component {
182 218
           <View className="bottom-buy-right">
183 219
             {!this.state.isShare ? (
184 220
               <>
185
-                <View className="bottom-buy-right-self">
221
+                <View
222
+                  onClick={this.handleShare}
223
+                  className="bottom-buy-right-self"
224
+                >
225
+                <Button openType="share" onClick={this.handleShare}>
186 226
                   <Image src={share} mode="aspectFit" />
187 227
                   <Text className="bottom-buy-text">分享赚</Text>
228
+                </Button>
188 229
                 </View>
189 230
                 <View
190 231
                   onClick={this.handleBuy}
@@ -203,9 +244,10 @@ export default class Index extends Component {
203 244
         </View>
204 245
         {/* 分享弹窗 */}
205 246
         <Modal
206
-          linkText="阿拉山口监督卡监督卡就"
247
+          linkText={this.state.productPromotion.short_tpwd}
207 248
           title="咸鱼口令已复制"
208 249
           isOpened={this.state.isOpened}
250
+          productPromotion={this.state.productPromotion}
209 251
         />
210 252
       </View>
211 253
     );

+ 43 - 9
src/pages/indexSub/productDetail/index.less

@@ -6,6 +6,7 @@
6 6
     .swiper {
7 7
         width: 100%;
8 8
         height: 730px;
9
+
9 10
         .swiper-img {
10 11
             width: 100%;
11 12
             height: 100%;
@@ -162,6 +163,7 @@
162 163
         display: flex;
163 164
         justify-content: space-between;
164 165
         align-items: center;
166
+
165 167
         .bottom-buy-left {
166 168
             display: flex;
167 169
             flex-direction: column;
@@ -178,41 +180,50 @@
178 180
                 color: #000000;
179 181
             }
180 182
         }
183
+
181 184
         .bottom-buy-right {
182 185
             width: 576px;
183 186
             height: 100%;
184 187
             display: flex;
185 188
             border-radius: 60px;
186 189
             overflow: hidden;
187
-            .bottom-buy-right-self,.bottom-buy-right-share{
190
+
191
+            .bottom-buy-right-self,
192
+            .bottom-buy-right-share {
188 193
                 line-height: 43px;
189 194
                 font-size: 30px;
190 195
                 width: 50%;
191 196
                 display: flex;
192 197
                 justify-content: center;
193 198
                 align-items: center;
194
-                image{
199
+
200
+                image {
195 201
                     margin-right: 9px;
196 202
                 }
197 203
             }
198
-            .bottom-buy-right-self{
204
+
205
+            .bottom-buy-right-self {
199 206
                 background-color: #fbe00f;
200 207
                 color: #000000;
201
-                image{
208
+
209
+                image {
202 210
                     width: 47px;
203 211
                     height: 46px;
204 212
                 }
205 213
             }
206
-            .bottom-buy-right-share{
214
+
215
+            .bottom-buy-right-share {
207 216
                 background-color: #ff1c14;
208 217
                 color: #fff;
209
-                image{
218
+
219
+                image {
210 220
                     width: 45px;
211 221
                     height: 31px;
212 222
                 }
213 223
             }
214 224
         }
215
-        .bottom-buy-right-btn{
225
+
226
+        .bottom-buy-right-btn {
216 227
             width: 586px;
217 228
             height: 100%;
218 229
             background: linear-gradient(90deg, #ff881b 0%, #fe6234 100%);
@@ -220,7 +231,8 @@
220 231
             display: flex;
221 232
             justify-content: center;
222 233
             align-items: center;
223
-            .bottom-buy-text{
234
+
235
+            .bottom-buy-text {
224 236
                 color: #fff;
225 237
                 font-size: 28px;
226 238
                 line-height: 41px;
@@ -245,4 +257,26 @@
245 257
         justify-content: center;
246 258
         z-index: 100;
247 259
     }
248
-}
260
+}
261
+
262
+// 清除Button默认样式
263
+Button {
264
+    padding: 0;
265
+    margin: 0;
266
+    background: none;
267
+    border: none;
268
+    line-height: normal;
269
+    height: 100%;
270
+    width: 100%;
271
+    display: flex;
272
+    justify-content: center;
273
+    align-items: center;
274
+
275
+    &::after {
276
+        border: none;
277
+    }
278
+}
279
+.button-hover {
280
+    background-color: transparent !important; /* 移除背景高亮 */
281
+    box-shadow: none !important;             /* 移除可能的阴影 */
282
+  }

+ 4 - 2
src/pages/login/index.jsx

@@ -34,6 +34,9 @@ export default class Index extends Component {
34 34
   //   }
35 35
   // };
36 36
   login = () => {
37
+    Taro.showLoading({
38
+      title: '正在登录',
39
+    })
37 40
     if (!this.state.isChecked) {
38 41
       Taro.showToast({
39 42
         title: "请先同意协议",
@@ -53,6 +56,7 @@ export default class Index extends Component {
53 56
             }).then((res) => {
54 57
               Taro.setStorageSync('session_key', res.session_key)
55 58
               Taro.setStorageSync('loginInfo', res)
59
+              Taro.hideLoading()
56 60
               Taro.showToast({
57 61
                 title: '登录成功',
58 62
                 icon: 'none',
@@ -64,13 +68,11 @@ export default class Index extends Component {
64 68
               if (lastPage == 'pages/mineSub/login/index') {
65 69
                 lastPage = 'pages/index/index'
66 70
               }
67
-              setTimeout(() => {
68 71
                 Taro.reLaunch({
69 72
                   url: `/${lastPage}?${objToParam(Taro.getStorageSync('optionsData'))}`
70 73
                 })
71 74
                 Taro.removeStorageSync('currentPage')
72 75
                 global.globalData.optionsData = {}
73
-              }, 1000)
74 76
             });
75 77
           },
76 78
         });

+ 55 - 42
src/pages/memberSub/productClassify/index.jsx

@@ -1,15 +1,18 @@
1 1
 import { Component } from "react";
2
-import { View, Text } from "@tarojs/components";
2
+import { View } from "@tarojs/components";
3 3
 import { AtTabs, AtTabsPane } from "taro-ui";
4 4
 import "./index.less";
5 5
 import Taro from "@tarojs/taro";
6 6
 import ProductList from "../../../components/index/ProductList";
7
-import { getBrowseShopProductList,addShopProduct,getAllTags } from "../../../service";
7
+import {
8
+  getBrowseShopProductList,
9
+  addShopProduct,
10
+  getAllTags,
11
+} from "../../../service";
8 12
 export default class Index extends Component {
9 13
   state = {
10 14
     current: 0, // 当前选中的标签页索引
11
-    tabList: [
12
-    ], // 标签页列表
15
+    tabList: [], // 标签页列表
13 16
     productList: [], // 商品列表
14 17
     page: 1, //页数
15 18
     loading: false, //加载状态
@@ -17,29 +20,38 @@ export default class Index extends Component {
17 20
     tabList: [], // 所有闲鱼tags
18 21
   };
19 22
   handleClick(value) {
20
-    this.setState({
21
-      current: value,
22
-      page: 1,
23
-    },()=>{
24
-      this.getBrowseShopProductList(true);
25
-    });
23
+    this.setState(
24
+      {
25
+        current: value,
26
+        page: 1,
27
+      },
28
+      () => {
29
+        Taro.pageScrollTo({
30
+          scrollTop: 0,
31
+          duration: 300
32
+        });
33
+        this.getBrowseShopProductList(true);
34
+      }
35
+    );
26 36
   }
27 37
   componentDidMount() {
28 38
     this.getAllTags();
29 39
   }
30 40
   // 获取商品列表
31
-  getBrowseShopProductList = async (isAdd=false) => {
41
+  getBrowseShopProductList = async (isAdd = false) => {
32 42
     const { page } = this.state;
33 43
     this.setState({ loading: true });
34
-    
44
+
35 45
     const res = await getBrowseShopProductList({
36
-      tag_name:this.state.tabList[this.state.current].title,
46
+      tag_name: this.state.tabList[this.state.current].title,
37 47
       page,
38 48
       page_size: 10,
39 49
     });
40 50
 
41 51
     this.setState((prevState) => ({
42
-      productList:isAdd ?  res.goods_list: [...prevState.productList, ...res.goods_list],
52
+      productList: isAdd
53
+        ? res.goods_list
54
+        : [...prevState.productList, ...res.goods_list],
43 55
       totalPages: res.total_pages,
44 56
       loading: false,
45 57
     }));
@@ -50,29 +62,29 @@ export default class Index extends Component {
50 62
     res = res.map((item, index) => ({
51 63
       title: item.name,
52 64
     }));
53
-    this.setState({
54
-      tabList: res,
55
-    },()=>{
56
-      this.getBrowseShopProductList(true);
57
-    });
58
-  }
65
+    this.setState(
66
+      {
67
+        tabList: res,
68
+      },
69
+      () => {
70
+        this.getBrowseShopProductList(true);
71
+      }
72
+    );
73
+  };
59 74
   // 添加商品
60
-  onAddProduct = (productId) => {
75
+  onAddProduct = (productId, index) => {
61 76
     addShopProduct({
62 77
       goods_ids: [productId],
63
-    }).then(res => {
64
-      if(res.success==true){
65
-        this.setState((prevState) => ({
66
-          productList: prevState.productList.map(item => {
67
-            if(item.id === productId){
68
-              return { ...item, is_collected: true };
69
-            }
70
-            return item;
71
-          })
72
-        }));
78
+    }).then((res) => {
79
+      if (res.success === true) {
80
+        this.setState((prevState) => {
81
+          const newList = [...prevState.productList];
82
+          newList[index] = { ...newList[index], is_collected: true };
83
+          return { productList: newList };
84
+        });
73 85
         Taro.showToast({
74
-          title: '添加成功',
75
-          icon: 'none',
86
+          title: "添加成功",
87
+          icon: "none",
76 88
         });
77 89
       }
78 90
     });
@@ -81,6 +93,7 @@ export default class Index extends Component {
81 93
   onReachBottom = () => {
82 94
     const { page, totalPages, loading } = this.state;
83 95
     if (page < totalPages && !loading) {
96
+      console.log("触底了");
84 97
       this.setState(
85 98
         (prevState) => ({ page: prevState.page + 1 }),
86 99
         () => this.getBrowseShopProductList()
@@ -95,15 +108,15 @@ export default class Index extends Component {
95 108
           current={this.state.current}
96 109
           tabList={this.state.tabList}
97 110
           onClick={this.handleClick.bind(this)}
98
-        >
99
-          {this.state.tabList.map((tab, index) => (
100
-            <AtTabsPane current={this.state.current} index={index} key={index}>
101
-              <View className="tab-content">
102
-                <ProductList loading={this.state.loading} productList={this.state.productList} isProductClassify={true} onAddProduct={this.onAddProduct} />
103
-              </View>
104
-            </AtTabsPane>
105
-          ))}
106
-        </AtTabs>
111
+        ></AtTabs>
112
+        <ProductList
113
+          loading={this.state.loading}
114
+          productList={this.state.productList}
115
+          isProductClassify={true}
116
+          onAddProduct={(productId, index) =>
117
+            this.onAddProduct(productId, index)
118
+          }
119
+        />
107 120
         {/* 底部按钮 */}
108 121
         <View onClick={() => Taro.navigateBack()} className="bottom-button">
109 122
           返回店铺首页

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

@@ -1,6 +1,6 @@
1 1
 .index {
2 2
     background-color: #f9f9f9;
3
-    padding-bottom: 130px;
3
+    padding-bottom: 160px;
4 4
     padding-top: 80px;
5 5
     box-sizing: border-box;
6 6
     .at-tabs__header{
@@ -33,5 +33,6 @@
33 33
         justify-content: center;
34 34
         position: fixed;
35 35
         bottom: 0;
36
+        z-index: 1;
36 37
     }
37 38
 }

+ 12 - 1
src/pages/memberSub/productManagement/index.jsx

@@ -38,6 +38,7 @@ export default class Index extends Component {
38 38
     totalPages: 1, // 添加总页数
39 39
     selectedProducts: [], // 删除商品选中id数组
40 40
     tags: [], // 所有闲鱼tags
41
+    isNoMore: false, // 是否没有更多
41 42
   };
42 43
   componentDidShow() {
43 44
     this.getAllTags();
@@ -70,6 +71,7 @@ export default class Index extends Component {
70 71
           : [...prevState.productList, ...res.goods_list],
71 72
         totalPages: res.total_pages,
72 73
         loading: false,
74
+        isNoMore: res.total_pages <= page,
73 75
       }),
74 76
       () => {
75 77
         this.setState((prevState) => ({
@@ -81,7 +83,11 @@ export default class Index extends Component {
81 83
   // 商品下拉选项
82 84
   handleSelectOption = (e) => {
83 85
     const selectedOption = this.state.options[e.detail.value];
84
-    this.setState({ selectedOption, page: 1 },()=>{
86
+    this.setState({ selectedOption, page: 1, isNoMore: false },()=>{
87
+      Taro.pageScrollTo({
88
+        scrollTop: 0,
89
+        duration: 300
90
+      });
85 91
       this.getMyShopList(true);
86 92
     });
87 93
   };
@@ -95,6 +101,8 @@ export default class Index extends Component {
95 101
       this.setState(
96 102
         {
97 103
           isManagementStatus: false,
104
+          isSelectAll: false, // 重置全选状态
105
+          checkedList: [], // 重置选中状态
98 106
         },
99 107
         () => {
100 108
           // 在清空后通过回调清除子组件中的选中状态
@@ -127,6 +135,8 @@ export default class Index extends Component {
127 135
           productList: prevState.productList.filter(
128 136
             (item) => !this.state.selectedProducts.includes(item.id)
129 137
           ),
138
+          isSelectAll: false, // 重置全选状态
139
+          checkedList: [], // 重置选中状态
130 140
         }),
131 141
         () => {
132 142
           // 在清空后通过回调清除子组件中的选中状态
@@ -251,6 +261,7 @@ export default class Index extends Component {
251 261
                     isManagementStatus={this.state.isManagementStatus}
252 262
                     loading={this.state.loading}
253 263
                     onDeleteProductSelect={this.onDeleteProductSelect}
264
+                    isNoMore={this.state.isNoMore}
254 265
                   />
255 266
                 )}
256 267
               </View>

+ 37 - 9
src/pages/memberSub/storeManagement/index.jsx

@@ -1,8 +1,8 @@
1 1
 import { Component } from "react";
2
-import { View, Text, Image } from "@tarojs/components";
2
+import { View, Text, Image, Button } from "@tarojs/components";
3 3
 import { AtIcon } from "taro-ui";
4 4
 import "./index.less";
5
-import { getMyShopList, getMyShopDetail } from "../../../service";
5
+import { getMyShopList, getMyShopDetail, getShareShopDetail, getShareShopProductList } from "../../../service";
6 6
 import storeManagement from "../../../images/storeManagement/storeManagement.png";
7 7
 import storeManagementIcon from "../../../images/storeManagement/storeManagementIcon.png";
8 8
 import ProductCard from "../../../components/ProductCard"; //卡片模块
@@ -16,10 +16,14 @@ export default class Index extends Component {
16 16
     page: 1, //页数
17 17
     loading: false, //加载状态
18 18
     totalPages: 1, // 添加总页数
19
+    isShare: false, // 是否是分享进入
20
+    shopId: '', // 店铺id
19 21
   };
20 22
   // 获取店铺详情
21 23
   getMyShopDetail = async () => {
22
-    const res = await getMyShopDetail();
24
+    const res = this.state.isShare ? await getShareShopDetail({
25
+      store_id: this.state.shopId
26
+    }) :  await getMyShopDetail();
23 27
     this.setState({
24 28
       shopDetail: res,
25 29
     });
@@ -29,8 +33,11 @@ export default class Index extends Component {
29 33
     const { page } = this.state;
30 34
     this.setState({ loading: true });
31 35
 
32
-    const res = await getMyShopList({
33
-      tag_name: "",
36
+    const res = this.state.isShare ? await getShareShopProductList({
37
+      store_id: this.state.shopId,
38
+      page,
39
+      page_size: 10,
40
+    }) : await getMyShopList({
34 41
       page,
35 42
       page_size: 10,
36 43
     });
@@ -46,10 +53,13 @@ export default class Index extends Component {
46 53
     const { router } = Taro.getCurrentInstance();
47 54
     const params = router.params;
48 55
     this.setState({
49
-      isManager: params.isManager, //是否是店长
56
+      isManager: JSON.parse(params.isManager), //是否是店长
57
+      isShare: params.isShare||false, // 是否是分享进入
58
+      shopId: params.shopId||'', // 店铺id
59
+    },()=>{
60
+      this.getMyShopDetail(); //获取店铺详情
61
+      this.getMyShopList(true); //获取店铺数据
50 62
     });
51
-    this.getMyShopDetail(); //获取店铺详情
52
-    this.getMyShopList(true); //获取店铺数据
53 63
   }
54 64
   // 页面上拉触底
55 65
   onReachBottom = () => {
@@ -67,7 +77,21 @@ export default class Index extends Component {
67 77
       url: "/pages/mineSub/infoEdit/index",
68 78
     });
69 79
   };
70
-
80
+  // 分享店铺
81
+  handleShare = () => {
82
+    Taro.showShareMenu({
83
+      withShareTicket: true,
84
+      menus: ['shareAppMessage']
85
+    });
86
+  };
87
+  // 配置分享内容
88
+  onShareAppMessage() {
89
+    return {
90
+      title: "店铺",
91
+      path: `/pages/memberSub/storeManagement/index?shopId=${this.state.shopDetail.id}&isShare=true&isManager=false`,
92
+      imageUrl: ''
93
+    }
94
+  }
71 95
   render() {
72 96
     const { shopDetail, productList } = this.state;
73 97
     return (
@@ -76,10 +100,14 @@ export default class Index extends Component {
76 100
         <View className="header-card">
77 101
           <Image className="bg-image" src={storeManagement} mode="widthFix" />
78 102
           {/* 分享店铺 */}
103
+          {!this.state.isShare && (
79 104
           <View className="share-shop">
105
+            <Button onClick={this.handleShare} openType="share">
80 106
             <Text>分享店铺</Text>
81 107
             <AtIcon value="chevron-right" size="10" color="#fff"></AtIcon>
108
+            </Button>
82 109
           </View>
110
+          )}
83 111
           {/* 个人信息 */}
84 112
           <View className="user-info">
85 113
             <View onClick={this.handleChangeAvatar} className="avatar-wrapper">

+ 23 - 6
src/pages/memberSub/storeManagement/index.less

@@ -78,17 +78,13 @@
78 78
             top: 20px;
79 79
             right: 20px;
80 80
             z-index: 1;
81
-            display: flex;
82
-            align-items: center;
83
-            color: #FFFFFF;
84 81
             font-size: 14px;
85
-            justify-content: center;
86
-            align-items: center;
87 82
 
88 83
             Text {
89 84
                 font-size: 22px;
90 85
                 line-height: 40px;
91 86
                 margin-right: 7px;
87
+            color: #FFFFFF;
92 88
             }
93 89
         }
94 90
     }
@@ -181,4 +177,25 @@
181 177
                 }
182 178
         }
183 179
     }
184
-}
180
+}
181
+
182
+// 清除Button默认样式
183
+Button {
184
+    padding: 0;
185
+    margin: 0;
186
+    background: none;
187
+    border: none;
188
+    line-height: normal;
189
+    height: 100%;
190
+    width: 100%;
191
+    display: flex;
192
+    justify-content: center;
193
+    align-items: center;
194
+    &::after {
195
+      border: none;
196
+    }
197
+  }
198
+  .button-hover {
199
+    background-color: transparent !important; /* 移除背景高亮 */
200
+    box-shadow: none !important;             /* 移除可能的阴影 */
201
+  }

+ 21 - 0
src/service/index.js

@@ -22,6 +22,13 @@ export const getProductDetail = data =>
22 22
     method: 'POST',
23 23
     data,
24 24
   })
25
+// 咸鱼商品推广转链
26
+export const getProductPromotion = data =>
27
+  Request({
28
+    url: '/xianyu/xianyu_goods_link',
29
+    method: 'POST',
30
+    data,
31
+  })
25 32
 // 获取猜你喜欢列表
26 33
 export const getProductLikeList = data =>
27 34
   Request({
@@ -94,6 +101,20 @@ export const getMyShopList = data =>
94 101
     method: 'POST',
95 102
     data,
96 103
   })
104
+  // 非店长获取店铺详情
105
+export const getShareShopDetail = data =>
106
+  Request({
107
+    url: '/vip/get_not_oneself_store_detail',
108
+    method: 'POST',
109
+    data,
110
+  })
111
+  // 非店长获取店铺商品数据列表
112
+export const getShareShopProductList = data =>
113
+  Request({
114
+    url: '/vip/get_not_oneself_store_data_list',
115
+    method: 'POST',
116
+    data,
117
+  })
97 118
 // 店铺添加指定商品
98 119
 export const addShopProduct = data =>
99 120
   Request({