articleDetail.php 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. use common\components\stringUtil;
  3. ?>
  4. <div class="lay-til J_MenuBody" id="J_SubHead">
  5. <div class="header-con">
  6. <i class="arrow-back" onclick="history.go(-1)"><img src="/images/pay_03.png" alt=""></i>
  7. <h1><a href="javascript:;" style="color:#595757;text-decoration:none;" ><?= $article['title'] ?></a></h1>
  8. </div>
  9. </div>
  10. <div class="lay-body" id="J_MainBody" style="margin-top:10px;">
  11. <div class="hzg-content">
  12. <?= $article['content'] ?>
  13. </div>
  14. </div>
  15. <script>
  16. <?php if($this->context->isWeixin){?>
  17. //微信分享
  18. var shareTitle = '<?php echo $article['title'] ?>';
  19. var descContent = '<?php echo stringUtil::subStringUtf8($article['summary'],26,'…'); ?>';
  20. var lineLink = '<?= Yii::$app->request->hostInfo ?>/article/article-detail?id=<?= $article['id'] ?>&account=<?= $_GET['account'] ?>&weixinShare=yes';
  21. var imgUrl = '<?php if(!empty($article['cover'])){ echo Yii::$app->params['imgUrl'].$article['cover']; }else{ echo "/images/weixinSharelogo.jpg"; }?>';
  22. wx.config({
  23. //debug:true,
  24. appId: '<?= $this->context->signPackage['appId'] ?>',
  25. timestamp: <?= $this->context->signPackage['timestamp'] ?>,
  26. nonceStr: '<?= $this->context->signPackage['nonceStr'] ?>',
  27. signature: '<?= $this->context->signPackage['signature'] ?>',
  28. jsApiList: [
  29. 'checkJsApi',
  30. 'onMenuShareTimeline',
  31. 'onMenuShareAppMessage',
  32. 'onMenuShareQQ',
  33. 'onMenuShareWeibo',
  34. ]
  35. });
  36. wx.ready(function () {
  37. var shareData = {
  38. title: shareTitle,
  39. link: lineLink,
  40. imgUrl: imgUrl,
  41. desc:descContent,
  42. };
  43. wx.onMenuShareAppMessage(shareData);
  44. wx.onMenuShareTimeline({
  45. title: shareTitle,
  46. link: lineLink,
  47. imgUrl: imgUrl,
  48. desc:descContent,
  49. success: function () {
  50. //分享成功后的操作
  51. },
  52. cancel: function () {
  53. // 用户取消分享后执行的回调函数
  54. }
  55. });
  56. wx.onMenuShareQQ({
  57. title: shareTitle,
  58. link: lineLink,
  59. imgUrl: imgUrl,
  60. desc:descContent,
  61. success: function () {
  62. //分享成功后的操作
  63. },
  64. cancel: function () {
  65. // 用户取消分享后执行的回调函数
  66. }
  67. });
  68. wx.onMenuShareWeibo(shareData);
  69. });
  70. <?php } ?>
  71. </script>