oil-station/gasStation-uni/pagesHome/editress/editress.vue
2023-12-05 13:33:30 +08:00

204 lines
3.8 KiB
Vue

<template>
<view class="content">
<view class="container">
<view class="my-header">
<view class="my-icons" @click="goback"> <uni-icons type="left" size="16"></uni-icons> </view>
<view class="my-text">收获信息</view>
<view class="my-icons"></view>
</view>
<view class="box-gang">
<view class="g-name">联系人</view>
<input type="text" placeholder="请填写收货人" v-model='dataForm.name' />
</view>
<view class="box-gang">
<view class="g-name">手机号</view>
<input type="text" placeholder="请填写手机号" v-model='dataForm.mobile' />
</view>
<view class="box-gang">
<view class="g-name">所在地区</view>
<input type="text" placeholder="请填写所在地区" v-model='dataForm.address' />
</view>
<view class="box-gang">
<view class="g-name">详细地区</view>
<input type="text" placeholder="请填写详细地区" v-model='dataForm.fullAddress' />
</view>
<view class="box-gang-bt">
<view class="g-name">默认地址</view>
<u-switch v-model="value" @change="change"></u-switch>
</view>
<!-- 顶部区域 -->
<view class="bottom-anniu" @click="goedit()">
<view class="">提交</view>
</view>
</view>
</view>
</template>
<script>
import config from '@/config'
import request from '../../utils/request'
export default {
data() {
return {
title: '',
value: true,
dataForm: {
id: null,
name: '',
mobile: '',
address: '',
ifDefault: '',
fullAddress: '',
}
}
},
onLoad() {
this.dataForm = {}
uni.$on('addressInfo', (data) => {
if (data != null) {
this.dataForm = data
if (this.dataForm.ifDefault == 1) {
this.value = true
} else {
this.value = false
}
}
})
uni.$emit('unAddressInfo')
},
components: {
},
methods: {
change(e) {
console.log(e);
},
goback() {
uni.navigateBack()
},
goedit() {
if (this.value) {
this.dataForm.ifDefault = 1
} else {
this.dataForm.ifDefault = 2
}
let url = 'business/userManager/mtUserExpressAddress'
if (this.dataForm.id != null) {
request({
url: url,
method: 'put',
data: this.dataForm
}).then((res) => {
if (res.code == 200) {
uni.showToast({
title: '修改成功',
icon: 'none'
}),
uni.navigateBack()
}
})
} else {
request({
url: url,
method: 'post',
data: this.dataForm
}).then((res) => {
if (res.code == 200) {
uni.showToast({
title: '提交成功',
icon: 'none'
}),
uni.navigateBack()
}
})
}
console.log("123123", this.dataForm)
}
}
}
</script>
<style scoped lang="scss">
.content {
background: #f4f5f6;
}
.container {
width: 100%;
height: 100vh;
box-sizing: border-box;
padding-top: 88px;
}
.my-header {
width: 100%;
height: 88px;
background: #ffffff;
display: flex;
align-items: center;
justify-content: space-between;
color: #000;
box-sizing: border-box;
padding: 0px 15px;
padding-top: 40px;
.my-icons {
width: 20px;
}
position: fixed;
top: 0px;
}
.box-gang {
width: 100%;
background-color: #ffffff;
box-sizing: border-box;
padding: 15px;
display: flex;
align-items: center;
border-bottom: 1px solid #f4f5f6;
}
.g-name {
margin-right: 5px;
}
.box-gang-bt {
width: 100%;
display: flex;
align-items: center;
justify-content: space-between;
background-color: #ffffff;
box-sizing: border-box;
padding: 15px;
}
.dataform {
background-color: #ffffff;
margin: 20px 20px 20px 20px;
}
.bottom-anniu {
width: 90%;
height: 50px;
display: flex;
align-items: center;
background: #1678ff;
color: white;
justify-content: center;
bottom: 15px;
margin: 20px auto;
border-radius: 8px;
}
</style>