关于apicloud开发中对vue和ajax方法的封装
先上图封装js//封装方法function Ardo(id, mydata, pagesize){var ardo = new Vue({el: '#'+id,data: {msg: '',status: 1,p: pagesize,mydata:...
·
先上图
封装js
//封装方法
function Ardo(id, mydata, pagesize){
var ardo = new Vue({
el: '#'+id,
data: {
msg: '',
status: 1,
p: pagesize,
mydata:mydata
}
});
return ardo;
}
//封装方法ajax
function ArdoAjax(url, req, calback) {
api.ajax({
url: url,
method: 'post',
timeout: 5,
data: {
values: req
}
}, function(ret, err) {
calback(ret, err);
});
}
调用方法:【vue】
var mydata = {
"id": 587,
"mobile": "18290073076",
"loadType": "1",
"daiKuanFee": "8000",
"daiKuanQiXian": "2",
"cityName": "北京",
"userName": "邓宇邵齐",
"age": "29",
"sex": "男",
"zhiYe": "4",
"workName": "私企或民企",
"workAge": "24个月以上",
"gongzi": "6000~9999元",
"sheBao": "无社保",
"gongJiJin": "无公积金",
"descInfo": "",
"state": "1",
"createTime": "2018-01-18 18:07:08.0",
"carType": "2",
"isHasHouse": "1",
"fuZhai": "无负债",
"xinYongRecord": "5"
};
var ardo = Ardo('content', mydata);
调用方法:ajax
var req = {
token: token,
deviceid: api.deviceId,
id:id
}
ArdoAjax(loanUserInfoDetailUrl, req, calbackfun);
function calbackfun(ret, err){
if(ret.code===0){
var loan_info = ret.data;
ardo.mydata.id = loan_info.id;
ardo.mydata.mobile = loan_info.mobile;
ardo.mydata.loadType = loan_info.loadType;
ardo.mydata.daiKuanFee = loan_info.daiKuanFee;
ardo.mydata.daiKuanQiXian = loan_info.daiKuanQiXian;
ardo.mydata.cityName = loan_info.cityName;
ardo.mydata.userName = loan_info.userName;
ardo.mydata.age = loan_info.age;
ardo.mydata.sex = loan_info.sex;
ardo.mydata.zhiYe = loan_info.zhiYe;
ardo.mydata.workName = loan_info.workName;
ardo.mydata.workAge = loan_info.workAge;
ardo.mydata.gongzi = loan_info.gongzi;
ardo.mydata.sheBao = loan_info.sheBao;
ardo.mydata.gongJiJin = loan_info.gongJiJin;
ardo.mydata.descInfo = loan_info.descInfo;
ardo.mydata.state = loan_info.state;
ardo.mydata.createTime = loan_info.createTime;
ardo.mydata.carType = loan_info.carType;
ardo.mydata.isHasHouse = loan_info.isHasHouse;
ardo.mydata.fuZhai = loan_info.fuZhai;
ardo.mydata.xinYongRecord = loan_info.xinYongRecord;
}else{
api.alert({ msg: JSON.stringify(ret.message) });
}
}
更多推荐
已为社区贡献2条内容
所有评论(0)