shareIOU.vue 1.95 KB
<template>
  <v-layout id="shareIOU" column justify-center align-center>
    <v-card id="mainBlock" flat>
      <div>分享本页面给微信好友或朋友圈</div>
      <div>或者</div>
      <div>让让对方扫一扫二维码</div>
      <div class="qr" v-html="img">

      </div>
    </v-card>
  </v-layout>
</template>

<script>
import {wechatShareSetting, dateParse} from '@/helper'
export default {
  async asyncData({store, query, app, redirect, route}) {
    console.log(route)
    let {data} = await app.$axios.get(`/iou/shareInfo?id=${query.id}&userId=${store.state.user.id}`)
    if (data.success) {
      return {
        img: data.img, 
        url: data.url, 
        amount: data.amount,
        startDate: data.startDate,
        endDate: data.endDate
      }
    } else {
      store.dispatch('displayMessage', data.msg)
      redirect(301, '/')
    }
  },
  data: () => ({
    info:{},
    ticket: {}
  }),
  computed: {
    userInfo() {
      return this.$store.state.user
    }
  },
  mounted() {
    wechatShareSetting(this.$axios, this.$store, {
      title: `${this.userInfo.name}邀请您确认借条`, // 分享标题
      link: `https://www.51liuliang.cc/netiou/shareRedirect?id=${this.$route.query.id}`, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
      imgUrl: 'https://www.51liuliang.cc/netiou/logo1.png', // 分享图标
      desc: `金额:${this.amount}元\n借款日期:${dateParse(this.startDate)}\n还款日期:${dateParse(this.endDate)}`,
      success: function () {},
      cancel: function () {}
    })
  }
}
</script>

<style lang="scss" scoped>
  #shareIOU {
    #mainBlock {
      width: 100vw;
      background-color: transparent;
      text-align: center;
      font-size: 1.3rem;
      font-weight: bold;

      .qr {
        width: 60%;
        background-color: #fff;
        margin: 1rem 20%;

        svg {
          vertical-align: bottom;
        }
      }
    }
  }
</style>