select.vue 8.4 KB

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