bank.vue 3.1 KB

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