rank.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454
  1. <!-- 薪资排行 -->
  2. <template>
  3. <view>
  4. <view class="contaier" style="background-color: #FFFFFF;">
  5. <view class="top_bg" :style="{backgroundImage: `url(${bgImage})`}" 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. room_id: 0,
  97. paper_id: 0,
  98. nowTime: '',
  99. defaultAvatar: '/static/user/avatar.png',
  100. first: null,
  101. second: null,
  102. third: null,
  103. rankList: [
  104. ],
  105. summary: {},
  106. showNodata: false,
  107. ad: {}
  108. }
  109. },
  110. // computed: {
  111. // getGradeUserAvatar(grade) {
  112. // return grade?.user?.avatar ?? this.defaultAvatar
  113. // },
  114. // },
  115. onLoad(e) {
  116. this.ad = this.utils.getData('ad')
  117. console.log('ad data', this.ad)
  118. // 插屏广告
  119. if (this.ad.rank_cp_open == 1) {
  120. this.adUtils.interstitial.load(this.ad.rank_cp)
  121. this.adUtils.interstitial.show()
  122. }
  123. this.room_id = e.room_id
  124. this.paper_id = e.paper_id
  125. this.getRank()
  126. this.getTime();
  127. },
  128. methods: {
  129. getRank() {
  130. // this.paper_id = 66
  131. this.http('room_grade/rank', {room_id: this.room_id,paper_id: this.paper_id}, 'post').then(res => {
  132. console.log('room_grade res', res)
  133. if (res.code == 0) {
  134. uni.showToast({
  135. title: res.msg,
  136. icon: 'none'
  137. })
  138. return
  139. } else {
  140. let list = res.data.list
  141. let getTop3 = (list) => {
  142. if (list?.length > 0) {
  143. return list.shift()
  144. }
  145. }
  146. this.first = getTop3(list)
  147. this.second = getTop3(list)
  148. this.third = getTop3(list)
  149. this.rankList = list
  150. this.summary = res.data.summary
  151. this.showNodata = list.length == 0
  152. }
  153. })
  154. },
  155. // 获取头像
  156. getGradeUserAvatar(grade) {
  157. let avatar = grade?.user?.avatar ?? this.defaultAvatar
  158. return avatar ? avatar : this.defaultAvatar
  159. },
  160. // 获取姓名
  161. getGradeUserName(grade) {
  162. return grade?.user?.nickname ?? '暂无'
  163. },
  164. getTime: function() {
  165. var date = new Date(),
  166. year = date.getFullYear(),
  167. month = date.getMonth() + 1,
  168. day = date.getDate(),
  169. hour = date.getHours() < 10 ? "0" + date.getHours() : date.getHours(),
  170. minute = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes(),
  171. second = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
  172. month >= 1 && month <= 9 ? (month = "0" + month) : "";
  173. day >= 0 && day <= 9 ? (day = "0" + day) : "";
  174. var timer = year + '-' + month + '-' + day + ' ' + hour + ':00';
  175. this.nowTime = timer
  176. console.log(this.nowTime);
  177. },
  178. },
  179. filters: {
  180. }
  181. }
  182. </script>
  183. <style lang="scss">
  184. .tui-nodata-fixed {
  185. top: 80% !important;
  186. }
  187. .top_bg {
  188. width: 750rpx;
  189. height: 650rpx;
  190. // background: url(@/static/rank/rank_bg.png) no-repeat;
  191. // background-size: 750rpx;
  192. // position: relative;
  193. margin-top: -50rpx;
  194. }
  195. .one_box {
  196. width: 750rpx;
  197. height: 260rpx;
  198. position: absolute;
  199. left: 0;
  200. bottom: 110rpx;
  201. display: flex;
  202. justify-content: space-around;
  203. }
  204. .one_box .top3 {
  205. width: 210rpx;
  206. height: 280rpx;
  207. }
  208. .top_name {
  209. width: 100%;
  210. height: 45rpx;
  211. // line-height: 60rpx;
  212. color: #f2f2f2;
  213. font-size: 26rpx;
  214. text-align: center;
  215. overflow: hidden;
  216. text-overflow: ellipsis;
  217. white-space: nowrap;
  218. }
  219. .top_sy {
  220. width: 100%;
  221. height: 40rpx;
  222. line-height: 40rpx;
  223. font-size: 24rpx;
  224. color: rgba(255, 255, 255, .7);
  225. text-align: center;
  226. overflow: hidden;
  227. text-overflow: ellipsis;
  228. white-space: nowrap;
  229. }
  230. .top_sy span {
  231. font-size: 20rpx !important;
  232. }
  233. .num_one {
  234. position: relative;
  235. }
  236. .huangguan1 {
  237. width: 60px;
  238. height: 60px;
  239. position: absolute;
  240. right: -10rpx;
  241. top: -18*2rpx;
  242. }
  243. .num_one .top3_head {
  244. width: 150rpx;
  245. height: 150rpx;
  246. border-radius: 100%;
  247. margin: 15rpx 0 0 30rpx;
  248. border: 4rpx solid #ffdd3c;
  249. }
  250. .num_two {
  251. position: relative;
  252. }
  253. .huangguan2 {
  254. width: 100rpx;
  255. height: 100rpx;
  256. position: absolute;
  257. right: 15rpx;
  258. }
  259. .num_two .top3_head {
  260. width: 120rpx;
  261. height: 120rpx;
  262. border-radius: 100%;
  263. margin: 45rpx 0 0 45rpx;
  264. border: 4rpx solid #bcdcdf;
  265. }
  266. .num_three {
  267. position: relative;
  268. }
  269. .huangguan2 {
  270. width: 100rpx;
  271. height: 100rpx;
  272. position: absolute;
  273. right: 15rpx;
  274. }
  275. .num_three .top3_head {
  276. width: 120rpx;
  277. height: 120rpx;
  278. border-radius: 100%;
  279. margin: 45rpx 0 0 45rpx;
  280. border: 4rpx solid #e29d85;
  281. }
  282. // 第二块
  283. .number_sy_box {
  284. width: 700rpx;
  285. height: 210rpx;
  286. background-color: #FFFFFF;
  287. position: absolute;
  288. left: 25rpx;
  289. border-radius: 20rpx;
  290. bottom: -140rpx;
  291. z-index: 999;
  292. padding: 22rpx;
  293. box-shadow: 3px 3px 15px 3px rgba(0, 0, 0, 0.1)
  294. }
  295. .number_sy_box_title {
  296. color: #888888;
  297. // font-weight: 500;
  298. font-size: 28rpx;
  299. display: flex;
  300. z-index: 9999;
  301. justify-content: space-between;
  302. }
  303. .number_sy_main {
  304. width: 100%;
  305. height: 124rpx;
  306. padding-top: 20rpx;
  307. line-height: 52rpx;
  308. // background: red;
  309. display: flex;
  310. justify-content: space-around;
  311. position: relative;
  312. }
  313. .xiaoding_bg {
  314. position: absolute;
  315. right: -22rpx;
  316. bottom: -30rpx;
  317. width: 180rpx;
  318. }
  319. .number_num1 {
  320. font-size: 40rpx;
  321. font-weight: 500;
  322. color: #2fc04f;
  323. }
  324. .number_num2 {
  325. font-size: 40rpx;
  326. font-weight: 500;
  327. color: #4bac7f;
  328. }
  329. .danwei {
  330. height: 60rpx;
  331. line-height: 60rpx;
  332. font-size: 26rpx;
  333. color: #c9c9c9;
  334. }
  335. // 列表
  336. .rankList_box {
  337. width: 750rpx;
  338. min-height: 420rpx;
  339. margin-top: 160rpx;
  340. }
  341. .rankItem:last-child {
  342. border: none;
  343. }
  344. .rankItem {
  345. width: 700rpx;
  346. height: 140rpx;
  347. margin: 0px auto;
  348. border-bottom: 1px solid #e9e9e9;
  349. }
  350. .rankIndex {
  351. width: 60rpx;
  352. height: 140rpx;
  353. line-height: 140rpx;
  354. text-align: center;
  355. color: #CCCCCC;
  356. font-size: 40rpx;
  357. float: left;
  358. }
  359. .HeardBox {
  360. width: 100rpx;
  361. height: 100rpx;
  362. margin: 20rpx;
  363. border-radius: 100%;
  364. overflow: hidden;
  365. float: left;
  366. margin-right: 25rpx;
  367. margin-left: 10rpx !important;
  368. }
  369. .HeardBox image {
  370. width: 100%;
  371. height: 100%;
  372. }
  373. .NameBox {
  374. width: 400rpx;
  375. height: 140rpx;
  376. float: left;
  377. padding-top: 10rpx;
  378. box-sizing: border-box;
  379. }
  380. .NameBox view {
  381. height: 50rpx;
  382. line-height: 70rpx;
  383. }
  384. .userName {
  385. min-width: 90rpx;
  386. font-size: 30rpx;
  387. float: left;
  388. margin-right: 20rpx;
  389. }
  390. .download_box {
  391. width: 80rpx;
  392. height: 140rpx;
  393. // background-color: red;
  394. float: right;
  395. }
  396. .download_box image {
  397. width: 45rpx;
  398. margin: 50rpx auto;
  399. display: block;
  400. }
  401. </style>