select.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358
  1. <template>
  2. <view class="container-box">
  3. <image src="/static/image/bmi/manual_icon_arrow.png" alt="" class="back-class" @click="goBcak()"></image>
  4. <text class="countdown">倒计时{{ countdown }}s</text>
  5. <view class="select-box">
  6. <view class="select-tab">
  7. <view v-for="(item, index) in tabs" :key="index" class="tab-item"
  8. :class="item.type == activeTab ? `tab-active-item${index}` : `tab-item${index}`" @click="changeTab(item)">
  9. <image class="tab-img" :src="item.type == activeTab ? item.actImg : item.img" alt=""></image>
  10. <text>{{ item.title }}</text>
  11. </view>
  12. </view>
  13. <view class="select-info" v-if="activeTab == 'grade'">
  14. <view v-for="(item, index) in totalList" class="info-item" @click="changeGrade(item)"
  15. :class="item.active == true ? `info-active-item0` : `info-item0`">{{ item.name }}</view>
  16. </view>
  17. <view class="select-info" v-else-if="activeTab == 'class'">
  18. <view v-for="(item, index) in classList" class="info-item" @click="changeClass(item)"
  19. :class="item.active == true ? `info-active-item1` : `info-item1`">{{ item.name }}</view>
  20. </view>
  21. <view class="select-info" v-else-if="activeTab == 'student'">
  22. <view v-for="(item, index) in studentList" class="info-item" @click="changeStudent(item)"
  23. :class="item.active == true ? `info-active-item2` : `info-item2`">{{ item.name }}</view>
  24. </view>
  25. </view>
  26. <view class="selected-box">
  27. <view>已选择:</view>
  28. <view class="selected-info">
  29. <view v-for="(item, index) in curSelected" :key="index">
  30. <text v-if="index != 0" class="selected-line">|</text>
  31. <text>{{ item.name }}</text>
  32. </view>
  33. </view>
  34. </view>
  35. <view :class="curSelected.length == 3 ? 'next-btn' : 'ban-btn'" @click="navToTest">进入检测页</view>
  36. </view>
  37. </template>
  38. <script>
  39. import { navTo, showToast } from "@/utils/app";
  40. export default {
  41. data() {
  42. return {
  43. title: '学生未激活',
  44. select: 0,
  45. selectMax: 1,
  46. queryForm: {
  47. student_id: 0,
  48. },
  49. totalList: [],
  50. activeTab: 'grade',
  51. tabs: [
  52. { title: '选择年级', type: 'grade', img: '/static/image/bmi/manual_icon_grade.png', actImg: '/static/image/bmi/manual_icon_grade_selected.png' },
  53. { title: '选择班级', type: 'class', img: '/static/image/bmi/manual_icon_class.png', actImg: '/static/image/bmi/manual_icon_class_selected.png' },
  54. { title: '选择学生', type: 'student', img: '/static/image/bmi/manual_icon_student.png', actImg: '/static/image/bmi/manual_icon_student_selected.png' }
  55. ],
  56. countdown: 60,
  57. selectedArr: [
  58. { name: '三年级', id: 1 },
  59. { name: '1班', id: 2 },
  60. { name: '11', id: 3 },
  61. ]
  62. }
  63. },
  64. computed: {
  65. classList() {
  66. let activeGrade = this.totalList.find(item => item.active == true)
  67. return activeGrade ? activeGrade.class : null
  68. },
  69. studentList() {
  70. let activeGrade = this.totalList.find(item => item.active == true)
  71. if (activeGrade.class) {
  72. let activeClass = activeGrade.class.find(item => item.active == true)
  73. return activeClass ? activeClass.student : null
  74. }
  75. return null
  76. },
  77. curSelected() {
  78. let arr = []
  79. let activeGrade = this.totalList.find(item => item.active == true)
  80. if (activeGrade) {
  81. arr.push(activeGrade)
  82. let activeClass = this.classList.find(item => item.active == true)
  83. if (activeClass) {
  84. arr.push(activeClass)
  85. let activeStudent = this.studentList.find(item => item.active == true)
  86. if (activeStudent) arr.push(activeStudent)
  87. }
  88. }
  89. return arr
  90. },
  91. },
  92. onLoad() {
  93. this.getGradeList()
  94. },
  95. methods: {
  96. getGradeList() {
  97. this.totalList = [
  98. { name: '一年级', id: 1 },
  99. { name: '二年级', id: 2 },
  100. { name: '二年级', id: 3 },
  101. { name: '二年级', id: 4 },
  102. { name: '二年级', id: 5 },
  103. { name: '二年级', id: 6 },
  104. { name: '二年级', id: 7 },
  105. ]
  106. console.log(this.totalList[0])
  107. },
  108. getClassList() {
  109. this.totalList.find(item => item.active == true).class = [
  110. { name: '一班', id: 1 },
  111. { name: '二班', id: 3 },
  112. { name: '三班', id: 4 },
  113. { name: '四班', id: 5 },
  114. { name: '五班', id: 6 },
  115. { name: '六班', id: 7 },
  116. ]
  117. },
  118. getStudent() {
  119. this.totalList.find(item => item.active == true).class
  120. .find(item => item.active == true).student = [
  121. { name: '11', id: 1 },
  122. { name: '22', id: 3 },
  123. { name: '33', id: 4 },
  124. { name: '44', id: 5 },
  125. { name: '55', id: 6 },
  126. { name: '66', id: 7 },
  127. ]
  128. },
  129. changeTab(item) {
  130. this.activeTab = item.type
  131. },
  132. changeGrade(item) {
  133. this.activeTab = 'class'
  134. for (let i of this.totalList) { i.active = false }
  135. item.active = true
  136. this.getClassList()
  137. },
  138. changeClass(item) {
  139. this.activeTab = 'student'
  140. let classList = this.totalList.find(i => i.active == true).class
  141. for (let i of classList) { i.active = false }
  142. item.active = true
  143. this.getStudent()
  144. },
  145. changeStudent(item) {
  146. let classList = this.totalList.find(i => i.active == true).class
  147. let studentList = classList.find(i => i.active == true).student
  148. for (let i of studentList) { i.active = false }
  149. item.active = true
  150. },
  151. goBcak() {
  152. navTo('pages/index/index', {
  153. })
  154. },
  155. navToTest() {
  156. if (this.curSelected.length == 3) {
  157. navTo('pages/test/bmi', {
  158. })
  159. }
  160. },
  161. }
  162. }
  163. </script>
  164. <style scoped>
  165. .container-box {
  166. height: 100vh;
  167. width: 100%;
  168. background: linear-gradient(to bottom left, rgb(218, 233, 253), #fff, rgb(218, 233, 253));
  169. position: relative;
  170. overflow: auto;
  171. }
  172. .back-class {
  173. position: absolute;
  174. top: 40upx;
  175. left: 46upx;
  176. width: 70upx;
  177. height: 70upx;
  178. }
  179. .countdown {
  180. position: absolute;
  181. top: 40upx;
  182. right: 46upx;
  183. font-weight: bold;
  184. font-size: 35upx;
  185. color: #2F3C42;
  186. line-height: 41upx;
  187. }
  188. .select-box {
  189. margin: 125upx auto 0;
  190. width: 680upx;
  191. height: 55vh;
  192. border-radius: 14upx;
  193. background: #fff;
  194. box-shadow: 0 0px 5px 1px #ccc;
  195. }
  196. .selected-box {
  197. margin: 25upx auto 0;
  198. width: 680upx;
  199. height: 15vh;
  200. line-height: 6vh;
  201. border-radius: 14upx;
  202. background: #fff;
  203. box-shadow: 0 0px 5px 1px #ccc;
  204. font-weight: bold;
  205. font-size: 28rpx;
  206. padding: 1.5vh 27upx;
  207. box-sizing: border-box;
  208. color: #0369E8;
  209. }
  210. .selected-info {
  211. display: flex;
  212. font-weight: 400;
  213. font-size: 28rpx;
  214. color: #2F3C42;
  215. }
  216. .selected-line {
  217. color: #ccc;
  218. padding: 0 10upx;
  219. }
  220. .next-btn {
  221. margin: 25upx auto 0;
  222. width: 389upx;
  223. height: 9vh;
  224. line-height: 9vh;
  225. border-radius: 14upx;
  226. background: #0369E8;
  227. color: #fff;
  228. font-weight: bold;
  229. font-size: 35rpx;
  230. text-align: center;
  231. }
  232. .ban-btn {
  233. margin: 25upx auto 0;
  234. width: 389upx;
  235. height: 9vh;
  236. line-height: 9vh;
  237. border-radius: 14upx;
  238. background: #ccc;
  239. color: #666;
  240. font-weight: bold;
  241. font-size: 35rpx;
  242. text-align: center;
  243. }
  244. .select-tab {
  245. display: flex;
  246. border-bottom: 1px solid #ccc;
  247. }
  248. .tab-img {
  249. width: 42upx;
  250. height: 42upx;
  251. margin-top: 34upx;
  252. }
  253. .tab-item {
  254. flex: 1;
  255. display: flex;
  256. justify-content: center;
  257. text-align: center;
  258. height: 110upx;
  259. line-height: 110upx;
  260. font-weight: bold;
  261. font-size: 28rpx;
  262. border-top-left-radius: 14upx;
  263. border-top-right-radius: 14upx;
  264. }
  265. .tab-item0 {
  266. color: rgb(3, 105, 232);
  267. background: #fff;
  268. }
  269. .tab-item1 {
  270. color: rgb(2, 193, 124);
  271. background: #fff;
  272. }
  273. .tab-item2 {
  274. color: rgb(211, 121, 13);
  275. background: #fff;
  276. }
  277. .tab-active-item0 {
  278. background: rgb(3, 105, 232);
  279. color: #fff;
  280. }
  281. .tab-active-item1 {
  282. background: rgb(2, 193, 124);
  283. color: #fff;
  284. }
  285. .tab-active-item2 {
  286. background: rgb(211, 121, 13);
  287. color: #fff;
  288. }
  289. .select-info {
  290. padding: 20upx;
  291. display: flex;
  292. flex-wrap: wrap;
  293. }
  294. .info-item {
  295. height: 69upx;
  296. width: 139upx;
  297. border-radius: 10upx;
  298. font-weight: bold;
  299. font-size: 21upx;
  300. text-align: center;
  301. line-height: 69upx;
  302. margin-right: 18upx;
  303. margin-bottom: 18upx;
  304. }
  305. .info-item0 {
  306. background: #F1F7FF;
  307. color: #0369E8;
  308. }
  309. .info-active-item0 {
  310. color: #fff;
  311. background: #0369E8;
  312. }
  313. .info-item1 {
  314. background: #EFFFF8;
  315. color: rgb(2, 193, 124);
  316. }
  317. .info-active-item1 {
  318. color: #EFFFF8;
  319. background: rgb(2, 193, 124);
  320. }
  321. .info-item2 {
  322. background: #FFFCF5;
  323. color: #D3790D;
  324. }
  325. .info-active-item2 {
  326. color: #FFFCF5;
  327. background: #D3790D;
  328. }
  329. </style>