haibaoInfo.vue 2.4 KB

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