user.vue 5.1 KB

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