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

228 lines
4.3 KiB

1 week 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. //调用增加分享次数的方法
  80. const params = {
  81. id:this.id,
  82. state:"2",
  83. }
  84. this.$fetch('addLogShareInfo', params)
  85. this.refreshLockStatus()
  86. return o
  87. },
  88. methods: {
  89. async fetchDetails() {
  90. try {
  91. this.detail = await this.$fetch('getGroupShareInfo', { id: this.id })
  92. } catch (err) {
  93. }
  94. },
  95. async fetchCheckShare() {
  96. try {
  97. return await this.$fetch('checkGroupShare', { id: this.id })
  98. } catch (err) {
  99. return {}
  100. }
  101. },
  102. async refreshLockStatus() {
  103. const result = await this.fetchCheckShare()
  104. const { title, open } = result
  105. console.log('--open', open)
  106. this.$refs.popupUnlock.close();
  107. if (open) {
  108. this.isLocked = false
  109. return
  110. }
  111. title && uni.showToast({
  112. title,
  113. icon: 'none',
  114. duration: 3000
  115. })
  116. },
  117. openPopup() {
  118. this.$refs.popupUnlock.open();
  119. },
  120. async onAdd() {
  121. const result = await this.fetchCheckShare()
  122. const { open, need_num, num } = result
  123. console.log('--open', open)
  124. if (open) { // 转发已达标
  125. this.isLocked = false
  126. return
  127. }
  128. uni.showToast({
  129. title: `还需转发${need_num - num}`,
  130. icon: 'none',
  131. })
  132. this.openPopup()
  133. }
  134. },
  135. }
  136. </script>
  137. <style scoped lang="scss">
  138. .page {
  139. position: relative;
  140. height: 100vh;
  141. }
  142. .content {
  143. display: flex;
  144. flex-direction: column;
  145. align-items: center;
  146. }
  147. .avatar {
  148. width: 180rpx;
  149. height: 180rpx;
  150. margin-top: 127rpx;
  151. }
  152. .nick-name {
  153. color: #1B1B1B;
  154. font-size: 32rpx;
  155. margin-top: 30rpx;
  156. }
  157. .desc {
  158. margin-top: 30rpx;
  159. }
  160. .btn, .group-info {
  161. position: absolute;
  162. }
  163. .btn {
  164. width: calc(100% - 60rpx*2);
  165. height: auto;
  166. left: 60rpx;
  167. bottom: 292rpx;
  168. background-color: #07C160;
  169. border: none;
  170. color: #FFFFFF;
  171. font-size: 28rpx;
  172. line-height: 1;
  173. border-radius: 45rpx;
  174. padding: 25rpx 0;
  175. box-sizing: border-box;
  176. }
  177. .group-info {
  178. bottom: 269rpx;
  179. flex-direction: column;
  180. color: #1B1B1B;
  181. font-size: 32rpx;
  182. }
  183. .qr {
  184. margin-top: 40rpx;
  185. width: 350rpx;
  186. height: 350rpx;
  187. }
  188. </style>