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

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