rank.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452
  1. <!-- 薪资排行 -->
  2. <template>
  3. <view>
  4. <view class="contaier" style="background-color: #FFFFFF;">
  5. <!-- style="background: url(/static/rank/rank_bg.png) no-repeat;background-size: 750rpx;position: relative;" -->
  6. <view class="top_bg" :style="{backgroundImage: `url(${bgImage})`}">
  7. <view class="one_box">
  8. <!-- 第二名 -->
  9. <view class="top3">
  10. <view class="num_two">
  11. <image class="huangguan2" src="@/static/rank/two.png"></image>
  12. <image class="top3_head" :src="getGradeUserAvatar(second)"></image>
  13. <view class="top_name">{{getGradeUserName(second)}}</view>
  14. <view class="top_sy">得分:<span>{{second ? second.score : 0}}</span></view>
  15. <view class="top_sy">用时:<span v-if="second">{{second.grade_time|format_second(second.grade_time)}}</span><span v-else>0</span></view>
  16. </view>
  17. </view>
  18. <!-- 第一名 -->
  19. <view class="top3">
  20. <view class="num_one">
  21. <image class="huangguan1" src="@/static/rank/one.png"></image>
  22. <image class="top3_head" :src="getGradeUserAvatar(first)"></image>
  23. <view class="top_name text-bold" style="font-size: 30rpx;">{{getGradeUserName(first)}}</view>
  24. <view class="top_sy">得分:<span>{{first ? first.score : 0}}</span></view>
  25. <view class="top_sy">用时:<span v-if="first">{{first.grade_time|format_second(first.grade_time)}}</span><span v-else>0</span></view>
  26. </view>
  27. </view>
  28. <!-- 第三名 -->
  29. <view class="top3">
  30. <view class="num_three">
  31. <image class="huangguan2" src="@/static/rank/three.png"></image>
  32. <image class="top3_head" :src="getGradeUserAvatar(third)"></image>
  33. <view class="top_name">{{getGradeUserName(third)}}</view>
  34. <view class="top_sy">得分:<span>{{third ? third.score : 0}}</span></view>
  35. <view class="top_sy">用时:<span v-if="third">{{third.grade_time|format_second(third.grade_time)}}</span><span v-else>0</span></view>
  36. </view>
  37. </view>
  38. </view>
  39. <view class="number_sy_box">
  40. <view class="number_sy_box_title">
  41. <text>统计</text>
  42. <text style="position: absolute; right: 20rpx;z-index: 9999; font-size: 24rpx;color: #c3c3c3;">
  43. 截止:{{summary.cache_time}}
  44. </text>
  45. </view>
  46. <view class="number_sy_main">
  47. <view style="width: 50%; text-align: center; border-right: 1px solid #eee;">
  48. <view class="number_num1">{{summary.grade_count}}人</view>
  49. <view class="danwei">考试人数</view>
  50. </view>
  51. <view style="width: 50%; text-align: center; z-index: 9999;">
  52. <view class="number_num2">{{summary.pass_rate}}</view>
  53. <view class="danwei">及格率</view>
  54. </view>
  55. <!-- <image mode="widthFix" class="xiaoding_bg" src="@/static/rank/Intersect.png"></image> -->
  56. </view>
  57. </view>
  58. </view>
  59. <view class="rankList_box">
  60. <view class="rankItem" v-for="(item,index) in rankList" :key="index">
  61. <view class="rankIndex">
  62. <text>{{ index + 4 }}</text>
  63. </view>
  64. <view class="HeardBox">
  65. <image class="rankHeard" :src="item.user.avatar"></image>
  66. </view>
  67. <view class="NameBox">
  68. <!-- <view class="userName">{{item.name}}</view> -->
  69. <view class="userName text-bold">{{item.user.nickname}}</view>
  70. <view class="userPost text-gray"></view>
  71. <view class="color_ccc text-sm">
  72. 得分:<span>{{item.score}}</span>分 | 用时:<text class="text-blue">{{item.grade_time|format_second}}</text>
  73. </view>
  74. </view>
  75. <view class="download_box">
  76. <!-- <image mode="widthFix" src="@/static/rank/download.png"></image> -->
  77. </view>
  78. </view>
  79. <tui-no-data imgUrl="/static/img/img_noorder_3x.png" v-if="showNodata">暂无数据</tui-no-data>
  80. </view>
  81. <view class="">
  82. </view>
  83. </view>
  84. <!--流量主组件-->
  85. <kz-ad ref="adRank" kind="BANNER" :config="ad" field="rank_banner"></kz-ad>
  86. <kz-ad ref="adRank" kind="VIDEO" :config="ad" field="rank_video"></kz-ad>
  87. <kz-ad ref="adRank" kind="VIDEO_PATCH" :config="ad" field="rank_video_patch"></kz-ad>
  88. </view>
  89. </template>
  90. <script>
  91. import bgImage from "@/static/rank/rank_bg.png"
  92. export default {
  93. data() {
  94. return {
  95. bgImage: bgImage,
  96. paper_id: 0,
  97. nowTime: '',
  98. defaultAvatar: '/static/user/avatar.png',
  99. first: null,
  100. second: null,
  101. third: null,
  102. rankList: [
  103. ],
  104. summary: {},
  105. showNodata: false,
  106. ad: {}
  107. }
  108. },
  109. // computed: {
  110. // getGradeUserAvatar(grade) {
  111. // return grade?.user?.avatar ?? this.defaultAvatar
  112. // },
  113. // },
  114. onLoad(e) {
  115. this.ad = this.utils.getData('ad')
  116. console.log('ad data', this.ad)
  117. // 插屏广告
  118. if (this.ad.rank_cp_open == 1) {
  119. this.adUtils.interstitial.load(this.ad.rank_cp)
  120. this.adUtils.interstitial.show()
  121. }
  122. this.paper_id = e.paper_id
  123. this.getRank()
  124. this.getTime();
  125. },
  126. methods: {
  127. getRank() {
  128. // this.paper_id = 66
  129. this.http('grade/rank', {paper_id: this.paper_id}, 'post').then(res => {
  130. console.log('grade res', res)
  131. if (res.code == 0) {
  132. uni.showToast({
  133. title: res.msg,
  134. icon: 'none'
  135. })
  136. return
  137. } else {
  138. let list = res.data.list
  139. let getTop3 = (list) => {
  140. if (list?.length > 0) {
  141. return list.shift()
  142. }
  143. }
  144. this.first = getTop3(list)
  145. this.second = getTop3(list)
  146. this.third = getTop3(list)
  147. this.rankList = list
  148. this.summary = res.data.summary
  149. this.showNodata = list.length == 0
  150. }
  151. })
  152. },
  153. // 获取头像
  154. getGradeUserAvatar(grade) {
  155. let avatar = grade?.user?.avatar ?? this.defaultAvatar
  156. return avatar ? avatar : this.defaultAvatar
  157. },
  158. // 获取姓名
  159. getGradeUserName(grade) {
  160. return grade?.user?.nickname ?? '暂无'
  161. },
  162. getTime: function() {
  163. var date = new Date(),
  164. year = date.getFullYear(),
  165. month = date.getMonth() + 1,
  166. day = date.getDate(),
  167. hour = date.getHours() < 10 ? "0" + date.getHours() : date.getHours(),
  168. minute = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes(),
  169. second = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
  170. month >= 1 && month <= 9 ? (month = "0" + month) : "";
  171. day >= 0 && day <= 9 ? (day = "0" + day) : "";
  172. var timer = year + '-' + month + '-' + day + ' ' + hour + ':00';
  173. this.nowTime = timer
  174. console.log(this.nowTime);
  175. },
  176. },
  177. filters: {
  178. }
  179. }
  180. </script>
  181. <style lang="scss">
  182. .tui-nodata-fixed {
  183. top: 80% !important;
  184. }
  185. .top_bg {
  186. width: 750rpx;
  187. height: 650rpx;
  188. // background: url(@/static/rank/rank_bg.png) no-repeat;
  189. background-size: 750rpx;
  190. position: relative;
  191. margin-top: -50rpx;
  192. }
  193. .one_box {
  194. width: 750rpx;
  195. height: 260rpx;
  196. position: absolute;
  197. left: 0;
  198. bottom: 110rpx;
  199. display: flex;
  200. justify-content: space-around;
  201. }
  202. .one_box .top3 {
  203. width: 210rpx;
  204. height: 280rpx;
  205. }
  206. .top_name {
  207. width: 100%;
  208. height: 45rpx;
  209. // line-height: 60rpx;
  210. color: #f2f2f2;
  211. font-size: 26rpx;
  212. text-align: center;
  213. overflow: hidden;
  214. text-overflow: ellipsis;
  215. white-space: nowrap;
  216. }
  217. .top_sy {
  218. width: 100%;
  219. height: 40rpx;
  220. line-height: 40rpx;
  221. font-size: 24rpx;
  222. color: rgba(255, 255, 255, .7);
  223. text-align: center;
  224. overflow: hidden;
  225. text-overflow: ellipsis;
  226. white-space: nowrap;
  227. }
  228. .top_sy span {
  229. font-size: 20rpx !important;
  230. }
  231. .num_one {
  232. position: relative;
  233. }
  234. .huangguan1 {
  235. width: 60px;
  236. height: 60px;
  237. position: absolute;
  238. right: -10rpx;
  239. top: -18*2rpx;
  240. }
  241. .num_one .top3_head {
  242. width: 150rpx;
  243. height: 150rpx;
  244. border-radius: 100%;
  245. margin: 15rpx 0 0 30rpx;
  246. border: 4rpx solid #ffdd3c;
  247. }
  248. .num_two {
  249. position: relative;
  250. }
  251. .huangguan2 {
  252. width: 100rpx;
  253. height: 100rpx;
  254. position: absolute;
  255. right: 15rpx;
  256. }
  257. .num_two .top3_head {
  258. width: 120rpx;
  259. height: 120rpx;
  260. border-radius: 100%;
  261. margin: 45rpx 0 0 45rpx;
  262. border: 4rpx solid #bcdcdf;
  263. }
  264. .num_three {
  265. position: relative;
  266. }
  267. .huangguan2 {
  268. width: 100rpx;
  269. height: 100rpx;
  270. position: absolute;
  271. right: 15rpx;
  272. }
  273. .num_three .top3_head {
  274. width: 120rpx;
  275. height: 120rpx;
  276. border-radius: 100%;
  277. margin: 45rpx 0 0 45rpx;
  278. border: 4rpx solid #e29d85;
  279. }
  280. // 第二块
  281. .number_sy_box {
  282. width: 700rpx;
  283. height: 210rpx;
  284. background-color: #FFFFFF;
  285. position: absolute;
  286. left: 25rpx;
  287. border-radius: 20rpx;
  288. bottom: -140rpx;
  289. z-index: 999;
  290. padding: 22rpx;
  291. box-shadow: 3px 3px 15px 3px rgba(0, 0, 0, 0.1)
  292. }
  293. .number_sy_box_title {
  294. color: #888888;
  295. // font-weight: 500;
  296. font-size: 28rpx;
  297. display: flex;
  298. z-index: 9999;
  299. justify-content: space-between;
  300. }
  301. .number_sy_main {
  302. width: 100%;
  303. height: 124rpx;
  304. padding-top: 20rpx;
  305. line-height: 52rpx;
  306. // background: red;
  307. display: flex;
  308. justify-content: space-around;
  309. position: relative;
  310. }
  311. .xiaoding_bg {
  312. position: absolute;
  313. right: -22rpx;
  314. bottom: -30rpx;
  315. width: 180rpx;
  316. }
  317. .number_num1 {
  318. font-size: 40rpx;
  319. font-weight: 500;
  320. color: #2fc04f;
  321. }
  322. .number_num2 {
  323. font-size: 40rpx;
  324. font-weight: 500;
  325. color: #4bac7f;
  326. }
  327. .danwei {
  328. height: 60rpx;
  329. line-height: 60rpx;
  330. font-size: 26rpx;
  331. color: #c9c9c9;
  332. }
  333. // 列表
  334. .rankList_box {
  335. width: 750rpx;
  336. min-height: 420rpx;
  337. margin-top: 160rpx;
  338. }
  339. .rankItem:last-child {
  340. border: none;
  341. }
  342. .rankItem {
  343. width: 700rpx;
  344. height: 140rpx;
  345. margin: 0px auto;
  346. border-bottom: 1px solid #e9e9e9;
  347. }
  348. .rankIndex {
  349. width: 60rpx;
  350. height: 140rpx;
  351. line-height: 140rpx;
  352. text-align: center;
  353. color: #CCCCCC;
  354. font-size: 40rpx;
  355. float: left;
  356. }
  357. .HeardBox {
  358. width: 100rpx;
  359. height: 100rpx;
  360. margin: 20rpx;
  361. border-radius: 100%;
  362. overflow: hidden;
  363. float: left;
  364. margin-right: 25rpx;
  365. margin-left: 10rpx !important;
  366. }
  367. .HeardBox image {
  368. width: 100%;
  369. height: 100%;
  370. }
  371. .NameBox {
  372. width: 400rpx;
  373. height: 140rpx;
  374. float: left;
  375. padding-top: 10rpx;
  376. box-sizing: border-box;
  377. }
  378. .NameBox view {
  379. height: 50rpx;
  380. line-height: 70rpx;
  381. }
  382. .userName {
  383. min-width: 90rpx;
  384. font-size: 30rpx;
  385. float: left;
  386. margin-right: 20rpx;
  387. }
  388. .download_box {
  389. width: 80rpx;
  390. height: 140rpx;
  391. // background-color: red;
  392. float: right;
  393. }
  394. .download_box image {
  395. width: 45rpx;
  396. margin: 50rpx auto;
  397. display: block;
  398. }
  399. </style>