my.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. <template>
  2. <view>
  3. <!-- 顶部导航 -->
  4. <fa-navbar title="个人中心" :border-bottom="false"></fa-navbar>
  5. <!-- 会员中心 -->
  6. <view class="u-p-t-30 u-p-b-50 home" :style="[{ backgroundColor: theme.bgColor || '#374486' }]">
  7. <view class="userinfo" :style="[{ height: vuex_user.vip > 0 ? '370rpx' : '310rpx' }]">
  8. <block v-if="vuex_token">
  9. <u-avatar
  10. size="120"
  11. :show-sex="vuex_user.vip == 0"
  12. :show-level="vuex_user.vip > 0"
  13. :sex-icon="vuex_user.gender == 1 ? 'man' : 'woman'"
  14. :src="url || vuex_user.avatar"
  15. @click="chooseAvatar"
  16. ></u-avatar>
  17. <view class="u-skeleton-fillet u-m-t-15 u-p-l-80 u-p-r-80 u-line-1">{{ vuex_user.nickname || '' }}</view>
  18. <view class="u-m-t-15" v-if="vuex_user.vip > 0">
  19. <u-tag
  20. type="success"
  21. :text="vuex_user.vipInfo && vuex_user.vipInfo.name ? vuex_user.vipInfo.name : ''"
  22. mode="light"
  23. shape="circle"
  24. size="mini"
  25. />
  26. </view>
  27. <view class="u-skeleton-fillet u-m-t-15 u-p-l-80 u-p-r-80 u-line-2">{{ vuex_user.bio || '这家伙很懒,什么也没写!' }}</view>
  28. </block>
  29. <block v-else>
  30. <u-avatar size="120" src="0"></u-avatar>
  31. <view class="u-m-t-30"><u-button hover-class="none" size="mini" @click="goPage('/pages/login/login')">立即登录</u-button></view>
  32. </block>
  33. </view>
  34. <view class="corrugated">
  35. <view class="wave-top wave-item" :style="[{ backgroundImage: 'url(' + wavetop + ')', height: vuex_user.vip > 0 ? '230rpx' : '200rpx' }]"></view>
  36. <view
  37. class="wave-middle wave-item"
  38. :style="[{ backgroundImage: 'url(' + wavemiddle + ')', height: vuex_user.vip > 0 ? '230rpx' : '200rpx' }]"
  39. ></view>
  40. <view
  41. class="wave-bottom wave-item"
  42. :style="[{ backgroundImage: 'url(' + wavebottom + ')', height: vuex_user.vip > 0 ? '230rpx' : '200rpx' }]"
  43. ></view>
  44. </view>
  45. </view>
  46. <!-- 统计 -->
  47. <view class="u-flex u-text-center u-p-l-30 u-p-r-30 u-p-t-50 u-p-b-50 u-bg-white">
  48. <view class="u-flex-4" @click="goPage('/pages/logs/money', true)">
  49. <view class="u-text-weight u-font-28">
  50. <text v-text="vuex_user.money || 0"></text>
  51. </view>
  52. <view class="u-m-t-20">余额</view>
  53. </view>
  54. <view class="u-flex-4 u-border-left u-border-right" @click="goPage('/pages/logs/score', true)">
  55. <view class="u-text-weight u-font-28"><text v-text="vuex_user.score || 0"></text></view>
  56. <view class="u-m-t-20">积分</view>
  57. </view>
  58. <view class="u-flex-4">
  59. <view class="u-text-weight u-font-28">
  60. Lv.
  61. <text v-text="vuex_user.level || 0"></text>
  62. </view>
  63. <view class="u-m-t-20">等级</view>
  64. </view>
  65. </view>
  66. <!-- 导航 -->
  67. <view class="u-m-t-30">
  68. <u-cell-group>
  69. <!-- <u-cell-item icon="chat-fill" title="我发表的评论" @click="goPage('/pages/my/comment', true)"></u-cell-item> -->
  70. <u-cell-item icon="level" title="我的VIP会员" @click="goPage('/pages/my/member', true)"></u-cell-item>
  71. <u-cell-item icon="heart-fill" title="我的收藏" @click="goPage('/pages/my/collection', true)"></u-cell-item>
  72. <u-cell-item icon="order" title="我的消费订单" @click="goPage('/pages/my/myorder', true)"></u-cell-item>
  73. <u-cell-item icon="pushpin-fill" title="每日一签" @click="goPage('/pages/signin/signin', true)"></u-cell-item>
  74. <!-- <u-cell-item icon="edit-pen-fill" title="我发布的文章" @click="goPage('/pages/publish/myarticle', true)"></u-cell-item> -->
  75. <u-cell-item icon="account-fill" title="个人资料" @click="goPage('/pages/my/profile', true)"></u-cell-item>
  76. <u-cell-item icon="man-add-fill" v-if="isBind" title="绑定账号" @click="goPage('/pages/my/bind', true)"></u-cell-item>
  77. <!-- <u-cell-item icon="edit-pen" title="发布文章" @click="goPage('/pages/publish/channel', true)"></u-cell-item> -->
  78. <!-- <u-cell-item icon="info-circle" title="关于我们" @click="goPage('/pages/my/about')"></u-cell-item>
  79. <u-cell-item icon="file-text-fill" title="自定义表单列表" @click="goPage('/pages/diyform/lists')"></u-cell-item> -->
  80. <u-cell-item icon="backspace" v-if="vuex_token" title="退出登录" @click="goPage('out')"></u-cell-item>
  81. </u-cell-group>
  82. </view>
  83. <u-top-tips ref="uTips" :navbar-height="statusBarHeight + navbarHeight"></u-top-tips>
  84. <!-- 底部导航 -->
  85. <fa-tabbar></fa-tabbar>
  86. </view>
  87. </template>
  88. <script>
  89. import { avatar } from '@/common/fa.mixin.js';
  90. export default {
  91. mixins: [avatar],
  92. computed: {
  93. wavetop() {
  94. return this.$u.http.config.baseUrl + '/assets/addons/cms/img/wave-top.png';
  95. },
  96. wavemiddle() {
  97. return this.$u.http.config.baseUrl + '/assets/addons/cms/img/wave-mid.png';
  98. },
  99. wavebottom() {
  100. return this.$u.http.config.baseUrl + '/assets/addons/cms/img/wave-bot.png';
  101. },
  102. isBind() {
  103. return false;
  104. }
  105. },
  106. onShow() {
  107. if (this.vuex_token) {
  108. this.getUserIndex();
  109. } else {
  110. this.$u.vuex('vuex_user', {});
  111. }
  112. //移除事件监听
  113. uni.$off('uAvatarCropper', this.upload);
  114. },
  115. data() {
  116. return {
  117. // 状态栏高度,H5中,此值为0,因为H5不可操作状态栏
  118. statusBarHeight: uni.getSystemInfoSync().statusBarHeight,
  119. // 导航栏内容区域高度,不包括状态栏高度在内
  120. navbarHeight: 44,
  121. url: '',
  122. form: {
  123. avatar: ''
  124. }
  125. };
  126. },
  127. methods: {
  128. getUserIndex: async function() {
  129. let res = await this.$api.getUserIndex();
  130. uni.stopPullDownRefresh();
  131. if (!res.code) {
  132. this.$u.toast(res.msg);
  133. return;
  134. }
  135. this.$u.vuex('vuex_user', res.data.userInfo || {});
  136. },
  137. goPage: async function(path, auth) {
  138. if (auth && !this.vuex_token) {
  139. this.$u.toast('请先登录再操作!');
  140. return;
  141. }
  142. if (path == 'out') {
  143. let res = await this.$api.goUserLogout();
  144. if (!res.code) {
  145. this.$u.toast(res.msg);
  146. return;
  147. }
  148. //退出成功
  149. this.$u.vuex('vuex_user', { avatar: '' }); //清除vuex_user
  150. this.$u.vuex('vuex_token', ''); //清除用户token
  151. return;
  152. }
  153. if (path == '/pages/my/member' && !this.vuex_user.is_install_vip) {
  154. this.$refs.uTips.show({
  155. title: '请先安装VIP会员插件或启用该插件',
  156. type: 'error',
  157. duration: '3000'
  158. });
  159. return;
  160. }
  161. if (path == '/pages/signin/signin' && !this.vuex_user.is_install_signin) {
  162. this.$refs.uTips.show({
  163. title: '请先安装会员签到插件插件或启用该插件',
  164. type: 'error',
  165. duration: '3000'
  166. });
  167. return;
  168. }
  169. this.$Router.push(path);
  170. },
  171. editAvatar: async function() {
  172. let res = await this.$api.goUserAvatar({
  173. avatar: this.form.avatar
  174. });
  175. }
  176. },
  177. //下拉刷新
  178. onPullDownRefresh() {
  179. if (this.vuex_token) {
  180. this.getUserIndex();
  181. } else {
  182. uni.stopPullDownRefresh();
  183. this.$u.toast('请先登录');
  184. this.$u.vuex('vuex_user', {});
  185. }
  186. }
  187. };
  188. </script>
  189. <style lang="scss">
  190. page {
  191. background-color: #f4f6f8;
  192. }
  193. .home {
  194. position: relative;
  195. .userinfo {
  196. display: flex;
  197. flex-direction: column;
  198. align-items: center;
  199. padding: 30rpx 0;
  200. z-index: 100;
  201. .u-skeleton-fillet {
  202. color: #ffffff;
  203. width: 100vw;
  204. text-align: center;
  205. }
  206. }
  207. .corrugated {
  208. bottom: -2rpx;
  209. left: 0;
  210. position: absolute;
  211. width: 100%;
  212. height: 50%;
  213. overflow: hidden;
  214. z-index: 0;
  215. .wave-item {
  216. position: absolute;
  217. width: 200%;
  218. left: 0;
  219. background-repeat: repeat no-repeat;
  220. background-position: 0 bottom;
  221. transform-origin: center bottom;
  222. }
  223. .wave-top {
  224. opacity: 0.5;
  225. animation: wave-animation 3s;
  226. animation-delay: 1s;
  227. background-size: 50% 60rpx;
  228. z-index: 15;
  229. }
  230. .wave-middle {
  231. opacity: 0.75;
  232. animation: wavemove 10s linear infinite;
  233. background-size: 50% 80rpx;
  234. z-index: 10;
  235. }
  236. .wave-bottom {
  237. animation: wavemove 15s linear infinite;
  238. background-size: 50% 45rpx;
  239. z-index: 5;
  240. }
  241. }
  242. }
  243. @keyframes wavemove {
  244. 0% {
  245. transform: translateX(0) translateZ(0) scaleY(1);
  246. }
  247. 50% {
  248. transform: translateX(-25%) translateZ(0) scaleY(0.55);
  249. }
  250. 100% {
  251. transform: translateX(-50%) translateZ(0) scaleY(1);
  252. }
  253. }
  254. </style>