personData.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. <template>
  2. <view class="content">
  3. <view class="list-container">
  4. <view class="list-item margin-bot">
  5. <view class="list-item-left">
  6. <text>头像</text>
  7. </view>
  8. <view class="list-item-right">
  9. <button class="avatar-wrapper" open-type="chooseAvatar" @chooseavatar="onChooseAvatar">
  10. <u-image class="avatar" width="100" height="100" :src="avatarUrl||'/static/def_personal_avatar.png'"></u-image>
  11. </button>
  12. <view style="font-size: 0.8rem;text-align: center;"><text v-if="!avatarUrl">点击头像修改</text></view>
  13. </view>
  14. </view>
  15. <view class="list-item border-bottom">
  16. <view class="list-item-left">
  17. <text>姓名</text>
  18. </view>
  19. <view class="list-item-right">
  20. <text>{{userInfo.userNameCN}}</text>
  21. </view>
  22. </view>
  23. <view class="list-item border-bottom">
  24. <view class="list-item-left">
  25. <text>手机号</text>
  26. </view>
  27. <view class="list-item-right">
  28. <text>{{userInfo.mobile}}</text>
  29. </view>
  30. </view>
  31. <view class="list-item border-bottom">
  32. <view class="list-item-left">
  33. <text>门店名称</text>
  34. </view>
  35. <view class="list-item-right">
  36. <text>{{userInfo.orgName}}</text>
  37. </view>
  38. </view>
  39. <view class="list-item margin-bot" v-if="shelfInfo">
  40. <view class="list-item-left">
  41. <text>汽配经销商</text>
  42. </view>
  43. <view class="list-item-right">
  44. <text>{{shelfInfo.dealerName}}</text>
  45. </view>
  46. </view>
  47. </view>
  48. <view class="bottom-cont" style="color: dodgerblue;" @click="quitOut">
  49. 退出登录
  50. </view>
  51. </view>
  52. </template>
  53. <script>
  54. import uniPopup from '@/components/uni-popup/uni-popup.vue'
  55. import uniPopupDialog from '@/components/uni-popup/uni-popup-dialog.vue'
  56. import {saveHeadImage } from '@/api/employee'
  57. const baseUrl = getApp().globalData.baseUrl
  58. import {
  59. mapState,
  60. mapMutations
  61. } from 'vuex'
  62. export default {
  63. components: {
  64. uniPopup,
  65. uniPopupDialog
  66. },
  67. data() {
  68. return {
  69. title:'',
  70. avatarUrl:"",
  71. userInfo: null
  72. }
  73. },
  74. computed: {
  75. ...mapState(['hasLogin']),
  76. shelfInfo(){
  77. return this.$store.state.vuex_storeShelf
  78. },
  79. },
  80. onShow() {
  81. this.avatarUrl = this.$store.state.vuex_userPhoto || uni.getStorageSync('userPhoto');
  82. this.userInfo = this.$store.state.vuex_userInfo
  83. },
  84. methods: {
  85. onChooseAvatar(e) {
  86. const _this = this
  87. const { avatarUrl } = e.detail
  88. uni.uploadFile({
  89. url: baseUrl + 'upload',
  90. filePath: avatarUrl,
  91. name: 'file',
  92. success: (uploadFileRes) => {
  93. const ret = JSON.parse(uploadFileRes.data)
  94. console.log(ret,'uploadFileRes')
  95. if(ret.status == 200){
  96. _this.avatarUrl = ret.data
  97. _this.$store.state.vuex_userPhoto = ret.data
  98. uni.setStorageSync('userPhoto', ret.data);
  99. saveHeadImage({photo: ret.data}).then(res => {
  100. if(res.status == 200){
  101. uni.showToast({
  102. icon: "none",
  103. title: "修改头像成功"
  104. })
  105. }
  106. })
  107. }else{
  108. uni.showToast({
  109. icon: "none",
  110. title: "修改头像失败,请重试"
  111. })
  112. }
  113. }
  114. });
  115. },
  116. quitOut(){
  117. let _this = this
  118. uni.showModal({
  119. title: '提示',
  120. content: '确定退出登录吗?',
  121. success: (ret) => {
  122. if(ret.confirm){
  123. _this.$store.dispatch('userLogout');
  124. uni.redirectTo({
  125. url: '/pages/login/login'
  126. });
  127. }
  128. }
  129. })
  130. }
  131. },
  132. }
  133. </script>
  134. <style lang="less" scoped>
  135. .content{
  136. padding: 0;
  137. background: rgb(245,245,245);
  138. .avatar-wrapper{
  139. width:100rpx;
  140. height:100rpx;
  141. background: none;
  142. padding: 0;
  143. border-radius: 100%;
  144. &::after{
  145. border:1px solid #eee;
  146. }
  147. }
  148. }
  149. .list-container{
  150. width: 100%;
  151. box-sizing:border-box;
  152. .border-bottom{
  153. padding-left: 32rpx;
  154. border-bottom: 1px solid #E5E5E5;
  155. }
  156. .margin-bot{
  157. margin-bottom: 20rpx;
  158. }
  159. .list-item{
  160. width: 100%;
  161. background-color: #fff;
  162. display: flex;
  163. padding: 30rpx 32rpx;
  164. justify-content: space-between;
  165. align-items:center;
  166. // border-bottom: 1px solid #E5E5E5;
  167. .user-photo{
  168. display: block;
  169. width: 100rpx;
  170. height: 100rpx;
  171. border-radius: 50%;
  172. overflow: hidden;
  173. }
  174. .list-item-left{
  175. font-size: 36rpx;
  176. color: #191919;
  177. }
  178. .list-item-right{
  179. font-size: 36rpx;
  180. color: #666666;
  181. .back-img{
  182. width: 18rpx;
  183. height: 34rpx;
  184. margin-left: 20rpx;
  185. }
  186. }
  187. }
  188. }
  189. .bottom-cont{
  190. width: 100%;
  191. background-color: #fff;
  192. height: 110rpx;
  193. font-size: 36rpx;
  194. color: #999999;
  195. text-align: center;
  196. line-height: 110rpx;
  197. margin-top: 20rpx;
  198. }
  199. </style>