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

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