Files
liche/admin/views/area.php
T
2021-07-05 09:56:27 +08:00

65 lines
2.5 KiB
PHP
Executable File

<script type="text/javascript">
var vm = new Vue({
el: '#area',
data: {
province_id: '',
city_id: '',
county_id: '',
province: JSON.parse('<?=json_encode($province)?>'),
city: [],
county: [],
},
methods: {
getCity: function(index) {
$.get('/common/area',{pid:_self.cate_id}, function (res) {
_self.lists.level2 = res.data;
},'json');
var c = JSON.parse('<?=json_encode($this->data['map']['city'])?>');
var tmp = new Array;
for(var i in c) {
if(c[i].province_id == index) {
tmp.push(c[i]);
}
}
this.city = tmp;
this.init();
this.county = '';
$('#city1').val('市');
$('#county1').val('区');
return true;
},
getCounty: function(index) {
var c = JSON.parse('<?=json_encode($this->data['map']['county'])?>');
var tmp = new Array;
for(var i in c) {
if(c[i].city_id == index) {
tmp.push(c[i]);
}
}
this.county = tmp;
$('#county_id1').find('option').eq(0).text('区');
$('#county_id1').find('option').eq(0).attr('value','');
$('#county1').val('区');
this.county_id = '';
return true;
},
init: function(index) {
$('#city_id1').find('option').eq(0).text('市');
$('#city_id1').find('option').eq(0).attr('value','');
this.city_id = '';
$('#county_id1').find('option').eq(0).text('区');
$('#county_id1').find('option').eq(0).attr('value','');
this.county_id = '';
},
setProvince: function(index) {
$('#province1').val($('#province_id1').find('option:selected').text());
},
setCity: function(index) {
$('#city1').val($('#city_id1').find('option:selected').text());
},
setCounty: function(index) {
$('#county1').val($('#county_id1').find('option:selected').text());
}
}
})
</script>