success.uvue 9.5 KB

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