detail.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444
  1. <!--
  2. 每月挑战 - 详情
  3. http://localhost:5173/card/#/pages/mytz/detail
  4. https://oss-mbh5.colormaprun.com/card/#/pages/mytz/detail
  5. -->
  6. <template>
  7. <view class="body">
  8. <view class="content uni-column">
  9. <view class="top uni-column">
  10. <view class="topbar uni-row">
  11. <image mode="aspectFit" class="topbar-back" @click="btnBack" src="/static/default/back.png"></image>
  12. <text class="mcName">{{ecName}}</text>
  13. <image mode="aspectFit" class="topbar-info" @click="btnInfo" src="/static/default/info.png"></image>
  14. </view>
  15. <text class="toplogo">{{curMonth}}</text>
  16. <text class="cardDesc">{{ecDesc}}</text>
  17. </view>
  18. <view class="main uni-column">
  19. <view class="cupview uni-column">
  20. <view class="cup" :style="getCupStyle('cup')">
  21. <view class="cup-gray" :style="getCupStyle('cup-gray')"></view>
  22. </view>
  23. <text class="cup-text"><text style="font-weight: 600;">{{month}}月</text> |
  24. {{realNum}}/{{targetNum}}</text>
  25. <text class="cup-text2">{{progressText}}</text>
  26. </view>
  27. <button class="btnStart" @click="btnStart">{{btnText}}</button>
  28. </view>
  29. </view>
  30. <uni-popup ref="popup" :mask-click="false" maskBackgroundColor="rgba(0, 0, 0, 0.6)">
  31. <view class="popup">
  32. <swiper ref="swiper" class="swiper" :current="swiperCurrent" @change="swiperChange"
  33. :indicator-dots="false" indicator-active-color="rgba(46, 133, 236, 1)" :autoplay="false"
  34. :interval="5000">
  35. <swiper-item class="swiper-item uni-column">
  36. <view class="introduce uni-column">
  37. <text class="introduce-title">挑战赛规则</text>
  38. <view>
  39. <text class="introduce-sn">①</text>
  40. <text class="introduce-content">选任意定向地图,完成4次挑战,你就胜利啦!</text>
  41. </view>
  42. <view>
  43. <text class="introduce-sn">②</text>
  44. <text class="introduce-content">挑战成功,会点亮你的电子奖杯!</text>
  45. </view>
  46. <view>
  47. <text class="introduce-sn">③</text>
  48. <text class="introduce-content">定向里程累计5千米,就有一枚奖章等你哦!</text>
  49. </view>
  50. </view>
  51. <image class="main-pic" mode="aspectFit" src="/static/mytz/main_pic.png"></image>
  52. <button class="swiper-item-button" @click="popupClose">确定</button>
  53. </swiper-item>
  54. </swiper>
  55. </view>
  56. </uni-popup>
  57. </view>
  58. </template>
  59. <script>
  60. import tools from '../../common/tools';
  61. import {
  62. token,
  63. apiCardBaseQuery,
  64. apiCurrentMonthlyChallengeQuery,
  65. checkResCode,
  66. checkToken
  67. } from '../../common/api';
  68. export default {
  69. data() {
  70. return {
  71. queryString: "",
  72. token: "",
  73. tokenValid: false,
  74. ecId: 0, // 卡片id
  75. ecName: '', // 卡片名称
  76. ecDesc: '', // 卡片简介
  77. month: '', // 月名称
  78. realNum: 0, // 实际完赛次数
  79. targetNum: 0, // 要求完赛次数
  80. // mcType: 0, // 赛事类型 1 普通活动 2 线下赛 3 线上赛
  81. // mcName: "", // 赛事名称
  82. swiperCurrent: 0, // swiper当前所在滑块的 index
  83. cupProgress: 100, // 奖杯进度 (100 - 实际进度,初始值为100)
  84. progressText: "",
  85. btnText: "",
  86. }
  87. },
  88. computed: {
  89. curMonth() {
  90. var currentDate = new Date();
  91. var currentMonth = currentDate.getMonth() + 1; // 月份从0开始,所以要加1
  92. return `${currentMonth}月`;
  93. },
  94. },
  95. onLoad(event) { // 类型非必填,可自动推导
  96. // console.log(event);
  97. this.queryString = tools.objectToQueryString(event);
  98. // console.log(queryString);
  99. this.token = event["token"] ?? token;
  100. this.ecId = event["id"] ?? 0;
  101. this.getCardBaseQuery();
  102. this.getCurrentMonthlyChallengeQuery();
  103. },
  104. // 页面初次渲染完成,此时组件已挂载完成,DOM 树($el)已可用
  105. onReady() {},
  106. onUnload() {},
  107. methods: {
  108. getCupProgress() {
  109. if (this.targetNum > 0 && this.realNum > 0) {
  110. if (this.realNum < this.targetNum) {
  111. const progress = this.realNum / this.targetNum * 100;
  112. this.cupProgress = 100 - progress;
  113. } else {
  114. this.cupProgress = 0;
  115. }
  116. } else {
  117. this.cupProgress = 100;
  118. }
  119. // console.log("cupProgress:", this.cupProgress);
  120. },
  121. getText() {
  122. if (!this.tokenValid) {
  123. this.progressText = `您尚未登录,欢迎参加挑战!!`;
  124. this.btnText = "开始挑战";
  125. }
  126. else if (this.realNum == 0) {
  127. this.progressText = `您尚未开始,欢迎参加挑战!!`;
  128. this.btnText = "开始挑战";
  129. }
  130. else if (this.realNum > 0 && this.realNum < this.targetNum) {
  131. this.progressText = `您已完成了${this.realNum}次挑战,继续加油!!`;
  132. this.btnText = "继续挑战";
  133. } else if (this.realNum > 0 && this.realNum >= this.targetNum){
  134. this.progressText = `恭喜,挑战成功!!`;
  135. this.btnText = "继续挑战";
  136. } else {
  137. this.progressText = ``;
  138. this.btnText = "开始挑战";
  139. }
  140. },
  141. getCupStyle(type) {
  142. if (! (this.month > 0)) {
  143. return '';
  144. }
  145. let group = 1;
  146. if (type == 'cup') {
  147. return `background-image: url("static/cup/${group}/${this.month}.png")`;
  148. } else if (type == 'cup-gray') {
  149. return `background-image: url("static/cup/${group}/${this.month}h.png"); height:${this.cupProgress}% ;`;
  150. }
  151. },
  152. // 卡片基本信息查询
  153. getCardBaseQuery() {
  154. uni.request({
  155. url: apiCardBaseQuery,
  156. header: {
  157. "Content-Type": "application/x-www-form-urlencoded",
  158. "token": this.token,
  159. },
  160. method: "POST",
  161. data: {
  162. ecId: this.ecId
  163. },
  164. success: (res) => {
  165. // console.log("getCardBaseQuery", res)
  166. const data = res.data.data;
  167. this.ecName = data.ecName;
  168. this.ecDesc = data.ecDesc;
  169. },
  170. fail: (err) => {
  171. console.log("getCardBaseQuery err", err)
  172. },
  173. });
  174. },
  175. // 玩家当前月挑战记录查询
  176. getCurrentMonthlyChallengeQuery() {
  177. uni.request({
  178. url: apiCurrentMonthlyChallengeQuery,
  179. header: {
  180. "Content-Type": "application/x-www-form-urlencoded",
  181. "token": this.token,
  182. },
  183. method: "POST",
  184. data: {},
  185. success: (res) => {
  186. console.log("getCurrentMonthlyChallengeQuery", res);
  187. if (checkResCode(res)) {
  188. if (res.statusCode == 401) { // 未登录
  189. this.tokenValid = false;
  190. } else {
  191. this.tokenValid = true;
  192. }
  193. const data = res.data.data;
  194. this.month = data.month;
  195. this.realNum = data.realNum;
  196. this.targetNum = data.targetNum;
  197. this.getCupProgress();
  198. this.getText();
  199. }
  200. },
  201. fail: (err) => {
  202. console.log("getCurrentMonthlyChallengeQuery err", err)
  203. },
  204. });
  205. },
  206. btnBack() {
  207. // window.history.back();
  208. window.location.href = `action://to_home/`;
  209. },
  210. btnInfo() {
  211. this.swiperCurrent = 0;
  212. this.$refs.popup.open();
  213. },
  214. btnStart() {
  215. window.location.href = `action://to_map_list/`;
  216. },
  217. //当前轮播索引
  218. swiperChange(e) {
  219. const curIndex = e.detail.current;
  220. this.swiperCurrent = curIndex;
  221. },
  222. swiperNext() {
  223. this.swiperCurrent++;
  224. },
  225. popupClose() {
  226. this.$refs.popup.close()
  227. }
  228. }
  229. }
  230. </script>
  231. <style scoped>
  232. .content {
  233. width: 100vw;
  234. height: 100vh;
  235. }
  236. .top {
  237. width: 100%;
  238. height: 360rpx;
  239. padding-top: 60rpx;
  240. padding-bottom: 60rpx;
  241. justify-content: space-between;
  242. background-image: url("/static/backgroud/top_run.png"), linear-gradient(180deg, #178bff 0%, #004d9b 100%);
  243. background-repeat: no-repeat;
  244. background-position: 50rpx 50rpx, 0rpx 0rpx;
  245. /* background-position-x: center; */
  246. /* background-position-y: center; */
  247. background-size: auto 430rpx, contain;
  248. }
  249. .topbar {
  250. width: 90%;
  251. padding: 0rpx 30rpx;
  252. justify-content: space-between;
  253. }
  254. .topbar-back {
  255. width: 43rpx;
  256. height: 43rpx;
  257. /* opacity: 0; */
  258. }
  259. .topbar-info {
  260. width: 46rpx;
  261. height: 46rpx;
  262. /* opacity: 0; */
  263. }
  264. .mcName {
  265. color: white;
  266. font-size: 40rpx;
  267. font-weight: 550;
  268. }
  269. .toplogo {
  270. width: 180rpx;
  271. height: 180rpx;
  272. /* margin-top: 20rpx; */
  273. background: url("/static/mytz/month_bg.png") no-repeat center;
  274. background-size: contain;
  275. color: #ff870d;
  276. font-size: 24px;
  277. font-weight: 700;
  278. text-align: center;
  279. line-height: 220rpx;
  280. }
  281. .cardDesc {
  282. /* font-weight: 550; */
  283. color: white;
  284. font-size: 32rpx;
  285. }
  286. .main {
  287. width: 80%;
  288. /* height: 800rpx; */
  289. flex-grow: 0.5;
  290. justify-content: space-between;
  291. }
  292. .cupview {
  293. height: 500rpx;
  294. margin-top: 150rpx;
  295. }
  296. .cup {
  297. width: 320rpx;
  298. height: 320rpx;
  299. /* background-image: url("/static/cup/004.png"); */
  300. background-position-x: center;
  301. background-repeat: no-repeat;
  302. background-size: 300rpx auto;
  303. }
  304. .cup-gray {
  305. width: 320rpx;
  306. /* height: 30%; */
  307. /* background-image: url("/static/cup/004h.png"); */
  308. background-position-x: center;
  309. background-repeat: no-repeat;
  310. background-size: 300rpx auto;
  311. overflow: hidden;
  312. /* filter: grayscale(1); */
  313. }
  314. .cup-text {
  315. color: #818181;
  316. font-size: 28rpx;
  317. line-height: 100rpx;
  318. }
  319. .cup-text2 {
  320. color: #333333;
  321. font-size: 28rpx;
  322. line-height: 100rpx;
  323. }
  324. .introduce {
  325. width: 80%;
  326. align-items: flex-start;
  327. justify-content: space-around;
  328. }
  329. .introduce-title {
  330. margin-top: 70rpx;
  331. margin-bottom: 60rpx;
  332. width: 100%;
  333. color: #333333;
  334. font-size: 36rpx;
  335. font-weight: 700;
  336. /* line-height: 60rpx; */
  337. text-align: center;
  338. }
  339. .introduce-sn {
  340. margin-right: 10rpx;
  341. color: #a16221;
  342. font-size: 38rpx;
  343. font-weight: 550;
  344. }
  345. .introduce-content {
  346. color: #333333;
  347. font-size: 28rpx;
  348. line-height: 72rpx;
  349. }
  350. .main-pic {
  351. width: 90%;
  352. height: 200rpx;
  353. }
  354. .btnStart {
  355. width: 100%;
  356. height: 100rpx;
  357. margin-bottom: 30rpx;
  358. color: white;
  359. font-weight: bold;
  360. line-height: 100rpx;
  361. background-color: #2e85ec;
  362. border-radius: 55rpx;
  363. }
  364. .popup {
  365. width: 90vw;
  366. height: 900rpx;
  367. background-color: #FEFBF6;
  368. border-radius: 50rpx;
  369. }
  370. .swiper {
  371. height: 100%;
  372. }
  373. .swiper-item {
  374. /* height: 80vh; */
  375. justify-content: space-between;
  376. /* background-color: lightblue; */
  377. }
  378. .swiper-item-title {
  379. margin-top: 80rpx;
  380. font-size: 40rpx;
  381. }
  382. .swiper-item-image {
  383. height: 300rpx;
  384. }
  385. .swiper-item-content {
  386. height: 100rpx;
  387. justify-content: start;
  388. }
  389. .swiper-item-button {
  390. width: 80%;
  391. height: 106rpx;
  392. margin-bottom: 80rpx;
  393. color: #ffffff;
  394. /* font-weight: bold; */
  395. line-height: 106rpx;
  396. background-color: #2e85ec;
  397. border-radius: 27px;
  398. }
  399. ::v-deep .uni-swiper-dots-horizontal {
  400. bottom: 230rpx;
  401. }
  402. </style>