jack 7 years ago
parent
commit
a867d89975
1 changed files with 107 additions and 0 deletions
  1. 107 0
      app/js/moreItem.js

+ 107 - 0
app/js/moreItem.js

1
mui.ready(function(){
2
	mui.plusReady(function(){
3
		var self = plus.webview.currentWebview();
4
		plus.nativeUI.closeWaiting();
5
		plus.webview.currentWebview().show("slide-in-right", 150);
6
		 
7
		/*微信及微信朋友圈分享专家*/
8
	var auths, shares;
9
	plus.oauth.getServices(function(services) {
10
		auths = {};
11
		for(var i in services) {
12
			var t = services[i];
13
			auths[t.id] = t;
14

15
		}
16
	}, function(e) {
17
		alert("获取登录服务列表失败:" + e.message + " - " + e.code);
18
	});
19
	plus.share.getServices(function(services) {
20

21
		shares = {};
22
		for(var i in services) {
23

24
			var t = services[i];
25

26
			shares[t.id] = t;
27

28
		}
29
	}, function(e) {
30
		alert("获取分享服务列表失败:" + e.message + " - " + e.code);
31
	});
32
	mui("#shareBlock").on("tap", "li", function() {
33
		document.getElementById("shareBlock").style.display = "none";
34
		document.getElementById("maskBlack").style.display = "none";
35
		var oFen = this.getElementsByTagName("span")[0].innerHTML;
36
		
37
		if(oFen == "微信好友") {
38
			var share = buildShareService("weixin");
39
			if(share) {
40
				shareMessage(share, "WXSceneSession", self.data);
41
			}
42
		} else if(oFen == "微信朋友圈") {
43
			var share = buildShareService("weixin");
44
			if(share) {
45
				shareMessage(share, "WXSceneSession",  self.data);
46
			}
47
		} else if(oFen == "新浪微博") {
48
			var share = buildShareService("sinaweibo");
49
			if(share) {
50
				shareMessage(share, "sinaweibo", self.weiboData);
51
			}
52
		}
53

54
	})
55

56
	function buildShareService(ttt) {
57
		var share = shares[ttt];
58
		if(share) {
59
			if(share.authenticated) {
60
				console.log("---已授权---");
61
			} else {
62
				console.log("---未授权---");
63
				share.authorize(function() {
64
					console.log('授权成功...')
65
				}, function(e) {
66
					alert("认证授权失败:" + e.code + " - " + e.message);
67
					return null;
68
				});
69
			}
70
			return share;
71
		} else {
72
			alert("没有获取微信分享服务");
73
			return null;
74
		}
75

76
	}
77

78
	function shareMessage(share, ex, msg) {
79
		msg.extra = {
80
			scene: ex
81
		};
82
		share.send(msg, function() {
83
			plus.nativeUI.closeWaiting();
84
			if(plus.storage.getItem('userid')) {
85
				shareAddIntegral(3);
86
			}
87

88
		}, function(e) {
89
			console.log(JSON.stringify(e))
90
			plus.nativeUI.closeWaiting();
91
			if(e.code == -2) {
92
				plus.nativeUI.toast('已取消分享', {
93
					verticalAlign: 'center'
94
				});
95
			}
96
		});
97
	}
98
	document.getElementById("corrEssor").addEventListener('tap',function(){
99
		plus.nativeUI.showWaiting(); //显示原生等待框
100
		var webviewShow = plus.webview.create("../html/correctBack.html", 'correctBack.html', {}, {
101
			proid: self.proid,
102
			name:self.name,
103
		})
104
	})
105
	
106
	})
107
})