act_detail.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380
  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. import { calculateDistance } from '@/utils/calculateDistance.js'
  103. // 富文本样式
  104. let tagStyle = {
  105. img: 'height:350rpx'
  106. }
  107. // 详情数据
  108. const info = ref({})
  109. // 活动ID
  110. const currentId = ref()
  111. const lat = ref('')
  112. const lng = ref('')
  113. onLoad((options) => {
  114. if (options.id) {
  115. currentId.value = options.id
  116. // 根据ID获取活动数据详情
  117. getData(options.id)
  118. // 获取当前用户经纬度
  119. getAddress()
  120. }
  121. })
  122. // 根据ID获取活动数据详情
  123. const getData = async (id) => {
  124. let data = {
  125. id
  126. }
  127. const res = await getDetailInfoById(data)
  128. // console.log(res)
  129. info.value = res.data
  130. }
  131. // 获取当前用户经纬度
  132. const getAddress = () => {
  133. uni.getLocation({
  134. // type: 'wgs84',
  135. success: (res) => {
  136. lng.value = res.longitude
  137. lat.value = res.latitude
  138. }
  139. })
  140. }
  141. // 点击查看更多回调
  142. const goDetail = (e) => {
  143. // 1为已报名,2为签到人员,3为活动相册
  144. if (e == 1 || e == 2) {
  145. let temList = e == 1 ? info.value.reportDatas : info.value.signinDatas
  146. let list = encodeURIComponent(JSON.stringify(temList))
  147. uni.navigateTo({
  148. url: `/pages/people_detail/people_detail?type=${e}&list=${list}`
  149. })
  150. } else if (e == 3) {
  151. let imgList = encodeURIComponent(JSON.stringify(info.value.images))
  152. uni.navigateTo({
  153. url: `/pages/act_album/act_album?imgList=${imgList}&currentId=${currentId.value}`
  154. })
  155. }
  156. }
  157. // 我要报名按钮回调
  158. const handleApply = (id) => {
  159. uni.showModal({
  160. title: '提示',
  161. content: '确定报名吗?',
  162. success: async (res) => {
  163. if (res.confirm) {
  164. let data = {
  165. id
  166. }
  167. const res = await getReportById(data)
  168. // console.log(res)
  169. if (res.code == 200) {
  170. uni.showToast({
  171. title: res.message,
  172. icon: 'success',
  173. mask: true
  174. })
  175. setTimeout(() => {
  176. getData(info.id)
  177. }, 1500)
  178. }
  179. }
  180. }
  181. })
  182. }
  183. // 我要签到按钮回调
  184. const handleSign = (id) => {
  185. let rangValue = 500
  186. // 计算出距离
  187. let distance = calculateDistance(info.value.lat, info.value.lng, lat.value, lng.value)
  188. // console.log(distance)
  189. if (rangValue > distance) {
  190. uni.showModal({
  191. title: '提示',
  192. content: '确定签到吗?',
  193. success: async (res) => {
  194. if (res.confirm) {
  195. let data = {
  196. id
  197. }
  198. const res = await getSigninById(data)
  199. // console.log(res)
  200. if (res.code == 200) {
  201. uni.showToast({
  202. title: res.message,
  203. icon: 'success',
  204. mask: true
  205. })
  206. setTimeout(() => {
  207. getData(info.id)
  208. }, 1500)
  209. }
  210. }
  211. }
  212. })
  213. } else {
  214. uni.showToast({
  215. title: '超出签到范围,无法签到',
  216. icon: 'none',
  217. mask: true
  218. })
  219. }
  220. }
  221. </script>
  222. <style lang="scss" scoped>
  223. .container {
  224. padding: 20rpx 18rpx 150rpx;
  225. margin-bottom: 60rpx;
  226. // min-height: 100vh;
  227. font-size: 28rpx;
  228. .title {
  229. font-size: 32rpx;
  230. font-weight: bold;
  231. }
  232. .time {
  233. margin-top: 15rpx;
  234. font-size: 24rpx;
  235. color: #808080;
  236. }
  237. .address {
  238. margin-top: 15rpx;
  239. line-height: 45rpx;
  240. font-size: 24rpx;
  241. color: #808080;
  242. }
  243. .richtext {
  244. margin: 15rpx 0;
  245. }
  246. .box {
  247. display: flex;
  248. align-items: center;
  249. .box_icon {
  250. width: 10rpx;
  251. height: 27rpx;
  252. border-radius: 30rpx;
  253. background-color: #007aff;
  254. }
  255. .box_title {
  256. margin-left: 16rpx;
  257. font-weight: bold;
  258. }
  259. .box_more {
  260. display: flex;
  261. align-items: center;
  262. margin-left: auto;
  263. color: #007aff;
  264. font-size: 24rpx;
  265. }
  266. }
  267. .desc {
  268. margin: 20rpx 0;
  269. line-height: 40rpx;
  270. }
  271. .sign {
  272. display: grid;
  273. grid-template-columns: repeat(6, 1fr);
  274. margin: 20rpx 0;
  275. .sign_box {
  276. display: flex;
  277. flex-direction: column;
  278. justify-content: center;
  279. align-items: center;
  280. height: 120rpx;
  281. .img {
  282. margin-bottom: 5rpx;
  283. width: 80rpx;
  284. height: 80rpx;
  285. border-radius: 50%;
  286. }
  287. .box_text {
  288. flex: 1;
  289. text-align: center;
  290. overflow: hidden;
  291. }
  292. }
  293. }
  294. .album {
  295. display: grid;
  296. grid-template-columns: repeat(3, 1fr);
  297. margin: 20rpx 0 120rpx;
  298. .img {
  299. width: 200rpx;
  300. height: 200rpx;
  301. border-radius: 10rpx;
  302. }
  303. }
  304. .btn {
  305. position: fixed;
  306. left: 50%;
  307. bottom: 40rpx;
  308. transform: translateX(-50%);
  309. display: flex;
  310. flex-direction: column;
  311. justify-content: space-evenly;
  312. align-items: center;
  313. width: 661rpx;
  314. height: 100rpx;
  315. color: #fff;
  316. font-size: 28rpx;
  317. border-radius: 8rpx;
  318. background-color: #007aff;
  319. .btn_text {
  320. font-size: 20rpx;
  321. }
  322. }
  323. .off {
  324. color: #a6a6a6;
  325. background-color: #e5e5e5;
  326. }
  327. .nostart {
  328. color: #fff;
  329. background-color: #007aff;
  330. opacity: 0.3;
  331. }
  332. }
  333. </style>