user.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731
  1. <template>
  2. <view class="container user clearfix">
  3. <cm-custom :navbar-data="nvabarData" v-if="isCmcustom"></cm-custom>
  4. <view class="user-section">
  5. <view
  6. class="header"
  7. :style="{
  8. height: CustomBar + 120 - StatusBar + 'px',
  9. paddingTop: CustomBar + 'px',
  10. background: 'url(https://static.caimei365.com/app/mini-mcare/icon/icon_header@2x.png)',
  11. backgroundSize: 'cover'
  12. }"
  13. >
  14. <view class="header-main" v-if="hasLogin">
  15. <view class="header-icon">
  16. <view class="header-logo">
  17. <image :src="underInfo.shopPhoto ? underInfo.shopPhoto : `${staticUrl}icon_default@3x.png`" mode=""></image>
  18. </view>
  19. </view>
  20. <view class="header-text">
  21. <view class="user-item"
  22. ><text class="user-item-none">{{ underInfo.name | nameFilters }}</text></view
  23. >
  24. </view>
  25. </view>
  26. <view class="header-main" v-else-if="isUnderLogin">
  27. <view class="header-icon">
  28. <view class="header-logo">
  29. <image
  30. :src="underInfo.shopPhoto ? underInfo.shopPhoto : `${staticUrl}icon_default@3x.png`"
  31. mode=""
  32. ></image>
  33. </view>
  34. </view>
  35. <view class="header-text">
  36. <view class="user-item"
  37. ><text class="u-h1">{{ underInfo.name | nameFilters }}</text></view
  38. >
  39. <view class="user-item">
  40. <view class="user-item-tips none">
  41. <text v-if="underInfo.clubStatus === 1">待审核</text>
  42. <text v-if="underInfo.clubStatus === 92" @click="underNavigator"
  43. >审核未通过,请重新提交 ></text
  44. >
  45. </view>
  46. </view>
  47. </view>
  48. </view>
  49. <view class="header-main-none" v-else>
  50. <view class="header-icon" @click="navigator('/pages/login/login')">
  51. <view class="header-logo">
  52. <image :src="staticUrl + 'icon_default@2x.png'" mode=""></image>
  53. </view>
  54. </view>
  55. <view class="header-text">
  56. <view class="user-item" @click="navigator('/pages/login/login')"> 登录 / 注册 </view>
  57. </view>
  58. </view>
  59. <!-- 订单 -->
  60. <view class="header-main-order">
  61. <view class="user-order">
  62. <view class="tab-title" @click="navigator('/pages/user/order/order-list?state=0')">
  63. <text class="cell-tit">我的订单</text> <text class="cell-more">全部订单</text>
  64. <text class="iconfont icon-xiangyou"></text>
  65. </view>
  66. <view class="order-section">
  67. <view
  68. class="order-item"
  69. @click="navigator('/pages/user/order/order-list?state=2')"
  70. hover-class="common-hover"
  71. :hover-stay-time="50"
  72. >
  73. <view class="order-icon">
  74. <image :src="staticUrl + 'icon_order_2@2x.png'" mode=""></image>
  75. <text
  76. v-if="paymentCount > 0 && hasLogin"
  77. class="uni-badge uni-badge-error uni-small uni-badge--small icon-num "
  78. :class="[paymentCount < 10 ? 'goleft' : '']"
  79. >
  80. {{ paymentCount >= 99 ? '99+' : paymentCount }}
  81. </text>
  82. </view>
  83. <text class="order-t">待付款</text>
  84. </view>
  85. <view
  86. class="order-item"
  87. @click="navigator('/pages/user/order/order-list?state=3')"
  88. hover-class="common-hover"
  89. :hover-stay-time="50"
  90. >
  91. <view class="order-icon">
  92. <image :src="staticUrl + 'icon_order_3@2x.png'" mode=""></image>
  93. <text
  94. v-if="waitShipmentsCount > 0 && hasLogin"
  95. class="uni-badge uni-badge-error uni-small uni-badge--small icon-num"
  96. :class="[waitShipmentsCount < 10 ? 'goleft' : '']"
  97. >
  98. {{ waitShipmentsCount >= 99 ? '99+' : waitShipmentsCount }}
  99. </text>
  100. </view>
  101. <text class="order-t">待发货</text>
  102. </view>
  103. <view
  104. class="order-item"
  105. @click="navigator('/pages/user/order/order-list?state=4')"
  106. hover-class="common-hover"
  107. :hover-stay-time="50"
  108. >
  109. <view class="order-icon">
  110. <image :src="staticUrl + 'icon_order_4@2x.png'" mode=""></image>
  111. <text
  112. v-if="shipmentsCount > 0 && hasLogin"
  113. class="uni-badge uni-badge-error uni-small uni-badge--small icon-num"
  114. :class="[shipmentsCount < 10 ? 'goleft' : '']"
  115. >
  116. {{ shipmentsCount >= 99 ? '99+' : shipmentsCount }}
  117. </text>
  118. </view>
  119. <text class="order-t">已发货</text>
  120. </view>
  121. <view
  122. class="order-item"
  123. @click="navigator('/pages/user/order/order-list?state=5')"
  124. hover-class="common-hover"
  125. :hover-stay-time="50"
  126. >
  127. <view class="order-icon">
  128. <image :src="staticUrl + 'icon_order_5@2x.png'" mode=""></image>
  129. <text
  130. v-if="salesReturnCount > 0 && hasLogin"
  131. class="uni-badge uni-badge-error uni-small uni-badge--small icon-num"
  132. :class="[salesReturnCount < 10 ? 'goleft' : '']"
  133. >
  134. {{ salesReturnCount >= 99 ? '99+' : salesReturnCount }}
  135. </text>
  136. </view>
  137. <text class="order-t">退货/款</text>
  138. </view>
  139. </view>
  140. </view>
  141. </view>
  142. <!-- 底部跳转 -->
  143. <view class="header-main-listcell">
  144. <view class="list-cell-item">
  145. <view
  146. class="list-cell"
  147. v-for="(item, index) in firstList"
  148. :key="index"
  149. @click="navigator(item.path)"
  150. hover-class="cell-hover"
  151. :hover-stay-time="50"
  152. >
  153. <view class="cell-icon">
  154. <image class="cell-icon-image" :src="staticUrl + item.icon" mode=""></image>
  155. </view>
  156. <text class="cell-tit"> {{ item.name }} </text>
  157. <text class="cell-more iconfont icon-xiangyou"></text>
  158. </view>
  159. <!-- #ifdef MP-WEIXIN -->
  160. <button class="list-cell" open-type="contact" @bindcontact="handleContact">
  161. <view class="cell-icon">
  162. <image class="cell-icon-image" :src="staticUrl + 'icon_club_5@2x.png'" mode=""></image>
  163. </view>
  164. <text class="cell-tit"> 官方客服 </text>
  165. <text class="cell-more iconfont icon-xiangyou"></text>
  166. </button>
  167. <!-- #endif -->
  168. </view>
  169. </view>
  170. </view>
  171. </view>
  172. <!-- 技术支持 -->
  173. <view class="copyright">
  174. <image class="image" :src="staticUrl + 'icon_caimei@2x.png'"></image>
  175. <view class="text">由采美365网提供技术服务</view>
  176. </view>
  177. </view>
  178. </template>
  179. <script>
  180. import authorize from '@/common/config/authorize.js'
  181. import { mapState, mapMutations } from 'vuex'
  182. export default {
  183. data() {
  184. return {
  185. nvabarData: {
  186. // 顶部自定义导航
  187. showCapsule: 1, // 是否显示左上角图标 1表示显示 0表示不显示,
  188. showSearch: 0,
  189. title: '个人中心', // 导航栏中间的标题
  190. haveBack: false,
  191. textLeft: this.$store.state.isIphone,
  192. textColor: '#333333',
  193. bgColor: ''
  194. },
  195. staticUrl: this.global.staticUrl,
  196. CustomBar: this.CustomBar, // 顶部导航栏高度
  197. StatusBar: this.StatusBar,
  198. userId: 0,
  199. isCmcustom: false,
  200. name: '',
  201. confirmedCount: 0, // 待确认
  202. paymentCount: 0, // 待付款角标
  203. waitShipmentsCount: 0, // 待收货角标
  204. shipmentsCount: 0, // 已发货角标
  205. salesReturnCount: '', // 退货/款角标
  206. firstList: [
  207. {
  208. name: '收藏商品',
  209. path: '/pages/user/collection/collection',
  210. icon: 'icon_club_1@2x.png'
  211. },
  212. {
  213. name: '收货地址管理',
  214. path: '/pages/user/address/address',
  215. icon: 'icon_club_2@2x.png'
  216. },
  217. {
  218. name: '机构资料',
  219. path: '/pages/login/information',
  220. icon: 'icon_club_3@2x.png'
  221. },
  222. {
  223. name: '账户设置',
  224. path: '/pages/user/setting/setting',
  225. icon: 'icon_club_4@2x.png'
  226. }
  227. ],
  228. underInfo: {},
  229. isUnderLogin: false
  230. }
  231. },
  232. filters: {
  233. nameFilters(value) {
  234. if(value && value.length>15){
  235. return value.substring(0,15)+"..."
  236. }else{
  237. return value
  238. }
  239. }
  240. },
  241. onLoad(option) {},
  242. computed: {
  243. ...mapState(['hasLogin', 'userInfo', 'isWxAuthorize']),
  244. },
  245. methods: {
  246. ...mapMutations(['updateNoticeNum']),
  247. async infoClucbUser() {
  248. const user = await this.$api.getStorage()
  249. console.log(user)
  250. this.underInfo = user
  251. if (this.underInfo.clubStatus === 1 || this.underInfo.clubStatus === 92) {
  252. this.isUnderLogin = true
  253. }
  254. },
  255. async getClubObtainCenter() {
  256. // 获取个人中心数据
  257. try{
  258. const res = await this.UserService.GetClubObtainCenter({ userId: this.userId })
  259. let data = res.data
  260. this.underInfo = { ...this.underInfo , ...data.user }
  261. }catch(e){
  262. this.$util.msg(error.msg, 2000)
  263. }
  264. },
  265. UserClubOrderCount() {
  266. //获取订单状态数量
  267. this.OrderService.UserClubOrderCount({ userId: this.userId })
  268. .then(response => {
  269. let data = response.data
  270. this.confirmedCount = this.showBadge(data.confirmedCount) //待确认
  271. this.paymentCount = this.showBadge(data.paymentCount) //待付款
  272. this.waitShipmentsCount = this.showBadge(data.waitShipmentsCount) //待收货
  273. this.shipmentsCount = this.showBadge(data.shipmentsCount) //已发货
  274. this.salesReturnCount = this.showBadge(data.salesReturnCount) //退货/款
  275. })
  276. .catch(error => {
  277. console.log('获取订单状态数量异常~')
  278. })
  279. },
  280. toPhone() {
  281. // 拨号
  282. uni.makePhoneCall({
  283. phoneNumber: this.contactNumber //仅为示例
  284. })
  285. },
  286. navigator(url) {
  287. if (this.hasLogin) {
  288. this.$api.navigateTo(url)
  289. } else {
  290. this.$api.navigateTo('/pages/login/login?type=0')
  291. }
  292. },
  293. underNavigator() {
  294. // 审核未通过修改资料
  295. this.$api.navigateTo('/pages/login/register-unid')
  296. },
  297. showBadge(n) {
  298. let num = ''
  299. if (n > 100) {
  300. num = 99
  301. } else {
  302. num = n
  303. }
  304. return num
  305. },
  306. clubStatusText(state) {
  307. let stateText
  308. switch (state) {
  309. case 90:
  310. stateText = ''
  311. break
  312. case 1:
  313. stateText = '正在审核中'
  314. break
  315. case 92:
  316. stateText = '审核不通过'
  317. break
  318. }
  319. return stateText
  320. },
  321. async initUserData() {
  322. const userInfo = await this.$api.getComStorage('userInfo')
  323. this.userId = userInfo.userId ? userInfo.userId : 0
  324. this.getClubObtainCenter()
  325. this.UserClubOrderCount()
  326. }
  327. },
  328. onPageScroll(e) {
  329. //实时获取到滚动的值
  330. if (e.scrollTop > 20) {
  331. this.isCmcustom = true
  332. this.nvabarData.bgColor = '#FFFFFF'
  333. this.nvabarData.textColor = '#333333'
  334. } else {
  335. this.isCmcustom = false
  336. this.nvabarData.bgColor = ''
  337. this.nvabarData.textColor = '#FFFFFF'
  338. }
  339. },
  340. onPullDownRefresh() {
  341. //下拉刷新
  342. if (this.hasLogin) {
  343. this.getClubObtainCenter()
  344. this.UserClubOrderCount()
  345. uni.stopPullDownRefresh()
  346. } else {
  347. uni.stopPullDownRefresh()
  348. }
  349. },
  350. onShow() {
  351. if (this.hasLogin) {
  352. this.initUserData()
  353. } else {
  354. this.infoClucbUser()
  355. this.$store.commit('updateAllNum', 0)
  356. }
  357. }
  358. }
  359. </script>
  360. <style lang="scss">
  361. @import '@/uni.scss';
  362. page {
  363. background-color: #f7f7f7;
  364. }
  365. .user {
  366. width: 100%;
  367. height: 100%;
  368. position: relative;
  369. background: rgba(247, 247, 247, 1);
  370. }
  371. .header {
  372. width: 100%;
  373. position: relative;
  374. background-size: cover;
  375. }
  376. .header-main {
  377. width: 702rpx;
  378. height: 130rpx;
  379. padding: 12rpx 24rpx;
  380. display: flex;
  381. .header-text {
  382. flex: 8;
  383. display: flex;
  384. flex-direction: column;
  385. box-sizing: border-box;
  386. padding: 10rpx 0 0 0rpx;
  387. .user-item {
  388. flex: 1;
  389. height: 64rpx;
  390. line-height: 64rpx;
  391. .user-item-tips {
  392. display: inline-block;
  393. float: left;
  394. height: 40rpx;
  395. background: #fcc120;
  396. border-radius: 20rpx;
  397. line-height: 40rpx;
  398. font-size: $font-size-22;
  399. text-align: center;
  400. color: #ffffff;
  401. box-sizing: border-box;
  402. padding: 0 20rpx;
  403. position: relative;
  404. &.none {
  405. background: #f85050;
  406. }
  407. }
  408. .user-item-none{
  409. font-size: $font-size-32;
  410. line-height: 120rpx;
  411. color: #ffffff;
  412. text-align: left;
  413. display: inline-block;
  414. }
  415. .u-none {
  416. font-size: $font-size-32;
  417. line-height: 120rpx;
  418. color: #ffffff;
  419. text-align: left;
  420. }
  421. .u-h1 {
  422. width: 400rpx;
  423. float: left;
  424. font-size: $font-size-30;
  425. color: #ffffff;
  426. text-align: left;
  427. -o-text-overflow: ellipsis;
  428. text-overflow: ellipsis;
  429. display: -webkit-box;
  430. word-break: break-all;
  431. -webkit-box-orient: vertical;
  432. -webkit-line-clamp: 1;
  433. overflow: hidden;
  434. }
  435. .u-p {
  436. font-size: $font-size-24;
  437. line-height: 30rpx;
  438. color: #ffffff;
  439. text-align: left;
  440. }
  441. }
  442. }
  443. .header-icon {
  444. flex: 2;
  445. display: flex;
  446. margin-right: 20rpx;
  447. align-items: center;
  448. justify-content: center;
  449. .header-logo {
  450. width: 120rpx;
  451. height: 120rpx;
  452. box-sizing: border-box;
  453. background-color: #fff;
  454. border-radius: 100%;
  455. image {
  456. width: 120rpx;
  457. height: 120rpx;
  458. display: block;
  459. border-radius: 100%;
  460. }
  461. }
  462. }
  463. }
  464. .header-main-none {
  465. width: 702rpx;
  466. height: 152rpx;
  467. padding: 0 24rpx;
  468. display: flex;
  469. .header-text {
  470. flex: 8;
  471. display: flex;
  472. flex-direction: column;
  473. position: relative;
  474. box-sizing: border-box;
  475. padding: 20rpx 0;
  476. .user-item {
  477. flex: 1;
  478. height: 120rpx;
  479. line-height: 120rpx;
  480. font-size: $font-size-32;
  481. color: #ffffff;
  482. text-align: left;
  483. }
  484. }
  485. .header-icon {
  486. flex: 2;
  487. display: flex;
  488. margin-right: 20rpx;
  489. align-items: center;
  490. justify-content: center;
  491. .header-logo {
  492. width: 120rpx;
  493. height: 120rpx;
  494. box-sizing: border-box;
  495. padding: 21rpx;
  496. background-color: #fff;
  497. border-radius: 100%;
  498. image {
  499. width: 78rpx;
  500. height: 78rpx;
  501. display: block;
  502. }
  503. }
  504. }
  505. }
  506. .header-main-order {
  507. width: 100%;
  508. height: auto;
  509. box-sizing: border-box;
  510. padding: 0 24rpx;
  511. margin-top: 26rpx;
  512. .user-order {
  513. width: 100%;
  514. height: auto;
  515. background-color: $bg-color;
  516. margin-bottom: 24rpx;
  517. border-radius: 20rpx;
  518. box-sizing: border-box;
  519. padding: 0 24rpx;
  520. }
  521. }
  522. .tab-title {
  523. font-size: $font-size-28;
  524. line-height: 80rpx;
  525. color: #333333;
  526. text-align: left;
  527. border-bottom: 1px solid #f8f8f8;
  528. position: relative;
  529. .cell-tit {
  530. font-size: $font-size-28;
  531. color: $text-color;
  532. }
  533. .cell-more {
  534. float: right;
  535. line-height: 80rpx;
  536. font-size: $font-size-24;
  537. color: $text-color;
  538. padding-right: 30rpx;
  539. }
  540. .iconfont {
  541. width: 30rpx;
  542. height: 80rpx;
  543. line-height: 80rpx;
  544. text-align: center;
  545. position: absolute;
  546. right: 0;
  547. top: 0;
  548. display: block;
  549. font-size: $font-size-28;
  550. color: #b2b2b2;
  551. }
  552. }
  553. .order-section {
  554. display: flex;
  555. justify-content: space-around;
  556. align-items: center;
  557. flex-wrap: wrap;
  558. height: 99rpx;
  559. padding: 24rpx 0;
  560. }
  561. .order-item {
  562. flex: 1;
  563. display: flex;
  564. flex-direction: column;
  565. align-items: center;
  566. position: relative;
  567. &:last-child {
  568. margin-right: 0;
  569. }
  570. .order-icon {
  571. width: 72rpx;
  572. height: 72rpx;
  573. position: relative;
  574. image {
  575. width: 72rpx;
  576. height: 72rpx;
  577. }
  578. .icon-num {
  579. position: absolute;
  580. right: -24rpx;
  581. top: -9rpx;
  582. }
  583. .icon-num.goleft {
  584. right: -12rpx;
  585. }
  586. }
  587. .order-t {
  588. line-height: 50rpx;
  589. font-size: $font-size-24;
  590. color: $text-color;
  591. }
  592. }
  593. .header-main-last {
  594. width: 100%;
  595. height: 20rpx;
  596. float: left;
  597. box-sizing: border-box;
  598. }
  599. .header-main-listcell {
  600. width: 100%;
  601. height: auto;
  602. box-sizing: border-box;
  603. padding: 0 24rpx;
  604. margin-bottom: 60rpx;
  605. }
  606. .list-cell-item {
  607. width: 654rpx;
  608. height: auto;
  609. margin-bottom: 24rpx;
  610. padding: 0 24rpx;
  611. background: $bg-color;
  612. border-radius: 20rpx;
  613. }
  614. .list-cell {
  615. width: 100%;
  616. line-height: 100rpx;
  617. position: relative;
  618. background: $bg-color;
  619. border-bottom: 1px solid #ebebeb;
  620. height: 100rpx;
  621. &:last-child {
  622. border-bottom: none;
  623. }
  624. &.cell-hover {
  625. background: #fafafa;
  626. }
  627. .cell-icon {
  628. width: 60rpx;
  629. height: 100rpx;
  630. text-align: center;
  631. box-sizing: border-box;
  632. padding: 32rpx 12rpx;
  633. float: left;
  634. .cell-icon-image {
  635. width: 36rpx;
  636. height: 36rpx;
  637. display: block;
  638. }
  639. }
  640. .cell-more {
  641. height: 100rpx;
  642. line-height: 100rpx;
  643. text-align: right;
  644. position: absolute;
  645. right: 0;
  646. top: 0;
  647. font-size: $font-size-28;
  648. color: #b2b2b2;
  649. &.cont {
  650. width: 250rpx;
  651. }
  652. .txt {
  653. color: #fb4343;
  654. padding-right: 10rpx;
  655. }
  656. }
  657. .cell-tit {
  658. width: 465rpx;
  659. display: block;
  660. float: left;
  661. font-size: $font-size-28;
  662. color: #666666;
  663. margin-right: 10rpx;
  664. text-align: left;
  665. &.cont {
  666. width: 300rpx;
  667. }
  668. .cell-tips {
  669. width: 74rpx;
  670. height: 32rpx;
  671. line-height: 32rpx;
  672. padding: 0 7rpx;
  673. border-radius: 16rpx;
  674. background-color: #ffe6dc;
  675. color: $color-system;
  676. text-align: center;
  677. font-size: $font-size-20;
  678. margin-left: 8rpx;
  679. }
  680. }
  681. .cell-tip {
  682. font-size: $font-size-28;
  683. color: $text-color;
  684. }
  685. }
  686. .list-cell.last {
  687. border-bottom: none;
  688. }
  689. .uni-badge--small {
  690. -webkit-transform: scale(0.8);
  691. -ms-transform: scale(0.8);
  692. transform: scale(0.8);
  693. -webkit-transform-origin: center center;
  694. -ms-transform-origin: center center;
  695. transform-origin: center center;
  696. }
  697. .uni-badge {
  698. font-family: 'Helvetica Neue', Helvetica, sans-serif;
  699. -webkit-box-sizing: border-box;
  700. box-sizing: border-box;
  701. font-size: 12px;
  702. line-height: 1;
  703. display: inline-block;
  704. padding: 3px 6px;
  705. color: #333;
  706. border-radius: 100px;
  707. background-color: #f1f1f1;
  708. }
  709. .uni-badge-error {
  710. color: #fff;
  711. background-color: #dd524d;
  712. }
  713. .copyright {
  714. width: 100%;
  715. position: absolute;
  716. bottom: 40rpx;
  717. display: flex;
  718. flex-direction: column;
  719. align-items: center;
  720. image {
  721. width: 180rpx;
  722. height: 60rpx;
  723. }
  724. .text {
  725. font-size: 20rpx;
  726. color: #cccccc;
  727. }
  728. }
  729. </style>