user-center.vue 19 KB

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