This commit is contained in:
zmj 2024-06-14 13:56:28 +08:00
parent 5afd6b8978
commit 87cc78ffcd
1 changed files with 167 additions and 115 deletions

View File

@ -3,54 +3,94 @@
<view class="card">
<up-form labelPosition="left" :model="formData" :rules="rules" ref="uForm" labelWidth="100">
<up-form-item label="收货人" prop="real_name" borderBottom>
<up-input v-model="formData.real_name" disabledColor="#ffffff" border="none" placeholder="请填写收货人姓名"></up-input>
<up-input v-model="formData.real_name" disabledColor="#ffffff" border="none"
placeholder="请填写收货人姓名"></up-input>
</up-form-item>
<up-form-item label="联系电话" prop="phone" borderBottom>
<up-input v-model="formData.phone" disabledColor="#ffffff" type="number" placeholder="请填写联系电话"
border="none"></up-input>
</up-form-item>
<!-- <up-form-item label="所在位置" prop="address" borderBottom>
<up-input v-model="formData.address" disabledColor="#ffffff" type="number"
@click='showAddressPop=true' placeholder="点击选择位置" border="none"></up-input>
<template #right>
<up-icon name="arrow-right"></up-icon>
</template>
</up-form-item> -->
<up-form-item label="详细地址" prop="detail" borderBottom>
<up-input v-model="formData.detail" disabledColor="#ffffff" placeholder="请填写详细地址" border="none"></up-input>
<up-input v-model="formData.detail" disabledColor="#ffffff" placeholder="请填写详细地址"
border="none"></up-input>
</up-form-item>
</up-form>
</view>
<view class="card">
<view class="is-default">
<view>设置为默认地址</view>
<up-switch v-model="formData.is_default" :activeValue="1" :inactiveValue="0" activeColor="#20B128"></up-switch>
<up-switch v-model="formData.is_default" :activeValue="1" :inactiveValue="0"
activeColor="#20B128"></up-switch>
</view>
</view>
<view class="bottom-fixed">
<up-button color="#20B128" shape="circle" @click="submit">保存</up-button>
</view>
<!-- 地址选择器 -->
<up-popup :show="showAddressPop" @close="showAddressPop=false" @open="showAddressPop=true" :round="10">
<view class='address-pop'>
<view class="title">
收货地址
</view>
</view>
</up-popup>
</view>
</template>
<script setup>
import { onLoad } from "@dcloudio/uni-app"
import { ref } from "vue"
import { addressCreateApi, addressEditApi, addressDetailApi } from "@/api/user.js"
import {
onLoad
} from "@dcloudio/uni-app"
import {
ref
} from "vue"
import {
addressCreateApi,
addressEditApi,
addressDetailApi
} from "@/api/user.js"
const mode = ref('add');
const showAddressPop = ref(false)
const formData = ref({
real_name: '',
phone: '',
detail: '',
is_default: 0
is_default: 0,
address: ""
})
const rules = ref({
real_name: [{ required: true, message: '请输入姓名', trigger: ['blur'] }],
phone: [{ required: true, message: '请输入手机号', trigger: ['blur'] },{
real_name: [{
required: true,
message: '请输入姓名',
trigger: ['blur']
}],
phone: [{
required: true,
message: '请输入手机号',
trigger: ['blur']
}, {
validator: (rule, value, callback) => {
// truefalse
// uni.$u.test.mobile()truefalse
return uni.$u.test.mobile(value);
},
message: '手机号码不正确',
trigger: ['change', 'blur'],
}],
detail: [{ required: true, message: '请输入地址', trigger: ['blur'] }]
detail: [{
required: true,
message: '请输入地址',
trigger: ['blur']
}]
})
const uForm = ref(null);
const submit = () => {
@ -130,4 +170,16 @@
padding-bottom: calc(env(safe-area-inset-bottom) + 20rpx);
/* 适用于Android设备 */
}
.address-pop {
height: 60vh;
padding: 20rpx;
overflow-y: auto;
.title {
font-size: 32rpx;
color: black;
text-align: center;
}
}
</style>