personal-information.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424
  1. <template>
  2. <view class="bodyContent">
  3. <form bindsubmit='handleSubmit'>
  4. <view class="uni-list">
  5. <view class="uni-list-cell">
  6. <view class="uni-list-cell-left">
  7. <text>*</text>姓名
  8. </view>
  9. <view class="uni-list-cell-db">
  10. <u--input class="uni-input" v-model="name" placeholder="请输入姓名"></u--input>
  11. </view>
  12. </view>
  13. </view>
  14. <view class="uni-list">
  15. <view class="uni-list-cell">
  16. <view class="uni-list-cell-left">
  17. <text>*</text>性别
  18. </view>
  19. <view class="uni-list-cell-db">
  20. <view class="radio">
  21. <radio-group @change="radioChange">
  22. <label style="margin-right: 30px;">
  23. <radio value="0" :checked="men" />男
  24. </label>
  25. <label>
  26. <radio value="1" :checked="women" />女
  27. </label>
  28. </radio-group>
  29. </view>
  30. </view>
  31. </view>
  32. </view>
  33. <view class="uni-list">
  34. <view class="uni-list-cell">
  35. <view class="uni-list-cell-left">
  36. <text>*</text>班级
  37. </view>
  38. <view class="uni-list-cell-db">
  39. <u--input class="uni-input" v-model="studentClazz" placeholder="请输入班级"></u--input>
  40. </view>
  41. </view>
  42. </view>
  43. <view class="uni-list">
  44. <view class="uni-list-cell">
  45. <view class="uni-list-cell-left">
  46. <text>*</text>手机号
  47. </view>
  48. <view class="uni-list-cell-db">
  49. <u--input class="uni-input" maxlength=11 v-model="studentPhone" placeholder="请输入手机号"></u--input>
  50. </view>
  51. </view>
  52. </view>
  53. <view class="uni-list">
  54. <view class="uni-list-cell">
  55. <view class="uni-list-cell-left">
  56. <text>*</text>备选手机号
  57. </view>
  58. <view class="uni-list-cell-db">
  59. <u--input class="uni-input" maxlength=11 v-model="studentOtherPhone" placeholder="请输入备选手机号">
  60. </u--input>
  61. </view>
  62. </view>
  63. </view>
  64. <view class="uni-list">
  65. <view class="cuni-list-cell">
  66. <view class="uni-list-cell-left">
  67. <text>*</text>学生宿舍
  68. </view>
  69. <view class="uni-list-cell-db">
  70. <picker class="uni-input-1" mode="multiSelector" :value="roomIndex" :range="room_List"
  71. @change="bindPickerChange_room" @columnchange="handleNum">
  72. <view class="uni-input2" v-if="dormNumber">
  73. {{dormNumber}}
  74. </view>
  75. <view class="uni-input2" style="color: #C0C4CC;" v-else>
  76. 请选择学生宿舍
  77. </view>
  78. </picker>
  79. </view>
  80. </view>
  81. </view>
  82. <view class="uni-list">
  83. <view class="uni-list-cell">
  84. <view class="uni-list-cell-left">
  85. <text>*</text>学生校区
  86. </view>
  87. <view class="uni-list-cell-db">
  88. <picker @change="bindPickerChange" :value="studentCampus" :range="array">
  89. <view class="uni-input2" v-if="studentCampus!==null">{{array[studentCampus]}}</view>
  90. <view class="uni-input2" style="color: #C0C4CC;" v-else>
  91. 请选择学生校区
  92. </view>
  93. </picker>
  94. </view>
  95. </view>
  96. </view>
  97. <button @click="modifyInformation" form-type="submit"
  98. style="color: white;background-color: rgba(42, 130, 228, 1);">确认</button>
  99. </form>
  100. </view>
  101. </template>
  102. <script>
  103. export default {
  104. data() {
  105. return {
  106. name: '', //姓名
  107. studentSex: 0, //性别
  108. studentClazz: '', //班级
  109. studentPhone: '', //手机号
  110. studentOtherPhone: '', //备用手机号
  111. dormNumber: null, //学生宿舍
  112. studentCampus: null, //学生校区
  113. studentDormitory: '',
  114. array: ['黄家湖校区', '墨轩湖校区'],
  115. men: true,
  116. women: false,
  117. room_List: [
  118. [],
  119. [],
  120. []
  121. ],
  122. roomIndex: null,
  123. buildId: 1,
  124. floorId: 1,
  125. roomId: 1,
  126. IdList: [],
  127. IdList2: [],
  128. count: 0,
  129. count2: 0,
  130. }
  131. },
  132. onLoad() {
  133. this.getStudentInformation()
  134. this.getbuild()
  135. this.getbuildHigh()
  136. this.getrooms()
  137. },
  138. methods: {
  139. // 获取学生数据
  140. getStudentInformation() {
  141. let res = uni.getStorageSync('student')
  142. // console.log('这是获取key中的内容', res)
  143. if (res) {
  144. this.name = res.studentName
  145. this.studentSex = res.studentSex
  146. if (this.studentSex == 0) {
  147. this.men = true
  148. this.women = false
  149. } else {
  150. this.men = false
  151. this.women = true
  152. }
  153. this.studentCampus = res.studentCampus
  154. this.studentPhone = res.studentPhone
  155. this.studentOtherPhone = res.studentOtherPhone
  156. this.studentDormitory = res.studentDormitory
  157. this.dormNumber = res.dormNumber
  158. this.studentClazz = res.studentClazz
  159. }
  160. },
  161. // 获取宿舍楼栋数据
  162. async getbuild() {
  163. let res = await this.$myRequest({
  164. method: "post",
  165. url: `/build/queryAllBuild`,
  166. })
  167. // console.log(res)
  168. let tempList = []
  169. res.data.forEach(item => {
  170. tempList.push(item.buildName)
  171. })
  172. this.$nextTick(() => {
  173. this.$set(this.room_List, 0, tempList)
  174. })
  175. },
  176. // 获取宿舍楼层数据
  177. async getbuildHigh() {
  178. let res = await this.$myRequest({
  179. method: "post",
  180. url: `/build/queryAllFloorByBuildID?buildId=${this.buildId}`,
  181. })
  182. // console.log(res)
  183. this.room_List[1] = []
  184. this.room_List[2] = []
  185. this.IdList = []
  186. let tempList = []
  187. res.data.forEach(item => {
  188. tempList.push(item.floorName)
  189. this.IdList.push(item.floorId)
  190. })
  191. this.$nextTick(() => {
  192. this.$set(this.room_List, 1, tempList)
  193. this.floorId = this.IdList[this.count]
  194. })
  195. },
  196. // 获取宿舍房间数据
  197. async getrooms() {
  198. let res = await this.$myRequest({
  199. method: "post",
  200. url: `/build/queryAllRoomByFloorID?floorId=${this.floorId}`,
  201. })
  202. // console.log(res)
  203. this.room_List[2] = []
  204. this.IdList2 = []
  205. let tempList2 = []
  206. res.data.forEach(item => {
  207. tempList2.push(item.roomName)
  208. this.IdList2.push(item.roomId)
  209. })
  210. this.$nextTick(() => {
  211. this.$set(this.room_List, 2, tempList2)
  212. this.roomId = this.IdList2[this.count2]
  213. })
  214. },
  215. // 编辑信息
  216. async modifyInformation() {
  217. let phoneVer = /^[1][3,4,5,7,8,9][0-9]{9}$/ //验证规则
  218. if (!this.name || !this.studentClazz || !this.studentPhone || !this
  219. .studentOtherPhone || this.dormNumber == null || this.studentCampus == null) {
  220. uni.showToast({
  221. title: "请输入具体信息",
  222. icon: "none"
  223. })
  224. } else if (!phoneVer.test(this.studentPhone) || !phoneVer.test(this.studentOtherPhone)) {
  225. uni.showToast({
  226. title: "请输入正确的联系电话",
  227. icon: 'none'
  228. })
  229. } else {
  230. let res = await this.$myRequest({
  231. method: "post",
  232. url: `/student/updateStudent?studentOtherPhone=${this.studentOtherPhone}&studentName=${this.name}&studentDormitory=${this.studentDormitory}&studentSex=${this.studentSex}&studentPhone=${this.studentPhone}&studentCampus=${this.studentCampus}&dormNumber=${this.dormNumber}&studentClazz=${this.studentClazz}`,
  233. })
  234. // console.log(res)
  235. if (res.status == 200) {
  236. uni.showToast({
  237. title: '编辑成功',
  238. icon: 'success'
  239. })
  240. uni.setStorageSync("updataMsg", true)
  241. uni.setStorageSync('student', res.data);
  242. setTimeout(() => {
  243. uni.reLaunch({
  244. url: '../index/index'
  245. })
  246. }, 1500)
  247. } else {
  248. uni.showToast({
  249. title: '编辑失败',
  250. icon: 'error'
  251. })
  252. }
  253. }
  254. },
  255. // 学生校区选择框
  256. bindPickerChange(e) {
  257. // console.log(e)
  258. this.studentCampus = e.detail.value
  259. },
  260. // 性别选择框
  261. radioChange(e) {
  262. // console.log(e.detail.value)
  263. this.studentSex = e.detail.value
  264. },
  265. // 三级联动下拉框回调
  266. bindPickerChange_room(e) {
  267. // console.log('picker发送选择改变,携带值为', e.detail.value)
  268. this.roomIndex = e.detail.value
  269. this.dormNumber = this.room_List[0][this.roomIndex[0]] + this.room_List[1][this.roomIndex[1]] + this
  270. .room_List[2][this.roomIndex[2]]
  271. // console.log(this.buildId + '-' + this.floorId + '-' + this.roomId)
  272. },
  273. // 三级联动下拉框拖动回调
  274. handleNum(e) {
  275. // console.log("第"+(e.detail.column+1)+"列"+"第"+(e.detail.value+1)+"行" )
  276. if (e.detail.column == 0) {
  277. // console.log("楼栋发生变化,当前为"+(e.detail.value+1)+"栋")
  278. if (e.detail.value < 4) {
  279. this.buildId = e.detail.value + 1
  280. } else {
  281. this.buildId = e.detail.value + 5
  282. }
  283. } else if (e.detail.column == 1) {
  284. // console.log("层数发生变化,当前为"+(e.detail.value+1)+"层")
  285. this.floorId = this.IdList[e.detail.value]
  286. this.count = e.detail.value
  287. } else {
  288. // console.log("房间数发生变化,当前为"+(e.detail.value+1)+"号")
  289. this.roomId = this.IdList2[e.detail.value]
  290. this.count2 = e.detail.value
  291. }
  292. // console.log(this.buildId + '-' + this.floorId + '-' + this.roomId)
  293. }
  294. },
  295. // 监听属性
  296. watch: {
  297. buildId: {
  298. handler() {
  299. this.getbuildHigh()
  300. },
  301. immediate: true
  302. },
  303. floorId: {
  304. handler() {
  305. this.getrooms()
  306. },
  307. immediate: true
  308. },
  309. },
  310. }
  311. </script>
  312. <style>
  313. .bodyContent {
  314. position: fixed;
  315. width: 100%;
  316. }
  317. .uni-list-cell-left {
  318. float: left;
  319. width: 22%;
  320. height: 94rpx;
  321. text-align: center;
  322. font-size: 28rpx;
  323. border-bottom: 1px solid rgba(200, 200, 205, 1);
  324. line-height: 94rpx;
  325. }
  326. .uni-list-cell-left text {
  327. color: red;
  328. }
  329. .uni-list-cell-db {
  330. float: right;
  331. width: 78%;
  332. height: 94rpx;
  333. border-bottom: 1px solid rgba(200, 200, 205, 1);
  334. }
  335. /* .uni-list-cell-db .name {
  336. float: right;
  337. } */
  338. .uni-list {
  339. position: relative;
  340. font-size: 28rpx;
  341. }
  342. .uni-list-cell-db input {
  343. height: 94rpx;
  344. width: 78%;
  345. float: right;
  346. text-align: center;
  347. line-height: 94rpx;
  348. font-size: 28rpx;
  349. border: none;
  350. }
  351. .uni-list-cell-db .u-border {
  352. border: none;
  353. float: right;
  354. margin-top: 16rpx;
  355. width: 196rpx;
  356. }
  357. .uni-list-cell-db .uni-input {
  358. float: right;
  359. margin-right: 44rpx;
  360. width: 240rpx;
  361. line-height: 94rpx;
  362. }
  363. .uni-list-cell-db .uni-input2 {
  364. float: right;
  365. margin-right: 64rpx;
  366. width: 240rpx;
  367. height: 96rpx;
  368. line-height: 94rpx;
  369. font-size: 30rpx;
  370. }
  371. .uni-list-cell-db uni-image {
  372. position: absolute;
  373. width: 52rpx;
  374. height: 52rpx;
  375. right: 6rpx;
  376. top: 22rpx;
  377. }
  378. button {
  379. position: absolute;
  380. top: 690rpx;
  381. left: 48rpx;
  382. width: 656rpx;
  383. height: 94rpx;
  384. color: white;
  385. }
  386. .radio {
  387. float: right;
  388. margin: 24rpx 72rpx 0 0;
  389. /* color: #C0C4CC; */
  390. }
  391. .uni-input-1 {
  392. height: 50rpx;
  393. }
  394. </style>