success.uvue 9.9 KB

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