success.uvue 9.3 KB

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