Authored by lijing

接口联调

import {
View
} from 'yoho-mvc';
let tip = require('plugin/tip');
class GetAjax extends View {
constructor() {
super();
}
let mvc = require('yoho-mvc');
class GetAjax {
getAjax() {
let diaobj = {};
$.ajax({
let data = {
url: '/activity/getCoupon',
async: false,
success: function(result) {
if (result && result.data && result.code === 200) {
diaobj.num = parseInt(result.data.not_support_reasons, 10);
diaobj.message = result.data.not_support_reasons_message;
diaobj.title = result.data.not_support_reasons_title;
diaobj.support = result.data.is_support;
} else {
tip.show('网络异常!');
}
},
error: function() {
async: false
};
mvc.http(data).then(result => {
if (result && result.data && result.code === 200) {
diaobj.num = parseInt(result.data.not_support_reasons, 10);
diaobj.message = result.data.not_support_reasons_message;
diaobj.title = result.data.not_support_reasons_title;
diaobj.support = result.data.is_support;
} else {
tip.show('网络异常!');
}
}).catch(() => {
tip.show('网络断开了~~');
});
return diaobj;
}
}
... ...