You've already forked qlg.frontend
Init Repo
This commit is contained in:
299
js/editAddress.js
Normal file
299
js/editAddress.js
Normal file
@ -0,0 +1,299 @@
|
||||
mui.init({
|
||||
beforeback: function() { //获得父页面的webview
|
||||
var list = plus.webview.currentWebview().opener(); //触发父页面的自定义事件(refresh),从而进行刷新
|
||||
mui.fire(list, 'reload');
|
||||
//返回true,继续页面关闭逻辑
|
||||
return true;
|
||||
}
|
||||
});
|
||||
mui.plusReady(function() {
|
||||
var self = plus.webview.currentWebview();
|
||||
var addressId = self.data_addressId ? self.data_addressId : 0;
|
||||
var isParentId = 1;
|
||||
var isProvince;
|
||||
var isCity;
|
||||
var userName = $('#userName');
|
||||
var userPhone = $('#userPhone');
|
||||
var province = $('#province');
|
||||
var city = $('#city');
|
||||
var Area = $('#area');
|
||||
var Textarea = $('textarea');
|
||||
var areaVal;
|
||||
if (addressId != 0) {
|
||||
$('.address_info').css('display', 'none');
|
||||
$('.add_info').css('display', 'block');
|
||||
mui.ajax(qlgUrl('app/useraddress/getById'), {
|
||||
data: {
|
||||
addressId: addressId
|
||||
},
|
||||
dataType: 'json', //服务器返回json格式数据
|
||||
type: 'post', //HTTP请求类型
|
||||
timeout: 10000, //超时时间设置为10秒;
|
||||
success: function(data) {
|
||||
//console.log(data);//服务器返回响应,根据响应结果,分析是否登录成功;
|
||||
data = toJson(data);
|
||||
if (data.status == 1) {
|
||||
data = data.data;
|
||||
//console.log(data);
|
||||
userName.val(data.userName)
|
||||
userPhone.val(data.userPhone)
|
||||
$('.add_info').html(data.areaName)
|
||||
Textarea.val(data.userAddress)
|
||||
areaVal = data.areaId
|
||||
} else {
|
||||
// mui.alert('发生错误请刷新后重试!');
|
||||
mui.alert(data.msg)
|
||||
// location.reload();
|
||||
}
|
||||
},
|
||||
error: function(xhr, type, errorThrown) { //异常处理;
|
||||
// mui.alert(type);
|
||||
}
|
||||
});
|
||||
}
|
||||
mui.ajax(qlgUrl('app/areas/listQuery'), {
|
||||
data: {
|
||||
parentId: 0
|
||||
},
|
||||
dataType: 'json', //服务器返回json格式数据
|
||||
type: 'post', //HTTP请求类型
|
||||
timeout: 10000, //超时时间设置为10秒;
|
||||
success: function(data) { //服务器返回响应,根据响应结果,分析是否登录成功;
|
||||
data = toJson(data);
|
||||
if (data.status == 1) {
|
||||
data = data.data;
|
||||
var html = '<option value="">选择省</option>';
|
||||
$.each(data, function() {
|
||||
html += '<option value="' + this.areaId + '">' + this.areaName + '</option>'
|
||||
});
|
||||
$('#province').html(html);
|
||||
|
||||
} else {
|
||||
// mui.alert('发生错误请刷新后重试!');
|
||||
mui.alert(data.msg)
|
||||
// location.reload();
|
||||
}
|
||||
},
|
||||
error: function(xhr, type, errorThrown) { //异常处理;
|
||||
// mui.alert(type);
|
||||
}
|
||||
});
|
||||
|
||||
$('.scroll_out_t').on('tap', '#province', function() {
|
||||
if (isParentId == 1) {
|
||||
isParentId = 0;
|
||||
mui.ajax(qlgUrl('app/areas/listQuery'), {
|
||||
data: {
|
||||
parentId: 0
|
||||
},
|
||||
dataType: 'json', //服务器返回json格式数据
|
||||
type: 'post', //HTTP请求类型
|
||||
timeout: 10000, //超时时间设置为10秒;
|
||||
success: function(data) { //服务器返回响应,根据响应结果,分析是否登录成功;
|
||||
data = toJson(data);
|
||||
if (data.status == 1) {
|
||||
data = data.data;
|
||||
var html = '';
|
||||
$.each(data, function() {
|
||||
html += '<option value="' + this.areaId + '">' + this.areaName + '</option>'
|
||||
});
|
||||
$('#province').html(html);
|
||||
var province = data[0].areaId;
|
||||
mui.ajax(hyhUrl('app/areas/listQuery'), {
|
||||
data: {
|
||||
parentId: province
|
||||
},
|
||||
dataType: 'json', //服务器返回json格式数据
|
||||
type: 'post', //HTTP请求类型
|
||||
timeout: 10000, //超时时间设置为10秒;
|
||||
success: function(data) { //服务器返回响应,根据响应结果,分析是否登录成功;
|
||||
data = toJson(data);
|
||||
if (data.status == 1) {
|
||||
data = data.data;
|
||||
var html = '';
|
||||
$.each(data, function() {
|
||||
html += '<option value="' + this.areaId + '">' + this.areaName + '</option>'
|
||||
});
|
||||
$('#city').html(html);
|
||||
var city = data[0].areaId;
|
||||
mui.ajax(hyhUrl('app/areas/listQuery'), {
|
||||
data: {
|
||||
parentId: city
|
||||
},
|
||||
dataType: 'json', //服务器返回json格式数据
|
||||
type: 'post', //HTTP请求类型
|
||||
timeout: 10000, //超时时间设置为10秒;
|
||||
success: function(data) { //服务器返回响应,根据响应结果,分析是否登录成功;
|
||||
data = toJson(data);
|
||||
if (data.status == 1) {
|
||||
data = data.data;
|
||||
var html = '';
|
||||
$.each(data, function() {
|
||||
html += '<option value="' + this.areaId + '">' + this.areaName + '</option>'
|
||||
});
|
||||
$('#area').html(html);
|
||||
isCity = city;
|
||||
} else {
|
||||
mui.alert('发生错误请刷新后重试!');
|
||||
// location.reload();
|
||||
}
|
||||
},
|
||||
error: function(xhr, type, errorThrown) { //异常处理;
|
||||
// mui.alert(type);
|
||||
}
|
||||
});
|
||||
isProvince = province;
|
||||
} else {
|
||||
mui.alert('发生错误请刷新后重试!');
|
||||
// location.reload();
|
||||
}
|
||||
},
|
||||
error: function(xhr, type, errorThrown) { //异常处理;
|
||||
// mui.alert(type);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// mui.alert('发生错误请刷新后重试!');
|
||||
mui.alert(data.msg)
|
||||
// location.reload();
|
||||
}
|
||||
},
|
||||
error: function(xhr, type, errorThrown) { //异常处理;
|
||||
// mui.alert(type);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
})
|
||||
$('.scroll_out_t').on('change', '#province', function() {
|
||||
var province = $(this).val()
|
||||
//console.log(province)
|
||||
if (isProvince != province) {
|
||||
mui.ajax(qlgUrl('app/areas/listQuery'), {
|
||||
data: {
|
||||
parentId: province
|
||||
},
|
||||
dataType: 'json', //服务器返回json格式数据
|
||||
type: 'post', //HTTP请求类型
|
||||
timeout: 10000, //超时时间设置为10秒;
|
||||
success: function(data) { //服务器返回响应,根据响应结果,分析是否登录成功;
|
||||
data = toJson(data);
|
||||
if (data.status == 1) {
|
||||
data = data.data;
|
||||
var html = '<option value="">选择市</option>';
|
||||
$.each(data, function() {
|
||||
html += '<option value="' + this.areaId + '">' + this.areaName + '</option>'
|
||||
});
|
||||
$('#city').html(html);
|
||||
// var city = data[0].areaId;
|
||||
// mui.ajax(hyhUrl('app/areas/listQuery'), {
|
||||
// data: {
|
||||
// parentId: city
|
||||
// },
|
||||
// dataType: 'json', //服务器返回json格式数据
|
||||
// type: 'post', //HTTP请求类型
|
||||
// timeout: 10000, //超时时间设置为10秒;
|
||||
// success: function(data) { //服务器返回响应,根据响应结果,分析是否登录成功;
|
||||
// data = toJson(data);
|
||||
// if(data.status == 1) {
|
||||
// data = data.data;
|
||||
var html = '<option value="">选择区</option>';
|
||||
// $.each(data, function() {
|
||||
// html += '<option value="' + this.areaId + '">' + this.areaName + '</option>'
|
||||
// });
|
||||
$('#area').html(html);
|
||||
// isCity = city;
|
||||
// } else {
|
||||
// mui.alert('发生错误请刷新后重试!');
|
||||
// // location.reload();
|
||||
// }
|
||||
// },
|
||||
// error: function(xhr, type, errorThrown) { //异常处理;
|
||||
// // mui.alert(type);
|
||||
// }
|
||||
// });
|
||||
isProvince = province;
|
||||
} else {
|
||||
// mui.alert('发生错误请刷新后重试!');
|
||||
mui.alert(data.msg)
|
||||
// location.reload();
|
||||
}
|
||||
},
|
||||
error: function(xhr, type, errorThrown) { //异常处理;
|
||||
// mui.alert(type);
|
||||
}
|
||||
});
|
||||
}
|
||||
})
|
||||
$('.scroll_out_t').on('change', '#city', function() {
|
||||
var city = $(this).val()
|
||||
if (isCity != city) {
|
||||
mui.ajax(qlgUrl('app/areas/listQuery'), {
|
||||
data: {
|
||||
parentId: city,
|
||||
level: 2
|
||||
},
|
||||
dataType: 'json', //服务器返回json格式数据
|
||||
type: 'post', //HTTP请求类型
|
||||
timeout: 10000, //超时时间设置为10秒;
|
||||
success: function(data) { //服务器返回响应,根据响应结果,分析是否登录成功;
|
||||
data = toJson(data);
|
||||
if (data.status == 1) {
|
||||
data = data.data;
|
||||
var html = '<option value="">选择区</option>';
|
||||
$.each(data, function() {
|
||||
html += '<option value="' + this.areaId + '">' + this.areaName + '</option>'
|
||||
});
|
||||
$('#area').html(html);
|
||||
isCity = city;
|
||||
} else {
|
||||
mui.alert(data.msg)
|
||||
// mui.alert('发生错误请刷新后重试!');
|
||||
// location.reload();
|
||||
}
|
||||
},
|
||||
error: function(xhr, type, errorThrown) { //异常处理;
|
||||
// mui.alert(type);
|
||||
}
|
||||
});
|
||||
}
|
||||
})
|
||||
|
||||
$('.bc_btn').on('tap', function() {
|
||||
var isDefault = $('input:radio[name="isDefault"]:checked').val() ? $('input:radio[name="isDefault"]:checked').val() :
|
||||
0;
|
||||
areaVal = $('#area').val() ? $('#area').val() : areaVal;
|
||||
var data = {
|
||||
isDefault: isDefault,
|
||||
addressId: addressId,
|
||||
userName: $('#userName').val(),
|
||||
areaId: areaVal,
|
||||
userPhone: $('#userPhone').val(),
|
||||
userAddress: $('textarea').val(),
|
||||
}
|
||||
mui.ajax(hyhUrl('app/useraddress/edits'), {
|
||||
data: data,
|
||||
dataType: 'json', //服务器返回json格式数据
|
||||
type: 'post', //HTTP请求类型
|
||||
timeout: 10000, //超时时间设置为10秒;
|
||||
success: function(data) { //服务器返回响应,根据响应结果,分析是否登录成功;
|
||||
var data = toJson(data);
|
||||
if (data.status == 1) {
|
||||
mui.back();
|
||||
} else {
|
||||
mui.alert(data.msg)
|
||||
// mui.alert('发生错误请刷新后重试!');
|
||||
// location.reload();
|
||||
}
|
||||
},
|
||||
error: function(xhr, type, errorThrown) { //异常处理;
|
||||
// mui.alert(type);
|
||||
}
|
||||
});
|
||||
})
|
||||
$('.add_info').on('tap', function() {
|
||||
$('.address_info').css('display', 'block');
|
||||
$('.add_info').css('display', 'none');
|
||||
})
|
||||
|
||||
})
|
Reference in New Issue
Block a user