addBankCard.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. <template>
  2. <view class="container">
  3. <navbar :config="config" backColor="#666666"></navbar>
  4. <form @submit="formSubmit">
  5. <view class="bg-fff">
  6. <view class="u-plr30">
  7. <!-- :value="index" -->
  8. <picker @change="bindPickerChange" range-key="name" :range="bankCardList">
  9. <view class="uni-form-item u-flex u-border-one-one">
  10. <view class="title u-font28 u-1A1A1A">银行卡名称:</view>
  11. <input class="uni-input u-font26" name="bank_name" disabled :value="dataform.bank_name" placeholder="请选择银行卡" />
  12. </view>
  13. </picker>
  14. <view class="uni-form-item u-flex u-border-one-one">
  15. <view class="title u-font28 u-1A1A1A">银行账号:</view>
  16. <input class="uni-input u-font26"type="number" maxlength="30" name="card_num" :value="dataform.card_num" placeholder="请输入银行账号" />
  17. </view>
  18. <view class="uni-form-item u-flex u-border-one-one">
  19. <view class="title u-font28 u-1A1A1A">预留银行卡的姓名:</view>
  20. <input class="uni-input u-font26" name="name" :value="dataform.name" placeholder="请输入预留银行卡的姓名" />
  21. </view>
  22. <view class="uni-form-item u-flex">
  23. <view class="title u-font28 u-1A1A1A">预留银行卡的手机号:</view>
  24. <input class="uni-input u-font26" type="number" maxlength="11" name="mobile" :value="dataform.mobile" placeholder="请输入预留银行卡的手机号" />
  25. </view>
  26. </view>
  27. </view>
  28. <view class="uni-btn-v mt216 u-plr30">
  29. <button form-type="submit" class="u-btn">确认</button>
  30. </view>
  31. </form>
  32. </view>
  33. </template>
  34. <script>
  35. export default {
  36. data() {
  37. return {
  38. config: {
  39. back: true, //false是tolbar页面 是则不写
  40. title: '银行卡',
  41. color: '#1A1A1A',
  42. //背景颜色;参数一:透明度(0-1);参数二:背景颜色(array则为线性渐变,string为单色背景)
  43. backgroundColor: [1, "#FFFFFF"],
  44. statusBarFontColor: '#1A1A1A'
  45. },
  46. dataform:{
  47. bank_name:'',
  48. icon:'',
  49. card_num:'',
  50. name:'',
  51. mobile:'',
  52. },
  53. bankCardList:[] // 银行卡列表
  54. }
  55. },
  56. onLoad(options) {
  57. if(options.item){
  58. let itemData = JSON.parse(decodeURIComponent(options.item))
  59. this.dataform.id = itemData.id
  60. this.dataform.mobile = itemData.mobile
  61. this.dataform.name = itemData.name
  62. this.dataform.card_num = itemData.card_num
  63. this.dataform.icon = itemData.icon
  64. this.dataform.bank_name = itemData.bank_name
  65. }
  66. //获取银行卡列表
  67. this.$http.get('/bankcard/icon/select',).then(res => {
  68. if(res&&res.code==200){
  69. this.bankCardList=res.list
  70. }
  71. })
  72. },
  73. methods: {
  74. bindPickerChange(e){
  75. let index = e.detail.value;
  76. this.dataform.bank_name = this.bankCardList[index].name
  77. this.dataform.icon = this.bankCardList[index].icon
  78. },
  79. //点击确定
  80. formSubmit: function(e) {
  81. let that = this;
  82. let target = e.detail.value;
  83. if(!target.bank_name){
  84. this.$mUtil.toast('请选择银行卡')
  85. return false
  86. }
  87. if(!target.card_num){
  88. this.$mUtil.toast('请输入银行账号')
  89. return false
  90. }
  91. if(!target.name){
  92. this.$mUtil.toast('请输入预留银行卡的姓名')
  93. return false
  94. }
  95. if(!target.mobile){
  96. this.$mUtil.toast('请输入预留银行卡的手机号')
  97. return false
  98. }
  99. if(!target.mobile.match(this.$mConfig.telRegex)){
  100. this.$mUtil.toast('请输入正确手机号')
  101. return false
  102. }
  103. this.dataform.card_num = target.card_num
  104. this.dataform.name = target.name
  105. this.dataform.mobile = target.mobile
  106. this.$http.post('/member/bankcard/save',this.dataform).then(res => {
  107. if(res&&res.code==200){
  108. uni.showToast({
  109. title:"添加成功",
  110. icon:"none",
  111. duration:3000,
  112. success() {
  113. let pages = getCurrentPages(); // 当前页面
  114. let beforePage = pages[pages.length - 2]; // 前一个页面
  115. //app需要加$vm
  116. uni.navigateBack({
  117. success: function() {
  118. beforePage.$vm.getAccountMsg(); // 执行前一个页面的onLoad方法
  119. beforePage.$vm.getBankCardList();//执行上一个页面的两个方法
  120. }
  121. });
  122. }
  123. })
  124. }
  125. })
  126. }
  127. }
  128. }
  129. </script>
  130. <style lang="scss">
  131. page{
  132. background-color: #F5F5F5;
  133. }
  134. .title{
  135. width: 330rpx;
  136. }
  137. .bg-fff{
  138. background-color: #FFFFFF;
  139. }
  140. .uni-form-item{
  141. height: 104rpx;
  142. line-height: 104rpx;
  143. }
  144. .uni-input{
  145. height: 104rpx;
  146. width: 70%;
  147. line-height: 110rpx;
  148. }
  149. .ml40{
  150. margin-left: 40rpx;
  151. }
  152. .mt216{
  153. margin-top: 216rpx;
  154. display: flex;
  155. justify-content: center;
  156. }
  157. </style>