HW %!s(int64=4) %!d(string=hai) anos
pai
achega
796ac68f92

BIN=BIN
src/assets/images/audioPlay.png


BIN=BIN
src/assets/images/autioSuspend.png


BIN=BIN
src/assets/images/noData.png


+ 286 - 0
src/components/NavBar/index.js

@@ -0,0 +1,286 @@
+import _isFunction from 'lodash/isFunction';
+import { Component } from 'react';
+import Taro from '@tarojs/taro';
+import { View } from '@tarojs/components';
+import './index.scss';
+
+function getSystemInfo() {
+  if (Taro.globalSystemInfo && !Taro.globalSystemInfo.ios) {
+    return Taro.globalSystemInfo;
+  } else {
+    // h5环境下忽略navbar
+    if (!_isFunction(Taro.getSystemInfoSync)) {
+      return null;
+    }
+    let systemInfo = Taro.getSystemInfoSync() || {
+      model: '',
+      system: ''
+    };
+    let ios = !!(systemInfo.system.toLowerCase().search('ios') + 1);
+    let rect;
+    try {
+      rect = Taro.getMenuButtonBoundingClientRect ? Taro.getMenuButtonBoundingClientRect() : null;
+      if (rect === null) {
+        throw 'getMenuButtonBoundingClientRect error';
+      }
+      //取值为0的情况  有可能width不为0 top为0的情况
+      if (!rect.width || !rect.top || !rect.left || !rect.height) {
+        throw 'getMenuButtonBoundingClientRect error';
+      }
+    } catch (error) {
+      let gap = ''; //胶囊按钮上下间距 使导航内容居中
+      let width = 96; //胶囊的宽度
+      if (systemInfo.platform === 'android') {
+        gap = 8;
+        width = 96;
+      } else if (systemInfo.platform === 'devtools') {
+        if (ios) {
+          gap = 5.5; //开发工具中ios手机
+        } else {
+          gap = 7.5; //开发工具中android和其他手机
+        }
+      } else {
+        gap = 4;
+        width = 88;
+      }
+      if (!systemInfo.statusBarHeight) {
+        //开启wifi的情况下修复statusBarHeight值获取不到
+        systemInfo.statusBarHeight = systemInfo.screenHeight - systemInfo.windowHeight - 20;
+      }
+      rect = {
+        //获取不到胶囊信息就自定义重置一个
+        bottom: systemInfo.statusBarHeight + gap + 32,
+        height: 32,
+        left: systemInfo.windowWidth - width - 10,
+        right: systemInfo.windowWidth - 10,
+        top: systemInfo.statusBarHeight + gap,
+        width: width
+      };
+      console.log('error', error);
+      console.log('rect', rect);
+    }
+
+    let navBarHeight = '';
+    if (!systemInfo.statusBarHeight) {
+      //开启wifi和打电话下
+      systemInfo.statusBarHeight = systemInfo.screenHeight - systemInfo.windowHeight - 20;
+      navBarHeight = (function() {
+        let gap = rect.top - systemInfo.statusBarHeight;
+        return 2 * gap + rect.height;
+      })();
+
+      systemInfo.statusBarHeight = 0;
+      systemInfo.navBarExtendHeight = 0; //下方扩展4像素高度 防止下方边距太小
+    } else {
+      navBarHeight = (function() {
+        let gap = rect.top - systemInfo.statusBarHeight;
+        return systemInfo.statusBarHeight + 2 * gap + rect.height;
+      })();
+      if (ios) {
+        systemInfo.navBarExtendHeight = 4; //下方扩展4像素高度 防止下方边距太小
+      } else {
+        systemInfo.navBarExtendHeight = 0;
+      }
+    }
+
+    systemInfo.navBarHeight = navBarHeight; //导航栏高度不包括statusBarHeight
+    systemInfo.capsulePosition = rect; //右上角胶囊按钮信息bottom: 58 height: 32 left: 317 right: 404 top: 26 width: 87 目前发现在大多机型都是固定值 为防止不一样所以会使用动态值来计算nav元素大小
+    systemInfo.ios = ios; //是否ios
+    Taro.globalSystemInfo = systemInfo; //将信息保存到全局变量中,后边再用就不用重新异步获取了
+    //console.log('systemInfo', systemInfo);
+    return systemInfo;
+  }
+}
+let globalSystemInfo = getSystemInfo();
+class AtComponent extends Component {
+  constructor(props) {
+    super(props);
+    this.state = {
+      configStyle: this.setStyle(globalSystemInfo)
+    };
+  }
+  static options = {
+    multipleSlots: true,
+    addGlobalClass: true
+  };
+  componentDidShow() {
+    if (globalSystemInfo.ios) {
+      globalSystemInfo = getSystemInfo();
+      this.setState({
+        configStyle: this.setStyle(globalSystemInfo)
+      });
+    }
+  }
+  handleBackClick() {
+    if (_isFunction(this.props.onBack)) {
+      this.props.onBack();
+    } else {
+      const pages = Taro.getCurrentPages();
+      if (pages.length >= 2) {
+        Taro.navigateBack({
+          delta: this.props.delta
+        });
+      }
+    }
+  }
+  handleGoHomeClick() {
+    if (_isFunction(this.props.onHome)) {
+      this.props.onHome();
+    }
+  }
+  handleSearchClick() {
+    if (_isFunction(this.props.onSearch)) {
+      this.props.onSearch();
+    }
+  }
+  static defaultProps = {
+    extClass: '',
+    background: 'rgba(255,255,255,1)', //导航栏背景
+    color: '#000000',
+    title: '',
+    searchText: '点我搜索',
+    searchBar: false,
+    back: false,
+    home: false,
+    iconTheme: 'black',
+    delta: 1
+  };
+
+  state = {};
+
+  setStyle(systemInfo) {
+    const { statusBarHeight, navBarHeight, capsulePosition, navBarExtendHeight, ios, windowWidth } = systemInfo;
+    const { back, home, title, color } = this.props;
+    let rightDistance = windowWidth - capsulePosition.right; //胶囊按钮右侧到屏幕右侧的边距
+    let leftWidth = windowWidth - capsulePosition.left; //胶囊按钮左侧到屏幕右侧的边距
+
+    let navigationbarinnerStyle = [
+      `color:${color}`,
+      //`background:${background}`,
+      `height:${navBarHeight + navBarExtendHeight}px`,
+      `padding-top:${statusBarHeight}px`,
+      `padding-right:${leftWidth}px`,
+      `padding-bottom:${navBarExtendHeight}px`
+    ].join(';');
+    let navBarLeft = [];
+    if ((back && !home) || (!back && home)) {
+      navBarLeft = [
+        `width:${capsulePosition.width}px`,
+        `height:${capsulePosition.height}px`,
+        `margin-left:0px`,
+        `margin-right:${rightDistance}px`
+      ].join(';');
+    } else if ((back && home) || title) {
+      navBarLeft = [
+        `width:${capsulePosition.width}px`,
+        `height:${capsulePosition.height}px`,
+        `margin-left:${rightDistance}px`
+      ].join(';');
+    } else {
+      navBarLeft = [`width:auto`, `margin-left:0px`].join(';');
+    }
+    return {
+      navigationbarinnerStyle,
+      navBarLeft,
+      navBarHeight,
+      capsulePosition,
+      navBarExtendHeight,
+      ios,
+      rightDistance
+    };
+  }
+
+  render() {
+    const {
+      navigationbarinnerStyle,
+      navBarLeft,
+      navBarHeight,
+      capsulePosition,
+      navBarExtendHeight,
+      ios,
+      rightDistance
+    } = this.state.configStyle;
+    const {
+      title,
+      background,
+      backgroundColorTop,
+      back,
+      home,
+      searchBar,
+      searchText,
+      iconTheme,
+      extClass
+    } = this.props;
+    let nav_bar__center = null;
+    if (title) {
+      nav_bar__center = <text>{title}</text>;
+    } else if (searchBar) {
+      nav_bar__center = (
+        <View
+          className='lxy-nav-bar-search'
+          style={`height:${capsulePosition.height}px;`}
+          onClick={this.handleSearchClick.bind(this)}
+        >
+          <View className='lxy-nav-bar-search__icon' />
+          <View className='lxy-nav-bar-search__input'>{searchText}</View>
+        </View>
+      );
+    } else {
+      /* eslint-disable */
+      nav_bar__center = this.props.renderCenter;
+      /* eslint-enable */
+    }
+    return (
+      <View
+        className={`lxy-nav-bar ${ios ? 'ios' : 'android'} ${extClass}`}
+        style={`background: ${backgroundColorTop ? backgroundColorTop : background};height:${navBarHeight +
+          navBarExtendHeight}px;`}
+      >
+        <View
+          className={`lxy-nav-bar__placeholder ${ios ? 'ios' : 'android'}`}
+          style={`padding-top: ${navBarHeight + navBarExtendHeight}px;`}
+        />
+        <View
+          className={`lxy-nav-bar__inner ${ios ? 'ios' : 'android'}`}
+          style={`background:${background};${navigationbarinnerStyle};`}
+        >
+          <View className='lxy-nav-bar__left' style={navBarLeft}>
+            {back && !home && (
+              <View
+                onClick={this.handleBackClick.bind(this)}
+                className={`lxy-nav-bar__button lxy-nav-bar__btn_goback ${iconTheme}`}
+              />
+            )}
+            {!back && home && (
+              <View
+                onClick={this.handleGoHomeClick.bind(this)}
+                className={`lxy-nav-bar__button lxy-nav-bar__btn_gohome ${iconTheme}`}
+              />
+            )}
+            {back && home && (
+              <View className={`lxy-nav-bar__buttons ${ios ? 'ios' : 'android'}`}>
+                <View
+                  onClick={this.handleBackClick.bind(this)}
+                  className={`lxy-nav-bar__button lxy-nav-bar__btn_goback ${iconTheme}`}
+                />
+                <View
+                  onClick={this.handleGoHomeClick.bind(this)}
+                  className={`lxy-nav-bar__button lxy-nav-bar__btn_gohome ${iconTheme}}`}
+                />
+              </View>
+            )}
+            {!back && !home && this.props.renderLeft}
+          </View>
+          <View className='lxy-nav-bar__center' style={`padding-left: ${rightDistance}px`}>
+            {nav_bar__center}
+          </View>
+          <View className='lxy-nav-bar__right' style={`margin-right: ${rightDistance}px`}>
+            {this.props.renderRight}
+          </View>
+        </View>
+      </View>
+    );
+  }
+}
+
+export default AtComponent;

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 212 - 0
src/components/NavBar/index.scss


