personData.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  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,uniPopupDialog
  65. },
  66. data() {
  67. return {
  68. title:'',
  69. avatarUrl:""
  70. }
  71. },
  72. computed: {
  73. ...mapState(['hasLogin']),
  74. userInfo(){
  75. return this.$store.state.vuex_userInfo
  76. },
  77. shelfInfo(){
  78. return this.$store.state.vuex_storeShelf
  79. },
  80. },
  81. onShow() {
  82. //检测是否登录
  83. this.$store.dispatch('checkLogin');
  84. this.avatarUrl = this.$store.state.vuex_userPhoto || uni.getStorageSync('userPhoto');
  85. },
  86. methods: {
  87. onChooseAvatar(e) {
  88. const _this = this
  89. const { avatarUrl } = e.detail
  90. uni.uploadFile({
  91. url: baseUrl + 'upload',
  92. filePath: avatarUrl,
  93. name: 'file',
  94. success: (uploadFileRes) => {
  95. const ret = JSON.parse(uploadFileRes.data)
  96. console.log(ret,'uploadFileRes')
  97. if(ret.status == 200){
  98. _this.avatarUrl = ret.data
  99. _this.$store.state.vuex_userPhoto = ret.data
  100. saveHeadImage({photo: ret.data}).then(res => {
  101. if(res.status == 200){
  102. uni.showToast({
  103. icon: "none",
  104. title: "修改头像成功"
  105. })
  106. }
  107. })
  108. }else{
  109. uni.showToast({
  110. icon: "none",
  111. title: "修改头像失败,请重试"
  112. })
  113. }
  114. }
  115. });
  116. },
  117. quitOut(){
  118. let _this = this
  119. uni.showModal({
  120. title: '提示',
  121. content: '确定退出登录吗?',
  122. success: (ret) => {
  123. if(ret.confirm){
  124. _this.$store.dispatch('userLogout');
  125. uni.redirectTo({
  126. url: '/pages/login/login'
  127. });
  128. }
  129. }
  130. })
  131. }
  132. },
  133. }
  134. </script>
  135. <style lang="less" scoped>
  136. .content{
  137. padding: 0;
  138. background: rgb(245,245,245);
  139. .avatar-wrapper{
  140. width:100rpx;
  141. height:100rpx;
  142. background: none;
  143. padding: 0;
  144. border-radius: 100%;
  145. &::after{
  146. border:1px solid #eee;
  147. }
  148. }
  149. }
  150. .list-container{
  151. width: 100%;
  152. box-sizing:border-box;
  153. .border-bottom{
  154. padding-left: 32rpx;
  155. border-bottom: 1px solid #E5E5E5;
  156. }
  157. .margin-bot{
  158. margin-bottom: 20rpx;
  159. }
  160. .list-item{
  161. width: 100%;
  162. background-color: #fff;
  163. display: flex;
  164. padding: 30rpx 32rpx;
  165. justify-content: space-between;
  166. align-items:center;
  167. // border-bottom: 1px solid #E5E5E5;
  168. .user-photo{
  169. display: block;
  170. width: 100rpx;
  171. height: 100rpx;
  172. border-radius: 50%;
  173. overflow: hidden;
  174. }
  175. .list-item-left{
  176. font-size: 36rpx;
  177. color: #191919;
  178. }
  179. .list-item-right{
  180. font-size: 36rpx;
  181. color: #666666;
  182. .back-img{
  183. width: 18rpx;
  184. height: 34rpx;
  185. margin-left: 20rpx;
  186. }
  187. }
  188. }
  189. }
  190. .bottom-cont{
  191. position: fixed;
  192. bottom: 0;
  193. width: 100%;
  194. background-color: #fff;
  195. height: 110rpx;
  196. font-size: 36rpx;
  197. color: #999999;
  198. text-align: center;
  199. line-height: 110rpx;
  200. }
  201. </style>