index.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  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='新昵称' 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. <authorize @onLoadFun="onLoadFun" :isAuto="isAuto" :isShowAuth="isShowAuth" @authColse="authColse"></authorize>
  19. </view>
  20. </template>
  21. <script>
  22. // +----------------------------------------------------------------------
  23. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  24. // +----------------------------------------------------------------------
  25. // | Copyright (c) 2016~2021 https://www.crmeb.com All rights reserved.
  26. // +----------------------------------------------------------------------
  27. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  28. // +----------------------------------------------------------------------
  29. // | Author: CRMEB Team <admin@crmeb.com>
  30. // +----------------------------------------------------------------------
  31. import {
  32. getUserInfo,
  33. userEdit,
  34. editAvatar
  35. } from '@/api/user.js'
  36. import {
  37. mapGetters
  38. } from "vuex";
  39. import authorize from '@/components/Authorize';
  40. export default {
  41. components: {
  42. authorize
  43. },
  44. data() {
  45. return {
  46. userInfo: {},
  47. inputcontent: "",
  48. isAuto: false,
  49. isShowAuth: false, //是否隐藏授权
  50. };
  51. },
  52. computed: mapGetters(['isLogin', 'viewColor']),
  53. onLoad() {
  54. if (this.isLogin) {
  55. this.getUserInfo();
  56. } else {
  57. this.isAuto = true;
  58. this.isShowAuth = true
  59. };
  60. },
  61. methods: {
  62. /**
  63. * 获取用户详情
  64. */
  65. getUserInfo: function() {
  66. let that = this;
  67. getUserInfo().then(res => {
  68. that.$set(that, 'userInfo', res.data);
  69. });
  70. },
  71. inputEdita() {
  72. if (this.userInfo.nickname == this.inputcontent) {
  73. uni.showToast({
  74. title: '昵称重复,请重新修改!',
  75. icon:'none',
  76. });
  77. } else if (this.inputcontent == '') {
  78. uni.showToast({
  79. title: '昵称不能为空!',
  80. icon: 'none',
  81. });
  82. } else {
  83. editAvatar({
  84. nickname: this.inputcontent
  85. }).then(res => {
  86. return this.$util.Tips({
  87. title: '修改成功!',
  88. icon: 'success'
  89. }, {
  90. tab: 5,
  91. url: '/pages/users/user_info/index'
  92. });
  93. })
  94. }
  95. },
  96. /**
  97. * 授权回调
  98. */
  99. onLoadFun: function() {
  100. this.isShowAuth = false;
  101. this.getUserInfo();
  102. },
  103. // 授权关闭
  104. authColse: function(e) {
  105. this.isShowAuth = e
  106. },
  107. }
  108. }
  109. </script>
  110. <style lang="scss">
  111. h2 {
  112. text-align: center;
  113. margin-top: 30rpx;
  114. font-weight: 600;
  115. }
  116. page {
  117. background-color: #fff !important;
  118. }
  119. .ChangePassword .phone {
  120. font-size: 32rpx;
  121. font-weight: bold;
  122. text-align: center;
  123. margin-top: 55rpx;
  124. }
  125. .ChangePassword .list {
  126. width: 580rpx;
  127. margin: 53rpx auto 0 auto;
  128. }
  129. .ChangePassword .list .item {
  130. width: 100%;
  131. height: 110rpx;
  132. border-bottom: 2rpx solid #f0f0f0;
  133. }
  134. .ChangePassword .list .item input {
  135. width: 100%;
  136. height: 100%;
  137. font-size: 32rpx;
  138. }
  139. .ChangePassword .list .item .placeholder {
  140. color: #b9b9bc;
  141. }
  142. .ChangePassword .list .item input.codeIput {
  143. width: 340rpx;
  144. }
  145. .ChangePassword .list .item .code {
  146. font-size: 32rpx;
  147. background-color: #fff;
  148. color: var(--view-theme);
  149. }
  150. .ChangePassword .list .item .code.on {
  151. color: #b9b9bc;
  152. }
  153. .ChangePassword .confirmBnt {
  154. font-size: 32rpx;
  155. width: 580rpx;
  156. height: 90rpx;
  157. border-radius: 45rpx;
  158. color: #fff;
  159. margin: 92rpx auto 0 auto;
  160. text-align: center;
  161. line-height: 90rpx;
  162. background-color: var(--view-theme);
  163. }
  164. .getPhoneBtn {
  165. font-size: 32rpx;
  166. width: 580rpx;
  167. height: 90rpx;
  168. border-radius: 45rpx;
  169. border: 1rpx solid #3CB625;
  170. color: #3CB625;
  171. margin: 40rpx auto 0 auto;
  172. text-align: center;
  173. line-height: 90rpx;
  174. .iconfont {
  175. font-size: 32rpx;
  176. margin-right: 12rpx;
  177. }
  178. }
  179. </style>