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="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. uni.setStorageSync('userPhoto', ret.data);
  101. saveHeadImage({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. quitOut(){
  119. let _this = this
  120. uni.showModal({
  121. title: '提示',
  122. content: '确定退出登录吗?',
  123. success: (ret) => {
  124. if(ret.confirm){
  125. _this.$store.dispatch('userLogout');
  126. uni.redirectTo({
  127. url: '/pages/login/login'
  128. });
  129. }
  130. }
  131. })
  132. }
  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>