|
@@ -1,6 +1,13 @@
|
|
|
-import { computed, ref, defineComponent, onMounted, reactive } from 'vue'
|
|
|
+import {
|
|
|
+ computed,
|
|
|
+ ref,
|
|
|
+ defineComponent,
|
|
|
+ onMounted,
|
|
|
+ reactive,
|
|
|
+ onUnmounted
|
|
|
+} from 'vue'
|
|
|
import { Card, Cell, CellGroup, Popup, SubmitBar, Toast } from 'vant'
|
|
|
-import { addressType, cartConfirm } from '../cart'
|
|
|
+import { addressType, cartConfirm, formateAttr } from '../cart'
|
|
|
import styles from '../index.module.less'
|
|
|
import Address from '../components/address'
|
|
|
import request from '@/helpers/request'
|
|
@@ -12,23 +19,32 @@ import ColPopup from '@/components/col-popup'
|
|
|
import UserAuth from '@/views/order-detail/userAuth'
|
|
|
import ColResult from '@/components/col-result'
|
|
|
import { moneyFormat } from '@/helpers/utils'
|
|
|
+import { listenerMessage, removeListenerMessage } from '@/helpers/native-message'
|
|
|
export default defineComponent({
|
|
|
name: 'cartConfirm',
|
|
|
setup() {
|
|
|
const list = cartConfirm.cartPromotionItemList
|
|
|
const calcAmount = cartConfirm.calcAmount
|
|
|
|
|
|
+ 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
|
|
|
+ }
|
|
|
+ const setAddress = (result: addressType) => {
|
|
|
+ address.value = result
|
|
|
+ }
|
|
|
onMounted(() => {
|
|
|
- // console.log(cartConfirm, '确认订单商品')
|
|
|
+ listenerMessage('getAddress', result => {
|
|
|
+ setAddress(result?.content || {})
|
|
|
+ })
|
|
|
+ })
|
|
|
+ onUnmounted(() => {
|
|
|
+ removeListenerMessage('getAddress', () => {})
|
|
|
})
|
|
|
-
|
|
|
- const payType = ref(0) // 0->未支付;1->支付宝;2->微信
|
|
|
-
|
|
|
- const address = cartConfirm.memberReceiveAddressList.length
|
|
|
- ? cartConfirm.memberReceiveAddressList.find(
|
|
|
- (n: any) => n.defaultStatus
|
|
|
- ) || cartConfirm.memberReceiveAddressList[0] || {}
|
|
|
- : {}
|
|
|
|
|
|
const agreeStatus = ref(false)
|
|
|
const paymentPopup = ref(false)
|
|
@@ -39,7 +55,7 @@ export default defineComponent({
|
|
|
})
|
|
|
// 提交
|
|
|
const onSubmit = () => {
|
|
|
- if (!(address as any).id){
|
|
|
+ if (!address.value?.id) {
|
|
|
Toast('请选择收货地址')
|
|
|
return
|
|
|
}
|
|
@@ -70,8 +86,7 @@ export default defineComponent({
|
|
|
}, [])
|
|
|
const body = {
|
|
|
cartIds: ids,
|
|
|
- memberReceiveAddressId: (address as any).id,
|
|
|
- payType: payType.value
|
|
|
+ memberReceiveAddressId: address.value?.id
|
|
|
}
|
|
|
try {
|
|
|
let { code, data } = await request.post(
|
|
@@ -96,7 +111,7 @@ export default defineComponent({
|
|
|
{list.length ? (
|
|
|
<div class={styles.cartConfirm}>
|
|
|
<div class={styles.cartConfirmBox}>
|
|
|
- <Address item={address as any} />
|
|
|
+ <Address item={address.value} setAddress={setAddress} />
|
|
|
</div>
|
|
|
<div
|
|
|
style={{ marginTop: '20px' }}
|
|
@@ -110,7 +125,7 @@ export default defineComponent({
|
|
|
>
|
|
|
<Card
|
|
|
price={moneyFormat(item.price)}
|
|
|
- desc={item.productAttr}
|
|
|
+ desc={formateAttr(item.productAttr)}
|
|
|
title={item.productName}
|
|
|
thumb={item.productPic}
|
|
|
num={item.quantity}
|
|
@@ -129,7 +144,11 @@ export default defineComponent({
|
|
|
title="运费"
|
|
|
value={moneyFormat(calcAmount.freightAmount)}
|
|
|
></Cell>
|
|
|
- <Cell border={false} title="优惠" value={'-¥ ' + moneyFormat(calcAmount.promotionAmount)}></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>
|
|
@@ -146,7 +165,9 @@ export default defineComponent({
|
|
|
>
|
|
|
<div class={styles.confirmBottom}>
|
|
|
合计{' '}
|
|
|
- <span class={styles['price-des']}>¥{moneyFormat(calcAmount.payAmount)}</span>
|
|
|
+ <span class={styles['price-des']}>
|
|
|
+ ¥{moneyFormat(calcAmount.payAmount)}
|
|
|
+ </span>
|
|
|
</div>
|
|
|
</SubmitBar>
|
|
|
<div style={{ height: 'var(--van-submit-bar-height)' }}></div>
|
|
@@ -174,7 +195,7 @@ export default defineComponent({
|
|
|
<ColResult
|
|
|
buttonText="去购物车"
|
|
|
onClick={() => {
|
|
|
- router.push({path: '/cart'})
|
|
|
+ router.push({ path: '/cart' })
|
|
|
}}
|
|
|
></ColResult>
|
|
|
)}
|