index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701
  1. <template>
  2. <view class="new-users copy-data">
  3. <!-- #ifdef APP-PLUS || H5 -->
  4. <view class="status_bar1"></view>
  5. <view class="" style="margin-top: var(--status-bar-height);">
  6. <uni-nav-bar height="55px" title="个人中心" backgroundColor="#ea3322" color="#fff"></uni-nav-bar>
  7. </view>
  8. <!-- #endif -->
  9. <view class="mid" style="flex:1;overflow: hidden;">
  10. <scroll-view scroll-y="true" style="height: 100%;">
  11. <view class="bg"></view>
  12. <view class="head pad30">
  13. <view class="user-card">
  14. <view class="user-info">
  15. <!-- 头像 -->
  16. <image class="avatar" :src='userInfo.avatar' v-if="userInfo.avatar" @click="goEdit" />
  17. <image v-else class="avatar" src="/static/images/f.png" mode="" @click="goEdit()"></image>
  18. <!-- 昵称 -->
  19. <view class="info">
  20. <view class="name" v-if="!isLogin" @tap="openAuto">请点击登录</view>
  21. <view class="name" v-else>
  22. {{ userInfo.nickname }}
  23. <view class="vip" v-if="userInfo.level">
  24. <image :src="userInfo.level.icon" alt="" />
  25. <view style="margin-left: 10rpx;" class="vip-txt">{{ userInfo.level.name || ''}}
  26. </view>
  27. </view>
  28. </view>
  29. <!-- 手机 -->
  30. <view class="num" v-if="userInfo.mobile" @click="goEdit">
  31. <view class="num-txt">{{userInfo.mobile}}</view>
  32. <view class="icon">
  33. <image src="/static/images/edit.png" mode="" />
  34. </view>
  35. </view>
  36. <view class="phone" v-else-if="isLogin" @tap="bindPhone">绑定手机号</view>
  37. </view>
  38. </view>
  39. <view class="sign" @click="goSignIn">签到</view>
  40. </view>
  41. <!-- 订单中心 -->
  42. <view class="order-wrapper">
  43. <view class="order-hd flex">
  44. <view class="left">订单中心</view>
  45. <navigator class="right flex" hover-class="none" url="/pages/users/order_list/index"
  46. open-type="navigate">
  47. 查看全部
  48. <text class="iconfont icon-xiangyou"></text>
  49. </navigator>
  50. </view>
  51. <view class="order-bd">
  52. <block v-for="(item,index) in orderMenu" :key="index">
  53. <navigator class="order-item" hover-class="none" :url="item.url">
  54. <view class="pic">
  55. <image :src="item.img" mode=""></image>
  56. <text class="order-status-num" v-if="item.num > 0">{{ item.num }}</text>
  57. </view>
  58. <view class="txt">{{item.title}}</view>
  59. </navigator>
  60. </block>
  61. </view>
  62. </view>
  63. </view>
  64. <view class="contenBox">
  65. <!-- 轮播 -->
  66. <view class="slider-wrapper" v-if="slideShows.length>0">
  67. <swiper indicator-dots="true" :autoplay="autoplay" :circular="circular" :interval="interval"
  68. :duration="duration" indicator-color="rgba(255,255,255,0.6)" indicator-active-color="#fff">
  69. <block v-for="(item,index) in slideShows" :key="index">
  70. <swiper-item class="borRadius14">
  71. <image :src="item.picUrl" class="slide-image" @click="navito(item.url)"></image>
  72. </swiper-item>
  73. </block>
  74. </swiper>
  75. </view>
  76. <!-- 会员菜单 -->
  77. <view class="user-menus" style="margin-top: 20rpx;">
  78. <view class="menu-title">我的服务</view>
  79. <view class="list-box">
  80. <block v-for="(item,index) in menus" :key="index">
  81. <navigator class="item" :url="item.url" hover-class="none" v-if="!(item.url ==='/pages/service/index'
  82. || (item.url === '/pages/users/user_spread_user/index' && brokerageUser && !brokerageUser.brokerageEnabled))">
  83. <image :src="item.picUrl"></image>
  84. <text>{{ item.name }}</text>
  85. </navigator>
  86. </block>
  87. <!-- TODO 芋艿:以后联系客服的方式,重新搞下 -->
  88. <!-- #ifndef MP -->
  89. <view class="item" @click="kefuClick">
  90. <image :src="servicePic"></image>
  91. <text>联系客服</text>
  92. </view>
  93. <!-- #endif -->
  94. <!-- #ifdef MP -->
  95. <button class="item" open-type='contact' hover-class='none'>
  96. <image :src="servicePic"></image>
  97. <text>联系客服</text>
  98. </button>
  99. <!-- #endif -->
  100. </view>
  101. </view>
  102. <!-- 余额 -->
  103. <view class="wallet-box">
  104. <navigator url="/pages/users/user_money/index" hover-class="none">
  105. <view class="wallet acea-row row-between-wrapper" v-if="userInfo.mobile">
  106. <view>余额</view>
  107. <view class="input">
  108. {{ userInfo.nowMoney ? Number(userInfo.nowMoney).toFixed(2) : 0 }}<text class="iconfont icon-xiangyou"></text>
  109. </view>
  110. </view>
  111. </navigator>
  112. <navigator url="/pages/users/user_integral/index" hover-class="none">
  113. <view class="wallet acea-row row-between-wrapper" v-if="userInfo.mobile">
  114. <view>积分</view>
  115. <view class="input">
  116. <text class="iconfont icon-xiangyou"></text>
  117. </view>
  118. </view>
  119. </navigator>
  120. <navigator url="/pages/users/user_coupon/index" hover-class="none">
  121. <view class="wallet acea-row row-between-wrapper" v-if="userInfo.mobile">
  122. <view>优惠卷</view>
  123. <view class="input">
  124. <text class="iconfont icon-xiangyou"></text>
  125. </view>
  126. </view>
  127. </navigator>
  128. <navigator url="/pages/users/user_goods_collection/index" hover-class="none">
  129. <view class="wallet acea-row row-between-wrapper" v-if="userInfo.mobile">
  130. <view>收藏</view>
  131. <view class="input">
  132. <text class="iconfont icon-xiangyou"></text>
  133. </view>
  134. </view>
  135. </navigator>
  136. </view>
  137. <!-- <image src="/static/images/support.png" alt="" class='support' />
  138. <view class="uni-p-b-98"></view> -->
  139. </view>
  140. </scroll-view>
  141. </view>
  142. </view>
  143. </template>
  144. <script>
  145. import {
  146. getBrokerageUser
  147. } from "../../api/trade/brokerage";
  148. let sysHeight = uni.getSystemInfoSync().statusBarHeight + 'px';
  149. import Cache from '@/utils/cache';
  150. import {
  151. BACK_URL
  152. } from '@/config/cache';
  153. import {
  154. toLogin
  155. } from '@/libs/login.js';
  156. import {
  157. mapGetters
  158. } from "vuex";
  159. import * as TradeOrderApi from '@/api/trade/order.js';
  160. import * as AfterSaleApi from '@/api/trade/afterSale.js';
  161. import * as DecorateApi from '@/api/promotion/decorate.js';
  162. import * as ProductFavoriteApi from '@/api/product/favorite.js';
  163. import * as CouponApi from '@/api/promotion/coupon.js';
  164. import * as BrokerageAPI from '@/api/trade/brokerage.js'
  165. const app = getApp();
  166. export default {
  167. computed: mapGetters(['isLogin', 'chatUrl', 'userInfo']),
  168. data() {
  169. return {
  170. orderMenu: [{
  171. img: '/static/images/order1.png',
  172. title: '待付款',
  173. url: '/pages/users/order_list/index?status=0',
  174. num: 0
  175. },
  176. {
  177. img: '/static/images/order2.png',
  178. title: '待发货',
  179. url: '/pages/users/order_list/index?status=1',
  180. num: 0
  181. },
  182. {
  183. img: '/static/images/order3.png',
  184. title: '待收货',
  185. url: '/pages/users/order_list/index?status=2',
  186. num: 0
  187. },
  188. {
  189. img: '/static/images/order4.png',
  190. title: '待评价',
  191. url: '/pages/users/order_list/index?status=3',
  192. num: 0
  193. },
  194. {
  195. img: '/static/images/order5.png',
  196. title: '售后/退款',
  197. url: '/pages/users/user_return_list/index',
  198. num: 0
  199. },
  200. ],
  201. brokerageUser: {}, // 分销信息
  202. slideShows: [], // 轮播图
  203. circular: true,
  204. interval: 3000,
  205. duration: 500,
  206. autoplay: true,
  207. menus: [], // 用户菜单
  208. servicePic: '/static/images/customer.png',
  209. favoriteCount: 0, // 收藏数量
  210. couponCount: 0, // 优惠劵数量
  211. sysHeight: sysHeight,
  212. // #ifdef MP
  213. pageHeight: '100%',
  214. // #endif
  215. // #ifdef H5
  216. pageHeight: app.globalData.windowHeight,
  217. // #endif
  218. }
  219. },
  220. onLoad() {
  221. console.log(this.userInfo,'userInfouserInfouserInfouserInfo')
  222. // #ifdef H5
  223. this.$set(this, 'pageHeight', app.globalData.windowHeight);
  224. // #endif
  225. this.$set(this, 'menus', app.globalData.MyMenus);
  226. },
  227. onShow: function() {
  228. let that = this;
  229. // #ifdef H5
  230. uni.getSystemInfo({
  231. success: function(res) {
  232. that.pageHeight = res.windowHeight + 'px'
  233. }
  234. });
  235. // #endif
  236. if (this.isLogin) {
  237. this.getMyMenus();
  238. // this.setVisit();
  239. this.getUserInfo();
  240. this.getOrderData();
  241. }
  242. },
  243. methods: {
  244. // 记录会员访问
  245. // setVisit(){
  246. // setVisit({
  247. // url:'/pages/user/index'
  248. // }).then(res=>{})
  249. // },
  250. navito(e) {
  251. window.location.href = 'https://' + e;
  252. },
  253. kefuClick() {
  254. location.href = this.chatUrl;
  255. },
  256. getUserInfo() {
  257. // 刷新用户信息
  258. this.$store.dispatch('USERINFO');
  259. // 获取各种数量
  260. ProductFavoriteApi.getFavoriteCount().then(res => {
  261. this.favoriteCount = res.data;
  262. })
  263. CouponApi.getUnusedCouponCount().then(res => {
  264. this.couponCount = res.data;
  265. })
  266. // 获取分销信息
  267. BrokerageAPI.getBrokerageUser().then(res => {
  268. this.brokerageUser = res.data;
  269. })
  270. },
  271. getOrderData() {
  272. TradeOrderApi.getOrderCount().then(res => {
  273. this.orderMenu.forEach((item) => {
  274. switch (item.title) {
  275. case '待付款':
  276. item.num = res.data.unpaidCount
  277. break
  278. case '待发货':
  279. item.num = res.data.undeliveredCount
  280. break
  281. case '待收货':
  282. item.num = res.data.deliveredCount
  283. break
  284. case '待评价':
  285. item.num = res.data.uncommentedCount
  286. break
  287. }
  288. })
  289. this.$set(this, 'orderMenu', this.orderMenu);
  290. })
  291. AfterSaleApi.getApplyingAfterSaleCount().then(res => {
  292. const afterSaleOrderMenu = this.orderMenu.filter(item => item.title === '售后/退款')
  293. if (afterSaleOrderMenu) {
  294. afterSaleOrderMenu[0].num = res.data
  295. this.$set(this, 'orderMenu', this.orderMenu);
  296. }
  297. })
  298. },
  299. // 打开授权
  300. openAuto() {
  301. Cache.set(BACK_URL, '')
  302. toLogin();
  303. },
  304. // 绑定手机
  305. bindPhone() {
  306. uni.navigateTo({
  307. url: '/pages/users/app_login/index'
  308. })
  309. },
  310. /**
  311. * 获取个人中心图标
  312. */
  313. getMyMenus: function() {
  314. if (this.menus.length > 0) {
  315. return;
  316. }
  317. DecorateApi.getDecorateComponentListByPage(2).then(res => {
  318. // 轮播图
  319. const slideShow = res.data.find(item => item.code === 'slide-show');
  320. if (slideShow) {
  321. this.$set(this, "slideShows", JSON.parse(slideShow.value));
  322. }
  323. // 菜单
  324. const menu = res.data.find(item => item.code === 'menu');
  325. if (menu) {
  326. this.$set(this, "menus", JSON.parse(menu.value));
  327. }
  328. })
  329. },
  330. // 编辑页面
  331. goEdit() {
  332. if (!this.isLogin) {
  333. toLogin();
  334. return;
  335. }
  336. uni.navigateTo({
  337. url: '/pages/users/user_info/index'
  338. })
  339. },
  340. // 签到
  341. goSignIn() {
  342. uni.navigateTo({
  343. url: '/pages/users/user_sgin/index'
  344. })
  345. },
  346. // goMenuPage
  347. goMenuPage(url) {
  348. if (this.isLogin) {
  349. uni.navigateTo({
  350. url
  351. })
  352. } else {
  353. // #ifdef MP||APP-PLUS
  354. this.openAuto()
  355. // #endif
  356. }
  357. }
  358. }
  359. }
  360. </script>
  361. <style lang="scss" scoped>
  362. page,
  363. body {
  364. height: 100%;
  365. }
  366. .bg {
  367. position: absolute;
  368. left: 0;
  369. top: 0;
  370. width: 100%;
  371. height: 420rpx;
  372. background-image: url('~@/static/images/user_bg.png');
  373. background-repeat: no-repeat;
  374. background-size: 100% 100%;
  375. }
  376. .contenBox {
  377. padding: 0 30rpx;
  378. }
  379. .support {
  380. width: 219rpx;
  381. height: 74rpx;
  382. margin: 54rpx auto;
  383. display: block;
  384. }
  385. .new-users {
  386. display: flex;
  387. flex-direction: column;
  388. height: 100%;
  389. .status_bar1{
  390. background-color: #ea3322;
  391. width: 100%;
  392. height: var(--status-bar-height);
  393. position: fixed;
  394. top: 0;
  395. z-index: 999;
  396. }
  397. .sys-head {
  398. position: relative;
  399. width: 100%;
  400. background: linear-gradient(90deg, $bg-star1 0%, $bg-end1 100%);
  401. .sys-title {
  402. z-index: 10;
  403. position: relative;
  404. height: 43px;
  405. text-align: center;
  406. line-height: 43px;
  407. font-size: 36rpx;
  408. color: #FFFFFF;
  409. }
  410. }
  411. .head {
  412. background: linear-gradient(360deg, rgba(255, 121, 49, 0) 0%, rgba(248, 74, 29, 0.82) 39%, #E93323 100%);
  413. // padding: 0 30rpx;
  414. .user-card {
  415. position: relative;
  416. width: 100%;
  417. margin: 0 auto;
  418. padding: 35rpx 0 30rpx 0;
  419. .user-info {
  420. z-index: 20;
  421. position: relative;
  422. display: flex;
  423. .avatar {
  424. width: 120rpx;
  425. height: 120rpx;
  426. border-radius: 50%;
  427. }
  428. .info {
  429. flex: 1;
  430. display: flex;
  431. flex-direction: column;
  432. justify-content: space-between;
  433. margin-left: 20rpx;
  434. padding: 15rpx 0;
  435. .name {
  436. display: flex;
  437. align-items: center;
  438. color: #fff;
  439. font-size: 31rpx;
  440. .vip {
  441. display: flex;
  442. align-items: center;
  443. padding: 6rpx 20rpx;
  444. background: rgba(0, 0, 0, 0.2);
  445. border-radius: 18px;
  446. font-size: 20rpx;
  447. margin-left: 12rpx;
  448. image {
  449. width: 27rpx;
  450. height: 27rpx;
  451. }
  452. }
  453. }
  454. .num {
  455. display: flex;
  456. align-items: center;
  457. font-size: 26rpx;
  458. color: rgba(255, 255, 255, 0.6);
  459. image {
  460. width: 22rpx;
  461. height: 23rpx;
  462. margin-left: 20rpx;
  463. }
  464. }
  465. }
  466. }
  467. .num-wrapper {
  468. z-index: 30;
  469. position: relative;
  470. display: flex;
  471. align-items: center;
  472. justify-content: space-between;
  473. margin-top: 30rpx;
  474. color: #fff;
  475. .num-item {
  476. width: 33.33%;
  477. text-align: center;
  478. .num {
  479. font-size: 42rpx;
  480. font-weight: bold;
  481. }
  482. .txt {
  483. margin-top: 10rpx;
  484. font-size: 26rpx;
  485. color: rgba(255, 255, 255, 0.6);
  486. }
  487. }
  488. }
  489. .sign {
  490. z-index: 200;
  491. position: absolute;
  492. right: -12rpx;
  493. top: 80rpx;
  494. display: flex;
  495. align-items: center;
  496. justify-content: center;
  497. width: 120rpx;
  498. height: 60rpx;
  499. background: linear-gradient(90deg, rgba(255, 225, 87, 1) 0%, rgba(238, 193, 15, 1) 100%);
  500. border-radius: 29rpx 4rpx 4rpx 29rpx;
  501. color: #282828;
  502. font-size: 28rpx;
  503. font-weight: bold;
  504. }
  505. }
  506. .order-wrapper {
  507. background-color: #fff;
  508. border-radius: 14rpx;
  509. padding: 30rpx 16rpx;
  510. position: relative;
  511. z-index: 11;
  512. .order-hd {
  513. justify-content: space-between;
  514. font-size: 30rpx;
  515. color: #282828;
  516. margin-bottom: 40rpx;
  517. padding: 0 16rpx;
  518. .left {
  519. color: #282828;
  520. font-size: 30rpx;
  521. font-weight: 600;
  522. }
  523. .right {
  524. align-items: center;
  525. color: #666666;
  526. font-size: 26rpx;
  527. .icon-xiangyou {
  528. margin-left: 5rpx;
  529. font-size: 24rpx;
  530. }
  531. }
  532. }
  533. .order-bd {
  534. display: flex;
  535. justify-content: space-between;
  536. padding: 0;
  537. .order-item {
  538. display: flex;
  539. flex-direction: column;
  540. justify-content: center;
  541. align-items: center;
  542. .pic {
  543. position: relative;
  544. text-align: center;
  545. image {
  546. width: 48rpx;
  547. height: 48rpx;
  548. }
  549. }
  550. .txt {
  551. margin-top: 15rpx;
  552. font-size: 26rpx;
  553. color: #454545;
  554. }
  555. }
  556. }
  557. }
  558. }
  559. .slider-wrapper {
  560. margin: 20rpx 0;
  561. height: 138rpx;
  562. swiper,
  563. swiper-item {
  564. height: 100%;
  565. }
  566. image {
  567. width: 100%;
  568. height: 100%;
  569. }
  570. }
  571. .user-menus {
  572. background-color: #fff;
  573. border-radius: 14rpx;
  574. .menu-title {
  575. padding: 30rpx 30rpx 40rpx;
  576. font-size: 30rpx;
  577. color: #282828;
  578. font-weight: 600;
  579. }
  580. .list-box {
  581. display: flex;
  582. flex-wrap: wrap;
  583. padding: 0;
  584. }
  585. .item {
  586. position: relative;
  587. display: flex;
  588. align-items: center;
  589. justify-content: space-between;
  590. flex-direction: column;
  591. width: 25%;
  592. margin-bottom: 47rpx;
  593. font-size: 26rpx;
  594. color: #333333;
  595. image {
  596. width: 52rpx;
  597. height: 52rpx;
  598. margin-bottom: 18rpx;
  599. }
  600. &:last-child::before {
  601. display: none;
  602. }
  603. }
  604. button {
  605. font-size: 28rpx;
  606. }
  607. }
  608. .wallet-box{
  609. background-color: #fff;
  610. margin-top: 20rpx;
  611. border-radius: 14rpx;
  612. font-size: 32rpx;
  613. .wallet{
  614. border-bottom: 1rpx solid #f2f2f2;
  615. padding: 24rpx;
  616. font-size: 32rpx;
  617. color: #282828;
  618. .input{
  619. color: #2D2D2D;
  620. font-size: 36rpx;
  621. }
  622. }
  623. }
  624. .phone {
  625. color: #fff;
  626. }
  627. .order-status-num {
  628. min-width: 12rpx;
  629. background-color: #fff;
  630. color: #ee5a52;
  631. border-radius: 15px;
  632. position: absolute;
  633. right: -14rpx;
  634. top: -15rpx;
  635. font-size: 20rpx;
  636. padding: 0 8rpx;
  637. border: 1px solid #ee5a52;
  638. }
  639. }
  640. ::v-deep .uni-navbar--border {
  641. border: none !important;
  642. }
  643. </style>