purchase-let/pagesOrder/addressEdit/addressEdit.vue

100 lines
2.9 KiB
Vue
Raw Normal View History

2024-04-27 18:02:43 +08:00
<template>
<view class="">
<view class="card">
<up-form labelPosition="left" :model="formData" :rules="rules" ref="uForm" labelWidth="100">
<up-form-item label="收货人" prop="name" borderBottom>
<up-input v-model="formData.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" 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.isDefault" activeColor="#20B128"></up-switch>
</view>
</view>
<view class="bottom-fixed">
<up-button color="#20B128" shape="circle" @click="submit">保存</up-button>
</view>
</view>
</template>
<script setup>
import { onLoad } from "@dcloudio/uni-app"
import { ref } from "vue"
const mode = ref('add');
const formData = ref({
name: '',
phone: '',
address: '',
isDefault: false
})
const rules = ref({
name: [{ required: true, message: '请输入姓名', trigger: ['blur'] }],
phone: [{ required: true, message: '请输入手机号', trigger: ['blur'] }],
address: [{ required: true, message: '请输入地址', trigger: ['blur'] }]
})
const uForm = ref(null);
const submit = () => {
uForm.value.validate().then(() => {
console.log('验证通过');
}).catch(() => {
console.log('验证失败');
})
}
onLoad((options) => {
if (options.mode == 'edit') {
mode.value = 'edit';
uni.setNavigationBarTitle({
title: '编辑地址'
})
} else uni.setNavigationBarTitle({
title: '新增地址'
})
})
</script>
<style lang="scss">
.card {
margin: 20rpx;
background-color: #fff;
border-radius: 14rpx;
padding: 0 30rpx;
.is-default {
display: flex;
align-items: center;
justify-content: space-between;
padding: 20rpx 0;
}
}
.bottom-fixed {
position: fixed;
bottom: 0;
left: 0;
height: 120rpx;
height: calc(constant(safe-area-inset-bottom) + 120rpx);
/* 适用于iOS设备 */
height: calc(env(safe-area-inset-bottom) + 120rpx);
/* 适用于Android设备 */
width: 100%;
box-sizing: border-box;
background-color: #fff;
padding: 20rpx;
padding-bottom: calc(constant(safe-area-inset-bottom) + 20rpx);
/* 适用于iOS设备 */
padding-bottom: calc(env(safe-area-inset-bottom) + 20rpx);
/* 适用于Android设备 */
}
</style>