share.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  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>1.长按保存邀请卡片(图片)至手机</van-row>
  8. <van-row>2.转发图片至朋友圈并截图</van-row>
  9. <van-row>3.将截图发送至<span style="color: #F4A460"> 深大换换 </span>公众号后台,即可获得本次活动的【匹配资格】和【抽奖机会】</van-row>
  10. </div>
  11. <div style="position: relative;">
  12. <img :src="isWX ? share_http[i] : share[i]" style="max-width: 80%; position: relative;"/>
  13. </div>
  14. <a :href="share[i]" download="post">
  15. <van-button size="large" type="primary" @click="savePic" style="background-color: #00FF00;
  16. border-color: #00FF00;
  17. margin: 10px 0 10px;
  18. width: 55%;"
  19. >保存</van-button>
  20. </a>
  21. <van-button size="large" type="primary" @click="Toindex" style="background-color: #fd6740;
  22. border-color: #fd6740;
  23. margin: 10px 0 10px;
  24. width: 55%;"
  25. >返回首页</van-button>
  26. </div>
  27. </div>
  28. </template>
  29. <script>
  30. // import wx from 'weixin-js-sdk';
  31. import {
  32. Row, Col,
  33. Button, Toast
  34. } from 'vant';
  35. import 'whatwg-fetch';
  36. // import {BasicFunction} from '../connector/basic-service';
  37. export default {
  38. name: "share",
  39. components: {
  40. [Button.name]: Button,
  41. [Row.name]: Row, [Col.name]: Col,
  42. // 'wx': {
  43. // render(createElement) {
  44. // return createElement(
  45. // 'script',
  46. // {
  47. // attrs: {
  48. // type: 'text/javascript',
  49. // src: 'http://res2.wx.qq.com/open/js/jweixin-1.4.0.js',
  50. // },
  51. // },
  52. // );
  53. // },
  54. // },
  55. },
  56. data() {
  57. return {
  58. note: {
  59. backgroundImage: "url('http://pjczv6ygf.bkt.clouddn.com/share_background.jpg')",
  60. },
  61. transparent: {
  62. backgroundColor: "rgba(50,50,50,0.7)",
  63. },
  64. active: 0,
  65. share: [
  66. require('../assets/posts/1.png'),
  67. require('../assets/posts/2.png'),
  68. require('../assets/posts/3.png'),
  69. require('../assets/posts/4.png'),
  70. ],
  71. share_http: [
  72. "http://pjczv6ygf.bkt.clouddn.com/1.png",
  73. "http://pjczv6ygf.bkt.clouddn.com/2.png",
  74. "http://pjczv6ygf.bkt.clouddn.com/3.png",
  75. "http://pjczv6ygf.bkt.clouddn.com/4.png",
  76. ],
  77. isWX: false,
  78. i: 0
  79. }
  80. },
  81. methods: {
  82. Toindex() {
  83. this.$router.push('index');
  84. },
  85. savePic() {
  86. if (isWeiXin()) alert('请长按图片,保存至手机');
  87. }
  88. // Toshare() {
  89. // alert("请点击右上角,即可分享");
  90. // Toast({
  91. // message: "请点击右上角,即可分享"
  92. // })
  93. // }
  94. },
  95. created: function () {
  96. if (!localStorage.getItem('frontend-userid')) {
  97. this.$router.push('login');
  98. return;
  99. }
  100. this.i = Math.ceil(Math.random() * 4) - 1;
  101. // console.log(this.i);
  102. if (isWeiXin()) this.isWX = true;
  103. // console.log(this.isWX);
  104. // BasicFunction.getSigned(['onMenuShareTimeline', 'onMenuShareAppMessage',], function () {
  105. // wx.ready(function () { //需在用户可能点击分享按钮前就先调用
  106. // wx.onMenuShareTimeline({
  107. // title: '用一份礼物,邂逅一段故事', // 分享标题
  108. // link: 'https://gift.fogice.com/?res=timeline', // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
  109. // imgUrl: 'http://gift.fogice.com/attachment/upload/2018-12-13_22-45-35_dbad3cb10afe017f8ef5158f96c9a7c6c622aa04db557384883f97fe38cae380.png', // 分享图标
  110. // success: function () {
  111. // // 设置成功
  112. // Toast({
  113. // message: "成功分享到朋友圈"
  114. // });
  115. // this.$router.push('index');
  116. // },
  117. // cancel: function () {
  118. // Toast({
  119. // message: "分享失败,您取消了分享!"
  120. // });
  121. // }
  122. // });
  123. // wx.onMenuShareAppMessage({
  124. // title: '用一份礼物,邂逅一段故事', // 分享标题
  125. // desc: '嘿~我送出了一份圣诞礼物 要和我来交换吗', // 分享描述
  126. // link: 'https://gift.fogice.com/?res=appmessage', // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
  127. // imgUrl: 'http://gift.fogice.com/attachment/upload/2018-12-13_22-45-35_dbad3cb10afe017f8ef5158f96c9a7c6c622aa04db557384883f97fe38cae380.png', // 分享图标
  128. // type: '', // 分享类型,music、video或link,不填默认为link
  129. // dataUrl: '', // 如果type是music或video,则要提供数据链接,默认为空
  130. // success: function () {
  131. // // 用户点击了分享后执行的回调函数
  132. // Toast({
  133. // message: "成功分享给朋友"
  134. // });
  135. // this.$router.push('index');
  136. // },
  137. // cancel: function () {
  138. // Toast({
  139. // message: "分享失败,您取消了分享!"
  140. // });
  141. // }
  142. // })
  143. // });
  144. // }, {});
  145. }
  146. }
  147. function isWeiXin() {
  148. let ua = window.navigator.userAgent.toLowerCase();
  149. return ua.match(/MicroMessenger/i) == 'micromessenger'; // 必须两个等号
  150. }
  151. </script>
  152. <style scoped>
  153. .card {
  154. margin-bottom: 20px;
  155. margin-left: 20px;
  156. margin-right: 20px;
  157. padding: 15px;
  158. text-align: left;
  159. }
  160. h3{
  161. font-size: 1.5em;
  162. }
  163. .van-row {
  164. font-size: 1em;
  165. color: white;
  166. }
  167. </style>