success.uvue 8.1 KB

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