myDorm.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344
  1. <template>
  2. <view class="container">
  3. <view class="info">{{ info }}</view>
  4. <!-- 床位列表区域 -->
  5. <view class="bed_list">
  6. <!-- 每一个床位区域 -->
  7. <view class="bed_item" v-for="(item, index) in bedList" :key="index">
  8. <view class="item_top">
  9. <view class="top_left" v-if="item.isCheck == 0">暂无入住</view>
  10. <view class="top_left" v-if="item.isCheck == 1">{{ item.name ? '本人入住' : '已入住' }}</view>
  11. <view class="top_right">{{ index + 1 }}号床</view>
  12. </view>
  13. <!-- 详细信息区域 -->
  14. <view class="item_form icon" v-if="item.isCheck == 0">
  15. <image class="form_not" src="/static/5.png" mode="aspectFill"></image>
  16. 暂无入住
  17. </view>
  18. <view class="item_form icon" v-if="item.isCheck == 1 && !item.name">
  19. <image class="form_have" src="/static/4.png" mode="aspectFill"></image>
  20. 已入住
  21. </view>
  22. <view class="item_form" v-if="item.isCheck == 1 && item.name">
  23. <view class="form_left">
  24. <view class="left_box">
  25. <view class="box_key">姓名:</view>
  26. <view class="box_value">
  27. <input
  28. class="input"
  29. type="text"
  30. placeholder="请输入姓名"
  31. placeholder-style="color:#CCCCCC;font-size:28rpx"
  32. :value="item.name"
  33. :disabled="item.name"
  34. />
  35. </view>
  36. </view>
  37. <view class="left_box">
  38. <view class="box_key">学院:</view>
  39. <view class="box_value">
  40. <input
  41. class="input"
  42. type="text"
  43. placeholder="请输入学院"
  44. placeholder-style="color:#CCCCCC;font-size:28rpx"
  45. :value="item.college"
  46. :disabled="item.college"
  47. />
  48. </view>
  49. </view>
  50. <view class="left_box">
  51. <view class="box_key">专业:</view>
  52. <view class="box_value">
  53. <input
  54. class="input"
  55. type="text"
  56. placeholder="请输入专业"
  57. placeholder-style="color:#CCCCCC;font-size:28rpx"
  58. :value="item.major"
  59. :disabled="item.major"
  60. />
  61. </view>
  62. </view>
  63. <view class="left_box">
  64. <view class="box_key">联系方式:</view>
  65. <view class="box_value">
  66. <input
  67. class="input"
  68. type="text"
  69. placeholder="请输入联系方式"
  70. placeholder-style="color:#CCCCCC;font-size:28rpx"
  71. :value="item.phone"
  72. :disabled="item.phone"
  73. />
  74. </view>
  75. </view>
  76. <view class="left_box">
  77. <view class="box_key">家庭住址:</view>
  78. <view class="box_value">
  79. <input
  80. class="input"
  81. type="text"
  82. placeholder="请输入家庭住址"
  83. placeholder-style="color:#CCCCCC;font-size:28rpx"
  84. :value="item.address"
  85. :disabled="item.address"
  86. />
  87. </view>
  88. </view>
  89. </view>
  90. <!-- 照片区域 -->
  91. <image class="form_photo" v-if="item.picture" :src="item.picture" mode="aspectFill"></image>
  92. <image class="form_photo" v-else src="@/static/7.png" mode="aspectFill"></image>
  93. </view>
  94. </view>
  95. </view>
  96. <!-- 按钮区域 -->
  97. <view class="btns">
  98. <view class="btn_next" @click="handleLook">查看预报道凭证</view>
  99. <view class="btn_next" @click="handleCar">车牌预约</view>
  100. <view class="btn_next" @click="logout">退出登录</view>
  101. </view>
  102. </view>
  103. </template>
  104. <script setup>
  105. import { onLoad } from '@dcloudio/uni-app'
  106. import { ref } from 'vue'
  107. import { getBedDetailsReq } from '@/api/index.js'
  108. const info = ref()
  109. const studentInfo = ref()
  110. // 宿舍床位数组
  111. const bedList = ref([])
  112. onLoad((options) => {
  113. // console.log(options)
  114. info.value = options.str
  115. studentInfo.value = uni.getStorageSync('studentInfo')
  116. getBedDetails()
  117. })
  118. // 获取宿舍详情
  119. const getBedDetails = async () => {
  120. const res = await getBedDetailsReq()
  121. // console.log(res)
  122. if (res.code == 200) {
  123. bedList.value = res.data
  124. }
  125. }
  126. // 查看电子凭证按钮回调
  127. const handleLook = () => {
  128. let studentCard = uni.getStorageSync('studentInfo').cardId
  129. // console.log(studentCard)
  130. if (bedList.value.length) {
  131. let obj = bedList.value.find((ele) => ele.studentCard == studentCard)
  132. // console.log(obj)
  133. if (obj) {
  134. let msg = encodeURIComponent(JSON.stringify(obj))
  135. uni.navigateTo({
  136. url: `/pages/proof/proof?msg=${msg}`
  137. })
  138. } else {
  139. uni.showToast({
  140. title: '请先选择床位',
  141. icon: 'none'
  142. })
  143. }
  144. } else {
  145. uni.showToast({
  146. title: '请先选择床位',
  147. icon: 'none'
  148. })
  149. }
  150. }
  151. // 车牌预约按钮回调
  152. const handleCar = () => {
  153. let info = uni.getStorageSync('studentInfo')
  154. // console.log(info)
  155. if (info.trafficMethod == '自驾') {
  156. uni.showModal({
  157. title: '提示',
  158. content: '确定前往车牌预约吗?',
  159. success: (res) => {
  160. if (res.confirm) {
  161. uni.reLaunch({
  162. url: '/pages/subscribe/subscribe'
  163. })
  164. }
  165. }
  166. })
  167. } else {
  168. uni.showToast({
  169. title: '您选择的交通方式不为自驾,不支持车牌预约',
  170. icon: 'none'
  171. })
  172. }
  173. }
  174. // 退出登录按钮回调
  175. const logout = () => {
  176. uni.showModal({
  177. title: '提示',
  178. content: '确定退出登录吗?',
  179. success: (res) => {
  180. if (res.confirm) {
  181. let urlstr = uni.getStorageSync('urlstr')
  182. uni.clearStorageSync()
  183. window.location.href = `https://chtech.ncjti.edu.cn/welcome/welcomeH5/#/?urlstr=${urlstr}`
  184. }
  185. }
  186. })
  187. }
  188. </script>
  189. <style lang="scss" scoped>
  190. .container {
  191. padding-top: 12rpx;
  192. padding-bottom: 50rpx;
  193. min-height: 100vh;
  194. background-color: #f5f9ff;
  195. .info {
  196. padding: 0 20rpx;
  197. height: 90rpx;
  198. line-height: 90rpx;
  199. font-size: 36rpx;
  200. font-weight: bold;
  201. text-align: center;
  202. background-color: #fff;
  203. }
  204. .bed_list {
  205. background-color: #fff;
  206. .bed_item {
  207. padding: 0 20rpx;
  208. margin-bottom: 20rpx;
  209. .item_top {
  210. display: flex;
  211. align-items: center;
  212. height: 80rpx;
  213. font-size: 28rpx;
  214. font-weight: bold;
  215. color: #0061ff;
  216. .top_left {
  217. box-sizing: border-box;
  218. padding-left: 42rpx;
  219. width: 520rpx;
  220. height: 100%;
  221. line-height: 80rpx;
  222. border-radius: 9rpx 9rpx, 0rpx, 0rpx;
  223. background-color: #cce0ff;
  224. }
  225. .top_right {
  226. flex: 1;
  227. height: 100%;
  228. line-height: 80rpx;
  229. text-align: center;
  230. }
  231. }
  232. .item_form {
  233. display: flex;
  234. box-sizing: border-box;
  235. padding-top: 40rpx;
  236. width: 710rpx;
  237. height: 543rpx;
  238. border-radius: 8rpx;
  239. background-color: #f2f7ff;
  240. .form_left {
  241. width: 520rpx;
  242. .left_box {
  243. display: flex;
  244. align-items: center;
  245. margin-bottom: 20rpx;
  246. .box_key {
  247. width: 140rpx;
  248. text-align: end;
  249. font-size: 28rpx;
  250. }
  251. .box_value {
  252. box-sizing: border-box;
  253. padding: 0 20rpx;
  254. width: 355rpx;
  255. height: 74rpx;
  256. border-radius: 4rpx;
  257. background-color: #fff;
  258. .input {
  259. height: 100%;
  260. }
  261. }
  262. }
  263. }
  264. .form_photo {
  265. margin-left: 20rpx;
  266. width: 156rpx;
  267. height: 199rpx;
  268. border-radius: 8rpx;
  269. border: 2rpx solid #ccc;
  270. }
  271. .form_have {
  272. margin-bottom: 5rpx;
  273. width: 132rpx;
  274. height: 132rpx;
  275. }
  276. .form_not {
  277. width: 174rpx;
  278. height: 174rpx;
  279. }
  280. }
  281. .icon {
  282. flex-direction: column;
  283. align-items: center;
  284. justify-content: center;
  285. font-size: 24rpx;
  286. }
  287. }
  288. }
  289. .btns {
  290. padding: 20rpx 20rpx 0;
  291. background-color: #fff;
  292. .btn_next {
  293. display: flex;
  294. align-items: center;
  295. justify-content: center;
  296. margin: 50rpx 20rpx;
  297. height: 100rpx;
  298. font-size: 32rpx;
  299. color: #fff;
  300. border-radius: 8rpx;
  301. background-color: #0061ff;
  302. }
  303. }
  304. }
  305. </style>