金诚优选前端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

73 lines
1.7 KiB

  1. <template>
  2. <view>
  3. <lf-nav :spreadOut="true" :showIcon="true" title="修改昵称" :backDiy="true" @backCallback="backCallback"></lf-nav>
  4. <view class="lf-color-black lf-font-28 lf-p-30">
  5. 可使用中英文数字和下划线字符限制1-10字符
  6. </view>
  7. <view class="lf-p-l-32 lf-p-r-32">
  8. <view class="set-tag lf-border-bottom">
  9. <view class="lf-font-28 lf-color-black">
  10. <input v-model="name" type="text" placeholder="起一个好听的昵称吧" />
  11. </view>
  12. <view class="lf-flex" v-if="name.length" @click="clear">
  13. <text class="lf-iconfont icon-cuo lf-font-24 lf-m-l-10 lf-color-777"></text>
  14. </view>
  15. </view>
  16. </view>
  17. </view>
  18. </template>
  19. <script>
  20. export default {
  21. data(){
  22. return {
  23. name: ''
  24. }
  25. },
  26. methods: {
  27. clear(){
  28. this.name = '';
  29. },
  30. backCallback(){
  31. if(!this.name){
  32. return this.$toBack();
  33. };
  34. uni.showLoading({
  35. title: '正在保存中'
  36. })
  37. let token = this.$cookieStorage.get('user_token');
  38. this.$http.post({
  39. api: 'api/users/update/info',
  40. data: {
  41. nick_name: this.name
  42. },
  43. header: {
  44. Authorization: token,
  45. Accept: 'application/json'
  46. }
  47. }).then(res => {
  48. uni.hideLoading();
  49. this.$msg('保存成功', {icon: 'success'}).then(() => {
  50. this.$toBack();
  51. });
  52. }).catch(err => {
  53. uni.hideLoading();
  54. this.$msg('保存失败', {icon: 'error'}).then(() => {
  55. this.$toBack();
  56. });
  57. })
  58. }
  59. }
  60. }
  61. </script>
  62. <style scoped lang="scss">
  63. .set-tag {
  64. height: 100rpx;
  65. width: 100%;
  66. display: flex;
  67. align-items: center;
  68. justify-content: space-between;
  69. // border-bottom: 1rpx solid rgba(0, 0, 0, 0.1);
  70. }
  71. </style>