|
@@ -554,6 +554,144 @@ var upload = {
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
+}
|
|
|
+
|
|
|
+var share =
|
|
|
+{
|
|
|
+ wechat : false,
|
|
|
+ url : '',
|
|
|
+ project : '',
|
|
|
+ uid : '-1',
|
|
|
+ param : {
|
|
|
+ title : '',
|
|
|
+ pic : '',
|
|
|
+ content : '',
|
|
|
+ link : '',
|
|
|
+ },
|
|
|
+ init : function(uid, project, url, param, button)
|
|
|
+ {
|
|
|
+ var self = this;
|
|
|
+ self.wechat = dever.is_weixin();
|
|
|
+ self.project = project;
|
|
|
+ self.url = url;
|
|
|
+ self.uid = uid;
|
|
|
+ self.param = param;
|
|
|
+ self.param.timelineCallback = function() {};
|
|
|
+ self.param.sendMessageCallback = function() {};
|
|
|
+ self.param.shareQQCallback = function() {};
|
|
|
+
|
|
|
+ if (self.wechat) {
|
|
|
+ self.wechatInit();
|
|
|
+ }
|
|
|
+ self.reflux();
|
|
|
+ }
|
|
|
+
|
|
|
+ ,wechatInit: function()
|
|
|
+ {
|
|
|
+ var self = this;
|
|
|
+ var url = this.url + 'init?callback=?';
|
|
|
+ var param = this.param;
|
|
|
+ var project = this.project;
|
|
|
+ var options = {};
|
|
|
+ options.project = project;
|
|
|
+ options.url = location.href.split('#')[0];
|
|
|
+ options.noloading = 1;
|
|
|
+ http.request('post', url, options, function(result) {
|
|
|
+ var data = result.data;
|
|
|
+ wx.config({
|
|
|
+
|
|
|
+ appId: data.appId,
|
|
|
+ timestamp: data.timestamp,
|
|
|
+ nonceStr: data.nonceStr,
|
|
|
+ signature: data.signature,
|
|
|
+ jsApiList: [
|
|
|
+ 'onMenuShareTimeline',
|
|
|
+ 'onMenuShareAppMessage',
|
|
|
+ 'onMenuShareQQ'
|
|
|
+ ]
|
|
|
+ });
|
|
|
+
|
|
|
+ wx.ready(function() {
|
|
|
+ wx.onMenuShareAppMessage({
|
|
|
+ title: param.title,
|
|
|
+ desc: param.content,
|
|
|
+ link: param.link,
|
|
|
+ imgUrl: param.pic,
|
|
|
+ success: function(res) {
|
|
|
+ param.sendMessageCallback('success', res)
|
|
|
+ self.shareLog(1, 1);
|
|
|
+ },
|
|
|
+ cancel: function(res) {
|
|
|
+ param.sendMessageCallback('cancel', res)
|
|
|
+ self.shareLog(1, 2);
|
|
|
+ },
|
|
|
+ fail: function(res) {
|
|
|
+ param.sendMessageCallback('fail', res)
|
|
|
+ self.shareLog(1, 3);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ wx.onMenuShareTimeline({
|
|
|
+ title: param.title,
|
|
|
+ link: param.url,
|
|
|
+ imgUrl: param.img,
|
|
|
+ success: function(res) {
|
|
|
+ param.timelineCallback('success', res)
|
|
|
+ self.shareLog(2, 1);
|
|
|
+ },
|
|
|
+ cancel: function(res) {
|
|
|
+ param.timelineCallback('cancel', res)
|
|
|
+ self.shareLog(2, 2);
|
|
|
+ },
|
|
|
+ fail: function(res) {
|
|
|
+ param.timelineCallback('fail', res)
|
|
|
+ self.shareLog(2, 3);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ wx.onMenuShareQQ({
|
|
|
+ title: param.title,
|
|
|
+ link: param.url,
|
|
|
+ imgUrl: param.img,
|
|
|
+ success: function(res) {
|
|
|
+ param.shareQQCallback('success', res)
|
|
|
+ self.shareLog(3, 1);
|
|
|
+ },
|
|
|
+ cancel: function(res) {
|
|
|
+ param.shareQQCallback('cancel', res)
|
|
|
+ self.shareLog(3, 2);
|
|
|
+ },
|
|
|
+ fail: function(res) {
|
|
|
+ param.shareQQCallback('fail', res)
|
|
|
+ self.shareLog(3, 3);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ ,reflux: function() {
|
|
|
+ var refer = document.referrer,
|
|
|
+ url = encodeURIComponent(document.location.href),
|
|
|
+ param = location.search.substr(1),
|
|
|
+ ua = encodeURIComponent(navigator.userAgent),
|
|
|
+ project = this.project,
|
|
|
+ uid = this.uid,
|
|
|
+ wechat = this.wechat;
|
|
|
+
|
|
|
+ if (param.indexOf("tsina-") > -1 || param.indexOf("timeline") > -1 || param.indexOf("singlemessage") > -1 || param.indexOf("groupmessage") > -1) {
|
|
|
+ var url = this.url + 'reflux?callback=?' + '&project='+project+'&url=' + url + '&ua=' + ua + '¶m=' + encodeURIComponent(param) + '&uid=' + uid + '&type=' + wechat;
|
|
|
+ http.request('post', url, {noloading:1});
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ ,shareLog: function(actType, actResult) {
|
|
|
+ var project = this.project;
|
|
|
+ var uid = this.uid;
|
|
|
+ var wechat = this.wechat;
|
|
|
+ var ua = encodeURIComponent(navigator.userAgent);
|
|
|
+ var url = encodeURIComponent(document.location.href);
|
|
|
+ var url = this.url + 'collect?callback=?' + '&project='+project+'&url=' + url + '&actType=' + actType + '&actResult=' + actResult + '&ua=' + ua + '&uid=' + uid + '&type=' + wechat
|
|
|
+ http.request('post', url, {noloading:1});
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
var dever = {
|
|
@@ -1108,10 +1246,14 @@ var dever = {
|
|
|
},
|
|
|
|
|
|
|
|
|
- wxTip : function() {
|
|
|
+ wxTip : function(type) {
|
|
|
var wx = this.is_weixin();
|
|
|
if (wx) {
|
|
|
- var tip = '<div id="weixin-tip" style="position: fixed; left:0; top:0; background: rgba(0,0,0,0.8); filter:alpha(opacity=80); width: 100%; height:100%; z-index: 100;" onclick="document.getElementById(\'weixin-tip\').remove()"><p style="text-align: center; margin-top: 10%; padding:0 5%;"><img src="static/dever/live_weixin.png" alt="微信打开" style="max-width: 100%; height: auto;"/></p></div>';
|
|
|
+ var img = 'live_weixin';
|
|
|
+ if (type) {
|
|
|
+ img = 'weixin-guide';
|
|
|
+ }
|
|
|
+ var tip = '<div id="weixin-tip" style="position: fixed; left:0; top:0; background: rgba(0,0,0,0.8); filter:alpha(opacity=80); width: 100%; height:100%; z-index: 100;" onclick="document.getElementById(\'weixin-tip\').remove()"><p style="text-align: center; margin-top: 10%; padding:0 5%;"><img src="static/dever/'+img+'.png" alt="微信打开" style="max-width: 100%; height: auto;"/></p></div>';
|
|
|
this.html(tip);
|
|
|
return true;
|
|
|
}
|
|
@@ -1468,6 +1610,64 @@ var dever = {
|
|
|
|
|
|
sleep : function(time) {
|
|
|
return new Promise((resolve) => setTimeout(resolve, time));
|
|
|
+ },
|
|
|
+
|
|
|
+
|
|
|
+ shareInit : function(data) {
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
+
|
|
|
+ share : function(provider, scene, type, data, success, error) {
|
|
|
+ if (this.source == 'h5') {
|
|
|
+ var weixin = this.wxTip(1);
|
|
|
+ if (!weixin) {
|
|
|
+ this.alert('请点击复制按钮');
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ var config = {
|
|
|
+ provider: provider,
|
|
|
+ type: type,
|
|
|
+ scene: scene,
|
|
|
+ href: data.link,
|
|
|
+ title: data.title,
|
|
|
+ summary: data.content,
|
|
|
+ imageUrl: data.pic,
|
|
|
+ success: function(res) {
|
|
|
+ if (success) {
|
|
|
+ success(res);
|
|
|
+ } else {
|
|
|
+ console.log("success:" + JSON.stringify(res));
|
|
|
+ }
|
|
|
+ },
|
|
|
+ fail: function(err) {
|
|
|
+ if (error) {
|
|
|
+ success(err);
|
|
|
+ } else {
|
|
|
+ console.log("fail:" + JSON.stringify(err));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+ if (data.media) {
|
|
|
+ config.mediaUrl = media;
|
|
|
+ }
|
|
|
+ if (this.source == 'applet') {
|
|
|
+ if (!data.path) {
|
|
|
+ console.log('data.path未定义!');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (!data.applet_id) {
|
|
|
+ console.log('data.applet_id未定义!');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ config.miniProgram = {};
|
|
|
+ config.miniProgram.id = data.applet_id;
|
|
|
+ config.miniProgram.path = data.path;
|
|
|
+ config.miniProgram.type = 0;
|
|
|
+ config.miniProgram.webUrl = data.link;
|
|
|
+ }
|
|
|
+ uni.share(config);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|