|
@@ -4,7 +4,6 @@ import styles from './index.module.less'
|
|
|
import { Checkbox, SubmitBar, Card, Stepper, CheckboxGroup } from 'vant'
|
|
|
import request from '@/helpers/request'
|
|
|
import { cartConfirm } from './cart'
|
|
|
-import item from '@/teacher/music/list/item'
|
|
|
import ColResult from '@/components/col-result'
|
|
|
import { moneyFormat } from '@/helpers/utils'
|
|
|
|
|
@@ -12,6 +11,7 @@ export default defineComponent({
|
|
|
name: 'cart',
|
|
|
data() {
|
|
|
return {
|
|
|
+ dataShow: false,
|
|
|
isManage: false,
|
|
|
cartList: [],
|
|
|
selectItems: []
|
|
@@ -48,6 +48,7 @@ export default defineComponent({
|
|
|
let { code, data } = await request.get('/api-mall-portal/cart/list')
|
|
|
code === 200 && (this.cartList = data)
|
|
|
} catch (err) {}
|
|
|
+ this.dataShow = true
|
|
|
},
|
|
|
setCheckAll() {
|
|
|
const selectItems = [] as any
|
|
@@ -67,7 +68,9 @@ export default defineComponent({
|
|
|
params: {
|
|
|
id: item.id,
|
|
|
quantity: item.quantity
|
|
|
- }
|
|
|
+ },
|
|
|
+
|
|
|
+ hideLoading: true
|
|
|
}
|
|
|
)
|
|
|
} catch (err) {}
|
|
@@ -128,93 +131,96 @@ export default defineComponent({
|
|
|
render() {
|
|
|
return (
|
|
|
<>
|
|
|
- {!this.cartList.length ? (
|
|
|
- <ColResult
|
|
|
- tips="购物车空空如也"
|
|
|
- buttonText="去商城逛逛"
|
|
|
- onClick={() => this.gotoShopMall()}
|
|
|
- ></ColResult>
|
|
|
- ) : (
|
|
|
- <>
|
|
|
- <ColHeader
|
|
|
- onClickRight={() => (this.isManage = !this.isManage)}
|
|
|
- v-slots={{
|
|
|
- right: () => (
|
|
|
- <span style={{ color: '#333', fontSize: '14px' }}>
|
|
|
- {this.isManage ? '完成' : '管理'}
|
|
|
- </span>
|
|
|
- )
|
|
|
- }}
|
|
|
- ></ColHeader>
|
|
|
- <div class={styles.cartBox}>
|
|
|
- <CheckboxGroup v-model={this.selectItems}>
|
|
|
- {this.cartList.map((item: any) => (
|
|
|
- <div class={styles.cartItem}>
|
|
|
- <Checkbox name={item.id}>
|
|
|
- <Card
|
|
|
- price={moneyFormat(item.price)}
|
|
|
- desc={item.productAttr}
|
|
|
- title={item.productName}
|
|
|
- thumb={item.productPic}
|
|
|
- v-slots={{
|
|
|
- num: () => (
|
|
|
- <Stepper
|
|
|
- v-model={item.quantity}
|
|
|
- onClick={e => {
|
|
|
- e.stopPropagation()
|
|
|
- }}
|
|
|
- onChange={() => this.setCartItem(item)}
|
|
|
- inputWidth="50px"
|
|
|
- buttonSize="24px"
|
|
|
- min={1}
|
|
|
- />
|
|
|
- )
|
|
|
- }}
|
|
|
- ></Card>
|
|
|
- </Checkbox>
|
|
|
- </div>
|
|
|
- ))}
|
|
|
- </CheckboxGroup>
|
|
|
+ {this.dataShow ? (
|
|
|
+ <div>
|
|
|
+ {!this.cartList.length ? (
|
|
|
+ <ColResult
|
|
|
+ tips="购物车空空如也"
|
|
|
+ buttonText="去商城逛逛"
|
|
|
+ onClick={() => this.gotoShopMall()}
|
|
|
+ ></ColResult>
|
|
|
+ ) : (
|
|
|
+ <>
|
|
|
+ <ColHeader
|
|
|
+ onClickRight={() => (this.isManage = !this.isManage)}
|
|
|
+ v-slots={{
|
|
|
+ right: () => (
|
|
|
+ <span style={{ color: '#333', fontSize: '14px' }}>
|
|
|
+ {this.isManage ? '完成' : '管理'}
|
|
|
+ </span>
|
|
|
+ )
|
|
|
+ }}
|
|
|
+ ></ColHeader>
|
|
|
+ <div class={styles.cartBox}>
|
|
|
+ <CheckboxGroup v-model={this.selectItems}>
|
|
|
+ {this.cartList.map((item: any) => (
|
|
|
+ <div class={styles.cartItem}>
|
|
|
+ <Checkbox name={item.id}>
|
|
|
+ <Card
|
|
|
+ price={moneyFormat(item.price)}
|
|
|
+ desc={item.productAttr}
|
|
|
+ title={item.productName}
|
|
|
+ thumb={item.productPic}
|
|
|
+ v-slots={{
|
|
|
+ num: () => (
|
|
|
+ <Stepper
|
|
|
+ v-model={item.quantity}
|
|
|
+ onClick={e => {
|
|
|
+ e.stopPropagation()
|
|
|
+ }}
|
|
|
+ onChange={() => this.setCartItem(item)}
|
|
|
+ inputWidth="50px"
|
|
|
+ buttonSize="24px"
|
|
|
+ min={1}
|
|
|
+ />
|
|
|
+ )
|
|
|
+ }}
|
|
|
+ ></Card>
|
|
|
+ </Checkbox>
|
|
|
+ </div>
|
|
|
+ ))}
|
|
|
+ </CheckboxGroup>
|
|
|
+ <div style={{ height: 'var(--van-submit-bar-height)' }}></div>
|
|
|
|
|
|
- {this.isManage ? (
|
|
|
- <div class={styles.delete}>
|
|
|
- <SubmitBar
|
|
|
- buttonText="删除"
|
|
|
- buttonColor="var(--van-primary)"
|
|
|
- disabled={this.totalPrice === 0}
|
|
|
- onSubmit={() => this.onDeleteCartItem()}
|
|
|
- >
|
|
|
- <Checkbox
|
|
|
- modelValue={this.checkAll}
|
|
|
- onClick={value => this.setCheckAll()}
|
|
|
- >
|
|
|
- 全选
|
|
|
- </Checkbox>
|
|
|
- </SubmitBar>
|
|
|
+ {this.isManage ? (
|
|
|
+ <div class={styles.delete}>
|
|
|
+ <SubmitBar
|
|
|
+ buttonText="删除"
|
|
|
+ buttonColor="var(--van-primary)"
|
|
|
+ disabled={this.totalPrice === 0}
|
|
|
+ onSubmit={() => this.onDeleteCartItem()}
|
|
|
+ >
|
|
|
+ <Checkbox
|
|
|
+ modelValue={this.checkAll}
|
|
|
+ onClick={value => this.setCheckAll()}
|
|
|
+ >
|
|
|
+ 全选
|
|
|
+ </Checkbox>
|
|
|
+ </SubmitBar>
|
|
|
+ </div>
|
|
|
+ ) : (
|
|
|
+ <div class={styles.submit}>
|
|
|
+ <SubmitBar
|
|
|
+ price={this.totalPrice}
|
|
|
+ buttonText={`结算(${this.len})`}
|
|
|
+ buttonColor="var(--van-primary)"
|
|
|
+ disabled={this.totalPrice === 0}
|
|
|
+ onSubmit={() => this.generateConfirmOrder()}
|
|
|
+ >
|
|
|
+ <Checkbox
|
|
|
+ modelValue={this.checkAll}
|
|
|
+ onClick={value => this.setCheckAll()}
|
|
|
+ >
|
|
|
+ 全选
|
|
|
+ </Checkbox>
|
|
|
+ </SubmitBar>
|
|
|
+ </div>
|
|
|
+ )}
|
|
|
</div>
|
|
|
- ) : (
|
|
|
- <div class={styles.submit}>
|
|
|
- <SubmitBar
|
|
|
- price={this.totalPrice}
|
|
|
- buttonText={`结算(${this.len})`}
|
|
|
- buttonColor="var(--van-primary)"
|
|
|
- disabled={this.totalPrice === 0}
|
|
|
- onSubmit={() => this.generateConfirmOrder()}
|
|
|
- >
|
|
|
- <Checkbox
|
|
|
- modelValue={this.checkAll}
|
|
|
- onClick={value => this.setCheckAll()}
|
|
|
- >
|
|
|
- 全选
|
|
|
- </Checkbox>
|
|
|
- </SubmitBar>
|
|
|
- </div>
|
|
|
- )}
|
|
|
- </div>
|
|
|
- </>
|
|
|
- )}
|
|
|
-
|
|
|
- <div style={{ height: 'var(--van-submit-bar-height)' }}></div>
|
|
|
+ </>
|
|
|
+ )}
|
|
|
+ </div>
|
|
|
+ ) : null}
|
|
|
</>
|
|
|
)
|
|
|
}
|