diff --git a/src/component/AliShopTypeInteraction/AliShopTypeInteraction.js b/src/component/AliShopTypeInteraction/AliShopTypeInteraction.js
index 83be0a9..2fef4ae 100644
--- a/src/component/AliShopTypeInteraction/AliShopTypeInteraction.js
+++ b/src/component/AliShopTypeInteraction/AliShopTypeInteraction.js
@@ -58,7 +58,7 @@ class ShopTypeInteractionComp extends Component {
// console.log('state', this.state.initailMultiArray, this.state.interactionMultiArray)
// this.passDataToParent(this.state.initailMultiArray)
- //返回初始选项在 在商品编辑页面
+ //返回初始选项在 在商品编辑页面
// console.log('联动数据', this.state.interactionMultiArray)
@@ -173,6 +173,7 @@ class ShopTypeInteractionComp extends Component {
this.passDataToParent(result)
}
invokeAliPicker() {
+ console.log('clicked')
this.setState({
AliIsShowPicker:true
})
@@ -184,7 +185,7 @@ class ShopTypeInteractionComp extends Component {
// 当然父组件有新的props的 会从新渲染组件
componentWillReceiveProps(nextProps) {
-
+
}
componentWillUnmount() { }
@@ -201,7 +202,7 @@ class ShopTypeInteractionComp extends Component {
- {this.state.AliIsShowPicker ?
+ {this.state.AliIsShowPicker ?
diff --git a/src/component/AliShopTypeInteraction/AliShopTypeInteraction.scss b/src/component/AliShopTypeInteraction/AliShopTypeInteraction.scss
index 72d25e6..64eb25a 100644
--- a/src/component/AliShopTypeInteraction/AliShopTypeInteraction.scss
+++ b/src/component/AliShopTypeInteraction/AliShopTypeInteraction.scss
@@ -1,3 +1,7 @@
+
+.shop-interaction{
+ opacity: 1;
+}
.page-section{
border-bottom: 1Px solid #d6e4ef;
font-size:32rpx;
@@ -79,3 +83,9 @@
text-align: right;
}
}
+
+ // .picker-wrapper{
+ // .at-list__item{
+ // background: rgba(0,0,0,1)
+ // }
+ // }
diff --git a/src/pages/allDemanding/allDemanding.js b/src/pages/allDemanding/allDemanding.js
index 95a15bd..ac86e21 100644
--- a/src/pages/allDemanding/allDemanding.js
+++ b/src/pages/allDemanding/allDemanding.js
@@ -1,9 +1,10 @@
import Taro, { Component } from '@tarojs/taro'
-import { View, Text, Image, Button,Picker } from '@tarojs/components'
-import { AtInput, AtIcon, AtModal, AtModalHeader, AtModalContent, AtModalAction } from 'taro-ui'
+import { View, Text, Image, Button, Picker } from '@tarojs/components'
+import { AtInput, AtIcon, AtModal, AtModalHeader, AtModalContent, AtModalAction } from 'taro-ui'
import CopyrightComponent from '../../component/copyrightComponent/copyrightComponent'
import ScrollToTopComponent from '../../component/scrollToTopComponent/scrollToTopComponent'
+import AliIndustryTypeInteraction from '../../component/aliIndustryTypeInteraction/aliIndustryTypeInteraction'
import InteractionComponent from '../../component/interactionComponent/interactionComponent'
import loginExpired from '../../util/loginExpired'
import onClickValueService from '../../util/onClickValueService'
@@ -13,373 +14,383 @@ import './allDemanding.scss'
import eyeIcon from '../../icons/eye.png'
import { getGlobalStorage } from '../../util/getSetStoage';
import { showLoading } from '../../util/hideShowLoading';
+import platformChecker from '../../util/plaformChecker';
class AllDemanding extends Component {
- config = {
- navigationBarTitleText: '全部业主需求'
+ config = {
+ navigationBarTitleText: '全部业主需求'
+ }
+ constructor() {
+ super(...arguments)
+ this.state = {
+ supplys: [], // 需求列表
+ demandingState: [{ name: '全部', id: '' }, { name: '在用', id: '1' }, { name: '已抢单', id: '2' }, { name: '已抢光', id: '3' },], // 供求状态选择
+ demandingStateSelected: { name: '全部', id: '' }, // 当前供求状态
+ industryTypeSelected: { name: '全部', id: '' },// 当前行业分类
+ title: '',
+ startDateSel: '',
+ endDateSel: '',
+ isOpenedGrabModal: false,
+ grabOrderId: '',//抢到订单的id
+ isGrabOrderSuccess: false,// 是否显示轻提示
+ grabOrderSuccess: '无法显示绑定后的字段',// 抢单成功返回字段
+ isAddToList: false,// / 请求业主需求的时候是否添加到旧列表里
+ isShowTopNav: false,// 是否显示返回顶部按钮
+ loadMorePageIndex: 1
+
}
- constructor() {
- super(...arguments)
- this.state = {
- supplys: [], // 需求列表
- demandingState: [{ name: '全部', id: '' }, { name: '在用', id: '1' }, { name: '已抢单', id: '2' }, { name: '已抢光', id: '3' },], // 供求状态选择
- demandingStateSelected: { name: '全部', id: '' }, // 当前供求状态
- industryTypeSelected: { name: '全部', id: '' },// 当前行业分类
- title: '',
- startDateSel: '',
- endDateSel: '',
- isOpenedGrabModal: false,
- grabOrderId: '',//抢到订单的id
- isGrabOrderSuccess: false,// 是否显示轻提示
- grabOrderSuccess: '无法显示绑定后的字段',// 抢单成功返回字段
- isAddToList: false,// / 请求业主需求的时候是否添加到旧列表里
- isShowTopNav: false,// 是否显示返回顶部按钮
- loadMorePageIndex: 1
+ }
- }
- }
+ // 搜索业主需求函数
+ searchDemanding({
+ curr_page = 1,
+ page_count = 10,
+ sd_title = this.state.title,
+ state = this.state.demandingStateSelected.id,
+ update_dateL = this.state.startDateSel,
+ update_dateU = this.state.endDateSel,
+ class_id = this.state.industryTypeSelected.id
+ }) {
+ Taro.request({
+ url: URL.GetAllDemanding,
+ method: 'POST',
+ dataType: 'json',
+ data: {
+ param: JSON.stringify({
+ curr_page: curr_page,
+ page_count: page_count,
+ sd_title: sd_title,
+ state: state,
+ update_dateL: update_dateL,
+ update_dateU: update_dateU,
+ class_id: class_id
- // 搜索业主需求函数
- searchDemanding({
- curr_page = 1,
- page_count = 10,
- sd_title = this.state.title,
- state = this.state.demandingStateSelected.id,
- update_dateL = this.state.startDateSel,
- update_dateU = this.state.endDateSel,
- class_id = this.state.industryTypeSelected.id
- }) {
- Taro.request({
- url: URL.GetAllDemanding,
- method: 'POST',
- dataType: 'json',
- data: {
- param: JSON.stringify({
- curr_page: curr_page,
- page_count: page_count,
- sd_title: sd_title,
- state: state,
- update_dateL: update_dateL,
- update_dateU: update_dateU,
- class_id: class_id
-
- }),
- },
- header: {
- 'content-type': 'application/x-www-form-urlencoded',
- 'X-Requested-With': 'XMLHttpRequest',
- 'Cookie': 'PFWSSS=' + getGlobalStorage('session_id'),
+ }),
+ },
+ header: {
+ 'content-type': 'application/x-www-form-urlencoded',
+ 'X-Requested-With': 'XMLHttpRequest',
+ 'Cookie': 'PFWSSS=' + getGlobalStorage('session_id'),
+ }
+ })
+ .then(res => {
+ Taro.hideLoading()
+ if (res.data.err_code === 0) {
+ if (res.data.supplys) {
+ if (this.state.isAddToList) {
+ this.setState({ supplys: this.state.supplys.concat(res.data.supplys), isAddToList: false })
+ } else {
+ this.setState({ supplys: res.data.supplys })
}
- })
- .then(res => {
- Taro.hideLoading()
- if (res.data.err_code === 0) {
- if (res.data.supplys) {
- if (this.state.isAddToList) {
- this.setState({ supplys: this.state.supplys.concat(res.data.supplys), isAddToList: false })
- } else {
- this.setState({ supplys: res.data.supplys })
- }
- } else {
- if (this.state.isAddToList) {
- Taro.showToast({
- title: '没有更多了',
- icon: 'none'
- })
- } else {
- this.setState({ supplys: [] })
- }
-
- }
- } else if (res.data.err_code === 88888) {
- loginExpired(res)
- } else {
- Taro.showToast({
- title: res.data.err_msg,
- icon: 'none',
- duration: 1500
- })
- }
- this.setState({ isAddToList: false })
- })
- }
-
- // 改变需求选项
- changeDemandingState = e => {
- this.setState({
- demandingStateSelected: this.state.demandingState[e.detail.value]
- })
- }
- titleChange(event) {
- this.setState({ title: event })
- }
-
- //改变开始日期
- onStartDateChange = e => {
- this.setState({
- startDateSel: e.detail.value,
-
- })
- }
- // 改变结束日期
- onEndDateChange = e => {
- this.setState({
- endDateSel: e.detail.value
- })
- }
- // 抢单接口
- GrabDemand({ demandId = 218 }) {
- Taro.request({
- url: URL.GrabDemand,
- method: 'POST',
- dataType: 'json',
- data: {
- demandId: demandId
- },
- header: {
- 'content-type': 'application/x-www-form-urlencoded',
- 'Cookie': 'PFWSSS=' + getGlobalStorage('session_id'),
- 'X-Requested-With': 'XMLHttpRequest'
+ } else {
+ if (this.state.isAddToList) {
+ Taro.showToast({
+ title: '没有更多了',
+ icon: 'none'
+ })
+ } else {
+ this.setState({ supplys: [] })
}
- })
- .then(res => {
- if (res.data.err_code === 0) {
- Taro.showToast({
- title: res.data.err_msg === 'success' ? '抢单成功' : res.data.err_msg,
- icon: res.data.err_msg === 'success' ? 'success' : 'none'
- })
- this.searchDemanding({ curr_page: 1 })
- } else if (res.data.err_code === 88888) {
- loginExpired(res)
- }
- else {
- Taro.showToast({
- title: res.data.err_msg,
- icon: 'none'
- })
- }
-
- console.log('抢单请求:', res)
- })
-
- }
- grabOrder(e) {
- const id = onClickValueService(e)
- this.setState({ isOpenedGrabModal: true, grabOrderId: id })
- }
- handleGrabModalClose() {
- this.setState({ isOpenedGrabModal: false })
- }
- handleGrabModalCancel() {
- this.setState({ isOpenedGrabModal: false })
- }
- handleGrabConfirm() {
- this.setState({ isOpenedGrabModal: false })
- this.GrabDemand({ demandId: this.state.grabOrderId })
- }
- searchHanlder() {
- showLoading({ title: '加载中' })
- this.searchDemanding({})
- }
- //清空筛选项
- emptyFilter() {
- this.setState({
- title: '',
- endDateSel: '',
- startDateSel: '',
- demandingStateSelected: { name: '全部', id: '' },
- industryTypeSelected: { name: '全部', id: '' },
- })
- Taro.showToast({
- title: '已清空',
- icon: 'success',
- duration: 1000
- })
- }
-
- getDataFromChild(value) {
- console.log('从子组件传回来的值', value)
- this.setState({ industryTypeSelected: value })
- }
-
- goToGrabOrderPage(e) {
- const id = onClickValueService(e)
- let orderId=encodeURIComponent(id)
- Taro.navigateTo({
- url: '/pages/grabOrderPage/grabOrderPage?orderId=' + orderId
- })
- }
-
- componentWillReceiveProps(nextProps) {
- console.log(this.props, nextProps)
- }
- componentDidMount() {
- // 得到第一页需求数据
- showLoading({ title: '加载中' })
- this.searchDemanding({})
-
-
-
- }
-
- componentWillUnmount() { }
-
- componentDidShow() { }
-
- componentDidHide() { }
- // 页面位置
- onPageScroll(location) {
- if (location.scrollTop <= 300 && this.state.isShowTopNav) {
- this.setState({ isShowTopNav: false })
- } else if (location.scrollTop > 300 && !this.state.isShowTopNav) {
- this.setState({ isShowTopNav: true })
+ }
+ } else if (res.data.err_code === 88888) {
+ loginExpired(res)
+ } else {
+ Taro.showToast({
+ title: res.data.err_msg,
+ icon: 'none',
+ duration: 1500
+ })
}
+ this.setState({ isAddToList: false })
+ })
+ }
+
+ // 改变需求选项
+ changeDemandingState = e => {
+ this.setState({
+ demandingStateSelected: this.state.demandingState[e.detail.value]
+ })
+ }
+ titleChange(event) {
+ this.setState({ title: event })
+ }
+
+ //改变开始日期
+ onStartDateChange = e => {
+ this.setState({
+ startDateSel: e.detail.value,
+
+ })
+ }
+ // 改变结束日期
+ onEndDateChange = e => {
+ this.setState({
+ endDateSel: e.detail.value
+ })
+ }
+ // 抢单接口
+ GrabDemand({ demandId = 218 }) {
+ Taro.request({
+ url: URL.GrabDemand,
+ method: 'POST',
+ dataType: 'json',
+ data: {
+ demandId: demandId
+ },
+ header: {
+ 'content-type': 'application/x-www-form-urlencoded',
+ 'Cookie': 'PFWSSS=' + getGlobalStorage('session_id'),
+ 'X-Requested-With': 'XMLHttpRequest'
+ }
+ })
+ .then(res => {
+ if (res.data.err_code === 0) {
+ Taro.showToast({
+ title: res.data.err_msg === 'success' ? '抢单成功' : res.data.err_msg,
+ icon: res.data.err_msg === 'success' ? 'success' : 'none'
+ })
+ this.searchDemanding({ curr_page: 1 })
+ } else if (res.data.err_code === 88888) {
+ loginExpired(res)
+ }
+ else {
+
+ Taro.showToast({
+ title: res.data.err_msg,
+ icon: 'none'
+ })
+ }
+
+ console.log('抢单请求:', res)
+ })
+
+ }
+ grabOrder(e) {
+ const id = onClickValueService(e)
+ this.setState({ isOpenedGrabModal: true, grabOrderId: id })
+ }
+ handleGrabModalClose() {
+ this.setState({ isOpenedGrabModal: false })
+ }
+ handleGrabModalCancel() {
+ this.setState({ isOpenedGrabModal: false })
+ }
+ handleGrabConfirm() {
+ this.setState({ isOpenedGrabModal: false })
+ this.GrabDemand({ demandId: this.state.grabOrderId })
+ }
+ searchHanlder() {
+ showLoading({ title: '加载中' })
+ this.searchDemanding({})
+ }
+ //清空筛选项
+ emptyFilter() {
+ this.setState({
+ title: '',
+ endDateSel: '',
+ startDateSel: '',
+ demandingStateSelected: { name: '全部', id: '' },
+ industryTypeSelected: { name: '全部', id: '' },
+ })
+ Taro.showToast({
+ title: '已清空',
+ icon: 'success',
+ duration: 1000
+ })
+ }
+
+ getDataFromChild(value) {
+ console.log('从子组件传回来的值', value)
+ this.setState({ industryTypeSelected: value })
+ }
+
+ goToGrabOrderPage(e) {
+ const id = onClickValueService(e)
+ let orderId = encodeURIComponent(id)
+ Taro.navigateTo({
+ url: '/pages/grabOrderPage/grabOrderPage?orderId=' + orderId
+ })
+ }
+
+ componentWillReceiveProps(nextProps) {
+ console.log(this.props, nextProps)
+ }
+ componentDidMount() {
+ // 得到第一页需求数据
+ showLoading({ title: '加载中' })
+ this.searchDemanding({})
+
+
+
+ }
+
+ componentWillUnmount() { }
+
+ componentDidShow() { }
+
+ componentDidHide() { }
+ // 页面位置
+ onPageScroll(location) {
+ if (location.scrollTop <= 300 && this.state.isShowTopNav) {
+ this.setState({ isShowTopNav: false })
+ } else if (location.scrollTop > 300 && !this.state.isShowTopNav) {
+ this.setState({ isShowTopNav: true })
}
+ }
- // 底部加载
- onReachBottom() {
- showLoading({
- title: '加载中'
- })
+ // 底部加载
+ onReachBottom() {
+ showLoading({
+ title: '加载中'
+ })
- this.setState({ isAddToList: true, loadMorePageIndex: this.state.loadMorePageIndex + 1 }, () => {
- this.searchDemanding({ curr_page: this.state.loadMorePageIndex })
- })
+ this.setState({ isAddToList: true, loadMorePageIndex: this.state.loadMorePageIndex + 1 }, () => {
+ this.searchDemanding({ curr_page: this.state.loadMorePageIndex })
+ })
- }
+ }
- render() {
- // 提示模态弹窗element
+ render() {
+ // 提示模态弹窗element
- const modalMessageGrabElement =
- 提示
-
- 确认抢单?
+ const modalMessageGrabElement =
+ 提示
+
+ 确认抢单?
-
-
+
+
- const allDemandingElementArray = this.state.supplys.length ? this.state.supplys.map((item, index) => {
- return
-
-
- 业主:{item.user_name}
-
- {item.class_name + ' '}
- |
+ const allDemandingElementArray = this.state.supplys.length ? this.state.supplys.map((item, index) => {
+ return
+
+
+ 业主:{item.user_name}
+
+ {item.class_name + ' '}
+ |
- {item.browse_times}
-
-
-
-
-
-
-
- {item.sd_title}
- {item.sd_desc}
- {item.state === '1' ?
-
- : null || item.state === '2' ?
-
- : null || item.state === '3' ?
-
- : null}
-
-
-
- {item.user_address}
- 更新日期:{item.update_date}
+ {item.browse_times}
+
+
+
+
+
+
+
+ {item.sd_title}
+ {item.sd_desc}
+ {item.state === '1' ?
+
+ : null || item.state === '2' ?
+
+ : null || item.state === '3' ?
+
+ : null}
+
+
+
+ {item.user_address}
+ 更新日期:{item.update_date}
+
+
+
+ }) : 没有更多了
+ return (
+
+ {/* 模态框 */}
+ {modalMessageGrabElement}
+
+
+ {/* 供求状态选择 */}
+
+
+
+
+ 供求状态: {this.state.demandingStateSelected.name}
+
+
+
+
+
+
+
+
+
+ {/* 开始和结束日期选择 */}
+
+
+
+
+
+
+ 开始日期: {this.state.startDateSel}
+
+
+
- }) : 没有更多了
- return (
-
- {/* 模态框 */}
- {modalMessageGrabElement}
-
- {/* 供求状态选择 */}
-
-
-
-
- 供求状态: {this.state.demandingStateSelected.name}
-
-
-
-
-
+
+
+
+
+ 结束日期: {this.state.endDateSel}
+
-
-
-
-
-
- {/* 开始和结束日期选择 */}
-
-
-
-
-
-
- 开始日期: {this.state.startDateSel}
-
-
-
-
-
-
-
-
-
- 结束日期: {this.state.endDateSel}
-
-
-
-
-
-
-
- {/* 行业分类选择 */}
-
-
-
-
-
-
-
-
-
-
-
-
- {/* 供求页面的数据加载 */}
-
- {allDemandingElementArray}
-
- {this.state.isShowTopNav ? : null}
-
+
- )
- }
+
+
+
+ {/* 行业分类选择 */}
+ {platformChecker() ?
+ :
+
+ }
+
+
+
+
+
+
+
+
+
+
+
+
+ {/* 供求页面的数据加载 */}
+
+ {allDemandingElementArray}
+
+ {this.state.isShowTopNav ? : null}
+
+
+ )
+ }
}
export default AllDemanding
diff --git a/src/pages/allDemanding/allDemanding.scss b/src/pages/allDemanding/allDemanding.scss
index 0538ca9..33d0b09 100644
--- a/src/pages/allDemanding/allDemanding.scss
+++ b/src/pages/allDemanding/allDemanding.scss
@@ -16,32 +16,35 @@ $themeColor: #FF7142;
}
.page-section{
border-bottom: 1Px solid #d6e4ef;
-
- .picker{
- // padding: 24rpx 0;
- .selected{
- display: inline-block;
- margin-left: 20%;
- font-size: 32rpx
- }
- .date{
- display: inline-block;
-
- font-size: 32rpx
- }
- .title-box{
- .title{
- //color: #333;
- margin-right:16rpx;
- width:172rpx;
- font-size:32rpx;
- line-height:100px;
- // vertical-align:middle;
- text-align:left;
- font-weight: bold;
- }
+
+
}
- }
+.page-section-picker{
+ .picker{
+ // padding: 24rpx 0;
+ .selected{
+ display: inline-block;
+ margin-left: 20%;
+ font-size: 32rpx
+ }
+ .date{
+ display: inline-block;
+
+ font-size: 32rpx
+ }
+ .title-box{
+.title{
+ //color: #333;
+ margin-right:16rpx;
+ width:172rpx;
+ font-size:32rpx;
+ line-height:100px;
+ // vertical-align:middle;
+ text-align:left;
+ font-weight: bold;
+}
+}
+ }
}
.input-box{
display: flex;
@@ -63,11 +66,11 @@ $themeColor: #FF7142;
flex-direction: row;
margin: 40px 0 0;
padding: 0 120px;
-
+
.button{
flex:1;
text-align: center;
-
+
// .button-s{
// // color:white;
@@ -78,7 +81,7 @@ $themeColor: #FF7142;
// // background-color:$themeColor;
// // border:1PX solid $themeColor;
// }
-
+
// .button-b{
// width: 150px;
// background-color:#d9534f;
@@ -150,8 +153,8 @@ $themeColor: #FF7142;
right:20px;
}
}
-
-
+
+
}
.footer{
display: flex;
@@ -160,7 +163,7 @@ $themeColor: #FF7142;
font-size: 25rpx;
.location{
flex:1
- }
+ }
.time{
flex:1
}
@@ -168,7 +171,7 @@ $themeColor: #FF7142;
}
}
-
+
}
.button{
.at-button--primary{
diff --git a/src/pages/goodsPublish/goodsPublish.js b/src/pages/goodsPublish/goodsPublish.js
index ecc755d..5640858 100644
--- a/src/pages/goodsPublish/goodsPublish.js
+++ b/src/pages/goodsPublish/goodsPublish.js
@@ -28,7 +28,6 @@ class GoodsPublish extends Component {
constructor() {
super(...arguments)
this.state = {
-
shopTypeSelected: { name: '选择店铺类型', id: '' },//已选的店铺分类
goodsTypeSelected: { name: '选择商品分类', id: '' },// 已选的商品分类
productName: '',
diff --git a/src/pages/home/home.js b/src/pages/home/home.js
index 9955b35..c8fe017 100644
--- a/src/pages/home/home.js
+++ b/src/pages/home/home.js
@@ -92,7 +92,7 @@ class Home extends Component {
}
})
}
- // api 得到推荐商店的信息
+ // api 得到推荐商店的信息
getShops({ parent_supply_class = this.state.parentClass, supply_class = this.state.childClass, supply_level = this.state.supplyLevel, curr_page = 1,
page_count = 5, action = "2" }) {
Taro.request({
@@ -114,7 +114,7 @@ class Home extends Component {
header: {
'content-type': 'application/x-www-form-urlencoded',
'Cookie': 'PFWSSS=' + Taro.getStorageSync('session_id'),
-
+
}
})
.then(res => {
@@ -147,13 +147,11 @@ class Home extends Component {
)
}
getUserLocation() {
-
if (process.env.TARO_ENV === 'alipay') {
return new Promise((resolve, reject) => {
my.getLocation({
success(res) {
my.hideLoading();
-
resolve(res)
},
fail(res) {
@@ -164,9 +162,6 @@ class Home extends Component {
})
})
-
-
-
} else if (process.env.TARO_ENV === 'weapp') {
return new Promise((resolve, reject) => {
Taro.getLocation({
@@ -182,12 +177,8 @@ class Home extends Component {
reject(res)
}
})
-
})
-
}
-
-
}
@@ -312,25 +303,24 @@ class Home extends Component {
componentDidMount() {
- // // 页面加载后 得到首页的基本信息和推荐店铺的信息
- // showLoading({ title: '加载中' })
- // // promise 返回经纬度给state 然后调用函数
- // this.getUserLocation().then(res => {
- // this.setState({
- // latitude: res.latitude,
- // longitude: res.longitude
- // }, () => {
- // this.getShops({})
- // this.getHomeCategoriesInfo()
- // })
- // }).catch(err => {
- // this.getShops({})
- // this.getHomeCategoriesInfo()
- // })
+ // 页面加载后 得到首页的基本信息和推荐店铺的信息
+ showLoading({ title: '加载中' })
+ // promise 返回经纬度给state 然后调用函数
this.getShops({})
this.getHomeCategoriesInfo()
- // 本地缓存没有userid时 从新登入
Taro.getStorageSync('userInfo').user_id ? true : weChatLogin()
+
+ this.getUserLocation().then(res => {
+ this.setState({
+ latitude: res.latitude,
+ longitude: res.longitude
+ })
+ }).catch(err => {
+ Taro.showToast({
+ title: '定位获取失败',
+ icon: 'none'
+ })
+ })
}
componentWillMount() {
diff --git a/src/pages/login/login.js b/src/pages/login/login.js
index 37e7d26..f788420 100644
--- a/src/pages/login/login.js
+++ b/src/pages/login/login.js
@@ -32,9 +32,11 @@ class Login extends Component {
loginHandler() {
if (this.state.username && this.state.password) {
standardLogin(this.state.username, this.state.password).then(res => {
- Taro.reLaunch({
- url: '/pages/home/home'
- })
+ setTimeout(() => {
+ Taro.reLaunch({
+ url: '/pages/home/home'
+ })
+ }, 1000);
}).catch(res => {
Taro.showToast({
title: res.data.msg,
@@ -65,7 +67,7 @@ class Login extends Component {
}
componentWillReceiveProps(nextProps) {
- console.log(this.props, nextProps)
+ // console.log(this.props, nextProps)
}
componentWillUnmount() { }
diff --git a/src/pages/myGoodList/myGoodList.js b/src/pages/myGoodList/myGoodList.js
index 5c4edbf..3aebdd9 100644
--- a/src/pages/myGoodList/myGoodList.js
+++ b/src/pages/myGoodList/myGoodList.js
@@ -38,7 +38,7 @@ class MyGoodList extends Component {
}, // 正反排序
selectedFilterValue: 0, //
myGoodList: [],// 保存后台返回的商品列表
- myGoodListTotal: '0',// 后台的商品总数
+ myGoodListTotal: '0',// 后台的商品总数
goodsStateParam: 1,//商品状态参数
pageCountParam: 20,// 商品数量参数
currPageParam: 1,// 当前页面 参数
@@ -147,11 +147,11 @@ class MyGoodList extends Component {
Taro.hideLoading()
console.log('res',res)
const data = platformChecker()? JSON.parse(res.data):res.data
-
+
if (data.err_code === 88888) {
loginExpired(data)
} else if (data.err_code != 10) {
-
+
if (data.goodsCount != '0' && data.goods.length) {
data.goods.forEach(item => {
item.checked = false
@@ -247,7 +247,7 @@ class MyGoodList extends Component {
// }
- // 商品列表下架API
+ // 商品列表下架API
changeGoodState({ goodsState = 0, goodsID = this.state.goodsIdList }) {
Taro.request({
url: URL.ChangeGoodState,
@@ -311,7 +311,8 @@ class MyGoodList extends Component {
'X-Requested-With': 'XMLHttpRequest'
}
}).then(res => {
- let responseData = JSON.parse(res.data)
+ console.log('res',res)
+ let responseData = platformChecker()? JSON.parse(res.data):res.data
Taro.hideLoading()
if (responseData.err_code === 0) {
Taro.showToast({
@@ -537,7 +538,7 @@ class MyGoodList extends Component {
}
// 导航到商品编辑页面myGoodsEdit
goToGoodEditPage(e) {
-
+
const goodId = onClickValueService(e)
const id=encodeURIComponent(goodId)
Taro.navigateTo({
@@ -657,7 +658,7 @@ class MyGoodList extends Component {
}
render() {
- //等待接口数据
+ //等待接口数据
const goodListElementArray = this.state.myGoodList.map((item, index) => {
return
diff --git a/src/pages/mySupplyDemand/mySupplyDemand.js b/src/pages/mySupplyDemand/mySupplyDemand.js
index 7963f71..96553a8 100644
--- a/src/pages/mySupplyDemand/mySupplyDemand.js
+++ b/src/pages/mySupplyDemand/mySupplyDemand.js
@@ -479,8 +479,6 @@ class MySupplyDemand extends Component {
-
-
个人中心
diff --git a/src/pages/shop/shop.js b/src/pages/shop/shop.js
index 3f56760..3c110c0 100644
--- a/src/pages/shop/shop.js
+++ b/src/pages/shop/shop.js
@@ -3,7 +3,7 @@ import { View, Button, Text, Image, Map } from '@tarojs/components'
import { AtTag, AtIcon, } from 'taro-ui'
import URL from '../../serviceAPI.config'
-
+import AliShopTypeInteraction from '../../component/AliShopTypeInteraction/AliShopTypeInteraction'
import ShopTypeInteractionComp from '../../component/shopTypeInteractionComp/shopTypeInteractionComp'
import ScrollToTopComponent from '../../component/scrollToTopComponent/scrollToTopComponent'
@@ -14,774 +14,774 @@ import CopyrightComponent from '../../component/copyrightComponent/copyrightComp
import onClickValueService from '../../util/onClickValueService';
import { getGlobalStorage } from '../../util/getSetStoage';
import { showLoading } from '../../util/hideShowLoading';
-
+import platformChecker from '../../util/plaformChecker';
const locationIcon = require('../../assets/img/location.png')
class Shop extends Component {
- // 项目配置
- config = {
- navigationBarTitleText: '店铺'
+ // 项目配置
+ config = {
+ navigationBarTitleText: '店铺'
+ }
+ constructor() {
+ super(...arguments)
+ this.state = {
+ isShopDetailsOn: false, // 是否显示店铺说明页面
+ shopItem: [], // 所有商品
+ value: '', // 搜索框的值
+ shopId: '', // 店铺的id
+ shopName: '', // 店铺名
+ FilterText: '', // 筛选的可选项
+ filterBar: ['all', 'amount', 'newProduct', 'price', 'popularity'], //筛选选项
+ filterBarKeys: { all: '综合排序', amount: '销量', newProduct: '新品', price: '价格', popularity: '人气' }, // 筛选选项对应值
+ selectedFilterValue: 0, //筛选项
+ isShowFilter: false, //是否显示侧边筛选
+ showShopHomePage: true,// 是否显示首页页面
+ shopDescriptionData: '',// 店铺详情信息
+ shopName: '',//店铺名称
+ shopAddress: '',//店铺地址
+ contactName: '',//联系人
+ contactNumber: '',//联系电话
+ shopDescription: '',//店铺简介
+ filterOptions: {
+ all: true,
+ amount: false,
+ newProduct: false,
+ price: false,
+ popularity: false,
+ },
+ filterCondition: '',// 筛选条件
+ mainType: [],// 侧边筛选分类
+ goodType: [],//侧边商品类型
+ otherType: [],//侧边其他类型
+ widthType: [],// 侧边宽度类型
+ checkedFilterIdList: [],//已选的筛选id
+ isAddToList: false,// 请求店铺商品的时候是否添加到旧列表里
+ loadMorePageIndex: 1,//上拉加载页面数
+ isShowTopNav: false,// 是否显示返回顶部按钮
+
+ // 下面是函数的默认参数
+ curr_page: 1,
+ page_count: 10,
+ shop_name: false,
+ shop_id: decodeURIComponent(this.$router.params.id),
+ config_id: 4,
+ shop_class_id: '',
+ order: '',
+ goods_class_id: '',
+ class_filter: '',
+ goods_type: '',
+ goodsSpec: [],
+ goodsParam: [],
+ goodsParamExt: [],
+ // 地图的经度和维度
+ longitude: '',
+ latitude: '',
+
+
}
- constructor() {
- super(...arguments)
- this.state = {
- isShopDetailsOn: false, // 是否显示店铺说明页面
- shopItem: [], // 所有商品
- value: '', // 搜索框的值
- shopId: '', // 店铺的id
- shopName: '', // 店铺名
- FilterText: '', // 筛选的可选项
- filterBar: ['all', 'amount', 'newProduct', 'price', 'popularity'], //筛选选项
- filterBarKeys: { all: '综合排序', amount: '销量', newProduct: '新品', price: '价格', popularity: '人气' }, // 筛选选项对应值
- selectedFilterValue: 0, //筛选项
- isShowFilter: false, //是否显示侧边筛选
- showShopHomePage: true,// 是否显示首页页面
- shopDescriptionData: '',// 店铺详情信息
- shopName: '',//店铺名称
- shopAddress: '',//店铺地址
- contactName: '',//联系人
- contactNumber: '',//联系电话
- shopDescription: '',//店铺简介
- filterOptions: {
- all: true,
- amount: false,
- newProduct: false,
- price: false,
- popularity: false,
- },
- filterCondition: '',// 筛选条件
- mainType: [],// 侧边筛选分类
- goodType: [],//侧边商品类型
- otherType: [],//侧边其他类型
- widthType: [],// 侧边宽度类型
- checkedFilterIdList: [],//已选的筛选id
- isAddToList: false,// 请求店铺商品的时候是否添加到旧列表里
- loadMorePageIndex: 1,//上拉加载页面数
- isShowTopNav: false,// 是否显示返回顶部按钮
-
- // 下面是函数的默认参数
- curr_page: 1,
- page_count: 10,
- shop_name: false,
- shop_id: decodeURIComponent(this.$router.params.id),
- config_id: 4,
- shop_class_id: '',
- order: '',
- goods_class_id: '',
- class_filter: '',
- goods_type: '',
- goodsSpec: [],
- goodsParam: [],
- goodsParamExt: [],
- // 地图的经度和维度
- longitude: '',
- latitude: '',
-
-
- }
- }
-
- // api 得到筛选的标签请求
- getSearchParams({
- shop_name = this.state.shop_name,
- shop_id = this.state.shop_id,
- shop_class_id = this.state.shop_class_id,
- goods_class_id = this.state.goods_class_id,
- class_filter = this.state.class_filter,
- goods_type = this.state.goods_type,
- goodsSpec = this.state.goodsSpec,
- goodsParam = this.state.goodsParam,
- goodsParamExt = this.state.goodsParamExt }) {
- Taro.request({
- url: URL.GetSearchParam,
- method: 'POST',
- dataType: 'json',
- data: {
- goods: JSON.stringify({
- shop_name: shop_name,
- shop_id: shop_id,
- shop_class_id: shop_class_id,
- goods_class_id: goods_class_id,
- class_filter: class_filter,
- goods_type: goods_type,
-
- }),
- goodsSpec: JSON.stringify(goodsSpec),
- goodsParam: JSON.stringify(goodsParam),
- goodsParamExt: JSON.stringify(goodsParamExt),
-
- },
- header: {
- 'content-type': 'application/x-www-form-urlencoded',
- 'X-Requested-With': 'XMLHttpRequest',
- 'Cookie': 'PFWSSS=' + getGlobalStorage('session_id'),
- }
- })
- .then(res => {
- if (res.statusCode === 200) {
- console.log('筛选项目成功', res)
- Taro.hideLoading()
- this.formatFilterData(res.data).then(data => {
- this.setState({
- sideFilterdata: data,
- mainType: data.mainType,
- goodType: data.goodType,
- otherType: data.otherType,
- widthType: data.widthType,
- })
-
-
-
- console.log('formated data', data)
- })
- } else {
- console.log('筛选项目获取失败')
- }
+ }
+ // api 得到筛选的标签请求
+ getSearchParams({
+ shop_name = this.state.shop_name,
+ shop_id = this.state.shop_id,
+ shop_class_id = this.state.shop_class_id,
+ goods_class_id = this.state.goods_class_id,
+ class_filter = this.state.class_filter,
+ goods_type = this.state.goods_type,
+ goodsSpec = this.state.goodsSpec,
+ goodsParam = this.state.goodsParam,
+ goodsParamExt = this.state.goodsParamExt }) {
+ Taro.request({
+ url: URL.GetSearchParam,
+ method: 'POST',
+ dataType: 'json',
+ data: {
+ goods: JSON.stringify({
+ shop_name: shop_name,
+ shop_id: shop_id,
+ shop_class_id: shop_class_id,
+ goods_class_id: goods_class_id,
+ class_filter: class_filter,
+ goods_type: goods_type,
+ }),
+ goodsSpec: JSON.stringify(goodsSpec),
+ goodsParam: JSON.stringify(goodsParam),
+ goodsParamExt: JSON.stringify(goodsParamExt),
+ },
+ header: {
+ 'content-type': 'application/x-www-form-urlencoded',
+ 'X-Requested-With': 'XMLHttpRequest',
+ 'Cookie': 'PFWSSS=' + getGlobalStorage('session_id'),
+ }
+ })
+ .then(res => {
+ if (res.statusCode === 200) {
+ console.log('筛选项目成功', res)
+ Taro.hideLoading()
+ this.formatFilterData(res.data).then(data => {
+ this.setState({
+ sideFilterdata: data,
+ mainType: data.mainType,
+ goodType: data.goodType,
+ otherType: data.otherType,
+ widthType: data.widthType,
})
+
+
+
+ console.log('formated data', data)
+ })
+ } else {
+ console.log('筛选项目获取失败')
+ }
+
+
+
+ })
+ }
+
+ async formatFilterData(data) {
+ const formatedFilterOptions = {}
+ //侧边筛选分类
+ if (data.goods_class) {
+ let typeArray = []
+ // 如果后台返回的筛选项有和checkedFilterIdList重叠的 就不显示.
+ if (this.state.checkedFilterIdList.length) {
+ data.goods_class.forEach(item => {
+ this.state.checkedFilterIdList.forEach((checkedItem) => {
+ if (checkedItem.id !== item.class_id) {
+ typeArray.push({ id: item.class_id, name: item.class_name, checked: false })
+ }
+ })
+ });
+ } else {
+ data.goods_class.forEach(item => {
+ typeArray.push({ id: item.class_id, name: item.class_name, checked: false })
+ }
+ )
+ }
+
+
+ formatedFilterOptions.mainType = typeArray
+ } else {
+ formatedFilterOptions.mainType = []
+ }
+ //侧边筛选商品类型
+ if (data.goods_type) {
+ // console.log('数据',data.goods_type)
+ let goodTypeArray = []
+ Object.keys(data.goods_type).forEach(key => {
+ if (data.goods_type[key]) {
+ goodTypeArray.push({
+ id: data.goods_type[key].goods_type_id,
+ name: data.goods_type[key].goods_type_ch_name,
+ checked: false
+ })
+ }
+ });
+ formatedFilterOptions.goodType = goodTypeArray
+ } else {
+ formatedFilterOptions.goodType = []
+
+ }
+ //侧边筛选其他类型
+ if (data.goodsParam) {
+ let goodsParamArray = []
+
+ Object.keys(data.goodsParam).forEach(key => {
+ if (data.goodsParam[key]) {
+ const value = data.goodsParam[key]
+ const subArray = value.param_value.map(item => {
+ return { id: value.param_id, name: item, checked: false }
+ })
+ goodsParamArray.push({ [value.param_name]: subArray })
+
+ }
+
+ });
+ formatedFilterOptions.otherType = goodsParamArray
+ }
+ else {
+ formatedFilterOptions.otherType = []
+
+ }
+ //侧边筛选宽度类型
+ if (data.goodsParamExt) {
+ let goodsParamExtArray = []
+ Object.keys(data.goodsParamExt).forEach(key => {
+ const value = data.goodsParamExt[key]
+ const keyId = value.param_id
+ Object.keys(value.param_value).forEach(item => {
+ const name = value.param_value[item].value_desc
+ const value1 = value.param_value[item]
+
+ goodsParamExtArray.push({ name: name, value: value1, checked: false, id: keyId })
+ });
+ });
+ formatedFilterOptions.widthType = goodsParamExtArray
+
+ } else {
+ formatedFilterOptions.widthType = []
}
- async formatFilterData(data) {
- const formatedFilterOptions = {}
- //侧边筛选分类
- if (data.goods_class) {
- let typeArray = []
- // 如果后台返回的筛选项有和checkedFilterIdList重叠的 就不显示.
- if (this.state.checkedFilterIdList.length) {
- data.goods_class.forEach(item => {
- this.state.checkedFilterIdList.forEach((checkedItem) => {
- if (checkedItem.id !== item.class_id) {
- typeArray.push({ id: item.class_id, name: item.class_name, checked: false })
- }
- })
- });
- } else {
- data.goods_class.forEach(item => {
- typeArray.push({ id: item.class_id, name: item.class_name, checked: false })
- }
- )
- }
+ return formatedFilterOptions
+ }
- formatedFilterOptions.mainType = typeArray
- } else {
- formatedFilterOptions.mainType = []
- }
- //侧边筛选商品类型
- if (data.goods_type) {
- // console.log('数据',data.goods_type)
- let goodTypeArray = []
- Object.keys(data.goods_type).forEach(key => {
- if (data.goods_type[key]) {
- goodTypeArray.push({
- id: data.goods_type[key].goods_type_id,
- name: data.goods_type[key].goods_type_ch_name,
- checked: false
- })
- }
- });
- formatedFilterOptions.goodType = goodTypeArray
- } else {
- formatedFilterOptions.goodType = []
-
- }
- //侧边筛选其他类型
- if (data.goodsParam) {
- let goodsParamArray = []
-
- Object.keys(data.goodsParam).forEach(key => {
- if (data.goodsParam[key]) {
- const value = data.goodsParam[key]
- const subArray = value.param_value.map(item => {
- return { id: value.param_id, name: item, checked: false }
- })
- goodsParamArray.push({ [value.param_name]: subArray })
-
- }
-
- });
- formatedFilterOptions.otherType = goodsParamArray
- }
- else {
- formatedFilterOptions.otherType = []
-
- }
- //侧边筛选宽度类型
- if (data.goodsParamExt) {
- let goodsParamExtArray = []
- Object.keys(data.goodsParamExt).forEach(key => {
- const value = data.goodsParamExt[key]
- const keyId = value.param_id
- Object.keys(value.param_value).forEach(item => {
- const name = value.param_value[item].value_desc
- const value1 = value.param_value[item]
-
- goodsParamExtArray.push({ name: name, value: value1, checked: false, id: keyId })
- });
- });
- formatedFilterOptions.widthType = goodsParamExtArray
-
- } else {
- formatedFilterOptions.widthType = []
- }
-
- return formatedFilterOptions
- }
-
-
- // api 得到所有的产品请求
- goodsSearch({
- curr_page = this.state.curr_page,
- page_count = this.state.page_count,
- shop_name = this.state.shop_name,
- shop_id = this.state.shop_id,
- config_id = this.state.config_id,
- shop_class_id = this.state.shop_class_id,
- order = this.state.order,
- goods_class_id = this.state.goods_class_id,
- currPage = '', // 不知道为什么筛选的时候要加 加这个参数为1
- goodsSpec = this.state.goodsSpec,
- goodsParam = this.state.goodsParam,
- goodsParamExt = this.state.goodsParamExt }) {
- Taro.request({
- url: URL.GoodsSearch,
- method: 'POST',
- dataType: 'json',
- data: {
- goods: JSON.stringify({
- curr_page: curr_page,
- page_count: page_count,
- shop_name: shop_name,
- shop_id: shop_id,
- config_id: config_id,
- shop_class_id: shop_class_id,
- order: order,
- goods_class_id: goods_class_id,
- currPage: currPage
- }),
- goodsRegion: JSON.stringify({}),
- goodsSpec: JSON.stringify(goodsSpec),
- goodsParam: JSON.stringify(goodsParam),
- goodsParamExt: JSON.stringify(goodsParamExt),
- },
- header: {
- // 'content-type': 'application/x-www-form-urlencoded',
- // 'X-Requested-With': 'XMLHttpRequest'
- 'content-type': 'application/x-www-form-urlencoded',
- 'Cookie': 'PFWSSS=' + getGlobalStorage('session_id'),
- 'X-Requested-With': 'XMLHttpRequest'
- }
- })
- .then(res => {
- console.log('searchGood', res)
-
- Taro.hideLoading()
- if (res.data.goods && res.data.goods.length) {
- if (this.state.isAddToList) {
- this.setState({
- shopItem: this.state.shopItem.concat(res.data.goods)
- }, () => {
- this.setState({ isAddToList: false })
- })
- } else {
- this.setState({ shopItem: res.data.goods, filterCondition: order })
- }
- } else {
- if (this.state.isAddToList) {
- Taro.showToast({
- title: '没有更多了',
- icon: 'none'
- })
- } else {
- this.setState({ shopItem: res.data.goods })
- }
-
-
- }
- this.setState({ isAddToList: false })
+ // api 得到所有的产品请求
+ goodsSearch({
+ curr_page = this.state.curr_page,
+ page_count = this.state.page_count,
+ shop_name = this.state.shop_name,
+ shop_id = this.state.shop_id,
+ config_id = this.state.config_id,
+ shop_class_id = this.state.shop_class_id,
+ order = this.state.order,
+ goods_class_id = this.state.goods_class_id,
+ currPage = '', // 不知道为什么筛选的时候要加 加这个参数为1
+ goodsSpec = this.state.goodsSpec,
+ goodsParam = this.state.goodsParam,
+ goodsParamExt = this.state.goodsParamExt }) {
+ Taro.request({
+ url: URL.GoodsSearch,
+ method: 'POST',
+ dataType: 'json',
+ data: {
+ goods: JSON.stringify({
+ curr_page: curr_page,
+ page_count: page_count,
+ shop_name: shop_name,
+ shop_id: shop_id,
+ config_id: config_id,
+ shop_class_id: shop_class_id,
+ order: order,
+ goods_class_id: goods_class_id,
+ currPage: currPage
+ }),
+ goodsRegion: JSON.stringify({}),
+ goodsSpec: JSON.stringify(goodsSpec),
+ goodsParam: JSON.stringify(goodsParam),
+ goodsParamExt: JSON.stringify(goodsParamExt),
+ },
+ header: {
+ // 'content-type': 'application/x-www-form-urlencoded',
+ // 'X-Requested-With': 'XMLHttpRequest'
+ 'content-type': 'application/x-www-form-urlencoded',
+ 'Cookie': 'PFWSSS=' + getGlobalStorage('session_id'),
+ 'X-Requested-With': 'XMLHttpRequest'
+ }
+ })
+ .then(res => {
+ console.log('searchGood', res)
+ Taro.hideLoading()
+ if (res.data.goods && res.data.goods.length) {
+ if (this.state.isAddToList) {
+ this.setState({
+ shopItem: this.state.shopItem.concat(res.data.goods)
+ }, () => {
+ this.setState({ isAddToList: false })
})
- }
+ } else {
+ this.setState({ shopItem: res.data.goods, filterCondition: order })
+ }
+ } else {
+ if (this.state.isAddToList) {
+ Taro.showToast({
+ title: '没有更多了',
+ icon: 'none'
+ })
+ } else {
+ this.setState({ shopItem: res.data.goods })
+ }
- // api 得到店铺详情请求
- getShopDescription({ shopID = this.state.shop_id }) {
- Taro.request({
- url: URL.ShopDescription,
- method: 'POST',
- dataType: 'json',
- data: {
- shopID: shopID,
- },
- header: {
- 'content-type': 'application/x-www-form-urlencoded',
- 'Cookie': 'PFWSSS=' + getGlobalStorage('session_id'),
- }
- })
- .then(res => {
- Taro.hideLoading()
- if (res.data.err_code === 0) {
- this.setState({
- shopDescriptionData: res.data,
- shopName: res.data.data.shop_name,
- shopAddress: res.data.data.shop_address,
- contactName: res.data.userRes.name,
- contactNumber: res.data.userRes.phone,
- shopDescription: res.data.data.shop_desc,
- latitude: res.data.data.shop_map.split(',')[1],
- longitude: res.data.data.shop_map.split(',')[0],
- })
- } else {
- Taro.showToast({
- title: res.data.err_msg,
- icon: 'none'
- })
-
- }
- }
- )
- }
-
- getDataFromShopChild(value) {
- console.log('从子组件店铺分类传回来的值', value)
- this.setState({ shop_class_id: value.id }, () => {
- this.goodsSearch({})
- })
-
- }
-
-
-
- // 产品排序
- accendingDescending(e) {
- const value = onClickValueService(e)
- showLoading({ title: '加载中' })
- this.setState({ selectedFilterValue: value })
- if (value == 0) {
- this.setState({
- filterOptions: {
- all: true,
- amount: false,
- newProduct: false,
- price: false,
- popularity: false
- },
- curr_page: 1,
- page_count: 10,
- shop_name: false,
- config_id: 4,
- shop_class_id: '',
- order: '',
- goods_class_id: '',
- goodsSpec: [],
- goodsParam: [],
- goodsParamExt: [],
- }, () => {
- this.goodsSearch({})
- }
- )
}
- if (value == 1) {
- this.setState({
+ this.setState({ isAddToList: false })
- filterOptions: {
- all: false,
- amount: !this.state.filterOptions.amount,
- newProduct: false,
- price: false,
- popularity: false
- }
- }, () => {
- this.state.filterOptions.amount ? this.goodsSearch({ currPage: 1, order: "g.sales_volume desc" }) : this.goodsSearch({ currPage: 1, order: "g.sales_volume" })
- }
- )
- }
- if (value == 2) {
- this.setState({
+ })
+ }
- filterOptions: {
- all: false,
- amount: false,
- newProduct: !this.state.filterOptions.newProduct,
- price: false,
- popularity: false
- }
- }, () => {
- this.state.filterOptions.newProduct ? this.goodsSearch({ currPage: 1, order: "g.create_date desc" }) : this.goodsSearch({ currPage: 1, order: "g.create_date" })
- }
- )
+ // api 得到店铺详情请求
+ getShopDescription({ shopID = this.state.shop_id }) {
+ Taro.request({
+ url: URL.ShopDescription,
+ method: 'POST',
+ dataType: 'json',
+ data: {
+ shopID: shopID,
+ },
+ header: {
+ 'content-type': 'application/x-www-form-urlencoded',
+ 'Cookie': 'PFWSSS=' + getGlobalStorage('session_id'),
+ }
+ })
+ .then(res => {
+ Taro.hideLoading()
+ if (res.data.err_code === 0) {
+ this.setState({
+ shopDescriptionData: res.data,
+ shopName: res.data.data.shop_name,
+ shopAddress: res.data.data.shop_address,
+ contactName: res.data.userRes.name,
+ contactNumber: res.data.userRes.phone,
+ shopDescription: res.data.data.shop_desc,
+ latitude: res.data.data.shop_map.split(',')[1],
+ longitude: res.data.data.shop_map.split(',')[0],
+ })
+ } else {
+ Taro.showToast({
+ title: res.data.err_msg,
+ icon: 'none'
+ })
}
- if (value == 3) {
+ }
+ )
+ }
- this.setState({
+ getDataFromShopChild(value) {
+ console.log('从子组件店铺分类传回来的值', value)
+ this.setState({ shop_class_id: value.id }, () => {
+ this.goodsSearch({})
+ })
- filterOptions: {
- all: false,
- amount: false,
- newProduct: false,
- price: !this.state.filterOptions.price,
- popularity: false
- }
- }, () => {
- this.state.filterOptions.price ? this.goodsSearch({ currPage: 1, order: "g.goods_price desc" }) : this.goodsSearch({ currPage: 1, order: "g.goods_price" })
- }
- )
+ }
+
+
+ // 产品排序
+ accendingDescending(e) {
+ const value = onClickValueService(e)
+ showLoading({ title: '加载中' })
+ this.setState({ selectedFilterValue: value })
+ if (value == 0) {
+ this.setState({
+ filterOptions: {
+ all: true,
+ amount: false,
+ newProduct: false,
+ price: false,
+ popularity: false
+ },
+ curr_page: 1,
+ page_count: 10,
+ shop_name: false,
+ config_id: 4,
+ shop_class_id: '',
+ order: '',
+ goods_class_id: '',
+ goodsSpec: [],
+ goodsParam: [],
+ goodsParamExt: [],
+ }, () => {
+ this.goodsSearch({})
+ }
+ )
+
+ }
+ if (value == 1) {
+ this.setState({
+
+ filterOptions: {
+ all: false,
+ amount: !this.state.filterOptions.amount,
+ newProduct: false,
+ price: false,
+ popularity: false
}
- if (value == 4) {
-
- this.setState({
-
- filterOptions: {
- all: false,
- amount: false,
- newProduct: false,
- price: false,
- popularity: !this.state.filterOptions.popularity
- }
- }, () => {
- this.state.filterOptions.popularity ? this.goodsSearch({ currPage: 1, order: "g.browse_times desc", }) : this.goodsSearch({ currPage: 1, order: "g.browse_times" })
-
- }
- )
+ }, () => {
+ this.state.filterOptions.amount ? this.goodsSearch({ currPage: 1, order: "g.sales_volume desc" }) : this.goodsSearch({ currPage: 1, order: "g.sales_volume" })
+ }
+ )
+ }
+ if (value == 2) {
+ this.setState({
+ filterOptions: {
+ all: false,
+ amount: false,
+ newProduct: !this.state.filterOptions.newProduct,
+ price: false,
+ popularity: false
}
- }
- // 是否显示侧边筛选
- showAndHideFilter() {
- this.setState({ isShowFilter: !this.state.isShowFilter })
- }
- // 选择侧边筛选的标签
- selectTag(name) {
- const id = name.name
- showLoading({ title: '加载中' })
- // 处理分类筛选项
- const newMainType = this.state.mainType.map((item) => {
- if (item.id === id) {
- item.checked = !item.checked
- setTimeout(() => {
- this.setState({ goods_class_id: id, checkedFilterIdList: this.state.checkedFilterIdList.concat([item]) }, () => {
- this.getSearchParams({ goods_class_id: this.state.goods_class_id })
- this.goodsSearch({ goods_class_id: this.state.goods_class_id })
- })
- }, 1000);
- }
- return item
- })
- // 处理商品类型筛选项
- const newGoodType = this.state.goodType.map((item) => {
- if (item.id === id) {
- item.checked = !item.checked
-
- setTimeout(() => {
- this.setState({ goods_type: id, checkedFilterIdList: this.state.checkedFilterIdList.concat([item]) }, () => {
- this.getSearchParams({ goods_type: this.state.goods_type })
- this.goodsSearch({ goods_type: this.state.goods_type })
- })
-
- }, 1000);
- }
- return item
- })
- // 处理其他筛选项
- const newOtherType = this.state.otherType.map(item => {
- const value = Object.values(item)[0]
- for (let each in value) {
- if (value[each].name === id) {
- value[each].checked = !value[each].checked
-
- setTimeout(() => {
-
- this.setState({ checkedFilterIdList: this.state.checkedFilterIdList.concat(value[each]), goodsParam: [{ param_id: value[each].name.id, param_value: value[each].name }] }, () => {
- this.getSearchParams({ goodsParam: this.state.goodsParam })
- this.goodsSearch({ goodsParam: this.state.goodsParam })
- })
- }, 1000);
- }
- }
- return item
- })
- // 处理宽度筛选项
- const newWidthType = this.state.widthType.map((item) => {
- if (item.name === id) {
- item.checked = !item.checked
- setTimeout(() => {
- this.setState({ checkedFilterIdList: this.state.checkedFilterIdList.concat(item), goodsParamExt: [{ param_id: item.id, param_ext: [item.value] }] }, () => {
- this.getSearchParams({ goodsParamExt: this.state.goodsParamExt })
- this.goodsSearch({ goodsParamExt: this.state.goodsParamExt })
- })
- }, 1000);
- }
- return item
- })
-
- this.setState({ mainType: newMainType, loadMorePageIndex: 1, goodType: newGoodType, widthType: newWidthType, otherType: newOtherType }, () => {
- // console.log(this.state.mainType)
- })
- }
-
- handleOnPageChange(value) {
- showLoading({ title: '加载中' })
- this.goodsSearch({ curr_page: value.current, order: this.state.filterCondition })
- }
- showHomePage() {
- this.setState({ showShopHomePage: true })
- }
- showDescriptionPage() {
- this.setState({ showShopHomePage: false })
- }
-
- // 确认筛选
- submitFilter() {
- this.setState({ isShowFilter: false })
- }
-
- //重置按键筛选
- resetFilterList() {
-
- showLoading({ title: '加载中' })
- this.setState({
- checkedFilterIdList: [],
- curr_page: 1,
- page_count: 10,
- shop_name: false,
- config_id: 4,
- shop_class_id: '',
- order: '',
- curr_page: 1,
- goods_class_id: '',
- class_filter: '',
- goods_type: '',
- goodsSpec: [],
- goodsParam: [],
- goodsParamExt: [],
- }, () => {
- this.getSearchParams({})
- this.goodsSearch({})
- })
-
+ }, () => {
+ this.state.filterOptions.newProduct ? this.goodsSearch({ currPage: 1, order: "g.create_date desc" }) : this.goodsSearch({ currPage: 1, order: "g.create_date" })
+ }
+ )
}
- openNavMap() {
- Taro.openLocation({
- latitude: Number(this.state.latitude),
- longitude: Number(this.state.longitude),
- name: this.state.shopAddress,
+ if (value == 3) {
- })
- }
- componentDidMount() {
- showLoading({ title: '加载中' })
- //页面加载之后 得到指定店铺的商品 和 筛选标签
- this.goodsSearch({}) // 加载店铺商品
- this.getSearchParams({})// 加载筛选项
- this.getShopDescription({}) // 加载店铺说明
- }
+ this.setState({
- componentDidShow() { }
-
- componentDidHide() { }
-
- // 底部加载
- onReachBottom() {
- showLoading({
- title: '加载中'
- })
- this.setState({ isAddToList: true, loadMorePageIndex: this.state.loadMorePageIndex + 1 }, () => {
- this.goodsSearch({ curr_page: this.state.loadMorePageIndex })
- })
-
- }
- // 页面位置
- onPageScroll(location) {
- if (location.scrollTop <= 300 && this.state.isShowTopNav) {
- this.setState({ isShowTopNav: false })
- } else if (location.scrollTop > 300 && !this.state.isShowTopNav) {
- this.setState({ isShowTopNav: true })
+ filterOptions: {
+ all: false,
+ amount: false,
+ newProduct: false,
+ price: !this.state.filterOptions.price,
+ popularity: false
}
+ }, () => {
+ this.state.filterOptions.price ? this.goodsSearch({ currPage: 1, order: "g.goods_price desc" }) : this.goodsSearch({ currPage: 1, order: "g.goods_price" })
+ }
+ )
+
}
- render() {
+ if (value == 4) {
- const ShopItemElementsArray = this.state.shopItem.length ? this.state.shopItem.map((item, index) => {
- return
-
-
- }) : null
+ this.setState({
- const filterElementsArray = this.state.filterBar.map((item, index) => {
- let isTure = this.state.filterOptions[item]
+ filterOptions: {
+ all: false,
+ amount: false,
+ newProduct: false,
+ price: false,
+ popularity: !this.state.filterOptions.popularity
+ }
+ }, () => {
+ this.state.filterOptions.popularity ? this.goodsSearch({ currPage: 1, order: "g.browse_times desc", }) : this.goodsSearch({ currPage: 1, order: "g.browse_times" })
- return
-
- {this.state.filterBarKeys[item]}
-
- {index !== 0 && index !== 5 && (isTure ? : )}
-
- })
- // 侧边已选项
- const checkedFilterElementsArray = this.state.checkedFilterIdList.map((item, index) => {
- return {item.name}
- })
+ }
+ )
+
+ }
+ }
+ // 是否显示侧边筛选
+ showAndHideFilter() {
+ this.setState({ isShowFilter: !this.state.isShowFilter })
+ }
+ // 选择侧边筛选的标签
+ selectTag(name) {
+ const id = name.name
+ showLoading({ title: '加载中' })
+ // 处理分类筛选项
+ const newMainType = this.state.mainType.map((item) => {
+ if (item.id === id) {
+ item.checked = !item.checked
+ setTimeout(() => {
+ this.setState({ goods_class_id: id, checkedFilterIdList: this.state.checkedFilterIdList.concat([item]) }, () => {
+ this.getSearchParams({ goods_class_id: this.state.goods_class_id })
+ this.goodsSearch({ goods_class_id: this.state.goods_class_id })
+ })
+ }, 1000);
+ }
+ return item
+ })
+ // 处理商品类型筛选项
+ const newGoodType = this.state.goodType.map((item) => {
+ if (item.id === id) {
+ item.checked = !item.checked
+
+ setTimeout(() => {
+ this.setState({ goods_type: id, checkedFilterIdList: this.state.checkedFilterIdList.concat([item]) }, () => {
+ this.getSearchParams({ goods_type: this.state.goods_type })
+ this.goodsSearch({ goods_type: this.state.goods_type })
+ })
+
+ }, 1000);
+ }
+ return item
+ })
+ // 处理其他筛选项
+ const newOtherType = this.state.otherType.map(item => {
+ const value = Object.values(item)[0]
+ for (let each in value) {
+ if (value[each].name === id) {
+ value[each].checked = !value[each].checked
+
+ setTimeout(() => {
+
+ this.setState({ checkedFilterIdList: this.state.checkedFilterIdList.concat(value[each]), goodsParam: [{ param_id: value[each].name.id, param_value: value[each].name }] }, () => {
+ this.getSearchParams({ goodsParam: this.state.goodsParam })
+ this.goodsSearch({ goodsParam: this.state.goodsParam })
+ })
+ }, 1000);
+ }
+ }
+ return item
+ })
+ // 处理宽度筛选项
+ const newWidthType = this.state.widthType.map((item) => {
+ if (item.name === id) {
+ item.checked = !item.checked
+ setTimeout(() => {
+ this.setState({ checkedFilterIdList: this.state.checkedFilterIdList.concat(item), goodsParamExt: [{ param_id: item.id, param_ext: [item.value] }] }, () => {
+ this.getSearchParams({ goodsParamExt: this.state.goodsParamExt })
+ this.goodsSearch({ goodsParamExt: this.state.goodsParamExt })
+ })
+ }, 1000);
+ }
+ return item
+ })
+
+ this.setState({ mainType: newMainType, loadMorePageIndex: 1, goodType: newGoodType, widthType: newWidthType, otherType: newOtherType }, () => {
+ // console.log(this.state.mainType)
+ })
+ }
+
+ handleOnPageChange(value) {
+ showLoading({ title: '加载中' })
+ this.goodsSearch({ curr_page: value.current, order: this.state.filterCondition })
+ }
+ showHomePage() {
+ this.setState({ showShopHomePage: true })
+ }
+ showDescriptionPage() {
+ this.setState({ showShopHomePage: false })
+ }
+
+ // 确认筛选
+ submitFilter() {
+ this.setState({ isShowFilter: false })
+ }
+
+ //重置按键筛选
+ resetFilterList() {
+
+ showLoading({ title: '加载中' })
+ this.setState({
+ checkedFilterIdList: [],
+ curr_page: 1,
+ page_count: 10,
+ shop_name: false,
+ config_id: 4,
+ shop_class_id: '',
+ order: '',
+ curr_page: 1,
+ goods_class_id: '',
+ class_filter: '',
+ goods_type: '',
+ goodsSpec: [],
+ goodsParam: [],
+ goodsParamExt: [],
+ }, () => {
+ this.getSearchParams({})
+ this.goodsSearch({})
+ })
+
+
+ }
+ openNavMap() {
+ Taro.openLocation({
+ latitude: Number(this.state.latitude),
+ longitude: Number(this.state.longitude),
+ name: this.state.shopAddress,
+
+ })
+ }
+ componentDidMount() {
+ showLoading({ title: '加载中' })
+ //页面加载之后 得到指定店铺的商品 和 筛选标签
+ this.goodsSearch({}) // 加载店铺商品
+ this.getSearchParams({})// 加载筛选项
+ this.getShopDescription({}) // 加载店铺说明
+ }
+
+ componentDidShow() { }
+
+ componentDidHide() { }
+
+ // 底部加载
+ onReachBottom() {
+ showLoading({
+ title: '加载中'
+ })
+ this.setState({ isAddToList: true, loadMorePageIndex: this.state.loadMorePageIndex + 1 }, () => {
+ this.goodsSearch({ curr_page: this.state.loadMorePageIndex })
+ })
+
+ }
+ // 页面位置
+ onPageScroll(location) {
+ if (location.scrollTop <= 300 && this.state.isShowTopNav) {
+ this.setState({ isShowTopNav: false })
+ } else if (location.scrollTop > 300 && !this.state.isShowTopNav) {
+ this.setState({ isShowTopNav: true })
+ }
+ }
+ render() {
+
+ const ShopItemElementsArray = this.state.shopItem.length ? this.state.shopItem.map((item, index) => {
+ return
+
+
+ }) : null
+
+ const filterElementsArray = this.state.filterBar.map((item, index) => {
+ let isTure = this.state.filterOptions[item]
+
+ return
+
+ {this.state.filterBarKeys[item]}
+
+ {index !== 0 && index !== 5 && (isTure ? : )}
+
+ })
+ // 侧边已选项
+ const checkedFilterElementsArray = this.state.checkedFilterIdList.map((item, index) => {
+ return {item.name}
+ })
- // 侧边筛选的分类项
- const goodsClassElementsArray = this.state.mainType.map((item, index) => {
- return {item.name}
- })
- // 侧边筛选的商品类型项
- const goodsTypeElementsArray = this.state.goodType.map((item, index) => {
- return {item.name}
- })
+ // 侧边筛选的分类项
+ const goodsClassElementsArray = this.state.mainType.map((item, index) => {
+ return {item.name}
+ })
+ // 侧边筛选的商品类型项
+ const goodsTypeElementsArray = this.state.goodType.map((item, index) => {
+ return {item.name}
+ })
- // 侧边筛选的其他项
- const goodsParamElementsArray = this.state.otherType.map((item, index) => {
- let titleKey = Object.keys(item)[0]
- let values = item[titleKey]
- return {titleKey}
- {values.map((subItem, subIndex) => {
- let name = subItem.name
- let isCheck = subItem.checked
- return
- {name}
-
- })}
-
- })
+ // 侧边筛选的其他项
+ const goodsParamElementsArray = this.state.otherType.map((item, index) => {
+ let titleKey = Object.keys(item)[0]
+ let values = item[titleKey]
+ return {titleKey}
+ {values.map((subItem, subIndex) => {
+ let name = subItem.name
+ let isCheck = subItem.checked
+ return
+ {name}
+
+ })}
+
+ })
- // 侧边筛选宽度选项
- const widthnessElementsArray = this.state.widthType.map((item, index) => {
- return {item.name}
- })
- // 店铺页面/店铺主页
- const shopHomepageElement =
-
- {filterElementsArray}
-
-
- 筛选
+ // 侧边筛选宽度选项
+ const widthnessElementsArray = this.state.widthType.map((item, index) => {
+ return {item.name}
+ })
+ // 店铺页面/店铺主页
+ const shopHomepageElement =
+
+ {filterElementsArray}
+
+
+ 筛选
-
-
-
-
- {/* 侧边筛选 */}
-
-
- {this.state.checkedFilterIdList.length ? 已选择 : null}
- {checkedFilterElementsArray}
- {this.state.mainType.length ? 分类 : null}
- {goodsClassElementsArray}
- {this.state.goodType.length ? 商品类型 : null}
- {goodsTypeElementsArray}
- {goodsParamElementsArray}
- {this.state.widthType.length ? 宽度 : null}
- {widthnessElementsArray}
-
-
-
-
-
-
-
-
-
-
- {/* 店铺的商品列表 */}
-
- {this.state.shopItem.length ? ShopItemElementsArray : 没有更多了}
-
-
- // 店铺详情
- const shopDescriptionElement =
-
-
-
-
- {this.state.shopName}
-
-
- {this.state.shopAddress}
-
-
- 联系人:{this.state.contactName}
- 联系电话:{this.state.contactNumber}
-
-
+
+
+
+ {/* 侧边筛选 */}
+
+
+ {this.state.checkedFilterIdList.length ? 已选择 : null}
+ {checkedFilterElementsArray}
+ {this.state.mainType.length ? 分类 : null}
+ {goodsClassElementsArray}
+ {this.state.goodType.length ? 商品类型 : null}
+ {goodsTypeElementsArray}
+ {goodsParamElementsArray}
+ {this.state.widthType.length ? 宽度 : null}
+ {widthnessElementsArray}
+
+
+
+
+
-
-
- 店铺简介
+
+
+
+
+ {/* 店铺的商品列表 */}
+
+ {this.state.shopItem.length ? ShopItemElementsArray : 没有更多了}
+
+
+
+ // 店铺详情
+ const shopDescriptionElement =
+
+
+
+
+ {this.state.shopName}
+
+
+ {this.state.shopAddress}
+
+
+ 联系人:{this.state.contactName}
+ 联系电话:{this.state.contactNumber}
+
+
+
+
+
+ 店铺简介
-
- 店铺介绍:
- {this.state.shopDescription}
-
-
+
+ 店铺介绍:
+ {this.state.shopDescription}
+
+
- {/*
+ {/*
*/}
- {/* location.png */}
-
-
-
-
+ {/* location.png */}
+
+
+
+
- {/* */}
+
+
+
+ return (
+
+
+
+
+ {this.state.shopName}
+
+
+
+
+ {platformChecker() ? : }
- return (
-
+
-
-
- {this.state.shopName}
-
-
-
-
-
-
-
-
-
- 店铺全部分类
+
+
+ 店铺全部分类
-
-
-
-
-
-
- 首页
-
-
-
-
- 店铺说明
-
-
-
-
- {/* 显示店铺首页或者店铺详情 */}
- {this.state.showShopHomePage ? shopHomepageElement : shopDescriptionElement}
- {this.state.isShowTopNav ? : null}
-
-
-
-
-
- {/* */}
-
+
+
- )
- }
+
+
+
+ 首页
+
+
+
+
+ 店铺说明
+
+
+
+
+ {/* 显示店铺首页或者店铺详情 */}
+ {this.state.showShopHomePage ? shopHomepageElement : shopDescriptionElement}
+ {this.state.isShowTopNav ? : null}
+
+
+
+
+
+ {/* */}
+
+
+ )
+ }
}
export default Shop
diff --git a/src/pages/shop/shop.scss b/src/pages/shop/shop.scss
index 56d9f39..11ad162 100644
--- a/src/pages/shop/shop.scss
+++ b/src/pages/shop/shop.scss
@@ -8,7 +8,7 @@ $themeColor:#FF7142;
top:100px;
left:60px;
font-size: 50px;
-
+
}
}
.show-blur{
@@ -20,7 +20,7 @@ $themeColor:#FF7142;
width: 100%
}
.nav-box{
-
+
background-color: black;
position: relative;
.shopcate-selection{
@@ -40,7 +40,7 @@ $themeColor:#FF7142;
font-size: 25px;
}
}
-
+
.nav{
display: flex;
line-height: 55px;
@@ -60,6 +60,7 @@ $themeColor:#FF7142;
.interaction{
position: absolute;
opacity: 0;
+
}
}
.homepage-link{
@@ -71,13 +72,13 @@ $themeColor:#FF7142;
flex:1;
}
}
-
+
}
.filter-box{
display: flex;
flex-wrap: nowrap;
flex-direction: row;
-
+
.filter-title{
box-sizing:border-box;
flex:1;
@@ -132,7 +133,7 @@ $themeColor:#FF7142;
}
}
}
-
+
}
.show{
left:0px;
@@ -149,32 +150,32 @@ $themeColor:#FF7142;
box-sizing:border-box;
width: 50%;
padding:10px;
-
+
}
.no-more-title{
width:100%;
margin-top:20%;
}
-
+
}
.pagination{
margin-top: 50px;
margin-bottom: 50px;
}
.copyright-box{
-
+
padding:0 20px;
.title{
text-align: center;
line-height: 100px;
font-size: 25px;
-
+
}
-
+
}
.gap{
-
+
height:150px;
}
//--------- 店铺说明样式
@@ -201,7 +202,7 @@ margin-top:20%;
}
}
-
+
}
}
.shop-description2{
@@ -240,7 +241,7 @@ margin-top:20%;
text-align: center;
font-size: 0;
margin-bottom: 5px;
-
+
}
}
-}
\ No newline at end of file
+}
diff --git a/src/util/standardLogin.js b/src/util/standardLogin.js
index 4da89d1..5efbc44 100644
--- a/src/util/standardLogin.js
+++ b/src/util/standardLogin.js
@@ -4,60 +4,59 @@ import { setGlobalStorage, getGlobalStorage } from './getSetStoage';
const setUserInfoToStorage = () => {
- Taro.request({
- url: URL.ShopWxStore,
- header: {
- 'Cookie': 'PFWSSS=' + getGlobalStorage('session_id'),
- }
- })
- .then(res => {
- if (res.data.err_msg === 'success') {
- setGlobalStorage('user_identity', { username: res.data.otherData.userName, userphone: res.data.otherData.userPhone })
+ Taro.request({
+ url: URL.ShopWxStore,
+ header: {
+ 'Cookie': 'PFWSSS=' + getGlobalStorage('session_id'),
+ }
+ })
+ .then(res => {
- } else {
- Taro.showToast({
- title: res.data.err_msg,
- icon: 'none',
- duration: 1500
- })
- }
+ if (res.data.err_msg === 'success') {
+ setGlobalStorage('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)=>{
+ return new Promise((resolve, reject) => {
Taro.request({
- url: URL.StandardLogin,
- method: 'POST',
- dataType: 'json',
- data: {
- username: username,
- password: password,
- },
- header: {
- 'content-type': 'application/x-www-form-urlencoded',
- 'X-Requested-With': 'XMLHttpRequest'
- }
+ url: URL.StandardLogin,
+ method: 'POST',
+ dataType: 'json',
+ data: {
+ username: username,
+ password: password,
+ },
+ header: {
+ 'content-type': 'application/x-www-form-urlencoded',
+ 'X-Requested-With': 'XMLHttpRequest'
+ }
})
- .then(res => {
- console.log('普通登录',res)
- if (res.data.err_code === 0) {
- Taro.showToast({
- title: '登入成功',
- icon: 'success',
- duration: 1000
- })
-
- setGlobalStorage('session_id', res.data.session_id)
- setGlobalStorage('shopInfo', res.data.shop_info)
- setGlobalStorage('userInfo', res.data.user_info)
- setGlobalStorage('accountInfo', { username: username, password: password })
- setUserInfoToStorage()
- resolve('success')
- } else {
-
- reject(res)
- }
- })
- })
+ .then(res => {
+ console.log('普通登录', res)
+ if (res.data.err_code === 0) {
+ Taro.showToast({
+ title: '登入成功',
+ icon: 'success',
+ duration: 1000
+ })
+ setGlobalStorage('session_id', res.data.session_id)
+ setGlobalStorage('shopInfo', res.data.shop_info)
+ setGlobalStorage('userInfo', res.data.user_info)
+ setGlobalStorage('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 e56cc80..ad36e4d 100644
--- a/src/util/weChatLogin.js
+++ b/src/util/weChatLogin.js
@@ -1,6 +1,7 @@
import Taro from '@tarojs/taro'
import URL from '../serviceAPI.config'
import { getGlobalStorage } from './getSetStoage';
+import platformChecker from './plaformChecker'
//用户信息姓名和电话号码接口
const setUserInfoToStorage = () => {
@@ -28,54 +29,61 @@ const setUserInfoToStorage = () => {
// 异步函数登入api
export default function wechatLogin() {
- return new Promise((resolve,reject)=>{
- 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 === 0) {
- 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()
- resolve('微信登入成功')
- } else {
- Taro.showToast({
- title: '微信登入失败',
- icon: 'none',
- duration: 2000
- })
- reject('微信登入失败')
- // Taro.clearStorageSync()
- }
+ //微信登录的时候查看小程序端是什么平台
+ if (platformChecker()) {
+ return new Promise((resolve, reject) => {
+ Taro.login({
+ success(res) {
+ if (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 === 0) {
+ 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()
+ resolve('微信登入成功')
+ } else {
+ Taro.showToast({
+ title: '微信登入失败',
+ icon: 'none',
+ duration: 2000
+ })
+ reject('微信登入失败')
+ }
+ }
+ )
}
- )
- }
- else {
- console.log('登录失败!' + res.errMsg)
- }
- }
- })
- })
-
-}
\ No newline at end of file
+ else {
+ console.log('微信登录失败!' + res.errMsg)
+ }
+ }
+ })
+ })
+
+ }else{
+ return new Promise((resolve, reject)=>{
+ resolve()
+ })
+ }
+
+
+}