|
@@ -11,7 +11,7 @@ import { addressType, cartConfirm, formateAttr } from '../cart'
|
|
|
import styles from '../index.module.less'
|
|
|
import Address from '../components/address'
|
|
|
import request from '@/helpers/request'
|
|
|
-import { useRouter } from 'vue-router'
|
|
|
+import { useRoute, useRouter } from 'vue-router'
|
|
|
import ColProtocol from '@/components/col-protocol'
|
|
|
import Payment from '@/views/order-detail/payment'
|
|
|
import { state } from '@/state'
|
|
@@ -26,17 +26,38 @@ import {
|
|
|
export default defineComponent({
|
|
|
name: 'cartConfirm',
|
|
|
setup() {
|
|
|
- const list = cartConfirm.cartPromotionItemList
|
|
|
- const calcAmount = cartConfirm.calcAmount
|
|
|
-
|
|
|
+ const loading = ref(true)
|
|
|
+ const route = useRoute()
|
|
|
const address = ref<addressType>()
|
|
|
- if (cartConfirm.memberReceiveAddressList.length) {
|
|
|
- const a =
|
|
|
- cartConfirm.memberReceiveAddressList.find(
|
|
|
- (n: any) => n.defaultStatus
|
|
|
- ) || cartConfirm.memberReceiveAddressList[0]
|
|
|
- if (a) address.value = a
|
|
|
- }
|
|
|
+ onMounted(async () => {
|
|
|
+ loading.value = true
|
|
|
+ if (route.query.cartIds) {
|
|
|
+ try {
|
|
|
+ let { code, data } = await request.post(
|
|
|
+ '/api-mall-portal/order/generateConfirmOrder',
|
|
|
+ {
|
|
|
+ params: {
|
|
|
+ cartIds: route.query.cartIds
|
|
|
+ }
|
|
|
+ }
|
|
|
+ )
|
|
|
+ if (code === 200) {
|
|
|
+ cartConfirm.calcAmount = data.calcAmount
|
|
|
+ cartConfirm.cartPromotionItemList = data.cartPromotionItemList
|
|
|
+ cartConfirm.memberReceiveAddressList = data.memberReceiveAddressList
|
|
|
+ }
|
|
|
+ } catch (error) {}
|
|
|
+ }
|
|
|
+ loading.value = false
|
|
|
+ if (cartConfirm.memberReceiveAddressList.length) {
|
|
|
+ const a =
|
|
|
+ cartConfirm.memberReceiveAddressList.find(
|
|
|
+ (n: any) => n.defaultStatus
|
|
|
+ ) || cartConfirm.memberReceiveAddressList[0]
|
|
|
+ if (a) address.value = a
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
const setAddress = (result: addressType) => {
|
|
|
address.value = result
|
|
|
}
|
|
@@ -83,10 +104,13 @@ export default defineComponent({
|
|
|
const router = useRouter()
|
|
|
//创建订单
|
|
|
const createOrder = async () => {
|
|
|
- const ids = list.reduce((arr, value: any) => {
|
|
|
- arr.push(value.id)
|
|
|
- return arr
|
|
|
- }, [])
|
|
|
+ const ids = cartConfirm.cartPromotionItemList.reduce(
|
|
|
+ (arr, value: any) => {
|
|
|
+ arr.push(value.id)
|
|
|
+ return arr
|
|
|
+ },
|
|
|
+ []
|
|
|
+ )
|
|
|
const body = {
|
|
|
cartIds: ids,
|
|
|
memberReceiveAddressId: address.value?.id
|
|
@@ -121,96 +145,102 @@ export default defineComponent({
|
|
|
}
|
|
|
return () => (
|
|
|
<>
|
|
|
- {list.length ? (
|
|
|
- <div class={styles.cartConfirm}>
|
|
|
- <div class={styles.cartConfirmBox}>
|
|
|
- <Address item={address.value} setAddress={setAddress} />
|
|
|
- </div>
|
|
|
- <div
|
|
|
- style={{ marginTop: '20px' }}
|
|
|
- class={[styles.cartBox, styles.cartConfirmBox]}
|
|
|
- >
|
|
|
- <div class={styles.shopBox}>
|
|
|
- {list.map((item: any) => (
|
|
|
- <div
|
|
|
- class={[styles.cartItem]}
|
|
|
- style={{ marginBottom: '10px' }}
|
|
|
- >
|
|
|
- <Card
|
|
|
- price={moneyFormat(item.price)}
|
|
|
- desc={formateAttr(item.productAttr)}
|
|
|
- title={item.productName}
|
|
|
- thumb={item.productPic}
|
|
|
- num={item.quantity}
|
|
|
- ></Card>
|
|
|
+ {loading.value ? null : (
|
|
|
+ <div>
|
|
|
+ {cartConfirm.cartPromotionItemList.length ? (
|
|
|
+ <div class={styles.cartConfirm}>
|
|
|
+ <div class={styles.cartConfirmBox}>
|
|
|
+ <Address item={address.value} setAddress={setAddress} />
|
|
|
+ </div>
|
|
|
+ <div
|
|
|
+ style={{ marginTop: '20px' }}
|
|
|
+ class={[styles.cartBox, styles.cartConfirmBox]}
|
|
|
+ >
|
|
|
+ <div class={styles.shopBox}>
|
|
|
+ {cartConfirm.cartPromotionItemList.map((item: any) => (
|
|
|
+ <div
|
|
|
+ class={[styles.cartItem]}
|
|
|
+ style={{ marginBottom: '10px' }}
|
|
|
+ >
|
|
|
+ <Card
|
|
|
+ price={moneyFormat(item.price)}
|
|
|
+ desc={formateAttr(item.productAttr)}
|
|
|
+ title={item.productName}
|
|
|
+ thumb={item.productPic}
|
|
|
+ num={item.quantity}
|
|
|
+ ></Card>
|
|
|
+ </div>
|
|
|
+ ))}
|
|
|
</div>
|
|
|
- ))}
|
|
|
- </div>
|
|
|
- <CellGroup border={false}>
|
|
|
- <Cell
|
|
|
- border={false}
|
|
|
- title="总额"
|
|
|
- value={'¥ ' + moneyFormat(calcAmount.totalAmount)}
|
|
|
- ></Cell>
|
|
|
- {/* <Cell
|
|
|
- border={false}
|
|
|
- title="运费"
|
|
|
- value={moneyFormat(calcAmount.freightAmount)}
|
|
|
- ></Cell>
|
|
|
- <Cell
|
|
|
- border={false}
|
|
|
- title="优惠"
|
|
|
- value={'-¥ ' + moneyFormat(calcAmount.promotionAmount)}
|
|
|
- ></Cell> */}
|
|
|
- {/* <Cell border={false} title="优惠卷" value="暂无可用优惠卷"></Cell>
|
|
|
- <Cell border={false} title="乐乐币抵扣" value={"-¥" + calcAmount.promotionAmount}></Cell> */}
|
|
|
- </CellGroup>
|
|
|
- </div>
|
|
|
+ <CellGroup border={false}>
|
|
|
+ <Cell
|
|
|
+ border={false}
|
|
|
+ title="总额"
|
|
|
+ value={
|
|
|
+ '¥ ' + moneyFormat(cartConfirm.calcAmount.totalAmount)
|
|
|
+ }
|
|
|
+ ></Cell>
|
|
|
+ {/* <Cell
|
|
|
+ border={false}
|
|
|
+ title="运费"
|
|
|
+ value={moneyFormat(cartConfirm.calcAmount.freightAmount)}
|
|
|
+ ></Cell>
|
|
|
+ <Cell
|
|
|
+ border={false}
|
|
|
+ title="优惠"
|
|
|
+ value={'-¥ ' + moneyFormat(cartConfirm.calcAmount.promotionAmount)}
|
|
|
+ ></Cell> */}
|
|
|
+ {/* <Cell border={false} title="优惠卷" value="暂无可用优惠卷"></Cell>
|
|
|
+ <Cell border={false} title="乐乐币抵扣" value={"-¥" + cartConfirm.calcAmount.promotionAmount}></Cell> */}
|
|
|
+ </CellGroup>
|
|
|
+ </div>
|
|
|
|
|
|
- <div class={styles.payProtocol}>
|
|
|
- <ColProtocol v-model={agreeStatus.value}></ColProtocol>
|
|
|
- </div>
|
|
|
- <SubmitBar
|
|
|
- buttonText={`结算(${list.length})`}
|
|
|
- buttonColor="var(--van-primary)"
|
|
|
- disabled={list.length === 0}
|
|
|
- onSubmit={() => onSubmit()}
|
|
|
- >
|
|
|
- <div class={styles.confirmBottom}>
|
|
|
- 合计{' '}
|
|
|
- <span class={styles['price-des']}>
|
|
|
- ¥{moneyFormat(calcAmount.payAmount)}
|
|
|
- </span>
|
|
|
+ <div class={styles.payProtocol}>
|
|
|
+ <ColProtocol v-model={agreeStatus.value}></ColProtocol>
|
|
|
+ </div>
|
|
|
+ <SubmitBar
|
|
|
+ buttonText={`结算(${cartConfirm.cartPromotionItemList.length})`}
|
|
|
+ buttonColor="var(--van-primary)"
|
|
|
+ disabled={cartConfirm.cartPromotionItemList.length === 0}
|
|
|
+ onSubmit={() => onSubmit()}
|
|
|
+ >
|
|
|
+ <div class={styles.confirmBottom}>
|
|
|
+ 合计{' '}
|
|
|
+ <span class={styles['price-des']}>
|
|
|
+ ¥{moneyFormat(cartConfirm.calcAmount.payAmount)}
|
|
|
+ </span>
|
|
|
+ </div>
|
|
|
+ </SubmitBar>
|
|
|
+ <div style={{ height: 'var(--van-submit-bar-height)' }}></div>
|
|
|
+ <ColPopup v-model={authPopup.value}>
|
|
|
+ <UserAuth onSuccess={onAuthSuccess} />
|
|
|
+ </ColPopup>
|
|
|
+ <Popup
|
|
|
+ show={paymentPopup.value}
|
|
|
+ closeOnClickOverlay={false}
|
|
|
+ position="bottom"
|
|
|
+ round
|
|
|
+ closeOnPopstate
|
|
|
+ safeAreaInsetBottom
|
|
|
+ style={{ minHeight: '30%' }}
|
|
|
+ >
|
|
|
+ <Payment
|
|
|
+ v-model={paymentPopup.value}
|
|
|
+ orderInfo={orderInfo}
|
|
|
+ paymentType="goodsPay"
|
|
|
+ onBackOut={() => (paymentPopup.value = false)}
|
|
|
+ />
|
|
|
+ </Popup>
|
|
|
</div>
|
|
|
- </SubmitBar>
|
|
|
- <div style={{ height: 'var(--van-submit-bar-height)' }}></div>
|
|
|
- <ColPopup v-model={authPopup.value}>
|
|
|
- <UserAuth onSuccess={onAuthSuccess} />
|
|
|
- </ColPopup>
|
|
|
- <Popup
|
|
|
- show={paymentPopup.value}
|
|
|
- closeOnClickOverlay={false}
|
|
|
- position="bottom"
|
|
|
- round
|
|
|
- closeOnPopstate
|
|
|
- safeAreaInsetBottom
|
|
|
- style={{ minHeight: '30%' }}
|
|
|
- >
|
|
|
- <Payment
|
|
|
- v-model={paymentPopup.value}
|
|
|
- orderInfo={orderInfo}
|
|
|
- paymentType="goodsPay"
|
|
|
- onBackOut={() => (paymentPopup.value = false)}
|
|
|
- />
|
|
|
- </Popup>
|
|
|
+ ) : (
|
|
|
+ <ColResult
|
|
|
+ buttonText="去购物车"
|
|
|
+ onClick={() => {
|
|
|
+ router.push({ path: '/cart' })
|
|
|
+ }}
|
|
|
+ ></ColResult>
|
|
|
+ )}
|
|
|
</div>
|
|
|
- ) : (
|
|
|
- <ColResult
|
|
|
- buttonText="去购物车"
|
|
|
- onClick={() => {
|
|
|
- router.push({ path: '/cart' })
|
|
|
- }}
|
|
|
- ></ColResult>
|
|
|
)}
|
|
|
</>
|
|
|
)
|