소스 검색

增加手机号绑定
增加直播接入

HW 4 년 전
부모
커밋
8bd383065e

+ 1 - 0
package.json

@@ -41,6 +41,7 @@
     "@tarojs/react": "3.1.4",
     "@tarojs/runtime": "3.1.4",
     "@tarojs/taro": "3.1.4",
+    "dayjs": "^1.10.4",
     "mp-html": "^2.1.0",
     "qs": "^6.10.1",
     "react": "^17.0.0",

+ 1 - 1
project.config.json

@@ -2,7 +2,7 @@
   "miniprogramRoot": "dist/",
   "projectname": "myApp",
   "description": "我的项目",
-  "appid": "wx466d25d822867332",
+  "appid": "wxcf634bc22ab19eac",
   "setting": {
     "urlCheck": false,
     "es6": false,

+ 12 - 5
src/app.config.js

@@ -4,12 +4,14 @@ export default {
     'pages/index/index',
     'pages/user/index',
     'pages/details/index',
-    // 'pages/webDetails/index'
+    'pages/webDetails/index',
+    'pages/liveList/index',
+    'pages/liveRoom/index',
   ],
   window: {
     backgroundTextStyle: 'light',
     navigationBarBackgroundColor: '#fff',
-    navigationBarTitleText: 'WeChat',
+    navigationBarTitleText: '湖南科德信息咨询集团有限公司说',
     navigationBarTextStyle: 'black',
 
   },
@@ -19,14 +21,19 @@ export default {
     list: [{
       pagePath: "pages/index/index",
       text: "首页"
-    }, {
+    },{
       pagePath: "pages/user/index",
       text: "我的",
-      badge: '444'
     }]
   },
-  debug:true,
+  // debug:true,
   networkTimeout:{
     request:1000
+  },
+  plugins: {
+    "live-player-plugin": {
+      version: "1.3.0",
+      provider: "wx2b03c6e691cd7370"
+    }
   }
 }

BIN
src/assets/images/audioPlay.png


BIN
src/assets/images/autioSuspend.png


BIN
src/assets/images/background.png


BIN
src/assets/images/noData.png


+ 1 - 1
src/components/common/listBottomStart/index.jsx

@@ -1,6 +1,6 @@
 import React,{Component} from "react";
 import {Image, View} from "@tarojs/components";
-import { AtActivityIndicator,AtDivider  } from 'taro-ui';
+import { AtActivityIndicator  } 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";

+ 84 - 0
src/components/common/phoneWarrantMore/index.jsx

@@ -0,0 +1,84 @@
+import React,{Component} from "react";
+import {Button, View} from '@tarojs/components'
+import Taro from "@tarojs/taro";
+import { AtIcon } from 'taro-ui'
+
+import "taro-ui/dist/style/components/icon.scss";
+
+import { setDecryptData } from '../../../utils/servers/servers';
+
+import './index.less';
+
+class PhoneWarrantMore extends Component{
+  constructor(props) {
+    super(props);
+    this.setDecryptData = this.setDecryptData.bind(this);
+  }
+
+  async setDecryptData(data){
+    Taro.showLoading({title:'正在努力绑定中...'})
+    let msg = await setDecryptData({
+      encryptedData : data.encryptedData,
+      iv : data.iv
+    });
+    if(msg.error && msg.error.length !== 0){
+      Taro.showToast({title:msg.error[0].message,icon:'none'});
+      Taro.hideLoading();
+      return;
+    }
+    if(msg.phoneNumber){
+      let userInfor = Taro.getStorageSync('userInfor');
+      userInfor.mobile = msg.phoneNumber;
+      Taro.setStorageSync('userInfor', userInfor);
+      Taro.showToast({
+        title:'绑定成功',
+        icon:'success'
+      });
+      this.props.onClose();
+    }else{
+      Taro.showToast({
+        title:'绑定失败',
+        icon:'error'
+      });
+    }
+    Taro.hideLoading();
+  }
+
+  render() {
+    return(
+      <>
+        {
+          this.props.visible ? <View className='phoneWarrantMore' onClick={(e)=>{
+            e.stopPropagation();
+            this.props.onClose();
+          }}>
+            <View className='content' onClick={(e)=>{
+              e.stopPropagation();
+            }}>
+              <View className='close' onClick={(e)=>{
+                e.stopPropagation();
+                this.props.onClose();
+              }}>
+                <AtIcon value='close' size='20' />
+              </View>
+              <View className='phone'>
+                <AtIcon value='phone' size='40' color='#24f121'/>
+              </View>
+              <View className='title'>绑定手机号授权</View>
+              <View className='introduction'>绑定手机号后,我们能更好的为您服务</View>
+              <Button className='phoneButton' type='primary' openType='getPhoneNumber' onGetphonenumber={(v)=>{
+                if(v.detail.encryptedData){
+                  this.setDecryptData(v.detail)
+                }
+              }}>
+                绑定手机号
+              </Button>
+            </View>
+          </View> : <View/>
+        }
+      </>
+    );
+  }
+}
+
+export default PhoneWarrantMore;

