index.vue 11 KB

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