Hetong.vue 2.5 KB

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