+ 48 - 0
src/components/common/listBottomStart/index.jsx

@@ -0,0 +1,48 @@
+import React,{Component} from "react";
+import {Image, View} from "@tarojs/components";
+import { AtActivityIndicator,AtDivider  } from 'taro-ui';
+import "taro-ui/dist/style/components/icon.scss";
+import "taro-ui/dist/style/components/divider.scss";
+import "taro-ui/dist/style/components/icon.scss";
+import './index.less';
+
+import noData from '../../../assets/images/noData.png';
+
+class ListBottomStart extends Component{
+  constructor(props) {
+    super(props);
+  }
+
+  render() {
+    const { state } = this.props;
+    return (
+      <View className='listBottomStartComponent'>
+        {
+          state === 'NO_MORE_DATA' ?
+            <View style={{width:'100%'}}>
+              <AtDivider content='没有更多了' fontColor='#999999' lineColor='#999999' />
+            </View>:
+          state === 'RELOAD' ?
+            <View className='reload'>
+              <View>加载失败</View>
+              <View className='operation' onClick={()=>{
+                this.props.reload && this.props.reload();
+              }}>点击重新加载</View>
+            </View>:
+            state === 'LOADING' ?
+              <View>
+                <AtActivityIndicator content='加载中...'/>
+              </View>:
+              state === 'NO_DATA' ?
+                <View className='noData'>
+                  <Image src={noData} className='noDataImg'/>
+                  <View className='noDataTitle'>暂时没有数据</View>
+                </View>
+            : null
+        }
+      </View>
+    )
+  }
+}
+
+export default ListBottomStart;

