user.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <template>
  2. <view>
  3. <view class="uni-textarea">
  4. <view v-if="type == '2'">
  5. <view class="uni-list">
  6. <radio-group @change="radioChange">
  7. <label class="uni-list-cell uni-list-cell-pd">
  8. <view>
  9. <radio :checked="info[show_type[type].key] == '0'" value="0" color="#1AAD19"/>
  10. </view>
  11. <view>男</view>
  12. </label>
  13. <label class="uni-list-cell uni-list-cell-pd">
  14. <view>
  15. <radio :checked="info[show_type[type].key] == '1'" value="1" color="#1AAD19"/>
  16. </view>
  17. <view>女</view>
  18. </label>
  19. </radio-group>
  20. </view>
  21. </view>
  22. <textarea auto-height v-model="info[show_type[type].key]" v-else/>
  23. </view>
  24. </view>
  25. </template>
  26. <script>
  27. import _get from '../../common/_get';
  28. import _hook from '../../common/_hook';
  29. import _data from '../../common/_data';
  30. export default {
  31. components:{
  32. },
  33. data() {
  34. return {
  35. info: {},
  36. content: '',
  37. type: '',
  38. show_type: [
  39. {
  40. 'title': '昵称',
  41. 'key': 'nickname'
  42. },
  43. {
  44. 'title': '个性签名',
  45. 'key': 'doodling'
  46. },
  47. {
  48. 'title': '性别',
  49. 'key': 'sex'
  50. },
  51. ],
  52. }
  53. },
  54. onShow(){
  55. _hook.routeSonHook();
  56. let _this = this;
  57. /** 监听新的个人数据 */
  58. uni.$on('data_user_info',function(data){
  59. _this.info = data;
  60. });
  61. },
  62. onLoad(option){
  63. let _this = this;
  64. _this.type = option.type;
  65. uni.setNavigationBarTitle({
  66. title: (_this.show_type[_this.type].title + '设置'),
  67. });
  68. _this.info = _data.data('user_info');
  69. },
  70. onUnload(){
  71. uni.$off('data_user_info');
  72. },
  73. computed:{
  74. },
  75. methods:{
  76. send(){
  77. let _this = this;
  78. _this.$httpSend({
  79. path: '/im/set/setInfo',
  80. data: { content: _this.info[_this.show_type[_this.type].key],type: _this.type, },
  81. success(data) {
  82. uni.showToast({
  83. title: '保存成功',
  84. duration: 2000
  85. });
  86. _data.data('user_info',_this.info);
  87. setTimeout(() => {
  88. uni.navigateBack();
  89. },2000);
  90. }
  91. });
  92. },
  93. radioChange(e){
  94. this.info[this.show_type[this.type].key] = e.target.value;
  95. },
  96. },
  97. onNavigationBarButtonTap(e) {
  98. this.send();
  99. },
  100. watch: {
  101. },
  102. }
  103. </script>
  104. <style>
  105. </style>