zfb.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. <template>
  2. <view class="content">
  3. <view class="box">
  4. <view class="item top">
  5. <text>真实姓名</text>
  6. <input type="text" value="" v-model="name" placeholder="请输入真实姓名" />
  7. </view>
  8. <view class="item">
  9. <text>支付宝账号</text>
  10. <input type="text" value="" v-model="id" placeholder="请输入支付宝账号" />
  11. </view>
  12. </view>
  13. <button class="button" type="default" @click="confirm()">确认</button>
  14. </view>
  15. </template>
  16. <script>
  17. import {
  18. orderData,
  19. getUserInfo
  20. } from '@/api/user.js';
  21. import {
  22. mapState,
  23. mapMutations
  24. } from 'vuex';
  25. import {
  26. userEdit
  27. } from '@/api/set.js';
  28. export default {
  29. data() {
  30. return {
  31. name: '',
  32. id: ''
  33. }
  34. },
  35. computed: {
  36. //mapState使用时需要先导入mapState辅助函数 import{ mapState} from 'vuex'
  37. ...mapState('user', ['userInfo', 'orderInfo', 'hasLogin'])
  38. },
  39. onLoad() {
  40. console.log(this.userInfo)
  41. if (this.userInfo.alipay_code != null) {
  42. this.id = this.userInfo.alipay_code
  43. }
  44. if (this.userInfo.alipay_name != null) {
  45. this.name = this.userInfo.alipay_name
  46. }
  47. },
  48. methods: {
  49. //缓存信息
  50. ...mapMutations('user', ['setUserInfo', 'setOrderInfo']),
  51. confirm() {
  52. let obj = this
  53. if (!obj.name) {
  54. return this.$api.msg("请输入提款人姓名")
  55. }
  56. if (!obj.id) {
  57. return this.$api.msg('请输入支付宝账号')
  58. }
  59. userEdit({
  60. alipay_name: obj.name,
  61. alipay_code: obj.id
  62. }).then(e => {
  63. obj.$api.msg('修改成功')
  64. obj.getUserInfo();
  65. }).catch(e=>{
  66. console.log(e);
  67. })
  68. },
  69. getUserInfo() {
  70. getUserInfo({}).then(({data})=>{
  71. console.log(data)
  72. this.setUserInfo(data)
  73. })
  74. }
  75. }
  76. }
  77. </script>
  78. <style lang="scss">
  79. page,
  80. .content {
  81. height: 100%;
  82. padding: 0;
  83. margin: 0;
  84. }
  85. .top {
  86. border-bottom: 1rpx solid #F3F3F3;
  87. }
  88. .box {
  89. background: #FFFFFF;
  90. margin: 20rpx 0 70rpx 0;
  91. .item {
  92. display: flex;
  93. align-items: center;
  94. text {
  95. margin: 0 40rpx 0 25rpx;
  96. width: 150rpx;
  97. font-size: 30rpx;
  98. font-family: PingFang SC;
  99. font-weight: 400;
  100. color: #333333;
  101. line-height: 100rpx;
  102. }
  103. input {
  104. font-size: 28rpx;
  105. font-family: PingFang SC;
  106. font-weight: 400;
  107. color: #999999;
  108. line-height: 100rpx;
  109. }
  110. }
  111. }
  112. .button {
  113. text-align: center;
  114. width: 560rpx;
  115. height: 80rpx;
  116. background: linear-gradient(90deg, #44BFEC, #438BED);
  117. border-radius: 40rpx;
  118. font-size: 30rpx;
  119. font-family: PingFangSC;
  120. font-weight: 500;
  121. color: #FFFFFF;
  122. line-height: 80rpx;
  123. }
  124. </style>