addBankCard.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  1. <template>
  2. <view class="container">
  3. <!-- 表单区域 -->
  4. <scroll-view class="content" scroll-y>
  5. <view class="form-section">
  6. <view class="form-item">
  7. <view class="form-label">开户行</view>
  8. <input
  9. class="form-input"
  10. v-model="formData.bankName"
  11. placeholder="请输入开户行"
  12. placeholder-class="text-placeholder"
  13. />
  14. </view>
  15. <view class="divider"></view>
  16. <view class="form-item">
  17. <view class="form-label">支行</view>
  18. <input
  19. class="form-input"
  20. v-model="formData.bankBranch"
  21. placeholder="请输入支行"
  22. placeholder-class="text-placeholder"
  23. />
  24. </view>
  25. <view class="divider"></view>
  26. <view class="form-item">
  27. <view class="form-label">银行卡号</view>
  28. <input
  29. class="form-input "
  30. v-model="formData.bankCardNo"
  31. placeholder="请输入银行卡号"
  32. type="number"
  33. maxlength="19"
  34. placeholder-class="text-placeholder"
  35. />
  36. </view>
  37. </view>
  38. <!-- 注意事项 -->
  39. <view class="notes-section">
  40. <view class="notes-title">注意:</view>
  41. <view class="notes-item">1、只能绑定认证用户本人的银行卡;</view>
  42. <view class="notes-item">2、每次更换次数不得超过三次。</view>
  43. </view>
  44. </scroll-view>
  45. <!-- 底部按钮 -->
  46. <view class="bottom-bar">
  47. <view class="submit-btn" @click="handleSubmit">确认添加</view>
  48. </view>
  49. </view>
  50. </template>
  51. <script>
  52. import { addBankCard } from '@/api/bankCard'
  53. export default {
  54. data() {
  55. return {
  56. formData: {
  57. "bankBranch": "",
  58. "bankCardNo": "",
  59. "bankName": ""
  60. }
  61. }
  62. },
  63. onLoad() {},
  64. methods: {
  65. goBack() {
  66. uni.navigateBack()
  67. },
  68. async handleSubmit() {
  69. // 表单验证
  70. if (!this.formData.bankName || !this.formData.bankName.trim()) {
  71. uni.showToast({
  72. icon: 'none',
  73. title: '请输入开户行'
  74. })
  75. return
  76. }
  77. if (!this.formData.bankBranch || !this.formData.bankBranch.trim()) {
  78. uni.showToast({
  79. icon: 'none',
  80. title: '请输入支行'
  81. })
  82. return
  83. }
  84. if (!this.formData.bankCardNo) {
  85. uni.showToast({
  86. icon: 'none',
  87. title: '请输入银行卡号'
  88. })
  89. return
  90. }
  91. // 银行卡号验证(简单验证)
  92. if (this.formData.bankCardNo.length < 16) {
  93. uni.showToast({
  94. icon: 'none',
  95. title: '请输入正确的银行卡号'
  96. })
  97. return
  98. }
  99. // uni.navigateTo({
  100. // url: '/pages_user/editBankCard'
  101. // })
  102. try {
  103. uni.showLoading({ title: '添加中...' })
  104. const res = await addBankCard(this.formData)
  105. uni.hideLoading()
  106. if (res.code === 200) {
  107. uni.showToast({
  108. icon: 'success',
  109. title: '添加成功'
  110. })
  111. setTimeout(() => {
  112. uni.navigateBack()
  113. }, 1500)
  114. } else {
  115. uni.showToast({
  116. icon: 'none',
  117. title: res.msg || '添加失败'
  118. })
  119. }
  120. } catch (e) {
  121. uni.hideLoading()
  122. uni.showToast({
  123. icon: 'none',
  124. title: '添加失败'
  125. })
  126. }
  127. }
  128. }
  129. }
  130. </script>
  131. <style lang="stylus">
  132. .text-placeholder{
  133. color: #C8C9CC !important;
  134. }
  135. </style>
  136. <style lang="scss" scoped>
  137. .container {
  138. // min-height: 100vh;
  139. background: #f5f5f5;
  140. display: flex;
  141. flex-direction: column;
  142. }
  143. .navbar {
  144. display: flex;
  145. align-items: center;
  146. justify-content: space-between;
  147. padding: 20rpx 24rpx;
  148. background: #fff;
  149. border-bottom: 1rpx solid #f0f0f0;
  150. .nav-left {
  151. width: 60rpx;
  152. .back-icon {
  153. font-size: 36rpx;
  154. color: #333;
  155. font-weight: bold;
  156. }
  157. }
  158. .nav-title {
  159. flex: 1;
  160. text-align: center;
  161. font-size: 36rpx;
  162. font-weight: bold;
  163. color: #333;
  164. }
  165. .nav-right {
  166. display: flex;
  167. align-items: center;
  168. gap: 24rpx;
  169. width: 60rpx;
  170. justify-content: flex-end;
  171. .more-icon {
  172. font-size: 32rpx;
  173. color: #333;
  174. }
  175. .eye-icon {
  176. font-size: 32rpx;
  177. color: #333;
  178. }
  179. }
  180. }
  181. .content {
  182. // flex: 1;
  183. // padding-bottom: 140rpx;
  184. }
  185. .form-section {
  186. background: #fff;
  187. // margin: 24rpx;
  188. // border-radius: 16rpx;
  189. overflow: hidden;
  190. .form-item {
  191. display: flex;
  192. align-items: center;
  193. justify-content: space-between;
  194. padding: 28rpx 32rpx;
  195. // min-height: 100rpx
  196. .form-label {
  197. font-family: PingFang SC, PingFang SC;
  198. font-weight: 400;
  199. font-size: 28rpx;
  200. color: #666666;
  201. width: 150rpx;
  202. }
  203. .form-input {
  204. flex: 1;
  205. font-size: 28rpx;
  206. color: #333;
  207. text-align: right;
  208. margin-left: 24rpx;
  209. &.picker-input {
  210. display: flex;
  211. align-items: center;
  212. justify-content: flex-end;
  213. .arrow-right {
  214. font-size: 32rpx;
  215. color: #999;
  216. margin-left: 8rpx;
  217. }
  218. }
  219. }
  220. }
  221. // placeholder 样式(需要独立定义,不能嵌套)
  222. .placeholder {
  223. color: #C8C9CC !important;
  224. }
  225. .divider {
  226. height: 1rpx;
  227. background: #EBEDF0;
  228. margin-left: 24rpx;
  229. }
  230. }
  231. .notes-section {
  232. // background: #fff;
  233. // border-radius: 16rpx;
  234. padding: 22rpx 32rpx;
  235. // margin: 0 24rpx 24rpx;
  236. .notes-title {
  237. font-family: PingFang SC, PingFang SC;
  238. font-weight: 400;
  239. font-size: 28rpx;
  240. color: #999999;
  241. line-height: 40rpx;
  242. }
  243. .notes-item {
  244. font-family: PingFang SC, PingFang SC;
  245. font-weight: 400;
  246. font-size: 28rpx;
  247. color: #999999;
  248. line-height: 40rpx;
  249. }
  250. }
  251. .bottom-bar {
  252. padding: 32rpx;
  253. .submit-btn {
  254. width: 100%;
  255. height: 88rpx;
  256. background: #388BFF;
  257. border-radius: 44rpx;
  258. display: flex;
  259. align-items: center;
  260. justify-content: center;
  261. font-size: 32rpx;
  262. font-weight: bold;
  263. color: #fff;
  264. }
  265. }
  266. </style>