success.uvue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  1. <!--
  2. http://localhost:5173/custom/#/pages/shanda/challenge/index?actId=18&matchType=3&pagetype=challenge_result&distance=1320&status=success&name=天生我材必有用&cal=13500100&duration=3600&accuracy=50&syscount=25
  3. https://oss-mbh5.colormaprun.com/custom/#/pages/shanda/challenge/index?pagetype=challenge_result&distance=1320&status=success&name=天生我材必有用&cal=13500100&duration=3600&accuracy=50&syscount=25
  4. -->
  5. <template>
  6. <view class="body">
  7. <view class="content">
  8. <view class="top">
  9. <image class="logo" mode="aspectFit" src="/static/shanda/logo.webp"></image>
  10. <text class="gameName">山大24级新生校园定向赛</text>
  11. </view>
  12. <view class="main">
  13. <view class="main-content">
  14. <view class="rank">
  15. <view class="statistic">
  16. <text class="statistic-title">打点数:</text>
  17. <view class="statistic-right">
  18. <text class="statistic-value">{{syscount}}</text><text class="statistic-unit">个</text>
  19. </view>
  20. </view>
  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">{{accuracy}}</text><text class="statistic-unit">%</text>
  32. </view>
  33. </view>
  34. <view class="statistic">
  35. <text class="statistic-title">总用时:</text>
  36. <view class="statistic-right">
  37. <text class="statistic-value">{{durationMin}}</text><text
  38. class="statistic-unit">min</text>
  39. </view>
  40. </view>
  41. </view>
  42. <text class="name">{{nameSub}}</text>
  43. </view>
  44. </view>
  45. <view class="btnRankList" @click="btnRankList">点击查看排行榜</view>
  46. </view>
  47. <my-fab></my-fab>
  48. </view>
  49. </template>
  50. <script>
  51. import tools from '/common/tools';
  52. import {
  53. token,
  54. apiCardUrlQuery,
  55. checkResCode
  56. } from '/common/api';
  57. export default {
  58. data() {
  59. return {
  60. token: "",
  61. matchType: 0, // 游戏类型 1 普通活动 2 线下赛 3 线上赛
  62. ecId: 0, // 卡片id
  63. status: "", // success: 挑战成功, ok: 挑战完成(没在规定时间完成,但打了所有点), fail: 挑战结束
  64. name: "", // 用户名
  65. duration: 0, // 总用时,秒
  66. distance: 0, // 总里程,米
  67. cal: 0, // 卡路里,卡 int
  68. accuracy: 0, // 脑力值百分比
  69. syscount: 0 ,// 点数
  70. actId: 0, // 活动或关联id
  71. urlRs: [], // Url集合
  72. }
  73. },
  74. computed: {
  75. nameSub() {
  76. // const maxlen = 8;
  77. const nameLen = tools.calStrLen(this.name);
  78. console.log('nameLen', nameLen);
  79. if (nameLen <= 10) {
  80. return '选手: ' + this.name;
  81. }
  82. // else if (nameLen >= maxlen) {
  83. // return this.name.substring(0,maxlen-1) + '...';
  84. // }
  85. else {
  86. return this.name;
  87. }
  88. },
  89. durationMin() {
  90. return Math.round(this.duration * 10 / 60) / 10;
  91. },
  92. distanceKm() {
  93. return Math.round(this.distance * 10 / 1000) / 10;
  94. }
  95. },
  96. onLoad(event) { // 类型非必填,可自动推导
  97. console.log('[challenge result] onLoad');
  98. this.token = event["token"] ?? token;
  99. this.actId = event["actId"] ?? 0;
  100. this.matchType = event["matchType"] ?? 0;
  101. this.status = event["status"] ?? "";
  102. this.name = event["name"] ?? "";
  103. this.duration = event["duration"] ?? 0;
  104. this.distance = event["distance"] ?? 0;
  105. this.cal = event["cal"] ?? 0;
  106. this.accuracy = event["accuracy"] ?? 0;
  107. this.syscount = event["syscount"] ?? 0;
  108. this.cardUrlQuery();
  109. },
  110. methods: {
  111. // 根据游戏id查询卡片信息
  112. cardUrlQuery() {
  113. uni.request({
  114. url: apiCardUrlQuery,
  115. header: {
  116. "Content-Type": "application/x-www-form-urlencoded",
  117. "token": this.token,
  118. },
  119. method: "POST",
  120. data: {
  121. actId: this.actId,
  122. matchType: this.matchType
  123. },
  124. success: (res) => {
  125. // console.log("cardUrlQuery", res);
  126. if (res.data.code == 0) {
  127. const data = res.data.data;
  128. this.ecId = data.ecId;
  129. this.urlRs = data.urlRs;
  130. }
  131. },
  132. fail: (err) => {
  133. console.log("cardUrlQuery err", err);
  134. },
  135. });
  136. },
  137. btnRankList() {
  138. // console.log("urlRs", this.urlRs);
  139. // const rankListUrl = this.urlRs.find(item => item.name === 'rankListUrl');
  140. const rankListUrl = this.urlRs.rankListUrl;
  141. // console.log("rankListUrl", rankListUrl);
  142. if (rankListUrl != null) {
  143. const url = rankListUrl + '?token=' + this.token + '&id=' + this.ecId;
  144. console.log("url", url);
  145. // uni.navigateTo({
  146. // url: url
  147. // });
  148. window.location.href = url;
  149. } else {
  150. uni.showToast({
  151. title: '网址错误:' + rankListUrl,
  152. icon: 'none',
  153. duration: 3000
  154. });
  155. }
  156. }
  157. }
  158. }
  159. </script>
  160. <style>
  161. .body {
  162. background-color: #8d2117;
  163. /* background-image: url("/static/shanda/challenge/success_bg.webp");
  164. background-repeat: no-repeat;
  165. background-position-x: center;
  166. background-position-y: top;
  167. background-size: cover; */
  168. }
  169. .content {
  170. width: 750rpx;
  171. min-height: 100vh;
  172. /* margin: 0 auto; */
  173. display: flex;
  174. flex-direction: column;
  175. align-items: center;
  176. justify-content: space-around;
  177. }
  178. .top {
  179. width: 100%;
  180. /* height: 600rpx; */
  181. padding-top: 100rpx;
  182. flex-direction: column;
  183. align-items: center;
  184. justify-content: center;
  185. }
  186. .logo {
  187. width: 210rpx;
  188. height: 210rpx;
  189. }
  190. .gameName {
  191. padding-top: 30rpx;
  192. padding-bottom: 30rpx;
  193. font-family: Source Han Sans CN;
  194. font-weight: 500;
  195. font-size: 50rpx;
  196. color: #ffffff;
  197. }
  198. .main {
  199. width: 100%;
  200. flex-direction: column;
  201. justify-content: flex-start;
  202. align-items: center;
  203. }
  204. .main-content {
  205. /* margin-top: 25rpx; */
  206. /* margin-bottom: 60rpx; */
  207. width: 100%;
  208. height: 830rpx;
  209. /* background-image: url("/static/shanda/challenge/rank_bg.webp"); */
  210. background-image: url("/static/shanda/challenge/rank_bg2.png");
  211. background-repeat: no-repeat;
  212. background-position-x: center;
  213. background-position-y: top;
  214. background-size: contain;
  215. }
  216. .rank {
  217. width: 380rpx;
  218. /* height: 500rpx; */
  219. margin-left: 180rpx;
  220. margin-top: 140rpx;
  221. }
  222. .name {
  223. width: 330rpx;
  224. /* 确保文本在一行内显示 */
  225. white-space: nowrap;
  226. /* 超出容器部分的文本隐藏起来 */
  227. overflow: hidden;
  228. /* 使用省略号表示被截断的文本 */
  229. /* text-overflow: ellipsis; */
  230. text-align: center;
  231. margin-left: 250rpx;
  232. margin-top: 30rpx;
  233. font-family: Source Han Sans CN;
  234. font-weight: 500;
  235. font-size: 36rpx;
  236. color: #000000;
  237. }
  238. .statistic {
  239. height: 112rpx;
  240. margin-bottom: 16rpx;
  241. flex-direction: row;
  242. align-items: center;
  243. justify-content: space-between;
  244. }
  245. .statistic-right {
  246. flex-direction: row;
  247. align-items: baseline;
  248. }
  249. .statistic-title {
  250. font-family: Source Han Sans CN;
  251. font-weight: 500;
  252. font-size: 46rpx;
  253. color: #ffffff;
  254. }
  255. .statistic-value {
  256. font-family: Source Han Sans CN;
  257. font-size: 56rpx;
  258. color: #ffffff;
  259. font-weight: bold;
  260. }
  261. .statistic-unit {
  262. font-family: Source Han Sans CN;
  263. font-size: 40rpx;
  264. color: #ffffff;
  265. padding-left: 10rpx;
  266. }
  267. .btnRankList {
  268. /* opacity: 30%; */
  269. width: 194px;
  270. height: 35px;
  271. margin-bottom: 60rpx;
  272. background: #b0352e;
  273. border-radius: 18px;
  274. align-items: center;
  275. color: #ffffff;
  276. font-size: 16px;
  277. line-height: 32px;
  278. }
  279. </style>