main.vue 11 KB

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