actDetail.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503
  1. <!--
  2. 赛事详情
  3. http://localhost:5173/actMgt/#/pages/actManage/actDetail?compId=80
  4. https://oss-mbh5.colormaprun.com/actMgt/#/pages/actManage/actDetail?compId=80
  5. -->
  6. <template>
  7. <view class="body">
  8. <view class="content uni-column">
  9. <view class="uni-column top" :style="getBannerStyle()">
  10. <my-topbar :title="actRs.config.matchInfo.compName" @btnBackClick="btnBack"
  11. :showBack="isSelfCreate && userlevel > 0"></my-topbar>
  12. <view class="top-content uni-row">
  13. </view>
  14. </view>
  15. <view class="main uni-column">
  16. <view class="compBox uni-column">
  17. <view class="compName">
  18. <uni-tag v-if="isSelfCreate && isMgt" :circle="true" :text="pubState[actRs.otherInfo.pubState]"
  19. :type="actRs.otherInfo.pubState > 1 ? 'primary' : 'warning'" size="small" />
  20. {{actRs.config.matchInfo.compName}}
  21. </view>
  22. <view class="comp_time">赛事日期:{{getActtime()}}</view>
  23. <view v-if="userlevel > 0 && isSelfCreate" class="comp_time">( 联系人:{{actRs.config.matchInfo.contactName}}
  24. &nbsp;&nbsp; 电话:<a :href="'tel:' + actRs.config.matchInfo.phone"
  25. style='color: #ff5500;'>{{actRs.config.matchInfo.phone}}</a> )</view>
  26. <view class="introduce uni-column">
  27. <!-- <text class="introduce-title">赛事介绍</text> -->
  28. <text class="introduce-content" v-html="actRs.config.matchInfo.description"></text>
  29. </view>
  30. <view v-if="actRs.config.matchInfo.rules.length > 0" class="activityRules uni-column">
  31. <text class="activityRules-title">活动规则</text>
  32. <text class="activityRules-content" v-html="actRs.config.matchInfo.rules"></text>
  33. </view>
  34. </view>
  35. <view class="uni-row uni-jcse qrImgBox">
  36. <view class="uni-column">
  37. <image class="imgQrCode" :src="imgQrCodeWx"></image>
  38. <view class="qrMemo">(微信扫码)</view>
  39. <view class="qrMemo">查看赛事详情</view>
  40. </view>
  41. <view v-if="isMgt" class="uni-column">
  42. <image class="imgQrCode" :src="imgQrCodeApp"></image>
  43. <view class="qrMemo">(彩图奔跑APP扫码)</view>
  44. <view class="qrMemo">查看赛事卡片<text v-if="isMgt" style="color: #ff5500;"
  45. @click="qrCodeReset"> [重置]</text></view>
  46. </view>
  47. </view>
  48. <view class="actButtonBox uni-row uni-jcc">
  49. <button v-if="isSelfCreate && isMgt" class="actButton" @click="btnActEdit">赛事修改</button>
  50. <button v-if="isSelfCreate && isMgt && actRs.otherInfo.pubState == 1" class="actButton" @click="btnActPublish">赛事发布</button>
  51. </view>
  52. </view>
  53. <view class="bottom uni-row uni-jcc">
  54. <button class="bottom-button" @click="btnRankList">排行榜</button>
  55. <button class="bottom-button" @click="btnUserList">玩家列表</button>
  56. <button v-if="isMgt" class="bottom-button" @click="btnTrack">场地直播</button>
  57. </view>
  58. </view>
  59. <view class="qrcodeBox">
  60. <uv-qrcode ref="qrCodeWx" class="qrCode" size="300px" :value="qrCodeWx" :options="qrCodeOptWx"
  61. @complete="qrCodeWxComplete">
  62. </uv-qrcode>
  63. <uv-qrcode v-if="isMgt" ref="qrCodeApp" class="qrCode" size="300px" :value="qrCodeApp"
  64. :options="qrCodeOptApp" @complete="qrCodeAppComplete">
  65. </uv-qrcode>
  66. </view>
  67. </view>
  68. </template>
  69. <script>
  70. import {
  71. mapState,
  72. mapGetters
  73. } from 'vuex';
  74. import tools from '/utils/tools.js';
  75. import card from '/utils/card.js';
  76. // import { tplStyleList, userLevel, pubState } from '/utils/define.js';
  77. import {
  78. pubState
  79. } from '/utils/define.js';
  80. import {
  81. apiCompInfoDetail,
  82. apiCompInfoPublish,
  83. apiCompQrCodeQuery,
  84. apiCompQrCodeReset,
  85. checkResCode
  86. } from '/utils/api.js';
  87. export default {
  88. data() {
  89. return {
  90. pubState: pubState, //发布状态 0:审核中 1:内测 2:已发布
  91. queryObj: {},
  92. queryString: "",
  93. compId: 0, // 赛事ID
  94. isMgt: false, // 当前用户是否有赛事管理权
  95. isSelfCreate: true, // 是否自助开赛
  96. qrCodeWx: "",
  97. qrCodeOptWx: {
  98. margin: 5,
  99. // areaColor: "#f1f1f1",
  100. foregroundImageSrc: '/static/logo/wechat.png' // 指定二维码前景,一般可在中间放logo
  101. },
  102. imgQrCodeWx: "",
  103. qrCodeApp: "",
  104. qrCodeOptApp: {
  105. margin: 5,
  106. // areaColor: "#f1f1f1",
  107. foregroundImageSrc: '/static/logo.png' // 指定二维码前景,一般可在中间放logo
  108. },
  109. imgQrCodeApp: "",
  110. actRs: card.actRs,
  111. /* actRs: {
  112. otherInfo: {
  113. compId: 1,
  114. pubState: "内测",
  115. playNum: 26,
  116. signupState: false,
  117. createTime: 1735530373
  118. },
  119. config: {
  120. "tplInfo": {
  121. "styleId": 0,
  122. "matchLogo": "/static/run.png",
  123. "matchBanner": "static/banner/banner1.png",
  124. },
  125. "matchInfo": {
  126. "compName": "小飞龙系列定向赛",
  127. "description": " · 小飞龙定向赛再次来袭!这次有五个场地哟~<br> · 神秘“蛋叔”闪亮登场~<br> · 蛋叔放大招,百味豆换鸡蛋!<br> · 时不可待!冲鸭!<br><br> · 能不能把蛋叔整郁闷,就看你的啦~<br> · 还等啥?火速报名吧!",
  128. "rules": "<li>随时参赛、不限完赛次数、起点任选、实时排名 <li>起点 -各途经点 -结束点完整打卡为一次有效完赛",
  129. "maxNum": 20,
  130. "contactName": "王老师",
  131. "phone": "13335116666",
  132. "regBeginSecond": 1735530373,
  133. "regEndSecond": 1735950373,
  134. "compBeginSecond": 1736050373,
  135. "compEndSecond": 1736950373,
  136. }
  137. }
  138. } */
  139. }
  140. },
  141. computed: {
  142. ...mapState([
  143. 'username', // 映射 this.username 为 store.state.username
  144. 'userlevel',
  145. 'token'
  146. ]),
  147. ...mapGetters([
  148. 'metadata'
  149. ]),
  150. },
  151. onLoad(query) {
  152. // console.log(query);
  153. this.queryObj = query;
  154. this.queryString = tools.objectToQueryString(this.queryObj);
  155. // console.log(queryString);
  156. this.compId = query["compId"] ?? 0;
  157. this.compInfoDetail();
  158. this.getQrCodeWx();
  159. },
  160. methods: {
  161. getBannerStyle() {
  162. return card.getBannerStyle(this.actRs);
  163. },
  164. getActtime() {
  165. return tools.fmtMcTime3(this.actRs.config.matchInfo.compBeginSecond, this.actRs.config.matchInfo
  166. .compEndSecond);
  167. },
  168. // 自助赛事详情查询
  169. compInfoDetail() {
  170. uni.request({
  171. url: apiCompInfoDetail,
  172. header: this.metadata,
  173. method: "POST",
  174. data: {
  175. compId: this.compId
  176. },
  177. success: (res) => {
  178. // console.log("compInfoDetail", res);
  179. if (checkResCode(res)) {
  180. const data = res.data.data;
  181. this.actRs = data;
  182. this.isSelfCreate = data.otherInfo.isSelfCreate;
  183. this.isMgt = data.otherInfo.isMgt;
  184. if (this.isMgt) {
  185. this.getQrCodeApp();
  186. }
  187. }
  188. },
  189. fail: (err) => {
  190. console.log("compInfoDetail err", err);
  191. },
  192. });
  193. },
  194. // 自助赛事发布
  195. compInfoPublish() {
  196. uni.request({
  197. url: apiCompInfoPublish,
  198. header: this.metadata,
  199. method: "POST",
  200. data: {
  201. compId: this.compId
  202. },
  203. success: (res) => {
  204. // console.log("compInfoPublish", res);
  205. if (checkResCode(res)) {
  206. // const data = res.data.data;
  207. uni.showToast({
  208. title: `赛事发布成功`,
  209. icon: 'none',
  210. duration: 3000
  211. });
  212. setTimeout(() => {
  213. this.$router.go(0); // 刷新当前页面
  214. }, 1000);
  215. }
  216. },
  217. fail: (err) => {
  218. console.log("compInfoPublish err", err);
  219. },
  220. });
  221. },
  222. getQrCodeWx() {
  223. this.qrCodeWx = process.env.OSS_URL + "#/pages/actManage/actDetail?compId=" + this.compId;
  224. },
  225. getQrCodeApp() {
  226. uni.request({
  227. url: apiCompQrCodeQuery,
  228. header: this.metadata,
  229. method: "POST",
  230. data: {
  231. compId: this.compId
  232. },
  233. success: (res) => {
  234. // console.log("getQrCodeApp", res);
  235. if (checkResCode(res)) {
  236. const data = res.data.data;
  237. this.qrCodeApp = "url:" + data.qrCode;
  238. }
  239. },
  240. fail: (err) => {
  241. console.log("getQrCodeApp err", err);
  242. },
  243. });
  244. },
  245. // 重置APP二维码
  246. qrCodeAppReset() {
  247. uni.request({
  248. url: apiCompQrCodeReset,
  249. header: this.metadata,
  250. method: "POST",
  251. data: {
  252. compId: this.compId
  253. },
  254. success: (res) => {
  255. // console.log("qrCodeAppReset", res);
  256. if (checkResCode(res)) {
  257. this.getQrCodeApp(); // 重新获取二维码
  258. uni.showToast({
  259. title: `二维码重置成功`,
  260. icon: 'none',
  261. duration: 3000
  262. });
  263. }
  264. },
  265. fail: (err) => {
  266. console.log("qrCodeAppReset err", err);
  267. },
  268. });
  269. },
  270. btnBack() {
  271. const url = "/pages/actManage/index";
  272. tools.appAction(url, "uni.switchTab");
  273. },
  274. btnActEdit() {
  275. this.queryObj.from = "actDetail";
  276. this.queryString = tools.objectToQueryString(this.queryObj);
  277. const url = '/pages/actCreate/actEdit?' + this.queryString;
  278. tools.appAction(url, "uni.navigateTo");
  279. },
  280. btnActPublish() {
  281. let that = this;
  282. uni.showModal({
  283. title: '提示',
  284. content: `赛事发布后将无法修改赛事内容\r\n您确定要继续吗?`,
  285. confirmText: '确定', //确定文本的文字
  286. cancelText: '取消', //确定文本的文字
  287. showCancel: true, //没有取消按钮的弹框
  288. success: function(res) {
  289. if (res.confirm) {
  290. that.compInfoPublish();
  291. } else if (res.cancel) {}
  292. }
  293. });
  294. },
  295. btnRankList() {
  296. const url = '/pages/actManage/rankList?' + this.queryString;
  297. tools.appAction(url, "uni.navigateTo");
  298. },
  299. btnTrack() {
  300. const url = '/pages/actManage/track?' + this.queryString;
  301. tools.appAction(url, "uni.navigateTo");
  302. },
  303. btnUserList() {
  304. const url = '/pages/actManage/userList?' + this.queryString;
  305. tools.appAction(url, "uni.navigateTo");
  306. },
  307. qrCodeReset() {
  308. let that = this;
  309. uni.showModal({
  310. title: '重置二维码',
  311. content: `重置后生成新码,旧码会失效\r\n您确定要继续吗?`,
  312. confirmText: '确定', //确定文本的文字
  313. cancelText: '取消', //确定文本的文字
  314. showCancel: true, //没有取消按钮的弹框
  315. success: function(res) {
  316. if (res.confirm) {
  317. that.qrCodeAppReset();
  318. } else if (res.cancel) {}
  319. }
  320. });
  321. },
  322. qrCodeWxComplete(res) {
  323. // console.log("[qrCodeWxComplete] res", res);
  324. this.$refs.qrCodeWx.toTempFilePath({
  325. success: (res) => {
  326. // console.log(res);
  327. this.imgQrCodeWx = res.tempFilePath;
  328. }
  329. });
  330. },
  331. qrCodeAppComplete(res) {
  332. // console.log("[qrCodeAppComplete] res", res);
  333. this.$refs.qrCodeApp.toTempFilePath({
  334. success: (res) => {
  335. // console.log(res);
  336. this.imgQrCodeApp = res.tempFilePath;
  337. }
  338. });
  339. }
  340. }
  341. }
  342. </script>
  343. <style scoped>
  344. .top {
  345. height: 170px;
  346. padding-top: 16px;
  347. flex-shrink: 0;
  348. background-repeat: no-repeat;
  349. background-size: cover;
  350. background-position: center;
  351. }
  352. .main {
  353. margin-bottom: 60px;
  354. overflow: scroll;
  355. }
  356. .compBox {
  357. width: 76%;
  358. margin-top: 20px;
  359. }
  360. .compName {
  361. width: 90%;
  362. font-size: 19px;
  363. font-weight: 500;
  364. text-align: center;
  365. }
  366. .comp_time {
  367. margin-top: 8px;
  368. font-size: 12px;
  369. font-weight: 400;
  370. color: #808080;
  371. }
  372. .introduce {
  373. width: 100%;
  374. margin-top: 12px;
  375. margin-bottom: 10px;
  376. align-items: flex-start;
  377. justify-content: space-around;
  378. }
  379. .introduce-title {
  380. color: #333333;
  381. font-size: 15px;
  382. line-height: 30px;
  383. font-family: Source Han Sans CN;
  384. }
  385. .introduce-content {
  386. color: #333333;
  387. font-size: 14px;
  388. line-height: 23px;
  389. font-family: Source Han Sans CN;
  390. }
  391. .activityRules {
  392. width: 100%;
  393. margin-top: 5px;
  394. margin-bottom: 10px;
  395. padding: 10px 15px;
  396. align-items: flex-start;
  397. justify-content: space-around;
  398. border-radius: 9px;
  399. background: #EBEBEB;
  400. }
  401. .activityRules-title {
  402. color: #333333;
  403. font-size: 14px;
  404. line-height: 25px;
  405. font-weight: 500;
  406. font-family: Source Han Sans CN;
  407. }
  408. .activityRules-content {
  409. color: #333333;
  410. font-size: 13px;
  411. line-height: 23px;
  412. font-family: Source Han Sans CN;
  413. }
  414. .actButtonBox {
  415. width: 80%;
  416. margin-top: 20px;
  417. margin-bottom: 20px;
  418. }
  419. .actButton {
  420. height: 30px;
  421. background: #FFB40B;
  422. font-size: 14px;
  423. font-weight: 400;
  424. line-height: 30px;
  425. }
  426. .bottom {
  427. position: fixed;
  428. bottom: 0;
  429. width: 100%;
  430. height: 40px;
  431. background-color: #ffffff;
  432. border-top: #E5E5E5 solid 1px;
  433. }
  434. .bottom-button {
  435. width: 90px;
  436. height: 30px;
  437. color: #ffffff;
  438. background: #2e85ec;
  439. font-size: 14px;
  440. font-weight: 400;
  441. line-height: 30px;
  442. }
  443. .qrImgBox {
  444. width: 90%;
  445. }
  446. .qrCode {
  447. visibility: hidden;
  448. }
  449. .imgQrCode {
  450. width: 120px;
  451. height: 120px;
  452. margin-top: 20px;
  453. margin-bottom: 6px;
  454. border: 2px solid;
  455. }
  456. .qrMemo {
  457. font-size: 12px;
  458. line-height: 18px;
  459. }
  460. .qrcodeBox {
  461. height: 0px;
  462. overflow: hidden;
  463. }
  464. </style>