success.uvue 10 KB

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