quanwei
18 hours ago c441dea81bd86bdfb12dff35821fed51f4cc91c2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<template>
  <el-dialog title="修改地址" :visible.sync="dialogVisible" :close-on-click-modal="false" :close-on-press-escape="false"
    width="900px">
    <el-input class="mb16" size="small" v-model="addressData.name" placeholder="请输入收货人"></el-input>
    <el-input class="mb16" size="small" v-model="addressData.phone" placeholder="请输入收获电话"></el-input>
    <el-select class="mb16" v-model="addressData.province_id" placeholder="省" @change="initCity">
      <el-option :label="item.name" :value="item.id" v-for="(item,index) in areaList" :key='index'></el-option>
    </el-select>
    <el-select v-if="addressData.province_id!=''" v-model="addressData.city_id" placeholder="市" @change="initRegion">
      <el-option :label="item1.name" :value="item1.id"
        v-for="(item1,index1) in areaList[addressData.province_id]['city']" :key='index1'></el-option>
    </el-select>
    <el-select v-if="addressData.city_id!=''" v-model="addressData.region_id" placeholder="区">
      <el-option :label="item2.name" :value="item2.id"
        v-for="(item2,index2) in areaList[addressData.province_id]['city'][addressData.city_id]['region']"
        :key='index2'></el-option>
    </el-select>
    <el-input class="mb16" size="small" v-model="addressData.detail" placeholder="请输入详细地址"></el-input>
    <div slot="footer" class="dialog-footer">
      <el-button size="small" @click="dialogFormVisible(false)">取 消</el-button>
      <el-button size="small" type="primary" @click="dialogFormVisible(true)">确 定</el-button>
    </div>
  </el-dialog>
</template>
 
<script>
  import OrderApi from '@/api/order.js';
  import DataApi from '@/api/data.js';
  export default {
    data() {
      return {
        /*是否显示*/
        dialogVisible: false,
        /*结果类别*/
        type: 'error',
        /*传出去的参数*/
        params: null,
        reverse: false,
        order_id: 0,
        activities: [],
        /*省市区*/
        areaList: [],
        address: {
          name: '',
          phone: '',
          region: {
            province: '',
            province_id: '',
            city: '',
            city_id: '',
            region: '',
            region_id: '',
            detail: ''
          }
        }
      }
    },
    props: ['isChange', 'addressData'],
    watch: {
      isChange: function(n, o) {
        if (n != o) {
          this.dialogVisible = n;
          this.type = 'error';
        }
      },
    },
    mounted() {
      this.getData();
    },
    methods: {
      getData(){
        let self = this;
        DataApi.getRegion({}, true)
          .then(res => {
            self.areaList = res.data.regionData;
          })
          .catch(error => {
 
          });
      },
      /*初始化城市id*/
      initCity() {
        this.addressData.city_id = ''
      },
 
      /*初始化区id*/
      initRegion() {
        this.addressData.region_id = ''
      },
      /*关闭弹窗*/
      dialogFormVisible(flag) {
        console.log(flag)
        if (flag) {
          this.$emit('closeDialog', {
            type: this.type,
            openDialog: false,
            params: this.addressData
          });
        } else {
          this.$emit('closeDialog', false)
        }
 
      },
    }
  }
</script>
 
<style>
 
</style>