user.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  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>
  61. </template>
  62. <script>
  63. import MescrollCompMixin from "@/components/mescroll-uni/mixins/mescroll-comp";
  64. import {
  65. mapGetters,
  66. mapActions
  67. } from 'vuex'
  68. import {
  69. authLogout
  70. } from '@/api/app';
  71. import {
  72. menuJump
  73. } from '@/utils/tools'
  74. import Cache from '@/utils/cache'
  75. const app = getApp()
  76. export default {
  77. mixins: [MescrollCompMixin],
  78. data() {
  79. return {
  80. navBg: 0,
  81. };
  82. },
  83. onLoad(options) {
  84. //配置referrer,防止图片403拒绝
  85. const oMeta = document.createElement('meta');
  86. oMeta.name = "referrer";
  87. oMeta.content = "no-referrer"
  88. document.getElementsByTagName('head')[0].appendChild(oMeta);
  89. },
  90. onShow() {
  91. this.getUser();
  92. },
  93. onPullDownRefresh() {
  94. this.getConfig();
  95. this.getUser();
  96. setTimeout(function() {
  97. uni.stopPullDownRefresh();
  98. }, 500);
  99. },
  100. onPageScroll(e) {
  101. const top = uni.upx2px(100)
  102. const {
  103. scrollTop
  104. } = e
  105. let percent = scrollTop / top > 1 ? 1 : scrollTop / top
  106. this.navBg = percent
  107. },
  108. methods: {
  109. ...mapActions(['getConfig', 'getUser']),
  110. logout() {
  111. authLogout().then(res => {
  112. if (res.code == 1) {
  113. this.$store.commit("logout");
  114. this.$toast({
  115. title: '退出成功'
  116. })
  117. setTimeout(() => {
  118. this.$Router.replaceAll('/pages/launch/launch')
  119. }, 500)
  120. }
  121. })
  122. },
  123. menuJump(item) {
  124. menuJump(item)
  125. },
  126. },
  127. computed: {
  128. ...mapGetters(['userInfo', 'appConfig']),
  129. background() {
  130. const {
  131. mobile_user_bg
  132. } = this.appConfig
  133. console.log(mobile_user_bg)
  134. return mobile_user_bg ? {
  135. 'background-image': `url(${mobile_user_bg})`
  136. } : {
  137. 'background-image': 'url(/static/images/bg.png)'
  138. }
  139. },
  140. }
  141. };
  142. </script>
  143. <style lang="scss" scoped>
  144. page {
  145. background: $-color-white;
  146. }
  147. .user {
  148. // background-image: #F7F7F7;
  149. background-size: 100% auto;
  150. background-repeat: no-repeat;
  151. height: 424rpx;
  152. }
  153. .header {
  154. margin-top: -424rpx;
  155. padding: 182rpx 28rpx 0;
  156. .user-info {
  157. background: #FFFFFF;
  158. box-shadow: 0px 5px 10px 1px rgba(0, 0, 0, 0.08);
  159. border-radius: 8px 8px 8px 8px;
  160. padding: 40rpx;
  161. .avatar {
  162. height: 176rpx;
  163. width: 176rpx;
  164. border-radius: 50%;
  165. overflow: hidden;
  166. margin-top: -200rpx;
  167. }
  168. .user-count {
  169. color: #5D5D5D;
  170. }
  171. }
  172. }
  173. .user-line {
  174. border-bottom: $-solid-border;
  175. }
  176. .user-opts {
  177. padding: 50rpx;
  178. image {
  179. width: 70rpx;
  180. height: 70rpx;
  181. }
  182. }
  183. .footer {
  184. position: fixed;
  185. bottom: 134rpx;
  186. width: 100%;
  187. .user-logout {
  188. margin-left: 176rpx;
  189. margin-right: 176rpx;
  190. margin-bottom: 36rpx;
  191. height: 68rpx;
  192. background: #DD4250;
  193. box-shadow: 0rpx 6rpx 12rpx 2rpx rgba(243, 113, 113, 0.39);
  194. border-radius: 12rpx 12rpx 12rpx 12rpx;
  195. opacity: 1;
  196. border: 2rpx solid #DD4250;
  197. }
  198. }
  199. </style>