处理session 过期
This commit is contained in:
parent
036bc4783a
commit
1f79ef2bda
@ -20,7 +20,7 @@ class App extends Component {
|
|||||||
config = {
|
config = {
|
||||||
pages: [
|
pages: [
|
||||||
//'pages/index/index', // index页面
|
//'pages/index/index', // index页面
|
||||||
'pages/individualCenter/individualCenter',// 个人中心页面
|
|
||||||
'pages/home/home',//首页 ---------------------
|
'pages/home/home',//首页 ---------------------
|
||||||
'pages/login/login',//登入页面 ---------------------
|
'pages/login/login',//登入页面 ---------------------
|
||||||
'pages/shop/shop',//店铺页面 ---------------------
|
'pages/shop/shop',//店铺页面 ---------------------
|
||||||
@ -38,6 +38,7 @@ class App extends Component {
|
|||||||
'pages/myNeedsView/myNeedsView',// 单个需求查看页面
|
'pages/myNeedsView/myNeedsView',// 单个需求查看页面
|
||||||
'pages/myNeedsEdit/myNeedsEdit',// 单个需求编辑页面
|
'pages/myNeedsEdit/myNeedsEdit',// 单个需求编辑页面
|
||||||
'pages/myNeedsPublish/myNeedsPublish',// 需求发布
|
'pages/myNeedsPublish/myNeedsPublish',// 需求发布
|
||||||
|
'pages/individualCenter/individualCenter',// 个人中心页面
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -164,8 +164,9 @@ class AllDemanding extends Component {
|
|||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
grabOrder(Id) {
|
grabOrder(e) {
|
||||||
this.setState({ isOpenedGrabModal: true, grabOrderId: Id })
|
const id = e.currentTarget.dataset.eTapAA
|
||||||
|
this.setState({ isOpenedGrabModal: true, grabOrderId: id })
|
||||||
}
|
}
|
||||||
handleGrabModalClose() {
|
handleGrabModalClose() {
|
||||||
this.setState({ isOpenedGrabModal: false })
|
this.setState({ isOpenedGrabModal: false })
|
||||||
@ -202,10 +203,10 @@ class AllDemanding extends Component {
|
|||||||
this.setState({ industryTypeSelected: value })
|
this.setState({ industryTypeSelected: value })
|
||||||
}
|
}
|
||||||
|
|
||||||
goToGrabOrderPage(orderId) {
|
goToGrabOrderPage(e) {
|
||||||
|
const id = e.currentTarget.dataset.eTapAA
|
||||||
Taro.navigateTo({
|
Taro.navigateTo({
|
||||||
|
url: '/pages/grabOrderPage/grabOrderPage?orderId=' + id
|
||||||
url: '/pages/grabOrderPage/grabOrderPage?orderId=' + orderId
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -264,7 +264,6 @@ class GoodsPublish extends Component {
|
|||||||
|
|
||||||
|
|
||||||
goToMyGoodListPage() {
|
goToMyGoodListPage() {
|
||||||
console.log('list ', Taro.getStorageSync('userInfo'))
|
|
||||||
if (!Taro.getStorageSync('userInfo').user_id) {
|
if (!Taro.getStorageSync('userInfo').user_id) {
|
||||||
LoginService()
|
LoginService()
|
||||||
return
|
return
|
||||||
|
@ -70,16 +70,12 @@ class GrabOrderPage extends Component {
|
|||||||
renderingImage: res.data.sdInfo.render_pics || []
|
renderingImage: res.data.sdInfo.render_pics || []
|
||||||
})
|
})
|
||||||
} else if (res.data.err_code === 88888) {
|
} else if (res.data.err_code === 88888) {
|
||||||
Taro.clearStorageSync()
|
loginExpired(res)
|
||||||
|
}else{
|
||||||
Taro.showToast({
|
Taro.showToast({
|
||||||
title:res.data.err_msg,
|
title:res.data.err_msg,
|
||||||
icon:'none'
|
icon:'none'
|
||||||
})
|
})
|
||||||
setTimeout(() => {
|
|
||||||
Taro.switchTab({
|
|
||||||
url: '/pages/home/home'
|
|
||||||
})
|
|
||||||
}, 1500);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -171,7 +167,7 @@ class GrabOrderPage extends Component {
|
|||||||
|
|
||||||
componentDidHide() { }
|
componentDidHide() { }
|
||||||
goMyNeedsPublishPage() {
|
goMyNeedsPublishPage() {
|
||||||
Taro.navigateTo({
|
Taro.switchTab({
|
||||||
url: '/pages/myNeedsPublish/myNeedsPublish'
|
url: '/pages/myNeedsPublish/myNeedsPublish'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -218,8 +214,8 @@ class GrabOrderPage extends Component {
|
|||||||
duration: 1500
|
duration: 1500
|
||||||
})
|
})
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
Taro.switchTab({
|
Taro.navigateBack({
|
||||||
url: '/pages/myNeeds/myNeeds'
|
delta:-1
|
||||||
})
|
})
|
||||||
}, 1500);
|
}, 1500);
|
||||||
} else if (res.data.err_code === 88888) {
|
} else if (res.data.err_code === 88888) {
|
||||||
@ -232,7 +228,6 @@ class GrabOrderPage extends Component {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
@ -259,7 +254,7 @@ class GrabOrderPage extends Component {
|
|||||||
<AtIcon value='' size='12' color='white'></AtIcon>
|
<AtIcon value='' size='12' color='white'></AtIcon>
|
||||||
我的需求</Button>
|
我的需求</Button>
|
||||||
</View>
|
</View>
|
||||||
<View className='button' onClick={this.goMyNeedEditPage.bind(this)}>
|
{/* <View className='button' onClick={this.goMyNeedEditPage.bind(this)}>
|
||||||
<Button size='mini' className='button-blue'>
|
<Button size='mini' className='button-blue'>
|
||||||
<AtIcon value='settings' size='12' color='white'></AtIcon>
|
<AtIcon value='settings' size='12' color='white'></AtIcon>
|
||||||
修改</Button>
|
修改</Button>
|
||||||
@ -269,7 +264,7 @@ class GrabOrderPage extends Component {
|
|||||||
<Button size='mini' className='button-dark-red'>
|
<Button size='mini' className='button-dark-red'>
|
||||||
<AtIcon value='trash' size='12' color='white'></AtIcon>
|
<AtIcon value='trash' size='12' color='white'></AtIcon>
|
||||||
删除</Button>
|
删除</Button>
|
||||||
</View>
|
</View> */}
|
||||||
</View>
|
</View>
|
||||||
} else if (localStoageUserId === this.state.userId && this.state.stateId != '1') {
|
} else if (localStoageUserId === this.state.userId && this.state.stateId != '1') {
|
||||||
ButtonElement = <View className='button-box'>
|
ButtonElement = <View className='button-box'>
|
||||||
|
@ -2,7 +2,7 @@ import Taro, { Component } from '@tarojs/taro'
|
|||||||
import { View, Image, Button } from '@tarojs/components'
|
import { View, Image, Button } from '@tarojs/components'
|
||||||
import { AtGrid, AtList, AtListItem, AtAvatar, AtButton } from "taro-ui"
|
import { AtGrid, AtList, AtListItem, AtAvatar, AtButton } from "taro-ui"
|
||||||
|
|
||||||
|
import LoginService from '../../util/LoginService'
|
||||||
import './individualCenter.scss'
|
import './individualCenter.scss'
|
||||||
import URL from '../../serviceAPI.config'
|
import URL from '../../serviceAPI.config'
|
||||||
|
|
||||||
@ -117,7 +117,12 @@ class IndividualCenter extends Component {
|
|||||||
|
|
||||||
componentWillUnmount() { }
|
componentWillUnmount() { }
|
||||||
|
|
||||||
componentDidShow() { }
|
componentDidShow() {
|
||||||
|
if (!Taro.getStorageSync('userInfo').user_id) {
|
||||||
|
LoginService()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
componentDidHide() { }
|
componentDidHide() { }
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import Taro, { Component } from '@tarojs/taro'
|
import Taro, { Component } from '@tarojs/taro'
|
||||||
import { View, Input, Button, Text, Image } from '@tarojs/components'
|
import { View, Input, Button, Image } from '@tarojs/components'
|
||||||
import URL from '../../serviceAPI.config'
|
import URL from '../../serviceAPI.config'
|
||||||
|
import standardLogin from '../../util/standardLogin'
|
||||||
import './login.scss'
|
import './login.scss'
|
||||||
|
|
||||||
|
|
||||||
@ -17,74 +17,7 @@ class Login extends Component {
|
|||||||
backgroundImage: 'background-image:url(' + URL.Base + '/Public/images/bg3.jpg);'
|
backgroundImage: 'background-image:url(' + URL.Base + '/Public/images/bg3.jpg);'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//用户信息姓名和电话号码接口
|
|
||||||
setUserInfoToStorage() {
|
|
||||||
Taro.request({
|
|
||||||
url: URL.ShopWxStore,
|
|
||||||
header: {
|
|
||||||
'Cookie': 'PFWSSS=' + Taro.getStorageSync('session_id'),
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.then(res => {
|
|
||||||
if (res.data.err_msg === 'success') {
|
|
||||||
Taro.setStorageSync('user_identity', { username: res.data.otherData.userName, userphone: res.data.otherData.userPhone })
|
|
||||||
|
|
||||||
} else {
|
|
||||||
Taro.showToast({
|
|
||||||
title: res.data.err_msg,
|
|
||||||
icon: 'none',
|
|
||||||
duration: 1500
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
loginApi() {
|
|
||||||
Taro.request({
|
|
||||||
url: URL.Base + 'user-login',
|
|
||||||
method: 'POST',
|
|
||||||
dataType: 'json',
|
|
||||||
data: {
|
|
||||||
username: this.state.username,
|
|
||||||
password: this.state.password,
|
|
||||||
},
|
|
||||||
header: {
|
|
||||||
'content-type': 'application/x-www-form-urlencoded',
|
|
||||||
'X-Requested-With': 'XMLHttpRequest'
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.then(res => {
|
|
||||||
if (res.data.err_code === 0) {
|
|
||||||
|
|
||||||
Taro.showToast({
|
|
||||||
title: res.data.err_msg && '登入成功',
|
|
||||||
icon: 'success',
|
|
||||||
duration: 1000
|
|
||||||
})
|
|
||||||
Taro.setStorageSync('session_id', res.data.session_id)
|
|
||||||
Taro.setStorageSync('shopInfo', res.data.shop_info)
|
|
||||||
Taro.setStorageSync('userInfo', res.data.user_info)
|
|
||||||
this.setUserInfoToStorage()
|
|
||||||
|
|
||||||
setTimeout(() => {
|
|
||||||
// Taro.navigateBack({
|
|
||||||
// delta: 1
|
|
||||||
// })
|
|
||||||
Taro.reLaunch({
|
|
||||||
url:'/pages/home/home'
|
|
||||||
})
|
|
||||||
}, 1000);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
Taro.showToast({
|
|
||||||
title: res.data.msg,
|
|
||||||
icon: 'none',
|
|
||||||
duration: 2000
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
})
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
usernameHandler(e) {
|
usernameHandler(e) {
|
||||||
let value = e.detail.value
|
let value = e.detail.value
|
||||||
@ -95,7 +28,37 @@ class Login extends Component {
|
|||||||
this.setState({ password: value })
|
this.setState({ password: value })
|
||||||
}
|
}
|
||||||
loginHandler() {
|
loginHandler() {
|
||||||
this.loginApi()
|
if (this.state.username && this.state.password) {
|
||||||
|
standardLogin(this.state.username, this.state.password).then(res => {
|
||||||
|
Taro.reLaunch({
|
||||||
|
url: '/pages/home/home'
|
||||||
|
})
|
||||||
|
}).catch(res => {
|
||||||
|
Taro.showToast({
|
||||||
|
title: res.data.msg,
|
||||||
|
icon: 'none',
|
||||||
|
})
|
||||||
|
})
|
||||||
|
} else if (!this.state.username) {
|
||||||
|
Taro.showToast({
|
||||||
|
title: '请输入用户名',
|
||||||
|
icon: 'none',
|
||||||
|
|
||||||
|
})
|
||||||
|
} else if (!this.state.password) {
|
||||||
|
Taro.showToast({
|
||||||
|
title: '请输入密码',
|
||||||
|
icon: 'none',
|
||||||
|
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
Taro.showToast({
|
||||||
|
title: '未知错误请联系管理员',
|
||||||
|
icon: 'none',
|
||||||
|
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
|
|
||||||
|
@ -146,9 +146,9 @@ class MyDemandSupplyEdit extends Component {
|
|||||||
url: '/pages/supplyDemandPublish/supplyDemandPublish'
|
url: '/pages/supplyDemandPublish/supplyDemandPublish'
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
// Taro.navigateTo({
|
Taro.redirectTo({
|
||||||
// url: '/pages/myDemandSupplyEdit/myDemandSupplyEdit?sdId=' + res.data.sd_id
|
url: '/pages/mySupplyDemand/mySupplyDemand',//我的供求页面
|
||||||
// })
|
})
|
||||||
}
|
}
|
||||||
}, 1000);
|
}, 1000);
|
||||||
})
|
})
|
||||||
@ -314,8 +314,8 @@ class MyDemandSupplyEdit extends Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
goToMyDemSupPage() {
|
goToMyDemSupPage() {
|
||||||
Taro.navigateBack({
|
Taro.redirectTo({
|
||||||
delta: 1
|
url: '/pages/mySupplyDemand/mySupplyDemand',//我的供求页面
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
deleteButtonHandler() {
|
deleteButtonHandler() {
|
||||||
@ -468,9 +468,9 @@ class MyDemandSupplyEdit extends Component {
|
|||||||
<View className='button' onClick={this.saveButtonHandler.bind(this)}>
|
<View className='button' onClick={this.saveButtonHandler.bind(this)}>
|
||||||
<Button size='mini' className='button-orange'>保存</Button>
|
<Button size='mini' className='button-orange'>保存</Button>
|
||||||
</View>
|
</View>
|
||||||
<View className='button' onClick={this.saveAndNewButton.bind(this)}>
|
{/* <View className='button' onClick={this.saveAndNewButton.bind(this)}>
|
||||||
<Button size='mini' className='button-green'>保存并新增</Button>
|
<Button size='mini' className='button-green'>保存并新增</Button>
|
||||||
</View>
|
</View> */}
|
||||||
{/* <View className='button'>
|
{/* <View className='button'>
|
||||||
|
|
||||||
<Button className='button-a' size='mini' className='button-orange'>保存并新增</Button>
|
<Button className='button-a' size='mini' className='button-orange'>保存并新增</Button>
|
||||||
@ -478,9 +478,9 @@ class MyDemandSupplyEdit extends Component {
|
|||||||
<View className='button' onClick={this.goToMyDemSupPage.bind(this)}>
|
<View className='button' onClick={this.goToMyDemSupPage.bind(this)}>
|
||||||
<Button size='mini' className='button-green'>我的供求</Button>
|
<Button size='mini' className='button-green'>我的供求</Button>
|
||||||
</View>
|
</View>
|
||||||
<View className='button' onClick={this.deleteButtonHandler.bind(this)}>
|
{/* <View className='button' onClick={this.deleteButtonHandler.bind(this)}>
|
||||||
<Button size='mini' className='button-dark-red'>删除</Button>
|
<Button size='mini' className='button-dark-red'>删除</Button>
|
||||||
</View>
|
</View> */}
|
||||||
</View>
|
</View>
|
||||||
<CopyrightComponent></CopyrightComponent>
|
<CopyrightComponent></CopyrightComponent>
|
||||||
|
|
||||||
|
@ -5,8 +5,6 @@ import CopyrightComponent from '../../component/copyrightComponent/copyrightComp
|
|||||||
import ScrollToTopComponent from '../../component/scrollToTopComponent/scrollToTopComponent'
|
import ScrollToTopComponent from '../../component/scrollToTopComponent/scrollToTopComponent'
|
||||||
|
|
||||||
import URL from '../../serviceAPI.config'
|
import URL from '../../serviceAPI.config'
|
||||||
|
|
||||||
|
|
||||||
import './myGoodList.scss'
|
import './myGoodList.scss'
|
||||||
import loginExpired from '../../util/loginExpired';
|
import loginExpired from '../../util/loginExpired';
|
||||||
|
|
||||||
@ -144,7 +142,9 @@ class MyGoodList extends Component {
|
|||||||
}
|
}
|
||||||
}).then(res => {
|
}).then(res => {
|
||||||
const data = JSON.parse(res.data)
|
const data = JSON.parse(res.data)
|
||||||
if (data.err_code != 10) {
|
if (data.err_code === 88888) {
|
||||||
|
loginExpired(data)
|
||||||
|
} else if (data.err_code != 10) {
|
||||||
console.log('我的商品列表', JSON.parse(res.data))
|
console.log('我的商品列表', JSON.parse(res.data))
|
||||||
|
|
||||||
Taro.hideLoading()
|
Taro.hideLoading()
|
||||||
@ -691,8 +691,8 @@ class MyGoodList extends Component {
|
|||||||
</AtModal>
|
</AtModal>
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<MovableArea style='height: 100%; width: 100%; '>
|
<MovableArea style='height: 100vh; width: 100%; '>
|
||||||
<View className='MyGoodList' style='position:relative;'>
|
<View className='MyGoodList' >
|
||||||
{/* 删除模态提示框 */}
|
{/* 删除模态提示框 */}
|
||||||
{modalMessageDeleteElement}
|
{modalMessageDeleteElement}
|
||||||
{/* 下架模态框提示 */}
|
{/* 下架模态框提示 */}
|
||||||
@ -820,11 +820,12 @@ class MyGoodList extends Component {
|
|||||||
|
|
||||||
|
|
||||||
<CopyrightComponent></CopyrightComponent>
|
<CopyrightComponent></CopyrightComponent>
|
||||||
|
|
||||||
|
</View>
|
||||||
<MovableView className='movable-point' x={this.state.screenWidth} y={this.state.screenHeight} style='opacity:0.3' direction='all' onClick={this.goToCenterPage.bind(this)} >
|
<MovableView className='movable-point' x={this.state.screenWidth} y={this.state.screenHeight} style='opacity:0.3' direction='all' onClick={this.goToCenterPage.bind(this)} >
|
||||||
|
|
||||||
个人中心
|
个人中心
|
||||||
</MovableView>
|
</MovableView>
|
||||||
</View>
|
|
||||||
</MovableArea>
|
</MovableArea>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -46,6 +46,7 @@ class MyGoodsEdit extends Component {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
.then(res => {
|
.then(res => {
|
||||||
|
console.log('res',res)
|
||||||
if (res.data.err_code === 0) {
|
if (res.data.err_code === 0) {
|
||||||
console.log('商品详情获取成功', res)
|
console.log('商品详情获取成功', res)
|
||||||
|
|
||||||
@ -62,8 +63,6 @@ class MyGoodsEdit extends Component {
|
|||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
if (Taro.getStorageSync('shopTypeObject')) {
|
if (Taro.getStorageSync('shopTypeObject')) {
|
||||||
let selectedValue = ''
|
let selectedValue = ''
|
||||||
const shopTypeObject = Taro.getStorageSync('shopTypeObject')
|
const shopTypeObject = Taro.getStorageSync('shopTypeObject')
|
||||||
@ -89,6 +88,7 @@ class MyGoodsEdit extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} else if (res.data.err_code === 88888) {
|
} else if (res.data.err_code === 88888) {
|
||||||
|
console.log('88888')
|
||||||
loginExpired(res)
|
loginExpired(res)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -172,9 +172,13 @@ class MyGoodsEdit extends Component {
|
|||||||
}).then(() => {
|
}).then(() => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (this.state.isSaveButton) {
|
if (this.state.isSaveButton) {
|
||||||
Taro.navigateBack({
|
// Taro.navigateBack({
|
||||||
delta:1
|
|
||||||
|
// delta:1
|
||||||
// url: '/pages/myGoodsList/myGoodsEdit?id=' + this.$router.params.id
|
// url: '/pages/myGoodsList/myGoodsEdit?id=' + this.$router.params.id
|
||||||
|
// })
|
||||||
|
Taro.redirectTo({
|
||||||
|
url: '/pages/myGoodList/myGoodList'
|
||||||
})
|
})
|
||||||
} else if (this.state.isSaveAndNewBUtton) {
|
} else if (this.state.isSaveAndNewBUtton) {
|
||||||
Taro.switchTab({
|
Taro.switchTab({
|
||||||
@ -349,7 +353,7 @@ class MyGoodsEdit extends Component {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
goToMyGoodListPage() {
|
goToMyGoodListPage() {
|
||||||
Taro.navigateTo({
|
Taro.redirectTo({
|
||||||
url: '/pages/myGoodList/myGoodList'
|
url: '/pages/myGoodList/myGoodList'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -251,13 +251,15 @@ class MyNeeds extends Component {
|
|||||||
needsStateSelected: this.state.needsState[e.detail.value]
|
needsStateSelected: this.state.needsState[e.detail.value]
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
goToMyNeedsViewPage(Id) {
|
goToMyNeedsViewPage(e) {
|
||||||
|
const id = e.currentTarget.dataset.eTapAA
|
||||||
Taro.navigateTo({
|
Taro.navigateTo({
|
||||||
url: '/pages/grabOrderPage/grabOrderPage?orderId=' + Id
|
url: '/pages/grabOrderPage/grabOrderPage?orderId=' + id
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
goToMyNeedsEditPage(id) {
|
goToMyNeedsEditPage(e) {
|
||||||
|
const id = e.currentTarget.dataset.eTapAA
|
||||||
Taro.navigateTo({
|
Taro.navigateTo({
|
||||||
url: '/pages/myNeedsEdit/myNeedsEdit?id=' + id
|
url: '/pages/myNeedsEdit/myNeedsEdit?id=' + id
|
||||||
})
|
})
|
||||||
|
@ -171,13 +171,16 @@ class MyNeedsEdit extends Component {
|
|||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
console.log('this.state.isSaveAndNew', this.state.isSaveAndNew)
|
console.log('this.state.isSaveAndNew', this.state.isSaveAndNew)
|
||||||
if (this.state.isSaveAndNew) {
|
if (this.state.isSaveAndNew) {
|
||||||
Taro.navigateTo({
|
// Taro.navigateTo({
|
||||||
url: '/pages/myNeedsPublish/myNeedsPublish'
|
// url: '/pages/myNeedsPublish/myNeedsPublish'
|
||||||
})
|
// })
|
||||||
} else {
|
} else {
|
||||||
// Taro.navigateTo({
|
// Taro.navigateTo({
|
||||||
// url: '/pages/myNeedsEdit/myNeedsEdit?id=' + this.state.sd_id
|
// url: '/pages/myNeedsEdit/myNeedsEdit?id=' + this.state.sd_id
|
||||||
// })
|
// })
|
||||||
|
Taro.reLaunch({
|
||||||
|
url: '/pages/myNeeds/myNeeds'
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}, 1500);
|
}, 1500);
|
||||||
})
|
})
|
||||||
@ -513,15 +516,15 @@ class MyNeedsEdit extends Component {
|
|||||||
<View className='button' onClick={this.saveButtonHandler.bind(this)}>
|
<View className='button' onClick={this.saveButtonHandler.bind(this)}>
|
||||||
<Button size='mini' className='button-orange'>保存</Button>
|
<Button size='mini' className='button-orange'>保存</Button>
|
||||||
</View>
|
</View>
|
||||||
<View className='button' onClick={this.saveAndNewButton.bind(this)}>
|
{/* <View className='button' onClick={this.saveAndNewButton.bind(this)}>
|
||||||
<Button size='mini' className='button-green'>保存并新增</Button>
|
<Button size='mini' className='button-green'>保存并新增</Button>
|
||||||
</View>
|
</View> */}
|
||||||
<View className='button' onClick={this.goToMyNeedsPage.bind(this)}>
|
<View className='button' onClick={this.goToMyNeedsPage.bind(this)}>
|
||||||
<Button className='button-green' size='mini'>我的需求</Button>
|
<Button className='button-green' size='mini'>我的需求</Button>
|
||||||
</View>
|
</View>
|
||||||
<View className='button' onClick={this.deleteButtonHandler.bind(this)}>
|
{/* <View className='button' onClick={this.deleteButtonHandler.bind(this)}>
|
||||||
<Button className='button-dark-red' size='mini'>删除</Button>
|
<Button className='button-dark-red' size='mini'>删除</Button>
|
||||||
</View>
|
</View> */}
|
||||||
</View>
|
</View>
|
||||||
<CopyrightComponent></CopyrightComponent>
|
<CopyrightComponent></CopyrightComponent>
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@ import { AtInput, AtImagePicker, AtTextarea, Picker } from 'taro-ui'
|
|||||||
import CopyrightComponent from '../../component/copyrightComponent/copyrightComponent'
|
import CopyrightComponent from '../../component/copyrightComponent/copyrightComponent'
|
||||||
import URL from '../../serviceAPI.config'
|
import URL from '../../serviceAPI.config'
|
||||||
import InteractionComponent from '../../component/interactionComponent/interactionComponent'
|
import InteractionComponent from '../../component/interactionComponent/interactionComponent'
|
||||||
|
import LoginService from '../../util/LoginService'
|
||||||
|
|
||||||
|
|
||||||
import './myNeedsPublish.scss'
|
import './myNeedsPublish.scss'
|
||||||
@ -79,9 +80,13 @@ class MyNeedsPublish extends Component {
|
|||||||
'X-Requested-With': 'XMLHttpRequest'
|
'X-Requested-With': 'XMLHttpRequest'
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.then(res => {
|
.then(response => {
|
||||||
console.log('上传需求', res)
|
console.log('上传需求', response)
|
||||||
if (res.data.err_code === 0) {
|
|
||||||
|
const res = JSON.parse(response.data)
|
||||||
|
console.log('jonson parse', res)
|
||||||
|
Taro.hideLoading()
|
||||||
|
if (res.err_code === 0) {
|
||||||
Taro.showToast({
|
Taro.showToast({
|
||||||
title: '发布成功',
|
title: '发布成功',
|
||||||
icon: 'success',
|
icon: 'success',
|
||||||
@ -94,17 +99,20 @@ class MyNeedsPublish extends Component {
|
|||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
Taro.navigateTo({
|
Taro.navigateTo({
|
||||||
url: '/pages/myNeedsEdit/myNeedsEdit?id=' + res.data.sd_id
|
url: '/pages/myNeedsEdit/myNeedsEdit?id=' + res.sd_id
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}, 1500);
|
}, 1500);
|
||||||
})
|
})
|
||||||
|
|
||||||
} else if (res.data.err_code === 88888) {
|
} else if (res.err_code === 88888) {
|
||||||
loginExpired(res)
|
|
||||||
|
const resp = { data: { err_msg: res.err_msg } }
|
||||||
|
console.log('resp',resp)
|
||||||
|
loginExpired(resp)
|
||||||
} else {
|
} else {
|
||||||
Taro.showToast({
|
Taro.showToast({
|
||||||
title: res.data.err_msg,
|
title: res.err_msg,
|
||||||
icon: 'none',
|
icon: 'none',
|
||||||
duration: 1500
|
duration: 1500
|
||||||
})
|
})
|
||||||
@ -266,7 +274,12 @@ class MyNeedsPublish extends Component {
|
|||||||
|
|
||||||
componentWillUnmount() { }
|
componentWillUnmount() { }
|
||||||
|
|
||||||
componentDidShow() { }
|
componentDidShow() {
|
||||||
|
if (!Taro.getStorageSync('userInfo').user_id) {
|
||||||
|
LoginService()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
componentDidHide() { }
|
componentDidHide() { }
|
||||||
|
|
||||||
|
@ -147,7 +147,9 @@ class SupplyDemandView extends Component {
|
|||||||
duration: 1500
|
duration: 1500
|
||||||
})
|
})
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.goToMyNeedsPage()
|
Taro.navigateBack({
|
||||||
|
delta:-1
|
||||||
|
})
|
||||||
}, 1500);
|
}, 1500);
|
||||||
} else if (res.data.err_code === 88888) {
|
} else if (res.data.err_code === 88888) {
|
||||||
loginExpired(res)
|
loginExpired(res)
|
||||||
@ -168,19 +170,16 @@ class SupplyDemandView extends Component {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
goMyNeedEditPage() {
|
goMyNeedEditPage() {
|
||||||
console.log('edit page')
|
|
||||||
console.log('id', this.state.sd_id)
|
|
||||||
Taro.navigateTo({
|
Taro.navigateTo({
|
||||||
url: '/pages/myNeedsEdit/myNeedsEdit?id=' + this.state.sd_id
|
url: '/pages/myNeedsEdit/myNeedsEdit?id=' + this.state.sd_id
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
goToMyNeedsPage() {
|
goToMyNeedsPage() {
|
||||||
|
|
||||||
Taro.navigateTo({
|
Taro.navigateTo({
|
||||||
url: '/pages/myNeeds/myNeeds'
|
url: '/pages/myNeeds/myNeeds'
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
deleteButton() {
|
deleteButton() {
|
||||||
this.setState({ isDeleteModal: true })
|
this.setState({ isDeleteModal: true })
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import Taro, { Component } from '@tarojs/taro'
|
import Taro, { Component } from '@tarojs/taro'
|
||||||
import { View, Text, Button } from '@tarojs/components'
|
import { View, Text, Button, MovableArea, MovableView } from '@tarojs/components'
|
||||||
import { AtInput, Picker, AtIcon, AtModal, AtModalHeader, AtModalContent, AtModalAction } from 'taro-ui'
|
import { AtInput, Picker, AtIcon, AtModal, AtModalHeader, AtModalContent, AtModalAction } from 'taro-ui'
|
||||||
import URL from '../../serviceAPI.config'
|
import URL from '../../serviceAPI.config'
|
||||||
import ScrollToTopComponent from '../../component/scrollToTopComponent/scrollToTopComponent'
|
import ScrollToTopComponent from '../../component/scrollToTopComponent/scrollToTopComponent'
|
||||||
@ -35,6 +35,8 @@ class MySupplyDemand extends Component {
|
|||||||
currentPage: 1,//当前页数
|
currentPage: 1,//当前页数
|
||||||
isShowTopNav: false,// 是否显示返回顶部按钮
|
isShowTopNav: false,// 是否显示返回顶部按钮
|
||||||
loadMorePageIndex: 1,//上拉加载页面数
|
loadMorePageIndex: 1,//上拉加载页面数
|
||||||
|
screenWidth: '',
|
||||||
|
screenHeight: ''
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//获取我的供求列表API
|
//获取我的供求列表API
|
||||||
@ -249,6 +251,23 @@ class MySupplyDemand extends Component {
|
|||||||
url: '/pages/supplyDemandView/supplyDemandView?sdId=' + sdId
|
url: '/pages/supplyDemandView/supplyDemandView?sdId=' + sdId
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
goToCenterPage() {
|
||||||
|
Taro.switchTab({
|
||||||
|
url: '/pages/individualCenter/individualCenter'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
getUserSystemInfo() {
|
||||||
|
Taro.getSystemInfo().then(res => {
|
||||||
|
return res
|
||||||
|
}).then(res => {
|
||||||
|
console.log('res', res)
|
||||||
|
this.setState({
|
||||||
|
screenWidth: res.screenWidth - 80 + 'px',
|
||||||
|
screenHeight: res.screenHeight - 200 + 'px'
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
componentWillMount() {
|
componentWillMount() {
|
||||||
@ -259,6 +278,7 @@ class MySupplyDemand extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
|
this.getUserSystemInfo()
|
||||||
Taro.showLoading({ title: '加载中' }).then(() => {
|
Taro.showLoading({ title: '加载中' }).then(() => {
|
||||||
this.getMySupplyDemand({})
|
this.getMySupplyDemand({})
|
||||||
})
|
})
|
||||||
@ -360,7 +380,7 @@ class MySupplyDemand extends Component {
|
|||||||
}) : <View className='no-more-title' >
|
}) : <View className='no-more-title' >
|
||||||
没有更多了....
|
没有更多了....
|
||||||
</View >
|
</View >
|
||||||
return (
|
return (<MovableArea style='height: 100vh; width: 100%; '>
|
||||||
<View className='mySupplyDemand'>
|
<View className='mySupplyDemand'>
|
||||||
{/* 是否删除供求确认框 */}
|
{/* 是否删除供求确认框 */}
|
||||||
{modalMessageConfirmElement}
|
{modalMessageConfirmElement}
|
||||||
@ -454,6 +474,11 @@ class MySupplyDemand extends Component {
|
|||||||
<CopyrightComponent></CopyrightComponent>
|
<CopyrightComponent></CopyrightComponent>
|
||||||
|
|
||||||
</View>
|
</View>
|
||||||
|
<MovableView className='movable-point' x={this.state.screenWidth} y={this.state.screenHeight} style='opacity:0.3' direction='all' onClick={this.goToCenterPage.bind(this)} >
|
||||||
|
|
||||||
|
个人中心
|
||||||
|
</MovableView>
|
||||||
|
</MovableArea>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,21 @@ $themeColor:#FF7142;
|
|||||||
.button-orange, .button-dark-red,.button-green{
|
.button-orange, .button-dark-red,.button-green{
|
||||||
font-size:28rpx;
|
font-size:28rpx;
|
||||||
}
|
}
|
||||||
|
.movable-point{
|
||||||
|
height:130rpx;
|
||||||
|
width:130rpx;
|
||||||
|
color:#ffffff;
|
||||||
|
background-color:black;
|
||||||
|
opacity: 0.3;
|
||||||
|
border-radius:50%;
|
||||||
|
position:fixed;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content:center;
|
||||||
|
font-size:25rpx;
|
||||||
|
opacity:1 ;
|
||||||
|
position:fixed;
|
||||||
|
}
|
||||||
|
|
||||||
.mySupplyDemand{
|
.mySupplyDemand{
|
||||||
padding: 10px 20px;
|
padding: 10px 20px;
|
||||||
|
@ -240,7 +240,7 @@ class SupplyDemand extends Component {
|
|||||||
LoginService()
|
LoginService()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
Taro.navigateTo({
|
Taro.redirectTo({
|
||||||
url: '/pages/mySupplyDemand/mySupplyDemand'
|
url: '/pages/mySupplyDemand/mySupplyDemand'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -121,19 +121,19 @@ class SupplyDemandView extends Component {
|
|||||||
|
|
||||||
}
|
}
|
||||||
goToSDPublishPage() {
|
goToSDPublishPage() {
|
||||||
Taro.navigateTo({
|
Taro.redirectTo({
|
||||||
url: '/pages/supplyDemandPublish/supplyDemandPublish',// 供求发布页面
|
url: '/pages/supplyDemandPublish/supplyDemandPublish',// 供求发布页面
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
// 跳转到我的供求编辑页面
|
// 跳转到我的供求编辑页面
|
||||||
goToMyDSEditPage() {
|
goToMyDSEditPage() {
|
||||||
Taro.navigateTo({
|
Taro.redirectTo({
|
||||||
url: '/pages/myDemandSupplyEdit/myDemandSupplyEdit?sdId=' + this.state.itemId
|
url: '/pages/myDemandSupplyEdit/myDemandSupplyEdit?sdId=' + this.state.itemId
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
goToMySDPage() {
|
goToMySDPage() {
|
||||||
Taro.navigateBack({
|
Taro.redirectTo({
|
||||||
url: '/pages/mySupplyDemand/mySupplyDemand',//我的供求页面
|
url: '/pages/mySupplyDemand/mySupplyDemand',//我的供求页面
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -17,137 +17,155 @@ bug: 商品编辑 增加图片后 图片顺序乱了
|
|||||||
|
|
||||||
|
|
||||||
等待后台--- 单个我的商品页面的图片顺序,单个我的需求页面的接口, 当个我哦的需求编辑页面的接口
|
等待后台--- 单个我的商品页面的图片顺序,单个我的需求页面的接口, 当个我哦的需求编辑页面的接口
|
||||||
|
|
||||||
import '@tarojs/async-await'
|
|
||||||
import Taro, { Component } from '@tarojs/taro'
|
import Taro, { Component } from '@tarojs/taro'
|
||||||
import { Provider } from '@tarojs/redux'
|
import { View, Input, Button, Image } from '@tarojs/components'
|
||||||
import Home from './pages/home'
|
import URL from '../../serviceAPI.config'
|
||||||
|
|
||||||
import configStore from './store'
|
import './login.scss'
|
||||||
|
|
||||||
import './app.scss'
|
|
||||||
|
|
||||||
// 如果需要在 h5 环境中开启 React Devtools
|
|
||||||
// 取消以下注释:
|
|
||||||
// if (process.env.NODE_ENV !== 'production' && process.env.TARO_ENV === 'h5') {
|
|
||||||
// require('nerv-devtools')
|
|
||||||
// }
|
|
||||||
|
|
||||||
const store = configStore()
|
class Login extends Component {
|
||||||
|
|
||||||
class App extends Component {
|
|
||||||
|
|
||||||
isTrue = Taro.getStorageSync('session_id') ? true : false
|
|
||||||
config = {
|
config = {
|
||||||
pages: [
|
navigationBarTitleText: '登入'
|
||||||
//'pages/index/index', // index页面
|
|
||||||
'pages/home/home',//首页 ---------------------
|
|
||||||
'pages/login/login',//登入页面 ---------------------
|
|
||||||
'pages/shop/shop',//店铺页面 ---------------------
|
|
||||||
'pages/goods/goods',// 商品页面 ---------------------
|
|
||||||
'pages/goodsPublish/goodsPublish',// 商品发布页面 ---------------------
|
|
||||||
'pages/supplyDemandPublish/supplyDemandPublish',// 供求发布页面 ---------------------
|
|
||||||
'pages/mySupplyDemand/mySupplyDemand',// 我的供求列表页面 ---------------------
|
|
||||||
'pages/myGoodsEdit/myGoodsEdit',// 我的商品编辑页面 ---------------------
|
|
||||||
'pages/allDemanding/allDemanding',// 所有供求页面 ---------------------
|
|
||||||
'pages/myGoodList/myGoodList',// 我的商品列表页面 --------------------- 编辑商品按键
|
|
||||||
'pages/myDemandSupplyEdit/myDemandSupplyEdit',// 我的供求编辑页面 ---------------------
|
|
||||||
'pages/supplyDemandView/supplyDemandView',// 查看单个供求页面
|
|
||||||
'pages/grabOrderPage/grabOrderPage',// 抢单页面
|
|
||||||
'pages/myNeeds/myNeeds',// 我的需求页面
|
|
||||||
'pages/myNeedsView/myNeedsView',// 单个需求查看页面
|
|
||||||
'pages/myNeedsEdit/myNeedsEdit',// 单个需求编辑页面
|
|
||||||
'pages/myNeedsPublish/myNeedsPublish',// 需求发布
|
|
||||||
|
|
||||||
// 'pages/shopDescription/shopDescription',
|
|
||||||
],
|
|
||||||
permission: {
|
|
||||||
"scope.userLocation": {
|
|
||||||
"desc": "你的位置信息将用于小程序位置接口的效果展示"
|
|
||||||
}
|
}
|
||||||
|
constructor() {
|
||||||
|
this.state = {
|
||||||
|
username: '',
|
||||||
|
password: '',
|
||||||
|
backgroundImage: 'background-image:url(' + URL.Base + '/Public/images/bg3.jpg);'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//用户信息姓名和电话号码接口
|
||||||
|
setUserInfoToStorage() {
|
||||||
|
Taro.request({
|
||||||
|
url: URL.ShopWxStore,
|
||||||
|
header: {
|
||||||
|
'Cookie': 'PFWSSS=' + Taro.getStorageSync('session_id'),
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.then(res => {
|
||||||
|
if (res.data.err_msg === 'success') {
|
||||||
|
Taro.setStorageSync('user_identity', { username: res.data.otherData.userName, userphone: res.data.otherData.userPhone })
|
||||||
|
|
||||||
|
} else {
|
||||||
|
Taro.showToast({
|
||||||
|
title: res.data.err_msg,
|
||||||
|
icon: 'none',
|
||||||
|
duration: 1500
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
loginApi() {
|
||||||
|
Taro.request({
|
||||||
|
url: URL.Base + 'user-login',
|
||||||
|
method: 'POST',
|
||||||
|
dataType: 'json',
|
||||||
|
data: {
|
||||||
|
username: this.state.username,
|
||||||
|
password: this.state.password,
|
||||||
},
|
},
|
||||||
window: {
|
header: {
|
||||||
backgroundTextStyle: 'light',
|
'content-type': 'application/x-www-form-urlencoded',
|
||||||
navigationBarBackgroundColor: '#fff',
|
'X-Requested-With': 'XMLHttpRequest'
|
||||||
navigationBarTitleText: 'WeChat',
|
}
|
||||||
navigationBarTextStyle: 'black',
|
})
|
||||||
// enablePullDownRefresh:true
|
.then(res => {
|
||||||
onReachBottomDistance: 0
|
if (res.data.err_code === 0) {
|
||||||
},
|
|
||||||
|
|
||||||
tabBar: {
|
Taro.showToast({
|
||||||
list: [{
|
title: res.data.err_msg && '登入成功',
|
||||||
pagePath: "pages/home/home",
|
icon: 'success',
|
||||||
text: "首页",
|
duration: 1000
|
||||||
iconPath: "./icons/home.png",
|
})
|
||||||
selectedIconPath: "./icons/home-actived.png"
|
Taro.setStorageSync('session_id', res.data.session_id)
|
||||||
},
|
Taro.setStorageSync('shopInfo', res.data.shop_info)
|
||||||
|
Taro.setStorageSync('userInfo', res.data.user_info)
|
||||||
|
Taro.setStorageSync('accountInfo',{username:this.state.username,password:this.state.password})
|
||||||
|
|
||||||
, {
|
this.setUserInfoToStorage()
|
||||||
pagePath: "pages/myNeedsPublish/myNeedsPublish",
|
|
||||||
text: "需求发布",
|
setTimeout(() => {
|
||||||
iconPath: "./icons/publish.png",
|
// Taro.navigateBack({
|
||||||
selectedIconPath: "./icons/publish-actived.png"
|
// delta: 1
|
||||||
}
|
// })
|
||||||
, {
|
Taro.reLaunch({
|
||||||
pagePath: "pages/myNeeds/myNeeds",
|
url:'/pages/home/home'
|
||||||
text: "我的需求",
|
})
|
||||||
iconPath: "./icons/needs.png",
|
}, 1000);
|
||||||
selectedIconPath: "./icons/needs-actived.png"
|
|
||||||
}
|
} else {
|
||||||
// , {
|
Taro.showToast({
|
||||||
// pagePath: "pages/individualCenter/individualCenter",
|
title: res.data.msg,
|
||||||
// text: "个人中心",
|
icon: 'none',
|
||||||
// iconPath: "./icons/needs.png",
|
duration: 2000
|
||||||
// selectedIconPath: "./icons/needs-actived.png"
|
})
|
||||||
// }
|
|
||||||
],
|
|
||||||
color: '#333',
|
|
||||||
selectedColor: '#FF7142',
|
|
||||||
backgroundColor: '#fff',
|
|
||||||
borderStyle: 'black'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
usernameHandler(e) {
|
||||||
|
let value = e.detail.value
|
||||||
|
this.setState({ username: value })
|
||||||
|
}
|
||||||
|
passwordHandler(e) {
|
||||||
|
let value = e.detail.value
|
||||||
|
this.setState({ password: value })
|
||||||
|
}
|
||||||
|
loginHandler() {
|
||||||
|
this.loginApi()
|
||||||
|
}
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
componentWillReceiveProps(nextProps) {
|
||||||
|
console.log(this.props, nextProps)
|
||||||
|
}
|
||||||
|
|
||||||
|
componentWillUnmount() { }
|
||||||
|
|
||||||
componentDidShow() { }
|
componentDidShow() { }
|
||||||
|
|
||||||
componentDidHide() { }
|
componentDidHide() { }
|
||||||
|
|
||||||
componentCatchError() { }
|
|
||||||
|
|
||||||
componentDidCatchError() { }
|
|
||||||
|
|
||||||
// 在 App 类中的 render() 函数没有实际作用
|
|
||||||
// 请勿修改此函数
|
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<Provider store={store}>
|
<View className='login'>
|
||||||
<Home />
|
<View className='background' style={this.state.backgroundImage}></View>
|
||||||
</Provider>
|
<View className='logo'>
|
||||||
|
<View className='image-wrapper'>
|
||||||
|
<View className='image-inner-wrapper'>
|
||||||
|
<Image style='width: 240px;height: 80px;background: #fff;' src={URL.Base + '/Public/images/com-logo.png'} />
|
||||||
|
</View>
|
||||||
|
|
||||||
|
<View className='title'>全屋定制商城</View>
|
||||||
|
</View>
|
||||||
|
|
||||||
|
</View>
|
||||||
|
<View className='login-wrapper'>
|
||||||
|
<View className='title'>用户登入</View>
|
||||||
|
<View className='bgtopWrap'>
|
||||||
|
<View className='loginWrap'>
|
||||||
|
<View className='username'>
|
||||||
|
<Input type='text' focus={true} name='username' maxLength='11' placeholder='请输入用户名/手机号' value={this.state.username} onInput={this.usernameHandler} />
|
||||||
|
</View>
|
||||||
|
<View className='password'>
|
||||||
|
<Input type='password' name='password' placeholder='请输入密码' value={this.state.password} onInput={this.passwordHandler} />
|
||||||
|
</View>
|
||||||
|
|
||||||
|
<Button className='button button-orange' onClick={this.loginHandler}>登录</Button>
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
|
||||||
|
</View>
|
||||||
|
|
||||||
|
</View>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Taro.render(<App />, document.getElementById('app'))
|
export default Login
|
||||||
// {
|
|
||||||
// pagePath: "pages/goodsPublish/goodsPublish",
|
|
||||||
// text: "商品发布",
|
|
||||||
// iconPath: "./icons/box.png",
|
|
||||||
// selectedIconPath: "./icons/box-actived.png"
|
|
||||||
// }, {
|
|
||||||
// pagePath: "pages/supplyDemandPublish/supplyDemandPublish",
|
|
||||||
// text: "供求发布",
|
|
||||||
// iconPath: "./icons/publish.png",
|
|
||||||
// selectedIconPath: "./icons/publish-actived.png"
|
|
||||||
// }
|
|
||||||
// , {
|
|
||||||
// pagePath: "pages/mySupplyDemand/mySupplyDemand",
|
|
||||||
// text: "我的供求",
|
|
||||||
// iconPath: "./icons/menu.png",
|
|
||||||
// selectedIconPath: "./icons/menu-actived.png"
|
|
||||||
// }
|
|
||||||
|
@ -1,85 +1,11 @@
|
|||||||
import Taro from '@tarojs/taro'
|
import Taro from '@tarojs/taro'
|
||||||
|
|
||||||
// //用户信息姓名和电话号码接口
|
// 当用户没用登入时候 切换到首页, 然后导航到登录页面
|
||||||
// const setUserInfoToStorage=()=>{
|
|
||||||
// Taro.request({
|
|
||||||
// url: URL.ShopWxStore,
|
|
||||||
// header: {
|
|
||||||
// 'Cookie': 'PFWSSS=' + Taro.getStorageSync('session_id'),
|
|
||||||
// }
|
|
||||||
// })
|
|
||||||
// .then(res => {
|
|
||||||
// if (res.data.err_msg === 'success') {
|
|
||||||
// Taro.setStorageSync('user_identity', { username: res.data.otherData.userName, userphone: res.data.otherData.userPhone })
|
|
||||||
|
|
||||||
// } else {
|
|
||||||
// Taro.showToast({
|
|
||||||
// title: res.data.err_msg,
|
|
||||||
// icon: 'none',
|
|
||||||
// duration: 1500
|
|
||||||
// })
|
|
||||||
// }
|
|
||||||
// })
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 异步函数登入api
|
|
||||||
export default function login() {
|
export default function login() {
|
||||||
Taro.redirectTo({
|
Taro.switchTab({
|
||||||
|
url: '/pages/home/home'
|
||||||
|
})
|
||||||
|
Taro.navigateTo({
|
||||||
url:'/pages/login/login'
|
url:'/pages/login/login'
|
||||||
})
|
})
|
||||||
|
|
||||||
// Taro.login({
|
|
||||||
// success(res) {
|
|
||||||
// if (res.code) {
|
|
||||||
// // 发起网络请求
|
|
||||||
// // console.log('手机端微信code:',res.code)
|
|
||||||
// Taro.request({
|
|
||||||
// url: URL.Login,
|
|
||||||
// method: 'POST',
|
|
||||||
// dataType: 'json',
|
|
||||||
// data: {
|
|
||||||
// code: res.code
|
|
||||||
// },
|
|
||||||
// header: {
|
|
||||||
// 'content-type': 'application/x-www-form-urlencoded',
|
|
||||||
// }
|
|
||||||
// })
|
|
||||||
// .then(response => {
|
|
||||||
// if (response.data.err_code === 888) {
|
|
||||||
// console.log('微信登入成功', response)
|
|
||||||
// Taro.showToast({
|
|
||||||
// title: '微信登入成功',
|
|
||||||
// icon: 'success',
|
|
||||||
// duration: 2000
|
|
||||||
// })
|
|
||||||
// Taro.setStorageSync('session_id', response.data.session_id)
|
|
||||||
// Taro.setStorageSync('shopInfo', response.data.shop_info)
|
|
||||||
// Taro.setStorageSync('userInfo', response.data.user_info)
|
|
||||||
// setUserInfoToStorage()
|
|
||||||
// } else if (response.data.err_code === 0){
|
|
||||||
// Taro.redirectTo({
|
|
||||||
// url: '/pages/login/login'
|
|
||||||
// })
|
|
||||||
// }else{
|
|
||||||
// Taro.showToast({
|
|
||||||
// title: '登入失败' + response.data.err_msg,
|
|
||||||
// icon: 'none',
|
|
||||||
// duration: 2000
|
|
||||||
// })
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// ).catch(err => {
|
|
||||||
// console.log('登入微信失败', err)
|
|
||||||
|
|
||||||
// }).then(()=>{
|
|
||||||
|
|
||||||
// })
|
|
||||||
// }
|
|
||||||
// else {
|
|
||||||
// console.log('登录失败!' + res.errMsg)
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// })
|
|
||||||
}
|
}
|
@ -1,14 +1,47 @@
|
|||||||
import Taro from '@tarojs/taro'
|
import Taro from '@tarojs/taro'
|
||||||
|
import standardLogin from '../util/standardLogin'
|
||||||
|
import weChatLogin from '../util/weChatLogin'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const tabbarURL = [
|
||||||
|
"pages/home/home",
|
||||||
|
"pages/myNeedsPublish/myNeedsPublish",
|
||||||
|
"pages/myNeeds/myNeeds",
|
||||||
|
"pages/individualCenter/individualCenter"
|
||||||
|
]
|
||||||
|
function reloadPage(){
|
||||||
|
let length = Taro.getCurrentPages().length - 1
|
||||||
|
let currentURL = Taro.getCurrentPages()[length].route
|
||||||
|
|
||||||
|
tabbarURL.includes(currentURL) ?
|
||||||
|
Taro.reLaunch({
|
||||||
|
url: '/' + currentURL
|
||||||
|
}) : Taro.navigateBack({
|
||||||
|
delta:-1
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
export default function loginExpired(res) {
|
export default function loginExpired(res) {
|
||||||
Taro.clearStorageSync()
|
// Taro.clearStorageSync()
|
||||||
Taro.showToast({
|
Taro.showToast({
|
||||||
title: res.data.err_msg,
|
title:'登录过期,重新登录中...',
|
||||||
icon: 'none'
|
icon:'none',
|
||||||
|
duration:2000
|
||||||
})
|
})
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
Taro.reLaunch({
|
const hasAccount = Taro.getStorageSync('accountInfo')
|
||||||
url: '/pages/home/home'
|
|
||||||
|
if (hasAccount) {
|
||||||
|
standardLogin(hasAccount.username, hasAccount.password).then(res => {
|
||||||
|
reloadPage()
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
weChatLogin().then(res=>{
|
||||||
|
reloadPage()
|
||||||
})
|
})
|
||||||
}, 1500);
|
}
|
||||||
|
}, 2000);
|
||||||
}
|
}
|
18
src/util/reloadCurrentPage.js
Normal file
18
src/util/reloadCurrentPage.js
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
import Taro from '@tarojs/taro'
|
||||||
|
|
||||||
|
const tabbarURL = [
|
||||||
|
"pages/home/home",
|
||||||
|
"pages/myNeedsPublish/myNeedsPublish",
|
||||||
|
"pages/myNeeds/myNeeds",
|
||||||
|
"pages/individualCenter/individualCenter"
|
||||||
|
]
|
||||||
|
export default function reloadCurrentPage() {
|
||||||
|
let currentURL = Taro.getCurrentPages().route
|
||||||
|
console.log('reloadCurrentPage',currentURL)
|
||||||
|
tabbarURL.includes(currentURL) ?
|
||||||
|
Taro.switchTab({
|
||||||
|
url: '/' + currentURL
|
||||||
|
}) : Taro.redirectTo({
|
||||||
|
url: '/' + currentURL
|
||||||
|
})
|
||||||
|
}
|
60
src/util/standardLogin.js
Normal file
60
src/util/standardLogin.js
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
import Taro from '@tarojs/taro'
|
||||||
|
import URL from '../serviceAPI.config'
|
||||||
|
|
||||||
|
|
||||||
|
const setUserInfoToStorage = () => {
|
||||||
|
Taro.request({
|
||||||
|
url: URL.ShopWxStore,
|
||||||
|
header: {
|
||||||
|
'Cookie': 'PFWSSS=' + Taro.getStorageSync('session_id'),
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.then(res => {
|
||||||
|
if (res.data.err_msg === 'success') {
|
||||||
|
Taro.setStorageSync('user_identity', { username: res.data.otherData.userName, userphone: res.data.otherData.userPhone })
|
||||||
|
|
||||||
|
} else {
|
||||||
|
Taro.showToast({
|
||||||
|
title: res.data.err_msg,
|
||||||
|
icon: 'none',
|
||||||
|
duration: 1500
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
export default function standardLogin(username, password) {
|
||||||
|
return new Promise((resolve,reject)=>{
|
||||||
|
Taro.request({
|
||||||
|
url: URL.Base + 'user-login',
|
||||||
|
method: 'POST',
|
||||||
|
dataType: 'json',
|
||||||
|
data: {
|
||||||
|
username: username,
|
||||||
|
password: password,
|
||||||
|
},
|
||||||
|
header: {
|
||||||
|
'content-type': 'application/x-www-form-urlencoded',
|
||||||
|
'X-Requested-With': 'XMLHttpRequest'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.then(res => {
|
||||||
|
if (res.data.err_code === 0) {
|
||||||
|
Taro.showToast({
|
||||||
|
title: '登入成功',
|
||||||
|
icon: 'success',
|
||||||
|
duration: 1000
|
||||||
|
})
|
||||||
|
Taro.setStorageSync('session_id', res.data.session_id)
|
||||||
|
Taro.setStorageSync('shopInfo', res.data.shop_info)
|
||||||
|
Taro.setStorageSync('userInfo', res.data.user_info)
|
||||||
|
Taro.setStorageSync('accountInfo', { username: username, password: password })
|
||||||
|
setUserInfoToStorage()
|
||||||
|
resolve('success')
|
||||||
|
} else {
|
||||||
|
|
||||||
|
reject(res)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
@ -26,7 +26,7 @@ const setUserInfoToStorage = () => {
|
|||||||
|
|
||||||
|
|
||||||
// 异步函数登入api
|
// 异步函数登入api
|
||||||
export default function login() {
|
export default function wechatLogin() {
|
||||||
return new Promise((resolve,reject)=>{
|
return new Promise((resolve,reject)=>{
|
||||||
Taro.login({
|
Taro.login({
|
||||||
success(res) {
|
success(res) {
|
||||||
|
Loading…
Reference in New Issue
Block a user