支付宝测试

This commit is contained in:
郑茂强 2019-03-26 17:32:11 +08:00
parent 870fc47323
commit ff5c1c1389
13 changed files with 1324 additions and 1294 deletions

View File

@ -173,6 +173,7 @@ class ShopTypeInteractionComp extends Component {
this.passDataToParent(result) this.passDataToParent(result)
} }
invokeAliPicker() { invokeAliPicker() {
console.log('clicked')
this.setState({ this.setState({
AliIsShowPicker:true AliIsShowPicker:true
}) })

View File

@ -1,3 +1,7 @@
.shop-interaction{
opacity: 1;
}
.page-section{ .page-section{
border-bottom: 1Px solid #d6e4ef; border-bottom: 1Px solid #d6e4ef;
font-size:32rpx; font-size:32rpx;
@ -79,3 +83,9 @@
text-align: right; text-align: right;
} }
} }
// .picker-wrapper{
// .at-list__item{
// background: rgba(0,0,0,1)
// }
// }

View File

@ -1,9 +1,10 @@
import Taro, { Component } from '@tarojs/taro' import Taro, { Component } from '@tarojs/taro'
import { View, Text, Image, Button,Picker } from '@tarojs/components' import { View, Text, Image, Button, Picker } from '@tarojs/components'
import { AtInput, AtIcon, AtModal, AtModalHeader, AtModalContent, AtModalAction } from 'taro-ui' import { AtInput, AtIcon, AtModal, AtModalHeader, AtModalContent, AtModalAction } from 'taro-ui'
import CopyrightComponent from '../../component/copyrightComponent/copyrightComponent' import CopyrightComponent from '../../component/copyrightComponent/copyrightComponent'
import ScrollToTopComponent from '../../component/scrollToTopComponent/scrollToTopComponent' import ScrollToTopComponent from '../../component/scrollToTopComponent/scrollToTopComponent'
import AliIndustryTypeInteraction from '../../component/aliIndustryTypeInteraction/aliIndustryTypeInteraction'
import InteractionComponent from '../../component/interactionComponent/interactionComponent' import InteractionComponent from '../../component/interactionComponent/interactionComponent'
import loginExpired from '../../util/loginExpired' import loginExpired from '../../util/loginExpired'
import onClickValueService from '../../util/onClickValueService' import onClickValueService from '../../util/onClickValueService'
@ -13,6 +14,7 @@ import './allDemanding.scss'
import eyeIcon from '../../icons/eye.png' import eyeIcon from '../../icons/eye.png'
import { getGlobalStorage } from '../../util/getSetStoage'; import { getGlobalStorage } from '../../util/getSetStoage';
import { showLoading } from '../../util/hideShowLoading'; import { showLoading } from '../../util/hideShowLoading';
import platformChecker from '../../util/plaformChecker';
@ -208,7 +210,7 @@ class AllDemanding extends Component {
goToGrabOrderPage(e) { goToGrabOrderPage(e) {
const id = onClickValueService(e) const id = onClickValueService(e)
let orderId=encodeURIComponent(id) let orderId = encodeURIComponent(id)
Taro.navigateTo({ Taro.navigateTo({
url: '/pages/grabOrderPage/grabOrderPage?orderId=' + orderId url: '/pages/grabOrderPage/grabOrderPage?orderId=' + orderId
}) })
@ -327,10 +329,11 @@ class AllDemanding extends Component {
placeholder='需求标题' placeholder='需求标题'
value={this.state.title} value={this.state.title}
onChange={this.titleChange.bind(this)} onChange={this.titleChange.bind(this)}
border={false}
/> />
</View> </View>
{/* 开始和结束日期选择 */} {/* 开始和结束日期选择 */}
<View className='page-section'> <View className='page-section-picker'>
<View className='picker-box'> <View className='picker-box'>
<View className='picker-wrapper'> <View className='picker-wrapper'>
<Picker mode='date' className='picker-container' onChange={this.onStartDateChange}> <Picker mode='date' className='picker-container' onChange={this.onStartDateChange}>
@ -355,7 +358,15 @@ class AllDemanding extends Component {
</View> </View>
</View> </View>
{/* 行业分类选择 */} {/* 行业分类选择 */}
<InteractionComponent url={URL.GetIndustryTypeList} onPassDataToChild={this.getDataFromChild.bind(this)} selectedValue={this.state.industryTypeSelected}></InteractionComponent> {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-box'>

View File

@ -17,6 +17,9 @@ $themeColor: #FF7142;
.page-section{ .page-section{
border-bottom: 1Px solid #d6e4ef; border-bottom: 1Px solid #d6e4ef;
}
.page-section-picker{
.picker{ .picker{
// padding: 24rpx 0; // padding: 24rpx 0;
.selected{ .selected{
@ -30,7 +33,7 @@ $themeColor: #FF7142;
font-size: 32rpx font-size: 32rpx
} }
.title-box{ .title-box{
.title{ .title{
//color: #333; //color: #333;
margin-right:16rpx; margin-right:16rpx;
width:172rpx; width:172rpx;
@ -39,7 +42,7 @@ $themeColor: #FF7142;
// vertical-align:middle; // vertical-align:middle;
text-align:left; text-align:left;
font-weight: bold; font-weight: bold;
} }
} }
} }
} }

View File

@ -28,7 +28,6 @@ class GoodsPublish extends Component {
constructor() { constructor() {
super(...arguments) super(...arguments)
this.state = { this.state = {
shopTypeSelected: { name: '选择店铺类型', id: '' },//已选的店铺分类 shopTypeSelected: { name: '选择店铺类型', id: '' },//已选的店铺分类
goodsTypeSelected: { name: '选择商品分类', id: '' },// 已选的商品分类 goodsTypeSelected: { name: '选择商品分类', id: '' },// 已选的商品分类
productName: '', productName: '',

View File

@ -147,13 +147,11 @@ class Home extends Component {
) )
} }
getUserLocation() { getUserLocation() {
if (process.env.TARO_ENV === 'alipay') { if (process.env.TARO_ENV === 'alipay') {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
my.getLocation({ my.getLocation({
success(res) { success(res) {
my.hideLoading(); my.hideLoading();
resolve(res) resolve(res)
}, },
fail(res) { fail(res) {
@ -164,9 +162,6 @@ class Home extends Component {
}) })
}) })
} else if (process.env.TARO_ENV === 'weapp') { } else if (process.env.TARO_ENV === 'weapp') {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
Taro.getLocation({ Taro.getLocation({
@ -182,12 +177,8 @@ class Home extends Component {
reject(res) reject(res)
} }
}) })
}) })
} }
} }
@ -312,25 +303,24 @@ class Home extends Component {
componentDidMount() { componentDidMount() {
// // 页面加载后 得到首页的基本信息和推荐店铺的信息 // 页面加载后 得到首页的基本信息和推荐店铺的信息
// showLoading({ title: '加载中' }) showLoading({ title: '加载中' })
// // promise 返回经纬度给state 然后调用函数 // promise 返回经纬度给state 然后调用函数
// this.getUserLocation().then(res => {
// this.setState({
// latitude: res.latitude,
// longitude: res.longitude
// }, () => {
// this.getShops({})
// this.getHomeCategoriesInfo()
// })
// }).catch(err => {
// this.getShops({})
// this.getHomeCategoriesInfo()
// })
this.getShops({}) this.getShops({})
this.getHomeCategoriesInfo() this.getHomeCategoriesInfo()
// 本地缓存没有userid时 从新登入
Taro.getStorageSync('userInfo').user_id ? true : weChatLogin() 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() { componentWillMount() {

View File

@ -32,9 +32,11 @@ class Login extends Component {
loginHandler() { loginHandler() {
if (this.state.username && this.state.password) { if (this.state.username && this.state.password) {
standardLogin(this.state.username, this.state.password).then(res => { standardLogin(this.state.username, this.state.password).then(res => {
setTimeout(() => {
Taro.reLaunch({ Taro.reLaunch({
url: '/pages/home/home' url: '/pages/home/home'
}) })
}, 1000);
}).catch(res => { }).catch(res => {
Taro.showToast({ Taro.showToast({
title: res.data.msg, title: res.data.msg,
@ -65,7 +67,7 @@ class Login extends Component {
} }
componentWillReceiveProps(nextProps) { componentWillReceiveProps(nextProps) {
console.log(this.props, nextProps) // console.log(this.props, nextProps)
} }
componentWillUnmount() { } componentWillUnmount() { }

View File

@ -311,7 +311,8 @@ class MyGoodList extends Component {
'X-Requested-With': 'XMLHttpRequest' 'X-Requested-With': 'XMLHttpRequest'
} }
}).then(res => { }).then(res => {
let responseData = JSON.parse(res.data) console.log('res',res)
let responseData = platformChecker()? JSON.parse(res.data):res.data
Taro.hideLoading() Taro.hideLoading()
if (responseData.err_code === 0) { if (responseData.err_code === 0) {
Taro.showToast({ Taro.showToast({

View File

@ -479,8 +479,6 @@ class MySupplyDemand extends Component {
<CopyrightComponent></CopyrightComponent> <CopyrightComponent></CopyrightComponent>
</View> </View>
<MovableView className='movable-point' x={this.state.screenWidth} y={this.state.screenHeight} style='opacity:0.3' direction='all' > <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> <View className='movable-point' onClick={this.goToCenterPage.bind(this)}> 个人中心</View>

View File

@ -3,7 +3,7 @@ import { View, Button, Text, Image, Map } from '@tarojs/components'
import { AtTag, AtIcon, } from 'taro-ui' import { AtTag, AtIcon, } from 'taro-ui'
import URL from '../../serviceAPI.config' import URL from '../../serviceAPI.config'
import AliShopTypeInteraction from '../../component/AliShopTypeInteraction/AliShopTypeInteraction'
import ShopTypeInteractionComp from '../../component/shopTypeInteractionComp/shopTypeInteractionComp' import ShopTypeInteractionComp from '../../component/shopTypeInteractionComp/shopTypeInteractionComp'
import ScrollToTopComponent from '../../component/scrollToTopComponent/scrollToTopComponent' import ScrollToTopComponent from '../../component/scrollToTopComponent/scrollToTopComponent'
@ -14,7 +14,7 @@ import CopyrightComponent from '../../component/copyrightComponent/copyrightComp
import onClickValueService from '../../util/onClickValueService'; import onClickValueService from '../../util/onClickValueService';
import { getGlobalStorage } from '../../util/getSetStoage'; import { getGlobalStorage } from '../../util/getSetStoage';
import { showLoading } from '../../util/hideShowLoading'; import { showLoading } from '../../util/hideShowLoading';
import platformChecker from '../../util/plaformChecker';
const locationIcon = require('../../assets/img/location.png') const locationIcon = require('../../assets/img/location.png')
class Shop extends Component { class Shop extends Component {
@ -809,12 +809,19 @@ class Shop extends Component {
<View className='nav'> <View className='nav'>
<View className='shop-cate'> <View className='shop-cate'>
<View className='interaction'> <View className='interaction'>
<ShopTypeInteractionComp {platformChecker() ? <ShopTypeInteractionComp
url={URL.GetShopCategoryList} url={URL.GetShopCategoryList}
shopId={this.state.shop_id} shopId={this.state.shop_id}
onPassDataToChild={this.getDataFromShopChild.bind(this)} onPassDataToChild={this.getDataFromShopChild.bind(this)}
></ShopTypeInteractionComp> ></ShopTypeInteractionComp> : <AliShopTypeInteraction url={URL.GetShopCategoryList}
shopId={getGlobalStorage('shopInfo') ? getGlobalStorage('shopInfo').shop_id : ''}
// selectedValue={this.state.shopTypeSelected}
onPassDataToChild={this.getDataFromShopChild.bind(this)}
></AliShopTypeInteraction>}
</View> </View>
<View > <View >
<Text className='text'> <Text className='text'>
店铺全部分类 店铺全部分类

View File

@ -60,6 +60,7 @@ $themeColor:#FF7142;
.interaction{ .interaction{
position: absolute; position: absolute;
opacity: 0; opacity: 0;
} }
} }
.homepage-link{ .homepage-link{

View File

@ -11,6 +11,7 @@ const setUserInfoToStorage = () => {
} }
}) })
.then(res => { .then(res => {
if (res.data.err_msg === 'success') { if (res.data.err_msg === 'success') {
setGlobalStorage('user_identity', { username: res.data.otherData.userName, userphone: res.data.otherData.userPhone }) setGlobalStorage('user_identity', { username: res.data.otherData.userName, userphone: res.data.otherData.userPhone })
@ -24,7 +25,7 @@ const setUserInfoToStorage = () => {
}) })
} }
export default function standardLogin(username, password) { export default function standardLogin(username, password) {
return new Promise((resolve,reject)=>{ return new Promise((resolve, reject) => {
Taro.request({ Taro.request({
url: URL.StandardLogin, url: URL.StandardLogin,
method: 'POST', method: 'POST',
@ -39,14 +40,13 @@ export default function standardLogin(username, password) {
} }
}) })
.then(res => { .then(res => {
console.log('普通登录',res) console.log('普通登录', res)
if (res.data.err_code === 0) { if (res.data.err_code === 0) {
Taro.showToast({ Taro.showToast({
title: '登入成功', title: '登入成功',
icon: 'success', icon: 'success',
duration: 1000 duration: 1000
}) })
setGlobalStorage('session_id', res.data.session_id) setGlobalStorage('session_id', res.data.session_id)
setGlobalStorage('shopInfo', res.data.shop_info) setGlobalStorage('shopInfo', res.data.shop_info)
setGlobalStorage('userInfo', res.data.user_info) setGlobalStorage('userInfo', res.data.user_info)
@ -54,7 +54,6 @@ export default function standardLogin(username, password) {
setUserInfoToStorage() setUserInfoToStorage()
resolve('success') resolve('success')
} else { } else {
reject(res) reject(res)
} }
}) })

View File

@ -1,6 +1,7 @@
import Taro from '@tarojs/taro' import Taro from '@tarojs/taro'
import URL from '../serviceAPI.config' import URL from '../serviceAPI.config'
import { getGlobalStorage } from './getSetStoage'; import { getGlobalStorage } from './getSetStoage';
import platformChecker from './plaformChecker'
//用户信息姓名和电话号码接口 //用户信息姓名和电话号码接口
const setUserInfoToStorage = () => { const setUserInfoToStorage = () => {
@ -28,12 +29,13 @@ const setUserInfoToStorage = () => {
// 异步函数登入api // 异步函数登入api
export default function wechatLogin() { export default function wechatLogin() {
return new Promise((resolve,reject)=>{ //微信登录的时候查看小程序端是什么平台
if (platformChecker()) {
return new Promise((resolve, reject) => {
Taro.login({ Taro.login({
success(res) { success(res) {
if (res.code) { if (res.code) {
// 发起网络请求 // 发起网络请求
console.log('手机端微信code', res.code)
Taro.request({ Taro.request({
url: URL.Login, url: URL.Login,
method: 'POST', method: 'POST',
@ -65,17 +67,23 @@ export default function wechatLogin() {
duration: 2000 duration: 2000
}) })
reject('微信登入失败') reject('微信登入失败')
// Taro.clearStorageSync()
} }
} }
) )
} }
else { else {
console.log('登录失败!' + res.errMsg) console.log('微信登录失败!' + res.errMsg)
} }
} }
}) })
}) })
}else{
return new Promise((resolve, reject)=>{
resolve()
})
}
} }