bank.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. <template>
  2. <view class="content">
  3. <view class="box">
  4. <view class="item ">
  5. <text>姓名</text>
  6. <input type="text" value="" v-model="name" placeholder="请输入真实姓名" />
  7. </view>
  8. <view class="item top">
  9. <text>银行卡号</text>
  10. <input type="text" value="" v-model="id" placeholder="请输入银行卡账号" />
  11. </view>
  12. <view class="item">
  13. <text>所属银行</text>
  14. <input type="text" value="" v-model="idName" placeholder="请输入银行" />
  15. </view>
  16. </view>
  17. <button class="button" @click="confirm()">确认</button>
  18. </view>
  19. </template>
  20. <script>
  21. import { userEdit } from '@/api/set.js';
  22. import { orderData,getUserInfo } from '@/api/user.js';
  23. import { mapState, mapMutations } from 'vuex';
  24. export default {
  25. computed: {
  26. ...mapState('user', ['userInfo', 'orderInfo', 'hasLogin']),
  27. },
  28. data() {
  29. return {
  30. name:'',
  31. id:'',
  32. idName:''
  33. };
  34. },
  35. onLoad() {
  36. console.log(this.userInfo,'1111')
  37. if(this.userInfo.bank_code != null){
  38. this.id = this.userInfo.bank_code
  39. }
  40. if(this.userInfo.bank_name != null){
  41. this.idName = this.userInfo.bank_name
  42. }
  43. if(this.userInfo.bank_user_name != null){
  44. this.name = this.userInfo.bank_user_name
  45. }
  46. },
  47. methods:{
  48. ...mapMutations('user', ['setUserInfo', 'setOrderInfo']),
  49. confirm(){
  50. let obj = this;
  51. console.log(obj,'112');
  52. if(!obj.name){
  53. return this.$api.msg('请输入提款人姓名');
  54. }
  55. if(!obj.id){
  56. return this.$api.msg('请输入银行卡号')
  57. }
  58. if(!obj.idName){
  59. return this.$api.msg('请输入所属银行')
  60. }
  61. userEdit({
  62. bank_user_name:obj.name,
  63. bank_name:obj.idName,
  64. bank_code:obj.id
  65. }).then(e=>{
  66. return this.$api.msg('修改成功')
  67. obj.getUserInfo();
  68. })
  69. },
  70. // 更新用户信息
  71. getUserInfo() {
  72. getUserInfo({})
  73. .then(({ data }) => {
  74. console.log(data)
  75. this.setUserInfo(data);
  76. // 获取用户数据完毕后在获取订单数据防止多次跳转到登录页
  77. orderData({})
  78. .then(({ data }) => {
  79. this.setOrderInfo(data);
  80. uni.navigateBack({
  81. delta: 1
  82. });
  83. })
  84. .catch(e => {
  85. this.setOrderInfo({
  86. complete_count: 0, //完成
  87. received_count: 0, //待收货
  88. unshipped_count: 0, //待发货
  89. order_count: 0, //订单总数
  90. unpaid_count: 0 //待付款
  91. });
  92. });
  93. })
  94. .catch(e => {
  95. console.log(e);
  96. });
  97. },
  98. }
  99. }
  100. </script>
  101. <style lang="scss">
  102. page , .content{
  103. height: 100%;
  104. padding: 0;
  105. margin: 0;
  106. }
  107. .top{
  108. border-top: 1rpx solid #F3F3F3;
  109. border-bottom: 1rpx solid #F3F3F3;
  110. }
  111. .box{
  112. background: #FFFFFF;
  113. margin: 20rpx 0 70rpx 0;
  114. .item{
  115. display: flex;
  116. align-items: center;
  117. text{
  118. margin: 0 40rpx 0 25rpx;
  119. width: 150rpx;
  120. font-size: 30rpx;
  121. font-family: PingFang SC;
  122. font-weight: 400;
  123. color: #333333;
  124. line-height: 100rpx;
  125. }
  126. input{
  127. font-size: 28rpx;
  128. font-family: PingFang SC;
  129. font-weight: 400;
  130. color: #999999;
  131. line-height: 100rpx;
  132. }
  133. }
  134. }
  135. .button{
  136. text-align: center;
  137. width: 560rpx;
  138. height: 80rpx;
  139. background: linear-gradient(90deg, #44BFEC, #438BED);
  140. border-radius: 40rpx;
  141. font-size: 30rpx;
  142. font-family: PingFangSC;
  143. font-weight: 500;
  144. color: #FFFFFF;
  145. line-height: 80rpx;
  146. }
  147. </style>