stayCheck.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  1. <template>
  2. <view class="page" :style="{'padding-top':mt+'px'}">
  3. <c-nav-bar title="添加入住人" :showIcon="true"></c-nav-bar>
  4. <u-form :model="form" ref="form">
  5. <view class="box" v-for="(item,index) in checkInPersonList" :key="index">
  6. <u-form-item label="姓名" prop="checkInName" label-width="172rpx" border-bottom>
  7. <u-input border="false" v-model="item.checkInName" placeholder="请输入姓名" />
  8. </u-form-item>
  9. <u-form-item label="手机号码" prop="checkInPhone" label-width="172rpx" border-bottom>
  10. <u-input border="false" v-model="item.checkInPhone" placeholder="请输入手机号" />
  11. </u-form-item>
  12. <u-form-item label="证件类型" label-width="172rpx" border-bottom @click.native="show=true">
  13. <view class="personInfo">
  14. <text style="font-size: 30rpx;">{{item.cardType|cardName}}</text>
  15. <u-picker :itemHeight="88" :immediateChange="true" :show="show" :columns="list" keyName="label"
  16. :defaultIndex="passengerDefault" @cancel="show=false;"
  17. @confirm="(e)=>passengerConfirm(e,index)"></u-picker>
  18. <u-icon name="arrow-right"></u-icon>
  19. </view>
  20. </u-form-item>
  21. <u-form-item label="证件号" prop="idCard" label-width="172rpx" border-bottom>
  22. <u-input border="false" v-model="item.idCard" placeholder="请输入证件号" />
  23. </u-form-item>
  24. <!-- <u-form-item label="民族" prop="nation" label-width="172rpx" border-bottom>
  25. <u-input border="false" v-model="item.nation" placeholder="请输入民族" />
  26. </u-form-item>
  27. <u-form-item label="地址" prop="address" label-width="172rpx" border-bottom>
  28. <u-input border="false" v-model="item.address" placeholder="请输入地址" />
  29. </u-form-item> -->
  30. <u-form-item class="delete" v-if="checkInPersonList.length>1">
  31. <view class="delete" @click="del(index)">
  32. <u-icon name="trash"></u-icon>
  33. <text style="font-size: 30rpx;">删除</text>
  34. </view>
  35. </u-form-item>
  36. </view>
  37. </u-form>
  38. <!-- 添加入住人 -->
  39. <view class="addPerson" @click="addPerson()">
  40. <u-icon name="plus" color="#2979ff"></u-icon>添加入住人
  41. </view>
  42. <!-- 按钮 -->
  43. <!-- 按钮 -->
  44. <view class="btn-tbn">
  45. <view class="yes" @click.native="conform">
  46. 确定
  47. </view>
  48. </view>
  49. </view>
  50. </template>
  51. <script>
  52. var that;
  53. export default {
  54. data() {
  55. return {
  56. checkInPersonList: [],
  57. passengerDefault: [0],
  58. orderInfo: [],
  59. orderId: null,
  60. show: false,
  61. list: [
  62. [{
  63. value: 0,
  64. label: '身份证'
  65. },
  66. {
  67. value: 1,
  68. label: '护照'
  69. },
  70. {
  71. value: 5,
  72. label: '台湾居民居住证'
  73. },
  74. {
  75. value: 6,
  76. label: '港澳居民居住证'
  77. }
  78. ]
  79. ],
  80. list2: [{
  81. value: 0,
  82. label: '身份证'
  83. },
  84. {
  85. value: 1,
  86. label: '护照'
  87. },
  88. {
  89. value: 5,
  90. label: '台湾居民居住证'
  91. },
  92. {
  93. value: 6,
  94. label: '港澳居民居住证'
  95. }
  96. ]
  97. }
  98. },
  99. filters: {
  100. cardName(val) {
  101. let item = that.list2.filter((item) => item.value == val);
  102. if (item[0]) {
  103. return item[0].label;
  104. } else {
  105. return ""
  106. }
  107. }
  108. },
  109. onUnload() {
  110. uni.$off('sendData');
  111. },
  112. onLoad(opt) {
  113. that = this;
  114. uni.$once('sendData', info => {
  115. that.orderInfo = info;
  116. that.checkInPersonList = that.deepClone(that.orderInfo.detailFormList[0].checkInPersonList)
  117. if (!that.checkInPersonList || that.checkInPersonList.length == 0) {
  118. that.checkInPersonList.push({
  119. cardType: 0,
  120. idCard: '',
  121. checkInPhone: '',
  122. checkInName: '',
  123. })
  124. }
  125. })
  126. uni.$emit('toSendData');
  127. },
  128. methods: {
  129. deepClone(obj, cache = new WeakMap()) {
  130. if (obj === null || typeof obj !== 'object') return obj;
  131. if (cache.has(obj)) return cache.get(obj);
  132. let clone;
  133. if (obj instanceof Date) {
  134. clone = new Date(obj.getTime());
  135. } else if (obj instanceof RegExp) {
  136. clone = new RegExp(obj);
  137. } else if (obj instanceof Map) {
  138. clone = new Map(Array.from(obj, ([key, value]) => [key, this.deepClone(value, cache)]));
  139. } else if (obj instanceof Set) {
  140. clone = new Set(Array.from(obj, value => this.deepClone(value, cache)));
  141. } else if (Array.isArray(obj)) {
  142. clone = obj.map(value => this.deepClone(value, cache));
  143. } else if (Object.prototype.toString.call(obj) === '[object Object]') {
  144. clone = Object.create(Object.getPrototypeOf(obj));
  145. cache.set(obj, clone);
  146. for (const [key, value] of Object.entries(obj)) {
  147. clone[key] = this.deepClone(value, cache);
  148. }
  149. } else {
  150. clone = Object.assign({}, obj);
  151. }
  152. cache.set(obj, clone);
  153. return clone;
  154. },
  155. passengerConfirm(e, index) {
  156. this.checkInPersonList[index].cardType = e.value[0].value;
  157. this.show = false;
  158. },
  159. showCardChoose() {
  160. this.show = true
  161. },
  162. del(index) {
  163. if (this.checkInPersonList.length > 1) {
  164. this.checkInPersonList.splice(index, 1);
  165. }
  166. },
  167. addPerson() {
  168. this.checkInPersonList.push({
  169. checkInPhone: '',
  170. idCard: '',
  171. cardType: 0,
  172. checkInName: '',
  173. })
  174. },
  175. conform() {
  176. this.checkInPersonList.forEach((item) => {
  177. if (!item.checkInName) {
  178. this.$showToast('请输入姓名');
  179. return false
  180. }
  181. let checkInPhone = item.checkInPhone;
  182. if (checkInPhone.indexOf("**") > -1) {
  183. checkInPhone = checkInPhone.replace(/\*/g, "5");
  184. }
  185. if (!this.$u.test.mobile(checkInPhone)) {
  186. this.$showToast('请输入正确手机号');
  187. return false
  188. }
  189. let idCard = item.idCard;
  190. if (idCard.indexOf("**") > -1) {
  191. idCard = idCard.replace(/\*/g, "1");
  192. }
  193. if (!this.$u.test.idCard(idCard)) {
  194. this.$showToast('请输入正确身份证号');
  195. return false
  196. }
  197. })
  198. let list = this.checkInPersonList.filter((item) => item.idCard && item.checkInName && item.checkInPhone);
  199. if (list.length == 0) return;
  200. this.getOpenerEventChannel().emit('addSuccess', {
  201. 'data': list
  202. });
  203. uni.navigateBack();
  204. },
  205. }
  206. }
  207. </script>
  208. <style lang="scss">
  209. .page {
  210. padding-bottom: 260rpx;
  211. box-sizing: border-box;
  212. overflow-y: auto;
  213. overflow-x: auto;
  214. }
  215. .box {
  216. background-color: #fff;
  217. margin: 0 auto 20rpx;
  218. border-radius: 10rpx;
  219. width: 92%;
  220. padding: 0 30rpx;
  221. margin-top: 20rpx;
  222. border-bottom: 20rpx solid #F3F4F4;
  223. ;
  224. }
  225. .tit {
  226. font-size: 32rpx;
  227. font-weight: bold;
  228. color: #333;
  229. }
  230. .del {
  231. display: flex;
  232. justify-content: center;
  233. align-items: center;
  234. width: 100%;
  235. height: 102rpx;
  236. background-color: #fff;
  237. font-size: 30rpx
  238. }
  239. .addPerson {
  240. // margin: 0 auto ;
  241. width: 92%;
  242. height: 100rpx;
  243. margin-left: 30rpx;
  244. background-color: #fff;
  245. border-radius: 10rpx;
  246. display: flex;
  247. justify-content: center;
  248. align-items: center;
  249. font-size: 30rpx;
  250. color: #1372FF;
  251. }
  252. .btn-tbn {
  253. width: 100%;
  254. height: 136rpx;
  255. background-color: #fff;
  256. position: fixed;
  257. bottom: 0;
  258. padding: 30rpx;
  259. z-index: 999;
  260. }
  261. .yes {
  262. width: 690rpx;
  263. height: 96rpx;
  264. line-height: 96rpx;
  265. background-color: #1372FF;
  266. border-radius: 48rpx;
  267. // margin-left: 30rpx;
  268. color: #fff;
  269. font-size: 34rpx;
  270. text-align: center;
  271. // line-height: 96rpx;
  272. // margin-top: 200rpx;
  273. }
  274. .delete {
  275. display: flex;
  276. justify-content: center;
  277. align-items: center;
  278. }
  279. .personInfo {
  280. padding-left: 15rpx;
  281. display: flex;
  282. align-items: center;
  283. justify-content: space-between;
  284. }
  285. </style>