支付宝测试

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)
}
invokeAliPicker() {
console.log('clicked')
this.setState({
AliIsShowPicker:true
})

View File

@ -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)
// }
// }

View File

@ -1,9 +1,10 @@
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 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,6 +14,7 @@ import './allDemanding.scss'
import eyeIcon from '../../icons/eye.png'
import { getGlobalStorage } from '../../util/getSetStoage';
import { showLoading } from '../../util/hideShowLoading';
import platformChecker from '../../util/plaformChecker';
@ -208,7 +210,7 @@ class AllDemanding extends Component {
goToGrabOrderPage(e) {
const id = onClickValueService(e)
let orderId=encodeURIComponent(id)
let orderId = encodeURIComponent(id)
Taro.navigateTo({
url: '/pages/grabOrderPage/grabOrderPage?orderId=' + orderId
})
@ -327,10 +329,11 @@ class AllDemanding extends Component {
placeholder='需求标题'
value={this.state.title}
onChange={this.titleChange.bind(this)}
border={false}
/>
</View>
{/* 开始和结束日期选择 */}
<View className='page-section'>
<View className='page-section-picker'>
<View className='picker-box'>
<View className='picker-wrapper'>
<Picker mode='date' className='picker-container' onChange={this.onStartDateChange}>
@ -355,7 +358,15 @@ class AllDemanding extends Component {
</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 File

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

View File

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

View File

@ -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() {

View File

@ -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 => {
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() { }

View File

@ -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({

View File

@ -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>

View File

@ -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,7 +14,7 @@ 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 {
@ -809,12 +809,19 @@ class Shop extends Component {
<View className='nav'>
<View className='shop-cate'>
<View className='interaction'>
<ShopTypeInteractionComp
{platformChecker() ? <ShopTypeInteractionComp
url={URL.GetShopCategoryList}
shopId={this.state.shop_id}
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 >
<Text className='text'>
店铺全部分类

View File

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

View File

@ -11,6 +11,7 @@ const setUserInfoToStorage = () => {
}
})
.then(res => {
if (res.data.err_msg === 'success') {
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) {
return new Promise((resolve,reject)=>{
return new Promise((resolve, reject) => {
Taro.request({
url: URL.StandardLogin,
method: 'POST',
@ -39,14 +40,13 @@ export default function standardLogin(username, password) {
}
})
.then(res => {
console.log('普通登录',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)
@ -54,7 +54,6 @@ export default function standardLogin(username, password) {
setUserInfoToStorage()
resolve('success')
} else {
reject(res)
}
})

View File

@ -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,12 +29,13 @@ const setUserInfoToStorage = () => {
// 异步函数登入api
export default function wechatLogin() {
return new Promise((resolve,reject)=>{
//微信登录的时候查看小程序端是什么平台
if (platformChecker()) {
return new Promise((resolve, reject) => {
Taro.login({
success(res) {
if (res.code) {
// 发起网络请求
console.log('手机端微信code', res.code)
Taro.request({
url: URL.Login,
method: 'POST',
@ -65,17 +67,23 @@ export default function wechatLogin() {
duration: 2000
})
reject('微信登入失败')
// Taro.clearStorageSync()
}
}
)
}
else {
console.log('登录失败!' + res.errMsg)
console.log('微信登录失败!' + res.errMsg)
}
}
})
})
}else{
return new Promise((resolve, reject)=>{
resolve()
})
}
}