Merge branch 'feature/installment2a' into release/4.9.2
Showing
7 changed files
with
130 additions
and
24 deletions
@@ -476,7 +476,9 @@ const postAccount = (params) => { | @@ -476,7 +476,9 @@ const postAccount = (params) => { | ||
476 | return api.get('', _.assign({ | 476 | return api.get('', _.assign({ |
477 | method: 'user.instalment.bindingCards', | 477 | method: 'user.instalment.bindingCards', |
478 | debug: 'XYZ' | 478 | debug: 'XYZ' |
479 | - }, params)); | 479 | + }, params), { |
480 | + timeout: 6000 | ||
481 | + }); | ||
480 | }; | 482 | }; |
481 | 483 | ||
482 | module.exports = { | 484 | module.exports = { |
@@ -13,7 +13,7 @@ | @@ -13,7 +13,7 @@ | ||
13 | <input id="list-{{key}}" type="checkbox" class="installment-check-btn" {{#if isChecked}}checked{{/if}}/> | 13 | <input id="list-{{key}}" type="checkbox" class="installment-check-btn" {{#if isChecked}}checked{{/if}}/> |
14 | <label for="list-{{key}}"> | 14 | <label for="list-{{key}}"> |
15 | <div class="cont"> | 15 | <div class="cont"> |
16 | - <p>¥{{currNoFeeAmt}}</p> | 16 | + <p>¥{{currAmt}}</p> |
17 | <p>【全{{stage}}期】{{billInfo}}</p> | 17 | <p>【全{{stage}}期】{{billInfo}}</p> |
18 | </div> | 18 | </div> |
19 | </label> | 19 | </label> |
@@ -46,6 +46,7 @@ $('input').on('input', function() { | @@ -46,6 +46,7 @@ $('input').on('input', function() { | ||
46 | 46 | ||
47 | applyButton.on('click', function() { | 47 | applyButton.on('click', function() { |
48 | var self = this; | 48 | var self = this; |
49 | + var ret = false; | ||
49 | 50 | ||
50 | if (!flag || $(this).hasClass('disabled') || !validateForm()) { | 51 | if (!flag || $(this).hasClass('disabled') || !validateForm()) { |
51 | return false; | 52 | return false; |
@@ -74,17 +75,24 @@ applyButton.on('click', function() { | @@ -74,17 +75,24 @@ applyButton.on('click', function() { | ||
74 | 75 | ||
75 | if (data.code === 200) { | 76 | if (data.code === 200) { |
76 | params.params.status = 1; | 77 | params.params.status = 1; |
78 | + ret = true; | ||
79 | + } else if (data.code === 500) { | ||
80 | + tip.show('连接超时'); | ||
81 | + flag = true; | ||
82 | + } else { | ||
83 | + params.params.message = data.message; | ||
84 | + ret = true; | ||
77 | } | 85 | } |
78 | 86 | ||
79 | url += encodeURIComponent(JSON.stringify(params)); | 87 | url += encodeURIComponent(JSON.stringify(params)); |
80 | 88 | ||
81 | $(self).attr('href', url); | 89 | $(self).attr('href', url); |
82 | - return true; | ||
83 | }, | 90 | }, |
84 | error: function() { | 91 | error: function() { |
85 | tip.show('网络断开连接了~'); | 92 | tip.show('网络断开连接了~'); |
86 | flag = true; | 93 | flag = true; |
87 | - return false; | ||
88 | } | 94 | } |
89 | }); | 95 | }); |
96 | + | ||
97 | + return ret; | ||
90 | }); | 98 | }); |
1 | var $ = require('yoho-jquery'); | 1 | var $ = require('yoho-jquery'); |
2 | var tip = require('../plugin/tip'); | 2 | var tip = require('../plugin/tip'); |
3 | +var yohoApp = require('../yoho-app'); | ||
3 | 4 | ||
4 | var Timer = function() { | 5 | var Timer = function() { |
5 | this.counter = 0; | 6 | this.counter = 0; |
@@ -35,7 +36,9 @@ var validateForm = function() { | @@ -35,7 +36,9 @@ var validateForm = function() { | ||
35 | formModel.mobile && | 36 | formModel.mobile && |
36 | formModel.snsCheckCode && | 37 | formModel.snsCheckCode && |
37 | formModel.agreements === 'on') { | 38 | formModel.agreements === 'on') { |
38 | - applyButton.removeClass('disabled'); | 39 | + if (!applyButton.data('running')) { |
40 | + applyButton.removeClass('disabled'); | ||
41 | + } | ||
39 | ret = true; | 42 | ret = true; |
40 | } else { | 43 | } else { |
41 | applyButton.addClass('disabled'); | 44 | applyButton.addClass('disabled'); |
@@ -162,18 +165,18 @@ $('#send-sms').click(function() { | @@ -162,18 +165,18 @@ $('#send-sms').click(function() { | ||
162 | 165 | ||
163 | // 输入框改变时同时更新模型 | 166 | // 输入框改变时同时更新模型 |
164 | /* | 167 | /* |
165 | -$('input').on('change', function() { | ||
166 | - var name = $(this).attr('name'); | 168 | + $('input').on('change', function() { |
169 | + var name = $(this).attr('name'); | ||
167 | 170 | ||
168 | - if ($(this).is(':checkbox')) { | ||
169 | - formModel[name] = $(this).is(':checked') ? $(this).val() : null; | ||
170 | - } else { | ||
171 | - formModel[name] = $(this).val(); | ||
172 | - } | 171 | + if ($(this).is(':checkbox')) { |
172 | + formModel[name] = $(this).is(':checked') ? $(this).val() : null; | ||
173 | + } else { | ||
174 | + formModel[name] = $(this).val(); | ||
175 | + } | ||
173 | 176 | ||
174 | - validateForm(); | ||
175 | -}); | ||
176 | -*/ | 177 | + validateForm(); |
178 | + }); | ||
179 | + */ | ||
177 | 180 | ||
178 | // validateForm(); | 181 | // validateForm(); |
179 | 182 | ||
@@ -198,14 +201,17 @@ setInterval(function() { | @@ -198,14 +201,17 @@ setInterval(function() { | ||
198 | $('#apply-button').click(function() { | 201 | $('#apply-button').click(function() { |
199 | var ret = false; | 202 | var ret = false; |
200 | var that = $(this); | 203 | var that = $(this); |
204 | + var asyncMode = yohoApp.isiOS; | ||
201 | 205 | ||
202 | if ($(this).hasClass('disabled') || !validateForm()) { | 206 | if ($(this).hasClass('disabled') || !validateForm()) { |
203 | return false; | 207 | return false; |
208 | + } else { | ||
209 | + $(this).addClass('disabled').text('处理中...').data('running', true); | ||
204 | } | 210 | } |
205 | 211 | ||
206 | $.ajax({ | 212 | $.ajax({ |
207 | method: 'get', | 213 | method: 'get', |
208 | - async: false, | 214 | + async: asyncMode, |
209 | url: '/home/installment/starting-service/check-verify-code', | 215 | url: '/home/installment/starting-service/check-verify-code', |
210 | data: { | 216 | data: { |
211 | mobile: formModel.mobile, | 217 | mobile: formModel.mobile, |
@@ -217,7 +223,7 @@ $('#apply-button').click(function() { | @@ -217,7 +223,7 @@ $('#apply-button').click(function() { | ||
217 | method: 'post', | 223 | method: 'post', |
218 | url: '/home/installment/activate-service', | 224 | url: '/home/installment/activate-service', |
219 | data: formModel, | 225 | data: formModel, |
220 | - async: false | 226 | + async: asyncMode |
221 | }); | 227 | }); |
222 | } else { | 228 | } else { |
223 | clearVerifyCode(); | 229 | clearVerifyCode(); |
@@ -226,8 +232,12 @@ $('#apply-button').click(function() { | @@ -226,8 +232,12 @@ $('#apply-button').click(function() { | ||
226 | }).then(function(result) { | 232 | }).then(function(result) { |
227 | var params; | 233 | var params; |
228 | 234 | ||
235 | + that.removeClass('disabled').text('下一步').data('running', false); | ||
236 | + | ||
229 | if (!result) { | 237 | if (!result) { |
230 | - return; | 238 | + result = { |
239 | + code: 500 | ||
240 | + }; | ||
231 | } | 241 | } |
232 | 242 | ||
233 | params = { | 243 | params = { |
@@ -238,12 +248,21 @@ $('#apply-button').click(function() { | @@ -238,12 +248,21 @@ $('#apply-button').click(function() { | ||
238 | }; | 248 | }; |
239 | 249 | ||
240 | if (result.code === 200 && result.data) { | 250 | if (result.code === 200 && result.data) { |
241 | - that.attr('href', location.pathname + '?openby:yohobuy=' + encodeURIComponent(JSON.stringify(params))); | 251 | + if (asyncMode) { |
252 | + yohoApp.invokeMethod('go.instalmentActivated', params.params); | ||
253 | + } else { | ||
254 | + that.attr('href', location.pathname + '?openby:yohobuy=' + encodeURIComponent(JSON.stringify(params))); | ||
255 | + } | ||
256 | + | ||
242 | ret = true; | 257 | ret = true; |
243 | } else if (result.code === 500) { | 258 | } else if (result.code === 500) { |
244 | // 接口可能超时返回审核中 by 孟令阶 | 259 | // 接口可能超时返回审核中 by 孟令阶 |
245 | params.params.status = '1'; | 260 | params.params.status = '1'; |
246 | - that.attr('href', location.pathname + '?openby:yohobuy=' + encodeURIComponent(JSON.stringify(params))); | 261 | + if (asyncMode) { |
262 | + yohoApp.invokeMethod('go.instalmentActivated', params.params); | ||
263 | + } else { | ||
264 | + that.attr('href', location.pathname + '?openby:yohobuy=' + encodeURIComponent(JSON.stringify(params))); | ||
265 | + } | ||
247 | ret = true; | 266 | ret = true; |
248 | } else { | 267 | } else { |
249 | tip.show(result.message); | 268 | tip.show(result.message); |
@@ -19,7 +19,7 @@ var repayment = new Repayment({ | @@ -19,7 +19,7 @@ var repayment = new Repayment({ | ||
19 | index: li.index(), | 19 | index: li.index(), |
20 | orderCode: li.data('billNo'), | 20 | orderCode: li.data('billNo'), |
21 | termNo: li.data('currterm'), | 21 | termNo: li.data('currterm'), |
22 | - amount: parseFloat(li.data('currnofeeamt')), | 22 | + amount: parseFloat(li.data('curramt')), |
23 | fee: parseFloat(li.data('currfee')) + 0 | 23 | fee: parseFloat(li.data('currfee')) + 0 |
24 | }; | 24 | }; |
25 | 25 | ||
@@ -49,10 +49,10 @@ $(CHECKBOX_SELECTOR + ':checkbox').click(function() { | @@ -49,10 +49,10 @@ $(CHECKBOX_SELECTOR + ':checkbox').click(function() { | ||
49 | billNo = $(self).parent().data('billNo'), | 49 | billNo = $(self).parent().data('billNo'), |
50 | li = $('li[data-bill-no=' + billNo + ']'), | 50 | li = $('li[data-bill-no=' + billNo + ']'), |
51 | selection = li.find('input:checked'), | 51 | selection = li.find('input:checked'), |
52 | - lastIndex = li.eq(0).index(); | 52 | + lastIndex = li.eq(0).data('currterm'); |
53 | 53 | ||
54 | selection.parent().each(function(index, sel) { | 54 | selection.parent().each(function(index, sel) { |
55 | - var key = $(sel).index(); | 55 | + var key = $(sel).data('currterm'); |
56 | 56 | ||
57 | if ((key + 1) - lastIndex > 1) { | 57 | if ((key + 1) - lastIndex > 1) { |
58 | isSkipped = true; | 58 | isSkipped = true; |
public/js/yoho-app.js
0 → 100644
1 | +/** | ||
2 | + * YOHO-SDK | ||
3 | + * | ||
4 | + * 与原生 APP 交互的代码 | ||
5 | + * 所有函数要做降级处理 | ||
6 | + * 假如不是 YOHO App,在浏览器实现对应的功能 | ||
7 | + * 浏览器不支持的功能,给出提示,控制台不能报错,不影响后续代码执行 | ||
8 | + * | ||
9 | + * 希望能与 微信 JS-SDK 一样方便 | ||
10 | + */ | ||
11 | +var tip = require('./plugin/tip'); | ||
12 | + | ||
13 | +/* 空方法 */ | ||
14 | +var emptyFn = function() {}; | ||
15 | + | ||
16 | +/* 提示信息 */ | ||
17 | +var tipInfo = '暂不支持,请在YOHO!BUY应用中打开'; | ||
18 | + | ||
19 | +var yoho = { | ||
20 | + /** | ||
21 | + * 判断是否是 APP | ||
22 | + */ | ||
23 | + isApp: /YohoBuy/i.test(navigator.userAgent || ''), | ||
24 | + isiOS: /\(i[^;]+;( U;)? CPU.+Mac OS X/i.test(navigator.userAgent || ''), | ||
25 | + isAndroid: /Android/i.test(navigator.userAgent || ''), | ||
26 | + | ||
27 | + /** | ||
28 | + * JS 与 APP 共享的对象 | ||
29 | + */ | ||
30 | + data: window.yohoInterfaceData, | ||
31 | + | ||
32 | + ready(callback) { | ||
33 | + if (this.isApp) { | ||
34 | + document.addEventListener('deviceready', callback); | ||
35 | + } else { | ||
36 | + return callback(); | ||
37 | + } | ||
38 | + }, | ||
39 | + | ||
40 | + /** | ||
41 | + * 调用APP原生方法 | ||
42 | + * @param method 方法名称 | ||
43 | + * @param args 传递给 APP 的参数 {"index":tab_index} | ||
44 | + * @param success 调用成功的回调方法 | ||
45 | + * @param fail 调用失败的回调方法 | ||
46 | + */ | ||
47 | + invokeMethod(method, args, success, fail) { | ||
48 | + var appInterface = window.yohoInterface; | ||
49 | + | ||
50 | + if (this.isApp && appInterface) { | ||
51 | + appInterface.triggerEvent(success || emptyFn, fail || emptyFn, { | ||
52 | + method: method, | ||
53 | + arguments: args | ||
54 | + }); | ||
55 | + } else { | ||
56 | + tip.show(tipInfo); | ||
57 | + } | ||
58 | + }, | ||
59 | + | ||
60 | + /** | ||
61 | + * 原生调用 JS 方法 | ||
62 | + * @param name 方法名 | ||
63 | + * @param callback 回调 | ||
64 | + */ | ||
65 | + addNativeMethod(name, callback) { | ||
66 | + var appInterface = window.yohoInterface; | ||
67 | + | ||
68 | + // 延迟 500ms 注入 | ||
69 | + setTimeout(function() { | ||
70 | + if (appInterface) { | ||
71 | + appInterface[name] = callback; | ||
72 | + } | ||
73 | + }, 500); | ||
74 | + } | ||
75 | +}; | ||
76 | + | ||
77 | +module.exports = yoho; |
-
Please register or login to post a comment