nickname.vue 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <template>
  2. <view class="container">
  3. <form @submit="bindSave" :report-submit="true">
  4. <tui-list-cell :hover="false" :lineLeft="false">
  5. <view class="tui-cell-input">
  6. <!-- #ifndef MP-WEIXIN -->
  7. <input type="text" v-model="nickname" placeholder="请输入昵称" placeholder-class="tui-phcolor" maxlength="40" />
  8. <!-- #endif -->
  9. <!-- #ifdef MP-WEIXIN -->
  10. <input type="nickname" v-model="nickname" @blur="inputNickname" @input="inputNickname" placeholder="请输入昵称" placeholder-class="tui-phcolor" maxlength="40" />
  11. <!-- #endif -->
  12. </view>
  13. </tui-list-cell>
  14. <view class="tui-btn-box">
  15. <tui-button formType="submit" shadow height="88rpx" shape="circle" type="danger">确定</tui-button>
  16. </view>
  17. </form>
  18. </view>
  19. </template>
  20. <script>
  21. export default {
  22. data() {
  23. return {
  24. nickname: ''
  25. };
  26. },
  27. onShow: function() {
  28. let _this = this;
  29. _this.$util.getUserInfo(function(userInfo) {
  30. //Console.log("adfs");
  31. _this.$request.get('member.detail',{
  32. samkey: (new Date()).valueOf()
  33. }).then(res => {
  34. if (res.errno == 0) {
  35. _this.nickname = res.data.nickname;
  36. }
  37. });
  38. })
  39. },
  40. methods: {
  41. bindSave(e) {
  42. let _this = this;
  43. _this.$request.post('member.update', {
  44. samkey: (new Date()).valueOf(),
  45. nickname: _this.nickname
  46. }).then(res => {
  47. if (res.errno == 0) {
  48. this.tui.href("/pagesA/my/userInfo/userInfo")
  49. }
  50. });
  51. },
  52. inputNickname(e) {
  53. this.nickname = e.detail.value;
  54. },
  55. clearInput() {
  56. this.nickname = '';
  57. }
  58. },
  59. /**
  60. * 页面相关事件处理函数--监听用户下拉动作
  61. */
  62. onPullDownRefresh: function() {
  63. setTimeout(() => {
  64. uni.stopPullDownRefresh()
  65. }, 200);
  66. },
  67. };
  68. </script>
  69. <style lang="scss">
  70. .container {
  71. padding-top: 20rpx;
  72. .tui-cell-input {
  73. width: 100%;
  74. display: flex;
  75. align-items: center;
  76. box-sizing: border-box;
  77. input {
  78. flex: 1;
  79. padding-left: $uni-spacing-row-base;
  80. }
  81. }
  82. .tui-btn-box {
  83. padding: 40rpx 30rpx 10rpx 30rpx;
  84. box-sizing: border-box;
  85. }
  86. }
  87. </style>