| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175 |
- <template>
- <view class="content bg-drak ft-main">
- <use-tabbar :tabbar="false"></use-tabbar>
- <view class="gap"></view>
-
- <view class="row dflex padding-lr">
- <text class="tit">收货人</text>
- <input class="input" placeholder="请输入收货人姓名" maxlength="140" v-model="fetch.name"/>
- </view>
-
- <view class="row dflex padding-lr">
- <text class="tit">手机号</text>
- <input class="input" placeholder="请输入手机号码" maxlength="140" type="number" pattern="[0-9]*" v-model="fetch.phone"/>
- </view>
-
- <view class="row dflex padding-left">
- <text class="tit">所在地区</text>
- <view class="dflex-b flex1">
- <view class="flex1 input_t" @click="openAddress">{{ fetch.area_string }}</view>
- <sx-address-picker v-model="address" :selected="fetch.area" @confirm="addressConfirm"/>
- </view>
- </view>
-
- <view class="use-area margin-lr-sm">
- <view class="tit">详细地址</view>
- <textarea class="bg-drak w-full border-radius-sm margin-top-sm padding" placeholder="请输入详细地址" maxlength="120" style="min-height: 70px; height: auto;" v-model="fetch.address"/>
- </view>
-
- <view class="gap"></view>
-
- <view class="row dflex-b padding-lr">
- <u-subsection :list="type" :current="fetch.type" @change="setType" mode="button"></u-subsection>
- </view>
-
- <view class="padding w-full margin-top-big" @click="save">
- <view class="dflex-b border-radius-big">
- <view class="tac padding-tb-sm flex1 bg-base">提交</view>
- </view>
- </view>
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- type: [],
- address:false,
-
- fetch: {
- id:-1,
- province_id:0,
- city_id:0,
- county_id:0,
- town_id:0,
- address:'',
- name:'',
- phone:'',
- type:0,
- area:['CN', '11', '1101', '110107', '110107005'],
- area_string: '请选择地址',
- }
- };
- },
- onLoad(options) {
- this.type = ['默认地址', '普通地址'];
- if (options) {
- if (options.temp == 1) {
- this.type.push('临时地址');
- }
- if (options.id) {
- this.fetch.id = options.id;
- }
- }
- this.loadData();
- },
- methods: {
- loadData() {
- this.DeverApi.get(this, 'address.getInfo', {id:this.fetch.id});
- },
- setType(index) {
- this.fetch.type = index;
- },
- save() {
- if (!this.fetch.name) {
- return this.Dever.alert('请输入收货人姓名');
- }
- if (!this.fetch.phone) {
- return this.Dever.alert('请输入手机号');
- }
-
- if (!/^1\d{10}$/.test(this.fetch.phone)) {
- return this.Dever.alert('请输入有效手机号');
- }
-
- if (!this.fetch.province_id) {
- return this.Dever.alert('请选择省份');
- }
- if (!this.fetch.city_id) {
- return this.Dever.alert('请选择城市');
- }
- if (!this.fetch.county_id) {
- return this.Dever.alert('请选择区县');
- }
- if (!this.fetch.town_id) {
- return this.Dever.alert('请选择街道');
- }
- if (!this.fetch.address) {
- return this.Dever.alert('请输入详细地址');
- }
-
- this.DeverApi.post('address.up', this.fetch, res => {
- this.Dever.success('提交成功', () => {
- this.Dever.back('user/address/list');
- });
- });
- },
- openAddress() {
- this.address = true
- },
- // 选择地址
- addressConfirm(res) {
- var name = [];
- res.forEach((item, index) => {
- if (index > 0) {
- if (name != '市辖区') {
- name.push(item.name)
- }
- if (index == 1) {
- this.fetch.province_id = item.code;
- } else if (index == 2) {
- this.fetch.city_id = item.code;
- } else if (index == 3) {
- this.fetch.county_id = item.code;
- } else if (index == 4) {
- this.fetch.town_id = item.code;
- }
- }
- });
- this.fetch.area_string = name.join('-')
- },
- }
- };
- </script>
- <style lang="scss">
- .row {
- background: #fff;
- position: relative;
- height: 104rpx;
- margin: 18rpx;
- border-radius: 18rpx;
-
- .input {
- flex: 1;
- font-size: 28rpx;
- padding-left: 0;
- }
-
- .tit {
- flex-shrink: 0;
- width: 144rpx;
- }
- }
-
- .use-area {
- border-radius: 18rpx;
- background: #fff;
- padding: 28rpx;
- margin-top: 18rpx;
- }
- </style>
|