Hetong.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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. <button v-if="info.id && info.status == 0" type="default" class="phone-green-btn ht-btn"
  18. @click="handleQianming">我已阅读</button>
  19. <uni-popup ref="popupRef" type="bottom" background-color="#fff" :is-mask-click="false" :mask-click="false">
  20. <view class="ht-qm-popup">
  21. <view class="icon-title-navBar-box">
  22. <view @click="goback2" class="nav-bar-icon"></view>
  23. <text class="nav-bar-title">签名</text>
  24. </view>
  25. <writeSign @getBase64="getBase64"></writeSign>
  26. </view>
  27. </uni-popup>
  28. </view>
  29. </template>
  30. <script setup>
  31. import {
  32. ref
  33. } from "vue";
  34. import * as httpApi from "@/api/hetong.js"
  35. import {
  36. onLoad
  37. } from "@dcloudio/uni-app"
  38. import writeSign from "@/components/writeSign/index.vue"
  39. const pdfUrl1 = ref('');
  40. const info = ref({})
  41. const show = ref(false)
  42. const popupRef = ref(null)
  43. function goUpPage() {
  44. uni.navigateBack()
  45. }
  46. onLoad(() => {
  47. init()
  48. })
  49. function init() {
  50. httpApi.getHetongLast().then(res => {
  51. info.value = res.data;
  52. pdfUrl1.value = `/hybrid/html/web/viewer.html?file=${encodeURIComponent(res.data.pdfUrl)}`;
  53. // let pdfUrl2 = `https://mozilla.github.io/pdf.js/web/viewer.html?file=${encodeURIComponent(res.data.pdfUrl)}`
  54. console.log('info', info.value)
  55. setTimeout(() => {
  56. console.log('xianshi')
  57. show.value = true;
  58. }, 3000)
  59. })
  60. }
  61. function handleGoLishi() {
  62. uni.redirectTo({
  63. url: '/pages/admin/Hetong/HetongList'
  64. })
  65. }
  66. function handleQianming() {
  67. popupRef.value.open()
  68. }
  69. function getBase64(img) {
  70. if (!img) {
  71. uni.showToast({
  72. title: '签名异常'
  73. })
  74. return;
  75. }
  76. httpApi.getHetongQianming({
  77. id: info.value.id,
  78. fuzeren: img.replace(/^data:image\/\w+;base64,/, '')
  79. }).then(res => {
  80. if (res.data) {
  81. uni.showToast({
  82. title: "签名成功",
  83. duration: 2000,
  84. success() {
  85. uni.navigateBack()
  86. }
  87. })
  88. }
  89. })
  90. }
  91. function goback2() {
  92. popupRef.value.close()
  93. }
  94. </script>
  95. <style>
  96. </style>