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

233 lines
4.5 KiB

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
  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 shareLog from '@/utils/shareLog'
  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.detail.id ? this.refreshLockStatus() : this.fetchDetails()
  47. // }
  48. if (this.detail.id) { // 转发后返回页面的场景
  49. this.refreshLockStatus()
  50. }
  51. },
  52. onLoad(option) {
  53. const { id, state, shareId } = option
  54. if (shareId) {
  55. uni.setStorageSync('shareId', shareId)
  56. }
  57. if (state) {
  58. uni.setStorageSync('state', state)
  59. }
  60. if (id) {
  61. uni.setStorageSync('id', id)
  62. }
  63. this.id = id
  64. // if (uni.getStorageSync('token')) {
  65. // this.fetchDetails()
  66. // } else {
  67. // uni.navigateTo({
  68. // url: '/pages_order/auth/wxLogin'
  69. // })
  70. // }
  71. this.fetchDetails()
  72. },
  73. onShareAppMessage(res) {
  74. const {
  75. textDetails,
  76. indexImage,
  77. } = this.detail
  78. let o = {
  79. title : textDetails,
  80. imageUrl: indexImage,
  81. query: `id=${this.id}&state=2&shareId=${this.userInfo.id}`,
  82. }
  83. //调用增加分享次数的方法
  84. const params = {
  85. id:this.id,
  86. state:"2",
  87. }
  88. this.$fetch('addLogShareInfo', params)
  89. shareLog.insert(this.id)
  90. return o
  91. },
  92. methods: {
  93. async fetchDetails() {
  94. try {
  95. this.detail = await this.$fetch('getGroupShareInfo', { id: this.id })
  96. } catch (err) {
  97. }
  98. },
  99. async fetchCheckShare() {
  100. try {
  101. return await shareLog.check(this.id, this.detail.num)
  102. } catch (err) {
  103. return {}
  104. }
  105. },
  106. async refreshLockStatus() {
  107. const result = await this.fetchCheckShare()
  108. const { title, open } = result
  109. console.log('--open', open)
  110. this.$refs.popupUnlock.close();
  111. if (open) {
  112. this.isLocked = false
  113. return
  114. }
  115. title && uni.showToast({
  116. title,
  117. icon: 'none',
  118. duration: 3000
  119. })
  120. },
  121. openPopup() {
  122. this.$refs.popupUnlock.open();
  123. },
  124. async onAdd() {
  125. const result = await this.fetchCheckShare()
  126. const { open, need_num, num } = result
  127. console.log('--open', open)
  128. if (open) { // 转发已达标
  129. this.isLocked = false
  130. return
  131. }
  132. uni.showToast({
  133. title: `还需转发${need_num - num}`,
  134. icon: 'none',
  135. })
  136. this.openPopup()
  137. }
  138. },
  139. }
  140. </script>
  141. <style scoped lang="scss">
  142. .page {
  143. position: relative;
  144. height: 100vh;
  145. }
  146. .content {
  147. display: flex;
  148. flex-direction: column;
  149. align-items: center;
  150. }
  151. .avatar {
  152. width: 180rpx;
  153. height: 180rpx;
  154. margin-top: 127rpx;
  155. }
  156. .nick-name {
  157. color: #1B1B1B;
  158. font-size: 32rpx;
  159. margin-top: 30rpx;
  160. }
  161. .desc {
  162. margin-top: 30rpx;
  163. }
  164. .btn, .group-info {
  165. position: absolute;
  166. }
  167. .btn {
  168. width: calc(100% - 60rpx*2);
  169. height: auto;
  170. left: 60rpx;
  171. bottom: 292rpx;
  172. background-color: #07C160;
  173. border: none;
  174. color: #FFFFFF;
  175. font-size: 28rpx;
  176. line-height: 1;
  177. border-radius: 45rpx;
  178. padding: 25rpx 0;
  179. box-sizing: border-box;
  180. }
  181. .group-info {
  182. bottom: 269rpx;
  183. flex-direction: column;
  184. color: #1B1B1B;
  185. font-size: 32rpx;
  186. }
  187. .qr {
  188. margin-top: 40rpx;
  189. width: 350rpx;
  190. height: 350rpx;
  191. }
  192. </style>