index.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. <template>
  2. <view class="index-content" :style="{'--status-bar-': statusBarHeight}">
  3. <view class="index-content-info">
  4. <!-- 头部主要内容 开始 -->
  5. <view class="index-content-header">
  6. <customNavbar
  7. :title="title"
  8. bgColor="rgba(0,0,0,0)"
  9. :is-left="true"
  10. :customNavbarInfo='{}'
  11. :leftStyle="{ color: '#fff' }"
  12. >
  13. </customNavbar>
  14. </view>
  15. <!-- 头部主要内容 结束 -->
  16. <view style="padding: 30rpx;">
  17. <u--form labelPosition="left" :model="form" :rules="rules" labelWidth='100' ref="uForm">
  18. <u-form-item label="真实姓名" prop="name" borderBottom>
  19. <u--input v-model="form.name" border="none"></u--input>
  20. </u-form-item>
  21. <u-form-item label="开户行" prop="bankName" borderBottom>
  22. <u--input v-model="form.bankName" border="none"></u--input>
  23. </u-form-item>
  24. <u-form-item label="银行卡号" prop="bankNo" borderBottom>
  25. <u--input v-model="form.bankNo" border="none"></u--input>
  26. </u-form-item>
  27. <u-form-item label="开户行" prop="openBankName" borderBottom>
  28. <u--input v-model="form.openBankName" border="none"></u--input>
  29. </u-form-item>
  30. </u--form>
  31. </view>
  32. <view style="padding: 30rpx;">
  33. <u-button type="primary" @click="insertOrUpdateFun()" text="提交"></u-button>
  34. </view>
  35. </view>
  36. </view>
  37. </template>
  38. <script>
  39. export default {
  40. data() {
  41. return {
  42. title: '我的银行卡',
  43. loading: false,
  44. statusBarHeight: 0, // 状态栏安全距离
  45. form: {
  46. "id": "",
  47. "name": "",
  48. "moblie": "",
  49. "bankName": "",
  50. "bankNo": "",
  51. "openBankName": ""
  52. },
  53. rules: {
  54. 'name': {
  55. type: 'string',
  56. required: true,
  57. message: '请输入姓名',
  58. trigger: ['blur', 'change']
  59. },
  60. 'moblie': {
  61. type: 'string',
  62. required: true,
  63. message: '请输入手机号',
  64. trigger: ['blur', 'change']
  65. },
  66. 'bankName': {
  67. type: 'string',
  68. required: true,
  69. message: '请输入银行名称',
  70. trigger: ['blur', 'change']
  71. },
  72. 'bankNo': {
  73. type: 'string',
  74. required: true,
  75. message: '请输入银行卡号',
  76. trigger: ['blur', 'change']
  77. },
  78. 'openBankName': {
  79. type: 'string',
  80. required: true,
  81. message: '请输入开户行',
  82. trigger: ['blur', 'change']
  83. },
  84. },
  85. }
  86. },
  87. onLoad() {
  88. this.getRetailQrcode()
  89. },
  90. onShow() {
  91. this.statusBarHeight = getApp().globalData.statusBarHeight
  92. //this.load()
  93. },
  94. methods: {
  95. /**
  96. * 获取 我的银行卡
  97. */
  98. async getRetailQrcode() {
  99. try {
  100. uni.showLoading({
  101. title: "获取银行卡中..."
  102. })
  103. let res = await this.$u.api.getPersonsBankApi({
  104. userid: this.distribution_user_info.userId
  105. })
  106. uni.hideLoading()
  107. if (res && res.code === 200) {
  108. this.form = {
  109. "id": res.data.id,
  110. "name": res.data.name,
  111. "moblie": res.data.moblie,
  112. "bankName": res.data.bankName,
  113. "bankNo": res.data.bankNo,
  114. "openBankName": res.data.openBankName
  115. }
  116. }
  117. } catch (e) {
  118. //TODO handle the exception
  119. console.error("e===", e)
  120. uni.hideLoading()
  121. }
  122. },
  123. /**
  124. * 提交 我的银行卡
  125. */
  126. async insertOrUpdateFun() {
  127. this.$refs.uForm.validate().then(async res => {
  128. try {
  129. uni.showLoading({
  130. title: "提交数据中..."
  131. })
  132. let res = await this.$u.api.insertOrUpdateApi({...this.form})
  133. uni.hideLoading()
  134. if (res && res.code === 200) {
  135. uni.showToast({
  136. title: "绑定成功!!!",
  137. duration: 2000
  138. })
  139. setTimeout(()=>{
  140. this.getRetailQrcode()
  141. },2000)
  142. }
  143. this.loading = false
  144. } catch (e) {
  145. uni.hideLoading()
  146. uni.showToast({
  147. title: "绑定失败!!!"
  148. })
  149. //TODO handle the exception
  150. console.error("e===", e)
  151. this.loading = false
  152. }
  153. }).catch(errors => {
  154. })
  155. },
  156. }
  157. }
  158. </script>
  159. <style lang="scss" scoped>
  160. .index-content {
  161. display: flex;
  162. flex-direction: column;
  163. align-items: center;
  164. justify-content: center;
  165. box-sizing: border-box;
  166. // background-color:
  167. .index-content-info {
  168. width: 100%;
  169. box-sizing: border-box;
  170. }
  171. }
  172. /** 头部主要内容 开始 */
  173. .index-content-header {
  174. width: 100%;
  175. box-sizing: border-box;
  176. background-color: var(--gd-bgm-color);
  177. ::v-deep .u-search {
  178. padding: 0 30rpx !important;
  179. }
  180. ::v-deep .u-search__action {
  181. color: #fff !important;
  182. }
  183. }
  184. /** 头部主要内容 结束 **/
  185. </style>