|
@@ -1,12 +1,29 @@
|
|
|
-import { Button, Cell, SwipeCell, Tag, Image, Icon, showConfirmDialog } from 'vant'
|
|
|
-import { defineComponent } from 'vue'
|
|
|
+import { Button, Cell, SwipeCell, Tag, Image, Icon, showConfirmDialog, List } from 'vant'
|
|
|
+import { defineComponent, onMounted, reactive } from 'vue'
|
|
|
import styles from './index.module.less'
|
|
|
import iconEdit from '../pre-apply/images/icon-edit.png'
|
|
|
import OSticky from '@/components/o-sticky'
|
|
|
+import request from '../request-music'
|
|
|
+import OEmpty from '@/components/o-empty'
|
|
|
+import { useRouter } from 'vue-router'
|
|
|
|
|
|
export default defineComponent({
|
|
|
name: 'shop-address',
|
|
|
setup() {
|
|
|
+ const router = useRouter()
|
|
|
+ const form = reactive({
|
|
|
+ isClick: false,
|
|
|
+ list: [] as any,
|
|
|
+ listState: {
|
|
|
+ dataShow: true, // 判断是否有数据
|
|
|
+ loading: false,
|
|
|
+ finished: false
|
|
|
+ },
|
|
|
+ params: {
|
|
|
+ page: 1,
|
|
|
+ rows: 20
|
|
|
+ }
|
|
|
+ })
|
|
|
const onBeforeClose = ({ position }: any) => {
|
|
|
if (position === 'right') {
|
|
|
showConfirmDialog({
|
|
@@ -18,40 +35,92 @@ export default defineComponent({
|
|
|
return true
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ // api-student/userReceiveAddress/page
|
|
|
+ const getList = async () => {
|
|
|
+ try {
|
|
|
+ if (form.isClick) return
|
|
|
+ form.isClick = true
|
|
|
+ const res = await request.post('/api-student/userReceiveAddress/page', {
|
|
|
+ data: {
|
|
|
+ ...form.params
|
|
|
+ }
|
|
|
+ })
|
|
|
+ form.listState.loading = false
|
|
|
+ const result = res.data || {}
|
|
|
+ // 处理重复请求数据
|
|
|
+ if (form.list.length > 0 && result.current === 1) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ form.list = form.list.concat(result.rows || [])
|
|
|
+ form.listState.finished = result.current >= result.pages
|
|
|
+ form.params.page = result.current + 1
|
|
|
+ form.listState.dataShow = form.list.length > 0
|
|
|
+ form.isClick = false
|
|
|
+ } catch {
|
|
|
+ form.listState.dataShow = false
|
|
|
+ form.listState.finished = true
|
|
|
+ form.isClick = false
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ onMounted(() => {
|
|
|
+ getList()
|
|
|
+ console.log('1111')
|
|
|
+ })
|
|
|
return () => (
|
|
|
<div class={styles.shopAddress}>
|
|
|
- {[1, 2, 3, 4, 5].map((item: any) => (
|
|
|
- <SwipeCell class={styles.swipeCell} beforeClose={onBeforeClose}>
|
|
|
- {{
|
|
|
- default: () => (
|
|
|
- <Cell center>
|
|
|
- {{
|
|
|
- title: () => (
|
|
|
- <div class={styles.title}>
|
|
|
- <span class={styles.name}>小林林</span>
|
|
|
- <span class={styles.phone}>15353535353</span>
|
|
|
- <Tag round color="#FF8057">
|
|
|
- 默认
|
|
|
- </Tag>
|
|
|
- </div>
|
|
|
- ),
|
|
|
- label: () => (
|
|
|
- <div class={styles.content}>
|
|
|
- 湖北省武汉市武昌区水果湖街街道楚河汉街总部国际A座3801
|
|
|
- </div>
|
|
|
- ),
|
|
|
- 'right-icon': () => <Icon name={iconEdit} size="18" />
|
|
|
- }}
|
|
|
- </Cell>
|
|
|
- ),
|
|
|
- right: () => <Button type="danger">删除</Button>
|
|
|
- }}
|
|
|
- </SwipeCell>
|
|
|
- ))}
|
|
|
-
|
|
|
+ {form.listState.dataShow ? (
|
|
|
+ <List
|
|
|
+ v-model:loading={form.listState.loading}
|
|
|
+ finished={form.listState.finished}
|
|
|
+ finishedText=" "
|
|
|
+ class={[styles.liveList]}
|
|
|
+ onLoad={getList}
|
|
|
+ immediateCheck={false}
|
|
|
+ >
|
|
|
+ {form.list.map((item: any) => (
|
|
|
+ <SwipeCell class={styles.swipeCell} beforeClose={onBeforeClose}>
|
|
|
+ {{
|
|
|
+ default: () => (
|
|
|
+ <Cell center>
|
|
|
+ {{
|
|
|
+ title: () => (
|
|
|
+ <div class={styles.title}>
|
|
|
+ <span class={styles.name}>小林林</span>
|
|
|
+ <span class={styles.phone}>15353535353</span>
|
|
|
+ <Tag round color="#FF8057">
|
|
|
+ 默认
|
|
|
+ </Tag>
|
|
|
+ </div>
|
|
|
+ ),
|
|
|
+ label: () => (
|
|
|
+ <div class={styles.content}>
|
|
|
+ 湖北省武汉市武昌区水果湖街街道楚河汉街总部国际A座3801
|
|
|
+ </div>
|
|
|
+ ),
|
|
|
+ 'right-icon': () => <Icon name={iconEdit} size="18" />
|
|
|
+ }}
|
|
|
+ </Cell>
|
|
|
+ ),
|
|
|
+ right: () => <Button type="danger">删除</Button>
|
|
|
+ }}
|
|
|
+ </SwipeCell>
|
|
|
+ ))}
|
|
|
+ </List>
|
|
|
+ ) : (
|
|
|
+ <OEmpty btnStatus={false} classImgSize="SMALL" tips="暂无收货地址" />
|
|
|
+ )}
|
|
|
<OSticky position="bottom">
|
|
|
<div class={'btnGroup'}>
|
|
|
- <Button type="primary" round block>
|
|
|
+ <Button
|
|
|
+ type="primary"
|
|
|
+ round
|
|
|
+ block
|
|
|
+ onClick={() => {
|
|
|
+ router.push('addressOperation')
|
|
|
+ }}
|
|
|
+ >
|
|
|
新建收货地址
|
|
|
</Button>
|
|
|
</div>
|