Hetong.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. <template>
  2. <view class="phone-hetong-page">
  3. <view class="phone-navBar-box">
  4. <view @click="goUpPage" class="nav-bar-icon"></view>
  5. <text class="nav-bar-title">合同</text>
  6. <uni-icons class="nav-bar-right-icon bar-ml10" type="list" @click="handleGoLishi" size="30"></uni-icons>
  7. </view>
  8. <template v-if="info.id">
  9. <view class="pdf-box">
  10. <image v-for="item in imgList" :mode="item.mode" :src="`data:image/png;base64,${item}`"></image>
  11. </view>
  12. <!-- -->
  13. <!-- <web-view class="dljt-pdf-view" :src="pdfUrl1" v-if="show"
  14. webview-styles="height: 50vh;margin-top: 75px"></web-view> -->
  15. </template>
  16. <template v-else>
  17. <view class="no-hetong-box">暂无合同</view>
  18. </template>
  19. <view class="hetong-tip-box" v-if="info.id && info.status == 0">
  20. 请务必仔细阅读上述内容,确认已完全理解所有条款后,点击【我已阅读】按钮完成签字确认。
  21. </view>
  22. <button v-if="info.id && info.status == 0" type="default" class="phone-green-btn ht-btn"
  23. @click="handleQianming">我已阅读</button>
  24. <uni-popup ref="popupRef" type="bottom" background-color="#fff" :is-mask-click="false" :mask-click="false">
  25. <view class="ht-qm-popup">
  26. <view class="icon-title-navBar-box">
  27. <view @click="goback2" class="nav-bar-icon"></view>
  28. <text class="nav-bar-title">签名</text>
  29. </view>
  30. <writeSign @getBase64="getBase64"></writeSign>
  31. </view>
  32. </uni-popup>
  33. </view>
  34. </template>
  35. <script setup>
  36. import {
  37. ref
  38. } from "vue";
  39. import * as httpApi from "@/api/hetong.js"
  40. import {
  41. onLoad
  42. } from "@dcloudio/uni-app"
  43. import writeSign from "@/components/writeSign/index.vue"
  44. import {throttleAdvanced} from "@/utils/common.js"
  45. const pdfUrl1 = ref('');
  46. const info = ref({})
  47. const show = ref(false)
  48. const popupRef = ref(null)
  49. const imgList = ref([])
  50. function goUpPage() {
  51. uni.navigateBack()
  52. }
  53. onLoad(({id}) => {
  54. init(id)
  55. })
  56. function init(id) {
  57. if (!id) {
  58. uni.showToast({
  59. title: '数据异常,请确认路径是否完整'
  60. })
  61. return;
  62. }
  63. httpApi.getHetongLast({id}).then(res => {
  64. info.value = res.data;
  65. // pdfUrl1.value = `/hybrid/html/web/viewer.html?file=${encodeURIComponent(res.data.pdfUrl)}`;
  66. // let pdfUrl2 = `https://mozilla.github.io/pdf.js/web/viewer.html?file=${encodeURIComponent(res.data.pdfUrl)}`
  67. // console.log('info', info.value)
  68. imgList.value = res.data.base64List;
  69. setTimeout(() => {
  70. console.log('xianshi')
  71. show.value = true;
  72. }, 3000)
  73. })
  74. }
  75. function handleGoLishi() {
  76. uni.redirectTo({
  77. url: '/pages/admin/Hetong/HetongList'
  78. })
  79. }
  80. function handleQianming() {
  81. popupRef.value.open()
  82. }
  83. const handleQM = throttleAdvanced((img) => {
  84. uni.showToast({
  85. title: "签名提交中...",
  86. mask: true,
  87. })
  88. httpApi.getHetongQianming({
  89. id: info.value.id,
  90. fuzeren: img.replace(/^data:image\/\w+;base64,/, '')
  91. }).then(res => {
  92. if (res.data) {
  93. uni.showToast({
  94. title: "签名成功",
  95. duration: 2000,
  96. mask: true,
  97. success() {
  98. setTimeout(() => uni.navigateBack(),2000)
  99. }
  100. })
  101. }
  102. })
  103. })
  104. function getBase64(img) {
  105. if (!img) {
  106. uni.showToast({
  107. title: '签名异常'
  108. })
  109. return;
  110. }
  111. handleQM(img)
  112. }
  113. function goback2() {
  114. popupRef.value.close()
  115. }
  116. </script>
  117. <style>
  118. </style>