add.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. <template>
  2. <view class="add">
  3. <view class="tips">
  4. 提醒:姓名与身份证一致,否则会影响出游
  5. </view>
  6. <view class="card">
  7. <view class="form-item">
  8. <view class="label">姓名</view>
  9. <u--input customStyle="input" placeholder="请输入姓名" v-model="form.userName" border="none"></u--input>
  10. </view>
  11. <view class="form-item" @click="show = true">
  12. <view class="label">证件类型</view>
  13. <u--input customStyle="input" readonly placeholder="请选择证件类型" value="身份证" border="none"></u--input>
  14. </view>
  15. <view class="form-item">
  16. <view class="label">证件号码</view>
  17. <u--input customStyle="input" :maxlength="18" placeholder="请输入姓名" v-model="form.idCard"
  18. border="none"></u--input>
  19. </view>
  20. <view class="form-item">
  21. <view class="label">手机号码</view>
  22. <u--input customStyle="input" :maxlength="11" placeholder="请输入号码" type="idcard" v-model="form.phone"
  23. border="none"></u--input>
  24. </view>
  25. <view class="form-item" @click="showSex = true">
  26. <view class="label">性别</view>
  27. <u--input customStyle="input" readonly placeholder="请选择性别" v-model="sexLabel" border="none"></u--input>
  28. </view>
  29. </view>
  30. <view class="buy-box">
  31. <button :loading="loading" class="buy-btn" type="default" @click="handleAdd">确定</button>
  32. </view>
  33. <u-action-sheet :closeOnClickOverlay="true" @close="show = false" :closeOnClickAction="true" cancelText="取消"
  34. :actions="option" :show="show"></u-action-sheet>
  35. <u-action-sheet :closeOnClickOverlay="true" @close="showSex = false" :closeOnClickAction="true" cancelText="取消"
  36. :actions="sexOption" @select="select" :show="showSex"></u-action-sheet>
  37. </view>
  38. </template>
  39. <script>
  40. import { saveTraveler } from "@/api/study"
  41. export default {
  42. data() {
  43. return {
  44. option: [
  45. {
  46. name: '身份证',
  47. },
  48. ],
  49. sexOption: [
  50. {
  51. name: '男',
  52. },
  53. {
  54. name: '女',
  55. },
  56. ],
  57. form: {
  58. id: '',
  59. idCard: '',
  60. cardType: '1',
  61. phone: '',
  62. sex: '',
  63. userId: '',
  64. userName: ''
  65. },
  66. sexLabel: '',
  67. show: false,
  68. showSex: false,
  69. loading:false
  70. };
  71. },
  72. methods: {
  73. select({ name }) {
  74. this.sexLabel = name
  75. this.form.sex = name == "男" ? 1 : 2
  76. },
  77. handleAdd() {
  78. this.loading = true
  79. saveTraveler(this.form).then(res => {
  80. this.loading = false
  81. if (res.state == 'Success') {
  82. uni.showToast({
  83. title: '完成',
  84. icon: 'none'
  85. });
  86. uni.navigateBack({
  87. delta: 1
  88. });
  89. }
  90. })
  91. }
  92. },
  93. };
  94. </script>
  95. <style lang="scss" scoped>
  96. .add {
  97. background: #F9F9F9;
  98. min-height: 100vh;
  99. padding: 0 20rpx;
  100. }
  101. .tips {
  102. color: #AAAAAA;
  103. font-size: 28rpx;
  104. padding: 28rpx 0;
  105. }
  106. .card {
  107. padding: 24rpx;
  108. background: #FFFFFF;
  109. border-radius: 16rpx;
  110. .form-item {
  111. border-top: 1px solid #F0F0F0;
  112. display: flex;
  113. &:first-child {
  114. border-top: none;
  115. }
  116. .label {
  117. color: #222222;
  118. font-size: 24rpx;
  119. margin: 24rpx 0;
  120. width: 152rpx;
  121. }
  122. .input {}
  123. }
  124. }
  125. .buy-box {
  126. position: fixed;
  127. bottom: 0%;
  128. left: 0%;
  129. width: 100%;
  130. background: #fff;
  131. padding: 10rpx 24rpx env(safe-area-inset-bottom);
  132. box-sizing: border-box;
  133. .buy-btn {
  134. width: 702rpx;
  135. height: 80rpx;
  136. line-height: 80rpx;
  137. text-align: center;
  138. background: #3B83FF;
  139. border-radius: 40rpx;
  140. font-weight: 600;
  141. font-size: 28rpx;
  142. color: #FFFFFF;
  143. }
  144. }
  145. </style>