user-center.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475
  1. <template>
  2. <app-layout>
  3. <app-user-center-top
  4. :top-style="userCenter.top_style"
  5. :top-pic-url="userCenter.top_pic_url"
  6. :member-pic-url="userCenter.member_pic_url"
  7. :is_icon_super_vip="is_icon_super_vip"
  8. :user-name-color="userCenter.user_name_color"
  9. ></app-user-center-top>
  10. <view class="u-foot-box main-center" v-if="userCenter.is_foot_bar_status == 1">
  11. <view @click="router(item.name)" class="u-foot-item main-center" v-for="(item, key) in foot_bar" :key="key">
  12. <image class="u-icon" :src="item.icon_url"></image>
  13. <view class="u-foot-info">
  14. <view class="u-foot-num">{{item.name | showNum(userInfo)}}</view>
  15. <view>{{item.name}}</view>
  16. </view>
  17. </view>
  18. <view class="u-line"></view>
  19. </view>
  20. <view style="padding: 0 24rpx">
  21. <app-vip-card></app-vip-card>
  22. </view>
  23. <app-account-balance
  24. v-if="account_bar_status == 1"
  25. :margin="true"
  26. :round="true"
  27. :input-user-center="userCenter"
  28. ></app-account-balance>
  29. <app-my-order
  30. v-if="userCenter.is_order_bar_status == 1"
  31. :margin="true"
  32. :round="true"
  33. :theme="getTheme"
  34. :order_bar="userCenter.order_bar"
  35. ></app-my-order>
  36. <view class="app-my-service" v-if="userCenter.is_menu_status == 1">
  37. <view class="title" v-if="userCenter.menu_title">{{userCenter.menu_title}}</view>
  38. <view class="list" :class="[listStyle]">
  39. <!-- #ifdef MP -->
  40. <view class="item" v-for="(item, index) in userCenter.menus" :key="index" >
  41. <app-jump-button form
  42. :url="item.link_url"
  43. :open_type="item.open_type"
  44. :item="item"
  45. :arrangement="`${userCenter.menu_style === '1' ? 'row' : userCenter.menu_style === '2' ? 'column' : ''}`">
  46. <view style="width: 100%"
  47. class="item-container"
  48. :class="[
  49. userCenter.menu_style=='1'?'dir-left-nowrap cross-center':'',
  50. userCenter.menu_style=='2'?'dir-top-nowrap cross-center':'',
  51. ]">
  52. <view class="box-grow-0">
  53. <image :src="item.icon_url" class="icon"></image>
  54. </view>
  55. <view class="box-grow-1" style="max-width: 100%">
  56. <view class="name">{{item.name}}</view>
  57. </view>
  58. <view class="box-grow-0" v-if="userCenter.menu_style=='1'">
  59. <image src="/static/image/icon/arrow-right.png" class="arrow"></image>
  60. </view>
  61. </view>
  62. </app-jump-button>
  63. </view>
  64. <!-- #endif -->
  65. <!-- #ifdef H5 -->
  66. <block v-for="(item, index) in menus" :key="index">
  67. <view class="item" v-if="item.open_type !== 'app'">
  68. <app-jump-button form
  69. :url="item.link_url"
  70. :open_type="item.open_type"
  71. :item="item"
  72. :arrangement="`${userCenter.menu_style === '1' ? 'row' : userCenter.menu_style === '2' ? 'column' : ''}`">
  73. <view style="width: 100%"
  74. class="item-container"
  75. :class="[
  76. userCenter.menu_style=='1'?'dir-left-nowrap cross-center':'',
  77. userCenter.menu_style=='2'?'dir-top-nowrap cross-center':'',
  78. ]">
  79. <view class="box-grow-0">
  80. <image :src="item.icon_url" class="icon"></image>
  81. </view>
  82. <view class="box-grow-1" style="max-width: 100%">
  83. <view class="name">{{item.name}}</view>
  84. </view>
  85. <view class="box-grow-0" v-if="userCenter.menu_style=='1'">
  86. <image src="/static/image/icon/arrow-right.png" class="arrow"></image>
  87. </view>
  88. </view>
  89. </app-jump-button>
  90. </view>
  91. <view v-else :id="item.id" class="item"></view>
  92. </block>
  93. <!-- #endif -->
  94. </view>
  95. </view>
  96. <!-- #ifdef H5 -->
  97. <view v-if="userInfo && isShowSetting" class="bd-setting dir-left-nowrap main-between cross-center" @click="routerGo">
  98. <view>设置</view>
  99. <image src="./../../static/image/icon/arrow-right.png" class="bd-arrow"></image>
  100. </view>
  101. <!-- #endif -->
  102. <app-copyright
  103. v-if="copyright && copyright.status == '1'"
  104. background-color="transparent"
  105. :link="copyrightLink"
  106. :pic-url="copyright.pic_url"
  107. :text="copyright.description"
  108. ></app-copyright>
  109. </app-layout>
  110. </template>
  111. <script>
  112. import {mapGetters, mapState} from 'vuex';
  113. import AppUserCenterTop from '../../components/page-component/app-user-center-top/app-user-center-top.vue';
  114. import AppAccountBalance from '../../components/page-component/app-account-balance/app-account-balance.vue';
  115. import AppMyOrder from '../../components/page-component/app-my-order/app-my-order.vue';
  116. import AppCopyright from '../../components/page-component/app-copyright/app-copyright.vue';
  117. import AppVipCard from '../../components/page-component/app-vip-card/app-vip-card.vue';
  118. export default {
  119. name: 'user-center',
  120. components: {
  121. AppCopyright,
  122. AppUserCenterTop,
  123. AppAccountBalance,
  124. AppMyOrder,
  125. AppVipCard,
  126. },
  127. computed: {
  128. ...mapState({
  129. copyright: state => state.mallConfig.copyright,
  130. userInfo: state => state.user.info,
  131. is_icon_super_vip: function (state) {
  132. return state.mallConfig.mall.setting.is_icon_super_vip;
  133. },
  134. foot_bar: function(state) {
  135. return state.userCenter.data.foot_bar;
  136. },
  137. account_bar_status: function() {
  138. return this.userCenter.account_bar ? this.userCenter.account_bar.status : 0;
  139. },
  140. // #ifdef H5
  141. isWechat: function() {
  142. return this.$jwx.isWechat();
  143. },
  144. menus: function() {
  145. let menus = this.userCenter.menus;
  146. menus.forEach(item => {
  147. if(item.open_type === 'app') {
  148. item.id = this.$utils.guid('user-center');
  149. let username = this.$utils.getUrlParamApp(item.link_url, 'username');
  150. let path = this.$utils.getUrlParamApp(item.link_url, 'path');
  151. let strImg = ``;
  152. let size = uni.upx2px(50) + 'px';
  153. let style = `
  154. <style>
  155. .app-button-row {
  156. height: 100%;
  157. width: 100%;
  158. display: flex;
  159. flex-direction: row;
  160. justify-content: center;
  161. align-items: center;
  162. }
  163. .app-button-column {
  164. height: 100%;
  165. width: 100%;
  166. display: flex;
  167. flex-direction: column;
  168. justify-content: center;
  169. align-items: center;
  170. }
  171. .box-grow-0 {
  172. min-width: 0;
  173. -webkit-box-flex: 0;
  174. -webkit-flex-grow: 0;
  175. -ms-flex-positive: 0;
  176. flex-grow: 0;
  177. -webkit-flex-shrink: 0;
  178. -ms-flex-negative: 0;
  179. flex-shrink: 0;
  180. }
  181. .box-grow-1 {
  182. min-width: 0;
  183. -webkit-box-flex: 1;
  184. -webkit-flex-grow: 1;
  185. -ms-flex-positive: 1;
  186. flex-grow: 1;
  187. -webkit-flex-shrink: 1;
  188. -ms-flex-negative: 1;
  189. flex-shrink: 1;
  190. }
  191. .name {
  192. color: #666666;
  193. white-space: nowrap;
  194. overflow: hidden;
  195. text-overflow: ellipsis;
  196. }
  197. .dir-left-nowrap {
  198. display: -webkit-box;
  199. display: -webkit-flex;
  200. display: flex;
  201. -webkit-flex-direction: row;
  202. flex-direction: row;
  203. flex-wrap: nowrap;
  204. }
  205. .dir-top-nowrap {
  206. display: -webkit-box;
  207. display: -webkit-flex;
  208. display: flex;
  209. -webkit-box-orient: vertical;
  210. -webkit-flex-direction: column;
  211. flex-direction: column;
  212. flex-wrap: nowrap;
  213. }
  214. .cross-center {
  215. display: -webkit-box;
  216. display: -webkit-flex;
  217. display: flex;
  218. -webkit-align-items: center;
  219. align-items: center;
  220. }
  221. </style>
  222. `;
  223. let classStr = '';
  224. let font = '';
  225. let padding = '';
  226. let arrow = require("../../static/image/icon/arrow-right.png");
  227. if (this.userCenter.menu_style == 1) {
  228. let margin = uni.upx2px(16);
  229. strImg = `<img src="${item.icon_url}" width="${size}" height="${size}" style="margin-right: ${margin}px"/>`;
  230. font = '17px';
  231. padding = 0;
  232. } else if (this.userCenter.menu_style == 2) {
  233. let margin = uni.upx2px(28);
  234. strImg = `<img src="${item.icon_url}" width="${size}" height="${size}" style="margin-bottom: ${margin}px"/>`;
  235. classStr = 'name';
  236. font = uni.upx2px(24) + 'px';
  237. padding = `0px` + ' ' +uni.upx2px(12) +'px';
  238. }
  239. let str = `<div class="box-grow-0">${strImg}</div>
  240. <div class="box-grow-1" style="max-width: 100%;"><div style="padding:${padding};font-size: ${font}" class="${classStr}">${item.name}</div></div>`;
  241. if (this.userCenter.menu_style == 1) {
  242. let width = uni.upx2px(12);
  243. let height = uni.upx2px(22);
  244. str+= ` <div class="box-grow-0">
  245. <img src="${arrow}" width="${width}px" height="${height}px"/>
  246. </div>`
  247. }
  248. let div = ``;
  249. let div1 = '';
  250. if (this.userCenter.menu_style == 1) {
  251. let padding1 = uni.upx2px(20) + 'px';
  252. let padding2 = uni.upx2px(32) + 'px';
  253. div1 = `<div style="width: 100%;padding: ${padding1} ${padding2}" class="dir-left-nowrap cross-center">${str}</div>`
  254. } else {
  255. let padding = uni.upx2px(24) + 'px';
  256. div1 = `<div style="width: 100%;padding: ${padding} 0" class="dir-top-nowrap cross-center">${str}</div>`
  257. }
  258. if (this.userCenter.menu_style == 1) {
  259. div = `<div class="app-button-row">${div1}</div>`
  260. } else {
  261. div = `<div class="app-button-column">${div1}</div>`
  262. }
  263. style += div;
  264. this.$utils.createWxOpenLaunchWeapp(item.id, username, path, style);
  265. }
  266. });
  267. return menus;
  268. }
  269. // #endif
  270. }),
  271. copyrightLink() {
  272. if (!this.copyright) return {};
  273. let { open_type, new_link_url, params } = this.copyright.link;
  274. return {
  275. openType: open_type,
  276. url: new_link_url,
  277. params: params ? params : []
  278. };
  279. },
  280. ...mapGetters('mallConfig', {
  281. getTheme: 'getTheme'
  282. }),
  283. ...mapGetters('userCenter',{
  284. userCenter: 'userCenter'
  285. }),
  286. listStyle() {
  287. if (this.userCenter.menu_style == 1) return 'row';
  288. if (this.userCenter.menu_style == 2) return 'grid dir-left-wrap';
  289. return '';
  290. },
  291. // #ifdef H5
  292. isShowSetting: function () {
  293. return this.$storage.getStorageSync('platform') !== 'wechat';
  294. }
  295. // #endif
  296. },
  297. onLoad() { this.$commonLoad.onload();
  298. // #ifdef H5
  299. this.$jwx.config();
  300. // #endif
  301. },
  302. onShow() {
  303. this.$event.on(this.$const.EVENT_USER_LOGIN).then(() => {
  304. uni.redirectTo({
  305. url: `/pages/user-center/user-center`
  306. });
  307. });
  308. if (this.$user.isLogin()) {
  309. this.$store.dispatch('user/refresh');
  310. }
  311. this.$nextTick().then(() => {
  312. this.$store.dispatch('userCenter/data');
  313. });
  314. },
  315. methods: {
  316. router(name) {
  317. let url = '';
  318. if (name === '我的收藏') {
  319. url = `/pages/favorite/favorite`;
  320. } else {
  321. url = `/pages/foot/index/index`;
  322. }
  323. uni.navigateTo({
  324. url: url
  325. });
  326. },
  327. // #ifdef H5
  328. routerGo() {
  329. uni.navigateTo({
  330. url: '/pages/registered/setting'
  331. });
  332. },
  333. // #endif
  334. },
  335. filters: {
  336. showNum(name, userInfo) {
  337. if (name === '我的收藏') {
  338. return userInfo && userInfo.favorite ? userInfo.favorite : 0;
  339. } else {
  340. return userInfo && userInfo.footprint ? userInfo.footprint : 0;
  341. }
  342. }
  343. }
  344. }
  345. </script>
  346. <style scoped lang="scss">
  347. .app-my-service {
  348. width: #{702rpx};
  349. border-radius: #{16rpx};
  350. margin: #{24rpx} auto;
  351. box-shadow: 0 0 #{8rpx} rgba(0, 0, 0, .05);
  352. background: #fff;
  353. .title {
  354. padding: #{32rpx} #{32rpx} #{16rpx};
  355. }
  356. .list {
  357. .item {
  358. .icon {
  359. width: #{50rpx};
  360. height: #{50rpx};
  361. display: block;
  362. }
  363. .arrow {
  364. width: #{12rpx};
  365. height: #{22rpx};
  366. }
  367. }
  368. }
  369. .list.row {
  370. .item-container {
  371. padding: #{20rpx} #{32rpx};
  372. }
  373. .icon {
  374. margin-right: #{16rpx};
  375. }
  376. }
  377. .list.grid {
  378. .item {
  379. width: 25%;
  380. .icon {
  381. margin-bottom: #{28rpx};
  382. }
  383. .name {
  384. padding: 0 #{12rpx};
  385. font-size: $uni-font-size-weak-one;
  386. color: $uni-general-color-one;
  387. white-space: nowrap;
  388. overflow: hidden;
  389. text-overflow: ellipsis;
  390. }
  391. }
  392. .item-container {
  393. padding: #{24rpx} 0;
  394. }
  395. }
  396. }
  397. .u-foot-box {
  398. position: relative;
  399. height: 104upx;
  400. }
  401. .u-icon {
  402. margin-top: 44upx;
  403. width: 40upx;
  404. height: 40upx;
  405. margin-right: 17upx;
  406. }
  407. .u-foot-item {
  408. font-size: #{26rpx};
  409. color: #666666;
  410. padding-top: #{14rpx};
  411. width: 50%;
  412. }
  413. .u-foot-info {
  414. text-align: center;
  415. }
  416. .u-foot-num {
  417. font-size: 32upx;
  418. margin-bottom: 10upx;
  419. }
  420. .u-line {
  421. height: 40upx;
  422. width: 2upx;
  423. background-color: #666666;
  424. position: absolute;
  425. top: 45upx;
  426. left: 50%;
  427. margin-left: -2upx;
  428. }
  429. // #ifdef H5
  430. .bd-setting {
  431. width: 702upx;
  432. height: 100upx;
  433. line-height: 100upx;
  434. border-radius: 16upx;
  435. padding: 0 33upx;
  436. background: #ffffff;
  437. margin: 24upx auto;
  438. box-shadow: 0 0 #{8rpx} rgba(0, 0, 0, .05);
  439. font-size:32upx;
  440. color: #353535;
  441. }
  442. .bd-arrow {
  443. width: #{12rpx};
  444. height: #{22rpx};
  445. }
  446. // #endif
  447. </style>