organization.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  1. <template>
  2. <view class="container">
  3. <!-- 顶部置顶区域 -->
  4. <view class="top">
  5. <!-- 信息区域 -->
  6. <view class="top_msg">
  7. <view class="msg_name">{{ info.name }}</view>
  8. <view class="msg_time">{{ info.createTime }}</view>
  9. </view>
  10. <!-- 按钮区域 -->
  11. <view v-if="info.isJoin == 1" class="top_btn off">已加入</view>
  12. <view v-if="info.isJoin == 2" class="top_btn" @click="handleJoin_debounce">立即加入</view>
  13. <view v-if="info.isJoin == 3" class="top_btn off">已申请</view>
  14. <!-- 背景图区域 -->
  15. <view class="top_bg">
  16. <img class="bgImg" mode="aspectFill" src="@/static/images/1.png" />
  17. </view>
  18. </view>
  19. <!-- 其他组织区域 -->
  20. <view class="org" v-if="info.otherClub?.length">
  21. <view class="org_text">其他组织</view>
  22. <!-- 组织列表区域 -->
  23. <view class="org_list">
  24. <org-item v-for="(item, index) in info.otherClub" :key="index" :item="item" @click="clickItem(index)">
  25. <template #bg>
  26. <img v-if="index % 4 == 0" class="img_bg" src="@/static/images/3.png" />
  27. <img v-if="index % 4 == 1" class="img_bg" src="@/static/images/4.png" />
  28. <img v-if="index % 4 == 2" class="img_bg" src="@/static/images/5.png" />
  29. <img v-if="index % 4 == 3" class="img_bg" src="@/static/images/6.png" />
  30. </template>
  31. </org-item>
  32. </view>
  33. </view>
  34. <!-- 底部分段器区域 -->
  35. <view class="foot">
  36. <common-controlTag :tagList="tagList" @change="changeIndex"></common-controlTag>
  37. <!-- 本会简介区域 -->
  38. <view v-if="currentIndex == 0" class="desc">
  39. {{ info.description }}
  40. </view>
  41. <!-- 联系我们区域 -->
  42. <view v-if="currentIndex == 1" class="contact">
  43. <view>联系人:{{ info.contact || '未知' }}</view>
  44. <view class="phone">
  45. 电话:
  46. <view class="phone_num" @click="handlePhone(info.phone)">{{ info.phone || '未知' }}</view>
  47. </view>
  48. <view>邮箱:{{ info.email || '未知' }}</view>
  49. <view>地址:{{ info.address || '未知' }}</view>
  50. </view>
  51. </view>
  52. </view>
  53. </template>
  54. <script setup>
  55. import { onLoad } from '@dcloudio/uni-app'
  56. import { ref } from 'vue'
  57. import { getHomeClubData, getJoinClubApply } from '@/api/index.js'
  58. import debounce from 'lodash/debounce'
  59. // 首页数据
  60. const info = ref({})
  61. // 分段器数组
  62. const tagList = ['本会简介', '联系我们']
  63. // 当前分段器索引
  64. const currentIndex = ref(0)
  65. onLoad(() => {
  66. // 获取首页数据
  67. getData()
  68. })
  69. // 获取首页数据
  70. const getData = async () => {
  71. const res = await getHomeClubData()
  72. // console.log(res)
  73. info.value = res.data
  74. }
  75. const handleJoin = () => {
  76. uni.showModal({
  77. title: '提示',
  78. content: '确定申请加入该组织吗?',
  79. success: (res) => {
  80. if (res.confirm) {
  81. handleJoinReq()
  82. }
  83. }
  84. })
  85. }
  86. // 点击立即加入按钮回调
  87. const handleJoin_debounce = debounce(handleJoin, 200)
  88. // 申请加入组织请求
  89. const handleJoinReq = async () => {
  90. let data = {
  91. id: info.value.id
  92. }
  93. const res = await getJoinClubApply(data)
  94. // console.log(res)
  95. if (res.code == 200) {
  96. uni.showToast({
  97. title: res.message,
  98. icon: 'none'
  99. })
  100. setTimeout(() => {
  101. getData()
  102. }, 1500)
  103. }
  104. }
  105. // 点击拨打电话回调
  106. const handlePhone = (phoneNumber) => {
  107. if (phoneNumber) {
  108. uni.makePhoneCall({
  109. phoneNumber
  110. })
  111. }
  112. }
  113. // 点击每一个组织回调
  114. const clickItem = (index) => {
  115. let list = encodeURIComponent(JSON.stringify(info.value.otherClub))
  116. uni.navigateTo({
  117. url: `/pages/org_list/org_list?list=${list}&index=${index}`
  118. })
  119. }
  120. // common-controlTag组件自定义事件
  121. const changeIndex = (e) => {
  122. currentIndex.value = e
  123. }
  124. </script>
  125. <style lang="scss" scoped>
  126. .container {
  127. padding: 30rpx 18rpx;
  128. min-height: 100vh;
  129. .top {
  130. position: relative;
  131. display: flex;
  132. justify-content: space-between;
  133. align-items: center;
  134. padding: 0 28rpx;
  135. height: 223rpx;
  136. border-radius: 26rpx;
  137. box-shadow: 0 0 10rpx #d3d3d3;
  138. background-color: #fff;
  139. .top_msg {
  140. flex: 1;
  141. margin: 0 20rpx;
  142. overflow: hidden;
  143. .msg_name {
  144. font-size: 32rpx;
  145. color: #333333;
  146. overflow: hidden;
  147. white-space: nowrap;
  148. text-overflow: ellipsis;
  149. }
  150. .msg_time {
  151. margin-top: 10rpx;
  152. font-size: 24rpx;
  153. color: #999999;
  154. }
  155. }
  156. .top_btn {
  157. display: flex;
  158. align-items: center;
  159. justify-content: center;
  160. width: 150rpx;
  161. height: 70rpx;
  162. font-size: 28rpx;
  163. color: #fff;
  164. border-radius: 8rpx;
  165. background-color: #007aff;
  166. }
  167. .off {
  168. color: #a6a6a6;
  169. background-color: #e5e5e5;
  170. }
  171. .top_bg {
  172. position: absolute;
  173. left: 0;
  174. right: 0;
  175. bottom: 0;
  176. height: 78rpx;
  177. .bgImg {
  178. width: 100%;
  179. height: 100%;
  180. }
  181. }
  182. }
  183. .org {
  184. margin-top: 30rpx;
  185. .org_text {
  186. position: relative;
  187. padding: 0 10rpx;
  188. font-size: 32rpx;
  189. font-weight: bold;
  190. &::after {
  191. position: absolute;
  192. bottom: 4rpx;
  193. left: 0;
  194. content: '';
  195. width: 148rpx;
  196. height: 9rpx;
  197. background-image: linear-gradient(270deg, rgba(91, 186, 255, 0.5) 0%, rgba(0, 119, 255, 0.5) 100%);
  198. }
  199. }
  200. .org_list {
  201. margin-top: 30rpx;
  202. display: grid;
  203. grid-template-columns: repeat(2, 1fr);
  204. gap: 20rpx;
  205. .img_bg {
  206. position: absolute;
  207. right: 8rpx;
  208. bottom: 8rpx;
  209. width: 139rpx;
  210. height: 130rpx;
  211. }
  212. }
  213. }
  214. .foot {
  215. margin-top: 38rpx;
  216. color: #333333;
  217. font-size: 28rpx;
  218. line-height: 50rpx;
  219. .desc {
  220. margin-top: 15rpx;
  221. }
  222. .contact {
  223. margin-top: 15rpx;
  224. .phone {
  225. display: flex;
  226. .phone_num {
  227. color: #007aff;
  228. }
  229. }
  230. }
  231. }
  232. }
  233. </style>