|                                                                                                                                                                                                                                                                                      |  | <template>  <view ref="report" class="page__view export">		<!-- <navbar title="报告" leftClick @leftClick="$utils.navigateBack" /> -->
    <template v-if="tempFilePath">      <img         :src="tempFilePath"         @contextmenu.prevent        style="display: block; width: 100vw; height: auto;"      />    </template>    <template v-else-if="detail">      <view class="title">{{ detail.title }}</view>
      <view class="section">        <view class="flex section-header">          <view class="line"></view>          <view>总概述</view>        </view>        <view class="section-content">          <view class="summary">            <view class="text">              经过本次问答信息收集的综合分析,检测出风险点共<text class="highlight">{{ detail.levelAllNum - detail.level3Num }}</text>项,其中高风险{{ detail.level2Num }}项,中风险{{ detail.level1Num }}项,低风险{{ detail.level0Num }}项            </view>            <view class="flex charts">              <progressCircle label="高风险" :value="detail.level2Num" color="#FF0000"></progressCircle>              <progressCircle label="中风险" :value="detail.level1Num" color="#FFA800"></progressCircle>              <progressCircle label="低风险" :value="detail.level0Num" color="#014FA2"></progressCircle>              <progressCircle label="合规" :value="detail.level3Num" color="#5AC725"></progressCircle>            </view>          </view>          <view class="table">            <!-- 全部合规 -->            <template v-if="detail.level3Num === detail.levelAllNum">              <img ref="succ" class="img-succ" style="display: block;" :src="configList.compliance_img" crossorigin=“anonymous />            </template>            <template v-else>              <reportTableView :list="tableList"></reportTableView>            </template>          </view>        </view>      </view>
      <view class="flex flex-column contact" v-if="configList.company_qrcode">        <view>扫下方二维码联系我们给你1V1解决方案</view>        <img ref="qr" class="qr" style="display: block;" :src="configList.company_qrcode" crossorigin=“anonymous />      </view>            <view>        <img v-if="configList.company_info" ref="info" class="img" style="display: block;" :src="configList.company_info" crossorigin=“anonymous />        <view class="logo" v-if="configList.company_logo">          <img ref="logo" class="img" style="display: block;" :src="configList.company_logo" crossorigin=“anonymous />        </view>      </view>    </template>
  </view></template>
<script>  import html2canvas from 'html2canvas'
  import progressCircle from './progressCircle.vue';  import reportTableView from './reportTableView.vue';
  export default {    components: {      progressCircle,      reportTableView,    },    data() {      return {        batchNo: null,        detail: null,        tableList: [],        canvas: null,        tempFilePath: null      }    },    async onLoad(arg) {			uni.showLoading({				title: '生成中...'			})            document.addEventListener('UniAppJSBridgeReady', function() {        console.log('UniAppJSBridgeReady', uni)        uni.getEnv(function(res) {            console.log('当前环境:' + JSON.stringify(res));        });      })            const { batchNo, token } = arg      token && uni.setStorageSync('token', token)      this.batchNo = batchNo    },    async mounted() {      console.log('mounted', this.batchNo)      await this.getData(this.batchNo)
      let fetchs = [        { ref: 'qr', url: this.configList.company_qrcode },        { ref: 'info', url: this.configList.company_info },        { ref: 'logo', url: this.configList.company_logo },        { ref: 'succ', url: this.configList.compliance_img },      ].map(item => {        return this.preLoadImage(item.ref, item.url)      })
      await Promise.all(fetchs)
      setTimeout(async () => {        await this.createImage()        uni.hideLoading()                // H5环境下提示用户长按保存
        uni.showModal({          title: '保存报告',          content: '请长按图片,选择"保存图片"即可保存到手机',          showCancel: false,          confirmText: '知道了'        })      }, 1000)    },    methods: {      async getData(batchNo) {
        try {          const result = await this.$fetch('queryReportById', { batchNo })          const {            title,            level0Num, // 低风险
            level1Num, // 中风险
            level2Num, // 高风险
            level3Num, // 合规
            levelAllNum,            pageList,          } = result
          this.tableList = pageList.reduce((arr, item) => {            const { id, risk, reason, level, consequence } = item
            if (level == '3') {              return arr            }
            const obj = {              id,              reason,              level,              result: consequence,            }
            const index = arr.findIndex(row => row.title === risk)
            if (index === -1) {              arr.push({                id: arr.length,                title: risk,                children: [obj]              })            } else {              arr[index].children.push(obj)            }
            return arr          }, [])
          this.detail = {            title,            level0Num, // 低风险
            level1Num, // 中风险
            level2Num, // 高风险
            level3Num, // 合规
            levelAllNum,          }        } catch (err) {
        }      },      async preLoadImage(ref, url) {        return new Promise((resolve) => {          console.log(ref, url)          if (!this.$refs[ref] || !url) {            resolve()            return          }          uni.downloadFile({            url,            success: (res) => {              if (res.statusCode === 200) {                console.log('下载成功');                this.$refs[ref].src = res.tempFilePath                resolve()              }            },            fail: (err) => {              resolve()            }          });        })      },      async createImage() {        console.log('createImage')        const node = document.querySelector('.export')        const canvas = await html2canvas(node, { allowTaint: true, useCORS: true, })        const image = canvas.toDataURL('image/png')        this.tempFilePath = image
        uni?.postMessage?.({          data: {            imageData: image,          }        });              },    },  }</script>
<style scoped lang="scss">  .title {    width: 100%;    padding: 42rpx 0 40rpx 0;    box-sizing: border-box;    text-align: center;    font-size: 30rpx;    font-weight: 600;    color: #000000;  }
  .section {    padding: 0 12rpx;
    &-header {      justify-content: flex-start;      column-gap: 9rpx;      padding: 0 17rpx;      font-size: 28rpx;      font-weight: 600;      color: #014FA2;
      .line {        width: 9rpx;        height: 33rpx;        background: #014FA2;        border-radius: 6rpx;      }    }
    &-content {      margin-top: 30rpx;    }  }
  .summary {    .text {      padding: 20rpx 10rpx;      font-size: 26rpx;      color: #014FA2;      background: rgba($color: #014FA2, $alpha: 0.16);
      .highlight {        color: #DB5742;      }    }
    .charts {      margin-top: 54rpx;      justify-content: space-between;      padding: 0 42rpx;    }  }
  .table {    margin-top: 49rpx;  }
  .img-succ {    width: 100%;    height: auto;  }    .contact {    margin-top: 53rpx;    row-gap: 40rpx;    width: 100%;    padding: 30rpx 0 22rpx 0;    box-sizing: border-box;    font-size: 28rpx;    color: #014FA2;    border: 1rpx dashed #014FA2;
    .qr {      width: 157rpx;      height: auto;    }  }
  .img {    width: 100%;    height: auto;  }
  .logo {    width: 100%;    padding: 42rpx 127rpx 46rpx 127rpx;    box-sizing: border-box;  }
    .bottom {    position: sticky;    left: 0;    bottom: 0;    width: 100%;    padding: 35rpx 56rpx;    padding-bottom: calc(env(safe-area-inset-bottom) + 35rpx);    background: #FFFFFF;    box-sizing: border-box;
    .btn {      width: 100%;      padding: 29rpx 0;      font-size: 30rpx;      line-height: 1.5;      color: #FFFFFF;      background: #014FA2;      border-radius: 50rpx;    }  }</style>
 |