success.uvue 7.8 KB

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