stayCheck.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  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. console.log(that.orderInfo)
  117. that.checkInPersonList = that.orderInfo.detailFormList[0].checkInPersonList;
  118. if (!that.checkInPersonList || that.checkInPersonList.length == 0) {
  119. that.checkInPersonList.push({
  120. cardType: 0,
  121. idCard: '',
  122. checkInPhone: '',
  123. checkInName: '',
  124. })
  125. }
  126. })
  127. uni.$emit('toSendData');
  128. },
  129. methods: {
  130. passengerConfirm(e, index) {
  131. this.checkInPersonList[index].cardType = e.value[0].value;
  132. this.show = false;
  133. },
  134. showCardChoose() {
  135. this.show = true
  136. },
  137. del(index) {
  138. if (this.checkInPersonList.length > 1) {
  139. this.checkInPersonList.splice(index, 1);
  140. }
  141. },
  142. addPerson() {
  143. this.checkInPersonList.push({
  144. checkInPhone: '',
  145. idCard: '',
  146. cardType: 0,
  147. checkInName: '',
  148. })
  149. },
  150. conform() {
  151. this.checkInPersonList.forEach((item) => {
  152. if (!item.checkInName) {
  153. this.$showToast('请输入姓名');
  154. return false
  155. }
  156. let checkInPhone = item.checkInPhone;
  157. if (checkInPhone.indexOf("**") > -1) {
  158. checkInPhone = checkInPhone.replace(/\*/g, "5");
  159. }
  160. if (!this.$u.test.mobile(checkInPhone)) {
  161. this.$showToast('请输入正确手机号');
  162. return false
  163. }
  164. let idCard = item.idCard;
  165. if (idCard.indexOf("**") > -1) {
  166. idCard = idCard.replace(/\*/g, "1");
  167. }
  168. if (!this.$u.test.idCard(idCard)) {
  169. this.$showToast('请输入正确身份证号');
  170. return false
  171. }
  172. })
  173. let list = this.checkInPersonList.filter((item) => item.idCard && item.checkInName && item.checkInPhone);
  174. if (list.length == 0) return;
  175. this.getOpenerEventChannel().emit('addSuccess', {
  176. 'data': list
  177. });
  178. uni.navigateBack();
  179. },
  180. }
  181. }
  182. </script>
  183. <style lang="scss">
  184. .page {
  185. padding-bottom: 260rpx;
  186. box-sizing: border-box;
  187. overflow-y: auto;
  188. overflow-x: auto;
  189. }
  190. .box {
  191. background-color: #fff;
  192. margin: 0 auto 20rpx;
  193. border-radius: 10rpx;
  194. width: 92%;
  195. padding: 0 30rpx;
  196. margin-top: 20rpx;
  197. border-bottom: 20rpx solid #F3F4F4;
  198. ;
  199. }
  200. .tit {
  201. font-size: 32rpx;
  202. font-weight: bold;
  203. color: #333;
  204. }
  205. .del {
  206. display: flex;
  207. justify-content: center;
  208. align-items: center;
  209. width: 100%;
  210. height: 102rpx;
  211. background-color: #fff;
  212. font-size: 30rpx
  213. }
  214. .addPerson {
  215. // margin: 0 auto ;
  216. width: 92%;
  217. height: 100rpx;
  218. margin-left: 30rpx;
  219. background-color: #fff;
  220. border-radius: 10rpx;
  221. display: flex;
  222. justify-content: center;
  223. align-items: center;
  224. font-size: 30rpx;
  225. color: #1372FF;
  226. }
  227. .btn-tbn {
  228. width: 100%;
  229. height: 136rpx;
  230. background-color: #fff;
  231. position: fixed;
  232. bottom: 0;
  233. padding: 30rpx;
  234. z-index: 999;
  235. }
  236. .yes {
  237. width: 690rpx;
  238. height: 96rpx;
  239. line-height: 96rpx;
  240. background-color: #1372FF;
  241. border-radius: 48rpx;
  242. // margin-left: 30rpx;
  243. color: #fff;
  244. font-size: 34rpx;
  245. text-align: center;
  246. // line-height: 96rpx;
  247. // margin-top: 200rpx;
  248. }
  249. .delete {
  250. display: flex;
  251. justify-content: center;
  252. align-items: center;
  253. }
  254. .personInfo {
  255. padding-left: 15rpx;
  256. display: flex;
  257. align-items: center;
  258. justify-content: space-between;
  259. }
  260. </style>