Hetong.vue 3.1 KB

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