裂变星小程序-25.03.04
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

164 lines
3.1 KiB

  1. <template>
  2. <view class="page">
  3. <navbar leftClick @leftClick="$utils.navigateBack" />
  4. <view class="content">
  5. <image class="avatar" :src="detail.headImage"></image>
  6. <text class="nick-name">{{ detail.headTitle }}</text>
  7. <template v-if="isLocked">
  8. <button class="btn" type="success" @click="onAdd">添加</button>
  9. </template>
  10. <template v-else>
  11. <image class="qr" :src="detail.wxCodeImage" :show-menu-by-longpress="true"></image>
  12. </template>
  13. </view>
  14. <popupUnlock ref="popupUnlock" src="../static/sharing/unlock-user.png"></popupUnlock>
  15. </view>
  16. </template>
  17. <script>
  18. import popupUnlock from '../components/popupUnlock.vue'
  19. export default {
  20. components: {
  21. popupUnlock,
  22. },
  23. data() {
  24. return {
  25. detail: {
  26. id: null,
  27. userId: null,
  28. headImage: null,
  29. headTitle: null,
  30. indexImage: null,
  31. num: 10,
  32. wxCodeImage: null,
  33. textDetails: null,
  34. },
  35. isLocked: true,
  36. }
  37. },
  38. onLoad(option) {
  39. const { id } = option
  40. this.fetchDetails(id)
  41. },
  42. onShareAppMessage(res) {
  43. const {
  44. headTitle,
  45. indexImage,
  46. } = this.detail
  47. let o = {
  48. title : headTitle,
  49. imageUrl: indexImage,
  50. query: `id=${this.id}`,
  51. }
  52. // todo: get times and check is unlocked
  53. this.refreshLockStatus()
  54. return o
  55. },
  56. methods: {
  57. async fetchDetails(id) {
  58. try {
  59. this.detail = await this.$fetch('getShareInfo', { id })
  60. } catch (err) {
  61. }
  62. },
  63. async fetchCheckShare(id) {
  64. try {
  65. return await this.$fetch('checkShare', { id })
  66. } catch (err) {
  67. return {}
  68. }
  69. },
  70. async refreshLockStatus() {
  71. const result = await this.fetchCheckShare()
  72. const { title, open } = result
  73. if (open) {
  74. this.isLocked = false
  75. this.$refs.popupUnlock.close();
  76. return
  77. }
  78. title && uni.showToast({
  79. title,
  80. icon: 'none',
  81. duration: 3000
  82. })
  83. },
  84. openPopup() {
  85. this.$refs.popupUnlock.open();
  86. },
  87. async onAdd() {
  88. const result = await this.fetchCheckShare()
  89. const { open } = result
  90. // todo: check
  91. if (open) { // 转发已达标
  92. this.isLocked = false
  93. return
  94. }
  95. this.openPopup()
  96. }
  97. },
  98. }
  99. </script>
  100. <style scoped lang="scss">
  101. .page {
  102. position: relative;
  103. height: 100vh;
  104. }
  105. .content {
  106. display: flex;
  107. flex-direction: column;
  108. align-items: center;
  109. }
  110. .avatar {
  111. width: 180rpx;
  112. height: 180rpx;
  113. margin-top: 127rpx;
  114. }
  115. .nick-name {
  116. color: #1B1B1B;
  117. font-size: 32rpx;
  118. margin-top: 30rpx;
  119. }
  120. .btn, .qr {
  121. position: absolute;
  122. }
  123. .btn {
  124. width: calc(100% - 60rpx*2);
  125. height: auto;
  126. left: 60rpx;
  127. bottom: 292rpx;
  128. background-color: #07C160;
  129. border: none;
  130. color: #FFFFFF;
  131. font-size: 28rpx;
  132. line-height: 1;
  133. border-radius: 45rpx;
  134. padding: 25rpx 0;
  135. box-sizing: border-box;
  136. }
  137. .qr {
  138. width: 350rpx;
  139. height: 350rpx;
  140. bottom: 269rpx;
  141. }
  142. </style>