123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154 |
- var qs = parseQueryString(window.location.href);
- var hostUrl = BASEURL;
- var returnUrl = qs.returnUrl;
- var token = qs.token;
- var addressName = '';
- var local_city = localStorage.getItem("city");
- if(local_city){
-
- }else{
-
- getAddress();
- }
- checkToken();
- $('#back').click(function() {
- if (document.referrer.includes('fund_h5_api.html')) {
- window.location.href = document.referrer;
- } else {
- redirectToFailedReturnUrl('', 'failed', 1020, '退出公积金查询页');
- }
- });
- $('.current-city').click(function() {
- var flag = false;
- var cityName = $('.current-city span').text();
- var cityCode = $('.current-city span').attr('data-code');
- tips.find(function(item, index) {
- if(item.region == $('.current-city span').text()){
- flag = true;
- if (document.referrer.includes('&name=')) {
- window.location.href = document.referrer.replace(/&name=[^&]+&code=[^&]+/, '&name=' + cityName + '&code=' + cityCode);
- } else {
- window.location.href = './fund_h5_api.html?token=' + token + '&name=' + cityName + '&code=' + cityCode;
- }
- }
- })
- if(!flag){
- window.location.href="no_open_city.html?cityName=" + $('.current-city span').text();
- }
- })
- function redirectToFailedReturnUrl(tid, result, failCode, reason) {
- if (returnUrl.indexOf('?') < 0) {
- returnUrl += "?result=" + result + "&tid=" + tid + "&token=" + token + "&failCode=" + failCode + "&reason=" + reason;
- } else {
- returnUrl += "&result=" + result + "&tid=" + tid + "&token=" + token + "&failCode=" + failCode + "&reason=" + reason;
- }
- window.sessionStorage.clear();
- 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) {
- window.location.href = './fund_h5_api.html?token=' + token + "&time=" + Math.round(Date.now() / 1000);
- 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 getAddress () {
- var code = '';
- var map = new BMap.Map("allmap");
- var point = new BMap.Point(116.331398,39.897445);
- map.centerAndZoom(point,12);
-
- var geolocation = new BMap.Geolocation();
-
- geolocation.enableSDKLocation();
- geolocation.getCurrentPosition(function(r){
- if(this.getStatus() == BMAP_STATUS_SUCCESS){
- var mk = new BMap.Marker(r.point);
- map.addOverlay(mk);
- map.panTo(r.point);
- addressName = r.address.city;
- localStorage.setItem("city",addressName);
- }
- else {
- }
-
- if (addressName.indexOf("市") != -1) {
- addressName = addressName.replace('市', '');
- console.log(addressName)
- tips.find(function(item, index) {
- if(item.region == addressName){
- $('.current-city span').text(addressName).attr('data-code', item.regionCode);
- }
- })
- }
- });
-
- }
|