103 lines
2.9 KiB
Vue
103 lines
2.9 KiB
Vue
<template>
|
||
<view>
|
||
<!-- 顶部操作条 -->
|
||
<cu-custom :bgColor="'bg-main-color'" :isBack="true">
|
||
<block slot="backText">返回</block>
|
||
<block slot="content">编辑地址</block>
|
||
</cu-custom>
|
||
<!-- 地址信息form -->
|
||
<view class="bg-white margin-top-sm">
|
||
<form @submit="submit">
|
||
<view class="cu-form-group">
|
||
<view class="title">联系人</view>
|
||
<input name="person2Contact" :value="formData.person2Contact"></input>
|
||
</view>
|
||
<view class="cu-form-group">
|
||
<view class="title">手机号码</view>
|
||
<input name="phone" :value="formData.phone"></input>
|
||
</view>
|
||
<!-- #ifndef H5 || APP-PLUS || MP-ALIPAY -->
|
||
<view class="cu-form-group">
|
||
<view class="title">地址选择</view>
|
||
<picker mode="region" @change="regionChange" name="area" :value="formData.area">
|
||
<view class="picker">
|
||
{{formData.area[0]}},{{formData.area[1]}},{{formData.area[2]}}
|
||
</view>
|
||
</picker>
|
||
</view>
|
||
<!-- #endif -->
|
||
<view class="cu-form-group">
|
||
<view class="title">详细地址</view>
|
||
<input name="address" :value="formData.address"></input>
|
||
</view>
|
||
<view class="cu-form-group margin-top">
|
||
<view class="title">默认地址</view>
|
||
<switch class="main-color radius" @change="isDefaultChange" :class="formData.isDefault?'checked':''"
|
||
:checked="formData.isDefault?true:false" name="isDefault" :value="formData.isDefault"></switch>
|
||
</view>
|
||
<!-- 底部操作栏 -->
|
||
<view class="cu-bar tabbar border shop fixed-bottom-bar">
|
||
<button class="bg-main-color long-btn margin-lr-sm" form-type="submit">保存</button>
|
||
</view>
|
||
</form>
|
||
</view>
|
||
</view>
|
||
</template>
|
||
|
||
<script>
|
||
export default {
|
||
data() {
|
||
return {
|
||
formData: {
|
||
id: 1,
|
||
person2Contact: '卢翰',
|
||
phone: '18928799765',
|
||
area: ['广西壮族自治区', '梧桐洲', '藤县'],
|
||
address: '同心镇同心村同心路88号',
|
||
isDefault: true
|
||
}
|
||
}
|
||
},
|
||
onLoad(options) {
|
||
const addressInfo = JSON.parse(decodeURIComponent(options.addressInfo));
|
||
this.fillForm(addressInfo);
|
||
},
|
||
methods: {
|
||
fillForm(addressInfo) {
|
||
this.formData = addressInfo ? addressInfo : this.formData;
|
||
},
|
||
regionChange(e) {
|
||
this.formData.area = e.detail.value;
|
||
},
|
||
isDefaultChange(e) {
|
||
this.formData.isDefault = e.detail.value;
|
||
},
|
||
validateForm(confirmFormData) {
|
||
return Boolean(confirmFormData.person2Contact) &&
|
||
Boolean(confirmFormData.phone) &&
|
||
Boolean(confirmFormData.address);
|
||
},
|
||
submit(e) {
|
||
const confirmFormData = e.detail.value;
|
||
let formValid = this.validateForm(confirmFormData);
|
||
if (formValid) {
|
||
uni.showToast({
|
||
title: '保存成功',
|
||
icon: 'success',
|
||
mask: true
|
||
})
|
||
} else {
|
||
uni.showToast({
|
||
title: '请填写完整信息',
|
||
icon: 'none',
|
||
mask: true
|
||
})
|
||
}
|
||
}
|
||
}
|
||
}
|
||
</script>
|
||
|
||
<style>
|
||
</style>
|