Browse Source

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

viczhq 1 week ago
parent
commit
443b3166fc

+ 29 - 8
project.private.config.json

@@ -3,13 +3,41 @@
3
   "projectname": "%E9%B1%BC%E5%B8%82",
3
   "projectname": "%E9%B1%BC%E5%B8%82",
4
   "setting": {
4
   "setting": {
5
     "compileHotReLoad": false,
5
     "compileHotReLoad": false,
6
-    "urlCheck": false
6
+    "urlCheck": true
7
   },
7
   },
8
   "libVersion": "3.6.4",
8
   "libVersion": "3.6.4",
9
   "condition": {
9
   "condition": {
10
     "miniprogram": {
10
     "miniprogram": {
11
       "list": [
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
           "name": "pages/mineSub/login/index",
41
           "name": "pages/mineSub/login/index",
14
           "pathName": "pages/mineSub/login/index",
42
           "pathName": "pages/mineSub/login/index",
15
           "query": "",
43
           "query": "",
@@ -52,13 +80,6 @@
52
           "scene": null
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
           "name": "pages/productManagement/index",
83
           "name": "pages/productManagement/index",
63
           "pathName": "pages/productManagement/index",
84
           "pathName": "pages/productManagement/index",
64
           "query": "",
85
           "query": "",

+ 14 - 12
src/api/request.js

@@ -16,7 +16,7 @@ export default async (options = { method: 'GET', data: {} }) => {
16
   const request_data = {
16
   const request_data = {
17
     session_key: Taro.getStorageSync('session_key') || '', // 缓存取值
17
     session_key: Taro.getStorageSync('session_key') || '', // 缓存取值
18
     appid: getAppId(),
18
     appid: getAppId(),
19
-    channel_name:'WeChat'
19
+    channel_name: 'WeChat'
20
   };
20
   };
21
 
21
 
22
   // 如果是登录接口,移除 session_key
22
   // 如果是登录接口,移除 session_key
@@ -37,8 +37,7 @@ export default async (options = { method: 'GET', data: {} }) => {
37
       },
37
       },
38
       method: options.method.toUpperCase(),
38
       method: options.method.toUpperCase(),
39
     });
39
     });
40
-
41
-    const { code, data, msg } = res.data;
40
+    const { code,data, msg } = res.data;
42
     switch (code) {
41
     switch (code) {
43
       case 200:
42
       case 200:
44
         return data;
43
         return data;
@@ -62,24 +61,27 @@ export default async (options = { method: 'GET', data: {} }) => {
62
           icon: 'none',
61
           icon: 'none',
63
           mask: true,
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
         Taro.reLaunch({
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
       default:
78
       default:
77
         Taro.showToast({
79
         Taro.showToast({
78
           title: `${msg || '请求失败'}`,
80
           title: `${msg || '请求失败'}`,
79
           icon: 'none',
81
           icon: 'none',
80
           mask: true,
82
           mask: true,
81
         });
83
         });
82
-        throw new Error(msg || '请求失败');
84
+        // throw new Error(msg || '请求失败');
83
     }
85
     }
84
   } catch (error) {
86
   } catch (error) {
85
     console.error('请求错误:', error);
87
     console.error('请求错误:', error);

+ 4 - 3
src/app.config.js

@@ -4,6 +4,7 @@ export default defineAppConfig({
4
     'pages/member/index',
4
     'pages/member/index',
5
     "pages/mine/index",
5
     "pages/mine/index",
6
     "pages/search/index",
6
     "pages/search/index",
7
+    "pages/login/index"
7
   ],
8
   ],
8
   subpackages: [
9
   subpackages: [
9
     {
10
     {
@@ -11,7 +12,8 @@ export default defineAppConfig({
11
       pages: [
12
       pages: [
12
         "productDetail/index",
13
         "productDetail/index",
13
         "seckillIndex/index",
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
       root: "pages/mineSub",
34
       root: "pages/mineSub",
33
       pages: [
35
       pages: [
34
         "infoEdit/index",
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
 import './app.less'
3
 import './app.less'
4
 import 'taro-ui/dist/style/index.scss'
4
 import 'taro-ui/dist/style/index.scss'
5
 
5
 
6
+// 在 App 类外定义全局变量
7
+global.globalData = {
8
+  optionsData: {}  // 存储页面参数
9
+}
10
+
6
 class App extends Component {
11
 class App extends Component {
7
   state = {
12
   state = {
8
     userInfo: Taro.getStorageSync('userInfo') || {},// 用户信息
13
     userInfo: Taro.getStorageSync('userInfo') || {},// 用户信息
9
-    optionsData: {},// 未登录页面跳转数据
10
-  }
11
-
12
-  // 新增方法:更新 optionsData
13
-  updateOptionsData = (data) => {
14
-    this.setState({ optionsData: data });
15
   }
14
   }
16
 
15
 
17
   componentDidMount () {
16
   componentDidMount () {

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

@@ -10,6 +10,9 @@ const OperationArea = ({ recommend }) => {
10
         url: "/pages/indexSub/seckillIndex/index",
10
         url: "/pages/indexSub/seckillIndex/index",
11
       });
11
       });
12
     } else if (type === "高佣专项") {
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
 import { AtIcon } from 'taro-ui'
2
 import { AtIcon } from 'taro-ui'
3
 import { Component } from 'react'
3
 import { Component } from 'react'
4
 import './index.less'
4
 import './index.less'
5
-
6
 export default class SearchBar extends Component {
5
 export default class SearchBar extends Component {
7
   handleChange = (e) => {
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
   render () {
16
   render () {
12
-    const { value, placeholder } = this.props
17
+    const { value = '', placeholder = '点击搜索商品', disabled } = this.props
13
 
18
 
14
     return (
19
     return (
15
         <View className="search-wrap">
20
         <View className="search-wrap">
@@ -26,8 +31,9 @@ export default class SearchBar extends Component {
26
             placeholder={placeholder}
31
             placeholder={placeholder}
27
             value={value}
32
             value={value}
28
             onInput={this.handleChange.bind(this)}
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
         </View>
37
         </View>
32
       </View>
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
 export default class Index extends Component {
15
 export default class Index extends Component {
16
   state = {
16
   state = {
17
-    value: "",
18
     current: 0, // 添加当前选中的tab索引
17
     current: 0, // 添加当前选中的tab索引
19
     homeData: {}, // 首页数据
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
     bannerList: [],
19
     bannerList: [],
34
     productList: [], // 添加商品列表
20
     productList: [], // 添加商品列表
35
     page: 1, // 添加页码
21
     page: 1, // 添加页码
@@ -46,15 +32,12 @@ export default class Index extends Component {
46
       this.getProductList(true);
32
       this.getProductList(true);
47
     });
33
     });
48
   };
34
   };
49
-  // 搜索框值改变
50
-  handleChange(value) {
51
-    this.setState({ value });
52
-  }
53
   // 修改 tab 切换处理函数
35
   // 修改 tab 切换处理函数
54
   handleClick(value) {
36
   handleClick(value) {
55
     this.setState(
37
     this.setState(
56
       {
38
       {
57
         current: value,
39
         current: value,
40
+        page: 1,
58
       },
41
       },
59
       () => {
42
       () => {
60
         // 跳转到列表顶部
43
         // 跳转到列表顶部
@@ -104,8 +87,7 @@ export default class Index extends Component {
104
     const { page } = this.state;
87
     const { page } = this.state;
105
     this.setState({ loading: true });
88
     this.setState({ loading: true });
106
     const res = await getProductList({
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
       page,
91
       page,
110
       page_size: 10,
92
       page_size: 10,
111
     });
93
     });
@@ -140,9 +122,9 @@ export default class Index extends Component {
140
             onClick={() => Taro.navigateTo({ url: '/pages/search/index' })}
122
             onClick={() => Taro.navigateTo({ url: '/pages/search/index' })}
141
           >
123
           >
142
             <SearchBar
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
           </View>
129
           </View>
148
           {/* tab分类 */}
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
 import { View } from "@tarojs/components";
3
 import { View } from "@tarojs/components";
4
 import "./index.less";
4
 import "./index.less";
5
 import ProductList from "../../../components/index/ProductList";
5
 import ProductList from "../../../components/index/ProductList";
6
+import { getSearchProductList } from "../../../service";
6
 export default class Index extends Component {
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
   render() {
50
   render() {
9
     return (
51
     return (
10
       <View className="index">
52
       <View className="index">
11
         {/* 搜索列表 */}
53
         {/* 搜索列表 */}
12
-        <ProductList></ProductList>
54
+        <ProductList
55
+          productList={this.state.productList}
56
+          loading={this.state.loading}
57
+        ></ProductList>
13
       </View>
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
 import { View, Image, Button, Checkbox } from "@tarojs/components";
2
 import { View, Image, Button, Checkbox } from "@tarojs/components";
3
 import Taro from "@tarojs/taro";
3
 import Taro from "@tarojs/taro";
4
 import { AtCheckbox } from "taro-ui";
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
 import "./index.less";
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
 export default class Index extends Component {
10
 export default class Index extends Component {
11
   state = {
11
   state = {
12
     isChecked: false,
12
     isChecked: false,
@@ -60,18 +60,16 @@ export default class Index extends Component {
60
               getUserInfo().then(res => {
60
               getUserInfo().then(res => {
61
                 Taro.setStorageSync('userInfo', res)
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
               setTimeout(() => {
67
               setTimeout(() => {
68
-                // Taro.reLaunch({
69
-                //   url: `/${lastPage}?${objToParam(Taro.getStorageSync('optionsData'))}`
70
-                // })
71
-                // Taro.removeStorageSync('currentPage')
72
                 Taro.reLaunch({
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
               }, 1000)
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
 import { Component } from "react";
1
 import { Component } from "react";
2
 import { View, Text, Image } from "@tarojs/components";
2
 import { View, Text, Image } from "@tarojs/components";
3
 import { AtIcon } from "taro-ui";
3
 import { AtIcon } from "taro-ui";
4
-import {getVipInfo} from '../../service'
4
+import { getVipInfo } from "../../service";
5
 import Taro from "@tarojs/taro";
5
 import Taro from "@tarojs/taro";
6
 import "./index.less";
6
 import "./index.less";
7
 import vip from "../../images/member/vip.png";
7
 import vip from "../../images/member/vip.png";
@@ -12,27 +12,37 @@ import withdrawable from "../../images/member/withdrawable.png";
12
 import order from "../../images/member/order.png";
12
 import order from "../../images/member/order.png";
13
 import avatar from "../../images/mine/avatar.png";
13
 import avatar from "../../images/mine/avatar.png";
14
 export default class Index extends Component {
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
     this.setState({
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
   componentDidShow() {
38
   componentDidShow() {
31
-    this.getVipInfo() //获取会员首页数据
39
+    if (Taro.getStorageSync("session_key")) {
40
+      this.getVipInfo(); //获取会员首页数据
41
+    }
32
   }
42
   }
33
 
43
 
34
   render() {
44
   render() {
35
-    const {vipInfo} = this.state
45
+    const { vipInfo } = this.state;
36
     return (
46
     return (
37
       <View className="member">
47
       <View className="member">
38
         <View className="member-bg"></View>
48
         <View className="member-bg"></View>
@@ -40,9 +50,15 @@ export default class Index extends Component {
40
           {/* 会员信息卡 */}
50
           {/* 会员信息卡 */}
41
           <View className="member-info-card">
51
           <View className="member-info-card">
42
             <View className="member-info-card-header">
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
               <View className="member-info-card-header-text">
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
                 <View className="member-info-card-header-text-level">
62
                 <View className="member-info-card-header-text-level">
47
                   <Text className="level-text">店长</Text>
63
                   <Text className="level-text">店长</Text>
48
                   <Image className="level-icon" src={vip} />
64
                   <Image className="level-icon" src={vip} />
@@ -50,30 +66,43 @@ export default class Index extends Component {
50
               </View>
66
               </View>
51
             </View>
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
               <Image className="my-shop-icon" src={home} />
77
               <Image className="my-shop-icon" src={home} />
55
               <View className="my-shop-text">我的小店</View>
78
               <View className="my-shop-text">我的小店</View>
56
             </View>
79
             </View>
57
           </View>
80
           </View>
58
           {/* 预估收益 */}
81
           {/* 预估收益 */}
59
-          {vipInfo.earnings && <View className="estimated-income">
82
+
83
+          <View className="estimated-income">
60
             <Text className="estimated-income-title">预估收益</Text>
84
             <Text className="estimated-income-title">预估收益</Text>
61
             <View className="estimated-income-content">
85
             <View className="estimated-income-content">
62
               <View className="income-item">
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
                 <Text className="label">今日预估收益</Text>
90
                 <Text className="label">今日预估收益</Text>
65
               </View>
91
               </View>
66
               <View className="divider"></View>
92
               <View className="divider"></View>
67
               <View className="income-item">
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
                 <Text className="label">累计收益</Text>
97
                 <Text className="label">累计收益</Text>
70
               </View>
98
               </View>
71
             </View>
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
               <Image className="to-detail" src={toDetail} />
102
               <Image className="to-detail" src={toDetail} />
75
-            </view>
76
-            </View>}
103
+            </view> */}
104
+          </View>
105
+
77
           {/* 可提现金额 */}
106
           {/* 可提现金额 */}
78
           <View className="withdrawable-amount">
107
           <View className="withdrawable-amount">
79
             <View className="withdrawable-amount-header">
108
             <View className="withdrawable-amount-header">
@@ -82,13 +111,16 @@ export default class Index extends Component {
82
             </View>
111
             </View>
83
             <View className="withdrawable-amount-content">
112
             <View className="withdrawable-amount-content">
84
               <View className="left">
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
                   <Image className="warning-icon" src={warning} />
119
                   <Image className="warning-icon" src={warning} />
88
                   <Text className="warning-text">未完成提现认证</Text>
120
                   <Text className="warning-text">未完成提现认证</Text>
89
-                </View>
121
+                </View> */}
90
               </View>
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
             </View>
124
             </View>
93
           </View>
125
           </View>
94
           {/* 今日订单 */}
126
           {/* 今日订单 */}
@@ -98,12 +130,13 @@ export default class Index extends Component {
98
                 <Image className="today-order-icon" src={order} />
130
                 <Image className="today-order-icon" src={order} />
99
                 <Text className="today-order-title">今日订单</Text>
131
                 <Text className="today-order-title">今日订单</Text>
100
               </View>
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
                 <AtIcon value='chevron-right' size='10' color='#A1A1A1'></AtIcon>
135
                 <AtIcon value='chevron-right' size='10' color='#A1A1A1'></AtIcon>
104
-              </View>
136
+              </View> */}
105
             </View>
137
             </View>
106
-            {vipInfo.order && <View className="today-order-content">
138
+
139
+            <View className="today-order-content">
107
               <View className="order-item">
140
               <View className="order-item">
108
                 <Text className="label">订单总量</Text>
141
                 <Text className="label">订单总量</Text>
109
                 <Text className="amount">{vipInfo.order.order_all}</Text>
142
                 <Text className="amount">{vipInfo.order.order_all}</Text>
@@ -116,7 +149,7 @@ export default class Index extends Component {
116
                 <Text className="label">购买历史</Text>
149
                 <Text className="label">购买历史</Text>
117
                 <Text className="amount">{vipInfo.order.order_pay}</Text>
150
                 <Text className="amount">{vipInfo.order.order_pay}</Text>
118
               </View>
151
               </View>
119
-            </View>}
152
+            </View>
120
           </View>
153
           </View>
121
         </View>
154
         </View>
122
       </View>
155
       </View>

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

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

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

@@ -7,6 +7,7 @@ import {
7
   getMyShopList,
7
   getMyShopList,
8
   deleteShopProduct,
8
   deleteShopProduct,
9
   updateProductSort,
9
   updateProductSort,
10
+  getAllTags
10
 } from "../../../service";
11
 } from "../../../service";
11
 import ProductList from "../../../components/index/ProductList"; //商品列表
12
 import ProductList from "../../../components/index/ProductList"; //商品列表
12
 import add from "../../../images/productManagement/add.png";
13
 import add from "../../../images/productManagement/add.png";
@@ -21,9 +22,9 @@ export default class Index extends Component {
21
     isManagementStatus: false, //是否是管理状态
22
     isManagementStatus: false, //是否是管理状态
22
     current: 0, //tabs坐标
23
     current: 0, //tabs坐标
23
     isSelectAll: false, //是否全选
24
     isSelectAll: false, //是否全选
24
-    selectedOption: "全部商品", //商品默认名称
25
+    selectedOption: "首页", //商品默认名称
25
     tabList: [{ title: "在售中 (0)" }], //tabs标题
26
     tabList: [{ title: "在售中 (0)" }], //tabs标题
26
-    options: ["全部商品", "选项2", "选项3"], //商品下拉选项
27
+    options: ["首页"], //商品下拉选项
27
     checkedList: [""], //全选
28
     checkedList: [""], //全选
28
     checkboxOption: [
29
     checkboxOption: [
29
       {
30
       {
@@ -36,9 +37,20 @@ export default class Index extends Component {
36
     loading: false, //加载状态
37
     loading: false, //加载状态
37
     totalPages: 1, // 添加总页数
38
     totalPages: 1, // 添加总页数
38
     selectedProducts: [], // 删除商品选中id数组
39
     selectedProducts: [], // 删除商品选中id数组
40
+    tags: [], // 所有闲鱼tags
39
   };
41
   };
40
   componentDidShow() {
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
   getMyShopList = async (isDelete) => {
56
   getMyShopList = async (isDelete) => {
@@ -46,7 +58,7 @@ export default class Index extends Component {
46
     this.setState({ loading: true });
58
     this.setState({ loading: true });
47
 
59
 
48
     const res = await getMyShopList({
60
     const res = await getMyShopList({
49
-      tag_name: "",
61
+      tag_name: this.state.selectedOption,
50
       page,
62
       page,
51
       page_size: 10,
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
   handleSelectOption = (e) => {
82
   handleSelectOption = (e) => {
77
     const selectedOption = this.state.options[e.detail.value];
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
   changeManagement = (type) => {
89
   changeManagement = (type) => {

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

@@ -50,6 +50,14 @@ export default class Index extends Component {
50
       userInfo: res,
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
   render() {
61
   render() {
54
     const { userInfo } = this.state;
62
     const { userInfo } = this.state;
55
     return (
63
     return (
@@ -59,7 +67,7 @@ export default class Index extends Component {
59
           <Image src={userInfo.icon?userInfo.icon:avatar} className="avatar" />
67
           <Image src={userInfo.icon?userInfo.icon:avatar} className="avatar" />
60
           <View className="info-right">
68
           <View className="info-right">
61
             <View className="user-info">
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
               <View className="account">{userInfo.id?userInfo.id:'XXXX'}</View>
71
               <View className="account">{userInfo.id?userInfo.id:'XXXX'}</View>
64
             </View>
72
             </View>
65
             <Image
73
             <Image

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

@@ -1,23 +1,25 @@
1
 import { Component } from 'react'
1
 import { Component } from 'react'
2
-import { View, Text } from '@tarojs/components'
2
+import { View, RichText } from '@tarojs/components'
3
 import './index.less'
3
 import './index.less'
4
-
4
+import { getUserAgreement } from '../../../service'
5
 export default class Index extends Component {
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
   render () {
19
   render () {
18
     return (
20
     return (
19
       <View className='index'>
21
       <View className='index'>
20
-        <Text>用户规范</Text>
22
+        {this.state.agreement && <RichText nodes={this.state.agreement} />}
21
       </View>
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
 import "./index.less";
5
 import "./index.less";
6
 export default class Index extends Component {
6
 export default class Index extends Component {
7
   state = {};
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
   render() {
24
   render() {
9
     return (
25
     return (
10
       <View className="index">
26
       <View className="index">
@@ -13,6 +29,8 @@ export default class Index extends Component {
13
           value={this.state.value}
29
           value={this.state.value}
14
           onChange={this.handleChange}
30
           onChange={this.handleChange}
15
           onSearch={this.handleSearch}
31
           onSearch={this.handleSearch}
32
+          placeholder="搜索商品"
33
+          disabled={false}
16
         />
34
         />
17
       </View>
35
       </View>
18
     );
36
     );

+ 21 - 1
src/service/index.js

@@ -36,7 +36,20 @@ export const getRecommendProductList = data =>
36
     method: 'POST',
36
     method: 'POST',
37
     data,
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
 export const getUserInfo = data =>
55
 export const getUserInfo = data =>
@@ -52,6 +65,13 @@ export const updateUserInfo = data =>
52
     method: 'POST',
65
     method: 'POST',
53
     data,
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
 export const getVipInfo = data =>
77
 export const getVipInfo = data =>