Bladeren bron

Merge remote-tracking branch 'origin/master'

sunyadv 5 jaren geleden
bovenliggende
commit
379e1f282a
1 gewijzigde bestanden met toevoegingen van 127 en 83 verwijderingen
  1. 127 83
      minigame/WebContent/lottery.html

+ 127 - 83
minigame/WebContent/lottery.html

@@ -27,89 +27,133 @@
             if(id == null || id == undefined || id == ""){
             	window.location.href = "https://wx.ttkuaiban.com/minigame";
             }
-        	
-//             $.post("./user/getWeiboConfigParam?url=https://wx.ttkuaiban.com/minigame/lottery.html", {}, function(resp) {
-//         		if (resp.code == 'error') {
-//         			console.log(resp.code);
-//         		}else{
-//         			window.WeiboJS.init({
-//         			    'appkey' : resp.data.appkey,
-//         			    'debug': true,
-//         			    'timestamp': resp.data.timestamp,
-//         			    'noncestr': resp.data.noncestr,
-//         			    'signature': resp.data.sign,
-//         			    'scope': [
-//         			        'getNetworkType',
-//         			        'networkTypeChanged',
-//         			        'getBrowserInfo',
-//         			        'checkAvailability',
-//         			        'setBrowserTitle',
-//         			        'openMenu',
-//         			        'setMenuItems',
-//         			        'menuItemSelected',
-//         			        'setSharingContent',
-//         			        'openImage',
-//         			        'scanQRCode',
-//         			        'pickImage',
-//         			        'getLocation',
-//         			        'pickContact',
-//         			        'apiFromTheFuture'
-//         			    ]
-//         			}, function(ret){
-//         			    alert('init done\n' + JSON.stringify(ret));/*DEBUG*/
-//         			});
-        			
-//         			WeiboJS.invoke("setSharingContent", {
-//         			    title: "抽奖页面测试标题",
-//         			    desc: "抽奖页面测试描述",
-//         			    icon: "https://wx.ttkuaiban.com/minigame/images/share_picture.png"
-//         			}, function(e) {
-//         	            alert("设置分享内容成功:" + JSON.stringify(e));
-//         	        });
-//         		}
-//             });
-        	
-            $.post("./user/getWxConfigParam?url=https://wx.ttkuaiban.com/minigame/lottery.html", {}, function(resp) {
-        		if (resp.code == 'error') {
-        			console.log(resp.code);
-        		}else{
-        			wx.config({
-        			    debug: false,
-        			    appId: 'wx749c84daac654e1e',
-        			    timestamp: resp.data.timestamp,
-        			    nonceStr: resp.data.noncestr,
-        			    signature: resp.data.sign,
-        			    jsApiList: ['onMenuShareTimeline', 'onMenuShareAppMessage', 'onMenuShareQQ', 'onMenuShareWeibo', 'onMenuShareQZone', 'showOptionMenu', 'hideAllNonBaseMenuItem', 'showAllNonBaseMenuItem']
-        			});
-        			wx.ready(function(){
-        				const share = {
-        			        title: "一秒变大厨,为远方的朋友做道菜吧!",
-        			        desc: "",
-        			        imgUrl: "https://wx.ttkuaiban.com/minigame/images/share_picture.png",
-        			        link: "https://wx.ttkuaiban.com/minigame/lottery.html",
-        			        success: function() {
-        			        	$.post("./prize/luckDrawAddShare", {uid: id}, function(resp) {
-        		    				if (resp.code == 'error') {
-        		    					console.log(resp.code);
-        		    				}else{
-        		    					//分享之后前端限制可抽奖次数+1
-        		    					limit--;
-        		    				}
-        		    			});
-        			        },
-        			        cancel: function() {}
-        			    };
-        			    wx.onMenuShareAppMessage(share);
-        			    wx.onMenuShareTimeline(share);
-        			    wx.onMenuShareQQ(share);
-        			    wx.onMenuShareQZone(share);
-        			    wx.onMenuShareWeibo(share);
-        			});
-        			wx.error(function(res){
-        				console.log(res);
-        			});
-        		};	
-        	});
+
+            var shareTitle = "一秒变大厨,为远方的朋友做道菜吧!";
+            var shareImg = "https://wx.ttkuaiban.com/minigame/images/share_picture.png";
+            var shareLink = "https://wx.ttkuaiban.com/minigame/lottery.html";
+            var ua = navigator.userAgent.toLowerCase();
+            if (ua.match(/microMessenger/i) == 'micromessenger') {
+                $.post("./user/getWxConfigParam?url=https://wx.ttkuaiban.com/minigame/lottery.html", {}, function(resp) {
+                    if (resp.code == 'error') {
+                        console.log(resp.code);
+                    }else{
+                        wx.config({
+                            debug: false,
+                            appId: 'wx749c84daac654e1e',
+                            timestamp: resp.data.timestamp,
+                            nonceStr: resp.data.noncestr,
+                            signature: resp.data.sign,
+                            jsApiList: ['onMenuShareTimeline', 'onMenuShareAppMessage', 'onMenuShareQQ', 'onMenuShareWeibo', 'onMenuShareQZone', 'showOptionMenu', 'hideAllNonBaseMenuItem', 'showAllNonBaseMenuItem']
+                        });
+                        wx.ready(function(){
+                            const share = {
+                                title: shareTitle,
+                                desc: "",
+                                imgUrl: shareImg,
+                                link: shareLink,
+                                success: function(res) {
+                                    console.log(res)
+                                },
+                                cancel: function() {}
+                            };
+                            wx.onMenuShareAppMessage(share);
+                            wx.onMenuShareTimeline(share);
+                            wx.onMenuShareQQ(share);
+                            wx.onMenuShareQZone(share);
+                            wx.onMenuShareWeibo(share);
+                        });
+
+                        wx.error(function(res){
+                            console.log(res);
+                        });
+                    };
+                });
+            } else if (ua.match(/weibo/i) == 'weibo') {
+                //weibo
+                var url = escape(location.href);
+                $.post("./user/getWeiboConfigParam?url=" + url, {}, function(resp) {
+                    if (resp.code == 'error') {
+                        console.log(resp.code);
+                    }else{
+                        window.WeiboJS.init({
+                            'appkey' : resp.data.appkey,
+                            'debug': false,
+                            'timestamp': parseInt(resp.data.timestamp),
+                            'noncestr': resp.data.noncestr,
+                            'signature': resp.data.sign,
+                            'scope': [
+                                'getNetworkType',
+                                'networkTypeChanged',
+                                'getBrowserInfo',
+                                'checkAvailability',
+                                'setBrowserTitle',
+                                'openMenu',
+                                'menuItemAvailable',
+                                'setMenuItems',
+                                'menuItemSelected',
+                                'setSharingContent',-
+                                    'openImage',
+                                'scanQRCode',
+                                'pickImage',
+                                'getLocation',
+                                'pickContact',
+                                'apiFromTheFuture'
+                            ]
+                        }, function(ret){
+                            WeiboJS.invoke("setSharingContent", {
+                                title: shareTitle,
+                                desc: "",
+                                icon: shareImg
+                            }, function(e) {
+    						    alert("1-设置分享内容成功:" + JSON.stringify(e));
+                            });
+                        });
+                    }
+                });
+            } else {}
+
+            //原微信部分
+            // $.post("./user/getWxConfigParam?url=https://wx.ttkuaiban.com/minigame/lottery.html", {}, function(resp) {
+        	// 	if (resp.code == 'error') {
+        	// 		console.log(resp.code);
+        	// 	}else{
+        	// 		wx.config({
+        	// 		    debug: false,
+        	// 		    appId: 'wx749c84daac654e1e',
+        	// 		    timestamp: resp.data.timestamp,
+        	// 		    nonceStr: resp.data.noncestr,
+        	// 		    signature: resp.data.sign,
+        	// 		    jsApiList: ['onMenuShareTimeline', 'onMenuShareAppMessage', 'onMenuShareQQ', 'onMenuShareWeibo', 'onMenuShareQZone', 'showOptionMenu', 'hideAllNonBaseMenuItem', 'showAllNonBaseMenuItem']
+        	// 		});
+        	// 		wx.ready(function(){
+        	// 			const share = {
+        	// 		        title: "一秒变大厨,为远方的朋友做道菜吧!",
+        	// 		        desc: "",
+        	// 		        imgUrl: "https://wx.ttkuaiban.com/minigame/images/share_picture.png",
+        	// 		        link: "https://wx.ttkuaiban.com/minigame/lottery.html",
+        	// 		        success: function() {
+        	// 		        	$.post("./prize/luckDrawAddShare", {uid: id}, function(resp) {
+        	// 	    				if (resp.code == 'error') {
+        	// 	    					console.log(resp.code);
+        	// 	    				}else{
+        	// 	    					//分享之后前端限制可抽奖次数+1
+        	// 	    					limit--;
+        	// 	    				}
+        	// 	    			});
+        	// 		        },
+        	// 		        cancel: function() {}
+        	// 		    };
+        	// 		    wx.onMenuShareAppMessage(share);
+        	// 		    wx.onMenuShareTimeline(share);
+        	// 		    wx.onMenuShareQQ(share);
+        	// 		    wx.onMenuShareQZone(share);
+        	// 		    wx.onMenuShareWeibo(share);
+        	// 		});
+        	// 		wx.error(function(res){
+        	// 			console.log(res);
+        	// 		});
+        	// 	};
+        	// });
             
             //进入和窗口缩放时重新设置内容位置
             setPosition();