From df687aa29a8a41f14a1810a610cd6895906eebc3 Mon Sep 17 00:00:00 2001 From: toogee Date: Fri, 29 May 2020 18:17:46 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=82=E9=85=8D=E5=AE=89=E5=8D=93APP?= =?UTF-8?q?=E7=9B=B8=E5=BA=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/static/res/mods/index.js | 16 ++++ public/static/share/icon/wx.png | Bin 0 -> 6560 bytes public/static/share/plusShare.js | 117 +++++++++++++++++++++++++++ view/taoler/index/public/base.html | 14 +++- view/taoler/index/public/flink.html | 2 +- view/taoler/index/public/footer.html | 2 +- 6 files changed, 148 insertions(+), 3 deletions(-) create mode 100644 public/static/share/icon/wx.png create mode 100644 public/static/share/plusShare.js diff --git a/public/static/res/mods/index.js b/public/static/res/mods/index.js index 60e2ddc..1c30b65 100644 --- a/public/static/res/mods/index.js +++ b/public/static/res/mods/index.js @@ -859,6 +859,22 @@ layui.define(['layer', 'laytpl', 'form', 'element', 'upload', 'util'], function( if(type === 'bar1'){ //slayer.msg('打开 index.js,开启发表新帖的路径'); location.href = articleAdd; + } + //分享 + if(type === 'bar2'){ + if(navigator.userAgent.indexOf("Html5Plus") > -1) { + //5+ 原生分享 + window.plusShare({ + title: "my-app-name",//应用名字 + content: "分享具体内容", + href: location.href,//分享出去后,点击跳转地址 + thumbs: ["/static/share/icon/wx.png"] //分享缩略图 + }, function(result) { + //分享回调 + }); + } else { + //原有wap分享实现 + } } } }); diff --git a/public/static/share/icon/wx.png b/public/static/share/icon/wx.png new file mode 100644 index 0000000000000000000000000000000000000000..84abbf80b8338545a370a9e9911cccfec451fbd9 GIT binary patch literal 6560 zcmchcWmFVS)c=VEmJpT@0aqGXLXZaOPU)0d>6QlRU3%%IySuxaMN%ZByF^_|T2LQ; z|Nr~veXU_#9tH-r zt+Jf7uCLi~E@6g=eCns*uYA8$LTY;CFku>)%7)l#Wgj#!;(!2o93##5H~@1_2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UUp)zNl&O`OTv~fv>WqN#;o{lnu0K_DH7H${; z_~D(32X5EJSr@6I37REyYK_QFPHTyT-^b>_-Diyj$CEuz1a!m&DyU}(!v?s7Yn~Lb z0r27PG+!+BiScuj$|Ge94g|gHHwdMB7@z8iiuBVyMVg`2mhR5xI`p11C~58w9pNhv z6@1fc=LyaZ~o;$NxA1kE+rA+*C-_ zp=vA_VS37-RN@-(T5!~bf>XJSFD9~KQKQP-hERP6CH6w`i%g=h<`ahtc0nkfDzY6< zVAjAdYaZejl*2&QAx9~RdPjtLhos$=KgPHI60gd=AI$3?=nZw%i$`_PE=#&6;5xKq|$79?BZS|mc8&q#^c9Q z#;78YjJ%;Sqc&HQpXBTpNOCZb^YFybwT_P+5dC~d7_C7n@5bNtA>kq~a`?O3fbj<% zAeqpR+p3V476Di~l}VEm(OgZm`j?4#CSi@6L1`VxYTbV=_!qbhf=-rny=~3MTH~F{ z-@TLulCgH#FPotb)s{W$@w5-5C`3zk6e1k>VO1;Og3M5-mLKGU3zUEdGnA8M|RMRyBwFpctdP?tQ5)BpgVin`1YArH9hDvxe zsGYMQyzAfXGXkQ)+B_LRtf!k+r;rAaFHvN0bg?;u61V~}y$`BL-88c?N5r4SRESc- z<>D%qRcT>*PD6lloqcqL=(GPfHTe`vCeh?cIe=W?5h_TZ`gh7m0g=@^DbOMXDIl3Z zkp;KGqdwp+kVB@n@CZc;y66J}Oa`U82pxDd%_A&CA$m<1=mFzjT~%IdG0_8}X|x*C zIRIhwoiytBFC891i;4Z(J^WF3Fc@YVl#6==2RW2k9S8*9cMxXDsCbkv{`2pDb!Iz% YlE{=I>@};^qw<2GEUzwCCj*8553u}5lK=n! literal 0 HcmV?d00001 diff --git a/public/static/share/plusShare.js b/public/static/share/plusShare.js new file mode 100644 index 0000000..5f94794 --- /dev/null +++ b/public/static/share/plusShare.js @@ -0,0 +1,117 @@ +(function() { + var plusReady = function(callback) { + if(window.plus) { + callback(); + } else { + document.addEventListener('plusready', callback); + } + } + var shareServices = {}; + var init = function() { + plus.share.getServices(function(services) { + for(var i = 0, len = services.length; i < len; i++) { + shareServices[services[i].id] = services[i]; + } + }); + }; + var isWechatInstalled = function() { + return plus.runtime.isApplicationExist && plus.runtime.isApplicationExist({ + pname: 'com.tencent.mm', + action: 'weixin://' + }); + }; + + function share(id, msg, callback) { + var service = shareServices[id]; + if(!service) { + callback && callback(false); + return; + } + var _share = function() { + service.send(msg, function() { + plus.nativeUI.toast("分享到\"" + service.description + "\"成功!"); + callback && callback(true); + }, function(e) { + plus.nativeUI.toast("分享到\"" + service.description + "\"失败!"); + callback && callback(false); + }) + }; + if(service.authenticated) { + _share(service, msg, callback); + } else { + service.authorize(function() { + _share(service, msg, callback); + }, function(e) { + console.log("认证授权失败"); + callback && callback(false); + }) + } + }; + + function openSystem(msg, callback) { + if(plus.share.sendWithSystem) { + plus.share.sendWithSystem(msg, function() { + //TODO 系统分享暂不支持回调 + //callback && callback(true); + }, function() { + //TODO 系统分享暂不支持回调 + //callback && callback(false); + }); + } else { + callback && callback(false); + } + } + var open = function(msg, callback) { + /** + *如下情况直接打开系统分享 + * 1、未配置微信分享通道 + * 2、用户手机未安装威胁你 + * 3、360浏览器下 + */ + + if(shareServices.weixin && isWechatInstalled() && !/360\sAphone/.test(navigator.userAgent)) { + plus.nativeUI.actionSheet({ + title: '分享到', + cancel: "取消", + buttons: [{ + title: "微信消息" + }, { + title: "微信朋友圈" + }, { + title: "更多分享" + }] + }, function(e) { + var index = e.index; + switch(index) { + case 1: //分享到微信好友 + msg.extra = { + scene: 'WXSceneSession' + }; + share('weixin', msg, callback); + break; + case 2: //分享到微信朋友圈 + msg.title = msg.content; + msg.extra = { + scene: 'WXSceneTimeline' + }; + share('weixin', msg, callback); + break; + case 3: //更多分享 + var url = msg.href ? ('( ' + msg.href + ' )') : ''; + msg.title = msg.title + url; + msg.content = msg.content + url; + openSystem(msg, callback); + break; + } + }) + } else { + //系统分享 + var url = msg.href ? ('( ' + msg.href + ' )') : ''; + msg.title = msg.title + url; + msg.content = msg.content + url; + openSystem(msg, callback); + } + }; + plusReady(init); + window.plusShare = open; +})(); \ No newline at end of file diff --git a/view/taoler/index/public/base.html b/view/taoler/index/public/base.html index b10981a..55e585b 100644 --- a/view/taoler/index/public/base.html +++ b/view/taoler/index/public/base.html @@ -6,10 +6,22 @@ - + + + + {include file="public/header" /} {block name="column"}导航{/block} {block name="content"}内容{/block} diff --git a/view/taoler/index/public/flink.html b/view/taoler/index/public/flink.html index 8ab4d83..14f70f6 100644 --- a/view/taoler/index/public/flink.html +++ b/view/taoler/index/public/flink.html @@ -1,4 +1,4 @@ -