123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316 |
- // 请求地址
- // var ajaxUrl= 'https://sgmhks.sgmlink.com/sgm_weixin_card';
- var projectUrl = 'https://sgmhks.sgmlink.com/sgm_txh_web/';
- // 测试地址
- // var ajaxUrl= 'http://shaopf.jiinfo.cn/';
- const ajaxUrl = 'https://sgmhkstest-web.sgmlink.com/hks-card/'
- // const ajaxUrl = 'https://txh.suggest.vip'
- // var projectUrl = 'https://sgmhks.sgmlink.com/sgm_weixin_card_web/';
- var isDev = false;
- // var ajaxUrl= 'https://txh.suggest.vip';
- //var workWxAuthUrl = 'https://auth2-shgm.qyhub.cn/auth/auth?url=https%3a%2f%2fsgmhks.sgmlink.com%2fsgm_weixin_card%2fapi%2fweixin%2fcp%2flogin%2fhome&appid=584e2fd227448&extattr=name,avatar,weixinid,extraData.business_unit,extraData.business_dept,extraData.business_role_desc';
- 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';
- // var workWxAuthUrl = 'https%3a%2f%2fsgmhkstest-web.sgmlink.com%2fhks-card%2fapi%2fweixin%2fcp%2flogin%2fhome&appid=5836556fa9d9a&extattr=name,avatar,ldap_userid,weixinid,extraData.sex,extraData.birthdate,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',
- //小程序token登录
- 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告知行为类型
- 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',
- // flag
- addFlag:'/api/sgm/weixin/card/PcwController/addFlag',
- //获取抽奖剩余次数
- getDrawRemainingCount:`/api/sgm/weixin/card/PcwController/getDrawRemainingCount`,
- //抽奖
- draw:`/api/sgm/weixin/card/PcwController/draw`,
- //根据渠道ID查询获奖信息
- getMyPrize:`/api/sgm/weixin/card/PcwController/getMyPrize`,
- //查询页面
- enterPage: `/api/sgm/weixin/card/PcwController/enterPage`,
- }
- //防止安卓input导致页面变形
- //获取url参数
- 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;
- }
- //添加replaceAll函数
- 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 || {};
- // data = {...data,
- // cpUserParam:{
- // cpUserId:1234
- // }
- // }
- 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),
- // 将XHR对象的withCredentials设为true
- 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()
- }
- // debugger;
- <<<<<<< HEAD
- // if(res.code=="99990004" || res.code=="99990005"){
- // //window.location.href=res.data;
- // if(GetQueryString('token')){
- // mpLogin();
- // return;
- // }
- // var ua= window.navigator.userAgent.toLowerCase()
- // if(url.endsWith("myRecommendLog")){
- // //alert('进入企业微信')
- // window.location.href = workWxAuthUrl;
- // }else{
- // getAuthUrl();
- // }
- // return;
- // }
- =======
- if(res.code=="99990004" || res.code=="99990005"){
- //window.location.href=res.data;
- // if(GetQueryString('token')){
- // mpLogin();
- // return;
- // }
- var ua= window.navigator.userAgent.toLowerCase()
- if(url.endsWith("myRecommendLog")){
- //alert('进入企业微信')
- 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)
- //showToast(res.code,res.message);
- }
- })
- }
- //提示框
- 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>
- `)
- //自定义转发到微信
- // try{
- // wx.invoke(
- // "shareWechatMessage", {
- // title: shareConfig.title, // 分享标题
- // desc: '', // 分享描述
- // link: shareConfig.link, // 分享链接
- // imgUrl: shareConfig.imgUrl // 分享封面
- // }, function(res) {
- // alert(res);
- // if (res.err_msg == "shareWechatMessage:ok") {
- // }
- // }
- // );
- // }catch(err){
- // alert(err)
- // }
- // alert(111);
- }
|