userinfo.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. <template>
  2. <view class="content">
  3. <view class="row1">
  4. <text class="tit">头像</text>
  5. <view class="background-img" @click.stop="imgsub"><image class="background-img" :src="userInfo.avatar" mode="aspectFill"></image></view>
  6. </view>
  7. <view class="row">
  8. <text class="tit">昵称</text>
  9. <input class="input" type="text" v-model="userInfo.nickname" placeholder-class="placeholder" />
  10. </view>
  11. <view class="row">
  12. <text class="tit" style="width: 240upx;">银行账号</text>
  13. <input class="input" type="text" v-model="userInfo.bank_card_no" placeholder-class="placeholder" />
  14. </view>
  15. <view class="row">
  16. <text class="tit" style="width: 240upx;">所属银行</text>
  17. <input class="input" type="text" v-model="userInfo.bank_of_deposit" placeholder-class="placeholder" />
  18. </view>
  19. <view class="row">
  20. <text class="tit">ID</text>
  21. <input class="input" type="text" disabled="true" v-model="userInfo.id" placeholder-class="placeholder" />
  22. </view>
  23. <view class="row">
  24. <text class="tit">账户</text>
  25. <input class="input" type="text" disabled="true" v-model="userInfo.username" placeholder-class="placeholder" />
  26. </view>
  27. <view class="add-btn" @click="confirm">提交</view>
  28. <view class="out" @click="toLogout">退出登录</view>
  29. </view>
  30. </template>
  31. <script>
  32. import { mapState,mapMutations } from 'vuex';
  33. import { uploads } from '@/api/user.js';
  34. import {userEdit,logout} from '@/api/set.js';
  35. export default{
  36. data(){
  37. return{
  38. }
  39. },
  40. onLoad() {
  41. console.log(this.userInfo)
  42. },
  43. computed: {
  44. ...mapState('user',['userInfo'])
  45. },
  46. methods: {
  47. ...mapMutations('user',['logout']),
  48. imgsub() {
  49. console.log('上传头像')
  50. uploads({
  51. filename: ''
  52. }).then(res => {
  53. // console.log("data",data);
  54. // this.userInfo.avatar = data.fullurl;
  55. console.log(res,'++++++++++++++++')
  56. this.userInfo.avatar = res[0].fullurl;
  57. })
  58. },
  59. confirm() {
  60. userEdit({ avatar: this.userInfo.avatar ,nickname: this.userInfo.nickname,bank_of_deposit:this.userInfo.bank_of_deposit,bank_card_no:this.userInfo.bank_card_no})
  61. .then(e => {
  62. this.$api.msg('修改成功');
  63. setTimeout(()=> {
  64. uni.switchTab({
  65. url:'/pages/user/user'
  66. });
  67. }, 1000);
  68. console.log(e);
  69. })
  70. .catch(e => {
  71. console.log(e);
  72. });
  73. },
  74. toLogout(){
  75. let obj = this;
  76. uni.showModal({
  77. content: '确定要退出登录么',
  78. success: (e)=>{
  79. if(e.confirm){
  80. // logout({}).then((e) => {
  81. // uni.navigateBack();
  82. // }).catch((e) => {
  83. // console.log(e);
  84. // })
  85. uni.navigateBack();
  86. obj.logout();
  87. }
  88. }
  89. });
  90. },
  91. }
  92. }
  93. </script>
  94. <style lang="scss">
  95. .row1 {
  96. display: flex;
  97. align-items: center;
  98. justify-content: space-between;
  99. position: relative;
  100. padding: 0 30upx;
  101. height: 110upx;
  102. background: #000;
  103. margin-bottom: 20upx;
  104. .tit {
  105. flex-shrink: 0;
  106. width: 120upx;
  107. font-size: $font-lg;
  108. color: #fff;
  109. }
  110. .background-img {
  111. width: 80rpx;
  112. height: 80rpx;
  113. border-radius: 50%;
  114. background: #f2f2f2;
  115. }
  116. }
  117. .row {
  118. display: flex;
  119. align-items: center;
  120. padding: 0 30upx;
  121. height: 110upx;
  122. background: #000;
  123. .tit {
  124. flex-shrink: 0;
  125. width: 120upx;
  126. font-size: $font-lg;
  127. color: #fff;
  128. }
  129. .input {
  130. flex: 1;
  131. text-align: right;
  132. font-size: $font-base;
  133. color: #fff;
  134. }
  135. }
  136. .add-btn {
  137. display: flex;
  138. align-items: center;
  139. justify-content: center;
  140. margin: 158rpx auto 30rpx;
  141. width: 560rpx;
  142. height: 80rpx;
  143. background: linear-gradient(-74deg, #CE9C6D, #FFECD6);
  144. border-radius: 40px;
  145. color: #FFFFFF;
  146. }
  147. .out {
  148. display: flex;
  149. align-items: center;
  150. justify-content: center;
  151. margin: 0 auto 30rpx;
  152. width: 560rpx;
  153. height: 80rpx;
  154. border: 1px solid #FFECD6;
  155. background: #FFFFFF;
  156. border-radius: 40px;
  157. color: #CE9C6D;
  158. }
  159. </style>