userSet.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. <template>
  2. <view class="container">
  3. <view class="row b-b flex jg">
  4. <text class="tit">头像</text>
  5. <!-- @click.stop="imgsub" -->
  6. <image :src="userInfo.avatar" ></image>
  7. </view>
  8. <view class="row b-b flex">
  9. <text class="tit">昵称</text>
  10. <input class="input" v-model="userInfo.nickname" type="text" placeholder-class="placeholder" disabled/>
  11. </view>
  12. <view class="row b-b flex">
  13. <text class="tit">ID</text>
  14. <input class="input" v-model="userInfo.id" type="text" disabled="true" placeholder-class="placeholder" />
  15. </view>
  16. <!-- <view class="row b-b flex">
  17. <text class="tit">用户账号</text>
  18. <input class="input" v-model="userInfo.account || userInfo.phone" type="number" disabled="true"
  19. placeholder-class="placeholder" />
  20. </view> -->
  21. <view class="submit-box ">
  22. <!-- <view class="submit" @click="edit">确认修改</view> -->
  23. <view class="submit submit1" @click="toLogout">退出登录</view>
  24. </view>
  25. </view>
  26. </template>
  27. <script>
  28. import uniList from '@/components/uni-list/uni-list.vue';
  29. import uniListItem from '@/components/uni-list-item/uni-list-item.vue';
  30. import {
  31. mapState,
  32. mapMutations
  33. } from 'vuex';
  34. import {
  35. logout
  36. } from '@/api/set.js';
  37. import {
  38. uploads,
  39. edit,
  40. // upload
  41. } from '@/api/user.js';
  42. import { upload } from '@/api/ask.js'
  43. export default {
  44. components: {
  45. uniList,
  46. uniListItem
  47. },
  48. data() {
  49. return {
  50. // nickName:'李淡淡',
  51. // id:'HFBNXISN',
  52. // account:'13745262356',
  53. userInfo: {},
  54. pics: []
  55. };
  56. },
  57. onLoad() {
  58. this.userInfo = uni.getStorageSync('userInfo') || '';
  59. console.log(this.userInfo)
  60. },
  61. methods: {
  62. ...mapMutations('user', ['logout']),
  63. //退出登录
  64. toLogout() {
  65. let obj = this;
  66. uni.showModal({
  67. content: '确定要退出登录么',
  68. success: e => {
  69. if (e.confirm) {
  70. logout({}).then(e => {
  71. obj.logout();
  72. uni.switchTab({
  73. url: '/pages/index/index'
  74. })
  75. })
  76. .catch(e => {
  77. console.log(e);
  78. });
  79. }
  80. }
  81. });
  82. },
  83. imgsub() {
  84. let obj = this
  85. // console.log('上传头像')
  86. // this.$util.uploadImageOne('upload/image', function(res) {
  87. // console.log('------',res);
  88. // // this.pics.push(res.data.pathreplace(/http:\/\/mer.crmeb.net/,'http://zccy.liuniu946.com'));
  89. // obj.userInfo.avatar = res.data.path.replace(/http:\/\/mer.crmeb.net/,'http://zccy.frp.liuniu946.com')
  90. // // obj.$set(this, 'pics', this.pics);
  91. // // obj.$set(this, 'extract_pic', this.pics[0])
  92. // });
  93. // uploads({
  94. // filename: ''
  95. // }).then(data => {
  96. // console.log("data",data);
  97. // this.userInfo.avatar = data[0].url;
  98. // })
  99. upload({
  100. filename: ''
  101. }).then(res => {
  102. console.log(res, '上传图片')
  103. console.log(res[0].url)
  104. obj.userInfo.avatar = res[0].url
  105. // console.log(obj.userInfo.avatar)
  106. });
  107. },
  108. edit() {
  109. const that = this;
  110. uni.showLoading({
  111. title: '提交中...',
  112. mask: true
  113. })
  114. edit({
  115. avatar: this.userInfo.avatar,
  116. nickname: this.userInfo.nickname
  117. }).then(e => {
  118. uni.hideLoading()
  119. that.$api.msg('修改成功');
  120. setTimeout(() => {
  121. uni.switchTab({
  122. url: '/pages/user/user'
  123. });
  124. }, 1000);
  125. }).catch(e => {
  126. console.log(e);
  127. that.$api.msg('修改失败');
  128. })
  129. }
  130. }
  131. };
  132. </script>
  133. <style lang='scss'>
  134. /* page{
  135. background: $page-color-base;
  136. }
  137. .list-cell{
  138. display:flex;
  139. align-items:baseline;
  140. padding: 20rpx $page-row-spacing;
  141. line-height:60rpx;
  142. position:relative;
  143. background: #fff;
  144. justify-content: center;
  145. &.log-out-btn{
  146. margin-top: 40rpx;
  147. .cell-tit{
  148. color: $uni-color-primary;
  149. text-align: center;
  150. margin-right: 0;
  151. }
  152. }
  153. .cell-tit{
  154. flex: 1;
  155. font-size: $font-base + 2rpx;
  156. color: $font-color-dark;
  157. margin-right:10rpx;
  158. }
  159. .cell-tip{
  160. font-size: $font-base;
  161. color: $font-color-light;
  162. }
  163. switch{
  164. transform: translateX(16rpx) scale(.84);
  165. }
  166. } */
  167. page {
  168. background-color: #f3f3f3;
  169. min-height: 100%;
  170. .container {
  171. height: 100%;
  172. }
  173. }
  174. .row {
  175. background-color: #fff;
  176. padding: 42rpx 25rpx;
  177. font-size: 30rpx;
  178. color: #333333;
  179. image {
  180. width: 80rpx;
  181. height: 80rpx;
  182. border-radius: 50%;
  183. }
  184. .input {
  185. text-align: right;
  186. color: #333333;
  187. }
  188. }
  189. .submit-box {
  190. padding-top: 157rpx;
  191. .submit {
  192. margin: 40rpx auto;
  193. width: 560rpx;
  194. background-color: #901b21;
  195. color: #FFFFFF;
  196. text-align: center;
  197. padding: 26rpx 0rpx;
  198. border-radius: 50rpx;
  199. }
  200. .submit1 {
  201. background-color: #FFFFFF;
  202. color:#fa7e67 ;
  203. border: 1px solid #fa7e67;
  204. }
  205. }
  206. .jg {
  207. margin-bottom: 20rpx;
  208. }
  209. .out {
  210. display: flex;
  211. align-items: center;
  212. justify-content: center;
  213. margin: 0 auto 30rpx;
  214. width: 560rpx;
  215. height: 80rpx;
  216. border: 1px solid #58BAB0;
  217. background: #FFFFFF;
  218. border-radius: 40px;
  219. color: #58BAB0;
  220. }
  221. .b-b {
  222. justify-content: space-between;
  223. }
  224. </style>