zfb.vue 2.8 KB

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