user.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. <template>
  2. <view>
  3. <!-- 头部 -->
  4. <view class="user" :style="[background]"></view><!-- end 头部 -->
  5. <view class="header">
  6. <view class="user-info">
  7. <!-- 用户信息 -->
  8. <view class="flex row-between w-full">
  9. <view class="flex-1 lg">
  10. <view class="line-2" v-if="userInfo.nickname">{{userInfo.nickname}} </view>
  11. <router-link to="/pages/login/login" class="line-2" v-else>请登录</router-link>
  12. <view class="m-t-20 flex">{{userInfo.tel}}</view>
  13. </view>
  14. <block>
  15. <image class="avatar flex-none" mode="widthFix" :src="userInfo.avatar" v-if="userInfo.avatar" />
  16. <image class="avatar flex-none" :src="'/static/images/portrait_empty.png'" v-else />
  17. </block>
  18. </view>
  19. <!-- 分割线 -->
  20. <view class="m-t-20 m-b-20 user-line"></view>
  21. <!-- 统计 -->
  22. <view class="flex row-around w-full user-count">
  23. <view class="flex-1 flex flex-col col-center" v-for="(item, index) in userInfo.count" :key="index"
  24. @tap="menuJump(item)">
  25. <view class="lg primary">{{ item.count }}</view>
  26. <view>{{ item.title }}</view>
  27. </view>
  28. </view>
  29. </view>
  30. </view>
  31. <!-- 列表 -->
  32. <view class="user-opts" v-if="userInfo.nickname">
  33. <router-link :to="'/pages/user/footprint'" class="flex row-between col-center w-full">
  34. <image mode="widthFix" src="/static/images/ico_footprint.png"></image>
  35. <view class="flex-1 m-l-24">我的足迹</view>
  36. <u-icon name="arrow-right" color="#ABABAB" size="28"></u-icon>
  37. </router-link>
  38. <!-- 分割线 -->
  39. <view class="m-t-16 m-b-16 user-line"></view>
  40. <router-link :to="'/pages/user/company'" class="flex row-between col-center w-full">
  41. <image mode="widthFix" src="/static/images/ico_company.png"></image>
  42. <view class="flex-1 m-l-24">企业反馈</view>
  43. <u-icon name="arrow-right" color="#ABABAB" size="28"></u-icon>
  44. </router-link>
  45. <!-- 分割线 -->
  46. <view class="m-t-16 m-b-16 user-line"></view>
  47. <router-link :to="'/pages/feedback/feedback'" class="flex row-between col-center w-full">
  48. <image mode="widthFix" src="/static/images/ico_feedback.png"></image>
  49. <view class="flex-1 m-l-24">意见反馈</view>
  50. <u-icon name="arrow-right" color="#ABABAB" size="28"></u-icon>
  51. </router-link>
  52. </view>
  53. <!-- 退出 -->
  54. <view class="footer flex row-center" v-if="userInfo.nickname">
  55. <view class="user-logout flex col-center row-center white w-full" @tap="logout">
  56. <u-icon name="arrow-rightward" size="28"></u-icon>
  57. <view class="m-l-24">退出登录</view>
  58. </view>
  59. </view>
  60. <view v-else>
  61. <u-empty mode="permission" margin-top="180" icon-size="600" text="请使用企业身份登录"
  62. src="/static/images/permission.png">
  63. <router-link to="/pages/login/login" slot="bottom"
  64. class="flex row-center user-login white m-t-16 p-t-16 p-b-16 p-l-50 p-r-50">
  65. 点击登录
  66. </router-link>
  67. </u-empty>
  68. </view>
  69. <u-tabbar :list="tabarList"></u-tabbar>
  70. </view>
  71. </template>
  72. <script>
  73. import MescrollCompMixin from "@/components/mescroll-uni/mixins/mescroll-comp";
  74. import {
  75. mapGetters,
  76. mapActions,
  77. mapMutations
  78. } from 'vuex'
  79. import {
  80. authLogout
  81. } from '@/api/app';
  82. import {
  83. menuJump
  84. } from '@/utils/tools'
  85. import Cache from '@/utils/cache'
  86. const app = getApp()
  87. export default {
  88. mixins: [MescrollCompMixin],
  89. data() {
  90. return {
  91. navBg: 0,
  92. };
  93. },
  94. onLoad(options) {
  95. //配置referrer,防止图片403拒绝
  96. const oMeta = document.createElement('meta');
  97. oMeta.name = "referrer";
  98. oMeta.content = "no-referrer"
  99. document.getElementsByTagName('head')[0].appendChild(oMeta);
  100. this.setTabarList({
  101. type: 'map'
  102. })
  103. },
  104. onShow() {
  105. this.getUser();
  106. },
  107. onPullDownRefresh() {
  108. this.getConfig();
  109. this.getUser();
  110. setTimeout(function() {
  111. uni.stopPullDownRefresh();
  112. }, 500);
  113. },
  114. onPageScroll(e) {
  115. const top = uni.upx2px(100)
  116. const {
  117. scrollTop
  118. } = e
  119. let percent = scrollTop / top > 1 ? 1 : scrollTop / top
  120. this.navBg = percent
  121. },
  122. methods: {
  123. ...mapMutations(["setTabarList"]),
  124. ...mapActions(['getConfig', 'getUser']),
  125. logout() {
  126. authLogout().then(res => {
  127. if (res.code == 1) {
  128. this.$store.commit("logout");
  129. this.$toast({
  130. title: '退出成功'
  131. })
  132. setTimeout(() => {
  133. this.$Router.replaceAll('/pages/launch/launch')
  134. }, 500)
  135. }
  136. })
  137. },
  138. menuJump(item) {
  139. menuJump(item)
  140. },
  141. },
  142. computed: {
  143. ...mapGetters(['userInfo', 'appConfig', 'tabarList']),
  144. background() {
  145. const {
  146. mobile_user_bg
  147. } = this.appConfig
  148. console.log(mobile_user_bg)
  149. return mobile_user_bg ? {
  150. 'background-image': `url(${mobile_user_bg})`
  151. } : {
  152. 'background-image': 'url(/static/images/bg.png)'
  153. }
  154. },
  155. }
  156. };
  157. </script>
  158. <style lang="scss" scoped>
  159. page {
  160. background: $-color-white;
  161. }
  162. .user {
  163. // background-image: #F7F7F7;
  164. background-size: 100% auto;
  165. background-repeat: no-repeat;
  166. height: 424rpx;
  167. }
  168. .header {
  169. margin-top: -424rpx;
  170. padding: 182rpx 28rpx 0;
  171. .user-info {
  172. background: #FFFFFF;
  173. box-shadow: 0px 5px 10px 1px rgba(0, 0, 0, 0.08);
  174. border-radius: 8px 8px 8px 8px;
  175. padding: 40rpx;
  176. .avatar {
  177. height: 176rpx;
  178. width: 176rpx;
  179. border-radius: 50%;
  180. overflow: hidden;
  181. margin-top: -200rpx;
  182. }
  183. .user-count {
  184. color: #5D5D5D;
  185. }
  186. }
  187. }
  188. .user-line {
  189. border-bottom: $-solid-border;
  190. }
  191. .user-opts {
  192. padding: 50rpx;
  193. image {
  194. width: 70rpx;
  195. height: 70rpx;
  196. }
  197. }
  198. .footer {
  199. position: fixed;
  200. bottom: 134rpx;
  201. width: 100%;
  202. .user-logout {
  203. margin-left: 176rpx;
  204. margin-right: 176rpx;
  205. margin-bottom: 36rpx;
  206. height: 68rpx;
  207. background: #DD4250;
  208. box-shadow: 0rpx 6rpx 12rpx 2rpx rgba(243, 113, 113, 0.39);
  209. border-radius: 12rpx 12rpx 12rpx 12rpx;
  210. opacity: 1;
  211. border: 2rpx solid #DD4250;
  212. }
  213. }
  214. .user-login {
  215. background: #DD4250;
  216. box-shadow: 0rpx 6rpx 12rpx 2rpx rgba(243, 113, 113, 0.39);
  217. border-radius: 12rpx 12rpx 12rpx 12rpx;
  218. border: 2rpx solid #DD4250;
  219. }
  220. </style>