edit-name.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <template>
  2. <view>
  3. <!--标题栏-->
  4. <bar-title bgColor="bg-white" isBack>
  5. <block slot="content">修改昵称</block>
  6. </bar-title>
  7. <!--提示栏-->
  8. <!-- <view class="bg-red light text-sm zaiui-tip-view">
  9. <view class="text-cut content">昵称90天只能修改一次,请慎重哦</view>
  10. <text class="cuIcon-close icon"/>
  11. </view> -->
  12. <view class="cu-form-group margin-top">
  13. <view class="title">新昵称</view>
  14. <input placeholder="请输入新昵称" v-model="name"></input>
  15. </view>
  16. <view class="text-sm text-gray padding-sm">13个字以内,仅支持汉字、字母、数字或下划线</view>
  17. <view class="bg-white zaiui-footer-fixed zaiui-foot-padding-bottom" style="padding: 20upx">
  18. <view class="flex flex-direction">
  19. <button class="cu-btn bg-red" @click="submitName">保存昵称</button>
  20. </view>
  21. </view>
  22. </view>
  23. </template>
  24. <script>
  25. import barTitle from '@/components/zaiui-common/basics/bar-title';
  26. import _tool from '@/static/zaiui/util/tools.js'; //工具函数
  27. export default {
  28. components: {
  29. barTitle
  30. },
  31. data() {
  32. return {
  33. name: ''
  34. }
  35. },
  36. onLoad() {
  37. this.name = this.userInfo.name;
  38. if(!this.userInfo.id) {
  39. this.loadUserInfo().then(res => {
  40. this.name = res.user.name;
  41. })
  42. }
  43. },
  44. onReady() {
  45. _tool.setBarColor(true);
  46. uni.pageScrollTo({
  47. scrollTop: 0,
  48. duration: 0
  49. });
  50. },
  51. methods: {
  52. submitName() {
  53. this.reqByuser({
  54. url: '?l=user.update',
  55. data: {
  56. name: this.name
  57. },
  58. success: res => {
  59. if(res.data.status == 1) {
  60. console.log(res.data.data)
  61. // this.user = res.data.data.user;
  62. // this.setUserInfo({...this.user, ...this.userInfo})
  63. }else {
  64. this.error = res.data.msg
  65. }
  66. }
  67. })
  68. }
  69. }
  70. }
  71. </script>
  72. <style lang="scss">
  73. /* #ifdef APP-PLUS */
  74. @import "../../static/colorui/main.css";
  75. @import "../../static/colorui/icon.css";
  76. @import "../../static/zaiui/style/app.scss";
  77. /* #endif */
  78. .cu-form-group {
  79. .title {
  80. &:before {
  81. content: "";
  82. position: absolute;
  83. height: 27.27upx;
  84. width: 3.63upx;
  85. background: #e6e6e6;
  86. top: 16.36upx;
  87. right: 12.72upx;
  88. }
  89. }
  90. input {
  91. color: #333333;
  92. }
  93. }
  94. </style>