+ 28 - 0
src/components/common/listBottomStart/index.less

@@ -0,0 +1,28 @@
+.listBottomStartComponent{
+  display: flex;
+  justify-content: center;
+  padding: 10px 0 10px 0;
+  .reload{
+    display: flex;
+    flex-flow: row nowrap;
+    color: #999999;
+    .operation{
+      padding-left: 15px;
+      color: #4564DC;
+    }
+  }
+  .noData{
+    display: flex;
+    align-items: center;
+    justify-content: center;
+    flex-flow: column nowrap;
+    .noDataImg{
+      width: 200px;
+      height: 200px;
+    }
+    .noDataTitle{
+      color: #969696;
+      padding-top: 20px;
+    }
+  }
+}

BIN=BIN
src/custom-tab-bar/image/home.png


BIN=BIN
src/custom-tab-bar/image/icon_API.png


BIN=BIN
src/custom-tab-bar/image/icon_API_HL.png


BIN=BIN
src/custom-tab-bar/image/icon_component.png


BIN=BIN
src/custom-tab-bar/image/icon_component_HL.png


BIN=BIN
src/custom-tab-bar/image/user.png


+ 29 - 27
src/custom-tab-bar/index.jsx

@@ -3,10 +3,8 @@ import Taro from '@tarojs/taro';
 import { View , CoverImage,CoverView } from '@tarojs/components'
 import './index.less'
 
-import icon_component from './image/icon_component.png';
-import icon_component_HL from './image/icon_component_HL.png';
-import icon_API from './image/icon_API.png';
-import icon_API_HL from './image/icon_API_HL.png';
+import icon_home from './image/home.png';
+import icon_user from './image/user.png';
 import {connect} from "react-redux";
 import {add, asyncAdd, minus} from "../actions/counter";
 
