风险测评小程序前端代码仓库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

315 lines
7.7 KiB

1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
  1. <template>
  2. <view ref="report" class="page__view export">
  3. <!-- <navbar title="报告" leftClick @leftClick="$utils.navigateBack" /> -->
  4. <template v-if="tempFilePath">
  5. <img
  6. :src="tempFilePath"
  7. @contextmenu.prevent
  8. style="display: block; width: 100vw; height: auto;"
  9. />
  10. </template>
  11. <template v-else-if="detail">
  12. <view class="title">{{ detail.title }}</view>
  13. <view class="section">
  14. <view class="flex section-header">
  15. <view class="line"></view>
  16. <view>总概述</view>
  17. </view>
  18. <view class="section-content">
  19. <view class="summary">
  20. <view class="text">
  21. 经过本次问答信息收集的综合分析检测出风险点共<text class="highlight">{{ detail.levelAllNum - detail.level3Num }}</text>其中高风险{{ detail.level2Num }}中风险{{ detail.level1Num }}低风险{{ detail.level0Num }}
  22. </view>
  23. <view class="flex charts">
  24. <progressCircle label="高风险" :value="detail.level2Num" color="#FF0000"></progressCircle>
  25. <progressCircle label="中风险" :value="detail.level1Num" color="#FFA800"></progressCircle>
  26. <progressCircle label="低风险" :value="detail.level0Num" color="#014FA2"></progressCircle>
  27. <progressCircle label="合规" :value="detail.level3Num" color="#5AC725"></progressCircle>
  28. </view>
  29. </view>
  30. <view class="table">
  31. <!-- 全部合规 -->
  32. <template v-if="detail.level3Num === detail.levelAllNum">
  33. <img class="img-succ" style="display: block;" :src="configList.compliance_img" crossorigin=anonymous />
  34. </template>
  35. <template v-else>
  36. <reportTableView :list="tableList"></reportTableView>
  37. </template>
  38. </view>
  39. </view>
  40. </view>
  41. <view class="flex flex-column contact">
  42. <view>扫下方二维码联系我们给你1V1解决方案</view>
  43. <img class="qr" style="display: block;" :src="configList.company_qrcode" crossorigin=anonymous />
  44. </view>
  45. <view>
  46. <img class="img" style="display: block;" :src="configList.company_info" crossorigin=anonymous />
  47. <view class="logo">
  48. <img class="img" style="display: block;" :src="configList.company_logo" crossorigin=anonymous />
  49. </view>
  50. </view>
  51. </template>
  52. <!-- <view class="bottom" data-html2canvas-ignore="true">
  53. <button class="btn" @click="onDownload">长按图片保存到手机</button>
  54. </view> -->
  55. </view>
  56. </template>
  57. <script>
  58. import html2canvas from 'html2canvas'
  59. import progressCircle from './progressCircle.vue';
  60. import reportTableView from './reportTableView.vue';
  61. export default {
  62. components: {
  63. progressCircle,
  64. reportTableView,
  65. },
  66. data() {
  67. return {
  68. detail: null,
  69. tableList: [],
  70. canvas: null,
  71. tempFilePath: null
  72. }
  73. },
  74. async onLoad(arg) {
  75. uni.showLoading({
  76. title: '生成中...'
  77. })
  78. document.addEventListener('UniAppJSBridgeReady', function() {
  79. console.log('UniAppJSBridgeReady', uni)
  80. uni.getEnv(function(res) {
  81. console.log('当前环境:' + JSON.stringify(res));
  82. });
  83. })
  84. const { batchNo, token } = arg
  85. token && uni.setStorageSync('token', token)
  86. await this.getData(batchNo)
  87. setTimeout(async () => {
  88. await this.createImage()
  89. uni.hideLoading()
  90. // H5环境下提示用户长按保存
  91. uni.showModal({
  92. title: '保存报告',
  93. content: '请长按图片,选择"保存图片"即可保存到手机',
  94. showCancel: false,
  95. confirmText: '知道了'
  96. })
  97. }, 800)
  98. },
  99. methods: {
  100. async getData(batchNo) {
  101. try {
  102. const result = await this.$fetch('queryReportById', { batchNo })
  103. const {
  104. title,
  105. level0Num, // 低风险
  106. level1Num, // 中风险
  107. level2Num, // 高风险
  108. level3Num, // 合规
  109. levelAllNum,
  110. pageList,
  111. } = result
  112. this.tableList = pageList.reduce((arr, item) => {
  113. const { id, risk, reason, level, consequence } = item
  114. if (level == '3') {
  115. return arr
  116. }
  117. const obj = {
  118. id,
  119. reason,
  120. level,
  121. result: consequence,
  122. }
  123. const index = arr.findIndex(row => row.title === risk)
  124. if (index === -1) {
  125. arr.push({
  126. id: arr.length,
  127. title: risk,
  128. children: [obj]
  129. })
  130. } else {
  131. arr[index].children.push(obj)
  132. }
  133. return arr
  134. }, [])
  135. this.detail = {
  136. title,
  137. level0Num, // 低风险
  138. level1Num, // 中风险
  139. level2Num, // 高风险
  140. level3Num, // 合规
  141. levelAllNum,
  142. }
  143. } catch (err) {
  144. }
  145. },
  146. async createImage() {
  147. console.log('createImage')
  148. const node = document.querySelector('.export')
  149. const canvas = await html2canvas(node, { allowTaint: true, useCORS: true, })
  150. const image = canvas.toDataURL('image/png')
  151. this.tempFilePath = image
  152. uni?.postMessage?.({
  153. data: {
  154. imageData: image,
  155. }
  156. });
  157. },
  158. onDownload() {
  159. if (!this.tempFilePath) {
  160. uni.showToast({
  161. title: '图片还未生成完成',
  162. icon: 'none'
  163. })
  164. return
  165. }
  166. // H5环境下提示用户长按保存
  167. uni.showModal({
  168. title: '保存图片',
  169. content: '请长按上方图片,选择"保存图片"即可保存到手机',
  170. showCancel: false,
  171. confirmText: '知道了'
  172. })
  173. },
  174. },
  175. }
  176. </script>
  177. <style scoped lang="scss">
  178. .title {
  179. width: 100%;
  180. padding: 42rpx 0 40rpx 0;
  181. box-sizing: border-box;
  182. text-align: center;
  183. font-size: 30rpx;
  184. font-weight: 600;
  185. color: #000000;
  186. }
  187. .section {
  188. padding: 0 12rpx;
  189. &-header {
  190. justify-content: flex-start;
  191. column-gap: 9rpx;
  192. padding: 0 17rpx;
  193. font-size: 28rpx;
  194. font-weight: 600;
  195. color: #014FA2;
  196. .line {
  197. width: 9rpx;
  198. height: 33rpx;
  199. background: #014FA2;
  200. border-radius: 6rpx;
  201. }
  202. }
  203. &-content {
  204. margin-top: 30rpx;
  205. }
  206. }
  207. .summary {
  208. .text {
  209. padding: 20rpx 10rpx;
  210. font-size: 26rpx;
  211. color: #014FA2;
  212. background: rgba($color: #014FA2, $alpha: 0.16);
  213. .highlight {
  214. color: #DB5742;
  215. }
  216. }
  217. .charts {
  218. margin-top: 54rpx;
  219. justify-content: space-between;
  220. padding: 0 42rpx;
  221. }
  222. }
  223. .table {
  224. margin-top: 49rpx;
  225. }
  226. .img-succ {
  227. width: 100%;
  228. height: auto;
  229. }
  230. .contact {
  231. margin-top: 53rpx;
  232. row-gap: 40rpx;
  233. width: 100%;
  234. padding: 30rpx 0 22rpx 0;
  235. box-sizing: border-box;
  236. font-size: 28rpx;
  237. color: #014FA2;
  238. border: 1rpx dashed #014FA2;
  239. .qr {
  240. width: 157rpx;
  241. height: auto;
  242. }
  243. }
  244. .img {
  245. width: 100%;
  246. height: auto;
  247. }
  248. .logo {
  249. width: 100%;
  250. padding: 42rpx 127rpx 46rpx 127rpx;
  251. box-sizing: border-box;
  252. }
  253. .bottom {
  254. position: sticky;
  255. left: 0;
  256. bottom: 0;
  257. width: 100%;
  258. padding: 35rpx 56rpx;
  259. padding-bottom: calc(env(safe-area-inset-bottom) + 35rpx);
  260. background: #FFFFFF;
  261. box-sizing: border-box;
  262. .btn {
  263. width: 100%;
  264. padding: 29rpx 0;
  265. font-size: 30rpx;
  266. line-height: 1.5;
  267. color: #FFFFFF;
  268. background: #014FA2;
  269. border-radius: 50rpx;
  270. }
  271. }
  272. </style>