haibaoInfo.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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="getUUid" 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="海报" desc="请点击查看海报详情" :link=haibaoUrl type="0" @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. function onShareSuccess(e){
  48. console.log('分享成功', e.scene)
  49. }
  50. function goUpPage() {
  51. uni.redirectTo({
  52. url: `/pages/admin/haibao/index?menuId=${data.menuId}`
  53. })
  54. }
  55. function getHaibaoOpsZhiyeData(id) {
  56. httpApi.getHaibaoInfo({
  57. id
  58. }).then(res => {
  59. data.img = res.data.image;
  60. data.jzName = res.data.jzName;
  61. data.realName = res.data.realName;
  62. data.tel = res.data.tel;
  63. }).catch(err => {
  64. console.error('加载海报失败:', err)
  65. uni.showToast({
  66. title: '加载失败',
  67. icon: 'none'
  68. })
  69. })
  70. }
  71. function getUUid() {
  72. httpApi.haibaoShare({
  73. id: data.id
  74. }).then(res => {
  75. if (res.code == 0) {
  76. data.uuid = res.data.uuid
  77. haibaoUrl.value = `${config.haibaoUrl}?uuid=${data.uuid}`
  78. sharePopupRef.value.open()
  79. }
  80. }).catch(err => {
  81. uni.showToast({
  82. title: '获得uuid失败',
  83. icon: 'none'
  84. })
  85. })
  86. }
  87. onLoad((options) => {
  88. data.id = options.cardId || ''
  89. data.menuId = options.menuId || ''
  90. if (data.id) {
  91. getHaibaoOpsZhiyeData(data.id)
  92. }
  93. })
  94. </script>