index.vue 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <template>
  2. <page :title="title" ref="pageRef" nav-color="#fff" custom-class="paddingB25">
  3. <view class="flex-align-between padding15 marginT30 cell">
  4. <view class="font5">昵称:</view>
  5. <view class="flex1">
  6. <input v-model.trim="value" placeholder="请输入昵称" />
  7. </view>
  8. </view>
  9. <view class="paddingX30 paddingY50">
  10. <cm-button @click="save">保存</cm-button>
  11. </view>
  12. </page>
  13. </template>
  14. <script>
  15. export default {
  16. data() {
  17. return {
  18. title: '',
  19. value: ''
  20. }
  21. },
  22. onLoad(options) {
  23. this.key = options.key
  24. this.value = decodeURIComponent(options.value)
  25. this.title = decodeURIComponent(options.title)
  26. },
  27. methods: {
  28. save() {
  29. if (!this.value) {
  30. return
  31. }
  32. if (this.key === 'nickname') {
  33. this.updateNickname()
  34. }
  35. },
  36. async updateNickname() {
  37. const res = await this.$service.user.updateNickname(this.value)
  38. if (res) {
  39. this.$service.user.info()
  40. this.$router.back()
  41. }
  42. }
  43. }
  44. }
  45. </script>
  46. <style lang="scss">
  47. </style>
  48. <style lang="scss" scoped>
  49. .bg {
  50. position: fixed;
  51. z-index: -1;
  52. left: 0;
  53. right: 0;
  54. top: 0;
  55. width: 100%;
  56. height: 100%;
  57. opacity: 0.3;
  58. }
  59. .cell {
  60. border-top: 1px solid rgba($color: #fff, $alpha: 0.3);
  61. border-bottom: 1px solid rgba($color: #fff, $alpha: 0.3);
  62. }
  63. </style>