裂变星小程序-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.

218 lines
4.1 KiB

11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
  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. <text class="desc">{{ `群人数:${detail.memberNum || 0}` }}</text>
  8. <template v-if="isLocked">
  9. <button class="btn" type="success" @click="onAdd">加入</button>
  10. </template>
  11. <view v-else class="group-info flex">
  12. <text>扫一扫加群主审核进群</text>
  13. <image class="qr" :src="detail.wxCodeImage" :show-menu-by-longpress="true"></image>
  14. </view>
  15. </view>
  16. <popupUnlock ref="popupUnlock" src="../static/sharing/unlock-group.png"></popupUnlock>
  17. </view>
  18. </template>
  19. <script>
  20. import { mapState } from 'vuex'
  21. import popupUnlock from '../components/popupUnlock.vue'
  22. export default {
  23. components: {
  24. popupUnlock,
  25. },
  26. data() {
  27. return {
  28. id: null,
  29. detail: {
  30. id: null,
  31. avatarUrl: null,
  32. nickName: null,
  33. imageUrl: null,
  34. times: 0,
  35. qrCode: null,
  36. description: null,
  37. },
  38. isLocked: true,
  39. }
  40. },
  41. computed: {
  42. ...mapState(['userInfo']),
  43. },
  44. onShow() {
  45. if (this.id && uni.getStorageSync('token')) {
  46. this.fetchDetails()
  47. }
  48. },
  49. onLoad(option) {
  50. const { id, state, shareId } = option
  51. if (shareId) {
  52. uni.setStorageSync('shareId', shareId)
  53. }
  54. if (state) {
  55. uni.setStorageSync('state', state)
  56. }
  57. if (id) {
  58. uni.setStorageSync('id', id)
  59. }
  60. this.id = id
  61. if (uni.getStorageSync('token')) {
  62. this.fetchDetails()
  63. } else {
  64. uni.navigateTo({
  65. url: '/pages_order/auth/wxLogin'
  66. })
  67. }
  68. },
  69. onShareAppMessage(res) {
  70. const {
  71. headTitle,
  72. indexImage,
  73. } = this.detail
  74. let o = {
  75. title : headTitle,
  76. imageUrl: indexImage,
  77. query: `id=${this.id}&state=2&shareId=${this.userInfo.id}`,
  78. }
  79. this.refreshLockStatus()
  80. return o
  81. },
  82. methods: {
  83. async fetchDetails() {
  84. try {
  85. this.detail = await this.$fetch('getGroupShareInfo', { id: this.id })
  86. } catch (err) {
  87. }
  88. },
  89. async fetchCheckShare() {
  90. try {
  91. return await this.$fetch('checkGroupShare', { id: this.id })
  92. } catch (err) {
  93. return {}
  94. }
  95. },
  96. async refreshLockStatus() {
  97. const result = await this.fetchCheckShare()
  98. const { title, open } = result
  99. console.log('--open', open)
  100. this.$refs.popupUnlock.close();
  101. if (open) {
  102. this.isLocked = false
  103. return
  104. }
  105. title && uni.showToast({
  106. title,
  107. icon: 'none',
  108. duration: 3000
  109. })
  110. },
  111. openPopup() {
  112. this.$refs.popupUnlock.open();
  113. },
  114. async onAdd() {
  115. const result = await this.fetchCheckShare()
  116. const { open, need_num, num } = result
  117. console.log('--open', open)
  118. if (open) { // 转发已达标
  119. this.isLocked = false
  120. return
  121. }
  122. uni.showToast({
  123. title: `还需转发${need_num - num}`,
  124. icon: 'none',
  125. })
  126. this.openPopup()
  127. }
  128. },
  129. }
  130. </script>
  131. <style scoped lang="scss">
  132. .page {
  133. position: relative;
  134. height: 100vh;
  135. }
  136. .content {
  137. display: flex;
  138. flex-direction: column;
  139. align-items: center;
  140. }
  141. .avatar {
  142. width: 180rpx;
  143. height: 180rpx;
  144. margin-top: 127rpx;
  145. }
  146. .nick-name {
  147. color: #1B1B1B;
  148. font-size: 32rpx;
  149. margin-top: 30rpx;
  150. }
  151. .desc {
  152. margin-top: 30rpx;
  153. }
  154. .btn, .group-info {
  155. position: absolute;
  156. }
  157. .btn {
  158. width: calc(100% - 60rpx*2);
  159. height: auto;
  160. left: 60rpx;
  161. bottom: 292rpx;
  162. background-color: #07C160;
  163. border: none;
  164. color: #FFFFFF;
  165. font-size: 28rpx;
  166. line-height: 1;
  167. border-radius: 45rpx;
  168. padding: 25rpx 0;
  169. box-sizing: border-box;
  170. }
  171. .group-info {
  172. bottom: 269rpx;
  173. flex-direction: column;
  174. color: #1B1B1B;
  175. font-size: 32rpx;
  176. }
  177. .qr {
  178. margin-top: 40rpx;
  179. width: 350rpx;
  180. height: 350rpx;
  181. }
  182. </style>