|
@@ -1,28 +1,20 @@
|
|
import { Component } from 'react';
|
|
import { Component } from 'react';
|
|
-import Taro,{getCurrentInstance} from '@tarojs/taro';
|
|
|
|
|
|
+import Taro from '@tarojs/taro';
|
|
import { connect } from 'react-redux'
|
|
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 './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 background from "../../assets/images/background.png";
|
|
|
|
+import NavBar from "../../components/NavBar";
|
|
|
|
|
|
@connect(({ counter }) => ({
|
|
@connect(({ counter }) => ({
|
|
counter
|
|
counter
|
|
}), (dispatch) => ({
|
|
}), (dispatch) => ({
|
|
- add () {
|
|
|
|
- dispatch(add())
|
|
|
|
- },
|
|
|
|
- dec () {
|
|
|
|
- dispatch(minus())
|
|
|
|
- },
|
|
|
|
- asyncAdd () {
|
|
|
|
- dispatch(asyncAdd())
|
|
|
|
- },
|
|
|
|
set (value) {
|
|
set (value) {
|
|
dispatch(set(value))
|
|
dispatch(set(value))
|
|
}
|
|
}
|
|
@@ -34,135 +26,97 @@ class Index extends Component {
|
|
constructor(props) {
|
|
constructor(props) {
|
|
super(props);
|
|
super(props);
|
|
this.state={
|
|
this.state={
|
|
- pageNo:1,
|
|
|
|
list: [],
|
|
list: [],
|
|
|
|
+ pageNo: 0,
|
|
|
|
+ listState: 'LOADING',
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- componentWillReceiveProps (nextProps) {
|
|
|
|
- console.log(this.props, nextProps)
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- componentWillUnmount () { }
|
|
|
|
-
|
|
|
|
componentDidShow() {
|
|
componentDidShow() {
|
|
this.props.set(1);
|
|
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');
|
|
let token = Taro.getStorageSync('token');
|
|
if(!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,
|
|
pageNo: pageNo,
|
|
pageSize: 5,
|
|
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({
|
|
this.setState({
|
|
- list:pageNo === 1 ? v.data.list : this.state.list.concat(v.data.list),
|
|
|
|
- pageNo: v.data.pageNo
|
|
|
|
|
|
+ listState: 'NO_MORE_DATA'
|
|
})
|
|
})
|
|
}else{
|
|
}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 () {
|
|
render () {
|
|
return (
|
|
return (
|
|
<View className='userPage'>
|
|
<View className='userPage'>
|
|
|
|
+ <NavBar
|
|
|
|
+ extClass='NavBar'
|
|
|
|
+ title='我的'
|
|
|
|
+ background='#76D3FF'
|
|
|
|
+ onHome={()=>{}}
|
|
|
|
+ />
|
|
<Image src={background} className='background'/>
|
|
<Image src={background} className='background'/>
|
|
<View className='userInfor'>
|
|
<View className='userInfor'>
|
|
<View className='avatar'>
|
|
<View className='avatar'>
|
|
@@ -176,7 +130,7 @@ class Index extends Component {
|
|
{this.state.list.map((v,k)=>(
|
|
{this.state.list.map((v,k)=>(
|
|
<View className='item' key={k} onClick={()=>{
|
|
<View className='item' key={k} onClick={()=>{
|
|
Taro.navigateTo({
|
|
Taro.navigateTo({
|
|
- url:'/pages/details/index?id='+v.id
|
|
|
|
|
|
+ url:'/pages/details/index?id='+v.projectId
|
|
})
|
|
})
|
|
}}>
|
|
}}>
|
|
<View className='block'>
|
|
<View className='block'>
|
|
@@ -187,15 +141,20 @@ class Index extends Component {
|
|
</View>
|
|
</View>
|
|
</View>
|
|
</View>
|
|
<View className='infor'>
|
|
<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>
|
|
<View className='moneyInfor'>
|
|
<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>
|
|
</View>
|
|
</View>
|
|
))}
|
|
))}
|
|
|
|
+ <ListBottomStart
|
|
|
|
+ state={this.state.listState}
|
|
|
|
+ reload={()=>{
|
|
|
|
+ this.getUserOrderList(this.state.pageNo+1);
|
|
|
|
+ }}/>
|
|
</View>
|
|
</View>
|
|
</View>
|
|
</View>
|
|
)
|
|
)
|