Explorar o código

剩余接口对接&&第一版鱼市小程序

viczhq hai 1 semana
pai
achega
443b3166fc

+ 29 - 8
project.private.config.json

@@ -3,13 +3,41 @@
3 3
   "projectname": "%E9%B1%BC%E5%B8%82",
4 4
   "setting": {
5 5
     "compileHotReLoad": false,
6
-    "urlCheck": false
6
+    "urlCheck": true
7 7
   },
8 8
   "libVersion": "3.6.4",
9 9
   "condition": {
10 10
     "miniprogram": {
11 11
       "list": [
12 12
         {
13
+          "name": "pages/mineSub/userSpecification/index",
14
+          "pathName": "pages/mineSub/userSpecification/index",
15
+          "query": "",
16
+          "launchMode": "default",
17
+          "scene": null
18
+        },
19
+        {
20
+          "name": "pages/indexSub/searchList/index",
21
+          "pathName": "pages/indexSub/searchList/index",
22
+          "query": "keyword=鞋",
23
+          "launchMode": "default",
24
+          "scene": null
25
+        },
26
+        {
27
+          "name": "pages/search/index",
28
+          "pathName": "pages/search/index",
29
+          "query": "",
30
+          "launchMode": "default",
31
+          "scene": null
32
+        },
33
+        {
34
+          "name": "pages/infoEdit/index",
35
+          "pathName": "pages/mineSub/infoEdit/index",
36
+          "query": "id=100",
37
+          "launchMode": "default",
38
+          "scene": null
39
+        },
40
+        {
13 41
           "name": "pages/mineSub/login/index",
14 42
           "pathName": "pages/mineSub/login/index",
15 43
           "query": "",
@@ -52,13 +80,6 @@
52 80
           "scene": null
53 81
         },
54 82
         {
55
-          "name": "pages/infoEdit/index",
56
-          "pathName": "pages/indexSub/productDetail/index",
57
-          "query": "id=100",
58
-          "launchMode": "default",
59
-          "scene": null
60
-        },
61
-        {
62 83
           "name": "pages/productManagement/index",
63 84
           "pathName": "pages/productManagement/index",
64 85
           "query": "",

+ 14 - 12
src/api/request.js

@@ -16,7 +16,7 @@ export default async (options = { method: 'GET', data: {} }) => {
16 16
   const request_data = {
17 17
     session_key: Taro.getStorageSync('session_key') || '', // 缓存取值
18 18
     appid: getAppId(),
19
-    channel_name:'WeChat'
19
+    channel_name: 'WeChat'
20 20
   };
21 21
 
22 22
   // 如果是登录接口,移除 session_key
@@ -37,8 +37,7 @@ export default async (options = { method: 'GET', data: {} }) => {
37 37
       },
38 38
       method: options.method.toUpperCase(),
39 39
     });
40
-
41
-    const { code, data, msg } = res.data;
40
+    const { code,data, msg } = res.data;
42 41
     switch (code) {
43 42
       case 200:
44 43
         return data;
@@ -62,24 +61,27 @@ export default async (options = { method: 'GET', data: {} }) => {
62 61
           icon: 'none',
63 62
           mask: true,
64 63
         });
65
-        const app = Taro.getApp()
64
+        
66 65
         // 获取当前跳转到登录的页面路径
67
-        const currentPage = Taro.getCurrentPages();
68
-        // 储存当前页面路径
69
-        Taro.setStorageSync('currentPage', currentPage[currentPage.length - 1].route);// 存储页面路径
70
-        // 储存当前页面数据
71
-        app.updateOptionsData(currentPage[currentPage.length - 1].options);// 更新页面数据
66
+        const currentPages = Taro.getCurrentPages();
67
+        const currentPage = currentPages[currentPages.length - 1];
68
+        if (currentPage) {
69
+          // 储存当前页面路径
70
+          Taro.setStorageSync('currentPage', currentPage.route);
71
+          global.globalData.optionsData = currentPage.options || {};
72
+        }
73
+        
72 74
         Taro.reLaunch({
73
-          url: '/pages/mineSub/login/index',
75
+          url: '/pages/login/index',
74 76
         });
75
-        throw new Error('需要登录');
77
+        // throw new Error('需要登录');
76 78
       default:
77 79
         Taro.showToast({
78 80
           title: `${msg || '请求失败'}`,
79 81
           icon: 'none',
80 82
           mask: true,
81 83
         });
82
-        throw new Error(msg || '请求失败');
84
+        // throw new Error(msg || '请求失败');
83 85
     }
84 86
   } catch (error) {
85 87
     console.error('请求错误:', error);

+ 4 - 3
src/app.config.js

@@ -4,6 +4,7 @@ export default defineAppConfig({
4 4
     'pages/member/index',
5 5
     "pages/mine/index",
6 6
     "pages/search/index",
7
+    "pages/login/index"
7 8
   ],
8 9
   subpackages: [
9 10
     {
@@ -11,7 +12,8 @@ export default defineAppConfig({
11 12
       pages: [
12 13
         "productDetail/index",
13 14
         "seckillIndex/index",
14
-        "searchList/index"
15
+        "searchList/index",
16
+        "highCommission/index"
15 17
       ]
16 18
     },
17 19
     {
@@ -32,8 +34,7 @@ export default defineAppConfig({
32 34
       root: "pages/mineSub",
33 35
       pages: [
34 36
         "infoEdit/index",
35
-        "userSpecification/index",
36
-        "login/index"
37
+        "userSpecification/index"
37 38
       ]
38 39
     },
39 40
   ],

+ 5 - 6
src/app.js

@@ -3,15 +3,14 @@ import Taro from '@tarojs/taro'
3 3
 import './app.less'
4 4
 import 'taro-ui/dist/style/index.scss'
5 5
 
6
+// 在 App 类外定义全局变量
7
+global.globalData = {
8
+  optionsData: {}  // 存储页面参数
9
+}
10
+
6 11
 class App extends Component {
7 12
   state = {
8 13
     userInfo: Taro.getStorageSync('userInfo') || {},// 用户信息
9
-    optionsData: {},// 未登录页面跳转数据
10
-  }
11
-
12
-  // 新增方法:更新 optionsData
13
-  updateOptionsData = (data) => {
14
-    this.setState({ optionsData: data });
15 14
   }
16 15
 
17 16
   componentDidMount () {

+ 3 - 0
src/components/index/OperationArea/index.jsx

@@ -10,6 +10,9 @@ const OperationArea = ({ recommend }) => {
10 10
         url: "/pages/indexSub/seckillIndex/index",
11 11
       });
12 12
     } else if (type === "高佣专项") {
13
+      Taro.navigateTo({
14
+        url: "/pages/indexSub/highCommission/index",
15
+      });
13 16
     }
14 17
   };
15 18
 

+ 10 - 4
src/components/index/SearchBar/index.jsx

@@ -2,14 +2,19 @@ import { View, Input } from '@tarojs/components'
2 2
 import { AtIcon } from 'taro-ui'
3 3
 import { Component } from 'react'
4 4
 import './index.less'
5
-
6 5
 export default class SearchBar extends Component {
7 6
   handleChange = (e) => {
8
-    this.props.onChange && this.props.onChange(e)
7
+    const value = e.detail.value;
8
+    this.props.onChange && this.props.onChange(value);
9
+  }
10
+  handleSearch = () => {
11
+    const searchValue = this.props.value || '';
12
+    // 触发父组件传入的 onSearch 方法
13
+    this.props.onSearch && this.props.onSearch(searchValue);
9 14
   }
10 15
 
11 16
   render () {
12
-    const { value, placeholder } = this.props
17
+    const { value = '', placeholder = '点击搜索商品', disabled } = this.props
13 18
 
14 19
     return (
15 20
         <View className="search-wrap">
@@ -26,8 +31,9 @@ export default class SearchBar extends Component {
26 31
             placeholder={placeholder}
27 32
             value={value}
28 33
             onInput={this.handleChange.bind(this)}
34
+            disabled={disabled}
29 35
           />
30
-          <View className="search-button">搜索</View>
36
+          <View onClick={this.handleSearch} className="search-button">搜索</View>
31 37
         </View>
32 38
       </View>
33 39
     )

+ 5 - 23
src/pages/index/index.jsx

@@ -14,22 +14,8 @@ import backTopIcon from "../../images/index/back-top.png";
14 14
 
15 15
 export default class Index extends Component {
16 16
   state = {
17
-    value: "",
18 17
     current: 0, // 添加当前选中的tab索引
19 18
     homeData: {}, // 首页数据
20
-    tabList: [
21
-      // 添加模拟的tab数据
22
-      { title: "推荐" },
23
-      { title: "男装" },
24
-      { title: "女装" },
25
-      { title: "运动" },
26
-      { title: "数码" },
27
-      { title: "美妆" },
28
-      { title: "箱包" },
29
-      { title: "家居" },
30
-      { title: "食品" },
31
-      { title: "母婴" },
32
-    ],
33 19
     bannerList: [],
34 20
     productList: [], // 添加商品列表
35 21
     page: 1, // 添加页码
@@ -46,15 +32,12 @@ export default class Index extends Component {
46 32
       this.getProductList(true);
47 33
     });
48 34
   };
49
-  // 搜索框值改变
50
-  handleChange(value) {
51
-    this.setState({ value });
52
-  }
53 35
   // 修改 tab 切换处理函数
54 36
   handleClick(value) {
55 37
     this.setState(
56 38
       {
57 39
         current: value,
40
+        page: 1,
58 41
       },
59 42
       () => {
60 43
         // 跳转到列表顶部
@@ -104,8 +87,7 @@ export default class Index extends Component {
104 87
     const { page } = this.state;
105 88
     this.setState({ loading: true });
106 89
     const res = await getProductList({
107
-      // tag_name:  this.state.homeData.tags[this.state.current].title,
108
-      tag_name:'首页',
90
+      tag_name:  this.state.homeData.tags[this.state.current].title,
109 91
       page,
110 92
       page_size: 10,
111 93
     });
@@ -140,9 +122,9 @@ export default class Index extends Component {
140 122
             onClick={() => Taro.navigateTo({ url: '/pages/search/index' })}
141 123
           >
142 124
             <SearchBar
143
-              value={this.state.value}
144
-              onChange={this.handleChange}
145
-              onSearch={this.handleSearch}
125
+              value=""
126
+              disabled={true}
127
+              placeholder="点击搜索商品"
146 128
             />
147 129
           </View>
148 130
           {/* tab分类 */}

+ 3 - 0
src/pages/indexSub/highCommission/index.config.js

@@ -0,0 +1,3 @@
1
+export default definePageConfig({
2
+  navigationBarTitleText: '高佣专项'
3
+})

+ 59 - 0
src/pages/indexSub/highCommission/index.jsx

@@ -0,0 +1,59 @@
1
+import { Component } from "react";
2
+import { View, Image } from "@tarojs/components";
3
+import "./index.less";
4
+import seckillImg from "../../../images/seckill/seckillTop.png";
5
+import ProductList from "../../../components/index/ProductList";
6
+import { getRecommendProductList } from "../../../service";
7
+export default class Index extends Component {
8
+  state = {
9
+    productList: [], //推荐商品列表
10
+    page: 1, //页数
11
+    loading: false, //加载状态
12
+    totalPages: 1, // 添加总页数
13
+  };
14
+  componentDidMount() {
15
+    this.getRecommendProductList();
16
+  }
17
+  // 获取推荐商品列表
18
+  getRecommendProductList = async () => {
19
+    const { page } = this.state;
20
+    this.setState({ loading: true });
21
+
22
+    const res = await getRecommendProductList({
23
+      tag_id: 121,
24
+      page,
25
+      page_size: 10,
26
+    });
27
+
28
+    this.setState((prevState) => ({
29
+      productList: [...prevState.productList, ...res.goods_list],
30
+      totalPages: res.total_pages,
31
+      loading: false,
32
+    }));
33
+  };
34
+  // 页面上拉触底
35
+  onReachBottom = () => {
36
+    const { page, totalPages, loading } = this.state;
37
+    if (page < totalPages && !loading) {
38
+      this.setState(
39
+        (prevState) => ({ page: prevState.page + 1 }),
40
+        () => this.getRecommendProductList()
41
+      );
42
+    }
43
+  };
44
+  render() {
45
+    return (
46
+      <View className="index">
47
+        <Image className="seckill" src={seckillImg} mode="aspectFill" />
48
+        {/* 商品列表 */}
49
+        <View className="product-list">
50
+          <ProductList
51
+            isSeckill={true}
52
+            productList={this.state.productList}
53
+            loading={this.state.loading}
54
+          />
55
+        </View>
56
+      </View>
57
+    );
58
+  }
59
+}

+ 13 - 0
src/pages/indexSub/highCommission/index.less

@@ -0,0 +1,13 @@
1
+.index{
2
+    width: 100%;
3
+    padding-bottom: 40px;
4
+    box-sizing: border-box;
5
+    .seckill{
6
+        width: 100%;
7
+        height: 300px;
8
+        background-color: yellow;
9
+    }
10
+    .product-list{
11
+        margin-top: -71px;
12
+    }
13
+}

+ 47 - 2
src/pages/indexSub/searchList/index.jsx

@@ -3,13 +3,58 @@ import Taro from "@tarojs/taro";
3 3
 import { View } from "@tarojs/components";
4 4
 import "./index.less";
5 5
 import ProductList from "../../../components/index/ProductList";
6
+import { getSearchProductList } from "../../../service";
6 7
 export default class Index extends Component {
7
-  state = {};
8
+  state = {
9
+    productList: [],
10
+    page: 1,
11
+    totalPages: 1,
12
+    loading: false,
13
+    keyword: "",
14
+  };
15
+  componentDidMount() {
16
+    const { keyword }  = Taro.getCurrentInstance().router.params||"";
17
+    this.setState({ keyword }, () => {
18
+      this.getSearchProductList(true);
19
+    });
20
+  }
21
+  // 获取商品列表
22
+  getSearchProductList = async (isAdd = false) => {
23
+    const { page } = this.state;
24
+    this.setState({ loading: true });
25
+
26
+    const res = await getSearchProductList({
27
+      search_name: this.state.keyword,
28
+      page,
29
+      page_size: 10,
30
+    });
31
+
32
+    this.setState((prevState) => ({
33
+      productList: isAdd
34
+        ? res.goods_list
35
+        : [...prevState.productList, ...res.goods_list],
36
+      totalPages: res.total_pages,
37
+      loading: false,
38
+    }));
39
+  };
40
+  // 页面上拉触底
41
+  onReachBottom = () => {
42
+    const { page, totalPages, loading } = this.state;
43
+    if (page < totalPages && !loading) {
44
+      this.setState(
45
+        (prevState) => ({ page: prevState.page + 1 }),
46
+        () => this.getSearchProductList()
47
+      );
48
+    }
49
+  };
8 50
   render() {
9 51
     return (
10 52
       <View className="index">
11 53
         {/* 搜索列表 */}
12
-        <ProductList></ProductList>
54
+        <ProductList
55
+          productList={this.state.productList}
56
+          loading={this.state.loading}
57
+        ></ProductList>
13 58
       </View>
14 59
     );
15 60
   }

src/pages/mineSub/login/index.config.js → src/pages/login/index.config.js


+ 11 - 13
src/pages/mineSub/login/index.jsx

@@ -2,11 +2,11 @@ import { Component } from "react";
2 2
 import { View, Image, Button, Checkbox } from "@tarojs/components";
3 3
 import Taro from "@tarojs/taro";
4 4
 import { AtCheckbox } from "taro-ui";
5
-import { login,getUserInfo } from "../../../service";
6
-import { objToParam } from "../../../common/toParams";
5
+import { login,getUserInfo } from "../../service";
6
+import { objToParam } from "../../common/toParams";
7 7
 import "./index.less";
8
-import logo1 from "../../../images/logo1.png";
9
-import loginBg from "../../../images/loginBg.png";
8
+import logo1 from "../../images/logo1.png";
9
+import loginBg from "../../images/loginBg.png";
10 10
 export default class Index extends Component {
11 11
   state = {
12 12
     isChecked: false,
@@ -60,18 +60,16 @@ export default class Index extends Component {
60 60
               getUserInfo().then(res => {
61 61
                 Taro.setStorageSync('userInfo', res)
62 62
               })
63
-              // let lastPage = Taro.getStorageSync('currentPage')
64
-              // if (lastPage == 'pages/mineSub/login/index') {
65
-              //   lastPage = 'pages/index/index'
66
-              // }
63
+              let lastPage = Taro.getStorageSync('currentPage')
64
+              if (lastPage == 'pages/mineSub/login/index') {
65
+                lastPage = 'pages/index/index'
66
+              }
67 67
               setTimeout(() => {
68
-                // Taro.reLaunch({
69
-                //   url: `/${lastPage}?${objToParam(Taro.getStorageSync('optionsData'))}`
70
-                // })
71
-                // Taro.removeStorageSync('currentPage')
72 68
                 Taro.reLaunch({
73
-                  url: '/pages/index/index',
69
+                  url: `/${lastPage}?${objToParam(Taro.getStorageSync('optionsData'))}`
74 70
                 })
71
+                Taro.removeStorageSync('currentPage')
72
+                global.globalData.optionsData = {}
75 73
               }, 1000)
76 74
             });
77 75
           },

src/pages/mineSub/login/index.less → src/pages/login/index.less


+ 66 - 33
src/pages/member/index.jsx

@@ -1,7 +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
+import { getVipInfo } from "../../service";
5 5
 import Taro from "@tarojs/taro";
6 6
 import "./index.less";
7 7
 import vip from "../../images/member/vip.png";
@@ -12,27 +12,37 @@ import withdrawable from "../../images/member/withdrawable.png";
12 12
 import order from "../../images/member/order.png";
13 13
 import avatar from "../../images/mine/avatar.png";
14 14
 export default class Index extends Component {
15
-  state={
16
-    vipInfo:{},//会员信息 
17
-  }
15
+  state = {
16
+    vipInfo: {
17
+      users: { name: "去登录", icon: avatar },
18
+      earnings: { store_earnings_now: 0, store_earnings_all: 0 },
19
+      draw_money: { store_earnings_now: 0 },
20
+      order: { order_all: 0, order_promotion: 0, order_pay: 0 },
21
+    }, //会员信息
22
+  };
18 23
   // 获取会员首页数据
19
-  getVipInfo = async () =>{
20
-    const res = await getVipInfo()
24
+  getVipInfo = async () => {
25
+    const res = await getVipInfo();
21 26
     this.setState({
22
-      vipInfo: res || {
23
-        users: { name: "未登录", icon: avatar },
24
-        earnings: { store_earnings_now: 0, store_earnings_all: 0 },
25
-        draw_money: { store_earnings_now: 0 },
26
-        order: { order_all: 0, order_promotion: 0, order_pay: 0 }
27
-      }
28
-    })
29
-  }
27
+      vipInfo: res,
28
+    });
29
+  };
30
+  // 去登录
31
+  Login = () => {
32
+    if (!Taro.getStorageSync("session_key")) {
33
+      Taro.reLaunch({
34
+        url: "/pages/login/index",
35
+      });
36
+    }
37
+  };
30 38
   componentDidShow() {
31
-    this.getVipInfo() //获取会员首页数据
39
+    if (Taro.getStorageSync("session_key")) {
40
+      this.getVipInfo(); //获取会员首页数据
41
+    }
32 42
   }
33 43
 
34 44
   render() {
35
-    const {vipInfo} = this.state
45
+    const { vipInfo } = this.state;
36 46
     return (
37 47
       <View className="member">
38 48
         <View className="member-bg"></View>
@@ -40,9 +50,15 @@ export default class Index extends Component {
40 50
           {/* 会员信息卡 */}
41 51
           <View className="member-info-card">
42 52
             <View className="member-info-card-header">
43
-              {vipInfo.users && <Image className="avatar" src={vipInfo.users.icon} mode="aspectFill" />}
53
+              <Image
54
+                className="avatar"
55
+                src={vipInfo.users.icon}
56
+                mode="aspectFill"
57
+              />
58
+
44 59
               <View className="member-info-card-header-text">
45
-                {vipInfo.users && <Text className="user-name">{vipInfo.users.name}</Text>}
60
+                <Text onClick={this.Login} className="user-name">{vipInfo.users.name}</Text>
61
+
46 62
                 <View className="member-info-card-header-text-level">
47 63
                   <Text className="level-text">店长</Text>
48 64
                   <Image className="level-icon" src={vip} />
@@ -50,30 +66,43 @@ export default class Index extends Component {
50 66
               </View>
51 67
             </View>
52 68
             {/* 我的小店 */}
53
-            <View onClick={() => Taro.navigateTo({ url: `/pages/memberSub/storeManagement/index?isManager=${true}` })} className="my-shop">
69
+            <View
70
+              onClick={() =>
71
+                Taro.navigateTo({
72
+                  url: `/pages/memberSub/storeManagement/index?isManager=${true}`,
73
+                })
74
+              }
75
+              className="my-shop"
76
+            >
54 77
               <Image className="my-shop-icon" src={home} />
55 78
               <View className="my-shop-text">我的小店</View>
56 79
             </View>
57 80
           </View>
58 81
           {/* 预估收益 */}
59
-          {vipInfo.earnings && <View className="estimated-income">
82
+
83
+          <View className="estimated-income">
60 84
             <Text className="estimated-income-title">预估收益</Text>
61 85
             <View className="estimated-income-content">
62 86
               <View className="income-item">
63
-                <Text className="amount">{vipInfo.earnings.store_earnings_now}</Text>
87
+                <Text className="amount">
88
+                  {vipInfo.earnings.store_earnings_now}
89
+                </Text>
64 90
                 <Text className="label">今日预估收益</Text>
65 91
               </View>
66 92
               <View className="divider"></View>
67 93
               <View className="income-item">
68
-                <Text className="amount">{vipInfo.earnings.store_earnings_all}</Text>
94
+                <Text className="amount">
95
+                  {vipInfo.earnings.store_earnings_all}
96
+                </Text>
69 97
                 <Text className="label">累计收益</Text>
70 98
               </View>
71 99
             </View>
72
-            <view onClick={() => Taro.navigateTo({ url: `/pages/memberSub/earningsDetail/index` })} className="estimated-income-detail">
100
+            {/* <view onClick={() => Taro.navigateTo({ url: `/pages/memberSub/earningsDetail/index` })} className="estimated-income-detail">
73 101
               收益详情
74 102
               <Image className="to-detail" src={toDetail} />
75
-            </view>
76
-            </View>}
103
+            </view> */}
104
+          </View>
105
+
77 106
           {/* 可提现金额 */}
78 107
           <View className="withdrawable-amount">
79 108
             <View className="withdrawable-amount-header">
@@ -82,13 +111,16 @@ export default class Index extends Component {
82 111
             </View>
83 112
             <View className="withdrawable-amount-content">
84 113
               <View className="left">
85
-                {vipInfo.draw_money && <Text className="amount">¥{vipInfo.draw_money.store_earnings_now}</Text>}
86
-                <View className="warning-icon-box">
114
+                <Text className="amount">
115
+                  ¥{vipInfo.draw_money.store_earnings_now}
116
+                </Text>
117
+
118
+                {/* <View className="warning-icon-box">
87 119
                   <Image className="warning-icon" src={warning} />
88 120
                   <Text className="warning-text">未完成提现认证</Text>
89
-                </View>
121
+                </View> */}
90 122
               </View>
91
-              <View onClick={() => Taro.navigateTo({ url: `/pages/memberSub/cashOut/index` })} className="right">点击提现</View>
123
+              {/* <View onClick={() => Taro.navigateTo({ url: `/pages/memberSub/cashOut/index` })} className="right">点击提现</View> */}
92 124
             </View>
93 125
           </View>
94 126
           {/* 今日订单 */}
@@ -98,12 +130,13 @@ export default class Index extends Component {
98 130
                 <Image className="today-order-icon" src={order} />
99 131
                 <Text className="today-order-title">今日订单</Text>
100 132
               </View>
101
-              <View onClick={() => Taro.navigateTo({ url: `/pages/memberSub/earningsOrder/index` })} className="today-order-header-right">
133
+              {/* <View onClick={() => Taro.navigateTo({ url: `/pages/memberSub/earningsOrder/index` })} className="today-order-header-right">
102 134
                 历史订单
103 135
                 <AtIcon value='chevron-right' size='10' color='#A1A1A1'></AtIcon>
104
-              </View>
136
+              </View> */}
105 137
             </View>
106
-            {vipInfo.order && <View className="today-order-content">
138
+
139
+            <View className="today-order-content">
107 140
               <View className="order-item">
108 141
                 <Text className="label">订单总量</Text>
109 142
                 <Text className="amount">{vipInfo.order.order_all}</Text>
@@ -116,7 +149,7 @@ export default class Index extends Component {
116 149
                 <Text className="label">购买历史</Text>
117 150
                 <Text className="amount">{vipInfo.order.order_pay}</Text>
118 151
               </View>
119
-            </View>}
152
+            </View>
120 153
           </View>
121 154
         </View>
122 155
       </View>

+ 21 - 11
src/pages/memberSub/productClassify/index.jsx

@@ -4,36 +4,36 @@ 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 } from "../../../service";
7
+import { getBrowseShopProductList,addShopProduct,getAllTags } from "../../../service";
8 8
 export default class Index extends Component {
9 9
   state = {
10 10
     current: 0, // 当前选中的标签页索引
11 11
     tabList: [
12
-      { title: "全部商品" },
13
-      { title: "选项2" },
14
-      { title: "选项3" },
15
-      { title: "选项4" },
16 12
     ], // 标签页列表
17 13
     productList: [], // 商品列表
18 14
     page: 1, //页数
19 15
     loading: false, //加载状态
20 16
     totalPages: 1, // 添加总页数
17
+    tabList: [], // 所有闲鱼tags
21 18
   };
22 19
   handleClick(value) {
23 20
     this.setState({
24 21
       current: value,
22
+      page: 1,
23
+    },()=>{
24
+      this.getBrowseShopProductList(true);
25 25
     });
26 26
   }
27 27
   componentDidMount() {
28
-    this.getBrowseShopProductList();
28
+    this.getAllTags();
29 29
   }
30 30
   // 获取商品列表
31 31
   getBrowseShopProductList = async (isAdd=false) => {
32 32
     const { page } = this.state;
33 33
     this.setState({ loading: true });
34
-
34
+    
35 35
     const res = await getBrowseShopProductList({
36
-      tag_name: "",
36
+      tag_name:this.state.tabList[this.state.current].title,
37 37
       page,
38 38
       page_size: 10,
39 39
     });
@@ -44,13 +44,24 @@ export default class Index extends Component {
44 44
       loading: false,
45 45
     }));
46 46
   };
47
+  // 获取所有闲鱼tags
48
+  getAllTags = async () => {
49
+    let res = await getAllTags();
50
+    res = res.map((item, index) => ({
51
+      title: item.name,
52
+    }));
53
+    this.setState({
54
+      tabList: res,
55
+    },()=>{
56
+      this.getBrowseShopProductList(true);
57
+    });
58
+  }
47 59
   // 添加商品
48 60
   onAddProduct = (productId) => {
49 61
     addShopProduct({
50 62
       goods_ids: [productId],
51 63
     }).then(res => {
52 64
       if(res.success==true){
53
-        // this.getBrowseShopProductList(true);
54 65
         this.setState((prevState) => ({
55 66
           productList: prevState.productList.map(item => {
56 67
             if(item.id === productId){
@@ -59,8 +70,6 @@ export default class Index extends Component {
59 70
             return item;
60 71
           })
61 72
         }));
62
-        console.log(this.state.productList);
63
-        
64 73
         Taro.showToast({
65 74
           title: '添加成功',
66 75
           icon: 'none',
@@ -82,6 +91,7 @@ export default class Index extends Component {
82 91
     return (
83 92
       <View className="index">
84 93
         <AtTabs
94
+          scroll
85 95
           current={this.state.current}
86 96
           tabList={this.state.tabList}
87 97
           onClick={this.handleClick.bind(this)}

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

@@ -7,6 +7,7 @@ import {
7 7
   getMyShopList,
8 8
   deleteShopProduct,
9 9
   updateProductSort,
10
+  getAllTags
10 11
 } from "../../../service";
11 12
 import ProductList from "../../../components/index/ProductList"; //商品列表
12 13
 import add from "../../../images/productManagement/add.png";
@@ -21,9 +22,9 @@ export default class Index extends Component {
21 22
     isManagementStatus: false, //是否是管理状态
22 23
     current: 0, //tabs坐标
23 24
     isSelectAll: false, //是否全选
24
-    selectedOption: "全部商品", //商品默认名称
25
+    selectedOption: "首页", //商品默认名称
25 26
     tabList: [{ title: "在售中 (0)" }], //tabs标题
26
-    options: ["全部商品", "选项2", "选项3"], //商品下拉选项
27
+    options: ["首页"], //商品下拉选项
27 28
     checkedList: [""], //全选
28 29
     checkboxOption: [
29 30
       {
@@ -36,9 +37,20 @@ export default class Index extends Component {
36 37
     loading: false, //加载状态
37 38
     totalPages: 1, // 添加总页数
38 39
     selectedProducts: [], // 删除商品选中id数组
40
+    tags: [], // 所有闲鱼tags
39 41
   };
40 42
   componentDidShow() {
41
-    this.getMyShopList(true);
43
+    this.getAllTags();
44
+  }
45
+  // 获取所有闲鱼tags
46
+  getAllTags = async () => {
47
+    const res = await getAllTags();
48
+    const arr = Object.values(res).map(item => item.name);
49
+    this.setState({
50
+      options: arr,
51
+    },()=>{
52
+      this.getMyShopList(true);
53
+    });
42 54
   }
43 55
   // 获取商品列表
44 56
   getMyShopList = async (isDelete) => {
@@ -46,7 +58,7 @@ export default class Index extends Component {
46 58
     this.setState({ loading: true });
47 59
 
48 60
     const res = await getMyShopList({
49
-      tag_name: "",
61
+      tag_name: this.state.selectedOption,
50 62
       page,
51 63
       page_size: 10,
52 64
     });
@@ -66,16 +78,12 @@ export default class Index extends Component {
66 78
       }
67 79
     );
68 80
   };
69
-  // tabs切换
70
-  handleClick(value) {
71
-    this.setState({
72
-      current: value,
73
-    });
74
-  }
75 81
   // 商品下拉选项
76 82
   handleSelectOption = (e) => {
77 83
     const selectedOption = this.state.options[e.detail.value];
78
-    this.setState({ selectedOption });
84
+    this.setState({ selectedOption, page: 1 },()=>{
85
+      this.getMyShopList(true);
86
+    });
79 87
   };
80 88
   // 切换管理状态
81 89
   changeManagement = (type) => {

+ 9 - 1
src/pages/mine/index.jsx

@@ -50,6 +50,14 @@ export default class Index extends Component {
50 50
       userInfo: res,
51 51
     });
52 52
   };
53
+  // 去登录
54
+  Login = () => {   
55
+    if (!Taro.getStorageSync("session_key")) {
56
+      Taro.reLaunch({
57
+        url: "/pages/login/index",
58
+      });
59
+    }
60
+  };
53 61
   render() {
54 62
     const { userInfo } = this.state;
55 63
     return (
@@ -59,7 +67,7 @@ export default class Index extends Component {
59 67
           <Image src={userInfo.icon?userInfo.icon:avatar} className="avatar" />
60 68
           <View className="info-right">
61 69
             <View className="user-info">
62
-              <View className="name">{userInfo.name?userInfo.name:'未登录'}</View>
70
+              <View onClick={this.Login} className="name">{userInfo.name?userInfo.name:'去登录'}</View>
63 71
               <View className="account">{userInfo.id?userInfo.id:'XXXX'}</View>
64 72
             </View>
65 73
             <Image

+ 16 - 14
src/pages/mineSub/userSpecification/index.jsx

@@ -1,23 +1,25 @@
1 1
 import { Component } from 'react'
2
-import { View, Text } from '@tarojs/components'
2
+import { View, RichText } from '@tarojs/components'
3 3
 import './index.less'
4
-
4
+import { getUserAgreement } from '../../../service'
5 5
 export default class Index extends Component {
6
-
7
-  componentWillMount () { }
8
-
9
-  componentDidMount () { }
10
-
11
-  componentWillUnmount () { }
12
-
13
-  componentDidShow () { }
14
-
15
-  componentDidHide () { }
16
-
6
+  state = {
7
+    agreement: ''
8
+  }
9
+  componentDidMount () { 
10
+    this.getUserAgreement()
11
+  }
12
+  // 获取用户协议
13
+  getUserAgreement = async () => {
14
+    const res = await getUserAgreement()
15
+    this.setState({
16
+      agreement: res.content
17
+    })
18
+  }
17 19
   render () {
18 20
     return (
19 21
       <View className='index'>
20
-        <Text>用户规范</Text>
22
+        {this.state.agreement && <RichText nodes={this.state.agreement} />}
21 23
       </View>
22 24
     )
23 25
   }

+ 4 - 0
src/pages/mineSub/userSpecification/index.less

@@ -0,0 +1,4 @@
1
+.index {
2
+  padding: 20rpx;
3
+  background-color: #f5f5f5;
4
+}

+ 18 - 0
src/pages/search/index.jsx

@@ -5,6 +5,22 @@ import SearchBar from "../../components/index/SearchBar"; //搜索框
5 5
 import "./index.less";
6 6
 export default class Index extends Component {
7 7
   state = {};
8
+  handleSearch = (value) => {
9
+    if (value.trim() === '') {
10
+      Taro.showToast({
11
+        title: '请输入搜索内容',
12
+        icon: 'none'
13
+      })
14
+      return;
15
+    }else{
16
+      Taro.navigateTo({
17
+        url: `/pages/indexSub/searchList/index?keyword=${value}`
18
+      })
19
+    }
20
+  }
21
+  handleChange = (value) => {
22
+    this.setState({ value });  // 更新状态
23
+  }
8 24
   render() {
9 25
     return (
10 26
       <View className="index">
@@ -13,6 +29,8 @@ export default class Index extends Component {
13 29
           value={this.state.value}
14 30
           onChange={this.handleChange}
15 31
           onSearch={this.handleSearch}
32
+          placeholder="搜索商品"
33
+          disabled={false}
16 34
         />
17 35
       </View>
18 36
     );

+ 21 - 1
src/service/index.js

@@ -36,7 +36,20 @@ export const getRecommendProductList = data =>
36 36
     method: 'POST',
37 37
     data,
38 38
   })
39
-
39
+// 获取所有闲鱼tags
40
+export const getAllTags = data =>
41
+  Request({
42
+    url: '/api/get_all_xianyu_tags',
43
+    method: 'POST',
44
+    data,
45
+  })
46
+// 获取搜索商品列表
47
+export const getSearchProductList = data =>
48
+  Request({
49
+    url: '/api/get_goods_search',
50
+    method: 'POST',
51
+    data,
52
+  })
40 53
 // -----------------------用户
41 54
 // 获取用户详情
42 55
 export const getUserInfo = data =>
@@ -52,6 +65,13 @@ export const updateUserInfo = data =>
52 65
     method: 'POST',
53 66
     data,
54 67
   })
68
+// 获取用户规范
69
+export const getUserAgreement = data =>
70
+  Request({
71
+    url: '/user/get_user_agreement',
72
+    method: 'POST',
73
+    data,
74
+  })
55 75
 // ---------------------会员
56 76
 // 获取会员详情
57 77
 export const getVipInfo = data =>