123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316 |
- var projectUrl = 'https://sgmhks.sgmlink.com/sgm_txh_web/';
- const ajaxUrl = 'https://sgmhkstest-web.sgmlink.com/hks-card/'
- var isDev = false;
- var workWxAuthUrl = 'https://auth-shgm-wx.cw.sgmlink.com/auth/auth?url=https%3a%2f%2fsgmhks.sgmlink.com%2fsgm_weixin_card%2fapi%2fweixin%2fcp%2flogin%2fhome&appid=5ee8b1317b62a&extattr=name,avatar,weixinid,extraData.business_unit,extraData.business_dept,extraData.business_role_desc';
- const api = {
-
- myRecommendLog :'/api/sgm/activity/AllStaffMarketingFacade/myRecommendLog',
-
- recQueryStatus:'/api/sgm/activity/AllStaffMarketingFacade/recQueryStatus',
-
- getAuthUrl:'/jiinfo/weixin/WeiXinController/getAuthUrl',
-
- getJsapiTicket:'/jiinfo/weixin/WeiXinController/getJsapiTicket',
-
- findProvinceAndCity:'/api/sgm/weixin/card/ReplacementFacade/findProvinceAndCity',
-
- findPage:'/api/sgm/weixin/card/ReplacementFacade/findPage',
-
- getAuthCode :'/api/sgm/weixin/miniprogram/MpLoginFacade/login',
-
- register:'/api/sgm/weixin/card/LoginFacade/register',
-
- tokenLogin:'/api/sgm/weixin/card/MpLogin/tokenLogin',
-
- submit:'/api/sgm/activity/AllStaffMarketingFacade/submit',
-
- chooseEntity:'/api/sgm/activity/AllStaffMarketingFacade/chooseEntity',
-
- invite:'/api/sgm/activity/AllStaffMarketingFacade/invite',
-
- queryEntityList:'/api/sgm/activity/AllStaffMarketingFacade/queryEntityList',
-
- queryCarsList:'/api/sgm/weixin/marketing/TCpwxCarReadFacade/findPage',
-
- queryCarTypeList:'/api/sgm/weixin/marketing/TCpwxCarReadFacade/findCarTypeList',
-
- updateCount:'/api/sgm/weixin/marketing/TCpwxCarWriteFacade/updateCount',
-
- tallType:'/api/sgm/activity/AllStaffMarketingFacade/statistics',
-
- readAdvert:'/api/sgm/activity/AllStaffMarketingFacade/readAdvert',
-
- getAuthPhone:'/api/weixin/getAuthPhone',
-
- getCode:'/api/weixin/getCode',
-
- getFlag:'/api/sgm/weixin/card/PcwController/getFlag',
-
- addFlag:'/api/sgm/weixin/card/PcwController/addFlag',
-
- getDrawRemainingCount:`/api/sgm/weixin/card/PcwController/getDrawRemainingCount`,
-
- draw:`/api/sgm/weixin/card/PcwController/draw`,
-
- getMyPrize:`/api/sgm/weixin/card/PcwController/getMyPrize`,
-
- enterPage: `/api/sgm/weixin/card/PcwController/enterPage`,
- }
- function GetQueryString(name){
- var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
- var r = window.location.search.substr(1).match(reg);
-
- if(r!=null)return unescape(r[2].replace(/\<|\>|\(|\)|\{|\}|\;|\/|\`|\,|\"|\'|\%|\&|\$|\@|\\’|\ \”|\|/g,"")); return null;
- }
- String.prototype.replaceAll = function(s1,s2){
- return this.replace(new RegExp(s1,"gm"),s2);
- }
- function getTerminal(){
- var ua = navigator.userAgent.toLowerCase();
- if (/iphone|ipad|ipod/.test(ua)) {
- return "ios"
- } else if (/android/.test(ua)) {
- return "android"
- }else {
- return "pc"
- }
- }
- function showLoading(text){
- $('body').append(`<div class="pop_loading">${text||'加载中'}</div>`);
- }
- function hideLoading(){
- $('.pop_loading').eq(0).remove();
- }
- function post(option) {
- let url = option.url;
- let data = option.data || {};
-
-
-
-
-
- let success = option.success;
- let fail = option.fail;
- let complete=option.complete||function(){};
- let noToast = option.noToast || false;
- let noLoading = option.noLoading || false;
- if(!noLoading){
- showLoading()
- }
- $.ajax({
- url: ajaxUrl + url,
- data: JSON.stringify(data),
-
- xhrFields: {
- withCredentials: true
- },
- crossDomain: true,
- type: 'post',
- dataType: 'JSON',
- contentType: 'application/json; charset=UTF-8',
- beforeSend: function (request) {
- if(GetQueryString('token')){
- request.setRequestHeader("token", GetQueryString('token'));
- }
-
- },
- success: function(res) {
- console.log(res)
- if(!noLoading){
- hideLoading()
- }
-
- <<<<<<< HEAD
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- =======
- if(res.code=="99990004" || res.code=="99990005"){
-
-
-
-
-
- var ua= window.navigator.userAgent.toLowerCase()
- if(url.endsWith("myRecommendLog")){
-
- window.location.href = workWxAuthUrl;
- }else{
- getAuthUrl();
- }
- return;
- }
- >>>>>>> da8383baab1517166755c7051e43d21e5abd90dd
- if(res.code=='99990000'){
- success&&success(res)
- }else{
- if(!noToast){
- showToast('01',res.message)
- }
- if(fail){
- fail(res)
- }
- }
- }, complete:function(xhr, ts){
- complete(xhr,ts)
- },
- error:function (xhr,status,error){
- if(xhr.status==500){
- hideLoading();
- showToast('01','服务器错误')
- }
- }
- })
- }
- let isGetAuthUrl = false
- function getAuthUrl(){
- if(isGetAuthUrl){return false}
- isGetAuthUrl = true
- post({
- url:api.getAuthUrl,
- data:{
- url:window.location.href
- },
- noToast:true,
- noLoading:true,
- success:function(res){
- window.location.href=res.data;
- }
- })
- }
- function mpLogin(data,callback){
- post({
- url:api.tokenLogin,
- data:{
- token:data
- },
- noToast:true,
- noLoading:false,
- success:function(res){
- callback&&callback(res)
-
- }
- })
- }
- function showToast(code,message){
- if(code=='00'){
- var c='success';
- }else{
- var c='danger';
- }
- $('body').append('<div class="alert alert-'+c+'" role="alert">\
- <font style="vertical-align: inherit;">\
- <font style="vertical-align: inherit;">'+message+'</font>\
- </font>\
- </div>')
- setTimeout(function(){
- $('.alert').remove();
- },3000);
- }
- $(function(){
- let token = GetQueryString("token");
- console.log("token"+token);
- if(token&&window.location.href.indexOf('html/recommended.html')==-1){
- console.log("token"+token);
- mpLogin(token);
- }
- })
- function showShare(){
- let newClass = '';
- if(GetQueryString('token')){
- newClass = 'share_pop2'
- }
- $('body').append(`
- <div class="share_pop ${newClass}">
- <img src="https://sgmhks.sgmlink.com/hks_miniprogram/static/tjg/share_btn.png" class="share_btn" onclick="$('.share_pop').eq(0).remove()">
- </div>
- `)
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- }
|