index.vue 15 KB

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