add.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. <template>
  2. <view class="app-container">
  3. <u-navbar title="新增实名游玩人" bgColor="#fff" :fixed="true" :autoBack="false" leftIconColor="#333333"
  4. leftIconSize="28" @leftClick="handleLeftClick">
  5. </u-navbar>
  6. <view class="app-container-item flex-column-center">
  7. <view class="tourist-form">
  8. <u--form labelPosition="left" :model="userInfo" :rules="rules" ref="uForm" labelWidth="150">
  9. <u-form-item label="姓名" prop="username" borderBottom :required="true">
  10. <u--input placeholder="请输入游玩人姓名" v-model="userInfo.username" inputAlign="right"
  11. border="none"></u--input>
  12. </u-form-item>
  13. <picker @change="bindPickerChange" :value="index" :range="IDTypeList" range-key="label"
  14. style="width: 100%">
  15. <u-form-item label="证件类型" prop="IDType" borderBottom :required="true">
  16. <!-- <u-cell name="IDType" :border="false" style="width: 100%"-->
  17. <!-- :rightIconStyle="{'font-size':'40px','color': '#CCCCCC'}" @click="onIDTypeFuc()">-->
  18. <!-- <template #value>-->
  19. <!-- <view>{{ form.IDType }}</view>-->
  20. <view style="width: 100%;display: flex;justify-content: flex-end;color: #333333">
  21. {{IDTypeList[index].label || '请选择证件类型'}}
  22. <u-icon name="arrow-right" color="#909399" size="30" style="margin-left: 5px"></u-icon>
  23. </view>
  24. <!-- </template>-->
  25. <!-- <template #right-icon>-->
  26. <!-- <u-icon name="arrow-right" color="#909399" size="30"></u-icon>-->
  27. <!-- </template>-->
  28. <!-- </u-cell>-->
  29. </u-form-item>
  30. </picker>
  31. <u-form-item label="证件号码" prop="idNumber" :required="true">
  32. <u--input placeholder="请输入证件号码" v-model="userInfo.idNumber" inputAlign="right"
  33. border="none"></u--input>
  34. </u-form-item>
  35. </u--form>
  36. </view>
  37. </view>
  38. <view class="app-container-btn flex-between">
  39. <u-button v-if="isSubmitEnabled" type="primary" shape="circle" class="btn" text="确定"
  40. @tap="toAppoint()"></u-button>
  41. <u-button text="确定" class="btn" v-else color="#DDE2EC"></u-button>
  42. </view>
  43. </view>
  44. </template>
  45. <script>
  46. import {
  47. isID,
  48. } from '@/utils/rules.js';
  49. export default {
  50. components: {},
  51. data() {
  52. return {
  53. show: false,
  54. index: 0,
  55. IDTypeList: [
  56. {
  57. label: '证件A',
  58. code: 'a'
  59. },
  60. {
  61. label: '证件B',
  62. code: 'b'
  63. }
  64. ],
  65. userInfo: {
  66. username: '', // 姓名
  67. IDType: '', // 证件类型
  68. idNumber: '', // 证件号码
  69. },
  70. isRules: {
  71. idNumber: false, // 证件号码
  72. },
  73. rules: {
  74. 'username': [{
  75. required: true,
  76. message: '请输入姓名',
  77. trigger: ['change', 'blur']
  78. }],
  79. 'IDType': [{
  80. required: true,
  81. message: '请选择证件类型',
  82. trigger: ['change', 'blur'],
  83. }],
  84. 'idNumber': [{
  85. required: true,
  86. message: '请输入证件号码',
  87. trigger: ['change', 'blur'],
  88. },
  89. {
  90. // 自定义验证函数,见上说明
  91. validator: (rule, value, callback) => {
  92. console.log(isID(value))
  93. this.isRules.idNumber = isID(value).state;
  94. callback(isID(value).data)
  95. },
  96. // message: '证件号码格式不正确',
  97. // 触发器可以同时用blur和change
  98. trigger: ['change', 'blur'],
  99. }
  100. ]
  101. },
  102. form: {
  103. startTime: this.$sun.formatTime(new Date(), '{y}-{m}-{d}'),
  104. num: 0,
  105. endTime: '',
  106. zoneDeviceRId: '22',
  107. zoneDeviceRName: '',
  108. visiteeRoom: '',
  109. },
  110. detailInfo: {
  111. title: '兰花街1、2、3',
  112. date: '2024.06.14',
  113. openStartTime: '08:00',
  114. openEndTime: '20:00',
  115. timePeriod: [{
  116. startTime: '08:00',
  117. endTime: '10:00',
  118. reservationState: 1
  119. },
  120. {
  121. startTime: '10:00',
  122. endTime: '12:00',
  123. reservationState: 2
  124. },
  125. {
  126. startTime: '12:00',
  127. endTime: '14:00',
  128. reservationState: 3
  129. },
  130. {
  131. startTime: '14:00',
  132. endTime: '16:00',
  133. reservationState: 4
  134. },
  135. {
  136. startTime: '16:00',
  137. endTime: '18:00',
  138. reservationState: 5
  139. },
  140. {
  141. startTime: '18:00',
  142. endTime: '20:00',
  143. reservationState: 4
  144. }
  145. ]
  146. },
  147. timePeriodCheckIndex: null,
  148. touristList: [{
  149. username: '刘琳琳', // 姓名
  150. idNumber: '430822********0465', // 证件号码
  151. IDType: '',
  152. }, {
  153. username: '刘琳X', // 姓名
  154. idNumber: '430822********0464', // 证件号码
  155. IDType: '',
  156. }, {
  157. username: '刘琳Y', // 姓名
  158. idNumber: '430822********0463', // 证件号码
  159. IDType: '',
  160. }]
  161. };
  162. },
  163. computed: {
  164. isSubmitEnabled() {
  165. return (this.userInfo.username && this.userInfo.username != '') && (this.isRules
  166. .idNumber);
  167. },
  168. },
  169. filters: {
  170. matchStateColor(code) {
  171. switch (code) {
  172. case 1:
  173. return '停售';
  174. case 2:
  175. return '普通';
  176. case 3:
  177. return '拥挤';
  178. case 4:
  179. return '空闲';
  180. case 5:
  181. return '繁忙';
  182. }
  183. }
  184. },
  185. onLoad(options) {
  186. // this.detailInfo = JSON.parse(options.info);
  187. console.log('onLoad', this.detailInfo)
  188. },
  189. onShow() {},
  190. methods: {
  191. bindPickerChange: function(e) {
  192. console.log('picker发送选择改变,携带值为', e.detail.value)
  193. this.index = e.detail.value
  194. },
  195. /**
  196. * 添加游玩人
  197. */
  198. addTourists() {
  199. console.log('添加游玩人')
  200. },
  201. /**
  202. * 立即预订
  203. */
  204. toAppoint() {
  205. },
  206. handleLeftClick() {
  207. //获取页面栈的长度
  208. const canNavBack = getCurrentPages()
  209. //判断是否刷新了浏览器,刷新了浏览器,页面栈只有当前一个
  210. if (canNavBack && canNavBack.length > 1) {
  211. uni.navigateBack({
  212. delta: 1
  213. })
  214. } else {
  215. history.back()
  216. }
  217. },
  218. }
  219. };
  220. </script>
  221. <style lang="scss" scoped>
  222. .app-container {
  223. width: 100vw;
  224. //background: #fff;
  225. position: relative;
  226. height: 100vh;
  227. &-item {
  228. position: absolute;
  229. top: 44px;
  230. padding: 10px 0;
  231. width: calc(100%);
  232. box-sizing: border-box;
  233. .tourist-form {
  234. background: #fff;
  235. width: 100%;
  236. box-sizing: border-box;
  237. padding: 5px 20px;
  238. }
  239. }
  240. &-btn {
  241. position: fixed;
  242. bottom: 0;
  243. height: 80px;
  244. text-align: center;
  245. background: white;
  246. width: 100%;
  247. padding: 0 24px;
  248. box-sizing: border-box;
  249. .btn {
  250. width: 100%;
  251. border-top-right-radius: 25px !important;
  252. border-top-left-radius: 25px !important;
  253. border-bottom-left-radius: 25px !important;
  254. border-bottom-right-radius: 25px !important;
  255. }
  256. }
  257. }
  258. </style>