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

222 lines
4.3 KiB

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