评论需要添加功能,提交订单有问题
This commit is contained in:
@@ -1,7 +1,198 @@
|
||||
<script setup></script>
|
||||
<script setup>
|
||||
import { navigateTo } from '@/utils/router'
|
||||
import { onShow } from '@dcloudio/uni-app'
|
||||
import { getUserAddress, updateUserAddress, deleteUserAddress } from '@/api'
|
||||
import { ref } from 'vue'
|
||||
import { useUI } from '@/utils/use-ui'
|
||||
|
||||
const { showDialog, showToast } = useUI()
|
||||
|
||||
const listData = ref([])
|
||||
const getData = async () => {
|
||||
const res = await getUserAddress({ pageNum: 1, pageSize: 99 })
|
||||
listData.value = res.rows
|
||||
}
|
||||
|
||||
const onAdd = () => {
|
||||
navigateTo('/pages/address/add')
|
||||
}
|
||||
|
||||
const onGo = id => {
|
||||
navigateTo('/pages/address/edit', { id })
|
||||
}
|
||||
|
||||
const onDefault = async item => {
|
||||
const show = await showDialog('提示', '确定要设为默认地址吗?')
|
||||
if (show) {
|
||||
const data = {
|
||||
id: item.id,
|
||||
houseNum: item.houseNum,
|
||||
name: item.name,
|
||||
phone: item.phone,
|
||||
address: item.address,
|
||||
defaultAddress: 1
|
||||
}
|
||||
await updateUserAddress(data)
|
||||
await showToast('设置成功', 'success')
|
||||
getData()
|
||||
}
|
||||
}
|
||||
|
||||
const onDelete = async item => {
|
||||
const show = await showDialog('提示', '确定要删除吗?')
|
||||
if (show) {
|
||||
await deleteUserAddress(item.id)
|
||||
await showToast('删除成功', 'success')
|
||||
getData()
|
||||
}
|
||||
}
|
||||
|
||||
onShow(() => {
|
||||
getData()
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<view class="address-index">地址列表</view>
|
||||
<view class="address-index">
|
||||
<nav-bar isTopBg isPlaceholder title="我的地址">
|
||||
<template #right>
|
||||
<text class="top-right-name" @click="onAdd">添加地址</text>
|
||||
</template>
|
||||
</nav-bar>
|
||||
<view class="address-list">
|
||||
<uni-swipe-action>
|
||||
<uni-swipe-action-item v-for="item in listData" :key="item.id">
|
||||
<view class="card-box" @click="onGo(item.id)">
|
||||
<view class="left-box">
|
||||
<text class="address">{{ item.address }}</text>
|
||||
<text class="name">{{ item.houseNum }}</text>
|
||||
<view class="bottom">
|
||||
<text>{{ item.name }}</text>
|
||||
<text>{{ item.phone }}</text>
|
||||
<text
|
||||
v-if="item.defaultAddress == 1"
|
||||
class="default-text"
|
||||
>
|
||||
默认地址
|
||||
</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<uni-icons type="compose" size="20"></uni-icons>
|
||||
</view>
|
||||
<template v-slot:right>
|
||||
<view class="swipe-box">
|
||||
<view
|
||||
v-if="item.defaultAddress == 0"
|
||||
class="btn-box"
|
||||
@click="onDefault(item)"
|
||||
>
|
||||
<uni-icons
|
||||
type="checkbox"
|
||||
size="18"
|
||||
color="#ffffff"
|
||||
></uni-icons>
|
||||
<text class="iocn-name">设为默认</text>
|
||||
</view>
|
||||
<view class="btn-box" @click="onDelete(item)">
|
||||
<uni-icons
|
||||
type="trash"
|
||||
size="18"
|
||||
color="#ffffff"
|
||||
></uni-icons>
|
||||
<text class="iocn-name">删除</text>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
</uni-swipe-action-item>
|
||||
</uni-swipe-action>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<style lang="scss" scoped></style>
|
||||
<style lang="scss" scoped>
|
||||
.top-right-name {
|
||||
font-family: PingFang SC, PingFang SC;
|
||||
font-weight: 500;
|
||||
font-size: 28rpx;
|
||||
color: #00d993;
|
||||
text-align: center;
|
||||
font-style: normal;
|
||||
text-transform: none;
|
||||
}
|
||||
.address-list {
|
||||
// padding: 32rpx;
|
||||
|
||||
.card-box {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 22rpx;
|
||||
border-bottom: 2rpx solid #f4f4f4;
|
||||
// margin-bottom: 22rpx;
|
||||
// padding-bottom: 22rpx;
|
||||
.left-box {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
font-family: PingFang SC, PingFang SC;
|
||||
font-weight: 500;
|
||||
|
||||
font-style: normal;
|
||||
text-transform: none;
|
||||
.address {
|
||||
font-size: 24rpx;
|
||||
color: #999999;
|
||||
}
|
||||
.name {
|
||||
font-size: 32rpx;
|
||||
color: #333333;
|
||||
margin: 10rpx 0;
|
||||
}
|
||||
|
||||
.bottom {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
text + text {
|
||||
margin-left: 26rpx;
|
||||
}
|
||||
text {
|
||||
font-size: 24rpx;
|
||||
color: #999999;
|
||||
}
|
||||
.default-text {
|
||||
font-size: 24rpx;
|
||||
background: #00d993;
|
||||
color: #ffffff;
|
||||
padding: 2rpx 6rpx;
|
||||
border-radius: 8rpx;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.swipe-box {
|
||||
display: flex;
|
||||
.btn-box {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: rgb(47, 194, 17);
|
||||
width: 130rpx;
|
||||
.iocn-name {
|
||||
font-family: PingFang SC, PingFang SC;
|
||||
font-weight: 500;
|
||||
font-size: 28rpx;
|
||||
color: #fff;
|
||||
text-align: left;
|
||||
font-style: normal;
|
||||
text-transform: none;
|
||||
}
|
||||
|
||||
// 最后一个
|
||||
&:last-child {
|
||||
background: rgb(206, 59, 22);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user