success.uvue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. <template>
  2. <view class="body">
  3. <view class="content">
  4. <view class="top">
  5. <image class="logo" mode="aspectFit" src="/static/logo.png"></image>
  6. <image class="right-logo" mode="aspectFit" src="/static/40.png"></image>
  7. </view>
  8. <view class="main">
  9. <view class="main-content">
  10. <view class="rank">
  11. <view class="statistic">
  12. <text class="statistic-title">总用时:</text>
  13. <view class="statistic-right">
  14. <text class="statistic-value">{{durationMin}}</text><text
  15. class="statistic-unit">min</text>
  16. </view>
  17. </view>
  18. <view class="statistic">
  19. <text class="statistic-title">总里程:</text>
  20. <view class="statistic-right">
  21. <text class="statistic-value">{{distanceKm}}</text><text
  22. class="statistic-unit">Km</text>
  23. </view>
  24. </view>
  25. <view class="statistic">
  26. <text class="statistic-title">脑力值:</text>
  27. <view class="statistic-right">
  28. <text class="statistic-value">{{accuracy}}</text><text class="statistic-unit">%</text>
  29. </view>
  30. </view>
  31. </view>
  32. <text class="name">{{nameSub}}</text>
  33. </view>
  34. </view>
  35. <!-- <view class="bottom">
  36. <view class="bottom-left">
  37. <image src="../../static/medal.webp" class="medal" mode="aspectFit"></image>
  38. <text class="medal_count">x{{syscount}}</text>
  39. </view>
  40. <view class="bottom-right">
  41. <text class="bottom-text">提示:</text>
  42. <text class="bottom-text">可以在“成就”中查看详细数据</text>
  43. </view>
  44. </view> -->
  45. </view>
  46. <my-fab></my-fab>
  47. </view>
  48. </template>
  49. <script>
  50. import tools from '../../common/tools';
  51. export default {
  52. data() {
  53. return {
  54. status: "", // success: 挑战成功, ok: 挑战完成(没在规定时间完成,但打了所有点), fail: 挑战结束
  55. name: "", // 用户名
  56. duration: 0, // 总用时,秒
  57. distance: 0, // 总里程,米
  58. cal: 0, // 卡路里,卡 int
  59. accuracy: 0, // 脑力值百分比
  60. syscount: 0 // 点数
  61. }
  62. },
  63. computed: {
  64. nameSub() {
  65. const maxlen = 8;
  66. const nameLen = tools.calStrLen(this.name);
  67. console.log('nameLen', nameLen);
  68. if (nameLen <= 6) {
  69. return '选手: ' + this.name;
  70. }
  71. // else if (nameLen >= maxlen) {
  72. // return this.name.substring(0,maxlen-1) + '...';
  73. // }
  74. else {
  75. return this.name;
  76. }
  77. },
  78. durationMin() {
  79. return Math.round(this.duration * 10 / 60) / 10;
  80. },
  81. distanceKm() {
  82. return Math.round(this.distance * 10 / 1000) / 10;
  83. }
  84. },
  85. onLoad(event) { // 类型非必填,可自动推导
  86. console.log('[challenge result] onLoad');
  87. this.status = event["status"] ?? "";
  88. this.name = event["name"] ?? "";
  89. this.duration = event["duration"] ?? 0;
  90. this.distance = event["distance"] ?? 0;
  91. this.cal = event["cal"] ?? 0;
  92. this.accuracy = event["accuracy"] ?? 0;
  93. this.syscount = event["syscount"] ?? 0;
  94. },
  95. methods: {
  96. }
  97. }
  98. </script>
  99. <style>
  100. .body {
  101. display: flex;
  102. flex-direction: column;
  103. align-items: center;
  104. justify-content: center;
  105. }
  106. .content {
  107. width: 750rpx;
  108. /* margin: 0 auto; */
  109. }
  110. .top {
  111. width: 100%;
  112. height: 10vh;
  113. padding: 0 60rpx;
  114. flex-direction: row;
  115. align-items: center;
  116. justify-content: space-between;
  117. }
  118. .logo {
  119. width: 183rpx;
  120. height: 52rpx;
  121. }
  122. .right-logo {
  123. width: 75rpx;
  124. height: 52rpx;
  125. }
  126. .main {
  127. width: 100%;
  128. flex-direction: column;
  129. justify-content: flex-start;
  130. }
  131. .main-content {
  132. /* width: 100%; */
  133. /* height: 570px; */
  134. margin-top: 25rpx;
  135. margin-bottom: 10rpx;
  136. height: 1100rpx;
  137. background-image: url("/static/challenge/success_bg.webp");
  138. background-repeat: no-repeat;
  139. background-position-x: center;
  140. background-position-y: top;
  141. background-size: contain;
  142. }
  143. .rank {
  144. width: 530rpx;
  145. margin-left: 100rpx;
  146. margin-top: 748rpx;
  147. }
  148. .name {
  149. width: 246rpx;
  150. /* 确保文本在一行内显示 */
  151. white-space: nowrap;
  152. /* 超出容器部分的文本隐藏起来 */
  153. overflow: hidden;
  154. /* 使用省略号表示被截断的文本 */
  155. /* text-overflow: ellipsis; */
  156. text-align: center;
  157. margin-left: 196rpx;
  158. margin-top: 36rpx;
  159. font-family: Source Han Sans CN;
  160. font-weight: 500;
  161. font-size: 36rpx;
  162. color: #ffffff;
  163. }
  164. .statistic {
  165. height: 73.9rpx;
  166. flex-direction: row;
  167. align-items: center;
  168. justify-content: space-between;
  169. }
  170. .statistic-right {
  171. flex-direction: row;
  172. align-items: baseline;
  173. }
  174. .statistic-title {
  175. font-family: Source Han Sans CN;
  176. font-weight: 500;
  177. font-size: 46rpx;
  178. color: #ffffff;
  179. }
  180. .statistic-value {
  181. font-family: Source Han Sans CN;
  182. font-weight: 700;
  183. font-size: 56rpx;
  184. color: #ffffff;
  185. font-weight: bold;
  186. }
  187. .statistic-unit {
  188. font-family: Source Han Sans CN;
  189. font-size: 40rpx;
  190. color: #ffffff;
  191. padding-left: 10rpx;
  192. }
  193. /* .bottom {
  194. width: 100%;
  195. flex-direction: row;
  196. justify-content: space-between;
  197. padding: 30px 30px 30px 30px;
  198. }
  199. .bottom-left {
  200. flex-direction: row;
  201. justify-content: flex-start;
  202. }
  203. .bottom-right {
  204. width: 116px;
  205. flex-direction: column;
  206. justify-content: center;
  207. }
  208. .medal {
  209. width: 78px;
  210. height: 81px;
  211. margin-right: 10px;
  212. }
  213. .medal_count {
  214. font-family: Source Han Sans CN;
  215. font-weight: 900;
  216. color: #ffee29;
  217. font-size: 50px;
  218. margin-top: 10px;
  219. }
  220. .bottom-text {
  221. line-height: normal;
  222. font-family: Source Han Sans CN;
  223. font-weight: 500;
  224. font-size: 12px;
  225. color: #ffffff;
  226. } */
  227. </style>