personData.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  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 {saveEmployee } 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. saveEmployee({id:_this.userInfo.userid,photo: ret.data}).then(res => {
  102. if(res.status == 200){
  103. uni.showToast({
  104. icon: "none",
  105. title: "修改头像成功"
  106. })
  107. }
  108. })
  109. }else{
  110. uni.showToast({
  111. icon: "none",
  112. title: "修改头像失败,请重试"
  113. })
  114. }
  115. }
  116. });
  117. },
  118. loginOut(){
  119. this.$refs.openModal.open()
  120. },
  121. onOk(){
  122. this.$refs.openModal.close()
  123. this.$store.dispatch('userLogout');
  124. setTimeout(function(){
  125. uni.redirectTo({
  126. url: '/pages/login/login'
  127. });
  128. },300)
  129. }
  130. },
  131. onLoad() {
  132. this.avatarUrl = this.userInfo.extInfo.userExtInfo ? this.userInfo.extInfo.userExtInfo.headImage : ''
  133. },
  134. }
  135. </script>
  136. <style lang="less" scoped>
  137. .content{
  138. padding: 0;
  139. background: rgb(245,245,245);
  140. .avatar-wrapper{
  141. width:100rpx;
  142. height:100rpx;
  143. background: none;
  144. padding: 0;
  145. border-radius: 100%;
  146. &::after{
  147. border:1px solid #eee;
  148. }
  149. }
  150. }
  151. .list-container{
  152. width: 100%;
  153. box-sizing:border-box;
  154. .border-bottom{
  155. padding-left: 32rpx;
  156. border-bottom: 1px solid #E5E5E5;
  157. }
  158. .margin-bot{
  159. margin-bottom: 20rpx;
  160. }
  161. .list-item{
  162. width: 100%;
  163. background-color: #fff;
  164. display: flex;
  165. padding: 30rpx 32rpx;
  166. justify-content: space-between;
  167. align-items:center;
  168. // border-bottom: 1px solid #E5E5E5;
  169. .user-photo{
  170. display: block;
  171. width: 100rpx;
  172. height: 100rpx;
  173. border-radius: 50%;
  174. overflow: hidden;
  175. }
  176. .list-item-left{
  177. font-size: 36rpx;
  178. color: #191919;
  179. }
  180. .list-item-right{
  181. font-size: 36rpx;
  182. color: #666666;
  183. .back-img{
  184. width: 18rpx;
  185. height: 34rpx;
  186. margin-left: 20rpx;
  187. }
  188. }
  189. }
  190. }
  191. .bottom-cont{
  192. position: fixed;
  193. bottom: 0;
  194. width: 100%;
  195. background-color: #fff;
  196. height: 110rpx;
  197. font-size: 36rpx;
  198. color: #999999;
  199. text-align: center;
  200. line-height: 110rpx;
  201. }
  202. </style>