act_detail.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349
  1. <template>
  2. <view class="container">
  3. <!-- 标题区域 -->
  4. <view class="title">{{ info.theme }}</view>
  5. <!-- 时间区域 -->
  6. <view class="time">时间:{{ dayjs(info.startTime).format('YYYY-MM-DD HH:mm:ss') }} 至 {{ dayjs(info.endTime).format('YYYY-MM-DD HH:mm:ss') }}</view>
  7. <!-- 地址区域 -->
  8. <view class="address">
  9. 地点:{{ info.address }}
  10. <uni-icons type="location" size="20" color="#007AFF"></uni-icons>
  11. </view>
  12. <!-- 富文本区域 -->
  13. <view class="richtext">
  14. <uv-parse :content="info.themeDetail" :tagStyle="tagStyle"></uv-parse>
  15. </view>
  16. <!-- 参与说明区域 -->
  17. <view class="box">
  18. <view class="box_icon"></view>
  19. <view class="box_title">参与说明</view>
  20. </view>
  21. <view class="desc">
  22. {{ info.describes }}
  23. </view>
  24. <!-- 已报名区域 -->
  25. <view class="box" v-if="info.reportDatas?.length">
  26. <view class="box_icon"></view>
  27. <view class="box_title">已报名({{ info.reportDatas.length }}人)</view>
  28. <view class="box_more" @click="goDetail(1)">
  29. 查看更多&nbsp;
  30. <uni-icons type="right" size="18" color="#007AFF"></uni-icons>
  31. </view>
  32. </view>
  33. <view class="sign" v-if="info.reportDatas?.length">
  34. <!-- 每一个报名人员 -->
  35. <view class="sign_box" v-for="(item, index) in info.reportDatas" :key="index">
  36. <image class="img" src="@/static/images/9.png" mode="aspectFill"></image>
  37. <view class="box_text">{{ item.name }}</view>
  38. </view>
  39. </view>
  40. <!-- 签到人员区域 -->
  41. <view class="box" v-if="info.signinDatas?.length">
  42. <view class="box_icon"></view>
  43. <view class="box_title">签到人员({{ info.signinDatas.length }}人)</view>
  44. <view class="box_more" @click="goDetail(2)">
  45. 查看更多&nbsp;
  46. <uni-icons type="right" size="18" color="#007AFF"></uni-icons>
  47. </view>
  48. </view>
  49. <view class="sign" v-if="info.signinDatas?.length">
  50. <!-- 每一个签到人员 -->
  51. <view class="sign_box" v-for="(item, index) in info.signinDatas" :key="index">
  52. <image class="img" src="@/static/images/9.png" mode="aspectFill"></image>
  53. <view class="box_text">{{ item.name }}</view>
  54. </view>
  55. </view>
  56. <!-- 活动相册区域 -->
  57. <view class="box" v-if="info.isImage == 1 && info.images?.length">
  58. <view class="box_icon"></view>
  59. <view class="box_title">活动相册</view>
  60. <view class="box_more" @click="goDetail(3)">
  61. 查看更多&nbsp;
  62. <uni-icons type="right" size="18" color="#007AFF"></uni-icons>
  63. </view>
  64. </view>
  65. <view class="album" v-if="info.isImage == 1 && info.images?.length">
  66. <!-- 每一张照片区域 -->
  67. <image class="img" :src="item" mode="aspectFill" v-for="(item, index) in info.images.splice(0, 3)" :key="item"></image>
  68. </view>
  69. <!-- 按钮区域 -->
  70. <view v-if="info.isReport == 2">
  71. <!-- 未报名时 -->
  72. <view v-if="dayjs(info.signsTime).valueOf() > Date.now()" class="btn nostart">
  73. 报名未开始
  74. <view class="btn_text">{{ dayjs(info.signsTime).format('YYYY-MM-DD HH:mm:ss') }} 开始报名</view>
  75. </view>
  76. <view v-if="dayjs(info.signeTime).valueOf() > Date.now()" class="btn" @click="handleApply(info.id)">
  77. 我要报名
  78. <view class="btn_text">{{ dayjs(info.signeTime).format('YYYY-MM-DD HH:mm:ss') }} 报名截止</view>
  79. </view>
  80. <view v-else class="btn off">报名已截止</view>
  81. </view>
  82. <view v-if="info.isReport == 1 && info.isSign == 2">
  83. <!-- 未签到时 -->
  84. <view v-if="dayjs(info.startTime).valueOf() > Date.now()" class="btn nostart">
  85. 活动未开始
  86. <view class="btn_text">{{ dayjs(info.startTime).format('YYYY-MM-DD HH:mm:ss') }} 开始签到</view>
  87. </view>
  88. <view v-if="dayjs(info.endTime).valueOf() > Date.now()" class="btn" @click="handleSign(info.id)">
  89. 我要签到
  90. <view class="btn_text">{{ dayjs(info.endTime).format('YYYY-MM-DD HH:mm:ss') }} 签到截止</view>
  91. </view>
  92. <view v-else class="btn off">活动已结束</view>
  93. </view>
  94. <view class="btn off" v-if="info.isReport == 1 && info.isSign == 1">已签到</view>
  95. </view>
  96. </template>
  97. <script setup>
  98. import { onLoad } from '@dcloudio/uni-app'
  99. import { ref } from 'vue'
  100. import { getDetailInfoById, getReportById, getSigninById } from '@/api/index.js'
  101. import dayjs from 'dayjs'
  102. // 富文本样式
  103. let tagStyle = {
  104. img: 'height:350rpx'
  105. }
  106. // 详情数据
  107. const info = ref({})
  108. // 活动ID
  109. const currentId = ref()
  110. onLoad((options) => {
  111. if (options.id) {
  112. currentId.value = options.id
  113. // 根据ID获取活动数据详情
  114. getData(options.id)
  115. }
  116. })
  117. // 根据ID获取活动数据详情
  118. const getData = async (id) => {
  119. let data = {
  120. id
  121. }
  122. const res = await getDetailInfoById(data)
  123. // console.log(res)
  124. info.value = res.data
  125. }
  126. // 点击查看更多回调
  127. const goDetail = (e) => {
  128. // 1为已报名,2为签到人员,3为活动相册
  129. if (e == 1 || e == 2) {
  130. let temList = e == 1 ? info.value.reportDatas : info.value.signinDatas
  131. let list = encodeURIComponent(JSON.stringify(temList))
  132. uni.navigateTo({
  133. url: `/pages/people_detail/people_detail?type=${e}&list=${list}`
  134. })
  135. } else if (e == 3) {
  136. let imgList = encodeURIComponent(JSON.stringify(info.value.images))
  137. uni.navigateTo({
  138. url: `/pages/act_album/act_album?imgList=${imgList}&currentId=${currentId.value}`
  139. })
  140. }
  141. }
  142. // 我要报名按钮回调
  143. const handleApply = (id) => {
  144. uni.showModal({
  145. title: '提示',
  146. content: '确定报名吗?',
  147. success: async (res) => {
  148. if (res.confirm) {
  149. let data = {
  150. id
  151. }
  152. const res = await getReportById(data)
  153. // console.log(res)
  154. if (res.code == 200) {
  155. uni.showToast({
  156. title: res.message,
  157. icon: 'success',
  158. mask: true
  159. })
  160. setTimeout(() => {
  161. getData(info.id)
  162. }, 1500)
  163. }
  164. }
  165. }
  166. })
  167. }
  168. // 我要签到按钮回调
  169. const handleSign = (id) => {
  170. uni.showModal({
  171. title: '提示',
  172. content: '确定签到吗?',
  173. success: async (res) => {
  174. if (res.confirm) {
  175. let data = {
  176. id
  177. }
  178. const res = await getSigninById(data)
  179. // console.log(res)
  180. if (res.code == 200) {
  181. uni.showToast({
  182. title: res.message,
  183. icon: 'success',
  184. mask: true
  185. })
  186. setTimeout(() => {
  187. getData(info.id)
  188. }, 1500)
  189. }
  190. }
  191. }
  192. })
  193. }
  194. </script>
  195. <style lang="scss" scoped>
  196. .container {
  197. padding: 20rpx 18rpx 150rpx;
  198. margin-bottom: 60rpx;
  199. // min-height: 100vh;
  200. font-size: 28rpx;
  201. .title {
  202. font-size: 32rpx;
  203. font-weight: bold;
  204. }
  205. .time {
  206. margin-top: 15rpx;
  207. font-size: 24rpx;
  208. color: #808080;
  209. }
  210. .address {
  211. margin-top: 15rpx;
  212. line-height: 45rpx;
  213. font-size: 24rpx;
  214. color: #808080;
  215. }
  216. .richtext {
  217. margin: 15rpx 0;
  218. }
  219. .box {
  220. display: flex;
  221. align-items: center;
  222. .box_icon {
  223. width: 10rpx;
  224. height: 27rpx;
  225. border-radius: 30rpx;
  226. background-color: #007aff;
  227. }
  228. .box_title {
  229. margin-left: 16rpx;
  230. font-weight: bold;
  231. }
  232. .box_more {
  233. display: flex;
  234. align-items: center;
  235. margin-left: auto;
  236. color: #007aff;
  237. font-size: 24rpx;
  238. }
  239. }
  240. .desc {
  241. margin: 20rpx 0;
  242. line-height: 40rpx;
  243. }
  244. .sign {
  245. display: grid;
  246. grid-template-columns: repeat(6, 1fr);
  247. margin: 20rpx 0;
  248. .sign_box {
  249. display: flex;
  250. flex-direction: column;
  251. justify-content: center;
  252. align-items: center;
  253. height: 120rpx;
  254. .img {
  255. margin-bottom: 5rpx;
  256. width: 80rpx;
  257. height: 80rpx;
  258. border-radius: 50%;
  259. }
  260. .box_text {
  261. flex: 1;
  262. text-align: center;
  263. overflow: hidden;
  264. }
  265. }
  266. }
  267. .album {
  268. display: grid;
  269. grid-template-columns: repeat(3, 1fr);
  270. margin: 20rpx 0 120rpx;
  271. .img {
  272. width: 200rpx;
  273. height: 200rpx;
  274. border-radius: 10rpx;
  275. }
  276. }
  277. .btn {
  278. position: fixed;
  279. left: 50%;
  280. bottom: 40rpx;
  281. transform: translateX(-50%);
  282. display: flex;
  283. flex-direction: column;
  284. justify-content: space-evenly;
  285. align-items: center;
  286. width: 661rpx;
  287. height: 100rpx;
  288. color: #fff;
  289. font-size: 28rpx;
  290. border-radius: 8rpx;
  291. background-color: #007aff;
  292. .btn_text {
  293. font-size: 20rpx;
  294. }
  295. }
  296. .off {
  297. color: #a6a6a6;
  298. background-color: #e5e5e5;
  299. }
  300. .nostart {
  301. color: #fff;
  302. background-color: #007aff;
  303. opacity: 0.3;
  304. }
  305. }
  306. </style>