nickNameReset.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <template>
  2. <view class="uni-flex uni-column nickNameReset jz_address">
  3. <view class="uni-flex">
  4. <input v-model="user.nickName" />
  5. </view>
  6. <view class="addBtnwrap uni-flex justify-align-center">
  7. <view class="addBtn uni-flex justify-align-center" @click="submit">保存昵称</view>
  8. </view>
  9. </view>
  10. </template>
  11. <script>
  12. import {
  13. mapState,
  14. mapMutations
  15. } from 'vuex'
  16. export default {
  17. computed: {
  18. ...mapState(['hasLogin', 'forcedLogin', 'jyyUser'])
  19. },
  20. data() {
  21. return {
  22. user: {}
  23. }
  24. },
  25. onLoad() {
  26. if (!this.hasLogin) {
  27. uni.navigateTo({
  28. url: '../login/login',
  29. });
  30. } else {
  31. this.user = JSON.parse(this.jyyUser);
  32. }
  33. },
  34. methods: {
  35. ...mapMutations(['login']),
  36. submit() {
  37. if (this.nickName == '') {
  38. uni.showToast({
  39. duration: 1000,
  40. title: '昵称不为空',
  41. icon: "none"
  42. })
  43. } else {
  44. uni.showLoading({
  45. title: '更新中'
  46. })
  47. uni.request({
  48. url: this.webUrl + 'SaveInfo',
  49. method: 'POST',
  50. data: {
  51. userid: this.user.id,
  52. nickName: this.user.nickName
  53. },
  54. header: {
  55. 'content-type': 'application/x-www-form-urlencoded'
  56. },
  57. success: res => {
  58. uni.hideLoading();
  59. this.login(JSON.stringify(this.user));
  60. uni.showToast({
  61. icon: "none",
  62. title: res.data.result.resultInfo,
  63. success() {
  64. setTimeout(() => {
  65. uni.navigateBack({
  66. delta: 1
  67. })
  68. }, 1000)
  69. }
  70. })
  71. },
  72. fail: () => {},
  73. complete: () => {}
  74. });
  75. }
  76. }
  77. }
  78. }
  79. </script>
  80. <style>
  81. .jz_address .addBtnwrap {
  82. width: 100%;
  83. margin-top: 30upx;
  84. }
  85. .nickNameReset input {
  86. width: 100%;
  87. border: 0;
  88. background: #FFFFFF;
  89. height: 80upx;
  90. line-height: 80upx;
  91. padding-left: 20upx;
  92. box-sizing: border-box;
  93. }
  94. .jz_address .addBtn {
  95. width: 550rpx;
  96. height: 115rpx;
  97. color: #FFFFFF;
  98. font-size: 28rpx;
  99. margin: 0 auto;
  100. background: url(../../../static/btn.png) no-repeat;
  101. background-size: 550rpx 115rpx;
  102. }
  103. </style>