success.uvue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  1. <!--
  2. http://localhost:5173/custom/#/pages/guoqing/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/guoqing/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/guoqing/logo.webp"></image>
  10. <text class="gameName"></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["id"] ?? 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. // console.log("event:", JSON.stringify(event));
  109. // uni.showToast({
  110. // title: 'event:' + JSON.stringify(event),
  111. // icon: 'none',
  112. // duration: 10000
  113. // });
  114. this.cardUrlQuery();
  115. },
  116. methods: {
  117. // 根据游戏id查询卡片信息
  118. cardUrlQuery() {
  119. uni.request({
  120. url: apiCardUrlQuery,
  121. header: {
  122. "Content-Type": "application/x-www-form-urlencoded",
  123. "token": this.token,
  124. },
  125. method: "POST",
  126. data: {
  127. actId: this.actId,
  128. matchType: this.matchType
  129. },
  130. success: (res) => {
  131. // console.log("cardUrlQuery", res);
  132. if (res.data.code == 0) {
  133. const data = res.data.data;
  134. this.ecId = data.ecId;
  135. this.urlRs = data.urlRs;
  136. }
  137. },
  138. fail: (err) => {
  139. console.log("cardUrlQuery err", err);
  140. },
  141. });
  142. },
  143. btnRankList() {
  144. // console.log("urlRs", this.urlRs);
  145. // const rankListUrl = this.urlRs.find(item => item.name === 'rankListUrl');
  146. const rankListUrl = this.urlRs.rankListUrl;
  147. // console.log("rankListUrl", rankListUrl);
  148. if (rankListUrl != null) {
  149. let url = "";
  150. if (rankListUrl.indexOf('?') !== -1) {
  151. url = rankListUrl + '&token=' + this.token + '&id=' + this.ecId;
  152. } else {
  153. url = rankListUrl + '?token=' + this.token + '&id=' + this.ecId;
  154. }
  155. console.log("url", url);
  156. // uni.navigateTo({
  157. // url: url
  158. // });
  159. window.location.href = url;
  160. } else {
  161. uni.showToast({
  162. // title: '网址错误:' + rankListUrl,
  163. title: '请升级APP到最新版才能查看排行榜',
  164. icon: 'none',
  165. duration: 3000
  166. });
  167. }
  168. }
  169. }
  170. }
  171. </script>
  172. <style>
  173. .body {
  174. /* background-color: #8d2117; */
  175. background-image: url("/static/guoqing/challenge/success_bg.png");
  176. background-repeat: no-repeat;
  177. background-position-x: center;
  178. background-position-y: center;
  179. background-size: cover;
  180. }
  181. .content {
  182. width: 750rpx;
  183. min-height: 100vh;
  184. /* margin: 0 auto; */
  185. display: flex;
  186. flex-direction: column;
  187. align-items: center;
  188. justify-content: space-around;
  189. }
  190. .top {
  191. width: 100%;
  192. /* height: 600rpx; */
  193. padding-top: 100rpx;
  194. flex-direction: column;
  195. align-items: center;
  196. justify-content: center;
  197. }
  198. .logo {
  199. width: 210rpx;
  200. height: 210rpx;
  201. }
  202. .gameName {
  203. padding-top: 30rpx;
  204. padding-bottom: 30rpx;
  205. font-family: Source Han Sans CN;
  206. font-weight: 500;
  207. font-size: 50rpx;
  208. color: #ffffff;
  209. }
  210. .main {
  211. width: 100%;
  212. flex-direction: column;
  213. justify-content: flex-start;
  214. align-items: center;
  215. }
  216. .main-content {
  217. /* margin-top: 25rpx; */
  218. /* margin-bottom: 60rpx; */
  219. width: 100%;
  220. height: 830rpx;
  221. /* background-image: url("/static/shanda/challenge/rank_bg.webp"); */
  222. background-image: url("/static/guoqing/challenge/rank_bg.png");
  223. background-repeat: no-repeat;
  224. background-position-x: center;
  225. background-position-y: top;
  226. background-size: contain;
  227. }
  228. .rank {
  229. width: 380rpx;
  230. /* height: 500rpx; */
  231. margin-left: 180rpx;
  232. margin-top: 146rpx;
  233. }
  234. .name {
  235. width: 330rpx;
  236. /* 确保文本在一行内显示 */
  237. white-space: nowrap;
  238. /* 超出容器部分的文本隐藏起来 */
  239. overflow: hidden;
  240. /* 使用省略号表示被截断的文本 */
  241. /* text-overflow: ellipsis; */
  242. text-align: center;
  243. margin-left: 250rpx;
  244. margin-top: 30rpx;
  245. font-family: Source Han Sans CN;
  246. font-weight: 500;
  247. font-size: 36rpx;
  248. color: #000000;
  249. }
  250. .statistic {
  251. height: 112rpx;
  252. margin-bottom: 16rpx;
  253. flex-direction: row;
  254. align-items: center;
  255. justify-content: space-between;
  256. }
  257. .statistic-right {
  258. flex-direction: row;
  259. align-items: baseline;
  260. }
  261. .statistic-title {
  262. font-family: Source Han Sans CN;
  263. font-weight: 500;
  264. font-size: 46rpx;
  265. color: #ffffff;
  266. }
  267. .statistic-value {
  268. font-family: Source Han Sans CN;
  269. font-size: 56rpx;
  270. color: #ffffff;
  271. font-weight: bold;
  272. }
  273. .statistic-unit {
  274. font-family: Source Han Sans CN;
  275. font-size: 40rpx;
  276. color: #ffffff;
  277. padding-left: 10rpx;
  278. }
  279. .btnRankList {
  280. /* opacity: 30%; */
  281. width: 194px;
  282. height: 40px;
  283. margin-bottom: 80rpx;
  284. background: #AB0505;
  285. border-radius: 18px;
  286. align-items: center;
  287. color: #ffffff;
  288. font-size: 16px;
  289. line-height: 40px;
  290. opacity: 0.51;
  291. }
  292. </style>