mirror of
https://gitee.com/ShopeX/ECShopX_mobile-frontend
synced 2026-08-14 17:41:45 +08:00
no message
This commit is contained in:
BIN
src/assets/imgs/404.png
Normal file
BIN
src/assets/imgs/404.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 27 KiB |
BIN
src/assets/imgs/500.png
Normal file
BIN
src/assets/imgs/500.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 28 KiB |
BIN
src/assets/imgs/cart_empty.png
Normal file
BIN
src/assets/imgs/cart_empty.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 21 KiB |
BIN
src/assets/imgs/plane.png
Normal file
BIN
src/assets/imgs/plane.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 24 KiB |
@@ -1,7 +1,7 @@
|
|||||||
import Taro, { Component } from '@tarojs/taro'
|
import Taro, { Component } from '@tarojs/taro'
|
||||||
import { View, Text, ScrollView } from '@tarojs/components'
|
import { View, Text, ScrollView } from '@tarojs/components'
|
||||||
import { AtInputNumber, AtButton } from 'taro-ui'
|
import { AtInputNumber, AtButton } from 'taro-ui'
|
||||||
import { GoodsItem, SpCheckbox, Address, Loading, Price } from '@/components'
|
import { GoodsItem, SpCheckbox, SpNote, Address, Loading, Price } from '@/components'
|
||||||
import { log } from '@/utils'
|
import { log } from '@/utils'
|
||||||
import api from '@/api'
|
import api from '@/api'
|
||||||
|
|
||||||
@@ -51,13 +51,19 @@ export default class CartIndex extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount () {
|
componentDidMount () {
|
||||||
|
}
|
||||||
|
|
||||||
|
componentDidShow () {
|
||||||
this.fetch()
|
this.fetch()
|
||||||
}
|
}
|
||||||
|
|
||||||
async fetch () {
|
async fetch () {
|
||||||
const { cartlist } = await api.cart.get()
|
const { cartlist } = await api.cart.get()
|
||||||
const list = resolveCartItems(cartlist)
|
// const list = resolveCartItems(cartlist)
|
||||||
const items = normalizeItems(list)
|
// const items = normalizeItems(list)
|
||||||
|
|
||||||
|
const list = []
|
||||||
|
const items = []
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
list,
|
list,
|
||||||
@@ -120,6 +126,7 @@ export default class CartIndex extends Component {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: 对接api
|
||||||
render () {
|
render () {
|
||||||
const { list, selection, totalPrice, cartMode } = this.state
|
const { list, selection, totalPrice, cartMode } = this.state
|
||||||
|
|
||||||
@@ -127,9 +134,9 @@ export default class CartIndex extends Component {
|
|||||||
return <Loading />
|
return <Loading />
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: redux 计算
|
|
||||||
const totalSelection = selection.size
|
const totalSelection = selection.size
|
||||||
const totalItems = totalSelection
|
const totalItems = totalSelection
|
||||||
|
const isEmpty = !list.length
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View className='page-cart-index'>
|
<View className='page-cart-index'>
|
||||||
@@ -137,12 +144,16 @@ export default class CartIndex extends Component {
|
|||||||
className='cart-list__wrap'
|
className='cart-list__wrap'
|
||||||
scrollY
|
scrollY
|
||||||
>
|
>
|
||||||
<View className='cart-list__actions'>
|
{
|
||||||
<Text
|
!isEmpty && (
|
||||||
clasName='btn-cart-mode'
|
<View className='cart-list__actions'>
|
||||||
onClick={this.toggleCartMode}
|
<Text
|
||||||
>{cartMode === 'edit' ? '完成' : '编辑'}</Text>
|
clasName='btn-cart-mode'
|
||||||
</View>
|
onClick={this.toggleCartMode}
|
||||||
|
>{cartMode === 'edit' ? '完成' : '编辑'}</Text>
|
||||||
|
</View>
|
||||||
|
)
|
||||||
|
}
|
||||||
<View className='cart-list'>
|
<View className='cart-list'>
|
||||||
{
|
{
|
||||||
list.map(shopCart =>
|
list.map(shopCart =>
|
||||||
@@ -187,10 +198,24 @@ export default class CartIndex extends Component {
|
|||||||
</View>
|
</View>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
!list.length && (
|
||||||
|
<View>
|
||||||
|
<SpNote customStyle={'margin-bottom: 20px'} img='cart_empty.png'>快去给我挑点宝贝吧~</SpNote>
|
||||||
|
<AtButton
|
||||||
|
circle
|
||||||
|
type='primary'
|
||||||
|
onClick={() => Taro.navigateTo({ url: '/pages/items/list' })}
|
||||||
|
>随便逛逛</AtButton>
|
||||||
|
</View>
|
||||||
|
)
|
||||||
|
}
|
||||||
</View>
|
</View>
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
|
|
||||||
<View className='toolbar cart-toolbar'>
|
<View
|
||||||
|
className={`toolbar cart-toolbar ${isEmpty && 'hidden'}`}
|
||||||
|
>
|
||||||
<View className='cart-toolbar__hd'>
|
<View className='cart-toolbar__hd'>
|
||||||
<SpCheckbox
|
<SpCheckbox
|
||||||
checked={this.isTotalChecked}
|
checked={this.isTotalChecked}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ export default class Index extends Component {
|
|||||||
componentWillMount () {
|
componentWillMount () {
|
||||||
if (process.env.NODE_ENV === 'development') {
|
if (process.env.NODE_ENV === 'development') {
|
||||||
Taro.redirectTo({
|
Taro.redirectTo({
|
||||||
url: '/pages/member/index'
|
url: '/pages/cart/index'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user