@@ -32,20 +30,20 @@ class CustomTabBar extends Component{
       list: [
         {
           pagePath: "/pages/index/index",
-          iconPath: icon_component,
-          selectedIconPath: icon_component_HL,
+          iconPath: icon_home,
+          selectedIconPath: icon_home,
           text: "首页"
         },
-        {
-          pagePath: "/pages/index/index",
-          iconPath: icon_API,
-          selectedIconPath: icon_API_HL,
-          text: "课程"
-        },
+        // {
+        //   pagePath: "/pages/index/index",
+        //   iconPath: icon_API,
+        //   selectedIconPath: icon_API_HL,
+        //   text: "课程"
+        // },
         {
           pagePath: "/pages/user/index",
-          iconPath: icon_API,
-          selectedIconPath: icon_API_HL,
+          iconPath: icon_user,
+          selectedIconPath: icon_user,
           text: "我的"
         },
       ]
@@ -68,19 +66,23 @@ class CustomTabBar extends Component{
               <View key={key} className='tab-bar-item' dataPath={v.pagePath} dataIndex={key} onClick={()=>{
                 this.switchTab(v,key);
               }}>
-                {
-                  key !== 1 ?
-                    <>
-                      <CoverImage className='coverImage' src={this.props.counter.num === key ? v.selectedIconPath : v.iconPath}/>
-                      <View className='View'  style={{color:this.props.counter.num === key ? this.state.selectedColor : this.state.color}}>
-                        {v.text}
-                      </View>
-                    </>:
-                    <View className='zhong'>
-                      <CoverImage className='coverImage' src={this.props.counter.num === key ? v.selectedIconPath : v.iconPath}/>
-                      <View className='View'  style={{color:this.props.counter.num === key ? this.state.selectedColor : this.state.color}}>{v.text}</View>
-                    </View>
-                }
+                <CoverImage className='coverImage' src={this.props.counter.num === key ? v.selectedIconPath : v.iconPath}/>
+                <View className='View'  style={{color:this.props.counter.num === key ? this.state.selectedColor : this.state.color}}>
+                  {v.text}
+                </View>
+                {/*{*/}
+                {/*  key !== 1 ?*/}
+                {/*    <>*/}
+                {/*      <CoverImage className='coverImage' src={this.props.counter.num === key ? v.selectedIconPath : v.iconPath}/>*/}
+                {/*      <View className='View'  style={{color:this.props.counter.num === key ? this.state.selectedColor : this.state.color}}>*/}
+                {/*        {v.text}*/}
+                {/*      </View>*/}
+                {/*    </>:*/}
+                {/*    <View className='zhong'>*/}
+                {/*      <CoverImage className='coverImage' src={this.props.counter.num === key ? v.selectedIconPath : v.iconPath}/>*/}
+                {/*      <View className='View'  style={{color:this.props.counter.num === key ? this.state.selectedColor : this.state.color}}>{v.text}</View>*/}
+                {/*    </View>*/}
+                {/*}*/}
               </View >
             ))
           }

+ 4 - 4
src/custom-tab-bar/index.less

@@ -3,12 +3,13 @@
   bottom: 0;
   left: 0;
   right: 0;
-  height: 149px;
+  height: 132px;
   display: flex;
   padding-bottom: env(safe-area-inset-bottom);
   z-index: 9999999;
