index.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. <template>
  2. <view :style="viewColor">
  3. <form report-submit='true'>
  4. <h2>修改昵称</h2>
  5. <view class="ChangePassword">
  6. <view class="list">
  7. <view class="item">
  8. <input type='text' name='nickname' :value='userInfo.nickname' disabled></input>
  9. </view>
  10. <view class="item acea-row row-between-wrapper">
  11. <input type='text' placeholder='新昵称(限8个字符以内)' maxlength="8" placeholder-class='placeholder' class="codeIput"
  12. v-model="inputcontent"></input>
  13. </view>
  14. </view>
  15. <button form-type="submit" @click="inputEdita" class="confirmBnt">确认修改</button>
  16. </view>
  17. </form>
  18. </view>
  19. </template>
  20. <script>
  21. // +----------------------------------------------------------------------
  22. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  23. // +----------------------------------------------------------------------
  24. // | Copyright (c) 2016~2024 https://www.crmeb.com All rights reserved.
  25. // +----------------------------------------------------------------------
  26. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  27. // +----------------------------------------------------------------------
  28. // | Author: CRMEB Team <admin@crmeb.com>
  29. // +----------------------------------------------------------------------
  30. import { getUserInfo, userEdit, editAvatar } from '@/api/user.js'
  31. import { mapGetters } from "vuex";
  32. import { toLogin } from '@/libs/login.js';
  33. export default {
  34. components: {},
  35. data() {
  36. return {
  37. userInfo: {},
  38. inputcontent: "",
  39. };
  40. },
  41. computed: mapGetters(['isLogin', 'viewColor']),
  42. onLoad() {
  43. if (this.isLogin) {
  44. this.getUserInfo();
  45. } else {
  46. toLogin()
  47. };
  48. },
  49. methods: {
  50. /**
  51. * 获取用户详情
  52. */
  53. getUserInfo: function() {
  54. let that = this;
  55. getUserInfo().then(res => {
  56. that.$set(that, 'userInfo', res.data);
  57. });
  58. },
  59. inputEdita() {
  60. if (this.userInfo.nickname == this.inputcontent) {
  61. uni.showToast({
  62. title: '昵称重复,请重新修改!',
  63. icon:'none',
  64. });
  65. } else if (this.inputcontent == '') {
  66. uni.showToast({
  67. title: '昵称不能为空!',
  68. icon: 'none',
  69. });
  70. } else {
  71. editAvatar({
  72. nickname: this.inputcontent
  73. }).then(res => {
  74. return this.$util.Tips({
  75. title: '修改成功!',
  76. icon: 'success'
  77. }, {
  78. tab: 5,
  79. url: '/pages/users/user_info/index'
  80. });
  81. }).catch(err => {
  82. uni.showToast({
  83. title: err,
  84. icon: 'none'
  85. });
  86. });
  87. }
  88. },
  89. }
  90. }
  91. </script>
  92. <style lang="scss" scoped>
  93. h2 {
  94. text-align: center;
  95. margin-top: 30rpx;
  96. font-weight: 600;
  97. }
  98. page {
  99. background-color: #fff !important;
  100. }
  101. .ChangePassword .phone {
  102. font-size: 32rpx;
  103. font-weight: bold;
  104. text-align: center;
  105. margin-top: 55rpx;
  106. }
  107. .ChangePassword .list {
  108. width: 580rpx;
  109. margin: 53rpx auto 0 auto;
  110. }
  111. .ChangePassword .list .item {
  112. width: 100%;
  113. height: 110rpx;
  114. border-bottom: 2rpx solid #f0f0f0;
  115. }
  116. .ChangePassword .list .item input {
  117. width: 100%;
  118. height: 100%;
  119. font-size: 32rpx;
  120. }
  121. .ChangePassword .list .item .placeholder {
  122. color: #b9b9bc;
  123. }
  124. .ChangePassword .list .item input.codeIput {
  125. width: 340rpx;
  126. }
  127. .ChangePassword .list .item .code {
  128. font-size: 32rpx;
  129. background-color: #fff;
  130. color: var(--view-theme);
  131. }
  132. .ChangePassword .list .item .code.on {
  133. color: #b9b9bc;
  134. }
  135. .ChangePassword .confirmBnt {
  136. font-size: 32rpx;
  137. width: 580rpx;
  138. height: 90rpx;
  139. border-radius: 45rpx;
  140. color: #fff;
  141. margin: 92rpx auto 0 auto;
  142. text-align: center;
  143. line-height: 90rpx;
  144. background-color: var(--view-theme);
  145. }
  146. </style>