success.uvue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  1. <!--
  2. http://localhost:5174/custom/#/pages/yuedong/challenge/index?sublogo=sddx_jjyjy.png&subTitle=“筑梦宿州·创赢未来 ”特训营&accuracyLable=正确答题&actId=18&matchType=3&pagetype=challenge_result&distance=1320&status=success&name=天生我材必有用&cal=13500100&duration=3600&accuracy=50&syscount=25
  3. http://localhost:5174/custom/#/pages/yuedong/challenge/index?subTitle=山东大学123周年庆&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?sublogo=sddx_jjyjy.png&subTitle=“筑梦宿州·创赢未来 ”特训营&accuracyLable=正确答题&pagetype=challenge_result&distance=1320&status=success&name=天生我材必有用&cal=13500100&duration=3600&accuracy=50&syscount=25
  5. 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
  6. -->
  7. <template>
  8. <view class="body">
  9. <view class="content">
  10. <view class="top"></view>
  11. <view class="main">
  12. <view class="main-content">
  13. <view class="namebox">
  14. <text class="name">{{nameSub}}</text>
  15. </view>
  16. <view class="rank">
  17. <view class="statistic">
  18. <text class="statistic-title">总里程:</text>
  19. <view class="statistic-right">
  20. <text class="statistic-value">{{distanceKm}}</text><text
  21. class="statistic-unit">Km</text>
  22. </view>
  23. </view>
  24. <view class="statistic">
  25. <text class="statistic-title">总用时:</text>
  26. <view class="statistic-right">
  27. <text class="statistic-value">{{durationMin}}</text><text
  28. class="statistic-unit">min</text>
  29. </view>
  30. </view>
  31. <view class="statistic">
  32. <text class="statistic-title">脑力值:</text>
  33. <view class="statistic-right">
  34. <text class="statistic-value">{{accuracy}}</text><text class="statistic-unit">%</text>
  35. </view>
  36. </view>
  37. <view class="statistic">
  38. <text class="statistic-title">悦动豆:</text>
  39. <view class="statistic-right">
  40. <text class="statistic-value">{{syscount}}</text><text class="statistic-unit"></text>
  41. </view>
  42. </view>
  43. </view>
  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. logo: "",
  66. sublogo: "",
  67. subTitle: "",
  68. accuracyLable: "",
  69. status: "", // success: 挑战成功, ok: 挑战完成(没在规定时间完成,但打了所有点), fail: 挑战结束
  70. name: "", // 用户名
  71. duration: 0, // 总用时,秒
  72. distance: 0, // 总里程,米
  73. cal: 0, // 卡路里,卡 int
  74. accuracy: 0, // 脑力值百分比
  75. syscount: 0, // 点数
  76. actId: 0, // 活动或关联id
  77. urlRs: [], // Url集合
  78. }
  79. },
  80. computed: {
  81. nameSub() {
  82. // const maxlen = 8;
  83. const nameLen = tools.calStrLen(this.name);
  84. console.log('nameLen', nameLen);
  85. if (nameLen <= 10) {
  86. return '选手: ' + this.name;
  87. }
  88. // else if (nameLen >= maxlen) {
  89. // return this.name.substring(0,maxlen-1) + '...';
  90. // }
  91. else {
  92. return this.name;
  93. }
  94. },
  95. durationMin() {
  96. return Math.round(this.duration * 10 / 60) / 10;
  97. },
  98. distanceKm() {
  99. return Math.round(this.distance * 10 / 1000) / 10;
  100. }
  101. },
  102. onLoad(event) { // 类型非必填,可自动推导
  103. console.log('[challenge result] onLoad');
  104. this.token = event["token"] ?? token;
  105. this.actId = event["id"] ?? 0;
  106. this.matchType = event["matchType"] ?? 0;
  107. this.logo = event["logo"] ?? "logo.webp";
  108. this.logo = "/static/shanda/" + this.logo;
  109. this.sublogo = event["sublogo"] ?? "";
  110. if (this.sublogo != "") {
  111. this.sublogo = "/static/shanda/" + this.sublogo;
  112. }
  113. this.subTitle = event["subTitle"] ?? "";
  114. this.accuracyLable = event["accuracyLable"] ?? "校园文化";
  115. this.status = event["status"] ?? "";
  116. this.name = event["name"] ?? "";
  117. this.duration = event["duration"] ?? 0;
  118. this.distance = event["distance"] ?? 0;
  119. this.cal = event["cal"] ?? 0;
  120. this.accuracy = event["accuracy"] ?? 0;
  121. this.syscount = event["syscount"] ?? 0;
  122. // console.log("event:", JSON.stringify(event));
  123. // uni.showToast({
  124. // title: 'event:' + JSON.stringify(event),
  125. // icon: 'none',
  126. // duration: 10000
  127. // });
  128. this.cardUrlQuery();
  129. },
  130. methods: {
  131. // 根据游戏id查询卡片信息
  132. cardUrlQuery() {
  133. uni.request({
  134. url: apiCardUrlQuery,
  135. header: {
  136. "Content-Type": "application/x-www-form-urlencoded",
  137. "token": this.token,
  138. },
  139. method: "POST",
  140. data: {
  141. actId: this.actId,
  142. matchType: this.matchType
  143. },
  144. success: (res) => {
  145. // console.log("cardUrlQuery", res);
  146. if (res.data.code == 0) {
  147. const data = res.data.data;
  148. this.ecId = data.ecId;
  149. this.ecName = data.ecName;
  150. this.urlRs = data.urlRs;
  151. }
  152. },
  153. fail: (err) => {
  154. console.log("cardUrlQuery err", err);
  155. },
  156. });
  157. },
  158. btnRankList() {
  159. // console.log("urlRs", this.urlRs);
  160. // const rankListUrl = this.urlRs.find(item => item.name === 'rankListUrl');
  161. const rankListUrl = this.urlRs.rankListUrl;
  162. // console.log("rankListUrl", rankListUrl);
  163. if (rankListUrl != null) {
  164. let url = "";
  165. if (rankListUrl.indexOf('?') !== -1) {
  166. url = rankListUrl + '&token=' + this.token + '&id=' + this.ecId;
  167. } else {
  168. url = rankListUrl + '?token=' + this.token + '&id=' + this.ecId;
  169. }
  170. console.log("url", url);
  171. // uni.navigateTo({
  172. // url: url
  173. // });
  174. window.location.href = url;
  175. } else {
  176. uni.showToast({
  177. // title: '网址错误:' + rankListUrl,
  178. title: '请升级APP到最新版才能查看排行榜',
  179. icon: 'none',
  180. duration: 3000
  181. });
  182. }
  183. }
  184. }
  185. }
  186. </script>
  187. <style>
  188. .body {
  189. background-color: #2d2d2d;
  190. }
  191. .content {
  192. width: 750rpx;
  193. min-height: 100vh;
  194. display: flex;
  195. flex-direction: column;
  196. align-items: center;
  197. justify-content: flex-end;
  198. }
  199. .top {
  200. width: 100%;
  201. height: 70vh;
  202. background-image: url("static/yuedong/challenge/success_bg.png");
  203. background-repeat: no-repeat;
  204. background-position-x: center;
  205. background-position-y: top;
  206. background-size: 100% 100%;
  207. }
  208. .main {
  209. width: 100%;
  210. height: 30vh;
  211. flex-direction: column;
  212. justify-content: flex-start;
  213. align-items: center;
  214. }
  215. .main-content {
  216. display: flex;
  217. flex-direction: row;
  218. width: 100%;
  219. height: 400rpx;
  220. /* background-color: #b0352e; */
  221. background-image: url("/static/yuedong/challenge/rank_bg.png");
  222. background-repeat: no-repeat;
  223. background-position-x: center;
  224. background-position-y: center;
  225. background-size: 100% auto;
  226. }
  227. .rank {
  228. width: 220rpx;
  229. /* height: 500rpx; */
  230. margin-left: 60rpx;
  231. margin-top: 120rpx;
  232. }
  233. .namebox {
  234. width: 330rpx;
  235. }
  236. .name {
  237. width: 280rpx;
  238. /* 确保文本在一行内显示 */
  239. white-space: nowrap;
  240. /* 超出容器部分的文本隐藏起来 */
  241. overflow: hidden;
  242. /* 使用省略号表示被截断的文本 */
  243. /* text-overflow: ellipsis; */
  244. text-align: center;
  245. margin-top: 250rpx;
  246. margin-left: 20rpx;
  247. font-family: Source Han Sans CN;
  248. font-weight: 500;
  249. font-size: 32rpx;
  250. color: #ffffff;
  251. }
  252. .statistic {
  253. height: 30rpx;
  254. margin-bottom: 16rpx;
  255. flex-direction: row;
  256. align-items: center;
  257. justify-content: flex-start;
  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: 28rpx;
  267. color: #ffffff;
  268. }
  269. .statistic-value {
  270. font-family: Source Han Sans CN;
  271. font-size: 28rpx;
  272. color: #ffffff;
  273. font-weight: bold;
  274. }
  275. .statistic-unit {
  276. font-family: Source Han Sans CN;
  277. font-size: 25rpx;
  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>