-  background: #00000000 url("./image/tabBarBackground.png") no-repeat;
-  background-size: 100% 100%;
+  background: #393484;
+  //background: #00000000 url("./image/tabBarBackground.png") no-repeat;
+  //background-size: 100% 100%;
   .tab-bar-border {
     background-color: rgba(0, 0, 0, 0.33);
     position: absolute;
@@ -31,7 +32,6 @@
   .tab-bar-item .coverImage {
     width: 44px;
     height: 44px;
-    padding-top: 48px;
   }
 
   .tab-bar-item .View {

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

@@ -1,7 +1,7 @@
 export default {
   navigationBarTitleText: '产品详情',
   enablePullDownRefresh: true,
-  backgroundColor: '#000',
+  backgroundColor: '#76D3FF',
   navigationBarBackgroundColor:'#77D4FF',
   navigationBarTextStyle:'white',
   usingComponents: {

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 121 - 144
src/pages/details/index.jsx


+ 50 - 0
src/pages/details/index.less

@@ -22,6 +22,46 @@
       width: 100%;
       .img{
         width: 100%;
+        display: block;
+      }
+      #video{
+        width: 100%;
+        display: block;
+      }
+      .audio{
+        position: relative;
+        .audioImg{
+          width: 100%;
+          display: block;
+        }
+        .operation{
+          position: absolute;
+          z-index: 1;
+          top: 0;
+          left: 0;
+          right: 0;
+          bottom: 0;
+          background: #00000085;
+          display: flex;
+          flex-flow: column nowrap;
+          align-items: center;
+          justify-content: center;
+          .play{
+            width: 100px;
+            height: 100px;
+          }
+          .suspend{
+            width: 100px;
+            height: 100px;
+          }
+          .atProgress{
+            position: absolute;
+            bottom: 0;
+            background: #ffffff8a;
+            width: 100%;
+            padding: 20px 20px;
+          }
+        }
       }
     }
     .infor{
@@ -35,6 +75,7 @@
         display: flex;
         flex-flow: row nowrap;
         justify-content: space-between;
+        align-items: center;
         padding-top: 19px;
         .introduceContent{
           color: #999999;
@@ -43,6 +84,15 @@
         .user{
           display: flex;
           flex-flow: row nowrap;
+          .typeName{
+            display: inline-block;
+            background: #EFF3FF;
+            border-radius: 2px;
+            font-size: 16px;
+            padding: 5px 7px;
+            color: #4564DC;
+            border: 1px #A7B6F1 solid;
+          }
           .avater{
              width: 18px;
              height: 18px;

+ 3 - 3
src/pages/index/index.config.js

@@ -1,11 +1,11 @@
 export default {
   navigationBarTitleText: '首页',
   enablePullDownRefresh: true,
-  // navigationStyle: 'custom',
+  navigationStyle: 'custom',
   navigationBarBackgroundColor:'#77D4FF',
   navigationBarTextStyle:'white',
-  backgroundColor: '#FFF',
-  onReachBottomDistance: 310,
+  backgroundColor: '#76D3FF',
+  onReachBottomDistance: 50,
   usingComponents: {
     "mp-html": "../../components/common/mp-weixin/index",
   }

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 71 - 124
src/pages/index/index.jsx


+ 28 - 9
src/pages/index/index.less

@@ -3,22 +3,36 @@
   min-height: 100vh;
   background: #F5F5F5;
   z-index: 1;
-  padding-bottom: 202px;
+  padding-bottom: 152px;
+  .NavBar{
+    .lxy-nav-bar__left{
+      display: none;
+    }
+    .lxy-nav-bar__center{
+      padding-left: 0 !important;
+      text{
+        padding-left: 25px !important;
+        margin-right: auto;
+        color: #FFFFFF;
+        font-size: 36px;
+      }
+    }
+  }
   .background{
     position: absolute;
     top: 0;
     z-index: -1;
     width: 100%;
-    height: 300px;
+    height: 400px;
   }
   .title{
     font-size: 37px;
     color: #393484;
     font-weight: bolder;
-    padding: 35px 0 30px 25px;
+    padding: 15px 0 30px 25px;
   }
   .list{
-    padding: 30px 23px 0 23px;
+    padding: 0 23px 0 23px;
     .item{
       border-radius: 6px;
       padding: 21px 11px 31px 57px;
@@ -27,7 +41,8 @@
       flex-flow: row nowrap;
       margin-bottom: 17px;
       .infor{
-        padding-right: 26px;
+        width: calc(100% - 260rpx);
+        margin-right: 26px;
         .name{
           font-size: 28px;
           color: #2F3742;
@@ -35,14 +50,16 @@
           line-height: 39px;
         }
         .createTimes{
-          display: inline;
-          background: #A1B1F0;
+          display: inline-block;
+          background: #EFF3FF;
           border-radius: 2px;
           font-size: 16px;
           margin-top: 19px;
           margin-bottom: 15px;
-          padding: 5px;
+          margin-left: 10px;
+          padding: 5px 7px;
           color: #4564DC;
+          border: 1px #A7B6F1 solid;
         }
         .amount{
           display: flex;
@@ -51,6 +68,7 @@
           font-size: 28px;
           font-weight: bolder;
           color: #FE3371;
+          padding-left: 35px;
           .money{
             padding-left: 10px;
             font-size: 20px;
@@ -58,7 +76,8 @@
         }
       }
       .thumbnailUrl{
-        width: 200px;
+        margin-bottom: 20px;
+        width: 234px;
         height: auto;
         margin-left: auto;
       }

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

@@ -2,7 +2,8 @@ export default {
   navigationBarTitleText: '我的',
   enablePullDownRefresh: true,
   navigationBarTextStyle:'white',
-  backgroundColor: '#FFF',
+  backgroundColor: '#76D3FF',
   navigationBarBackgroundColor:'#77D4FF',
   onReachBottomDistance: 310,
+  navigationStyle: 'custom',
 }

+ 78 - 119
src/pages/user/index.jsx

@@ -1,28 +1,20 @@
 import { Component } from 'react';
-import Taro,{getCurrentInstance} from '@tarojs/taro';
+import Taro from '@tarojs/taro';
 import { connect } from 'react-redux'
-import { View, Image, Video,Button,OpenData } from '@tarojs/components'
-import {add, minus, asyncAdd, set} from '../../actions/counter'
-import { Swiper, SwiperItem } from '@tarojs/components'
-import { AtTabs, AtTabsPane } from 'taro-ui'
+import { View, Image,OpenData } from '@tarojs/components'
+
+import {set} from '../../actions/counter'
+import { login,getUserOrderList } from '../../utils/servers/servers'
+import ListBottomStart from "../../components/common/listBottomStart";
+
 import './index.less'
-import IconFont from '../../components/iconfont';
-import API from '../../utils/API';
-import { login,getProjecList } from '../../utils/servers/servers'
+
 import background from "../../assets/images/background.png";
+import NavBar from "../../components/NavBar";
 
 @connect(({ counter }) => ({
   counter
 }), (dispatch) => ({
-  add () {
-    dispatch(add())
-  },
-  dec () {
-    dispatch(minus())
-  },
-  asyncAdd () {
-    dispatch(asyncAdd())
-  },
   set (value) {
     dispatch(set(value))
   }
@@ -34,135 +26,97 @@ class Index extends Component {
   constructor(props) {
     super(props);
     this.state={
-      pageNo:1,
       list: [],
+      pageNo: 0,
+      listState: 'LOADING',
     }
   }
 
-  componentWillReceiveProps (nextProps) {
-    console.log(this.props, nextProps)
-  }
-
-  componentWillUnmount () { }
-
   componentDidShow() {
     this.props.set(1);
   }
 
+  async componentDidMount() {
+    await this.login();
+    await this.getUserOrderList();
+  }
 
-  componentWillMount () {
-
+  onPullDownRefresh(){
+    this.getUserOrderList();
   }
 
-  componentDidHide () { }
+  onReachBottom(){
+    this.getUserOrderList(this.state.pageNo+1);
+  }
 
-  login(){
+  async login(){
     let token = Taro.getStorageSync('token');
     if(!token){
-      Taro.login({
-        success: function (res) {
-          if (res.code) {
-            login({code:res.code}).then(v => {
-              if(v.error.length === 0){
-                Taro.setStorageSync('token', v.token)
-              }else{
-                Taro.showToast({title:v.error[0].message,icon:'none'})
-              }
-            }).catch(err => {
-              Taro.showToast({title:'系统错误,请稍后重试',icon:'none'});
-              console.log(err)
-            })
-          } else {
-            Taro.showToast({title:res.errMsg,icon:'none'})
-            console.log('登录失败!' + res.errMsg)
+      let loginMsg = await Taro.login();
+      if (loginMsg.code) {
+        try{
+          let msg = await login({code:loginMsg.code});
+          if(msg.error.length === 0){
+            Taro.setStorageSync('token', msg.token)
+          }else{
+            Taro.showToast({title:msg.error[0].message,icon:'none'})
           }
+        }catch (err) {
+          Taro.showToast({title:'系统错误,请稍后重试',icon:'none'});
+          console.log(err)
         }
-      })
-    }
-  }
-
-  getUserInfor(){
-    // Taro.getUserProfile({
-    //   desc: '用于完善会员资料', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
-    //   success: (res) => {
-    //     console.log(res)
-    //   }
-    // })
-    Taro.getSetting({
-      success: (res)=>{
-        if (res.authSetting['scope.userInfo']) {
-          // 已经授权,可以直接调用 getUserInfo 获取头像昵称
-          Taro.getUserInfo({
-            success: function(res) {
-              console.log(res)
-            }
-          })
-        }else{
-          Taro.authorize({
-            scope: 'scope.userInfo',
-            success: ()=> {
-              // 用户已经同意小程序使用录音功能,后续调用 wx.startRecord 接口不会弹窗询问
-              Taro.getUserInfo({
-                success: function(res) {
-                  console.log(res)
-                }
-              })
-            }
-          })
-          console.log(11111)
-        }
-      },
-      fail: (err)=>{
-        console.log(err)
+      } else {
+        Taro.showToast({title:loginMsg.errMsg,icon:'none'})
+        console.log('登录失败!' + loginMsg.errMsg)
       }
-    })
-  }
-
-  getCode(){
-    let params = getCurrentInstance().router.params
-    console.log(Object.keys(params).length,'this.$router.params')
-    if(Object.keys(params).length === 0){
-      let encodeURI = encodeURIComponent('http://172.16.0.253:10086/#/pages/index/index');
-      let url = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxe99e0a402c1da6b0&redirect_uri=${encodeURI}&response_type=code&scope=snsapi_base&state=12580#wechat_redirect`;
-      window.location.href=url;
-    }else{0
-      console.log(params,'this.$router.params')
     }
   }
 
-  getProjecList (pageNo = 1){
-    getProjecList({
+  async getUserOrderList (pageNo = 1){
+    this.setState({
+      listState: 'LOADING'
+    })
+    let msg = await getUserOrderList({
       pageNo: pageNo,
       pageSize: 5,
-    }).then(v=>{
-      if(v.error.length === 0){
+    });
+    if(msg.error.length === 0){
+      if(msg.data.totalCount === this.state.list.length && pageNo !== 1){
+        Taro.showToast({title:'没有更多数据了',icon:'none'});
         this.setState({
-          list:pageNo === 1 ? v.data.list : this.state.list.concat(v.data.list),
-          pageNo: v.data.pageNo
+          listState: 'NO_MORE_DATA'
         })
       }else{
-        Taro.showToast({title:v.error[0].message,icon:'none'})
+        this.setState({
+          list:pageNo === 1 ? msg.data.list : this.state.list.concat(msg.data.list),
+          pageNo: msg.data.pageNo
+        },()=>{
+          if(msg.data.totalCount === this.state.list.length){
+            this.setState({
+              listState: 'NO_MORE_DATA'
+            })
+          }
+        })
       }
-      Taro.stopPullDownRefresh();
-    })
-  }
-
-  async componentDidMount() {
-    this.login();
-    await this.getProjecList();
-  }
-
-  onPullDownRefresh(){
-    this.getProjecList();
+    }else{
+      Taro.showToast({title:msg.error[0].message,icon:'none'});
+      this.setState({
+        listState: 'RELOAD'
+      })
+    }
+    Taro.stopPullDownRefresh();
   }
 
-  onReachBottom(){
-    this.getProjecList(this.state.pageNo+1);
-  }
 
   render () {
     return (
       <View className='userPage'>
+        <NavBar
+          extClass='NavBar'
+          title='我的'
+          background='#76D3FF'
+          onHome={()=>{}}
+        />
         <Image src={background} className='background'/>
         <View className='userInfor'>
           <View className='avatar'>
@@ -176,7 +130,7 @@ class Index extends Component {
           {this.state.list.map((v,k)=>(
             <View className='item' key={k} onClick={()=>{
               Taro.navigateTo({
-                url:'/pages/details/index?id='+v.id
+                url:'/pages/details/index?id='+v.projectId
               })
             }}>
               <View className='block'>
@@ -187,15 +141,20 @@ class Index extends Component {
                 </View>
               </View>
               <View className='infor'>
-                <View className='title'>高新培育课程</View>
-                <View className='content'>快速提高 项目奖励 </View>
+                <View className='title'>{v.projectName}</View>
+                <View className='content'>{v.projectTypeName}</View>
               </View>
               <View className='moneyInfor'>
-                <View className='money'>¥269</View>
-                <View className='time'>2021-05-01</View>
+                <View className='money'>¥{parseFloat(v.projectAmount)}</View>
+                <View className='time'>{v.createTimes}</View>
               </View>
             </View>
           ))}
+          <ListBottomStart
+            state={this.state.listState}
+            reload={()=>{
+              this.getUserOrderList(this.state.pageNo+1);
+            }}/>
         </View>
       </View>
     )

+ 22 - 3
src/pages/user/index.less

@@ -4,18 +4,32 @@
   background: #F5F5F5;
   z-index: 1;
   padding-bottom: 202px;
+  .NavBar{
+    .lxy-nav-bar__left{
+      display: none;
+    }
+    .lxy-nav-bar__center{
+      padding-left: 0 !important;
+      text{
+        padding-left: 25px !important;
+        margin-right: auto;
+        color: #FFFFFF;
+        font-size: 36px;
+      }
+    }
+  }
   .background{
     position: absolute;
     top: 0;
     z-index: -1;
     width: 100%;
-    height: 300px;
+    height: 400px;
   }
   .userInfor{
     display: flex;
     flex-flow: row nowrap;
     align-items: flex-start;
-    padding: 39px 0 36px 25px;
+    padding: 0px 0 36px 25px;
     .avatar{
       width: 104px;
       height: 104px;
@@ -70,7 +84,12 @@
         }
         .content{
           font-size: 18px;
-          color: #000000;
+          display: inline-block;
+          background: #EFF3FF;
+          border-radius: 2px;
+          padding: 5px 7px;
+          color: #4564DC;
+          border: 1px #A7B6F1 solid;
         }
       }
       .moneyInfor{

+ 2 - 0
src/utils/config.js

@@ -1 +1,3 @@
 export const resourceAddress = 'http://172.16.0.188:3000/upload/'
+// export const resourceAddress = 'http://kedejs.jishutao.com//upload/'
+

+ 2 - 2
src/utils/servers/baseUrl.js

@@ -2,10 +2,10 @@ const getBaseUrl = (url) => {
   let BASE_URL = '';
   if (process.env.NODE_ENV === 'development') {
     //开发环境 - 根据请求不同返回不同的BASE_URL
-    BASE_URL = 'http://172.16.0.188:8088'
+    BASE_URL = 'https://www.kedexinxi.com'
   } else {
     // 生产环境
-    BASE_URL = 'http://172.16.0.188:8088'
+    BASE_URL = 'https://www.kedexinxi.com'
   }
   return BASE_URL
 }

+ 3 - 2
src/utils/servers/config.js

@@ -9,5 +9,6 @@ export const HTTP_STATUS = {
   SERVER_ERROR: 500,
   BAD_GATEWAY: 502,
   SERVICE_UNAVAILABLE: 503,
-  GATEWAY_TIMEOUT: 504
-}
+  GATEWAY_TIMEOUT: 504,
+  NO_PERMISSION: 302,         //无权限
+}

+ 1 - 1
src/utils/servers/http.js

@@ -19,7 +19,7 @@ class httpRequest {
       header: {
         'content-type': contentType,
         'Authorization': Taro.getStorageSync('Authorization'),
-      }
+      },
     };
     return Taro.request(option);
   }

+ 7 - 4
src/utils/servers/interceptors.js

@@ -7,7 +7,7 @@ const customInterceptor = (chain) => {
   const requestParams = chain.requestParams
 
   return chain.proceed(requestParams).then(res => {
-    // console.log(res,'proceed')
+    console.log(res,'proceed')
     // 只要请求成功,不管返回什么状态码,都走这个回调
     if (res.statusCode === HTTP_STATUS.NOT_FOUND) {
       return Promise.reject("请求资源不存在")
@@ -15,11 +15,11 @@ const customInterceptor = (chain) => {
     } else if (res.statusCode === HTTP_STATUS.BAD_GATEWAY) {
       return Promise.reject("服务端出现了问题")
 
-    } else if (res.statusCode === HTTP_STATUS.FORBIDDEN) {
+    } else if (res.statusCode === HTTP_STATUS.FORBIDDEN || res.statusCode === HTTP_STATUS.NO_PERMISSION) {
       Taro.setStorageSync("token", "")
       pageToLogin()
       // TODO 根据自身业务修改
-      return Promise.reject("没有权限访问,请重新登录");
+      return;
 
     } else if (res.statusCode === HTTP_STATUS.AUTHENTICATE) {
       Taro.setStorageSync("Authorization", "")
@@ -27,8 +27,11 @@ const customInterceptor = (chain) => {
       return Promise.reject("需要鉴权")
 
     } else if (res.statusCode === HTTP_STATUS.SUCCESS) {
+      if(res.data.error.length !== 0 && res.data.error[0].field === '403'){
+        Taro.setStorageSync("token", "")
+        pageToLogin()
+      }
       return res.data
-
     }
   })
 }

+ 7 - 1
src/utils/servers/servers.js

@@ -13,7 +13,7 @@ export const pay = (postData) => {
 
 //撤销支付
 export const payClose = (postData) => {
-  return HTTPREQUEST.get('/wxClose', postData)
+  return HTTPREQUEST.get('/api/user/wxClose', postData)
 }
 
 //产品列表
@@ -21,6 +21,12 @@ export const getProjecList = (postData) => {
   return HTTPREQUEST.get('/open/projectList', postData)
 }
 
+//用户产品列表
+export const getUserOrderList = (postData) => {
+  return HTTPREQUEST.get('/api/user/order/list', postData)
+}
+
+
 //产品详情
 export const getSelectProject = (postData) => {
   return HTTPREQUEST.get('/open/selectProject', postData)

+ 27 - 5
src/utils/servers/utils.js

@@ -1,4 +1,5 @@
-import Taro from "@tarojs/taro";
+import Taro,{getCurrentPages} from "@tarojs/taro";
+import { login } from '../../utils/servers/servers'
 /**
  * @description 获取当前页url
  */
@@ -9,11 +10,32 @@ export const getCurrentPageUrl = () => {
   return url
 };
 
-export const pageToLogin = () => {
+export const pageToLogin = async () => {
   let path = getCurrentPageUrl()
   if (!path.includes('login')) {
-    Taro.navigateTo({
-      url: "/pages/login/login"
-    });
+    setTimeout(async ()=>{
+      Taro.showLoading({title: '重新登录中...',})
+      setTimeout(async ()=>{
+        let loginMsg = await Taro.login();
+        if (loginMsg.code) {
+          try{
+            let msg = await login({code:loginMsg.code});
+            if(msg.error.length === 0){
+              Taro.setStorageSync('token', msg.token);
+              Taro.showToast({title:'登录成功',icon:'success'});
+              Taro.startPullDownRefresh();
+            }else{
+              Taro.showToast({title:msg.error[0].message,icon:'none'})
+            }
+          }catch (err) {
+            Taro.showToast({title:'系统错误,请稍后重试',icon:'none'});
+          }
+        } else {
+          Taro.showToast({title:loginMsg.errMsg,icon:'none'})
+        }
+        Taro.hideLoading();
+      },800)
+    },800)
+
   }
 }