index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636
  1. <template>
  2. <view class="content">
  3. <view class="list-box" v-if="userInfo.user_type==2">
  4. <view class="list-item" v-for="(item,index) in list"
  5. @click="navTo('/pages/index/main?id='+item.id+'&pid='+project_id)">
  6. <view class="list-bg">
  7. <image :src="baseURL + item.backgroundimage" mode=""></image>
  8. </view>
  9. <image class="list-icon" :src="baseURL+item.iocnimage" mode=""></image>
  10. <view class="list-name">
  11. {{item.name}}
  12. </view>
  13. </view>
  14. </view>
  15. <view v-else>
  16. <view class="top">
  17. <view class="top-bg">
  18. <image src="../../static/img/top.png" mode=""></image>
  19. </view>
  20. <view class="top-box">
  21. <view class="top-item" v-for="(item,index) in list" @click="tabClick(index)">
  22. <view class="top-main">
  23. <image v-if="tabCurrentIndex == index" class="top-icon" :src="baseURL + item.iconimage"
  24. mode="">
  25. </image>
  26. <image v-if="tabCurrentIndex != index" class="top-icon" :src="baseURL + item.icon2image"
  27. mode="">
  28. </image>
  29. <view class="top-name" :class="{curret:tabCurrentIndex==index}">
  30. {{item.name}}
  31. </view>
  32. </view>
  33. <image class="jt" v-if="index != list.length -1" src="../../static/img/jt.png" mode=""></image>
  34. </view>
  35. </view>
  36. <swiper :current="tabCurrentIndex" :style="{ height: height }" class="swiper-box" duration="300"
  37. @change="changeTab">
  38. <swiper-item class="tab-content" v-for="(tabItem, tabIndex) in list" :key="tabIndex">
  39. <scroll-view scroll-y="true" style="height: 100%;">
  40. <view class="student-box flex">
  41. <view class="student-left">
  42. <view class="shu">
  43. </view>
  44. <view class="student-name">
  45. 组: <text>{{dquser.group}}</text>
  46. </view>
  47. </view>
  48. <view class="student-right" @click="qh()">
  49. <view class="student-qh">
  50. 切换
  51. </view>
  52. <image class="student-back" src="../../static/icon/back.png" mode=""></image>
  53. </view>
  54. </view>
  55. <view class="step" v-for="(item,index) in tabItem.item" :key="index">
  56. <view class="step-top">
  57. <view class="shu"></view>
  58. <view class="step-title">{{item.name}}</view>
  59. </view>
  60. <view class="step-main flex">
  61. <view class="step-left">分数(共{{item.max_score}}分)</view>
  62. <view class="step-right">
  63. <input class="step-input" type="digit" v-model="item.score"
  64. :max="item.max_score*1" placeholder-class="place" placeholder="请输入分数">
  65. <view class="step-font">分</view>
  66. </view>
  67. </view>
  68. <view class="step-info" v-if="item.info">
  69. <view class="set-info-title">说明:</view>
  70. <view class="set-info-mian">{{item.info}}</view>
  71. </view>
  72. </view>
  73. <view class="btn" @click="tj(tabItem)">
  74. 确认提交
  75. </view>
  76. <view style="height:50px;">
  77. </view>
  78. </scroll-view>
  79. </swiper-item>
  80. </swiper>
  81. </view>
  82. <uni-popup ref="student" type="bottom">
  83. <view class="popup-box">
  84. <view class="popup-title flex">
  85. <view class="qx" @click="cancel">取消</view>
  86. <view class="qd" @click="cancel">确定</view>
  87. </view>
  88. <view class="popup">
  89. <scroll-view class="popup-right" scroll-y="true">
  90. <view v-for="(item,index) in userlist" :key="index" class="popup-right-item"
  91. :class="{currRight:item.id==dquser.id}" @click="changepeople(item,index)">
  92. {{item.group}}
  93. </view>
  94. <view class="bottom" style="height: 50px"></view>
  95. </scroll-view>
  96. </view>
  97. </view>
  98. </uni-popup>
  99. <!-- 111 -->
  100. </view>
  101. </view>
  102. </template>
  103. <script>
  104. import {
  105. mapState,
  106. mapMutations
  107. } from 'vuex';
  108. import * as mTabbar from '@/components/m-tabbar/m-tabbar.vue'
  109. import {
  110. getproject,
  111. new_project,
  112. misssion,
  113. user_list,
  114. score
  115. } from '@/api/project.js'
  116. export default {
  117. data() {
  118. return {
  119. id: '',
  120. list: [],
  121. userlist: [],
  122. height: '',
  123. dquser: '',
  124. dqdjg: '',
  125. tabCurrentIndex: 0,
  126. project_id: '',
  127. };
  128. },
  129. computed: {
  130. ...mapState('user', ['userInfo', 'hasLogin', 'urlFile']),
  131. ...mapState(['baseURL'])
  132. },
  133. onLoad() {},
  134. onShow() {
  135. if (this.userInfo.user_type != 2) {
  136. uni.setTabBarItem({
  137. index: 1,
  138. "pagePath": "pages/user/grade",
  139. "iconPath": "../../static/tabbar/tab-grade.png",
  140. "selectedIconPath": "../../static/tabbar/tab-grade-current.png",
  141. "text": "我的成绩",
  142. "visible": true
  143. });
  144. } else {
  145. uni.setTabBarItem({
  146. index: 1,
  147. "pagePath": "pages/user/grade",
  148. "iconPath": "../../static/tabbar/tab-grade.png",
  149. "selectedIconPath": "../../static/tabbar/tab-grade-current.png",
  150. "text": "我的成绩",
  151. "visible": false
  152. });
  153. }
  154. this.loadData()
  155. },
  156. onReachBottom() {},
  157. onReady(res) {
  158. var _this = this;
  159. uni.getSystemInfo({
  160. success: resu => {
  161. const query = uni.createSelectorQuery();
  162. query.select('.swiper-box').boundingClientRect();
  163. query.exec(function(res) {
  164. _this.height = resu.windowHeight - res[0].top + 'px';
  165. console.log('打印页面的剩余高度', _this.height);
  166. });
  167. },
  168. fail: res => {}
  169. });
  170. },
  171. methods: {
  172. loadData() {
  173. const obj = this
  174. new_project({}).then(er => {
  175. if (!er.data.new) {
  176. this.$api.msg('暂无考试')
  177. }
  178. getproject({}, er.data.new.id).then(({
  179. data
  180. }) => {
  181. this.project_id = data.id;
  182. console.log(data);
  183. if (this.userInfo.user_type == 2) {
  184. this.list = data.mission
  185. } else {
  186. data.mission.forEach(e => {
  187. misssion({}, e.id, obj.userInfo.group_id, obj.project_id).then(
  188. er => {
  189. if (er.data.step.length != 0) {
  190. obj.id = er.data.id
  191. console.log(obj.id);
  192. obj.studentpf()
  193. }
  194. })
  195. console.log(e);
  196. })
  197. }
  198. })
  199. })
  200. },
  201. qh() {
  202. this.$refs.student.open()
  203. },
  204. cancel() {
  205. this.$refs.student.close()
  206. },
  207. studentpf() {
  208. user_list({}).then(({
  209. data
  210. }) => {
  211. if (data.length == 0) {
  212. return this.$api.msg('暂无组员')
  213. }
  214. this.dquser = data[0]
  215. this.dqdjg = 0
  216. this.userlist = data
  217. this.getproject()
  218. })
  219. },
  220. changepeople(item, index) {
  221. this.dquser = item
  222. this.dqdjg = index
  223. this.cancel()
  224. this.getproject()
  225. },
  226. //swiper 切换
  227. changeTab(e) {
  228. this.tabCurrentIndex = e.detail.current;
  229. },
  230. //顶部tab点击
  231. tabClick(index) {
  232. this.tabCurrentIndex = index * 1;
  233. console.log(index == this.tabCurrentIndex);
  234. },
  235. getproject() {
  236. uni.showLoading({
  237. title: '加载中'
  238. })
  239. misssion({}, this.id, this.dquser.id, this.project_id).then(({
  240. data
  241. }) => {
  242. uni.hideLoading()
  243. this.list = data.step
  244. })
  245. },
  246. next() {
  247. const obj = this
  248. obj.dqdjg++
  249. if (obj.dqdjg >= this.userlist.length) {
  250. uni.showModal({
  251. title: '提示',
  252. content: '当前关的全部组已全部评完',
  253. success: function(res) {
  254. if (res.confirm) {
  255. uni.switchTab({
  256. url: '/pages/index/index'
  257. })
  258. } else if (res.cancel) {}
  259. }
  260. })
  261. } else {
  262. console.log(obj.dqdjg);
  263. obj.$api.msg('当前组已评价,切换到下一个')
  264. obj.dquser = obj.userlist[obj.dqdjg]
  265. this.tabCurrentIndex = 0
  266. this.getproject()
  267. }
  268. },
  269. tj(opt) {
  270. const obj = this
  271. let isok = 0;
  272. try {
  273. opt.item.forEach(e => {
  274. if (!e.score) {
  275. obj.$api.msg('请输入' + e.name + '的分数')
  276. isok = 1
  277. throw Error()
  278. }
  279. if (e.score * 1 > e.max_score) {
  280. obj.$api.msg(e.name + '的最大分数为' + e.max_score + ',请不要超过这个分数')
  281. isok = 1
  282. throw Error()
  283. }
  284. score({
  285. score: e.score
  286. }, e.id, obj.dquser.id, obj.project_id).then(e => {})
  287. })
  288. if (isok == 1) {
  289. throw Error()
  290. } else {
  291. obj.$api.msg('该组已评价完成')
  292. // if (obj.tabCurrentIndex != obj.list.length - 1 && isok == 0) {
  293. // obj.tabCurrentIndex++
  294. // } else {
  295. // obj.next()
  296. // }
  297. }
  298. } catch (e) {
  299. //TODO handle the exception
  300. }
  301. },
  302. navTo(url) {
  303. uni.navigateTo({
  304. url,
  305. })
  306. }
  307. }
  308. };
  309. </script>
  310. <style lang="scss">
  311. page,
  312. .content {
  313. min-height: 100%;
  314. height: auto;
  315. }
  316. .list-item {
  317. width: 700rpx;
  318. margin: 30rpx auto;
  319. position: relative;
  320. padding: 40rpx 40rpx;
  321. display: flex;
  322. align-items: center;
  323. .list-bg {
  324. position: absolute;
  325. top: 0;
  326. left: 0;
  327. right: 0;
  328. width: 100%;
  329. height: 100%;
  330. image {
  331. width: 100%;
  332. height: 100%;
  333. }
  334. }
  335. .list-icon {
  336. width: 112rpx;
  337. height: 112rpx;
  338. border-radius: 24rpx;
  339. }
  340. .list-name {
  341. position: relative;
  342. z-index: 2;
  343. margin-left: 40rpx;
  344. font-size: 36rpx;
  345. font-family: Source Han Sans CN;
  346. font-weight: bold;
  347. color: #FFFFFF;
  348. }
  349. }
  350. .top {
  351. width: 750rpx;
  352. height: 300rpx;
  353. position: relative;
  354. .top-bg {
  355. width: 750rpx;
  356. height: 300rpx;
  357. position: absolute;
  358. top: 0;
  359. left: 0;
  360. right: 0;
  361. image {
  362. width: 100%;
  363. height: 100%;
  364. }
  365. }
  366. .top-box {
  367. padding-top: 44rpx;
  368. display: flex;
  369. justify-content: center;
  370. align-items: center;
  371. .top-item {
  372. display: flex;
  373. .top-main {
  374. margin: 0 10rpx;
  375. display: flex;
  376. flex-direction: column;
  377. align-items: center;
  378. .top-icon {
  379. width: 80rpx;
  380. height: 80rpx;
  381. background: #FFFFFF;
  382. border-radius: 50%;
  383. }
  384. .top-name {
  385. position: relative;
  386. z-index: 2;
  387. margin-top: 16rpx;
  388. font-size: 24rpx;
  389. font-family: PingFang SC;
  390. font-weight: 500;
  391. color: rgba(#ffffff, 0.7);
  392. }
  393. .curret {
  394. font-weight: bold;
  395. color: #2A9CEC;
  396. -webkit-text-stroke: 1rpx #FFFFFF;
  397. text-stroke: 1rpx #FFFFFF;
  398. }
  399. }
  400. .jt {
  401. margin-top: 40rpx;
  402. width: 38rpx;
  403. height: 22rpx;
  404. }
  405. }
  406. }
  407. }
  408. .student-box {
  409. margin: 34rpx auto 0;
  410. width: 698rpx;
  411. background: #FFFFFF;
  412. box-shadow: 0px 6rpx 12rpx 1rpx rgba(101, 101, 101, 0.06);
  413. border-radius: 28rpx;
  414. padding: 28rpx 22rpx;
  415. .student-left {
  416. display: flex;
  417. align-items: center;
  418. .shu {
  419. width: 6rpx;
  420. height: 30rpx;
  421. background: #F9A81B;
  422. border-radius: 3rpx;
  423. }
  424. .student-name {
  425. margin-left: 16rpx;
  426. font-size: 30rpx;
  427. font-family: PingFang SC;
  428. font-weight: bold;
  429. color: #000000;
  430. text {
  431. color: #40547E;
  432. }
  433. }
  434. }
  435. .student-right {
  436. display: flex;
  437. align-items: center;
  438. .student-qh {
  439. font-size: 26rpx;
  440. font-family: PingFang SC;
  441. font-weight: 500;
  442. color: #666666;
  443. margin-right: 10rpx;
  444. }
  445. .student-back {
  446. width: 12rpx;
  447. height: 23rpx;
  448. }
  449. }
  450. }
  451. .step {
  452. margin: 34rpx auto 0;
  453. width: 698rpx;
  454. background: #FFFFFF;
  455. box-shadow: 0px 6rpx 12rpx 1rpx rgba(101, 101, 101, 0.06);
  456. border-radius: 20rpx;
  457. padding: 28rpx 22rpx;
  458. .step-top {
  459. display: flex;
  460. align-items: center;
  461. .shu {
  462. width: 6rpx;
  463. height: 30rpx;
  464. background: #F9A81B;
  465. border-radius: 3rpx;
  466. }
  467. .step-title {
  468. margin-left: 16rpx;
  469. font-size: 30rpx;
  470. font-family: PingFang SC;
  471. font-weight: bold;
  472. color: #000000;
  473. }
  474. }
  475. .step-main {
  476. padding: 50rpx 20rpx 32rpx;
  477. line-height: 1;
  478. .step-left {
  479. font-size: 28rpx;
  480. font-family: PingFang SC;
  481. font-weight: 500;
  482. color: #666666;
  483. }
  484. .step-right {
  485. display: flex;
  486. align-items: center;
  487. .step-input {
  488. text-align: right;
  489. font-size: 32rpx;
  490. font-family: PingFang SC;
  491. font-weight: bold;
  492. color: #FF4C4C;
  493. }
  494. .place {
  495. line-height: 1;
  496. font-size: 28rpx;
  497. font-family: PingFang SC;
  498. font-weight: bold;
  499. color: #999999;
  500. }
  501. .step-font {
  502. margin-left: 10rpx;
  503. font-size: 28rpx;
  504. font-family: PingFang SC;
  505. font-weight: bold;
  506. color: #000000;
  507. }
  508. }
  509. }
  510. .step-info {
  511. margin-right: 20rpx;
  512. border-top: 1px solid #ECECEC;
  513. padding: 32rpx 20rpx 0;
  514. display: flex;
  515. align-items: flex-start;
  516. .set-info-title {
  517. width: 80rpx;
  518. flex-shrink: 0;
  519. margin-right: 10rpx;
  520. font-size: 24rpx;
  521. font-family: PingFang SC;
  522. font-weight: 500;
  523. color: #666666;
  524. line-height: 41rpx;
  525. }
  526. .set-info-mian {
  527. font-size: 24rpx;
  528. font-family: PingFang SC;
  529. font-weight: 500;
  530. color: #666666;
  531. line-height: 41rpx;
  532. }
  533. }
  534. }
  535. .btn {
  536. margin: 50rpx auto 0;
  537. width: 674rpx;
  538. height: 88rpx;
  539. background: #2A9CEC;
  540. border-radius: 20rpx;
  541. text-align: center;
  542. line-height: 88rpx;
  543. font-size: 36rpx;
  544. font-family: PingFang SC;
  545. font-weight: 500;
  546. color: #FFFFFF;
  547. }
  548. .popup-box {
  549. width: 750rpx;
  550. background: #FFFFFF;
  551. border-top-left-radius: 30rpx;
  552. border-top-right-radius: 30rpx;
  553. .popup-title {
  554. padding: 32rpx 38rpx;
  555. .qx {
  556. font-size: 28rpx;
  557. font-family: PingFang SC;
  558. font-weight: 500;
  559. color: #666666;
  560. }
  561. .qd {
  562. font-size: 28rpx;
  563. font-family: PingFang SC;
  564. font-weight: bold;
  565. color: #2A9CEC;
  566. }
  567. }
  568. }
  569. .popup {
  570. display: flex;
  571. align-items: center;
  572. .popup-right {
  573. width: 100%;
  574. height: 500rpx;
  575. padding: 0 20rpx;
  576. .popup-right-item {
  577. text-align: center;
  578. padding: 30rpx 20rpx;
  579. border-bottom: 1px solid #f7f7f7;
  580. }
  581. .currRight {
  582. color: #2A9CEC;
  583. }
  584. }
  585. }
  586. </style>