|
@@ -17,7 +17,7 @@
|
|
|
</div>
|
|
|
<div class="methods-item-content">
|
|
|
<div class="methods-item-content-input">
|
|
|
- <el-input v-model="linkText" :readonly="true" placeholder="请输入内容" />
|
|
|
+ <el-input v-model="localInfo.urlLink" :readonly="true" placeholder="请输入内容" />
|
|
|
<el-button class="copy-btn" type="primary" @click="copyLinkEvent">
|
|
|
复制链接
|
|
|
</el-button>
|
|
@@ -28,8 +28,28 @@
|
|
|
<div class="methods-item-title">
|
|
|
方法2:下载海报发给微信好友
|
|
|
</div>
|
|
|
- <div class="methods-item-content">
|
|
|
- <img src="@/assets/images/tell-example.png" alt="">
|
|
|
+ <div v-if="!canvasImg" ref="contentToCapture" class="methods-item-content">
|
|
|
+ <img src="@/assets/images/gift-record/vip-product.png" alt="">
|
|
|
+ <div class="methods-item-content-info">
|
|
|
+ <img src="@/assets/images/auto.png" alt="">
|
|
|
+ <div class="methods-item-content-info-text">
|
|
|
+ <div class="phone-text">
|
|
|
+ {{ localInfo.giftUserPhone }}
|
|
|
+ </div>
|
|
|
+ <div class="gift-text">
|
|
|
+ 送给{{ localInfo.recipientUserPhone }}超级订阅会员,{{ localInfo.duration }}个月内可免费获取全行业招采信息
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="methods-item-content-info-qrcode">
|
|
|
+ <img :src="localInfo.qRCodeLink" alt="">
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div v-else class="methods-item-content-canvas">
|
|
|
+ <img :src="canvasImg" alt="">
|
|
|
+ </div>
|
|
|
+ <div class="methods-item-content-info-download">
|
|
|
+ 点击右键保存到本地
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
@@ -48,6 +68,7 @@
|
|
|
|
|
|
<script>
|
|
|
import { Button, Input } from 'element-ui'
|
|
|
+import html2canvas from 'html2canvas'
|
|
|
import CustomDialog from '@/components/dialog/Dialog.vue'
|
|
|
|
|
|
export default {
|
|
@@ -63,29 +84,75 @@ export default {
|
|
|
type: String,
|
|
|
default: '告知好友'
|
|
|
},
|
|
|
- telllink: {
|
|
|
- type: String,
|
|
|
- default: 'https://www.jianyu360.cn/swoswoswoswo...'
|
|
|
+ info: {
|
|
|
+ type: Object,
|
|
|
+ default: () => ({})
|
|
|
}
|
|
|
},
|
|
|
data() {
|
|
|
return {
|
|
|
- linkText: ''
|
|
|
+ localInfo: { ...this.info },
|
|
|
+ canvasImg: ''
|
|
|
}
|
|
|
},
|
|
|
- created() {
|
|
|
- this.linkText = this.telllink
|
|
|
+ watch: {
|
|
|
+ info: {
|
|
|
+ handler(newVal) {
|
|
|
+ this.localInfo = { ...newVal } // 当 info 更新时同步到本地数据
|
|
|
+ },
|
|
|
+ deep: true
|
|
|
+ },
|
|
|
+ visible: {
|
|
|
+ handler(newVal) {
|
|
|
+ if (newVal) {
|
|
|
+ this.$nextTick(() => {
|
|
|
+ this.generateImage()
|
|
|
+ })
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ this.canvasImg = ''
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
},
|
|
|
methods: {
|
|
|
update(e) {
|
|
|
this.$emit('update:visible', e)
|
|
|
},
|
|
|
onClickConfirm() {
|
|
|
+ this.canvasImg = ''
|
|
|
this.update(false)
|
|
|
},
|
|
|
copyLinkEvent() {
|
|
|
- this.$copyText(this.linkText).then(() => {
|
|
|
- this.$message.success('复制成功')
|
|
|
+ const textLink = `好友${this.localInfo.giftUserPhone}送你超级订阅会员,${this.localInfo.duration}个月内可免费获取全行业招采信息。${this.localInfo.urlLink}`
|
|
|
+ this.$copyText(textLink).then(() => {
|
|
|
+ this.$toast('复制成功')
|
|
|
+ })
|
|
|
+ },
|
|
|
+ generateImage() {
|
|
|
+ const element = this.$refs.contentToCapture
|
|
|
+ console.log(element, 'element')
|
|
|
+ // 等待所有图片加载完成
|
|
|
+ const images = element.querySelectorAll('img')
|
|
|
+ const promises = Array.from(images).map((img) => {
|
|
|
+ return new Promise((resolve, reject) => {
|
|
|
+ if (img.complete) {
|
|
|
+ resolve()
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ img.onload = resolve
|
|
|
+ img.onerror = reject
|
|
|
+ }
|
|
|
+ })
|
|
|
+ })
|
|
|
+ Promise.all(promises).then(() => {
|
|
|
+ html2canvas(element).then((canvas) => {
|
|
|
+ this.canvasImg = canvas.toDataURL('image/png')
|
|
|
+ }).catch((error) => {
|
|
|
+ console.error('Error loading images:', error)
|
|
|
+ })
|
|
|
+ }).catch((error) => {
|
|
|
+ console.error('Error loading images:', error)
|
|
|
})
|
|
|
}
|
|
|
}
|
|
@@ -122,6 +189,7 @@ export default {
|
|
|
overflow: hidden;
|
|
|
}
|
|
|
.methods-item {
|
|
|
+ position: relative;
|
|
|
margin-top: 20px;
|
|
|
}
|
|
|
.methods-item-title {
|
|
@@ -131,6 +199,8 @@ export default {
|
|
|
color: #1D1D1D;
|
|
|
}
|
|
|
.methods-item-content {
|
|
|
+ border-radius: 16px;
|
|
|
+ overflow: hidden;
|
|
|
.methods-item-content-input {
|
|
|
position: relative;
|
|
|
.el-input {
|
|
@@ -142,9 +212,12 @@ export default {
|
|
|
color: #1D1D1D;
|
|
|
::v-deep {
|
|
|
.el-input__inner {
|
|
|
+ width: 324px;
|
|
|
+ height: 22px;
|
|
|
+ white-space: nowrap;
|
|
|
+ text-overflow: ellipsis;
|
|
|
border: none;
|
|
|
line-height: 22px;
|
|
|
- height: 22px;
|
|
|
padding: 0;
|
|
|
}
|
|
|
}
|
|
@@ -161,6 +234,56 @@ export default {
|
|
|
color: #FFFFFF;
|
|
|
}
|
|
|
}
|
|
|
+ .methods-item-content-info {
|
|
|
+ display: flex;
|
|
|
+ padding: 16px 16px 40px;
|
|
|
+ background: linear-gradient(to bottom, #FFFBF2, #FFF7E8);
|
|
|
+ >img {
|
|
|
+ margin: 6px 8px 0 0;
|
|
|
+ width: 48px;
|
|
|
+ height: 48px;
|
|
|
+ }
|
|
|
+ .methods-item-content-info-text {
|
|
|
+ flex: 1;
|
|
|
+ }
|
|
|
+ .phone-text {
|
|
|
+ margin-bottom: 8px;
|
|
|
+ line-height: 24px;
|
|
|
+ font-size: 16px;
|
|
|
+ color: #1D1D1D;
|
|
|
+ }
|
|
|
+ .gift-text {
|
|
|
+ line-height: 22px;
|
|
|
+ font-size: 14px;
|
|
|
+ color: #686868;
|
|
|
+ }
|
|
|
+ .methods-item-content-info-qrcode {
|
|
|
+ width: 60px;
|
|
|
+ height: 60px;
|
|
|
+ margin-left: 16px;
|
|
|
+ border: 1px solid rgba(0, 0, 0, .1);
|
|
|
+ background: #FFFFFF;
|
|
|
+ border-radius: 4px;
|
|
|
+ overflow: hidden;
|
|
|
+ >img {
|
|
|
+ width: 60px;
|
|
|
+ height: 60px;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .methods-item-content-info-download {
|
|
|
+ position: absolute;
|
|
|
+ bottom: 0;
|
|
|
+ left: 100px;
|
|
|
+ display: flex;
|
|
|
+ justify-content: center;
|
|
|
+ background: url(@/assets/images/gift-record/vip-bg.png) no-repeat;
|
|
|
+ background-size: 300px 24px;
|
|
|
+ width: 300px;
|
|
|
+ height: 24px;
|
|
|
+ line-height: 22px;
|
|
|
+ color: #FFFFFF;
|
|
|
}
|
|
|
}
|
|
|
</style>
|