wang jun 3 tahun lalu
induk
melakukan
32c8c40db8

File diff ditekan karena terlalu besar
+ 20 - 0
public/static/jssha/sha.js


File diff ditekan karena terlalu besar
+ 0 - 0
public/static/wechat/jweixin-1.0.0.js


+ 95 - 0
public/static/wechat/wx_share.js

@@ -0,0 +1,95 @@
+wx.ready(function(){
+    //分享到 qq 和朋友
+	wx.updateAppMessageShareData({ 
+	    title: share_info.title, // 分享标题
+	    desc: share_info.desc, // 分享描述
+	    link: share_info.link, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
+	    imgUrl: share_info.imgUrl, // 分享图标
+	    success: function () {
+	     	console.log('timeline');
+	    }
+	}); 
+    //分享到 qq空间 和朋友圈
+	wx.updateTimelineShareData({ 
+	    title: share_info.title, // 分享标题
+	    link: share_info.link, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
+	    imgUrl: share_info.imgUrl, // 分享图标
+	    success: function () {
+	      	console.log('timeline');
+            
+	    }
+	});
+    //分享到朋友圈 即将废弃
+	wx.onMenuShareTimeline({
+        title: share_info.title, // 分享标题
+        link: share_info.link, // 分享链接
+        imgUrl: share_info.imgUrl, // 分享图标
+        success: function () {
+            // 用户确认分享后执行的回调函数
+            console.log('timeline');
+           
+        },
+        cancel: function () {
+            // 用户取消分享后执行的回调函数
+        }
+    });
+    //分享给朋友 即将废弃
+    wx.onMenuShareAppMessage({
+        title: share_info.title, // 分享标题
+        desc: share_info.desc, // 分享描述
+        link: share_info.link, // 分享链接
+        imgUrl: share_info.imgUrl, // 分享图标
+        type: '', // 分享类型,music、video或link,不填默认为link
+        dataUrl: '', // 如果type是music或video,则要提供数据链接,默认为空
+        success: function () {
+            // 用户确认分享后执行的回调函数
+            console.log('appmessage');
+            
+        },
+        cancel: function () {
+            // 用户取消分享后执行的回调函数
+        }
+    });
+    //分享到qq 即将废弃
+    wx.onMenuShareQQ({
+        title: share_info.title, // 分享标题
+        desc: share_info.desc, // 分享描述
+        link: share_info.link, // 分享链接
+        imgUrl: share_info.imgUrl, // 分享图标
+        success: function () { 
+           // 用户确认分享后执行的回调函数
+           console.log('qq');
+        },
+        cancel: function () { 
+           // 用户取消分享后执行的回调函数
+        }
+    });
+    //分享到微博
+    wx.onMenuShareWeibo({
+        title: share_info.title, // 分享标题
+        desc: share_info.desc, // 分享描述
+        link: share_info.link, // 分享链接
+        imgUrl: share_info.imgUrl, // 分享图标
+        success: function () { 
+           // 用户确认分享后执行的回调函数
+           console.log('weibo');
+        },
+        cancel: function () { 
+            // 用户取消分享后执行的回调函数
+        }
+    });
+    //分享到qq控件 即将废弃
+    wx.onMenuShareQZone({
+        title: share_info.title, // 分享标题
+        desc: share_info.desc, // 分享描述
+        link: share_info.link, // 分享链接
+        imgUrl: share_info.imgUrl, // 分享图标
+        success: function () { 
+           // 用户确认分享后执行的回调函数
+           console.log('qzone');
+        },
+        cancel: function () { 
+            // 用户取消分享后执行的回调函数
+        }
+    });
+});

+ 45 - 0
public/static/wechat/wx_share_config.js

@@ -0,0 +1,45 @@
+const appid="wxcacf6eb6e7478e29";
+const nonceStr = function() {
+    return Math.random().toString(36).substr(2, 15);
+};
+const timeStamp = function () {
+    return parseInt(new Date().getTime() / 1000) + '';
+};
+const ticket= function (){
+    var ticket = '';
+    $.ajaxSetup({
+        async: false, //默认为true,改为false 则为同步请求
+        url: "https://app.tjzhxx.cn:11443//index.php/index/index/getticket",
+        type: "POST",
+        success:function(result){
+            ticket=result
+        }
+    });
+    return ticket;
+}
+var url=window.location.href;
+var calcSignature =function(ticket,nonceStr,timeStamp,url) {
+    var result = {
+        jsapi_ticket: ticket,
+        nonceStr: nonceStr,
+        timestamp: timeStamp,
+        url: url,
+    }
+    var str = 'jsapi_ticket=' + ticket + '&noncestr=' + nonceStr + '&timestamp=' + timeStamp + '&url=' + url;
+    // 对str使用sha1签名,得到signature,这里使用jsSHA模块,需install
+    shaObj = new jsSHA(str, 'TEXT');
+    result.signature = shaObj.getHash('SHA-1', 'HEX');
+    return result; // 返回到前端,提供接口由前端请求
+}
+var createSignture =function(url){
+    return calcSignature(ticket,nonceStr,timeStamp,url);
+}
+const signature = createSignture(url);
+wx.config({
+    debug:true, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
+    appId:appid, // 必填,企业号的唯一标识,此处填写企业号corpid
+    timestamp:timeStamp , // 必填,生成签名的时间戳
+    nonceStr:nonceStr, // 必填,生成签名的随机串
+    signature: signature,// 必填,签名,见附录1
+    jsApiList:['onMenuShareTimeline','onMenuShareAppMessage','onMenuShareQQ','onMenuShareWeibo','onMenuShareQZone'] // 必填,需要使用的JS接口列表,所有JS接口列表见附录2
+});

