diff --git a/src/app.js b/src/app.js
index 87baeb9..ecbbbf6 100644
--- a/src/app.js
+++ b/src/app.js
@@ -20,7 +20,7 @@ class App extends Component {
config = {
pages: [
//'pages/index/index', // index页面
- 'pages/individualCenter/individualCenter',// 个人中心页面
+
'pages/home/home',//首页 ---------------------
'pages/login/login',//登入页面 ---------------------
'pages/shop/shop',//店铺页面 ---------------------
@@ -38,6 +38,7 @@ class App extends Component {
'pages/myNeedsView/myNeedsView',// 单个需求查看页面
'pages/myNeedsEdit/myNeedsEdit',// 单个需求编辑页面
'pages/myNeedsPublish/myNeedsPublish',// 需求发布
+ 'pages/individualCenter/individualCenter',// 个人中心页面
diff --git a/src/pages/allDemanding/allDemanding.js b/src/pages/allDemanding/allDemanding.js
index 2413e6d..60100c2 100644
--- a/src/pages/allDemanding/allDemanding.js
+++ b/src/pages/allDemanding/allDemanding.js
@@ -164,8 +164,9 @@ class AllDemanding extends Component {
})
}
- grabOrder(Id) {
- this.setState({ isOpenedGrabModal: true, grabOrderId: Id })
+ grabOrder(e) {
+ const id = e.currentTarget.dataset.eTapAA
+ this.setState({ isOpenedGrabModal: true, grabOrderId: id })
}
handleGrabModalClose() {
this.setState({ isOpenedGrabModal: false })
@@ -202,10 +203,10 @@ class AllDemanding extends Component {
this.setState({ industryTypeSelected: value })
}
- goToGrabOrderPage(orderId) {
+ goToGrabOrderPage(e) {
+ const id = e.currentTarget.dataset.eTapAA
Taro.navigateTo({
-
- url: '/pages/grabOrderPage/grabOrderPage?orderId=' + orderId
+ url: '/pages/grabOrderPage/grabOrderPage?orderId=' + id
})
}
diff --git a/src/pages/goodsPublish/goodsPublish.js b/src/pages/goodsPublish/goodsPublish.js
index f552819..be054e2 100644
--- a/src/pages/goodsPublish/goodsPublish.js
+++ b/src/pages/goodsPublish/goodsPublish.js
@@ -264,7 +264,6 @@ class GoodsPublish extends Component {
goToMyGoodListPage() {
- console.log('list ', Taro.getStorageSync('userInfo'))
if (!Taro.getStorageSync('userInfo').user_id) {
LoginService()
return
diff --git a/src/pages/grabOrderPage/grabOrderPage.js b/src/pages/grabOrderPage/grabOrderPage.js
index 444da30..13ab6c1 100644
--- a/src/pages/grabOrderPage/grabOrderPage.js
+++ b/src/pages/grabOrderPage/grabOrderPage.js
@@ -70,16 +70,12 @@ class GrabOrderPage extends Component {
renderingImage: res.data.sdInfo.render_pics || []
})
} else if (res.data.err_code === 88888) {
- Taro.clearStorageSync()
+ loginExpired(res)
+ }else{
Taro.showToast({
- title: res.data.err_msg,
- icon: 'none'
+ title:res.data.err_msg,
+ icon:'none'
})
- setTimeout(() => {
- Taro.switchTab({
- url: '/pages/home/home'
- })
- }, 1500);
}
}
@@ -171,7 +167,7 @@ class GrabOrderPage extends Component {
componentDidHide() { }
goMyNeedsPublishPage() {
- Taro.navigateTo({
+ Taro.switchTab({
url: '/pages/myNeedsPublish/myNeedsPublish'
})
}
@@ -218,8 +214,8 @@ class GrabOrderPage extends Component {
duration: 1500
})
setTimeout(() => {
- Taro.switchTab({
- url: '/pages/myNeeds/myNeeds'
+ Taro.navigateBack({
+ delta:-1
})
}, 1500);
} else if (res.data.err_code === 88888) {
@@ -232,7 +228,6 @@ class GrabOrderPage extends Component {
})
}
})
-
}
render() {
@@ -259,7 +254,7 @@ class GrabOrderPage extends Component {
我的需求
-
+ {/*
@@ -269,7 +264,7 @@ class GrabOrderPage extends Component {
-
+ */}
} else if (localStoageUserId === this.state.userId && this.state.stateId != '1') {
ButtonElement =
diff --git a/src/pages/individualCenter/individualCenter.js b/src/pages/individualCenter/individualCenter.js
index 1a5d7af..ef2ca17 100644
--- a/src/pages/individualCenter/individualCenter.js
+++ b/src/pages/individualCenter/individualCenter.js
@@ -2,7 +2,7 @@ import Taro, { Component } from '@tarojs/taro'
import { View, Image, Button } from '@tarojs/components'
import { AtGrid, AtList, AtListItem, AtAvatar, AtButton } from "taro-ui"
-
+import LoginService from '../../util/LoginService'
import './individualCenter.scss'
import URL from '../../serviceAPI.config'
@@ -117,7 +117,12 @@ class IndividualCenter extends Component {
componentWillUnmount() { }
- componentDidShow() { }
+ componentDidShow() {
+ if (!Taro.getStorageSync('userInfo').user_id) {
+ LoginService()
+ return
+ }
+ }
componentDidHide() { }
diff --git a/src/pages/login/login.js b/src/pages/login/login.js
index 353e7e7..638f8eb 100644
--- a/src/pages/login/login.js
+++ b/src/pages/login/login.js
@@ -1,7 +1,7 @@
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 standardLogin from '../../util/standardLogin'
import './login.scss'
@@ -17,74 +17,7 @@ class Login extends Component {
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) {
let value = e.detail.value
@@ -95,7 +28,37 @@ class Login extends Component {
this.setState({ password: value })
}
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() {
@@ -135,7 +98,7 @@ class Login extends Component {
-
+
diff --git a/src/pages/myDemandSupplyEdit/myDemandSupplyEdit.js b/src/pages/myDemandSupplyEdit/myDemandSupplyEdit.js
index 5a91871..7f26463 100644
--- a/src/pages/myDemandSupplyEdit/myDemandSupplyEdit.js
+++ b/src/pages/myDemandSupplyEdit/myDemandSupplyEdit.js
@@ -146,9 +146,9 @@ class MyDemandSupplyEdit extends Component {
url: '/pages/supplyDemandPublish/supplyDemandPublish'
})
} else {
- // Taro.navigateTo({
- // url: '/pages/myDemandSupplyEdit/myDemandSupplyEdit?sdId=' + res.data.sd_id
- // })
+ Taro.redirectTo({
+ url: '/pages/mySupplyDemand/mySupplyDemand',//我的供求页面
+ })
}
}, 1000);
})
@@ -314,9 +314,9 @@ class MyDemandSupplyEdit extends Component {
}
}
goToMyDemSupPage() {
- Taro.navigateBack({
- delta: 1
- })
+ Taro.redirectTo({
+ url: '/pages/mySupplyDemand/mySupplyDemand',//我的供求页面
+ })
}
deleteButtonHandler() {
this.setState({ isConfirmWindow: true })
@@ -468,9 +468,9 @@ class MyDemandSupplyEdit extends Component {
-
+ {/*
-
+ */}
{/*
@@ -478,9 +478,9 @@ class MyDemandSupplyEdit extends Component {
-
+ {/*
-
+ */}
diff --git a/src/pages/myGoodList/myGoodList.js b/src/pages/myGoodList/myGoodList.js
index 6b2c978..616461d 100644
--- a/src/pages/myGoodList/myGoodList.js
+++ b/src/pages/myGoodList/myGoodList.js
@@ -5,8 +5,6 @@ import CopyrightComponent from '../../component/copyrightComponent/copyrightComp
import ScrollToTopComponent from '../../component/scrollToTopComponent/scrollToTopComponent'
import URL from '../../serviceAPI.config'
-
-
import './myGoodList.scss'
import loginExpired from '../../util/loginExpired';
@@ -47,8 +45,8 @@ class MyGoodList extends Component {
isOpenOffStockModal: false,// 是否显示下架模态框
isAddToList: false,// 是否下拉加载 如果是 就添加商品到我的商品列表
isShowTopNav: false,// 是否显示返回顶部按钮
- screenWidth:'',
- screenHeight:''
+ screenWidth: '',
+ screenHeight: ''
}
}
@@ -144,7 +142,9 @@ class MyGoodList extends Component {
}
}).then(res => {
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))
Taro.hideLoading()
@@ -588,16 +588,16 @@ class MyGoodList extends Component {
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'
+ 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'
+ })
})
- })
}
@@ -616,7 +616,7 @@ class MyGoodList extends Component {
componentWillUnmount() { }
componentDidShow() {
-
+
}
componentDidHide() { }
@@ -691,8 +691,8 @@ class MyGoodList extends Component {
return (
-
-
+
+
{/* 删除模态提示框 */}
{modalMessageDeleteElement}
{/* 下架模态框提示 */}
@@ -820,11 +820,12 @@ class MyGoodList extends Component {
-
- 个人中心
-
+
+
+ 个人中心
+
)
}
diff --git a/src/pages/myGoodsEdit/myGoodsEdit.js b/src/pages/myGoodsEdit/myGoodsEdit.js
index e91053d..847a852 100644
--- a/src/pages/myGoodsEdit/myGoodsEdit.js
+++ b/src/pages/myGoodsEdit/myGoodsEdit.js
@@ -46,6 +46,7 @@ class MyGoodsEdit extends Component {
}
})
.then(res => {
+ console.log('res',res)
if (res.data.err_code === 0) {
console.log('商品详情获取成功', res)
@@ -62,8 +63,6 @@ class MyGoodsEdit extends Component {
// }
// }
// }
-
-
if (Taro.getStorageSync('shopTypeObject')) {
let selectedValue = ''
const shopTypeObject = Taro.getStorageSync('shopTypeObject')
@@ -89,6 +88,7 @@ class MyGoodsEdit extends Component {
}
} else if (res.data.err_code === 88888) {
+ console.log('88888')
loginExpired(res)
}
else {
@@ -172,10 +172,14 @@ class MyGoodsEdit extends Component {
}).then(() => {
setTimeout(() => {
if (this.state.isSaveButton) {
- Taro.navigateBack({
- delta:1
+ // Taro.navigateBack({
+
+ // delta:1
// url: '/pages/myGoodsList/myGoodsEdit?id=' + this.$router.params.id
- })
+ // })
+ Taro.redirectTo({
+ url: '/pages/myGoodList/myGoodList'
+ })
} else if (this.state.isSaveAndNewBUtton) {
Taro.switchTab({
url: '/pages/goodsPublish/goodsPublish'
@@ -349,7 +353,7 @@ class MyGoodsEdit extends Component {
})
}
goToMyGoodListPage() {
- Taro.navigateTo({
+ Taro.redirectTo({
url: '/pages/myGoodList/myGoodList'
})
}
diff --git a/src/pages/myNeeds/myNeeds.js b/src/pages/myNeeds/myNeeds.js
index 78393b3..5e37c01 100644
--- a/src/pages/myNeeds/myNeeds.js
+++ b/src/pages/myNeeds/myNeeds.js
@@ -251,13 +251,15 @@ class MyNeeds extends Component {
needsStateSelected: this.state.needsState[e.detail.value]
})
}
- goToMyNeedsViewPage(Id) {
+ goToMyNeedsViewPage(e) {
+ const id = e.currentTarget.dataset.eTapAA
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({
url: '/pages/myNeedsEdit/myNeedsEdit?id=' + id
})
diff --git a/src/pages/myNeedsEdit/myNeedsEdit.js b/src/pages/myNeedsEdit/myNeedsEdit.js
index 1b9b17a..c1c8f80 100644
--- a/src/pages/myNeedsEdit/myNeedsEdit.js
+++ b/src/pages/myNeedsEdit/myNeedsEdit.js
@@ -171,13 +171,16 @@ class MyNeedsEdit extends Component {
setTimeout(() => {
console.log('this.state.isSaveAndNew', this.state.isSaveAndNew)
if (this.state.isSaveAndNew) {
- Taro.navigateTo({
- url: '/pages/myNeedsPublish/myNeedsPublish'
- })
+ // Taro.navigateTo({
+ // url: '/pages/myNeedsPublish/myNeedsPublish'
+ // })
} else {
// Taro.navigateTo({
// url: '/pages/myNeedsEdit/myNeedsEdit?id=' + this.state.sd_id
// })
+ Taro.reLaunch({
+ url: '/pages/myNeeds/myNeeds'
+ })
}
}, 1500);
})
@@ -513,15 +516,15 @@ class MyNeedsEdit extends Component {
-
+ {/*
-
+ */}
-
+ {/*
-
+ */}
diff --git a/src/pages/myNeedsPublish/myNeedsPublish.js b/src/pages/myNeedsPublish/myNeedsPublish.js
index 3651e27..7d992eb 100644
--- a/src/pages/myNeedsPublish/myNeedsPublish.js
+++ b/src/pages/myNeedsPublish/myNeedsPublish.js
@@ -6,6 +6,7 @@ import { AtInput, AtImagePicker, AtTextarea, Picker } from 'taro-ui'
import CopyrightComponent from '../../component/copyrightComponent/copyrightComponent'
import URL from '../../serviceAPI.config'
import InteractionComponent from '../../component/interactionComponent/interactionComponent'
+import LoginService from '../../util/LoginService'
import './myNeedsPublish.scss'
@@ -27,8 +28,8 @@ class MyNeedsPublish extends Component {
needsType: [{ name: '业主需求', id: '4' }, { name: '效果图', id: '5' }],
needsTypeSelected: { name: '业主需求', id: '4' },
title: '',
- contactName: Taro.getStorageSync('user_identity').username||'',
- contactNumber: Taro.getStorageSync('user_identity').userphone||'',
+ contactName: Taro.getStorageSync('user_identity').username || '',
+ contactNumber: Taro.getStorageSync('user_identity').userphone || '',
contactAddress: '',
content: '',
pickerImageUrl: [], // 上传的图片
@@ -79,9 +80,13 @@ class MyNeedsPublish extends Component {
'X-Requested-With': 'XMLHttpRequest'
}
})
- .then(res => {
- console.log('上传需求', res)
- if (res.data.err_code === 0) {
+ .then(response => {
+ console.log('上传需求', response)
+
+ const res = JSON.parse(response.data)
+ console.log('jonson parse', res)
+ Taro.hideLoading()
+ if (res.err_code === 0) {
Taro.showToast({
title: '发布成功',
icon: 'success',
@@ -94,17 +99,20 @@ class MyNeedsPublish extends Component {
})
} else {
Taro.navigateTo({
- url: '/pages/myNeedsEdit/myNeedsEdit?id=' + res.data.sd_id
+ url: '/pages/myNeedsEdit/myNeedsEdit?id=' + res.sd_id
})
}
}, 1500);
})
- } else if (res.data.err_code === 88888) {
- loginExpired(res)
+ } else if (res.err_code === 88888) {
+
+ const resp = { data: { err_msg: res.err_msg } }
+ console.log('resp',resp)
+ loginExpired(resp)
} else {
Taro.showToast({
- title: res.data.err_msg,
+ title: res.err_msg,
icon: 'none',
duration: 1500
})
@@ -266,7 +274,12 @@ class MyNeedsPublish extends Component {
componentWillUnmount() { }
- componentDidShow() { }
+ componentDidShow() {
+ if (!Taro.getStorageSync('userInfo').user_id) {
+ LoginService()
+ return
+ }
+ }
componentDidHide() { }
diff --git a/src/pages/myNeedsView/myNeedsView.js b/src/pages/myNeedsView/myNeedsView.js
index 93c7e59..528bee4 100644
--- a/src/pages/myNeedsView/myNeedsView.js
+++ b/src/pages/myNeedsView/myNeedsView.js
@@ -147,7 +147,9 @@ class SupplyDemandView extends Component {
duration: 1500
})
setTimeout(() => {
- this.goToMyNeedsPage()
+ Taro.navigateBack({
+ delta:-1
+ })
}, 1500);
} else if (res.data.err_code === 88888) {
loginExpired(res)
@@ -168,19 +170,16 @@ class SupplyDemandView extends Component {
})
}
goMyNeedEditPage() {
- console.log('edit page')
- console.log('id', this.state.sd_id)
+
Taro.navigateTo({
url: '/pages/myNeedsEdit/myNeedsEdit?id=' + this.state.sd_id
})
}
goToMyNeedsPage() {
-
Taro.navigateTo({
url: '/pages/myNeeds/myNeeds'
})
-
}
deleteButton() {
this.setState({ isDeleteModal: true })
diff --git a/src/pages/mySupplyDemand/mySupplyDemand.js b/src/pages/mySupplyDemand/mySupplyDemand.js
index efaa0eb..32dae13 100644
--- a/src/pages/mySupplyDemand/mySupplyDemand.js
+++ b/src/pages/mySupplyDemand/mySupplyDemand.js
@@ -1,5 +1,5 @@
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 URL from '../../serviceAPI.config'
import ScrollToTopComponent from '../../component/scrollToTopComponent/scrollToTopComponent'
@@ -35,6 +35,8 @@ class MySupplyDemand extends Component {
currentPage: 1,//当前页数
isShowTopNav: false,// 是否显示返回顶部按钮
loadMorePageIndex: 1,//上拉加载页面数
+ screenWidth: '',
+ screenHeight: ''
}
}
//获取我的供求列表API
@@ -111,7 +113,7 @@ class MySupplyDemand extends Component {
}
onSearchButtonHandler() {
-
+
Taro.showLoading({ title: '加载中' })
this.setState({ loadMorePageIndex: 1 }, () => {
@@ -156,7 +158,7 @@ class MySupplyDemand extends Component {
}
)
-
+
}
// 新增我的供求
@@ -236,7 +238,7 @@ class MySupplyDemand extends Component {
// 跳转到我的供求编辑页面
goToMyDSEditPage(e) {
- const sdId=e.currentTarget.dataset.eTapAA
+ const sdId = e.currentTarget.dataset.eTapAA
Taro.navigateTo({
url: '/pages/myDemandSupplyEdit/myDemandSupplyEdit?sdId=' + sdId
})
@@ -244,11 +246,28 @@ class MySupplyDemand extends Component {
}
// 转到供求查看页面
goSupplyDemandView(e) {
- const sdId=e.currentTarget.dataset.eTapAA
+ const sdId = e.currentTarget.dataset.eTapAA
Taro.navigateTo({
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() {
@@ -259,6 +278,7 @@ class MySupplyDemand extends Component {
}
componentDidMount() {
+ this.getUserSystemInfo()
Taro.showLoading({ title: '加载中' }).then(() => {
this.getMySupplyDemand({})
})
@@ -360,7 +380,7 @@ class MySupplyDemand extends Component {
}) :
没有更多了....
- return (
+ return (
{/* 是否删除供求确认框 */}
{modalMessageConfirmElement}
@@ -454,6 +474,11 @@ class MySupplyDemand extends Component {
+
+
+ 个人中心
+
+
)
}
}
diff --git a/src/pages/mySupplyDemand/mySupplyDemand.scss b/src/pages/mySupplyDemand/mySupplyDemand.scss
index e05c612..b78af4c 100644
--- a/src/pages/mySupplyDemand/mySupplyDemand.scss
+++ b/src/pages/mySupplyDemand/mySupplyDemand.scss
@@ -2,6 +2,21 @@ $themeColor:#FF7142;
.button-orange, .button-dark-red,.button-green{
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{
padding: 10px 20px;
diff --git a/src/pages/supplyDemandPublish/supplyDemandPublish.js b/src/pages/supplyDemandPublish/supplyDemandPublish.js
index 0f6faee..4d1a12b 100644
--- a/src/pages/supplyDemandPublish/supplyDemandPublish.js
+++ b/src/pages/supplyDemandPublish/supplyDemandPublish.js
@@ -240,7 +240,7 @@ class SupplyDemand extends Component {
LoginService()
return
}
- Taro.navigateTo({
+ Taro.redirectTo({
url: '/pages/mySupplyDemand/mySupplyDemand'
})
}
diff --git a/src/pages/supplyDemandView/supplyDemandView.js b/src/pages/supplyDemandView/supplyDemandView.js
index 09b011d..a683e25 100644
--- a/src/pages/supplyDemandView/supplyDemandView.js
+++ b/src/pages/supplyDemandView/supplyDemandView.js
@@ -121,19 +121,19 @@ class SupplyDemandView extends Component {
}
goToSDPublishPage() {
- Taro.navigateTo({
+ Taro.redirectTo({
url: '/pages/supplyDemandPublish/supplyDemandPublish',// 供求发布页面
})
}
// 跳转到我的供求编辑页面
goToMyDSEditPage() {
- Taro.navigateTo({
+ Taro.redirectTo({
url: '/pages/myDemandSupplyEdit/myDemandSupplyEdit?sdId=' + this.state.itemId
})
}
goToMySDPage() {
- Taro.navigateBack({
+ Taro.redirectTo({
url: '/pages/mySupplyDemand/mySupplyDemand',//我的供求页面
})
}
diff --git a/src/todo list.txt b/src/todo list.txt
index 8307de8..0055330 100644
--- a/src/todo list.txt
+++ b/src/todo list.txt
@@ -17,137 +17,155 @@ bug: 商品编辑 增加图片后 图片顺序乱了
等待后台--- 单个我的商品页面的图片顺序,单个我的需求页面的接口, 当个我哦的需求编辑页面的接口
-
-import '@tarojs/async-await'
import Taro, { Component } from '@tarojs/taro'
-import { Provider } from '@tarojs/redux'
-import Home from './pages/home'
+import { View, Input, Button, Image } from '@tarojs/components'
+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 App extends Component {
-
- isTrue = Taro.getStorageSync('session_id') ? true : false
+class Login extends Component {
config = {
- pages: [
- //'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": "你的位置信息将用于小程序位置接口的效果展示"
- }
- },
- window: {
- backgroundTextStyle: 'light',
- navigationBarBackgroundColor: '#fff',
- navigationBarTitleText: 'WeChat',
- navigationBarTextStyle: 'black',
- // enablePullDownRefresh:true
- onReachBottomDistance: 0
- },
-
- tabBar: {
- list: [{
- pagePath: "pages/home/home",
- text: "首页",
- iconPath: "./icons/home.png",
- selectedIconPath: "./icons/home-actived.png"
- },
-
- , {
- pagePath: "pages/myNeedsPublish/myNeedsPublish",
- text: "需求发布",
- iconPath: "./icons/publish.png",
- selectedIconPath: "./icons/publish-actived.png"
- }
- , {
- pagePath: "pages/myNeeds/myNeeds",
- text: "我的需求",
- iconPath: "./icons/needs.png",
- selectedIconPath: "./icons/needs-actived.png"
- }
- // , {
- // pagePath: "pages/individualCenter/individualCenter",
- // text: "个人中心",
- // iconPath: "./icons/needs.png",
- // selectedIconPath: "./icons/needs-actived.png"
- // }
- ],
- color: '#333',
- selectedColor: '#FF7142',
- backgroundColor: '#fff',
- borderStyle: 'black'
+ navigationBarTitleText: '登入'
+ }
+ 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,
+ },
+ 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)
+ Taro.setStorageSync('accountInfo',{username:this.state.username,password:this.state.password})
+
+ 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) {
+ let value = e.detail.value
+ this.setState({ username: value })
+ }
+ passwordHandler(e) {
+ let value = e.detail.value
+ this.setState({ password: value })
+ }
+ loginHandler() {
+ this.loginApi()
+ }
componentDidMount() {
}
+ componentWillReceiveProps(nextProps) {
+ console.log(this.props, nextProps)
+ }
+
+ componentWillUnmount() { }
+
componentDidShow() { }
componentDidHide() { }
- componentCatchError() { }
-
- componentDidCatchError() { }
-
- // 在 App 类中的 render() 函数没有实际作用
- // 请勿修改此函数
render() {
return (
-
-
-
+
+
+
+
+
+
+
+
+ 全屋定制商城
+
+
+
+
+ 用户登入
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
)
}
}
-Taro.render(, document.getElementById('app'))
- // {
- // 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"
- // }
\ No newline at end of file
+export default Login
diff --git a/src/util/LoginService.js b/src/util/LoginService.js
index b0320d2..2959b2a 100644
--- a/src/util/LoginService.js
+++ b/src/util/LoginService.js
@@ -1,85 +1,11 @@
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() {
- Taro.redirectTo({
- url: '/pages/login/login'
+ Taro.switchTab({
+ url: '/pages/home/home'
+ })
+ Taro.navigateTo({
+ 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)
-// }
-// }
-// })
}
\ No newline at end of file
diff --git a/src/util/loginExpired.js b/src/util/loginExpired.js
index e08f09e..51e2b1e 100644
--- a/src/util/loginExpired.js
+++ b/src/util/loginExpired.js
@@ -1,14 +1,47 @@
import Taro from '@tarojs/taro'
+import standardLogin from '../util/standardLogin'
+import weChatLogin from '../util/weChatLogin'
- export default function loginExpired(res){
- Taro.clearStorageSync()
- Taro.showToast({
- title: res.data.err_msg,
- icon: 'none'
+
+
+
+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) {
+ // Taro.clearStorageSync()
+ Taro.showToast({
+ title:'登录过期,重新登录中...',
+ icon:'none',
+ duration:2000
+ })
+
setTimeout(() => {
- Taro.reLaunch({
- url: '/pages/home/home'
+ const hasAccount = Taro.getStorageSync('accountInfo')
+
+ if (hasAccount) {
+ standardLogin(hasAccount.username, hasAccount.password).then(res => {
+ reloadPage()
})
- }, 1500);
+ } else {
+ weChatLogin().then(res=>{
+ reloadPage()
+ })
+ }
+ }, 2000);
}
\ No newline at end of file
diff --git a/src/util/reloadCurrentPage.js b/src/util/reloadCurrentPage.js
new file mode 100644
index 0000000..f0f424b
--- /dev/null
+++ b/src/util/reloadCurrentPage.js
@@ -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
+ })
+}
\ No newline at end of file
diff --git a/src/util/standardLogin.js b/src/util/standardLogin.js
new file mode 100644
index 0000000..38da3cb
--- /dev/null
+++ b/src/util/standardLogin.js
@@ -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)
+ }
+ })
+ })
+
+}
\ No newline at end of file
diff --git a/src/util/weChatLogin.js b/src/util/weChatLogin.js
index 9a0ecc7..3658d00 100644
--- a/src/util/weChatLogin.js
+++ b/src/util/weChatLogin.js
@@ -26,7 +26,7 @@ const setUserInfoToStorage = () => {
// 异步函数登入api
-export default function login() {
+export default function wechatLogin() {
return new Promise((resolve,reject)=>{
Taro.login({
success(res) {