123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- var qs = parseQueryString(window.location.href);
- var hostUrl = BASEURL;
- var returnUrl = qs.returnUrl;
- var token = qs.token;
- checkToken();
- if (qs.name) {
- $('.current-city span').text(qs.name).attr('data-code', qs.code);
- }
- $('#back').click(function() {
- window.webkit.messageHandlers.PopRootMessageHandler.postMessage({name:"1"});
- });
- $('.current-city').click(function() {
- var data = {
- name: $(".current-city span").html(),
- code: $(".current-city span").attr('data-code')
- }
- window.webkit.messageHandlers.CityLocationMessageHandler.postMessage(data);
- })
- function redirectToFailedReturnUrl(tid, result, failCode, reason) {
- var linkString = returnUrl.includes('?') ? '&' : '?';
- returnUrl += linkString + "result=" + result + "&tid=" + tid + "&token=" + token + "&failCode=" + failCode + "&reason=" + reason;
- window.location.href = returnUrl;
- }
- function showMsg(msg) {
- var msgBox = $('.alert-info');
- msgBox.children('p').text(msg);
- msgBox.show();
- setTimeout(function() {
- msgBox.hide();
- }, 30000);
- }
- function checkToken() {
- var getTokenInfo = $.ajax({
- type: 'GET',
- url: hostUrl + '/token?token=' + token + "&time=" + Math.round(Date.now() / 1000),
- timeout: 30000,
- contentType: 'application/json;charset=utf-8'
- });
- getTokenInfo.done(function(data) {
- if (data.returnUrl && !returnUrl) {
- returnUrl = data.returnUrl;
- }
- if (data.tid && data.region && data.loginLabel && data.inputData) {
- return;
- }
- $('body').show();
- getCityListAndRender();
- });
- getTokenInfo.fail(function(err) {
- $('body').show();
- showMsg('token校验失败:' + JSON.stringify(err.responseJSON.error));
- });
- }
- function getCityListAndRender() {
- $.ajax({
- type: "GET",
- url: hostUrl + '/city_list?type=fund&sort=true&token=' + token + '&time=' + Math.round(Date.now() / 1000),
- contentType: 'application/json;charset=utf-8',
- success: function(data) {
- return $(".city-list").CityPicker(data);
- },
- error: function(err) {
- return showMsg('获取城市列表失败:' + JSON.stringify(err.responseJSON.error));
- }
- });
- }
- function searchCity () {
- window.location.href = "choice_city.html?token=" + token + "&path=choose_city02";
- }
|