haibaoInfo.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <template>
  2. <view class="phone-haibao-info-page">
  3. <view class="phone-navBar-box">
  4. <view @click="goUpPage" class="nav-bar-icon"></view>
  5. <text class="nav-bar-title">职业海报</text>
  6. <view @click="getHaibaoImg" class="text-btn">分享</view>
  7. </view>
  8. <view class="haibao-info-body-box">
  9. <view v-if="data.img" class="img-box">
  10. <img :src="data.img" class="haibao-image" />
  11. <view class="info-text-box">
  12. <view class="haibao-info-text">
  13. <icon class="jz-icon"></icon>{{data.jzName}}
  14. </view>
  15. <view class="haibao-info-text">
  16. <icon class="tel-icon"></icon>{{data.realName}}({{data.tel}})
  17. </view>
  18. </view>
  19. </view>
  20. <view v-else class="loading-text">暂无数据</view>
  21. </view>
  22. </view>
  23. <share-popup ref="sharePopupRef" title="海报" :image="haibaoImage" type="2" @success="onShareSuccess" />
  24. </template>
  25. <script setup>
  26. import {
  27. reactive,
  28. ref
  29. } from "vue"
  30. import {
  31. onLoad
  32. } from "@dcloudio/uni-app";
  33. import * as httpApi from '@/api/haibao.js'
  34. import SharePopup from '@/components/sharePopUp/index.vue'
  35. import config from "../../../config"
  36. const data = reactive({
  37. img: '',
  38. id: '',
  39. menuId: '',
  40. jzName: '',
  41. realName: '',
  42. tel: '',
  43. uuid: ''
  44. })
  45. const haibaoUrl = ref('')
  46. const sharePopupRef = ref(null)
  47. const haibaoImage = ref(null)
  48. function onShareSuccess(e) {
  49. console.log('分享成功', e.scene)
  50. }
  51. function goUpPage() {
  52. uni.redirectTo({
  53. url: `/pages/admin/haibao/index?menuId=${data.menuId}`
  54. })
  55. }
  56. function getHaibaoOpsZhiyeData(id) {
  57. httpApi.getHaibaoInfo({
  58. id
  59. }).then(res => {
  60. data.img = res.data.image;
  61. data.jzName = res.data.jzName;
  62. data.realName = res.data.realName;
  63. data.tel = res.data.tel;
  64. }).catch(err => {
  65. console.error('加载海报失败:', err)
  66. uni.showToast({
  67. title: '加载失败',
  68. icon: 'none'
  69. })
  70. })
  71. }
  72. function getHaibaoImg() {
  73. httpApi.haibaoShare({
  74. id: data.id
  75. }).then(res => {
  76. console.log(res, 'res');
  77. if (res.code == 0) {
  78. haibaoImage.value = res.data
  79. sharePopupRef.value.open()
  80. }
  81. }).catch(err => {
  82. uni.showToast({
  83. title: '获得海报图片失败',
  84. icon: 'none'
  85. })
  86. })
  87. }
  88. onLoad((options) => {
  89. data.id = options.cardId || ''
  90. data.menuId = options.menuId || ''
  91. if (data.id) {
  92. getHaibaoOpsZhiyeData(data.id)
  93. }
  94. })
  95. </script>