+ 43 - 0
src/components/common/phoneWarrantMore/index.less

@@ -0,0 +1,43 @@
+.phoneWarrantMore{
+  position: absolute;
+  top: 0;
+  left: 0;
+  right: 0;
+  bottom: 132px;
+  z-index: 99999;
+  background: #0000007a;
+  display: flex;
+  align-items: center;
+  justify-content: center;
+  padding: 30px;
+  .content{
+    width: 100%;
+    background: #FFFFFF;
+    border-radius: 20px;
+    display: flex;
+    flex-flow: column nowrap;
+    align-items: center;
+    padding: 30px 20px;
+    .phone{
+      padding-bottom: 27px;
+      padding-top: 27px;
+    }
+    .close{
+      margin-left: auto;
+    }
+    .title{
+      color: #303030;
+      font-size: 45px;
+      font-weight: bolder;
+      padding-bottom: 20px;
+    }
+    .introduction{
+      color: #969696;
+      font-size: 25px;
+      padding-bottom: 40px;
+    }
+    .phoneButton{
+      width: 100%;
+    }
+  }
+}

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


BIN
src/custom-tab-bar/image/selectHome.png


BIN
src/custom-tab-bar/image/selectUser.png


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


+ 6 - 6
src/custom-tab-bar/index.jsx

@@ -37,10 +37,10 @@ class CustomTabBar extends Component{
           text: "首页"
         },
         // {
