receiving-account-form.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. <template>
  2. <view class="receiving-account-form-container">
  3. <JHeader width="50" height="50" title="收款账户表单"></JHeader>
  4. <FieldPaneRA v-model="form.basicInfo" :fields="applyOne" title="账户信息"></FieldPaneRA>
  5. <view class="buts">
  6. <button class="btn" @click="submit()">
  7. 提交
  8. </button>
  9. </view>
  10. </view>
  11. </template>
  12. <script>
  13. import FieldPaneRA from './components/field-pane-ra.vue'
  14. import { getByIdBankApi, updateBankUpdateApi, addBankSaveApi } from '../../../api/anotherTFInterface'
  15. export default {
  16. name: 'ReceivingAccountForm',
  17. components: {
  18. FieldPaneRA
  19. },
  20. onLoad(options) {
  21. if (Number(options.isEdit)) {
  22. this.getBankMessage()
  23. }
  24. },
  25. data() {
  26. return {
  27. applyOne: [
  28. {
  29. label: '持卡人姓名:',
  30. field: 'cardName',
  31. type: 'input',
  32. placeholder: '请填写持卡人姓名'
  33. },
  34. {
  35. label: '卡号:',
  36. field: 'cardNumber',
  37. type: 'input',
  38. placeholder: '请填写卡号'
  39. },
  40. {
  41. label: '银行:',
  42. field: 'bank',
  43. type: 'select'
  44. },
  45. {
  46. label: '注册手机号:',
  47. field: 'phone',
  48. type: 'input',
  49. placeholder: '请填写注册手机号'
  50. },
  51. {
  52. label: '验证码:',
  53. field: 'code',
  54. type: 'input',
  55. placeholder: '请填写验证码'
  56. }
  57. ],
  58. form: {
  59. basicInfo: {
  60. cardName: '',
  61. cardNumber: '',
  62. bank: '',
  63. phone: '',
  64. code: ''
  65. }
  66. }
  67. }
  68. },
  69. methods: {
  70. // 获取收款账户信息
  71. async getBankMessage() {
  72. uni.showLoading()
  73. const res = await getByIdBankApi({})
  74. uni.hideLoading()
  75. if (res.data) {
  76. this.form.basicInfo.cardName = res.data.cardName || ''
  77. this.form.basicInfo.cardNumber = res.data.cardNumber || ''
  78. this.form.basicInfo.bank = res.data.bank || ''
  79. this.form.basicInfo.phone = res.data.phone || ''
  80. }
  81. },
  82. // 点击提交按钮
  83. submit() {
  84. const data = {
  85. ...this.form.basicInfo
  86. }
  87. console.log(data)
  88. if (!data.cardName) {
  89. this.$showToast('缺少持卡人姓名')
  90. return
  91. }
  92. if (!data.cardNumber) {
  93. this.$showToast('缺少卡号')
  94. return
  95. }
  96. if (!(/^([1-9]{1})(\d{15}|\d{18})$/).test(data.cardNumber)) {
  97. this.$showToast('卡号格式错误')
  98. return
  99. }
  100. if (!data.bank) {
  101. this.$showToast('缺少银行信息')
  102. return
  103. }
  104. if (!data.phone) {
  105. this.$showToast('缺少手机号')
  106. return
  107. }
  108. if (!data.code) {
  109. this.$showToast('缺少验证码')
  110. return
  111. }
  112. if (!(/^1[3-9]\d{9}$/).test(data.phone)) {
  113. this.$showToast('手机号格式错误')
  114. return
  115. }
  116. uni.showModal({
  117. title: '提示',
  118. content: '确认提交收款账户表单?',
  119. success: (res) => {
  120. if (res.confirm) {
  121. if (data.id) {
  122. updateBankUpdateApi(data).then((res) => {
  123. this.$showToast('提交成功')
  124. setTimeout(() => {
  125. uni.navigateBack()
  126. }, 2000)
  127. })
  128. } else {
  129. addBankSaveApi(data).then((res) => {
  130. this.$showToast('提交成功')
  131. setTimeout(() => {
  132. uni.navigateBack()
  133. }, 2000)
  134. })
  135. }
  136. }
  137. }
  138. })
  139. }
  140. }
  141. }
  142. </script>
  143. <style lang="less" scoped>
  144. .receiving-account-form-container {
  145. padding: 40upx 40upx 140upx 40upx;
  146. box-sizing: border-box;
  147. .buts {
  148. position: fixed;
  149. bottom: -1px;
  150. z-index: 2;
  151. padding: 20upx 40upx;
  152. left: 0;
  153. display: flex;
  154. justify-content: center;
  155. align-items: center;
  156. background-color: #fff;
  157. width: 100%;
  158. box-sizing: border-box;
  159. margin-top: 272upx;
  160. }
  161. .btn {
  162. display: flex;
  163. justify-content: center;
  164. align-items: center;
  165. height: 72upx;
  166. width: 306upx;
  167. font-size: 32upx;
  168. color: #fff;
  169. margin: 0;
  170. background-color: #07b9b9;
  171. border-radius: 100px;
  172. &:last-child {
  173. background-color: #fa5151;
  174. }
  175. }
  176. }
  177. </style>