index.vue 2.6 KB
<!--
 * @Date: 2022-09-28 11:52:13
 * @LastEditors: hookehuyr hookehuyr@gmail.com
 * @LastEditTime: 2022-09-28 15:37:50
 * @FilePath: /swx/src/pages/joinSuccess/index.vue
 * @Description: 文件描述
-->
<template>
  <view class="join-success-page">
    <view class="success-icon">
      <van-image width="12rem" height="12rem" fit="contain"
        src="https://tva1.sinaimg.cn/large/5f01a858gy1h6m8rrcoywj208c07maav.jpg" />
    </view>
    <view class="success-info">
      <view class="text">报名成功</view>
      <!-- <view @tap="shareJoin" class="join">邀请好友报名</view> -->
      <button id="share" data-name="shareBtn" open-type="share" style="font-size: 1.15rem; padding: 0; margin: 1.5rem 3rem; border: 1px solid #199A74; color: #199A74; border-radius: 2rem; background-color: white;">邀请好友报名</button>
    </view>
  </view>
</template>

<script setup>
import { ref } from "vue";
import Taro from '@tarojs/taro'

// 打开朋友圈分享
wx.showShareMenu({
  withShareTicket: true,
  menus: ['shareAppMessage', 'shareTimeline']
})
</script>

<script>
import "./index.less";

export default {
  name: "joinSuccessPage",
  // TODO:分享内容待设置
  onShareAppMessage(options) {
    // 设置菜单中的转发按钮触发转发事件时的转发内容
    var shareObj = {
      title: "胜文轩-活动报名",    // 默认是小程序的名称(可以写slogan等)
      path: 'pages/joinActivity/index',    // 默认是当前页面,必须是以‘/'开头的完整路径
      imageUrl: '',   //自定义图片路径,可以是本地文件路径、代码包文件路径或者网络图片路径,支持PNG及JPG,不传入 imageUrl 则使用默认截图。显示图片长宽比是 5:4
      success: function (res) {
        // 转发成功之后的回调
        if (res.errMsg == 'shareAppMessage:ok') {
          //
        }
      },
      fail: function () {
        // 转发失败之后的回调
        if (res.errMsg == 'shareAppMessage:fail cancel') {
          // 用户取消转发
        } else if (res.errMsg == 'shareAppMessage:fail') {
          // 转发失败,其中 detail message 为详细失败信息
        }
      },
      complete: function () {
        // 转发结束之后的回调(转发成不成功都会执行)
      }
    }
    // 来自页面内的按钮的转发
    // if (options.from == 'button') {
    //   var eData = options.target.dataset;
    //   console.warn(eData);   // shareBtn
    //   // 此处可以修改 shareObj 中的内容
    //   // shareObj.path = '/pages/goods/goods?goodId=' + eData.id;
    // }
    // 返回shareObj
    return shareObj;
  }
}
</script>