|
@@ -3,14 +3,13 @@
|
|
|
title="市场分析报告下载"
|
|
|
:visible.sync="options.visible"
|
|
|
:close-on-click-modal="false"
|
|
|
-
|
|
|
lock-scroll
|
|
|
center
|
|
|
top="15%"
|
|
|
custom-class="self-report-download-dialog"
|
|
|
width="1000px"
|
|
|
>
|
|
|
- <div class="content">
|
|
|
+ <div class="content" v-loading="loading">
|
|
|
<section class="report-effect-box">
|
|
|
<div class="left">
|
|
|
<p class="box-label">报告作用:</p>
|
|
@@ -23,6 +22,15 @@
|
|
|
<span v-for="item in totalList">{{item.label}}:<strong>{{ item.count + item.unit }}</strong></span>
|
|
|
<span class="highlight view-more" @click="viewMore">查看更多</span>
|
|
|
</section>
|
|
|
+ <section class="email-box">
|
|
|
+ <span class="email-label"><i class="star">*</i>接收邮箱:</span>
|
|
|
+ <el-input v-model="s_email" placeholder="必填,报告将发送至邮箱" @input="showEmailError = false" @change="checkEmail"></el-input>
|
|
|
+ <span class="error-tip" v-if="showEmailError">
|
|
|
+ <i class="el-icon-error"></i>
|
|
|
+ <span v-if="s_email">邮箱格式错误</span>
|
|
|
+ <span v-else>请输入邮箱</span>
|
|
|
+ </span>
|
|
|
+ </section>
|
|
|
<section class="download-notice-box">
|
|
|
<p class="box-label">下载须知:</p>
|
|
|
<div class="box-desc">
|
|
@@ -33,35 +41,33 @@
|
|
|
</div>
|
|
|
</section>
|
|
|
</div>
|
|
|
- <div slot="footer">
|
|
|
+ <div slot="footer" >
|
|
|
<div class="footer-con">
|
|
|
- <span class="residue">市场分析定制报告下载余额:1份</span>
|
|
|
+ <span class="residue">市场分析定制报告下载余额:{{ residueCount }}份</span>
|
|
|
<span class="go-recharge" @click="goRecharge">去充值></span>
|
|
|
<span class="deduct">本次扣除:<em>1份</em></span>
|
|
|
<span class="zero-tip" v-if="residueCount === 0">余额不足,请先充值</span>
|
|
|
</div>
|
|
|
- <el-button class="download-btn" type="primary" @click="downloadHandle">立即下载</el-button>
|
|
|
+ <el-button class="download-btn" type="primary" @click="downloadHandle" >立即下载</el-button>
|
|
|
</div>
|
|
|
</el-dialog>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import { Dialog, Button } from 'element-ui'
|
|
|
-import { debounce } from '@/utils/'
|
|
|
import { mapGetters } from 'vuex'
|
|
|
+import { getPDFPackBalance, sendPdfEmail, getPdfEmail, savePdfCondition } from '@/api/modules/'
|
|
|
+import { debounce } from '@/utils/'
|
|
|
+import { emailRegExp } from '@/utils/constant'
|
|
|
|
|
|
export default {
|
|
|
- components: {
|
|
|
- [Dialog.name]: Dialog,
|
|
|
- [Button.name]: Button
|
|
|
- },
|
|
|
props: {
|
|
|
options: {
|
|
|
type: Object,
|
|
|
default: () => {
|
|
|
return {
|
|
|
visible: false,
|
|
|
- totalList: []
|
|
|
+ totalList: [],
|
|
|
+ sid: ''
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -69,7 +75,10 @@ export default {
|
|
|
data () {
|
|
|
return {
|
|
|
// 下载余额
|
|
|
- residueCount: 0
|
|
|
+ residueCount: 0,
|
|
|
+ s_email: '',
|
|
|
+ showEmailError: false,
|
|
|
+ loading: false
|
|
|
}
|
|
|
},
|
|
|
computed: {
|
|
@@ -85,21 +94,69 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
created() {
|
|
|
+ console.log(this.options)
|
|
|
+ this.getEmail()
|
|
|
+ this.getResidueCount()
|
|
|
},
|
|
|
methods: {
|
|
|
- // 获取下载余额
|
|
|
- getResidueCount () {
|
|
|
+ async getEmail () {
|
|
|
+ const {error_code: code, data } = await getPdfEmail()
|
|
|
+ if(data && code === 0) {
|
|
|
+ this.s_email = data || ''
|
|
|
+ }
|
|
|
|
|
|
},
|
|
|
+ // 获取下载余额
|
|
|
+ async getResidueCount () {
|
|
|
+ const {error_code: code, data } = await getPDFPackBalance()
|
|
|
+ if(code === 0 && data) {
|
|
|
+ this.residueCount = data.market?.total || 0
|
|
|
+ }
|
|
|
+ },
|
|
|
// 查看报告样例
|
|
|
- viewExample (fileUrl) {
|
|
|
- // TODO 需要服务端提供链接
|
|
|
- window.open('https://www.kdocs.cn/l/ctXdN3LVDdjP', '_blank')
|
|
|
+ viewExample () {
|
|
|
+ window.open('/pdf-files/markerPdf/analyze.pdf', '_blank')
|
|
|
},
|
|
|
// 立即下载
|
|
|
- downloadHandle: debounce(function (fileUrl) {
|
|
|
- this.options.visible = false
|
|
|
- this.$confirm('您可前往“资产-报告下载记录”查看详情。', '报告下载成功', {
|
|
|
+ downloadHandle: debounce(function () {
|
|
|
+ if(this.residueCount > 0) {
|
|
|
+ if(this.showEmailError) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ const params = {
|
|
|
+ type: 3,
|
|
|
+ sid: this.options.sid,
|
|
|
+ s_email: this.s_email
|
|
|
+ }
|
|
|
+ this.loading = true
|
|
|
+ // 保存pdf的条件
|
|
|
+ savePdfCondition(params).then(res => {
|
|
|
+ const {error_code: code, data } = res
|
|
|
+ if(code === 0 && data) {
|
|
|
+ // 发送邮箱
|
|
|
+ // 此处id是接口返回的id
|
|
|
+ const params = {
|
|
|
+ sid: data
|
|
|
+ }
|
|
|
+ sendPdfEmail(params).then(response => {
|
|
|
+ if(response.error_code === 0 && response.data) {
|
|
|
+ this.showConfirmDialog()
|
|
|
+ }
|
|
|
+ }).finally(() => {
|
|
|
+ this.loading = false
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }).catch(() => {
|
|
|
+ this.loading = false
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ // 余额不足
|
|
|
+ this.goRecharge()
|
|
|
+ }
|
|
|
+ }, 300),
|
|
|
+ showConfirmDialog () {
|
|
|
+ const _this = this
|
|
|
+ this.$confirm('报告将于10分钟内发送至您的邮箱内,您也可前往“资产-报告下载记录”查看详情。', '报告下载成功', {
|
|
|
confirmButtonText: '返回',
|
|
|
cancelButtonText: '查看下载记录',
|
|
|
center: true,
|
|
@@ -107,20 +164,28 @@ export default {
|
|
|
customClass: 'download-message-tip btn-reverse',
|
|
|
}).then(() => {
|
|
|
}).catch(() => {
|
|
|
+ _this.$router.push('/report/download_record')
|
|
|
})
|
|
|
- }, 300),
|
|
|
+ },
|
|
|
// 查看更多
|
|
|
viewMore () {
|
|
|
this.options.visible = false
|
|
|
},
|
|
|
// 去充值
|
|
|
goRecharge () {
|
|
|
-
|
|
|
+ this.$router.push('/order/download-pack/market')
|
|
|
},
|
|
|
// 联系客服
|
|
|
openCustomer() {
|
|
|
this.options.visible = false
|
|
|
this.contactCustomer(this)
|
|
|
+ },
|
|
|
+ checkEmail () {
|
|
|
+ if (!emailRegExp.test(this.s_email)) {
|
|
|
+ this.showEmailError = true
|
|
|
+ } else {
|
|
|
+ this.showEmailError = false
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -177,6 +242,44 @@ export default {
|
|
|
background: linear-gradient(180deg, #F7F9FA 100%, #F7F9FA 0%);
|
|
|
border-radius: 8px;
|
|
|
border: 1px solid rgba(0,0,0, 0.05);
|
|
|
+ }
|
|
|
+ .email-box{
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ font-size:14px;
|
|
|
+ .email-label{
|
|
|
+ display: inline-block;
|
|
|
+ width:94px;
|
|
|
+ color: #5F5E64;
|
|
|
+ }
|
|
|
+ .star {
|
|
|
+ color: #ff3a20;
|
|
|
+ margin-right:3px;
|
|
|
+ }
|
|
|
+ .error-tip {
|
|
|
+ color: #ff3a20;
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ .el-icon-error{
|
|
|
+ font-size:22px;
|
|
|
+ margin:0 8px;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ::v-deep {
|
|
|
+ .el-input {
|
|
|
+ width: 438px;
|
|
|
+ }
|
|
|
+ .el-input__inner{
|
|
|
+ width: 438px;
|
|
|
+ height: 36px;
|
|
|
+ line-height: 36px;
|
|
|
+ font-size:14px;
|
|
|
+ line-hieght: 22px;
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
.highlight {
|
|
|
color: $color_main;
|