personData.vue 4.8 KB

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