+ 40 - 8
public/themes/simpleboot3/portal/page/share.html

@@ -8,7 +8,19 @@
     <link rel="icon" href="__TMPL__/public/assets/images/favicon.png" type="image/png">
     <link href="__TMPL__/public/assets/simpleboot3/themes/simpleboot3/bootstrap.min.css" rel="stylesheet">
     <link href="__TMPL__/public/assets/simpleboot3/font-awesome/4.4.0/css/font-awesome.min.css" rel="stylesheet" type="text/css">
-    <script src="__TMPL__/public/assets/js/jquery-1.10.2.min.js"></script>
+    <script src="/static/wechat/jweixin-1.0.0.js"></script>
+    <script src="/static/js/jquery.js"></script>
+    <script src="/static/jssha/sha.js"></script>
+    <script src="/static/wechat/wx_share_config.js"></script>
+    <script>
+        var share_info = {
+            title:"水猫工匠app",
+            desc:"水猫工匠app",
+            link:window.location.href,
+            imgUrl:'https://'+window.location.host+'__TMPL__/public/assets/images/favicon.png'
+        }; 
+    </script>
+    <script src="/static/wechat/wx_share.js"></script>
     <script src="https://cdn.jsdelivr.net/npm/vue@2"></script>
     <script src="https://cdn.bootcdn.net/ajax/libs/jquery.qrcode/1.0/jquery.qrcode.min.js"></script>
     <style>
@@ -110,9 +122,9 @@
                         </div>
                     </div>
                     <div class="col-xs-12">
-                        <a href="http://www.tjzhonghui.cn:20443/file/apk/app-watercat.apk" class="btn btn-primary btn-lg btn-block" role="button">
+                        <button @click="downloadapp" class="btn btn-primary btn-lg btn-block" role="button">
                             下载
-                        </a>
+                        </button>
                     </div>
                     <div class="col-xs-12 qrcodelist">
                         <div class="col-md-offset-3 col-md-6 col-xs-12 item">
@@ -123,7 +135,7 @@
                    
                 </div>
                 <div v-else class="col-xs-12">
-                    <p  class="lead text-center error-height">{{ error }}</p>
+                    <p  class="lead text-center error-height">{{ errormsg }}</p>
                 </div>
                 
             </div>
@@ -134,6 +146,7 @@
               el:'#app',
               data:{
                 error:false,
+                errormsg:"加载中",
                 type:false,
                 infoid:false,
                 url:'https://app.tjzhxx.cn:10443/index.php',
@@ -204,7 +217,8 @@
                                 app.info = res.data
                             }else{
                                 app.info=false
-                                app.error = res.msg;
+                                app.error=true
+                                app.errormsg = res.msg;
                             }
                         });
                     }
@@ -212,6 +226,21 @@
                 getqrcode(){
                     var baiduUrl='https://mobile.baidu.com/item?docid=30633471&f0=search_suggestContent%400_appBaseNormal%400';
                     $('#baiduqrcode').qrcode(baiduUrl);
+                },
+                downloadapp(){
+                    let downurl="http://www.tjzhonghui.cn:20443/file/apk/app-watercat.apk";
+                    if(!this.error){
+                        var ua = navigator.userAgent.toLowerCase();
+                        var isAndroid = ua.indexOf('android') > -1 || ua.indexOf('linux') > -1;
+                        //仅处理android
+                        if(isAndroid){
+                            window.location="launchapp://com.tjzhxx.craftsmen";//打开某手机上的某个app应用
+                            setTimeout(function(){
+                                window.location=downurl;
+                                return
+                            },500);
+                        }
+                    }
                 }
               },
               mounted(){
@@ -238,13 +267,16 @@
                 if (browser.versions.mobile) {
                     var ua = navigator.userAgent.toLowerCase();
                     if (ua.match(/MicroMessenger/i) == "micromessenger") {
-                        this.error="请使用浏览器打开"
+                        this.error="true"
+                        this.errormsg="请使用浏览器打开"
                     }
                     if (ua.match(/WeiBo/i) == "weibo") {
-                        this.error="请使用浏览器打开"
+                        this.error="true"
+                        this.errormsg="请使用浏览器打开"
                     }
                     if (ua.match(/QQ/i) == "qq") {
-                        this.error="请使用浏览器打开"
+                        this.error="true"
+                        this.errormsg="请使用浏览器打开"
                     }
                 }
                 this.getinfo();

Beberapa file tidak ditampilkan karena terlalu banyak file yang berubah dalam diff ini