-        //   pagePath: "/pages/index/index",
-        //   iconPath: icon_API,
-        //   selectedIconPath: icon_API_HL,
-        //   text: "课程"
+        //   pagePath: "/pages/liveList/index",
+        //   iconPath: icon_home,
+        //   selectedIconPath: icon_selectHome,
+        //   text: "直播"
         // },
         {
           pagePath: "/pages/user/index",
@@ -80,8 +80,8 @@ class CustomTabBar extends Component{
                 {/*        {v.text}*/}
                 {/*      </View>*/}
                 {/*    </>:*/}
-                {/*    <View className='zhong'>*/}
-                {/*      <CoverImage className='coverImage' src={this.props.counter.num === key ? v.selectedIconPath : v.iconPath}/>*/}
+                {/*    <View className='center'>*/}
+                {/*      <CoverImage className='centerCoverImage' 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>*/}
                 {/*}*/}

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

@@ -39,17 +39,17 @@
     padding-top: 10px;
   }
 
-  .zhong {
+  .center {
     position: absolute;
     bottom: 14px;
     width: 98px;
-    height: 98px;
+    height: 146px;
     padding: 23px;
     border-radius: 98px;
     display: flex;
     flex-flow: column;
     align-items: center;
-    .coverImage{
+    .centerCoverImage{
       width: 75px;
       height: 75px;
       padding-top: 8px;

+ 5 - 34
src/pages/details/index.jsx

@@ -1,5 +1,5 @@
 import { Component } from 'react';
-import Taro from '@tarojs/taro';
+import Taro, {getCurrentPages} from '@tarojs/taro';
 import {View, Image, Video} from '@tarojs/components'
 import AudioPlayer from '../../components/audio';
 
@@ -27,7 +27,6 @@ class Details extends Component {
     this.pay= this.pay.bind(this);
     this.payClose= this.payClose.bind(this);
     this.wxQuery= this.wxQuery.bind(this);
-    this.login= this.login.bind(this);
   }
 
   componentDidMount() {
@@ -43,12 +42,10 @@ class Details extends Component {
     if(!token){
       Taro.getUserProfile({
         desc: '用于用户登录',
-        success: async (res)=> {
-          let userInfo = res.userInfo
-          let nickName = userInfo.nickName
-          Taro.setStorageSync('userInfor', userInfo);
-          await this.login(nickName);
-          await this.getSelectProject();
+        success: (userInfor)=> {
+          login(userInfor).then(()=>{
+            this.getSelectProject();
+          })
         },
         fail: ()=>{
           Taro.showToast({title:'请同意授权获取用户信息',icon:'none'});
@@ -93,32 +90,6 @@ class Details extends Component {
     })
   }
 
-  async login(nickname){
-    let token = Taro.getStorageSync('token');
-    if(!token){
-      let loginMsg = await Taro.login();
-      if (loginMsg.code) {
-        try{
-          let msg = await login({
-            code:loginMsg.code,
-            nickname
-          });
-          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)
-        }
-      } else {
-        Taro.showToast({title:loginMsg.errMsg,icon:'none'})
-        console.log('登录失败!' + loginMsg.errMsg)
-      }
-    }
-  }
-
   payClose(orderNo){
     payClose({
       orderNo,

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

@@ -95,7 +95,7 @@ class Index extends Component {
       <View className='indexPage'>
         <NavBar
           extClass='NavBar'
-          title='课程'
+          title='科德高企培育'
           background='#7ac7ff'
           onHome={()=>{}}
         />

+ 9 - 0
src/pages/liveList/index.config.js

@@ -0,0 +1,9 @@
+export default {
+  navigationBarTitleText: '直播列表',
+  enablePullDownRefresh: true,
+  navigationBarTextStyle:'white',
+  backgroundColor: '#7ac7ff',
+  navigationBarBackgroundColor:'#7ac7ff',
+  onReachBottomDistance: 310,
+  navigationStyle: 'custom',
+}

+ 133 - 0
src/pages/liveList/index.jsx

@@ -0,0 +1,133 @@
+import { Component } from 'react';
+import Taro from '@tarojs/taro';
+import { View, Image } from '@tarojs/components'
+import { getLiveList } from '../../utils/servers/servers'
+import dayjs from 'dayjs';
+
+import ListBottomStart  from '../../components/common/listBottomStart';
+
+import './index.less';
+
+import background from '../../assets/images/background.png';
+import NavBar from "../../components/NavBar";
+
+class LiveList extends Component {
+
+  constructor(props) {
+    super(props);
+    this.state={
+      list: [],
+      pageNo: 0,
+      listState: 'LOADING',
+    }
+    this.getLiveList= this.getLiveList.bind(this);
+  }
+
+  async componentDidShow() {
+    this.props.set(1);
+  }
+
+  async componentDidMount() {
+    await this.getLiveList();
+  }
+
+  onPullDownRefresh(){
+    this.getLiveList();
+  }
+
+  onReachBottom(){
+    this.getLiveList(this.state.pageNo+1);
+  }
+
+  async getLiveList (pageNo = 1){
+    this.setState({
+      listState: 'LOADING'
+    })
+    let msg = await getLiveList({
+      pageNo: pageNo,
+      pageSize: 10,
+    });
+    if(msg.error.length === 0){
+      if(msg.data.totalCount === 0){
+        this.setState({
+          listState: 'NO_DATA'
+        })
+      }else if(msg.data.totalCount === this.state.list.length && pageNo !== 1){
+        Taro.showToast({title:'没有更多数据了',icon:'none'});
+        this.setState({
+          listState: 'NO_MORE_DATA'
+        })
+      }else{
+        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'
+            })
+          }
+        })
+      }
+    }else{
+      Taro.showToast({title:msg.error[0].message,icon:'none'});
+      this.setState({
+        listState: msg.error[0].field === '403' ? 'NO_DATA' : 'RELOAD'
+      })
+    }
+    Taro.stopPullDownRefresh();
+  }
+
+  render () {
+    return (
+      <View className='livePlayerPage'>
+        <NavBar
+          extClass='NavBar'
+          title='直播'
+          background='#7ac7ff'
+          onHome={()=>{}}
+        />
+        <Image src={background} className='background'/>
+        <View className='title'>推荐</View>
+        <View className='list'>
+          {
+            this.state.list.map((v,k)=>(
+              <View key={k} className='item' onClick={()=>{
+                let customParams = encodeURIComponent(JSON.stringify({ path: 'pages/liveRoom/index', pid: 1 }));
+                let url = 'plugin-private://wx2b03c6e691cd7370/pages/live-player-plugin?room_id='+v.roomid+'&custom_params='+customParams;
+                Taro.navigateTo({
+                  url
+                })
+              }}>
+                <View className='infor'>
+                  <View className='name'>{v.name}</View>
+                  <View className='createTimes'>{
+                    v.live_status === 101 ? '直播中' :
+                      v.live_status === 102 ? '未开始' :
+                        v.live_status === 103 ? '已结束' :
+                          v.live_status === 104 ? '禁播' :
+                            v.live_status === 105 ? '暂停' :
+                              v.live_status === 106 ? '异常' :
+                                v.live_status === 107 ? '已过期' : ''
+                  }</View>
+                  <View className='amount'>
+                    {/*<View className='money'>开播时间:</View>*/}
+                    {dayjs.unix(v.start_time).format('YYYY-MM-DD HH:mm:ss')}
+                  </View>
+                </View>
+                <Image className='thumbnailUrl' src={v.feeds_img} resizeMode='center'/>
+              </View>
+            ))
+          }
+          <ListBottomStart
+            state={this.state.listState}
+            reload={()=>{
+              this.getLiveList(this.state.pageNo+1);
+            }}/>
+        </View>
+      </View>
+    )
+  }
+}
+
+export default LiveList

+ 93 - 0
src/pages/liveList/index.less

@@ -0,0 +1,93 @@
+.livePlayerPage{
+  position: relative;
+  min-height: 100vh;
+  background: #F5F5F5;
+  z-index: 1;
+  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: 400px;
+  }
+  .title{
+    font-size: 37px;
+    color: #393484;
+    font-weight: bolder;
+    padding: 15px 0 30px 25px;
+  }
+  .list{
+    padding: 0 23px 0 23px;
+    .item{
+      border-radius: 6px;
+      padding: 21px 11px 31px 57px;
+      background: #FFFFFF;
+      display: flex;
+      flex-flow: row nowrap;
+      margin-bottom: 17px;
+      .infor{
+        width: calc(100% - 260rpx);
+        margin-right: 26px;
+        .name{
+          font-size: 28px;
+          color: #2F3742;
+          font-weight: bolder;
+          line-height: 39px;
+          height: 78px;
+          text-overflow: -o-ellipsis-lastline;
+          overflow: hidden;
+          text-overflow: ellipsis;
+          display: -webkit-box;
+          -webkit-line-clamp: 2;
+          -webkit-box-orient: vertical;
+        }
+        .createTimes{
+          display: inline-block;
+          background: #EFF3FF;
+          border-radius: 2px;
+          font-size: 16px;
+          margin-top: 19px;
+          margin-bottom: 15px;
+          margin-left: 10px;
+          padding: 5px 7px;
+          color: #4564DC;
+          border: 1px #A7B6F1 solid;
+        }
+        .amount{
+          display: flex;
+          flex-flow: row nowrap;
+          align-items: flex-end;
+          font-size: 28px;
+          font-weight: bolder;
+          color: #FE3371;
+          padding-left: 35px;
+          .money{
+            padding-left: 10px;
+            font-size: 20px;
+          }
+        }
+      }
+      .thumbnailUrl{
+        margin-bottom: 20px;
+        width: 234px;
+        height: auto;
+        margin-left: auto;
+      }
+    }
+  }
+}

+ 22 - 0
src/pages/liveRoom/index.jsx

@@ -0,0 +1,22 @@
+import React,{Component} from "react";
+import { View } from '@tarojs/components'
+
+class LiveRoom extends Component{
+  constructor(props) {
+    super(props);
+  }
+
+  componentDidMount() {
+    console.log(11111)
+  }
+
+  render() {
+    return (
+      <View>
+
+      </View>
+    )
+  }
+}
+
+export default LiveRoom;

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

@@ -6,4 +6,5 @@ export default {
   navigationBarBackgroundColor:'#7ac7ff',
   onReachBottomDistance: 310,
   navigationStyle: 'custom',
+  usingComponents: {}
 }

+ 85 - 48
src/pages/user/index.jsx

@@ -1,13 +1,14 @@
 import { Component } from 'react';
-import Taro,{getCurrentPages} from '@tarojs/taro';
+import Taro from '@tarojs/taro';
 import {connect} from 'react-redux'
-import { View, Image } from '@tarojs/components'
+import {View, Image} from '@tarojs/components'
 
 import {set} from '../../actions/counter'
-import { login,getUserOrderList } from '../../utils/servers/servers'
+import { login,getUserOrderList,setDecryptData } from '../../utils/servers/servers'
 
 import NavBar from "../../components/NavBar";
 import ListBottomStart from "../../components/common/listBottomStart";
+import PhoneWarrantMore from "../../components/common/phoneWarrantMore";
 
 import './index.less'
 
@@ -31,7 +32,9 @@ class Index extends Component {
       list: [],
       pageNo: 0,
       listState: 'LOADING',
-      userInfor:Taro.getStorageSync('userInfor') || ''
+      userInfor:Taro.getStorageSync('userInfor') || '',
+      token: Taro.getStorageSync('token') || '',
+      visible: false,
     }
   }
 
@@ -39,7 +42,8 @@ class Index extends Component {
     this.props.set(1);
     if(!Taro.getStorageSync('token')){
       this.setState({
-        list: []
+        list: [],
+        token: '',
       })
     }
   }
@@ -56,35 +60,27 @@ class Index extends Component {
     this.getUserOrderList(this.state.pageNo+1);
   }
 
-  async login(nickname){
-    Taro.showLoading({
-      title:'登录中...',
-    })
-    let token = Taro.getStorageSync('token');
-    if(!token){
-      let loginMsg = await Taro.login();
-      if (loginMsg.code) {
-        try{
-          let msg = await login({
-            code:loginMsg.code,
-            nickname
-          });
-          if(msg.error.length === 0){
-            Taro.setStorageSync('token', msg.token);
-            this.getUserOrderList();
-          }else{
-            Taro.showToast({title:msg.error[0].message,icon:'none'})
+  login(){
+    Taro.getUserProfile({
+      desc: '用于用户登录',
+      success: (userInfor)=> {
+        login(userInfor).then((mobile)=>{
+          if(!mobile){
+            this.setState({
+              visible: true
+            })
           }
-        }catch (err) {
-          Taro.showToast({title:'系统错误,请稍后重试',icon:'none'});
-          console.log(err)
-        }
-      } else {
-        Taro.showToast({title:loginMsg.errMsg,icon:'none'})
-        console.log('登录失败!' + loginMsg.errMsg)
+          this.setState({
+            userInfor:Taro.getStorageSync('userInfor') || '',
+            token: Taro.getStorageSync('token') || '',
+          })
+          this.getUserOrderList();
+        })
+      },
+      fail: ()=>{
+        Taro.showToast({title:'请同意授权获取用户信息',icon:'none'});
       }
-    }
-    Taro.hideLoading();
+    })
   }
 
   async getUserOrderList (pageNo = 1){
@@ -120,6 +116,11 @@ class Index extends Component {
       }
     }else{
       Taro.showToast({title:msg.error[0].message,icon:'none'});
+      if(msg.error[0].field === '403'){
+        this.setState({
+          token: ''
+        })
+      }
       this.setState({
         listState: msg.error[0].field === '403' ? 'NO_DATA' : 'RELOAD'
       })
@@ -127,6 +128,38 @@ class Index extends Component {
     Taro.stopPullDownRefresh();
   }
 
+  async setDecryptData(data){
+    let msg = await setDecryptData({
+      encryptedData : data.encryptedData,
+      iv : data.iv
+    });
+    if(msg.error && msg.error.length !== 0){
+      if(msg.error[0].field === '403'){
+        this.setState({
+          token: ''
+        })
+      }
+      Taro.showToast({title:msg.error[0].message,icon:'none'});
+      return;
+    }
+    if(msg.phoneNumber){
+      let userInfor = Taro.getStorageSync('userInfor');
+      userInfor.mobile = msg.phoneNumber;
+      Taro.setStorageSync('userInfor', userInfor);
+      this.setState({
+        userInfor: userInfor
+      })
+      Taro.showToast({
+        title:'绑定成功',
+        icon:'success'
+      });
+    }else{
+      Taro.showToast({
+        title:'绑定失败',
+        icon:'error'
+      });
+    }
+  }
 
   render () {
     return (
@@ -142,24 +175,11 @@ class Index extends Component {
           if(Taro.getStorageSync('token')){
             return;
           }
-          Taro.getUserProfile({
-            desc: '用于用户登录',
-            success: async (res)=> {
-              let userInfo = res.userInfo
-              let nickName = userInfo.nickName
-              Taro.setStorageSync('userInfor', userInfo);
-              await this.login(nickName);
-              await this.getUserOrderList();
-              getCurrentPages()[getCurrentPages().length - 1].onLoad()
-            },
-            fail: ()=>{
-              Taro.showToast({title:'请同意授权获取用户信息',icon:'none'});
-            }
-          })
+          this.login()
         }}>
           <View className='avatar'>
             {
-              Taro.getStorageSync('token') ?
+              this.state.token ?
                 <Image src={this.state.userInfor.avatarUrl} className='login'/> :
                 <Image className='noLogin' src={userIcon}/>
             }
@@ -167,11 +187,17 @@ class Index extends Component {
           </View>
           <View className='nickName'>
             {
-              Taro.getStorageSync('token') ?
+              this.state.token ?
                 this.state.userInfor.nickName :
                 '点击登录'
             }
           </View>
+          {this.state.token && this.state.userInfor && !this.state.userInfor.mobile ? <View className='bindPhone' onClick={(e)=>{
+            e.stopPropagation();
+            this.setState({
+              visible:true
+            })
+          }}>绑定手机</View> : null}
         </View>
         <View className='list'>
           {this.state.list.map((v,k)=>(
@@ -203,6 +229,17 @@ class Index extends Component {
               this.getUserOrderList(this.state.pageNo+1);
             }}/>
         </View>
+        <PhoneWarrantMore
+          visible={this.state.visible}
+          onClose={()=>{
+            this.setState({
+              userInfor: Taro.getStorageSync('userInfor')
+            })
+            this.setState({
+              visible:false
+            })
+          }}
+        />
       </View>
     )
   }

+ 14 - 2
src/pages/user/index.less

@@ -28,8 +28,8 @@
   .userInfor{
     display: flex;
     flex-flow: row nowrap;
-    align-items: flex-start;
-    padding: 0px 0 36px 25px;
+    align-items: center;
+    padding: 0 0 36px 25px;
     .avatar{
       width: 104px;
       height: 104px;
@@ -52,6 +52,18 @@
       padding-left: 19px;
       font-size: 25px;
       color: #FFFFFF;
+      align-self: flex-start;
+    }
+    .bindPhone{
+      padding: 10px 15px;
+      border: 1px solid #2f33e866;
+      border-radius: 7px;
+      color: #FFF;
+      font-size: 26px;
+      margin-left: auto;
+      line-height: 26px;
+      background: #96b3c736;
+      margin-right: 23px;
     }
   }
   .list{

+ 2 - 98
src/pages/webDetails/index.jsx

@@ -4,7 +4,7 @@ import {View, Image, Video} from '@tarojs/components'
 import AudioPlayer from '../../components/audio';
 
 import API from '../../utils/API';
-import { pay,payClose,getSelectProject,wxQuery,login } from '../../utils/servers/servers';
+import { payClose,getSelectProject,wxQuery } from '../../utils/servers/servers';
 import {resourceAddress} from '../../utils/config';
 
 import './index.less'
@@ -24,10 +24,8 @@ class Details extends Component {
     this.state={
       projectInfor: {},
     }
-    this.pay= this.pay.bind(this);
     this.payClose= this.payClose.bind(this);
     this.wxQuery= this.wxQuery.bind(this);
-    this.login= this.login.bind(this);
   }
 
   componentDidMount() {
@@ -43,87 +41,6 @@ class Details extends Component {
     window.location.href='https://cloud1-2gpyny9bdfc8c33a-1305545304.tcloudbaseapp.com/jump-mp.html?sign=639f843ec9b22075c5ce44e301060206&t=1618818701&id=27';
   }
 
-  pay(){
-    let token = Taro.getStorageSync('token');
-    if(!token){
-      Taro.getUserProfile({
-        desc: '用于用户登录',
-        success: async (res)=> {
-          let userInfo = res.userInfo
-          let nickName = userInfo.nickName
-          Taro.setStorageSync('userInfor', userInfo);
-          await this.login(nickName);
-          await this.getSelectProject();
-        },
-        fail: ()=>{
-          Taro.showToast({title:'请同意授权获取用户信息',icon:'none'});
-        }
-      })
-      return ;
-    }
-    Taro.showLoading({title:'加载中'})
-    pay({
-      id:this.inst.router.params.id,
-    }).then(v => {
-      Taro.hideLoading();
-      if(v.error.length === 0){
-        if(v.data.amount === "0"){
-          Taro.showToast({title:'购买成功'});
-          this.getSelectProject();
-          return ;
-        }
-        API.requestPayment({
-          timeStamp: v.data.timeStamp,
-          nonceStr: v.data.nonceStr,
-          package: v.data.package,
-          signType: 'MD5',
-          paySign: v.data.paySign,
-          success: (_)=> {
-            Taro.showToast({title:'支付成功'});
-            this.wxQuery(v.data.out_trade_no);
-            this.getSelectProject();
-          },
-          fail: (err)=> {
-            console.log(err,'fail');
-            this.payClose(v.data.out_trade_no);
-          },
-        })
-      }else{
-        Taro.showToast({title:v.error[0].message,icon:'none'})
-      }
-    }).catch(err => {
-      Taro.hideLoading();
-      Taro.showToast({title:'系统错误,请稍后重试',icon:'none'});
-      console.log(err)
-    })
-  }
-
-  async login(nickname){
-    let token = Taro.getStorageSync('token');
-    if(!token){
-      let loginMsg = await Taro.login();
-      if (loginMsg.code) {
-        try{
-          let msg = await login({
-            code:loginMsg.code,
-            nickname
-          });
-          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)
-        }
-      } else {
-        Taro.showToast({title:loginMsg.errMsg,icon:'none'})
-        console.log('登录失败!' + loginMsg.errMsg)
-      }
-    }
-  }
-
   payClose(orderNo){
     payClose({
       orderNo,
@@ -238,22 +155,9 @@ class Details extends Component {
         </View>
         <View className='shop'>
           <View className='singlePurchase' onClick={()=>{
-            if(Taro.getEnv() === 'WEB'){
-              this.jumpWeapp();
-            }else{
-              this.pay();
-            }
+            this.jumpWeapp();
           }}>购买: ¥{projectInfor.amount}</View>
         </View>
-        {/*{projectInfor.buy === 0 ? <View className='shop' style={{bottom:Taro.getEnv() === 'WEB' ? '50px' : '0'}}>*/}
-        {/*  <View className='singlePurchase' onClick={()=>{*/}
-        {/*    if(Taro.getEnv() === 'WEB'){*/}
-        {/*      this.jumpWeapp();*/}
-        {/*    }else{*/}
-        {/*      this.pay();*/}
-        {/*    }*/}
-        {/*  }}>购买: ¥{projectInfor.amount}</View>*/}
-        {/*</View> : null}*/}
       </View>
     )
   }

+ 2 - 2
src/utils/config.js

@@ -1,3 +1,3 @@
-export const resourceAddress = 'http://172.16.0.188:3000/upload'
-// export const resourceAddress = 'http://kedejs.jishutao.com/upload'
+// 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
 }

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

@@ -45,7 +45,7 @@ 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'){
+      if(res.data.error && res.data.error.length !== 0 && res.data.error[0].field === '403'){
         Taro.setStorageSync("token", "");
         Taro.setStorageSync('userInfor', "");
         pageToLogin()

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

@@ -1,9 +1,40 @@
 /* eslint-disable import/prefer-default-export */
 import HTTPREQUEST from "./http"
+import Taro, {getCurrentPages} from "@tarojs/taro";
 
 //登录
-export const login = (postData) => {
-  return HTTPREQUEST.post('/wxLogin', postData)
+export const login = (res) => {
+  return new Promise(async (resolve,_)=>{
+    Taro.showLoading({
+      title:'登录中...',
+    })
+    let userInfor = res.userInfo
+    let loginMsg = await Taro.login();
+    if (loginMsg.code) {
+      try{
+        let msg = await HTTPREQUEST.post('/wxLogin', {
+          code:loginMsg.code,
+          nickname:userInfor.nickName
+        });
+        if(msg.error.length === 0){
+          userInfor.mobile = msg.data.mobile;
+          Taro.setStorageSync('userInfor', userInfor);
+          Taro.setStorageSync('token', msg.token);
+          Taro.showToast({title:'登录成功',icon:'success'})
+          resolve(userInfor.mobile);
+        }else{
+          Taro.showToast({title:msg.error[0].message,icon:'none'})
+        }
+      }catch (err) {
+        Taro.showToast({title:'系统错误,请稍后重试',icon:'none'});
+        console.log(err,'login')
+      }
+    } else {
+      Taro.showToast({title:loginMsg.errMsg,icon:'none'})
+      console.log('登录失败!' + loginMsg.errMsg)
+    }
+    Taro.hideLoading();
+  })
 }
 
 //产品支付
@@ -37,6 +68,16 @@ export const wxQuery = (postData) => {
   return HTTPREQUEST.get('/api/user/wxQuery', postData)
 }
 
+//获取直播列表
+export const getLiveList = (postData) => {
+  return HTTPREQUEST.get('/api/user/getliveinfo', postData)
+}
+
+//上传手机号
+export const setDecryptData = (postData) => {
+  return HTTPREQUEST.post('/api/user/decryptData', postData)
+}
+
 //测试
 export const test = (postData) => {
   return HTTPREQUEST.get('/open/test', postData)

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

@@ -11,10 +11,10 @@ export const getCurrentPageUrl = () => {
 };
 
 export const pageToLogin = async () => {
-  // let path = getCurrentPageUrl()
   Taro.switchTab({
     url: '/pages/user/index'
   })
+
   // if (!path.includes('login')) {
   //   setTimeout(async ()=>{
   //     Taro.showLoading({title: '重新登录中...',})

+ 1 - 1
yarn.lock

@@ -3422,7 +3422,7 @@ data-urls@^1.1.0:
     whatwg-mimetype "^2.2.0"
     whatwg-url "^7.0.0"
 
-dayjs@^1.7.7:
+dayjs@^1.10.4, dayjs@^1.7.7:
   version "1.10.4"
   resolved "https://registry.yarnpkg.com/dayjs/-/dayjs-1.10.4.tgz#8e544a9b8683f61783f570980a8a80eaf54ab1e2"
   integrity sha512-RI/Hh4kqRc1UKLOAf/T5zdMMX5DQIlDxwUe3wSyMMnEbGunnpENCdbUgM+dW7kXidZqCttBrmw7BhN4TMddkCw==