shareIOU.vue
1.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<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>