index.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <template>
  2. <view class="previewCard">
  3. <capsule :showBorder="true" bgColor="transparent">
  4. <template v-slot:top>
  5. <view class="detail-top">
  6. <view class="back-box" @click="goBack">
  7. <tui-icon name="arrowleft" color="#000" :size="28"></tui-icon>
  8. </view>
  9. <view class="top-text">预览名片</view>
  10. </view>
  11. </template>
  12. </capsule>
  13. <view class="seat"></view>
  14. <view class="box-bg"></view>
  15. <view class="card-box">
  16. <cardCom :cardData="cardInfo" :imgSerial="cardInfo.style"></cardCom>
  17. <view class="seat-list">
  18. <view class="seat-item" @click="callMobile">
  19. <image class="" src="@/static/images/preview_icon1.png" />
  20. <text>电话</text>
  21. </view>
  22. <view class="seat-item" @click="copyText('wechat')">
  23. <image class="" src="@/static/images/preview_icon2.png" />
  24. <text>微信</text>
  25. </view>
  26. <view class="seat-item" @click="copyText('address')">
  27. <image class="" src="@/static/images/preview_icon3.png" />
  28. <text>地址</text>
  29. </view>
  30. </view>
  31. <view class="card-bg">
  32. <image class="" src="@/static/images/card-bg.png" />
  33. </view>
  34. </view>
  35. <view class="brief">
  36. <view class="brief-item">
  37. <view class="item-title">个人简介</view>
  38. <view class="item-container">{{
  39. cardInfo.personalIntroduction || "--"
  40. }}</view>
  41. </view>
  42. <view class="brief-item">
  43. <view class="item-title">公司简介</view>
  44. <view class="item-container">{{ cardInfo.companyIntroduction }}</view>
  45. </view>
  46. </view>
  47. <view class="footer">
  48. <view class="btn-list" v-if="id == ''">
  49. <button @click="goBack">返回</button>
  50. </view>
  51. </view>
  52. </view>
  53. </template>
  54. <script>
  55. import cardCom from "@/components/cardCom/index.vue";
  56. import { getCardDetailApi } from "@/api/index.js";
  57. export default {
  58. components: {
  59. cardCom,
  60. },
  61. onLoad(option) {
  62. if (!option.id) {
  63. // 拿到本地存储的数据
  64. this.cardInfo = this.$cache.getCache("cardInfo");
  65. } else {
  66. this.id = option.id;
  67. // 请求名片数据
  68. this.getCardDetail();
  69. }
  70. },
  71. data() {
  72. return {
  73. id: "",
  74. cardInfo: {},
  75. };
  76. },
  77. methods: {
  78. // 根据 id 获取详情
  79. async getCardDetail() {
  80. let { data } = await getCardDetailApi({ id: this.id });
  81. this.cardInfo = data;
  82. },
  83. // 打电话
  84. callMobile() {
  85. uni.makePhoneCall({
  86. phoneNumber: this.cardInfo.mobile,
  87. });
  88. },
  89. // 复制内容
  90. copyText(txt) {
  91. console.log("进来了1111");
  92. uni.setClipboardData({
  93. data: this.cardInfo[txt] || '',
  94. success: () => {
  95. this.$showToast("复制成功");
  96. },
  97. fail:(err)=>{
  98. console.log(err);
  99. }
  100. });
  101. },
  102. goBack() {
  103. uni.navigateBack({
  104. delta: 1,
  105. fail: () => {
  106. if (this.id != "") {
  107. uni.reLaunch({
  108. url: "/pages/index/index",
  109. });
  110. }
  111. },
  112. });
  113. },
  114. },
  115. // 页面卸载
  116. onUnload() {
  117. // 删除本地存储
  118. this.$cache.removeCache("cardInfo");
  119. },
  120. };
  121. </script>
  122. <style lang="scss" scoped>
  123. @import "./index.scss";
  124. </style>