123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245 |
- var head= document.getElementsByTagName('head')[0];
- var WXscript= document.createElement('script');
- var shareUrl = 'https://sgmhks.sgmlink.com/sgm_txh_web/html/recommended.html'
- var thisUrl = 'https://sgmhks.sgmlink.com/sgm_txh_web/html/recommend.html'
- WXscript.type= 'text/javascript';
- var shareConfig = {
- title: '上汽通用员工推荐购',
- desc: '通过内部推荐链接预约活动,享员工推荐福利',
- link: shareUrl,
- imgUrl: projectUrl+'images/share.jpg',
- }
- var ua= window.navigator.userAgent.toLowerCase()
- if(ua.indexOf('wxwork')>-1&&!isDev){
- WXscript.src = '//res.wx.qq.com/open/js/jweixin-1.2.0.js'
- head.appendChild(WXscript);
- WXscript.onload =function(){
- WXscript= document.createElement('script');
- WXscript.type= 'text/javascript';
- WXscript.src = '//auth-shgm-wx.cw.sgmlink.com/qywechat.js?debug=false&apis=checkJsApi,onMenuShareAppMessage,onMenuShareWechat,onMenuShareTimeline,shareAppMessage,shareWechatMessage,hideMenuItems'
- head.appendChild(WXscript);
- WXscript.onload =function(){
- wxReady();
- }
- }
- }else if(!isDev){
- WXscript.src= 'https://res.wx.qq.com/open/js/jweixin-1.6.0.js';
- head.appendChild(WXscript);
- WXscript.onload =function() {
- post({
- url: api.getJsapiTicket,
- data: {
- url: window.location.href
- },
- noToast: true,
- noLoading: true,
- success: function (res) {
- let conf = res.data;
- conf.jsApiList = ['getLocation', 'updateAppMessageShareData', 'updateTimelineShareData', 'openAddress','hideMenuItems']
- wxReady();
-
- wx.config(conf);
- }
- })
- }
- }
- function wxReady() {
-
- wx.ready(function () {
-
- try{
- setShare()
- }catch(err){
- }
- })
- wx.error(function(res){
- console.error(res);
-
- })
- };
- function setShare(){
- if(ua.indexOf('wxwork')>-1){
- wx.showOptionMenu();
- wx.showAllNonBaseMenuItem();
- wx.hideMenuItems({
- menuList: []
- });
- }else{
- wx.hideMenuItems({
- menuList: ['menuItem:share:qq','menuItem:share:weiboApp','menuItem:share:QZone','menuItem:copyUrl','menuItem:openWithSafari','menuItem:openWithQQBrowser']
- });
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
- try {
- wx.onMenuShareTimeline({
- title: shareConfig.title,
- link: shareConfig.link,
- imgUrl: shareConfig.imgUrl,
- success: function () {
-
- console.log("updateTimelineShareData");
- tallType(0)
- },
- error: function (e) {
- console.error(e);
- }
- });
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- wx.onMenuShareWechat({
- title: shareConfig.title,
- desc: shareConfig.desc,
- link: shareConfig.link,
- imgUrl: shareConfig.imgUrl,
- success: function () {
-
-
- tallType(0)
- },
- cancel: function (e) {
-
- }
- });
- wx.onMenuShareAppMessage({
- title: shareConfig.title,
- desc: shareConfig.desc,
- link: shareConfig.link,
- imgUrl: shareConfig.imgUrl,
- success: function () {
-
-
- tallType(0)
- },
- cancel: function () {
-
- }
- });
- }catch (e) {
- }
- try {
- wx.updateAppMessageShareData({
- title: shareConfig.title,
- desc: shareConfig.desc,
- link: shareConfig.link,
- imgUrl: shareConfig.imgUrl,
- success: function () {
-
- tallType(0)
- }
- });
- wx.updateTimelineShareData({
- title: shareConfig.title,
- link: shareConfig.link,
- imgUrl: shareConfig.imgUrl,
- success: function () {
-
- tallType(0)
- },
- error: function (e) {
- console.error(e);
- }
- });
- }catch (e) {
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- }
- function tallType(params) {
- post({
- url:api.tallType,
- data:{
- type:params
- }
- })
- }
|