info.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. <template>
  2. <view class="container padding-lr-sm" v-if="fetch && fetch.user">
  3. <use-tabbar :tabbar="false"></use-tabbar>
  4. <view class="border-radius dflex-b bg-main padding-lr-sm padding-tb-sm margin-top" @click="openAvatar">
  5. <text>头像</text>
  6. <view class="dflex-c">
  7. <image class="border-radius-c headimg image-60 margin-right-xs" :src="fetch.user.avatar" />
  8. <view class="iconfont iconjiantou-01 fs-sm" style="color: rgb(192, 192, 192);"></view>
  9. </view>
  10. </view>
  11. <l-clipper v-if="avatar" :image-url="fetch.user.avatar" @success="uploadAvatar" @cancel="avatar = false" />
  12. <view class="border-radius margin-top-sm">
  13. <view class="use-list-title dflex-b padding-lr-sm w-full bg-main" @click="open('nick')">
  14. <view class="dflex">
  15. <text class="flex1 ws-np" style="font-size: 13px; font-weight: normal;">昵称</text>
  16. </view>
  17. <view class="dflex margin-left-xl">
  18. <text class="tip line-height-1 margin-right-xs">{{fetch.user.name}}</text>
  19. <view class="iconfont fs-sm iconjiantou-01" style="color: rgb(192, 192, 192);"></view>
  20. </view>
  21. </view>
  22. <u-popup mode="center" @close="close('nick')" :show="show.nick" round="14" :closeable="true">
  23. <view class="alert-area border-radius bg-main pos-r">
  24. <view class="dflex-b ft-dark margin-bottom-sm margin-lr-xs">
  25. <view>修改昵称</view>
  26. </view>
  27. <view class="dflex border-radius-sm field" style="padding: 8px 7px;">
  28. <u--input placeholder="请输入昵称" v-model="fetch.user.name" class="fwb fs-sm" type="nickname"
  29. border="none" :focus="true" :clearable="true"></u--input>
  30. </view>
  31. <!-- 提交按钮 -->
  32. <view class="bg-base margin-top-xl tac w-full border-radius-lg padding-tb-sm"
  33. @click="update('nick')">
  34. 提交
  35. </view>
  36. </view>
  37. </u-popup>
  38. <!-- 性别项 -->
  39. <view class="use-list-title dflex-b padding-lr-sm w-full bg-main" @click="open('sex')">
  40. <view class="dflex">
  41. <text class="flex1 ws-np" style="font-size: 13px; font-weight: normal;">性别</text>
  42. </view>
  43. <view class="dflex margin-left-xl">
  44. <text class="tip line-height-1 margin-right-xs">{{sexName}}</text>
  45. <view class="iconfont fs-sm iconjiantou-01" style="color: rgb(192, 192, 192);"></view>
  46. </view>
  47. </view>
  48. <u-action-sheet :actions="sex" :closeOnClickAction="true" :closeOnClickOverlay="true" :show="show.sex"
  49. @select="setSex" @close="close('sex')" :round="14" title="修改性别"></u-action-sheet>
  50. <view class="use-list-title dflex-b padding-lr-sm w-full bg-main" @click="open('sign')">
  51. <view class="dflex">
  52. <text class="flex1 ws-np" style="font-size: 13px; font-weight: normal;">个人签名</text>
  53. </view>
  54. <view class="dflex margin-left-xl">
  55. <text class="tip line-height-1 margin-right-xs">{{fetch.user.sign}}</text>
  56. <view class="iconfont fs-sm iconjiantou-01" style="color: rgb(192, 192, 192);"></view>
  57. </view>
  58. </view>
  59. <u-popup mode="center" @close="close('sign')" :show="show.sign" round="14" :closeable="true">
  60. <view class="alert-area border-radius bg-main pos-r">
  61. <view class="dflex-b ft-dark margin-bottom-sm margin-lr-xs">
  62. <view>修改个人签名</view>
  63. </view>
  64. <view class="dflex border-radius-sm field" style="padding: 8px 7px;">
  65. <u--input placeholder="请输入个人签名" v-model="fetch.user.sign" class="fwb fs-sm" type="textarea"
  66. border="none" :focus="true" :clearable="true"></u--input>
  67. </view>
  68. <!-- 提交按钮 -->
  69. <view class="bg-base margin-top-xl tac w-full border-radius-lg padding-tb-sm"
  70. @click="update('sign')">
  71. 提交
  72. </view>
  73. </view>
  74. </u-popup>
  75. </view>
  76. <view class="padding"></view>
  77. </view>
  78. </template>
  79. <script>
  80. import lClipper from "@/lib/l-clipper/l-clipper.vue";
  81. export default {
  82. components: {
  83. lClipper
  84. },
  85. data() {
  86. return {
  87. fetch: {},
  88. avatar: false,
  89. show: {
  90. nick: false,
  91. sign: false,
  92. sex: false,
  93. },
  94. sex: [{
  95. id : 1,
  96. name: '男'
  97. },
  98. {
  99. id: 2,
  100. name: '女'
  101. },
  102. {
  103. id: 3,
  104. name: '未知'
  105. }
  106. ],
  107. }
  108. },
  109. onLoad() {
  110. this.loadData();
  111. },
  112. computed: {
  113. sexName() {
  114. const match = this.sex.find(item => item.id === this.fetch.user.sex);
  115. return match ? match.name : '';
  116. }
  117. },
  118. methods: {
  119. loadData() {
  120. this.DeverApi.get(this, 'user.info');
  121. },
  122. update: function(key) {
  123. if (key == 'nick' && !this.fetch.user.name) {
  124. return this.Dever.alert('昵称不能为空');
  125. }
  126. if (key == 'sign' && !this.fetch.user.sign) {
  127. return this.Dever.alert('个人签名不能为空');
  128. }
  129. this.close(key);
  130. this.DeverApi.post('user.update', this.fetch.user);
  131. },
  132. setSex: function(e) {
  133. this.fetch.user.sex = e.id;
  134. this.update('sex')
  135. },
  136. uploadAvatar: function(e) {
  137. var url = e.url;
  138. this.avatar = false;
  139. this.DeverApi.upload(e.url, 'avatar', 1, (type, file) => {
  140. this.fetch.user.avatar = file;
  141. this.DeverApi.post('user.update', {
  142. avatar: file
  143. });
  144. });
  145. },
  146. openAvatar: function() {
  147. this.avatar = true;
  148. },
  149. open(key) {
  150. this.show[key] = true;
  151. },
  152. close(key) {
  153. this.show[key] = false;
  154. },
  155. }
  156. }
  157. </script>
  158. <style>
  159. .image-60 {
  160. width: 56rpx;
  161. height: 56rpx;
  162. }
  163. </style>