index.vue 15 KB

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