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. onLoad(({id}) => {
  50. init(id)
  51. })
  52. function init(id) {
  53. if (!id) {
  54. uni.showToast({
  55. title: '数据异常,请确认路径是否完整'
  56. })
  57. return;
  58. }
  59. httpApi.getHetongLast({id}).then(res => {
  60. info.value = res.data;
  61. pdfUrl1.value = `/hybrid/html/web/viewer.html?file=${encodeURIComponent(res.data.pdfUrl)}`;
  62. // let pdfUrl2 = `https://mozilla.github.io/pdf.js/web/viewer.html?file=${encodeURIComponent(res.data.pdfUrl)}`
  63. console.log('info', info.value)
  64. setTimeout(() => {
  65. console.log('xianshi')
  66. show.value = true;
  67. }, 3000)
  68. })
  69. }
  70. function handleGoLishi() {
  71. uni.redirectTo({
  72. url: '/pages/admin/Hetong/HetongList'
  73. })
  74. }
  75. function handleQianming() {
  76. popupRef.value.open()
  77. }
  78. const handleQM = throttleAdvanced((img) => {
  79. uni.showToast({
  80. title: "签名提交中...",
  81. mask: true,
  82. })
  83. httpApi.getHetongQianming({
  84. id: info.value.id,
  85. fuzeren: img.replace(/^data:image\/\w+;base64,/, '')
  86. }).then(res => {
  87. if (res.data) {
  88. uni.showToast({
  89. title: "签名成功",
  90. duration: 2000,
  91. mask: true,
  92. success() {
  93. setTimeout(() => uni.navigateBack(),2000)
  94. }
  95. })
  96. }
  97. })
  98. })
  99. function getBase64(img) {
  100. if (!img) {
  101. uni.showToast({
  102. title: '签名异常'
  103. })
  104. return;
  105. }
  106. handleQM(img)
  107. }
  108. function goback2() {
  109. popupRef.value.close()
  110. }
  111. </script>
  112. <style>
  113. </style>