|
@@ -1,9 +1,18 @@
|
|
|
import { Cell, Icon } from 'vant'
|
|
|
-import { defineComponent, onMounted, ref, computed, PropType, toRef } from 'vue'
|
|
|
+import {
|
|
|
+ defineComponent,
|
|
|
+ onMounted,
|
|
|
+ ref,
|
|
|
+ computed,
|
|
|
+ PropType,
|
|
|
+ toRef,
|
|
|
+ onUnmounted
|
|
|
+} from 'vue'
|
|
|
import styles from './index.module.less'
|
|
|
import iconAddress from '@views/shop-mall/images/icon-address.png'
|
|
|
import request from '@/helpers/request'
|
|
|
import { cartConfirm, addressType } from '../../cart'
|
|
|
+import { postMessage, removeListenerMessage, listenerMessage } from '@/helpers/native-message'
|
|
|
|
|
|
export default defineComponent({
|
|
|
name: 'cart-address',
|
|
@@ -18,7 +27,7 @@ export default defineComponent({
|
|
|
}
|
|
|
},
|
|
|
setup(props) {
|
|
|
- const address = props.item
|
|
|
+ let address = props.item
|
|
|
const addressInfo = computed(() => {
|
|
|
return [
|
|
|
address.province,
|
|
@@ -27,18 +36,39 @@ export default defineComponent({
|
|
|
address.detailAddress
|
|
|
].join('')
|
|
|
})
|
|
|
+ const setAddress =(data: any) => {
|
|
|
+ console.log(data)
|
|
|
+ address = data
|
|
|
+ }
|
|
|
+
|
|
|
+ const selectAddress = () => {
|
|
|
+ postMessage({
|
|
|
+ api: 'setAddress',
|
|
|
+ content: {}
|
|
|
+ })
|
|
|
+ }
|
|
|
+ onMounted(() => {
|
|
|
+ listenerMessage('getAddress', setAddress)
|
|
|
+ })
|
|
|
+
|
|
|
+ onUnmounted(() => {
|
|
|
+ removeListenerMessage('getAddress', () => {})
|
|
|
+ })
|
|
|
|
|
|
return () => (
|
|
|
<>
|
|
|
<Cell
|
|
|
class={styles.cell}
|
|
|
is-link={props.isLink}
|
|
|
+ onClick={() => selectAddress()}
|
|
|
v-slots={{
|
|
|
icon: () => <Icon name={iconAddress} size={19} />,
|
|
|
title: () => (
|
|
|
<div>
|
|
|
<span class={styles.userName}>{address?.name}</span>
|
|
|
- <span class={styles.phone}>{address?.phoneNumber}</span>
|
|
|
+ <span class={styles.phone}>
|
|
|
+ {address?.phoneNumber || '去填写收货地址'}
|
|
|
+ </span>
|
|
|
</div>
|
|
|
),
|
|
|
label: () => (
|