Hetong.vue 3.2 KB

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