success.uvue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380
  1. <!--
  2. http://localhost:5173/custom/#/pages/yuedong/challenge/success?id=13&matchType=3&pagetype=challenge_result&status=success&name=天生我材必有用
  3. http://localhost:5174/custom/#/pages/yuedong/challenge/success?actId=18&matchType=3&pagetype=challenge_result&distance=1320&status=success&name=天生我材必有用&cal=13500100&duration=3600&accuracy=50&syscount=25
  4. https://oss-mbh5.colormaprun.com/custom/#/pages/yuedong/challenge/index?pagetype=challenge_result&distance=1320&status=success&name=天生我材必有用&cal=13500100&duration=3600&accuracy=50&syscount=25
  5. -->
  6. <template>
  7. <view class="body">
  8. <view class="content">
  9. <view class="topBg"></view>
  10. <view class="top uni-column">
  11. <view class="topLogo"></view>
  12. </view>
  13. <view class="main">
  14. <view class="main-content">
  15. <view class="namebox uni-column">
  16. <image class="nameLogo" mode="aspectFit" src="/static/yuedong/challenge/logo.png"></image>
  17. <text class="name">{{nameSub}}</text>
  18. </view>
  19. <view class="rank">
  20. <image class="rankTopLogo" mode="aspectFit" src="/static/yuedong/challenge/yuedong.png"></image>
  21. <view class="statistic">
  22. <text class="statistic-title">总里程:</text>
  23. <view class="statistic-right">
  24. <text class="statistic-value">{{distanceKm}}</text><text
  25. class="statistic-unit">Km</text>
  26. </view>
  27. </view>
  28. <view class="statistic">
  29. <text class="statistic-title">总用时:</text>
  30. <view class="statistic-right">
  31. <text class="statistic-value">{{durationMin}}</text><text
  32. class="statistic-unit">min</text>
  33. </view>
  34. </view>
  35. <view class="statistic">
  36. <text class="statistic-title">脑力值:</text>
  37. <view class="statistic-right">
  38. <text class="statistic-value">{{accuracy}}</text><text class="statistic-unit">%</text>
  39. </view>
  40. </view>
  41. <view class="statistic">
  42. <text class="statistic-title">悦动豆:</text>
  43. <view class="statistic-right">
  44. <text class="statistic-value">{{syscount}}</text><text class="statistic-unit"></text>
  45. </view>
  46. </view>
  47. <image class="rankBtmLogo" mode="aspectFit" src="/static/yuedong/challenge/rfydpz.png"></image>
  48. </view>
  49. </view>
  50. </view>
  51. <!-- <view class="btnRankList" @click="btnRankList">点击查看排行榜</view> -->
  52. </view>
  53. <my-fab></my-fab>
  54. </view>
  55. </template>
  56. <script>
  57. import tools from '/common/tools';
  58. import {
  59. token,
  60. apiCardUrlQuery,
  61. apiMatchFininshInfoQuery,
  62. checkResCode
  63. } from '/common/api';
  64. export default {
  65. data() {
  66. return {
  67. token: "",
  68. matchType: 0, // 游戏类型 1 普通活动 2 线下赛 3 线上赛
  69. ecId: 0, // 卡片id
  70. ecName: "", // 卡片名称
  71. logo: "",
  72. sublogo: "",
  73. subTitle: "",
  74. accuracyLable: "",
  75. status: "", // success: 挑战成功, ok: 挑战完成(没在规定时间完成,但打了所有点), fail: 挑战结束
  76. name: "", // 用户名
  77. duration: 0, // 总用时,秒
  78. distance: 0, // 总里程,米
  79. cal: 0, // 卡路里,卡 int
  80. accuracy: 0, // 脑力值百分比
  81. syscount: 0, // 点数
  82. actId: 0, // 活动或关联id
  83. urlRs: [], // Url集合
  84. }
  85. },
  86. computed: {
  87. nameSub() {
  88. return this.name;
  89. /* const nameLen = tools.calStrLen(this.name);
  90. console.log('nameLen', nameLen);
  91. if (nameLen <= 10) {
  92. return '选手: ' + this.name;
  93. }
  94. // else if (nameLen >= maxlen) {
  95. // return this.name.substring(0,maxlen-1) + '...';
  96. // }
  97. else {
  98. return this.name;
  99. } */
  100. },
  101. durationMin() {
  102. return Math.round(this.duration * 10 / 60) / 10;
  103. },
  104. distanceKm() {
  105. return Math.round(this.distance * 10 / 1000) / 10;
  106. }
  107. },
  108. onLoad(event) { // 类型非必填,可自动推导
  109. console.log('[challenge result] onLoad');
  110. this.token = event["token"] ?? token;
  111. this.actId = event["id"] ?? 0;
  112. this.matchType = event["matchType"] ?? 0;
  113. this.logo = event["logo"] ?? "logo.webp";
  114. this.logo = "/static/shanda/" + this.logo;
  115. this.sublogo = event["sublogo"] ?? "";
  116. if (this.sublogo != "") {
  117. this.sublogo = "/static/shanda/" + this.sublogo;
  118. }
  119. this.subTitle = event["subTitle"] ?? "";
  120. this.accuracyLable = event["accuracyLable"] ?? "校园文化";
  121. this.status = event["status"] ?? "";
  122. this.name = event["name"] ?? "";
  123. // this.duration = event["duration"] ?? 0;
  124. // this.distance = event["distance"] ?? 0;
  125. // this.cal = event["cal"] ?? 0;
  126. // this.accuracy = event["accuracy"] ?? 0;
  127. // this.syscount = event["syscount"] ?? 0;
  128. // console.log("event:", JSON.stringify(event));
  129. // uni.showToast({
  130. // title: 'event:' + JSON.stringify(event),
  131. // icon: 'none',
  132. // duration: 10000
  133. // });
  134. // this.cardUrlQuery();
  135. this.matchFininshInfoQuery();
  136. },
  137. methods: {
  138. // 根据游戏id查询卡片信息
  139. cardUrlQuery() {
  140. uni.request({
  141. url: apiCardUrlQuery,
  142. header: {
  143. "Content-Type": "application/x-www-form-urlencoded",
  144. "token": this.token,
  145. },
  146. method: "POST",
  147. data: {
  148. actId: this.actId,
  149. matchType: this.matchType
  150. },
  151. success: (res) => {
  152. // console.log("cardUrlQuery", res);
  153. if (res.data.code == 0) {
  154. const data = res.data.data;
  155. this.ecId = data.ecId;
  156. this.ecName = data.ecName;
  157. this.urlRs = data.urlRs;
  158. }
  159. },
  160. fail: (err) => {
  161. console.log("cardUrlQuery err", err);
  162. },
  163. });
  164. },
  165. // 查询赛事结束显示信息
  166. matchFininshInfoQuery() {
  167. uni.request({
  168. url: apiMatchFininshInfoQuery,
  169. header: {
  170. "Content-Type": "application/x-www-form-urlencoded",
  171. "token": this.token,
  172. },
  173. method: "POST",
  174. data: {
  175. actId: this.actId,
  176. matchType: this.matchType
  177. },
  178. success: (res) => {
  179. console.log("matchFininshInfoQuery", res);
  180. if (res.data.code == 0) {
  181. const data = res.data.data.finishInfo;
  182. this.duration = data.totalTime;
  183. this.distance = data.distance;
  184. this.accuracy = data.rightAnswerPer;
  185. this.syscount = data.sysScore;
  186. }
  187. },
  188. fail: (err) => {
  189. console.log("matchFininshInfoQuery err", err);
  190. },
  191. });
  192. },
  193. btnRankList() {
  194. // console.log("urlRs", this.urlRs);
  195. // const rankListUrl = this.urlRs.find(item => item.name === 'rankListUrl');
  196. const rankListUrl = this.urlRs.rankListUrl;
  197. // console.log("rankListUrl", rankListUrl);
  198. if (rankListUrl != null) {
  199. let url = "";
  200. if (rankListUrl.indexOf('?') !== -1) {
  201. url = rankListUrl + '&token=' + this.token + '&id=' + this.ecId;
  202. } else {
  203. url = rankListUrl + '?token=' + this.token + '&id=' + this.ecId;
  204. }
  205. console.log("url", url);
  206. // uni.navigateTo({
  207. // url: url
  208. // });
  209. window.location.href = url;
  210. } else {
  211. uni.showToast({
  212. // title: '网址错误:' + rankListUrl,
  213. title: '请升级APP到最新版才能查看排行榜',
  214. icon: 'none',
  215. duration: 3000
  216. });
  217. }
  218. }
  219. }
  220. }
  221. </script>
  222. <style>
  223. .body {
  224. background-color: #2d2d2d;
  225. }
  226. .content {
  227. position: relative;
  228. width: 750rpx;
  229. min-height: 100vh;
  230. display: flex;
  231. flex-direction: column;
  232. align-items: center;
  233. justify-content: flex-end;
  234. }
  235. .topBg {
  236. position: absolute;
  237. top: 0;
  238. z-index: 1;
  239. width: 100%;
  240. height: 60vh;
  241. background-color: #c7e848;
  242. }
  243. .top {
  244. z-index: 10;
  245. width: 100%;
  246. height: 72vh;
  247. background-image: url("/static/yuedong/challenge/success_bg.png");
  248. background-repeat: no-repeat;
  249. background-position-x: center;
  250. background-position-y: bottom;
  251. background-size: 100% auto;
  252. }
  253. .topLogo {
  254. z-index: 10;
  255. width: 100%;
  256. height: 8vh;
  257. background-image: url("/static/yuedong/challenge/logo2.png");
  258. background-repeat: no-repeat;
  259. background-position-x: 40rpx;
  260. background-position-y: bottom;
  261. background-size: 360rpx auto;
  262. }
  263. .main {
  264. width: 100%;
  265. height: 28vh;
  266. flex-direction: column;
  267. justify-content: flex-start;
  268. align-items: center;
  269. }
  270. .main-content {
  271. display: flex;
  272. flex-direction: row;
  273. width: 100%;
  274. /* height: 400rpx; */
  275. }
  276. .namebox {
  277. width: 330rpx;
  278. margin-top: 40rpx;
  279. }
  280. .nameLogo {
  281. width: 200rpx;
  282. height: 200rpx;
  283. }
  284. .name {
  285. width: 280rpx;
  286. white-space: nowrap;
  287. overflow: hidden;
  288. text-align: center;
  289. margin-top: 10rpx;
  290. margin-left: 20rpx;
  291. font-family: Source Han Sans CN;
  292. font-weight: 500;
  293. font-size: 32rpx;
  294. color: #ffffff;
  295. }
  296. .rank {
  297. margin-left: 20rpx;
  298. margin-top: 0rpx;
  299. }
  300. .rankTopLogo {
  301. width: 300rpx;
  302. height: 120rpx;
  303. }
  304. .rankBtmLogo {
  305. width: 320rpx;
  306. height: 50rpx;
  307. margin-left: 5rpx;
  308. }
  309. .statistic {
  310. margin-left: 10rpx;
  311. height: 30rpx;
  312. margin-bottom: 16rpx;
  313. flex-direction: row;
  314. align-items: center;
  315. justify-content: flex-start;
  316. }
  317. .statistic-right {
  318. flex-direction: row;
  319. align-items: baseline;
  320. }
  321. .statistic-title {
  322. font-family: Source Han Sans CN;
  323. font-weight: 500;
  324. font-size: 28rpx;
  325. color: #ffffff;
  326. }
  327. .statistic-value {
  328. font-family: Source Han Sans CN;
  329. font-size: 28rpx;
  330. color: #ffffff;
  331. font-weight: bold;
  332. }
  333. .statistic-unit {
  334. font-family: Source Han Sans CN;
  335. font-size: 25rpx;
  336. color: #ffffff;
  337. padding-left: 10rpx;
  338. }
  339. .btnRankList {
  340. /* opacity: 30%; */
  341. width: 194px;
  342. height: 35px;
  343. margin-bottom: 60rpx;
  344. background: #b0352e;
  345. border-radius: 18px;
  346. align-items: center;
  347. color: #ffffff;
  348. font-size: 16px;
  349. line-height: 32px;
  350. }
  351. </style>