details.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  1. <template>
  2. <view class="app-content" :class="{ 'pc-fixed-frame': isPc }">
  3. <view v-show="matchInfo.id">
  4. <view class="head">
  5. <view class="title"> {{ matchInfo?.matchName }} </view>
  6. <view class="time">
  7. <text class="iconfont">&#xe8b8;</text>
  8. <text class="text"
  9. >发布时间 {{ matchInfo?.publishTime || "--" }}</text
  10. >
  11. </view>
  12. </view>
  13. <view class="content">
  14. <view class="list-item">
  15. <InfoHead title="赛事概述" />
  16. <view> {{ matchInfo?.matchSummary }} </view>
  17. </view>
  18. <view class="list-item ql-editor-box">
  19. <InfoHead title="赛事介绍" />
  20. <uv-parse
  21. :content="processedContent(matchInfo.introduction)"
  22. ></uv-parse>
  23. </view>
  24. <view class="list-item ql-editor-box">
  25. <InfoHead title="报名要求" />
  26. <uv-parse
  27. :content="processedContent(matchInfo.registrationRequirement)"
  28. ></uv-parse>
  29. </view>
  30. <view v-if="matchInfo?.awardContent" class="list-item ql-editor-box">
  31. <InfoHead title="奖励内容" />
  32. <uv-parse
  33. :content="processedContent(matchInfo.awardContent)"
  34. ></uv-parse>
  35. </view>
  36. <view
  37. class="list-item"
  38. v-if="matchInfo.attachments && matchInfo.attachments.length"
  39. >
  40. <InfoHead title="附件资料" />
  41. <!-- annexList -->
  42. <view
  43. class="annex-item"
  44. v-for="(item, index) in matchInfo?.attachments"
  45. :key="index"
  46. >
  47. <view class="name">{{ index + 1 }}、{{ item.fileName }} </view>
  48. <!-- <view class="download" @click="downloadFile(item.url)">
  49. <text class="iconfont">&#xe61a;</text>
  50. <text class="text">下载</text>
  51. </view> -->
  52. </view>
  53. </view>
  54. <view class="list-item" v-if="dataList && dataList.length > 0">
  55. <InfoHead title="参赛项目" />
  56. <view class="project-list">
  57. <project-item
  58. v-for="(item, index) in dataList"
  59. :key="index"
  60. :item="item"
  61. keyId="projectId"
  62. />
  63. </view>
  64. <EmptyState
  65. v-if="!loading && dataList.length === 0"
  66. type="noData"
  67. text="暂无项目"
  68. sub-text="暂时没有相关项目信息"
  69. />
  70. <!-- 加载更多组件 -->
  71. <LoadMoreView v-if="dataList.length > 0" :noMore="noMore" />
  72. </view>
  73. </view>
  74. </view>
  75. <view v-if="!matchInfo.id && pagesLoading">
  76. <EmptyState
  77. type="noData"
  78. text="暂无赛事信息"
  79. sub-text="暂时没有相关赛事信息"
  80. />
  81. </view>
  82. </view>
  83. </template>
  84. <script setup>
  85. import { ref } from "vue";
  86. import {
  87. onLoad,
  88. onUnload,
  89. onReachBottom,
  90. onShareAppMessage,
  91. } from "@dcloudio/uni-app";
  92. import { navigateTo, downloadFile, processedContent } from "@/utils/utils.js";
  93. import { useListQuery } from "@/mixins/useListQuery.js";
  94. import { matchDetailInfo, projectListByMatchId } from "@/api/tournament.js";
  95. const matchInfo = ref({});
  96. const pagesLoading = ref(false);
  97. const isPc = ref(false);
  98. let originalBodyBackground = "";
  99. const detectIsPcOnH5 = () => {
  100. if (typeof navigator === "undefined") return false;
  101. const ua = navigator.userAgent || "";
  102. const isMobileUa =
  103. /Android|webOS|iPhone|iPod|BlackBerry|IEMobile|Opera Mini/i.test(ua) ||
  104. /iPad/i.test(ua) ||
  105. (/Macintosh/i.test(ua) && navigator.maxTouchPoints > 1);
  106. return !isMobileUa;
  107. };
  108. onLoad(async (options) => {
  109. // #ifdef H5
  110. isPc.value = detectIsPcOnH5();
  111. if (isPc.value && typeof document !== "undefined") {
  112. originalBodyBackground = document.body.style.background || "";
  113. document.body.style.background = "#e9e9e9";
  114. }
  115. // #endif
  116. queryForm.matchId = options.id;
  117. if (!options.id) {
  118. pagesLoading.value = true;
  119. return;
  120. }
  121. try {
  122. let res = await getMatchInfo(options.id);
  123. if (!res || res.hidden) {
  124. pagesLoading.value = true;
  125. return;
  126. }
  127. matchInfo.value = res;
  128. getDataList(true);
  129. } catch (error) {
  130. console.log(error);
  131. }
  132. });
  133. var { dataList, loading, noMore, getDataList, loadMore, queryForm } =
  134. useListQuery(projectListByMatchId);
  135. const getMatchInfo = async (id) => {
  136. return new Promise((resolve, reject) => {
  137. matchDetailInfo(id).then((res) => {
  138. resolve(res.data);
  139. });
  140. });
  141. };
  142. // 定义页面的分享内容
  143. onShareAppMessage(() => {
  144. const imageUrl = matchInfo.value.thumbnail;
  145. return {
  146. title: matchInfo.value.matchName,
  147. path: `/pages/tournament/details?id=${matchInfo.value.id}`,
  148. imageUrl,
  149. };
  150. });
  151. // 上拉加载更多
  152. onReachBottom(() => {
  153. // console.log("onReachBottom");
  154. if (!matchInfo.value.id) return;
  155. if (!loading.value && !noMore.value) {
  156. loadMore();
  157. }
  158. });
  159. onUnload(() => {
  160. // #ifdef H5
  161. if (isPc.value && typeof document !== "undefined") {
  162. document.body.style.background = originalBodyBackground;
  163. }
  164. // #endif
  165. });
  166. </script>
  167. <style lang="scss" scoped>
  168. .app-content {
  169. position: relative;
  170. padding-top: 0;
  171. // padding-bottom: 152rpx;
  172. .head {
  173. padding: 20rpx;
  174. font-size: 30rpx;
  175. text-align: center;
  176. border-bottom: 1rpx solid #e6e6e6;
  177. .title {
  178. min-height: 48rpx;
  179. font-size: 34rpx;
  180. font-weight: 700;
  181. text-align: center;
  182. color: #1a1a1a;
  183. // line-height: 36rpx;
  184. }
  185. .time {
  186. display: flex;
  187. align-items: center;
  188. justify-content: center;
  189. font-size: 24rpx;
  190. font-weight: 400;
  191. text-align: center;
  192. color: #666666;
  193. margin-top: 10rpx;
  194. .iconfont {
  195. margin-right: 5rpx;
  196. }
  197. }
  198. }
  199. .content {
  200. padding: 30rpx 20rpx;
  201. .list-item {
  202. margin-bottom: 30rpx;
  203. .annex-item {
  204. display: flex;
  205. align-items: center;
  206. justify-content: space-between;
  207. padding-bottom: 15rpx;
  208. .name {
  209. flex: 1;
  210. font-size: 26rpx;
  211. font-weight: 400;
  212. color: #666666;
  213. word-break: break-word;
  214. }
  215. .download {
  216. flex-shrink: 0;
  217. font-size: 24rpx;
  218. font-weight: 400;
  219. color: #0077ff;
  220. line-height: 24rpx;
  221. margin-left: 20rpx;
  222. }
  223. }
  224. }
  225. .project-list {
  226. // display: flex;
  227. // justify-content: space-between;
  228. // flex-wrap: wrap;
  229. // padding-top: 10rpx;
  230. }
  231. }
  232. .float-btn {
  233. position: fixed;
  234. width: 750rpx;
  235. height: 148rpx;
  236. background: #ffffff;
  237. left: 0;
  238. bottom: 0;
  239. border-top: 1rpx dotted #666666;
  240. display: flex;
  241. align-items: center;
  242. justify-content: space-between;
  243. gap: 30rpx;
  244. padding: 0 46rpx;
  245. box-sizing: border-box;
  246. .btn-item {
  247. flex: 1;
  248. width: 100%;
  249. height: 80rpx;
  250. line-height: 80rpx;
  251. text-align: center;
  252. background: #d20b17;
  253. border-radius: 40rpx;
  254. font-size: 32rpx;
  255. font-weight: 400;
  256. color: #ffffff;
  257. .iconfont {
  258. margin-right: 5rpx;
  259. }
  260. }
  261. .btn-item.share {
  262. background: #1f71b9;
  263. &::after {
  264. border: none;
  265. }
  266. }
  267. }
  268. }
  269. .pc-fixed-frame {
  270. width: 390px;
  271. height: auto;
  272. min-height: unset !important;
  273. margin: 24px auto;
  274. padding: 0 !important;
  275. // overflow-y: auto;
  276. overflow-x: hidden;
  277. border-radius: 16px;
  278. background-color: #f5f5f5;
  279. box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
  280. }
  281. </style>