|
@@ -1,24 +1,172 @@
|
|
|
<template>
|
|
|
- <mobile-frame>
|
|
|
- 新增收货地址
|
|
|
+ <mobile-frame :frameStyle="frameStyle" @toPath="toPath">
|
|
|
+ <view class="main">
|
|
|
+ <view class="one">
|
|
|
+ <uni-forms ref="form" :modelValue="form" :rules="rules" label-width="auto">
|
|
|
+ <uni-forms-item label="收货人" name="name">
|
|
|
+ <uni-easyinput type="text" v-model="form.name" placeholder="请输入收货人" />
|
|
|
+ </uni-forms-item>
|
|
|
+ <uni-forms-item label="联系电话" name="phone">
|
|
|
+ <uni-easyinput type="text" v-model="form.phone" placeholder="请输入联系电话" />
|
|
|
+ </uni-forms-item>
|
|
|
+ <uni-forms-item label="所在地区" name="deptname">
|
|
|
+ <uni-data-picker placeholder="请选择省,市,区/街道" popup-title="选择省,市,区/街道" :localdata="provincial"
|
|
|
+ @change="onchange">
|
|
|
+ </uni-data-picker>
|
|
|
+ <text class="iconfont icon-dingweixiao"
|
|
|
+ @click="tolocation('/pagesMy/address/location')">定位</text>
|
|
|
+ </uni-forms-item>
|
|
|
+ <uni-forms-item label="详细地址" name="address">
|
|
|
+ <uni-easyinput type="text" v-model="form.address" placeholder="请输入所在小区/大厦/学校" />
|
|
|
+ </uni-forms-item>
|
|
|
+ <uni-forms-item label="楼牌号" name="num">
|
|
|
+ <uni-easyinput type="text" v-model="form.num" placeholder="请输入楼牌号" />
|
|
|
+ </uni-forms-item>
|
|
|
+ <uni-forms-item label="设为默认" name="true">
|
|
|
+ <switch :checked="check" @change="switchChange" />
|
|
|
+ </uni-forms-item>
|
|
|
+ </uni-forms>
|
|
|
+ <view class="btn">
|
|
|
+ <button type="primary" @click="onSubmit('form')" size="small">提交保存</button>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+
|
|
|
</mobile-frame>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
export default {
|
|
|
data() {
|
|
|
- return {};
|
|
|
+ return {
|
|
|
+ frameStyle: {
|
|
|
+ useBar: false
|
|
|
+ },
|
|
|
+ form: {},
|
|
|
+ rules: {
|
|
|
+ name: {
|
|
|
+ rules: [{
|
|
|
+ required: true,
|
|
|
+ errorMessage: '请输入收货人',
|
|
|
+ }]
|
|
|
+ },
|
|
|
+ phone: {
|
|
|
+ rules: [{
|
|
|
+ required: true,
|
|
|
+ errorMessage: '请输入联系电话',
|
|
|
+ tel: true
|
|
|
+ }]
|
|
|
+ },
|
|
|
+ deptname: {
|
|
|
+ rules: [{
|
|
|
+ required: true,
|
|
|
+ errorMessage: '请输入机构名称'
|
|
|
+ }]
|
|
|
+ },
|
|
|
+ address: {
|
|
|
+ rules: [{
|
|
|
+ required: true,
|
|
|
+ errorMessage: '请输入详细地址'
|
|
|
+ }]
|
|
|
+ },
|
|
|
+ },
|
|
|
+ provincial: [],
|
|
|
+ check: false,
|
|
|
+ };
|
|
|
},
|
|
|
onLoad: function(e) {
|
|
|
console.log(e);
|
|
|
},
|
|
|
onShow: function() {},
|
|
|
methods: {
|
|
|
-
|
|
|
+ toPath(e) {
|
|
|
+ if (e && e.route) uni.redirectTo({
|
|
|
+ url: `/${e.route}`
|
|
|
+ })
|
|
|
+ },
|
|
|
+ // 是否设为默认地址
|
|
|
+ switchChange(e) {
|
|
|
+ const that = this;
|
|
|
+ const {
|
|
|
+ value
|
|
|
+ } = e.detail;
|
|
|
+ that.$set(that, `check`, value);
|
|
|
+ },
|
|
|
+ // 选择城市
|
|
|
+ onchange() {},
|
|
|
+ // 定位
|
|
|
+ tolocation(route,e) {
|
|
|
+ uni.navigateTo({
|
|
|
+ url: `${route}`
|
|
|
+ })
|
|
|
+ },
|
|
|
+ // 提交保存
|
|
|
+ onSubmit() {
|
|
|
+ const that = this;
|
|
|
+ let data = that.form;
|
|
|
+ data = {
|
|
|
+ ...data,
|
|
|
+ check: that.check
|
|
|
+ }
|
|
|
+ console.log(data);
|
|
|
+ // this.$refs.form.validate().then(async (res) => {
|
|
|
+ // let arr;
|
|
|
+ // if (data._id) {
|
|
|
+ // arr = await that.$api(``, 'POST', data)
|
|
|
+ // } else {
|
|
|
+ // arr = await that.$api(``, 'POST', data)
|
|
|
+ // }
|
|
|
+ // if (arr.errcode == '0') {
|
|
|
+ // uni.showToast({
|
|
|
+ // title: `维护信息成功`,
|
|
|
+ // icon: 'success',
|
|
|
+ // duration: 2000
|
|
|
+ // });
|
|
|
+ // that.back()
|
|
|
+ // } else {
|
|
|
+ // uni.showToast({
|
|
|
+ // title: arr.errmsg,
|
|
|
+ // icon: 'error',
|
|
|
+ // duration: 2000
|
|
|
+ // })
|
|
|
+ // }
|
|
|
+ // })
|
|
|
+ },
|
|
|
}
|
|
|
}
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss">
|
|
|
+ .main {
|
|
|
+ display: flex;
|
|
|
+ flex-direction: column;
|
|
|
+ width: 100vw;
|
|
|
+ height: 100vh;
|
|
|
+
|
|
|
+ .one {
|
|
|
+ padding: 2vw;
|
|
|
+
|
|
|
+ .uni-input {
|
|
|
+ border: #f1f1ff 1px solid;
|
|
|
+ padding: 2vw 2vw;
|
|
|
+ border-radius: 1vw;
|
|
|
+ }
|
|
|
+
|
|
|
+ .btn {
|
|
|
+ text-align: center;
|
|
|
|
|
|
+ button {
|
|
|
+ margin: 0 2vw 2vw 2vw;
|
|
|
+ background-color: var(--f35BColor);
|
|
|
+ color: var(--fffColor);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ .uni-forms-item {
|
|
|
+ margin-bottom: 6vw !important;
|
|
|
+ display: flex;
|
|
|
+ flex-direction: row;
|
|
|
+ }
|
|
|
</style>
|