index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515
  1. <!--
  2. [活动管理] 活动列表
  3. http://localhost:5173/actMgt/#/pages/actManage/index
  4. https://oss-mbh5.colormaprun.com/actMgt/#/pages/actManage/index
  5. -->
  6. <template>
  7. <view class="body">
  8. <view class="content uni-column">
  9. <view class="uni-column top">
  10. <view class="top-content uni-row">
  11. <image class="tc-headimg" mode="aspectFit" src="/static/headimg.png"></image>
  12. <view class="tc-userBox uni-column uni-ais uni-jcse">
  13. <view class="userBox-name">{{selfInfo.name}}</view>
  14. <view class="userBox-info uni-row">
  15. <view class="">等级:{{userLevel[selfInfo.level]}}</view>
  16. <view class="" style="margin-left: 20px;">余额:¥{{selfInfo.balance}}</view>
  17. </view>
  18. </view>
  19. </view>
  20. </view>
  21. <view class="main uni-column">
  22. <view class="actBox uni-row uni-jcsb">
  23. <view class="actBox-title">赛事活动</view>
  24. <view class="actBox-info"><text style="color: #0085D4;">{{actStatistic.totalCompCt}}</text>个赛事,已开赛<text
  25. style="color: #FF8D1A;">{{actStatistic.normalCompCt}}</text>个,进行中<text style="color: #FF8D1A;">{{actStatistic.InGameCompCt}}</text>个</view>
  26. </view>
  27. <view class="norecord" v-if="actList == null || actList.length == 0">暂无记录</view>
  28. <view class="list uni-row" v-else>
  29. <view class="item uni-column" v-for="(item, index) in actList" :key="index"
  30. @click="showDetail(item)">
  31. <view class="item-cardbox uni-column uni-jcc"
  32. :class="getCardClass(item.config.tplInfo.styleId)">
  33. <view class="item-cornerBox item-cornerLeft">{{pubState[item.otherInfo.pubState]}}</view>
  34. <view class="item-cornerBox item-cornerRight">
  35. {{getMatchState(item.config.matchInfo.compBeginSecond, item.config.matchInfo.compEndSecond)}}
  36. </view>
  37. <image class="item-pic" mode="aspectFit" :src="item.config.tplInfo.matchLogo != '' ? item.config.tplInfo.matchLogo : defaultLogo"></image>
  38. <view class="item-matchType">锦标赛</view>
  39. <view class="item-matchName">{{item.config.matchInfo.compName}}</view>
  40. <view class="item-createTime">( {{fmtTime(item.otherInfo.createTime, 1)}} 创建 )</view>
  41. </view>
  42. <view class="item-introduce uni-column uni-jcse uni-ais">
  43. <view class="item-playNum">参赛人数:{{item.otherInfo.playNum}}人</view>
  44. <view class="uni-width-100 uni-row uni-jcsb">
  45. <view v-if="item.otherInfo.signupState" class="item-signupState">允许报名</view>
  46. <view v-else class="item-signupState" style="color: #F70000;">禁止报名</view>
  47. <image class="item-ico" mode="aspectFit" src="/static/ico_edit.png" @click="btnActEdit(item)">
  48. </image>
  49. </view>
  50. </view>
  51. </view>
  52. </view>
  53. </view>
  54. </view>
  55. </view>
  56. </template>
  57. <script>
  58. import {
  59. mapState,
  60. mapGetters
  61. } from 'vuex';
  62. import tools from '/utils/tools.js';
  63. import {
  64. tplStyleList,
  65. userLevel,
  66. pubState
  67. } from '/utils/define.js';
  68. import {
  69. apiGetSelfInfo,
  70. apiCompInfoQuery,
  71. checkResCode
  72. } from '/utils/api.js';
  73. export default {
  74. components: {},
  75. data() {
  76. return {
  77. pubState: pubState,
  78. userLevel: userLevel,
  79. queryObj: {},
  80. queryString: "",
  81. selfInfo: {
  82. name: "", // 姓名
  83. phone: "", // 手机号
  84. balance: "", // 余额
  85. level: "", // 等级
  86. },
  87. // defaultLogo: "/static/run.png",
  88. defaultLogo: "https://oss-mbh5.colormaprun.com/static/logo/default.png",
  89. actStatistic: {}, // 赛事活动统计信息
  90. actList: null, // 赛事活动列表
  91. /* actList: [{
  92. otherInfo: {
  93. compId: 1,
  94. pubState: 0,
  95. playNum: 26,
  96. signupState: false,
  97. createTime: 1735530373
  98. },
  99. config: {
  100. tplInfo: {
  101. styleId: 0,
  102. matchLogo: "/static/run.png",
  103. },
  104. matchInfo: {
  105. compName: "小飞龙系列定向赛",
  106. compBeginSecond: 1735530373,
  107. compEndSecond: 1735950373,
  108. }
  109. }
  110. },
  111. {
  112. otherInfo: {
  113. compId: 2,
  114. pubState: 1,
  115. playNum: 37,
  116. signupState: true,
  117. createTime: 1735530373,
  118. },
  119. config: {
  120. tplInfo: {
  121. styleId: 1,
  122. matchLogo: "/static/logo/xfl.png",
  123. },
  124. matchInfo: {
  125. compName: "领秀城社区定向赛",
  126. compBeginSecond: 1735530373,
  127. compEndSecond: 1735550373,
  128. }
  129. }
  130. },
  131. {
  132. otherInfo: {
  133. compId: 3,
  134. pubState: 2,
  135. playNum: 37,
  136. signupState: true,
  137. createTime: 1735530373,
  138. },
  139. config: {
  140. tplInfo: {
  141. styleId: 2,
  142. matchLogo: "/static/logo/poly.png",
  143. },
  144. matchInfo: {
  145. compName: "领秀城社区定向赛",
  146. compBeginSecond: 1735530373,
  147. compEndSecond: 1735550373,
  148. }
  149. }
  150. },
  151. {
  152. otherInfo: {
  153. compId: 4,
  154. pubState: 1,
  155. playNum: 37,
  156. signupState: true,
  157. createTime: 1735530373,
  158. },
  159. config: {
  160. tplInfo: {
  161. styleId: 3,
  162. matchLogo: "/static/logo/sddx.png",
  163. },
  164. matchInfo: {
  165. compName: "领秀城社区定向赛",
  166. compBeginSecond: 1735530373,
  167. compEndSecond: 1735550373,
  168. }
  169. }
  170. },
  171. {
  172. otherInfo: {
  173. compId: 5,
  174. pubState: 2,
  175. playNum: 37,
  176. signupState: true,
  177. createTime: 1735530373,
  178. },
  179. config: {
  180. tplInfo: {
  181. styleId: 3,
  182. matchLogo: "/static/logo/sddx.png",
  183. },
  184. matchInfo: {
  185. compName: "领秀城社区定向赛",
  186. compBeginSecond: 1735530373,
  187. compEndSecond: 1735550373,
  188. }
  189. }
  190. }
  191. ] */
  192. }
  193. },
  194. computed: {
  195. ...mapState([
  196. 'username', // 映射 this.username 为 store.state.username
  197. 'userlevel',
  198. 'token'
  199. ]),
  200. ...mapGetters([
  201. 'metadata'
  202. ]),
  203. },
  204. onLoad(query) {
  205. this.init();
  206. },
  207. onShow() {
  208. // console.log("metadata:", this.metadata);
  209. this.init();
  210. },
  211. methods: {
  212. init() {
  213. this.getSelfInfo();
  214. this.compInfoQuery();
  215. },
  216. getCardClass(styleid) {
  217. let css = "";
  218. if (styleid >= 0) {
  219. css = "item-cardbox-bg-" + tplStyleList[styleid];
  220. }
  221. return css;
  222. },
  223. fmtTime(timestamp, type = 3) {
  224. return tools.timestampToTime(timestamp * 1000, type);
  225. },
  226. // 获取比赛状态
  227. getMatchState(beginSecond, endSecond) {
  228. // console.log(this.endSecond)
  229. let countdown = "";
  230. if (beginSecond > 0 && endSecond > 0) {
  231. const now = Date.now() / 1000;
  232. const dif1 = beginSecond - now;
  233. const dif2 = endSecond - now;
  234. if (dif1 > 0) {
  235. countdown = "未开赛";
  236. } else if (dif2 > 0) {
  237. countdown = "已开赛";
  238. } else {
  239. countdown = "已结束";
  240. }
  241. // countdown = tools.convertSecondsToHMS(dif);
  242. } else {
  243. countdown = "--";
  244. }
  245. return countdown;
  246. },
  247. // 获取倒计时
  248. getCountdown(endSecond) {
  249. // console.log(this.endSecond)
  250. let countdown = "";
  251. if (endSecond > 0) {
  252. const now = Date.now() / 1000;
  253. const dif = endSecond - now;
  254. // const dif = 3600*24 - 60;
  255. if (dif > 0) {
  256. countdown = "距结束 " + tools.convertSecondsToDHM(dif);
  257. } else {
  258. countdown = "已结束";
  259. }
  260. // countdown = tools.convertSecondsToHMS(dif);
  261. } else {
  262. countdown = "距结束 --天--小时";
  263. }
  264. return countdown;
  265. },
  266. // 获取个人信息
  267. getSelfInfo() {
  268. uni.request({
  269. url: apiGetSelfInfo,
  270. header: this.metadata,
  271. method: "POST",
  272. data: {},
  273. success: (res) => {
  274. console.log("getSelfInfo", res);
  275. if (checkResCode(res)) {
  276. const data = res.data.data;
  277. this.selfInfo = data;
  278. }
  279. },
  280. fail: (err) => {
  281. console.log("getSelfInfo err", err)
  282. },
  283. });
  284. },
  285. // 自助查询赛事信息
  286. compInfoQuery() {
  287. uni.request({
  288. url: apiCompInfoQuery,
  289. header: this.metadata,
  290. method: "POST",
  291. data: {},
  292. success: (res) => {
  293. console.log("compInfoQuery", res);
  294. if (checkResCode(res)) {
  295. const data = res.data.data;
  296. this.actStatistic = data.info;
  297. this.actList = data.rs;
  298. }
  299. },
  300. fail: (err) => {
  301. console.log("compInfoQuery err", err)
  302. },
  303. });
  304. },
  305. showDetail(data) {
  306. // console.log("showDetail data:", data);
  307. const queryObj = {
  308. compId: data.otherInfo.compId
  309. };
  310. const queryString = tools.objectToQueryString(queryObj);
  311. const url = '/pages/actManage/actDetail?' + queryString;
  312. tools.appAction(url, "uni.navigateTo");
  313. },
  314. btnActEdit(data) {
  315. const queryObj = {
  316. from: "index",
  317. compId: data.otherInfo.compId
  318. };
  319. const queryString = tools.objectToQueryString(queryObj);
  320. const url = '/pages/actCreate/actEdit?' + queryString;
  321. tools.appAction(url, "uni.navigateTo");
  322. event.stopPropagation();
  323. },
  324. }
  325. }
  326. </script>
  327. <style scoped>
  328. /deep/ uni-page {
  329. background-color: #F6F6F6;
  330. }
  331. .top {
  332. background-color: #FFFFFF;
  333. }
  334. .top-content {
  335. position: relative;
  336. width: 90%;
  337. height: 90px;
  338. }
  339. .tc-headimg {
  340. width: 48px;
  341. height: 48px;
  342. }
  343. .tc-userBox {
  344. height: 80%;
  345. margin-left: 20px;
  346. flex-grow: 1;
  347. }
  348. .userBox-name {
  349. font-size: 16px;
  350. font-weight: 550;
  351. color: #383838;
  352. }
  353. .userBox-info {
  354. width: 90%;
  355. font-size: 14px;
  356. font-weight: 500;
  357. color: #383838;
  358. }
  359. .actBox {
  360. width: 90%;
  361. margin-top: 30rpx;
  362. margin-bottom: 10rpx;
  363. }
  364. .actBox-title {
  365. font-size: 15px;
  366. font-weight: 550;
  367. }
  368. .actBox-info {
  369. font-size: 14px;
  370. color: #383838;
  371. }
  372. .norecord {
  373. font-weight: 500;
  374. color: #818181;
  375. font-size: 14px;
  376. text-align: center;
  377. line-height: 58vh;
  378. }
  379. .list {
  380. width: 95%;
  381. flex-wrap: wrap;
  382. justify-content: flex-start;
  383. /* background-color: #FFCD29; */
  384. }
  385. .item {
  386. /* width: 43.8%; */
  387. width: 45.7%;
  388. margin: 20rpx 15rpx;
  389. border-radius: 8px;
  390. background-color: #FFFFFF;
  391. }
  392. .item-cardbox {
  393. position: relative;
  394. width: 100%;
  395. height: 180px;
  396. border-radius: 8px 8px 0px 0px;
  397. }
  398. .item-cardbox-bg-blue {
  399. background: linear-gradient(180deg, #009DFF 0%, #005591 100%), #CCCCCC;
  400. }
  401. .item-cardbox-bg-green {
  402. background: linear-gradient(180deg, #39AB27 0%, #006B05 100%), #CCCCCC;
  403. }
  404. .item-cardbox-bg-orange {
  405. background: linear-gradient(180deg, #ff8103 0%, #915900 100%), #CCCCCC;
  406. }
  407. .item-cardbox-bg-purple {
  408. background: linear-gradient(180deg, #ab01ff 0%, #6d0091 100%), #CCCCCC;
  409. }
  410. .item-cornerBox {
  411. position: absolute;
  412. height: 17px;
  413. padding: 1px 8px;
  414. background-color: rgba(0, 0, 0, 0.38);
  415. border-radius: 17.85px;
  416. font-size: 12px;
  417. font-weight: 500;
  418. color: #FFFFFF;
  419. text-align: center;
  420. line-height: 17px;
  421. white-space: nowrap;
  422. }
  423. .item-cornerLeft {
  424. left: 5px;
  425. top: 5px;
  426. }
  427. .item-cornerRight {
  428. right: 5px;
  429. top: 5px;
  430. }
  431. .item-pic {
  432. width: 100%;
  433. height: 70px;
  434. /* padding: 10px 0px; */
  435. padding-top: 20px;
  436. padding-bottom: 5px;
  437. }
  438. .item-matchType {
  439. font-size: 12px;
  440. font-weight: 400;
  441. color: #FFFFFF;
  442. }
  443. .item-matchName {
  444. padding: 5px 0px;
  445. font-size: 14px;
  446. font-weight: 700;
  447. color: #FFFFFF;
  448. }
  449. .item-createTime {
  450. font-size: 11px;
  451. font-weight: 500;
  452. color: #FFEB3B;
  453. }
  454. .item-introduce {
  455. width: 86%;
  456. height: 66px;
  457. /* margin-top: 10rpx; */
  458. }
  459. .item-playNum {
  460. width: 100%;
  461. font-size: 14px;
  462. font-weight: 400;
  463. color: #383838;
  464. }
  465. .item-signupState {
  466. padding: 2px 8px;
  467. border-radius: 80px;
  468. background: #F2F2F2;
  469. font-size: 14px;
  470. font-weight: 500;
  471. color: #383838;
  472. }
  473. .item-ico {
  474. width: 22px;
  475. height: 22px;
  476. }
  477. </style>