info.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. <template>
  2. <view class="content">
  3. <view class="one">
  4. <view class="one_1">
  5. ·{{info.number||0}}制 | 共{{info.wheel||0}}轮
  6. </view>
  7. <view class="one_2">
  8. <view class="left">
  9. <image class="image" mode="aspectFill" :src="info?.redInfo?.logo||config.logoUrl">
  10. </image>
  11. <view class="name">{{info?.redInfo?.name||'暂无红方名称'}}</view>
  12. </view>
  13. <view class="center">{{info.redScore||0}} : {{info.blueScore||0}}</view>
  14. <view class="right">
  15. <image class="image" mode="aspectFill" :src="info?.blueInfo?.logo||config.logoUrl">
  16. </image>
  17. <view class="name">{{info?.blueInfo?.name||'暂无蓝方名称'}}</view>
  18. </view>
  19. </view>
  20. <view class="one_3">
  21. <text>{{getDayOfWeek(info.startTime)}}</text>
  22. {{info.time||'暂无时间'}}
  23. </view>
  24. <view class="one_4 textOne"><text>{{info?.matchInfo?.address||'暂无地点'}}</text> </view>
  25. </view>
  26. <view class="position">
  27. <view class="two">
  28. <uni-segmented-control :current="current" :values="list" @clickItem="onClickItem" styleType="text"
  29. activeColor="#dd524d"></uni-segmented-control>
  30. <view class="two_1">
  31. <view v-show="current === 0">
  32. 出勤报名
  33. </view>
  34. <view v-show="current === 1">
  35. 数据统计
  36. </view>
  37. </view>
  38. </view>
  39. </view>
  40. </view>
  41. </template>
  42. <script setup lang="ts">
  43. import moment from 'moment';
  44. import { getCurrentInstance, ref } from 'vue';
  45. //该依赖已内置不需要单独安装
  46. import { onLoad } from "@dcloudio/uni-app";
  47. // 请求接口
  48. const $api = getCurrentInstance()?.appContext.config.globalProperties.$api;
  49. // 基本信息
  50. const config = ref({ logoUrl: '' });
  51. const info = ref({});
  52. const list = ref(['出勤报名', '数据统计']);
  53. const current = ref(0);
  54. // 详情信息id
  55. const id = ref('');
  56. onLoad(async (options) => {
  57. id.value = options && options.id
  58. uni.setNavigationBarTitle({
  59. title: options && options.name || '活动详情'
  60. });
  61. await searchConfig();
  62. await search();
  63. })
  64. // config信息
  65. const searchConfig = async () => {
  66. config.value = uni.getStorageSync('config');
  67. };
  68. // 查询
  69. const search = async () => {
  70. if (id.value) {
  71. const res = await $api(`game/${id.value}`, 'GET', {});
  72. if (res.code === 200) {
  73. if (res.data) {
  74. const date1 = moment(res.data.startTime).format('YYYY-MM-DD')
  75. const date2 = moment(res.data.endTime).format('YYYY-MM-DD')
  76. if (moment(date1).isSame(date2)) res.data.time = moment(res.data.startTime).format('MM-DD') + ' ' + moment(res.data.startTime).format('HH:mm') + '-' + moment(res.data.endTime).format('HH:mm');
  77. else res.data.time = moment(res.data.startTime).format('MM-DD') + '/' + moment(res.data.endTime).format('MM-DD')
  78. info.value = res.data
  79. }
  80. } else {
  81. uni.showToast({
  82. title: res.msg || '',
  83. icon: 'error',
  84. });
  85. }
  86. }
  87. };
  88. // 点击分页器
  89. const onClickItem = (e) => {
  90. if (current.value !== e.currentIndex) current.value = e.currentIndex
  91. };
  92. // 日期换算星期几
  93. const getDayOfWeek = (dateString) => {
  94. if (dateString) {
  95. const date = new Date(dateString);
  96. const dayOfWeek = date.getDay();
  97. const weekdays = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'];
  98. return weekdays[dayOfWeek];
  99. } else return '暂无日期';
  100. };
  101. </script>
  102. <style lang="scss" scoped>
  103. .content {
  104. display: flex;
  105. flex-direction: column;
  106. width: 100vw;
  107. height: 100vh;
  108. .one {
  109. background-color: var(--f12Color);
  110. padding: 0 0 10vw 0;
  111. .one_1 {
  112. padding: 2vw;
  113. text-align: center;
  114. font-size: var(--font14Size);
  115. color: var(--f99Color);
  116. }
  117. .one_2 {
  118. display: flex;
  119. justify-content: space-around;
  120. align-items: center;
  121. color: var(--mainColor);
  122. .left {
  123. display: flex;
  124. flex-direction: column;
  125. align-items: center;
  126. .image {
  127. width: 12vw;
  128. height: 12vw;
  129. border-radius: 12vw;
  130. }
  131. .name {
  132. margin: 2vw 0 0 0;
  133. }
  134. }
  135. .center {
  136. font-size: 25px;
  137. }
  138. .right {
  139. display: flex;
  140. flex-direction: column;
  141. align-items: center;
  142. .image {
  143. width: 12vw;
  144. height: 12vw;
  145. border-radius: 12vw;
  146. }
  147. .name {
  148. margin: 2vw 0 0 0;
  149. }
  150. }
  151. }
  152. .one_3 {
  153. color: var(--mainColor);
  154. text-align: center;
  155. padding: 2vw;
  156. font-size: var(--font16Size);
  157. text {
  158. padding: 2px 5px;
  159. background-color: rgba(105, 105, 105, 0.9);
  160. border-radius: 2vw;
  161. }
  162. }
  163. .one_4 {
  164. text-align: center;
  165. margin: 2vw;
  166. text {
  167. font-size: var(--font14Size);
  168. padding: 2px 5px;
  169. background-color: rgba(105, 105, 105, 0.9);
  170. border-radius: 10vw;
  171. color: var(--mainColor);
  172. }
  173. }
  174. }
  175. .position {
  176. position: absolute;
  177. top: 50vw;
  178. .two {
  179. width: 100vw;
  180. border-top-left-radius: 25px;
  181. border-top-right-radius: 25px;
  182. background-color: var(--mainColor);
  183. }
  184. }
  185. }
  186. </style>