zfb.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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 { userEdit } from '@/api/set.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. userEdit({
  49. alipay_name: obj.name,
  50. alipay_code: obj.id
  51. })
  52. .then(e => {
  53. obj.$api.msg('修改成功');
  54. obj.getUserInfo();
  55. })
  56. .catch(e => {
  57. console.log(e);
  58. });
  59. },
  60. // 更新用户信息
  61. getUserInfo() {
  62. getUserInfo({})
  63. .then(({ data }) => {
  64. console.log(data)
  65. this.setUserInfo(data);
  66. // 获取用户数据完毕后在获取订单数据防止多次跳转到登录页
  67. orderData({})
  68. .then(({ data }) => {
  69. this.setOrderInfo(data);
  70. uni.navigateBack({
  71. delta: 1
  72. });
  73. })
  74. .catch(e => {
  75. this.setOrderInfo({
  76. complete_count: 0, //完成
  77. received_count: 0, //待收货
  78. unshipped_count: 0, //待发货
  79. order_count: 0, //订单总数
  80. unpaid_count: 0 //待付款
  81. });
  82. });
  83. })
  84. .catch(e => {
  85. console.log(e);
  86. });
  87. },
  88. }
  89. };
  90. </script>
  91. <style lang="scss">
  92. page,
  93. .content {
  94. height: 100%;
  95. padding: 0;
  96. margin: 0;
  97. }
  98. .top {
  99. border-bottom: 1rpx solid #f3f3f3;
  100. }
  101. .box {
  102. background: #ffffff;
  103. margin: 20rpx 0 70rpx 0;
  104. .item {
  105. display: flex;
  106. align-items: center;
  107. text {
  108. margin: 0 40rpx 0 25rpx;
  109. width: 150rpx;
  110. font-size: 30rpx;
  111. font-family: PingFang SC;
  112. font-weight: 400;
  113. color: #333333;
  114. line-height: 100rpx;
  115. }
  116. input {
  117. font-size: 28rpx;
  118. font-family: PingFang SC;
  119. font-weight: 400;
  120. color: #999999;
  121. line-height: 100rpx;
  122. }
  123. }
  124. }
  125. .button {
  126. text-align: center;
  127. width: 560rpx;
  128. height: 80rpx;
  129. background: #5dbc7c;
  130. border-radius: 40rpx;
  131. font-size: 30rpx;
  132. font-family: PingFangSC;
  133. font-weight: 500;
  134. color: #ffffff;
  135. line-height: 80rpx;
  136. margin: 0 auto;
  137. }
  138. </style>