Showing
1 changed file
with
17 additions
and
20 deletions
1 | -import { | ||
2 | - View | ||
3 | -} from 'yoho-mvc'; | ||
4 | 1 | ||
5 | let tip = require('plugin/tip'); | 2 | let tip = require('plugin/tip'); |
6 | 3 | ||
7 | -class GetAjax extends View { | ||
8 | - constructor() { | ||
9 | - super(); | ||
10 | - } | 4 | +let mvc = require('yoho-mvc'); |
5 | + | ||
6 | +class GetAjax { | ||
11 | 7 | ||
12 | getAjax() { | 8 | getAjax() { |
13 | let diaobj = {}; | 9 | let diaobj = {}; |
14 | 10 | ||
15 | - $.ajax({ | 11 | + let data = { |
16 | url: '/activity/getCoupon', | 12 | url: '/activity/getCoupon', |
17 | - async: false, | ||
18 | - success: function(result) { | ||
19 | - if (result && result.data && result.code === 200) { | ||
20 | - diaobj.num = parseInt(result.data.not_support_reasons, 10); | ||
21 | - diaobj.message = result.data.not_support_reasons_message; | ||
22 | - diaobj.title = result.data.not_support_reasons_title; | ||
23 | - diaobj.support = result.data.is_support; | ||
24 | - } else { | ||
25 | - tip.show('网络异常!'); | ||
26 | - } | ||
27 | - }, | ||
28 | - error: function() { | 13 | + async: false |
14 | + }; | ||
15 | + | ||
16 | + mvc.http(data).then(result => { | ||
17 | + if (result && result.data && result.code === 200) { | ||
18 | + diaobj.num = parseInt(result.data.not_support_reasons, 10); | ||
19 | + diaobj.message = result.data.not_support_reasons_message; | ||
20 | + diaobj.title = result.data.not_support_reasons_title; | ||
21 | + diaobj.support = result.data.is_support; | ||
22 | + } else { | ||
29 | tip.show('网络异常!'); | 23 | tip.show('网络异常!'); |
30 | } | 24 | } |
25 | + }).catch(() => { | ||
26 | + tip.show('网络断开了~~'); | ||
31 | }); | 27 | }); |
28 | + | ||
32 | return diaobj; | 29 | return diaobj; |
33 | } | 30 | } |
34 | } | 31 | } |
-
Please register or login to post a comment