支付宝测试
This commit is contained in:
parent
870fc47323
commit
ff5c1c1389
@ -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 {
|
||||
<AtListItem hasBorder={false} title='店铺分类' extraText={this.props.selectedValue.name} arrow='right' />
|
||||
</AtList>
|
||||
</View>
|
||||
{this.state.AliIsShowPicker ? <View>
|
||||
{this.state.AliIsShowPicker ? <View>
|
||||
<View className='curtain' onClick={this.aliCancelButton.bind(this)} > </View>
|
||||
|
||||
<View class='ali-picker-container'>
|
||||
|
@ -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)
|
||||
// }
|
||||
// }
|
||||
|
@ -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 = <AtModal isOpened={this.state.isOpenedGrabModal}>
|
||||
<AtModalHeader>提示</AtModalHeader>
|
||||
<AtModalContent>
|
||||
确认抢单?
|
||||
const modalMessageGrabElement = <AtModal isOpened={this.state.isOpenedGrabModal}>
|
||||
<AtModalHeader>提示</AtModalHeader>
|
||||
<AtModalContent>
|
||||
确认抢单?
|
||||
</AtModalContent>
|
||||
<AtModalAction> <Button onClick={this.handleGrabModalCancel.bind(this)}>取消</Button> <Button className='orange' onClick={this.handleGrabConfirm.bind(this)}>确定</Button> </AtModalAction>
|
||||
</AtModal>
|
||||
<AtModalAction> <Button onClick={this.handleGrabModalCancel.bind(this)}>取消</Button> <Button className='orange' onClick={this.handleGrabConfirm.bind(this)}>确定</Button> </AtModalAction>
|
||||
</AtModal>
|
||||
|
||||
const allDemandingElementArray = this.state.supplys.length ? this.state.supplys.map((item, index) => {
|
||||
return <View className='demanding-info' key={index}>
|
||||
<View className='header'>
|
||||
<AtIcon value='user' size='12' color='#2196F3'></AtIcon>
|
||||
<View className='name'> 业主:{item.user_name}</View>
|
||||
<View className='others'>
|
||||
<Text className='cate'>{item.class_name + ' '} </Text>
|
||||
|
|
||||
const allDemandingElementArray = this.state.supplys.length ? this.state.supplys.map((item, index) => {
|
||||
return <View className='demanding-info' key={index}>
|
||||
<View className='header'>
|
||||
<AtIcon value='user' size='12' color='#2196F3'></AtIcon>
|
||||
<View className='name'> 业主:{item.user_name}</View>
|
||||
<View className='others'>
|
||||
<Text className='cate'>{item.class_name + ' '} </Text>
|
||||
|
|
||||
<Image src={eyeIcon} style='width:12px; height:12px; vertical-align:middle;' />
|
||||
<Text className='watch'>{item.browse_times}</Text>
|
||||
</View>
|
||||
</View>
|
||||
<View className='body'>
|
||||
<View className='image-container' onClick={this.goToGrabOrderPage.bind(this, item.sd_id)}>
|
||||
<Image style='width:100%;height:100%' src={URL.Base + item.file_path[0].thumb_path} />
|
||||
</View>
|
||||
<View className='detail'>
|
||||
<View className='title'>{item.sd_title}</View>
|
||||
<View className='para'>{item.sd_desc}</View>
|
||||
{item.state === '1' ? <View className='button' onClick={this.grabOrder.bind(this, item.sd_id)}>
|
||||
<Button size='mini' className='button-orange'>抢单</Button>
|
||||
</View> : null || item.state === '2' ? <View className='button'>
|
||||
<Button size='mini' className='button-orange blur'>{item.state_name}</Button>
|
||||
</View> : null || item.state === '3' ? <View className='button'>
|
||||
<Button size='mini' className='button-orange blur'>{item.state_name}</Button>
|
||||
</View> : null}
|
||||
</View>
|
||||
</View>
|
||||
<View className='footer'>
|
||||
<View className='location'><AtIcon value='map-pin' size='12' color='black'></AtIcon>{item.user_address}</View>
|
||||
<View className='time'>更新日期:{item.update_date}</View>
|
||||
<Text className='watch'>{item.browse_times}</Text>
|
||||
</View>
|
||||
</View>
|
||||
<View className='body'>
|
||||
<View className='image-container' onClick={this.goToGrabOrderPage.bind(this, item.sd_id)}>
|
||||
<Image style='width:100%;height:100%' src={URL.Base + item.file_path[0].thumb_path} />
|
||||
</View>
|
||||
<View className='detail'>
|
||||
<View className='title'>{item.sd_title}</View>
|
||||
<View className='para'>{item.sd_desc}</View>
|
||||
{item.state === '1' ? <View className='button' onClick={this.grabOrder.bind(this, item.sd_id)}>
|
||||
<Button size='mini' className='button-orange'>抢单</Button>
|
||||
</View> : null || item.state === '2' ? <View className='button'>
|
||||
<Button size='mini' className='button-orange blur'>{item.state_name}</Button>
|
||||
</View> : null || item.state === '3' ? <View className='button'>
|
||||
<Button size='mini' className='button-orange blur'>{item.state_name}</Button>
|
||||
</View> : null}
|
||||
</View>
|
||||
</View>
|
||||
<View className='footer'>
|
||||
<View className='location'><AtIcon value='map-pin' size='12' color='black'></AtIcon>{item.user_address}</View>
|
||||
<View className='time'>更新日期:{item.update_date}</View>
|
||||
</View>
|
||||
|
||||
</View>
|
||||
}) : <View className='no-more-title'>没有更多了</View>
|
||||
return (
|
||||
<View className='allDemanding'>
|
||||
{/* 模态框 */}
|
||||
{modalMessageGrabElement}
|
||||
|
||||
<View className='page-section'>
|
||||
{/* 供求状态选择 */}
|
||||
<View>
|
||||
<Picker mode='selector' rangeKey='name' range={this.state.demandingState} onChange={this.changeDemandingState}>
|
||||
<View className='picker'>
|
||||
<View className='title-box'>
|
||||
<Text className='title'> 供求状态:</Text> <Text className='selected'>{this.state.demandingStateSelected.name}</Text>
|
||||
</View>
|
||||
|
||||
</View>
|
||||
</Picker>
|
||||
</View>
|
||||
</View>
|
||||
|
||||
<View className='input-box'>
|
||||
|
||||
<AtInput
|
||||
name='value'
|
||||
title='需求标题:'
|
||||
type='text'
|
||||
placeholder='需求标题'
|
||||
value={this.state.title}
|
||||
onChange={this.titleChange.bind(this)}
|
||||
border={false}
|
||||
/>
|
||||
</View>
|
||||
{/* 开始和结束日期选择 */}
|
||||
<View className='page-section-picker'>
|
||||
<View className='picker-box'>
|
||||
<View className='picker-wrapper'>
|
||||
<Picker mode='date' className='picker-container' onChange={this.onStartDateChange}>
|
||||
<View className='picker'>
|
||||
<View className='title-box'>
|
||||
<Text className='title'>开始日期:</Text> <Text className='date'>{this.state.startDateSel}</Text>
|
||||
</View>
|
||||
</View>
|
||||
</Picker>
|
||||
</View>
|
||||
}) : <View className='no-more-title'>没有更多了</View>
|
||||
return (
|
||||
<View className='allDemanding'>
|
||||
{/* 模态框 */}
|
||||
{modalMessageGrabElement}
|
||||
|
||||
<View className='page-section'>
|
||||
{/* 供求状态选择 */}
|
||||
<View>
|
||||
<Picker mode='selector' rangeKey='name' range={this.state.demandingState} onChange={this.changeDemandingState}>
|
||||
<View className='picker'>
|
||||
<View className='title-box'>
|
||||
<Text className='title'> 供求状态:</Text> <Text className='selected'>{this.state.demandingStateSelected.name}</Text>
|
||||
</View>
|
||||
|
||||
</View>
|
||||
</Picker>
|
||||
</View>
|
||||
<View className='picker-wrapper'>
|
||||
<Picker className='picker-container' mode='date' start={this.state.startDateSel} onChange={this.onEndDateChange}>
|
||||
<View className='picker'>
|
||||
<View className='title-box'>
|
||||
<Text className='title'>结束日期:</Text> <Text className='date'>{this.state.endDateSel}</Text>
|
||||
</View>
|
||||
</View>
|
||||
|
||||
<View className='input-box'>
|
||||
|
||||
<AtInput
|
||||
name='value'
|
||||
title='需求标题:'
|
||||
type='text'
|
||||
placeholder='需求标题'
|
||||
value={this.state.title}
|
||||
onChange={this.titleChange.bind(this)}
|
||||
/>
|
||||
</View>
|
||||
{/* 开始和结束日期选择 */}
|
||||
<View className='page-section'>
|
||||
<View className='picker-box'>
|
||||
<View className='picker-wrapper'>
|
||||
<Picker mode='date' className='picker-container' onChange={this.onStartDateChange}>
|
||||
<View className='picker'>
|
||||
<View className='title-box'>
|
||||
<Text className='title'>开始日期:</Text> <Text className='date'>{this.state.startDateSel}</Text>
|
||||
</View>
|
||||
</View>
|
||||
</Picker>
|
||||
</View>
|
||||
|
||||
<View className='picker-wrapper'>
|
||||
<Picker className='picker-container' mode='date' start={this.state.startDateSel} onChange={this.onEndDateChange}>
|
||||
<View className='picker'>
|
||||
<View className='title-box'>
|
||||
<Text className='title'>结束日期:</Text> <Text className='date'>{this.state.endDateSel}</Text>
|
||||
</View>
|
||||
</View>
|
||||
</Picker>
|
||||
</View>
|
||||
|
||||
</View>
|
||||
</View>
|
||||
{/* 行业分类选择 */}
|
||||
<InteractionComponent url={URL.GetIndustryTypeList} onPassDataToChild={this.getDataFromChild.bind(this)} selectedValue={this.state.industryTypeSelected}></InteractionComponent>
|
||||
|
||||
|
||||
<View className='button-box'>
|
||||
<View className='button' onClick={this.searchHanlder.bind(this)}>
|
||||
<Button type='primary' size='mini' className='button-orange' >
|
||||
<AtIcon value='search' size='12' color='white'></AtIcon>
|
||||
搜索</Button>
|
||||
</View>
|
||||
|
||||
<View className='button' onClick={this.emptyFilter.bind(this)}>
|
||||
<Button type='primary' size='mini' className='button-dark-red' >
|
||||
<AtIcon value='trash' size='12' color='white'></AtIcon>
|
||||
清空</Button>
|
||||
</View>
|
||||
</View>
|
||||
{/* 供求页面的数据加载 */}
|
||||
<View className='demanding-box'>
|
||||
{allDemandingElementArray}
|
||||
</View>
|
||||
{this.state.isShowTopNav ? <ScrollToTopComponent ></ScrollToTopComponent> : null}
|
||||
<CopyrightComponent></CopyrightComponent>
|
||||
</Picker>
|
||||
</View>
|
||||
)
|
||||
}
|
||||
|
||||
</View>
|
||||
</View>
|
||||
{/* 行业分类选择 */}
|
||||
{platformChecker() ?
|
||||
<InteractionComponent url={URL.GetIndustryTypeList}
|
||||
onPassDataToChild={this.getDataFromChild.bind(this)}
|
||||
selectedValue={this.state.industryTypeSelected}></InteractionComponent> :
|
||||
<AliIndustryTypeInteraction url={URL.GetIndustryTypeList}
|
||||
onPassDataToChild={this.getDataFromChild.bind(this)}
|
||||
selectedValue={this.state.industryTypeSelected} />
|
||||
}
|
||||
|
||||
|
||||
|
||||
<View className='button-box'>
|
||||
<View className='button' onClick={this.searchHanlder.bind(this)}>
|
||||
<Button type='primary' size='mini' className='button-orange' >
|
||||
<AtIcon value='search' size='12' color='white'></AtIcon>
|
||||
搜索</Button>
|
||||
</View>
|
||||
|
||||
<View className='button' onClick={this.emptyFilter.bind(this)}>
|
||||
<Button type='primary' size='mini' className='button-dark-red' >
|
||||
<AtIcon value='trash' size='12' color='white'></AtIcon>
|
||||
清空</Button>
|
||||
</View>
|
||||
</View>
|
||||
{/* 供求页面的数据加载 */}
|
||||
<View className='demanding-box'>
|
||||
{allDemandingElementArray}
|
||||
</View>
|
||||
{this.state.isShowTopNav ? <ScrollToTopComponent ></ScrollToTopComponent> : null}
|
||||
<CopyrightComponent></CopyrightComponent>
|
||||
</View>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
export default AllDemanding
|
||||
|
@ -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{
|
||||
|
@ -28,7 +28,6 @@ class GoodsPublish extends Component {
|
||||
constructor() {
|
||||
super(...arguments)
|
||||
this.state = {
|
||||
|
||||
shopTypeSelected: { name: '选择店铺类型', id: '' },//已选的店铺分类
|
||||
goodsTypeSelected: { name: '选择商品分类', id: '' },// 已选的商品分类
|
||||
productName: '',
|
||||
|
@ -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() {
|
||||
|
@ -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() { }
|
||||
|
@ -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 <View key={index} className='good-container'>
|
||||
<View className='good-container-a'>
|
||||
|
@ -479,8 +479,6 @@ class MySupplyDemand extends Component {
|
||||
<CopyrightComponent></CopyrightComponent>
|
||||
|
||||
</View>
|
||||
|
||||
|
||||
<MovableView className='movable-point' x={this.state.screenWidth} y={this.state.screenHeight} style='opacity:0.3' direction='all' >
|
||||
<View className='movable-point' onClick={this.goToCenterPage.bind(this)}> 个人中心</View>
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -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;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
}
|
||||
else {
|
||||
console.log('微信登录失败!' + res.errMsg)
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
}else{
|
||||
return new Promise((resolve, reject)=>{
|
||||
resolve()
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user