share.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. <template>
  2. <div class="note" :style="note">
  3. <div class="transparent" :style="transparent">
  4. <!--分享页面-->
  5. <div class="card">
  6. <h3 style="color: white"><strong>提交成功!最后一步</strong></h3>
  7. <van-row>保存邀请卡片(图片)至手机</van-row>
  8. <van-row>转发图片至朋友圈并截图</van-row>
  9. <van-row>将截图发送至<span style="color: #F4A460"> 深大欢欢 </span>公众号后台,才可获得本次活动的【匹配资格】和【抽奖机会】</van-row>
  10. </div>
  11. <div style="position: relative;">
  12. <img :src="share" style="max-width: 80%; position: relative;"/>
  13. </div>
  14. <van-button size="large" type="primary" @click="Toshare">分享</van-button>
  15. <van-button size="large" type="primary" @click="Toindex">返回首页</van-button>
  16. </div>
  17. </div>
  18. </template>
  19. <script>
  20. // import wx from 'weixin-js-sdk';
  21. import {
  22. Row, Col,
  23. Button
  24. } from 'vant';
  25. import 'whatwg-fetch';
  26. import { BasicFunction } from '../connector/basic-service';
  27. export default {
  28. name: "share",
  29. components: {
  30. [Button.name]: Button,
  31. [Row.name]: Row, [Col.name]: Col,
  32. 'wx': {
  33. render(createElement) {
  34. return createElement(
  35. 'script',
  36. {
  37. attrs: {
  38. type: 'text/javascript',
  39. src: 'http://res2.wx.qq.com/open/js/jweixin-1.4.0.js',
  40. },
  41. },
  42. );
  43. },
  44. },
  45. },
  46. mounted: {},
  47. data() {
  48. return {
  49. note: {
  50. backgroundImage: "url(" + require("../assets/prize_background.jpg") + ")",
  51. },
  52. transparent: {
  53. backgroundColor: "rgba(50,50,50,0.7)",
  54. },
  55. active: 0,
  56. share: require('../assets/post.png'),
  57. }
  58. },
  59. methods: {
  60. Toindex() {
  61. this.$router.push('index');
  62. },
  63. Toshare() {
  64. alert("请点击右上角,即可分享");
  65. Toast({
  66. message: "请点击右上角,即可分享"
  67. })
  68. }
  69. },
  70. created: function () {
  71. if (!localStorage.getItem('frontend-userid')) {
  72. this.$router.push('login');
  73. return;
  74. }
  75. BasicFunction.getSigned(['onMenuShareTimeline', 'onMenuShareAppMessage',], function () {
  76. wx.ready(function () { //需在用户可能点击分享按钮前就先调用
  77. wx.onMenuShareTimeline({
  78. title: '用一份礼物,邂逅一段故事', // 分享标题
  79. link: 'https://gift.fogice.com/?res=timeline', // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
  80. imgUrl: 'http://gift.fogice.com/attachment/upload/2018-12-13_22-45-35_dbad3cb10afe017f8ef5158f96c9a7c6c622aa04db557384883f97fe38cae380.png', // 分享图标
  81. success: function () {
  82. // 设置成功
  83. Toast({
  84. message: "成功分享到朋友圈"
  85. });
  86. this.$router.push('index');
  87. },
  88. cancel: function () {
  89. Toast({
  90. message: "分享失败,您取消了分享!"
  91. });
  92. }
  93. });
  94. wx.onMenuShareAppMessage({
  95. title: '用一份礼物,邂逅一段故事', // 分享标题
  96. desc: '嘿~我送出了一份圣诞礼物 要和我来交换吗', // 分享描述
  97. link: 'https://gift.fogice.com/?res=appmessage', // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
  98. imgUrl: 'http://gift.fogice.com/attachment/upload/2018-12-13_22-45-35_dbad3cb10afe017f8ef5158f96c9a7c6c622aa04db557384883f97fe38cae380.png', // 分享图标
  99. type: '', // 分享类型,music、video或link,不填默认为link
  100. dataUrl: '', // 如果type是music或video,则要提供数据链接,默认为空
  101. success: function () {
  102. // 用户点击了分享后执行的回调函数
  103. Toast({
  104. message: "成功分享给朋友"
  105. });
  106. this.$router.push('index');
  107. },
  108. cancel: function () {
  109. Toast({
  110. message: "分享失败,您取消了分享!"
  111. });
  112. }
  113. })
  114. });
  115. /* wx.config({
  116. debug: true, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
  117. appId: '', // 必填,公众号的唯一标识
  118. timestamp:, // 必填,生成签名的时间戳
  119. nonceStr: '', // 必填,生成签名的随机串
  120. signature: '',// 必填,签名
  121. jsApiList: [] // 必填,需要使用的JS接口列表
  122. });*/
  123. },{});
  124. }
  125. };
  126. </script>
  127. <style scoped>
  128. .van-button {
  129. background-color: #fd6740;
  130. border-color: #fd6740;
  131. margin: 10px 0 10px;
  132. width: 55%;
  133. }
  134. .card {
  135. margin-bottom: 20px;
  136. margin-left: 20px;
  137. margin-right: 20px;
  138. padding: 15px;
  139. text-align: left;
  140. }
  141. .van-row {
  142. font-size: 0.3em;
  143. color: white;
  144. }
  145. </style>