index.vue 18 KB

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