index.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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="previewCard">
  19. <image class="" src="@/static/images/my_icon1.png" />
  20. <text>预览</text>
  21. </view>
  22. <view class="seat-item" @click="editCard">
  23. <image class="" src="@/static/images/my_icon2.png" />
  24. <text>编辑</text>
  25. </view>
  26. <view class="seat-item" @click="deleteCard">
  27. <image class="" src="@/static/images/my_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="btn-box">
  36. <button open-type="share">发名片</button>
  37. </view>
  38. <view class="card-data">
  39. <view class="card-container">
  40. <view class="data-top">
  41. <text>名片数据</text>
  42. <tui-icon
  43. name="arrowright"
  44. :size="22"
  45. color="rgba(0, 0, 0, 0.9)"
  46. ></tui-icon>
  47. </view>
  48. <view class="data-bottom">
  49. <view class="bottom-item">
  50. <text>12</text>
  51. <text>今日访客</text>
  52. </view>
  53. <view class="bottom-item">
  54. <text>100</text>
  55. <text>总访客</text>
  56. </view>
  57. </view>
  58. </view>
  59. </view>
  60. </view>
  61. </template>
  62. <script>
  63. import cardCom from "@/components/cardCom/index.vue";
  64. import { getCardDetailApi, deleteCardApi } from "@/api/index.js";
  65. export default {
  66. components: {
  67. cardCom,
  68. },
  69. onLoad(option) {
  70. this.id = option.id;
  71. this.getCardDetail();
  72. },
  73. data() {
  74. return {
  75. id: null,
  76. cardInfo: {},
  77. };
  78. },
  79. methods: {
  80. // 根据 id 获取详情
  81. async getCardDetail() {
  82. let { data } = await getCardDetailApi({ id: this.id });
  83. this.cardInfo = data;
  84. },
  85. // 预览名片
  86. previewCard() {
  87. // 存储数据到本地
  88. this.$cache.setCache("cardInfo", this.cardInfo);
  89. // 跳转预览页面
  90. uni.navigateTo({
  91. url: "/pages_module/previewCard/index",
  92. });
  93. },
  94. // 编辑名片
  95. editCard() {
  96. // 存储数据到本地
  97. this.$cache.setCache("cardInfo", this.cardInfo);
  98. // 跳转编辑页面
  99. uni.navigateTo({
  100. url: `/pages_module/establish/index?id=${this.cardInfo.id}`,
  101. });
  102. },
  103. // 删除名片
  104. deleteCard() {
  105. // #ifdef MP-WEIXIN
  106. wx.showModal({
  107. title: "提示",
  108. content: "是否删除当前名片",
  109. success: async (res) => {
  110. if (res.confirm) {
  111. let res = await deleteCardApi({ id: this.cardInfo.id });
  112. if (res.statusCode == 20000) {
  113. this.$showToast("删除成功...", "success");
  114. setTimeout(() => {
  115. // 跳转首页
  116. uni.reLaunch({
  117. url: "/pages/index/index",
  118. });
  119. }, 1200);
  120. }
  121. }
  122. },
  123. });
  124. // #endif
  125. },
  126. // 返回
  127. goBack() {
  128. uni.navigateBack({
  129. delta: 1,
  130. fail: () => {
  131. uni.reLaunch({
  132. url: "/pages/index/index",
  133. });
  134. },
  135. });
  136. },
  137. },
  138. onShareAppMessage(){
  139. return {
  140. title:"团蜂小名片",
  141. path: `/pages_module/previewCard/index?id=${this.cardInfo.id}`
  142. }
  143. },
  144. };
  145. </script>
  146. <style lang="scss" scoped>
  147. @import "./index.scss";
  148. </style>