Merge branch 'pinjinjin' of git.ishopex.cn:onex/espier-taro-fenxiao into pinjinjin

* 'pinjinjin' of git.ishopex.cn:onex/espier-taro-fenxiao:
  地址列表
  地址修改

# Conflicts:
#	src/pages/index/index.js
This commit is contained in:
bentz
2019-03-08 21:45:22 +08:00
12 changed files with 339 additions and 43 deletions

View File

@@ -13,15 +13,19 @@ export function addressList () {
}
export function addressCreate (params = {}) {
return req.post('http://pjj.aixue7.com/index.php/api/h5app/wxapp/member/setAddress', params)
return req.post('http://pjj.aixue7.com/index.php/api/h5app/wxapp/member/address', params)
}
export function addressUpdate (data) {
return req.post('/member.address.update', data)
return req.put(`http://pjj.aixue7.com/index.php/api/h5app/wxapp/member/address/${data.address_id}`,data)
}
export function addressDelete (address_id) {
return req.post('http://pjj.aixue7.com/index.php/api/h5app/wxapp/member/delAddress', { address_id })
return req.delete(`http://pjj.aixue7.com/index.php/api/h5app/wxapp/member/address/${address_id}`)
}
export function areaList () {
return req.get('http://pjj.aixue7.com/index.php/api/h5app/wxapp/member/addressarea')
}
export function addressCreateOrUpdate (data) {

View File

@@ -35,6 +35,7 @@ class App extends Component {
'pages/auth/forgotpwd',
'pages/cashier/index',
'pages/cashier/cashier-result',
'pages/member/index',
'pages/member/favorite',

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

View File

@@ -1,8 +1,9 @@
import Taro, { Component } from '@tarojs/taro'
import { View, Switch } from '@tarojs/components'
import {View, Switch, Text, Picker} from '@tarojs/components'
import { AtForm, AtInput, AtButton } from 'taro-ui'
import { SpCell } from '@/components'
import api from '@/api'
import { pickBy } from '@/utils'
import S from '@/spx'
import './edit.scss'
@@ -16,10 +17,53 @@ export default class AddressEdit extends Component {
super(props)
this.state = {
info: { ...this.props.value }
info: { ...this.props.value },
list: [],
areaList: [],
multiIndex: [],
}
}
componentDidMount () {
this.fetch()
}
async fetch () {
let res = await api.member.areaList()
const nList = pickBy(res, {
label: 'label',
children: 'children',
})
let arr_label = []
let s_arr_label = []
let th_arr_label = []
let arr = []
let s_arr = []
let th_arr = []
let all_arr =[]
res.map(item => {
arr_label.push(item.label)
arr.push({label:item.label,children:item.children})
})
arr[0].children.map(item => {
s_arr_label.push(item.label)
s_arr.push({label:item.label,children:item.children})
})
s_arr[0].children.map(item => {
th_arr_label.push(item.label)
th_arr.push({label:item.label,children:item.children})
})
all_arr[0] = arr_label
all_arr[1] = s_arr_label
all_arr[2] = th_arr_label
this.setState({
areaList: all_arr,
list: nList,
multiIndex: [0, 0, 0]
})
console.log(all_arr, arr, s_arr, th_arr, 31)
}
componentWillReceiveProps (nextProps) {
if (nextProps.value !== this.state.info) {
this.setState({
@@ -28,16 +72,91 @@ export default class AddressEdit extends Component {
}
}
// 选定开户地区
bindMultiPickerChange = async (e) => {
console.log('picker发送选择改变携带值为', e.detail.value)
const { list, info } = this.state
list.map((item, index) => {
if(index === e.detail.value[0]) {
info.province = item.label
item.children.map((s_item,sIndex) => {
if(sIndex === e.detail.value[1]) {
info.city = s_item.label
s_item.children.map((th_item,thIndex) => {
if(thIndex === e.detail.value[2]) {
info.county = th_item.label
}
})
}
})
}
})
this.setState({
info
})
}
bindMultiPickerColumnChange = async (e) => {
const { list, areaList, multiIndex } = this.state
console.log('修改的列为', e.detail.column, ',值为', e.detail.value)
if(e.detail.column === 0) {
this.setState({
multiIndex: [e.detail.value, 0, 0]
})
list.map(item=> {
if (item.label === areaList[0][e.detail.value]) {
let s_arr = []
let th_arr = []
item.children.map((s_item, s_index) => {
s_arr.push(s_item.label)
if(s_index === 0) {
s_item.children.map(th_item => {
th_arr.push(th_item.label)
})
}
})
areaList[1] = s_arr
areaList[2] = th_arr
this.setState({areaList})
}
})
}else if (e.detail.column === 1) {
let indexSarr = multiIndex
indexSarr[1] = e.detail.value
this.setState({
multiIndex: indexSarr
})
console.log(multiIndex, list[multiIndex[0]])
let th_arr = []
list[multiIndex[0]].children.map(item => {
if (item.label === areaList[1][e.detail.value]) {
item.children.map(th_item => {
th_arr.push(th_item.label)
})
}
})
areaList[2] = th_arr
this.setState({areaList})
}else {
let indexTharr = multiIndex
indexTharr[2] = e.detail.value
this.setState({
multiIndex: indexTharr
})
}
}
handleSubmit = async (e) => {
const { value } = e.detail
const data = {
...this.state.info,
provinceName: '天津市',
cityName: '市辖区',
countyName: '和平区',
...value
}
if (!data.is_def) {
data.is_def = 0
}
if (!data.username) {
return S.toast('请输入收件人')
}
@@ -46,17 +165,15 @@ export default class AddressEdit extends Component {
return S.toast('请输入正确的手机号')
}
// if (!data.area) {
// return S.toast('请选择所在区域')
// }
if (!data.detailInfo) {
return S.toast('请输入详细地址')
if (!data.area) {
return S.toast('请选择所在区域')
}
let res = await api.member.addressCreate(data)
console.log(res, 57)
if (!data.adrdetail) {
return S.toast('请输入详细地址')
}
// console.log(data, 182)
// return false
this.props.onChange && this.props.onChange(data)
this.props.onClose && this.props.onClose()
}
@@ -70,7 +187,7 @@ export default class AddressEdit extends Component {
handleDefChange = (val) => {
const info = {
...this.state.info,
def_addr: val ? 1 : 0
is_def: val ? 1 : 0
}
this.setState({
@@ -81,9 +198,12 @@ export default class AddressEdit extends Component {
handleDelete = () => {
this.props.onDelete(this.state.info)
}
handleBlur = e => {
console.log(e)
}
render () {
const { info } = this.state
const { info, areaList, multiIndex } = this.state
if (!info) {
return null
}
@@ -99,6 +219,7 @@ export default class AddressEdit extends Component {
name='username'
value={info.username}
onChange={this.handleChange.bind(this, 'username')}
onBlur={this.handleBlur.bind(this)}
/>
<AtInput
title='手机号码'
@@ -107,17 +228,33 @@ export default class AddressEdit extends Component {
value={info.telephone}
onChange={this.handleChange.bind(this, 'telephone')}
/>
<Picker
mode='multiSelector'
onChange={this.bindMultiPickerChange}
onColumnchange={this.bindMultiPickerColumnChange}
value={multiIndex}
range={areaList}
>
<View className='picker'>
<View className='picker__title'>所在区域</View>
<Text>{areaList[0][multiIndex[0]]}{areaList[1][multiIndex[1]]}{areaList[2][multiIndex[2]]}</Text>
{/*<Text*/}
{/*className={classNames(item.value ? 'pick-value' : 'pick-value-null')}*/}
{/*>{item.value ? item.value : `请选择${item.name}`}</Text>*/}
</View>
</Picker>
{/*<AtInput*/}
{/*title='所在区域'*/}
{/*name='area'*/}
{/*value={info.area}*/}
{/*onChange={this.handleChange.bind(this, 'area')}*/}
{/*/>*/}
<AtInput
title='详细地址'
name='detailInfo'
value={info.detailInfo}
onChange={this.handleChange.bind(this, 'detailInfo')}
name='adrdetail'
value={info.adrdetail}
onChange={this.handleChange.bind(this, 'adrdetail')}
/>
<AtInput
title='邮政编码'
@@ -132,7 +269,7 @@ export default class AddressEdit extends Component {
title='设为默认地址'
>
<Switch
checked={info.def_addr}
checked={info.is_def}
onChange={this.handleDefChange}
/>
</SpCell>

View File

@@ -6,4 +6,25 @@
padding: $edge-size;
margin: 0 0 $edge-margin;
}
.picker {
padding: 16px 0;
margin: 0 0 $edge-size;
display: flex;
justify-content: flex-start;
border-bottom: 1PX solid rgba($color-brand-primary, 0.2);
&__title {
font-size: $font-size;
margin-right:16px;
width:172px;
}
.pick-value {
color: #333;
}
span.pick-value-null {
color: #ccc;
}
text.pick-value-null {
color: #808080;
}
}
}

View File

@@ -1,7 +1,7 @@
import Taro, { Component } from '@tarojs/taro'
import { View, Text } from '@tarojs/components'
import { AtNavBar } from 'taro-ui'
import { SpCell, SpToast, Note } from '@/components'
import { SpCell, SpToast, SpNote } from '@/components'
import { classNames, log } from '@/utils'
import api from '@/api'
import find from 'lodash/find'
@@ -48,9 +48,9 @@ export default class AddressPicker extends Component {
}
changeSelection (params = {}) {
const { addr_id } = params
const { address_id } = params
const { list } = this.state
const address = find(list, addr => addr_id ? addr_id === addr.address_id : addr.def_addr > 0) || list[0] || null
const address = find(list, addr => address_id ? address_id === addr.address_id : addr.def_addr > 0) || list[0] || null
log.debug('[address picker] change selection: ', address)
this.props.onChange(address)
@@ -174,7 +174,7 @@ export default class AddressPicker extends Component {
<Text className='address-item__receiver'>
<Text className='address-item__name'>{item.username}</Text>
<Text className='address-item__mobile'>{item.telephone}</Text>
<Text className='address-item__addr'>{item.area}</Text>
<Text className='address-item__addr'>{item.province}{item.city}{item.county}{item.adrdetail}</Text>
</Text>
<Text
className='address-item__ft'

View File

@@ -54,18 +54,6 @@ export default class Login extends Component {
Taro.redirectTo({
url: urlBack
})
// if (Taro.getCurrentPages().length > 1) {
// Taro.navigateBack({
// delta: 1
// });
// } else {
// Taro.redirectTo({
// url: "/pages/home/index"
// })
// }
// Taro.navigateBack()
// let currentPages = Taro.getCurrentPages()
// Taro.navigateBack({ delta: Taro.getCurrentPages().length - 1 })
})
}
@@ -130,7 +118,7 @@ export default class Login extends Component {
</View>
<View className='btns'>
<AtButton type='primary' onClick={this.handleSubmit} formType='submit'>登录</AtButton>
<AtButton type='primary' formType='submit'>登录</AtButton>
</View>
</AtForm>
<SpToast />

View File

@@ -261,7 +261,7 @@ export default class Reg extends Component {
}
</View>
<View className='btns'>
<AtButton type='primary' onClick={this.handleSubmit} formType='submit'>同意协议并注册</AtButton>
<AtButton type='primary' formType='submit'>同意协议并注册</AtButton>
<View className='accountAgreement'>
已阅读并同意
<Text

View File

@@ -108,10 +108,10 @@ export default class CartCheckout extends Component {
address
? <View className='address-info__bd'>
<Text className='address-info__receiver'>
收货人{address.name} {address.mobile}
收货人{address.name} {address.telephone}
</Text>
<Text className='address-info__addr'>
收货地址{address.addrdetail}
收货地址{address.province}{address.city}{address.county}{address.adrdetail}
</Text>
</View>
: <View className='address-info__bd'>请选择收货地址</View>

View File

@@ -0,0 +1,63 @@
import Taro, { Component } from '@tarojs/taro'
import {Button, Image, Text, View} from '@tarojs/components'
import {AtBadge, AtButton} from 'taro-ui'
import api from '@/api'
import './cashier-result.scss'
export default class CashierResult extends Component {
constructor (props) {
super(props)
this.state = {
}
}
render () {
// const { list, pluralType, imgType, currentIndex } = this.state
return (
<View className='page-cashier-index'>
<View className='cashier-content'>
<View className='cashier-result'>
<View className='cashier-result__img'>
<Image
className='note__img'
mode='aspectFill'
src='/assets/imgs/pay_fail.png'
/>
</View>
<View className='cashier-result__info'>
{/*<View className='cashier-result__info-title'>订单支付成功</View>*/}
<View className='cashier-result__info-title'>订单支付失败</View>
<View className='cashier-result__info-news'>订单号B2C123102831</View>
<View className='cashier-result__info-news'>创建时间2016-06-16 16:54:09</View>
<View className='cashier-result__info-news'>支付时间2016-06-16 16:54:09</View>
</View>
</View>
</View>
<View className='goods-buy-toolbar'>
{/*<View className='goods-buy-toolbar__btns'>*/}
{/*<Button*/}
{/*className='goods-buy-toolbar__btn btn-add-cart'*/}
{/*// onClick={onClickAddCart}*/}
{/*>继续购物</Button>*/}
{/*<Button*/}
{/*className='goods-buy-toolbar__btn btn-fast-buy'*/}
{/*// onClick={onClickFastBuy}*/}
{/*>订单详情</Button>*/}
{/*</View>*/}
<View className='goods-buy-toolbar__btns'>
<Button
className='goods-buy-toolbar__btn btn-fast-buy'
// onClick={onClickFastBuy}
>返回订单详情</Button>
</View>
</View>
</View>
)
}
}

View File

@@ -0,0 +1,82 @@
@import "../../style/imports";
.page-cashier-index {
height: 100%;
.cashier-content {
padding: 50px $edge-size;
border-top: 1px solid $color-border-gray-dark;
background: $color-brand-primary-text;
.cashier-result {
border: 1PX solid #DDDDDD;
background: #F9F9F9;
padding: 20px 30px;
box-sizing: border-box;
display: flex;
justify-content: space-between;
align-items: center;
}
}
.goods-buy-toolbar {
background: #fff;
height: $toolbar-height;
box-sizing: border-box;
padding: $edge-margin $edge-size;
position: fixed;
bottom: 0;
width: 100%;
z-index: $z-index-toolbar;
display: flex;
align-items: center;
box-shadow: 0 0 -5px rgba(#000, 0.3);
&__btns {
width: 100%;
display: flex;
align-items: center;
border-radius: 52px;
overflow: hidden;
box-shadow: 0 5px 5px rgba(darken($color-brand-primary, 20%), 0.2);
}
&__btn {
background: $color-brand-primary;
font-size: $font-size;
flex: 1;
height: 80px;
line-height: 80px;
text-align: center;
color: #fff;
border: none;
border-radius: 0;
font-weight: bold;
&:before, &:after {
display: none;
}
}
.btn-add-cart {
background: linear-gradient(90deg, #FFBE1C, #FA7815);
}
.btn-fast-buy {
background: linear-gradient(90deg, $color-brand-primary, $color-brand-primary);
}
}
}
.cashier-result {
&__img {
flex: 1;
text-align: center;
image {
width: 132px;
height: 100px;
}
}
&__info {
color: #000000;
font-size: 28px;
&-title {
font-size: 40px;
color: $color-brand-primary;
margin-bottom: 18px;
}
}
}