user.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737
  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 }}</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 }}</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. isModify: false,
  200. isCmcustom: false,
  201. name: '',
  202. userType: '',
  203. shopPhoto: '',
  204. userVip: {}, // 超级会员信息
  205. userBeans: 0,
  206. userMoney: '0.00',
  207. couponNum: 0,
  208. bankNum: 0,
  209. contactNumber: '',
  210. openid: '',
  211. aboutHtml: '',
  212. telPhone: '',
  213. isSvip: false,
  214. isSvipType: 2,
  215. userIdentity: '', // 机构等级
  216. confirmedCount: 0, // 待确认
  217. paymentCount: 0, // 待付款角标
  218. waitShipmentsCount: 0, // 待收货角标
  219. shipmentsCount: 0, // 已发货角标
  220. salesReturnCount: '', // 退货/款角标
  221. firstList: [
  222. {
  223. name: '收藏商品',
  224. path: '/pages/user/collection/collection',
  225. icon: 'icon_club_1@2x.png'
  226. },
  227. {
  228. name: '收货地址管理',
  229. path: '/pages/user/address/address',
  230. icon: 'icon_club_2@2x.png'
  231. },
  232. {
  233. name: '机构资料',
  234. path: '/pages/login/information',
  235. icon: 'icon_club_3@2x.png'
  236. },
  237. {
  238. name: '账户设置',
  239. path: '/pages/user/setting/setting',
  240. icon: 'icon_club_4@2x.png'
  241. }
  242. ],
  243. underInfo: {},
  244. isUnderLogin: false
  245. }
  246. },
  247. onLoad(option) {},
  248. computed: {
  249. ...mapState(['hasLogin', 'userInfo', 'isWxAuthorize'])
  250. },
  251. methods: {
  252. ...mapMutations(['updateNoticeNum']),
  253. async infoClucbUser() {
  254. const user = await this.$api.getStorage()
  255. console.log(user)
  256. this.underInfo = user
  257. if (this.underInfo.clubStatus === 1 || this.underInfo.clubStatus === 92) {
  258. this.isUnderLogin = true
  259. }
  260. },
  261. async getClubObtainCenter() {
  262. // 获取个人中心数据
  263. try{
  264. const res = await this.UserService.GetClubObtainCenter({ userId: this.userId })
  265. let data = res.data
  266. this.underInfo = { ...this.underInfo , ...data.user }
  267. }catch(e){
  268. this.$util.msg(error.msg, 2000)
  269. }
  270. },
  271. UserClubOrderCount() {
  272. //获取订单状态数量
  273. this.OrderService.UserClubOrderCount({ userId: this.userId })
  274. .then(response => {
  275. let data = response.data
  276. this.confirmedCount = this.showBadge(data.confirmedCount) //待确认
  277. this.paymentCount = this.showBadge(data.paymentCount) //待付款
  278. this.waitShipmentsCount = this.showBadge(data.waitShipmentsCount) //待收货
  279. this.shipmentsCount = this.showBadge(data.shipmentsCount) //已发货
  280. this.salesReturnCount = this.showBadge(data.salesReturnCount) //退货/款
  281. })
  282. .catch(error => {
  283. console.log('获取订单状态数量异常~')
  284. })
  285. },
  286. toPhone() {
  287. // 拨号
  288. uni.makePhoneCall({
  289. phoneNumber: this.contactNumber //仅为示例
  290. })
  291. },
  292. navigator(url) {
  293. if (this.hasLogin) {
  294. this.$api.navigateTo(url)
  295. } else {
  296. this.$api.navigateTo('/pages/login/login?type=0')
  297. }
  298. },
  299. underNavigator() {
  300. // 审核未通过修改资料
  301. this.$api.navigateTo('/pages/login/register-unid')
  302. },
  303. showBadge(n) {
  304. let num = ''
  305. if (n > 100) {
  306. num = 99
  307. } else {
  308. num = n
  309. }
  310. return num
  311. },
  312. clubStatusText(state) {
  313. let stateText
  314. switch (state) {
  315. case 90:
  316. stateText = ''
  317. break
  318. case 1:
  319. stateText = '正在审核中'
  320. break
  321. case 92:
  322. stateText = '审核不通过'
  323. break
  324. }
  325. return stateText
  326. },
  327. async initUserData() {
  328. const userInfo = await this.$api.getComStorage('userInfo')
  329. this.userId = userInfo.userId ? userInfo.userId : 0
  330. this.getClubObtainCenter()
  331. this.UserClubOrderCount()
  332. }
  333. },
  334. onPageScroll(e) {
  335. //实时获取到滚动的值
  336. if (e.scrollTop > 20) {
  337. this.isCmcustom = true
  338. this.nvabarData.bgColor = '#FFFFFF'
  339. this.nvabarData.textColor = '#333333'
  340. } else {
  341. this.isCmcustom = false
  342. this.nvabarData.bgColor = ''
  343. this.nvabarData.textColor = '#FFFFFF'
  344. }
  345. },
  346. onPullDownRefresh() {
  347. //下拉刷新
  348. if (this.hasLogin) {
  349. this.getClubObtainCenter()
  350. this.UserClubOrderCount()
  351. uni.stopPullDownRefresh()
  352. } else {
  353. uni.stopPullDownRefresh()
  354. }
  355. },
  356. onShow() {
  357. if (this.hasLogin) {
  358. this.initUserData()
  359. } else {
  360. this.infoClucbUser()
  361. this.$store.commit('updateAllNum', 0)
  362. }
  363. }
  364. }
  365. </script>
  366. <style lang="scss">
  367. @import '@/uni.scss';
  368. page {
  369. background-color: #f7f7f7;
  370. }
  371. .user {
  372. width: 100%;
  373. height: 100%;
  374. position: relative;
  375. background: rgba(247, 247, 247, 1);
  376. }
  377. .header {
  378. width: 100%;
  379. position: relative;
  380. background-size: cover;
  381. }
  382. .header-main {
  383. width: 702rpx;
  384. height: 130rpx;
  385. padding: 12rpx 24rpx;
  386. display: flex;
  387. .header-text {
  388. flex: 8;
  389. display: flex;
  390. flex-direction: column;
  391. box-sizing: border-box;
  392. padding: 10rpx 0 0 0rpx;
  393. .user-item {
  394. flex: 1;
  395. height: 64rpx;
  396. line-height: 64rpx;
  397. .user-item-tips {
  398. display: inline-block;
  399. float: left;
  400. height: 40rpx;
  401. background: #fcc120;
  402. border-radius: 20rpx;
  403. line-height: 40rpx;
  404. font-size: $font-size-22;
  405. text-align: center;
  406. color: #ffffff;
  407. box-sizing: border-box;
  408. padding: 0 20rpx;
  409. position: relative;
  410. &.none {
  411. background: #f85050;
  412. }
  413. }
  414. .user-item-none{
  415. font-size: $font-size-32;
  416. line-height: 50rpx;
  417. color: #ffffff;
  418. text-align: left;
  419. display: inline-block;
  420. }
  421. .u-none {
  422. font-size: $font-size-32;
  423. line-height: 120rpx;
  424. color: #ffffff;
  425. text-align: left;
  426. }
  427. .u-h1 {
  428. width: 400rpx;
  429. float: left;
  430. font-size: $font-size-30;
  431. color: #ffffff;
  432. text-align: left;
  433. -o-text-overflow: ellipsis;
  434. text-overflow: ellipsis;
  435. display: -webkit-box;
  436. word-break: break-all;
  437. -webkit-box-orient: vertical;
  438. -webkit-line-clamp: 1;
  439. overflow: hidden;
  440. }
  441. .u-p {
  442. font-size: $font-size-24;
  443. line-height: 30rpx;
  444. color: #ffffff;
  445. text-align: left;
  446. }
  447. }
  448. }
  449. .header-icon {
  450. flex: 2;
  451. display: flex;
  452. margin-right: 20rpx;
  453. align-items: center;
  454. justify-content: center;
  455. .header-logo {
  456. width: 120rpx;
  457. height: 120rpx;
  458. box-sizing: border-box;
  459. background-color: #fff;
  460. border-radius: 100%;
  461. image {
  462. width: 120rpx;
  463. height: 120rpx;
  464. display: block;
  465. border-radius: 100%;
  466. }
  467. }
  468. }
  469. }
  470. .header-main-none {
  471. width: 702rpx;
  472. height: 152rpx;
  473. padding: 0 24rpx;
  474. display: flex;
  475. .header-text {
  476. flex: 8;
  477. display: flex;
  478. flex-direction: column;
  479. position: relative;
  480. box-sizing: border-box;
  481. padding: 20rpx 0;
  482. .user-item {
  483. flex: 1;
  484. height: 120rpx;
  485. line-height: 120rpx;
  486. font-size: $font-size-32;
  487. color: #ffffff;
  488. text-align: left;
  489. }
  490. }
  491. .header-icon {
  492. flex: 2;
  493. display: flex;
  494. margin-right: 20rpx;
  495. align-items: center;
  496. justify-content: center;
  497. .header-logo {
  498. width: 120rpx;
  499. height: 120rpx;
  500. box-sizing: border-box;
  501. padding: 21rpx;
  502. background-color: #fff;
  503. border-radius: 100%;
  504. image {
  505. width: 78rpx;
  506. height: 78rpx;
  507. display: block;
  508. }
  509. }
  510. }
  511. }
  512. .header-main-order {
  513. width: 100%;
  514. height: auto;
  515. box-sizing: border-box;
  516. padding: 0 24rpx;
  517. margin-top: 26rpx;
  518. .user-order {
  519. width: 100%;
  520. height: auto;
  521. background-color: $bg-color;
  522. margin-bottom: 24rpx;
  523. border-radius: 20rpx;
  524. box-sizing: border-box;
  525. padding: 0 24rpx;
  526. }
  527. }
  528. .tab-title {
  529. font-size: $font-size-28;
  530. line-height: 80rpx;
  531. color: #333333;
  532. text-align: left;
  533. border-bottom: 1px solid #f8f8f8;
  534. position: relative;
  535. .cell-tit {
  536. font-size: $font-size-28;
  537. color: $text-color;
  538. }
  539. .cell-more {
  540. float: right;
  541. line-height: 80rpx;
  542. font-size: $font-size-24;
  543. color: $text-color;
  544. padding-right: 30rpx;
  545. }
  546. .iconfont {
  547. width: 30rpx;
  548. height: 80rpx;
  549. line-height: 80rpx;
  550. text-align: center;
  551. position: absolute;
  552. right: 0;
  553. top: 0;
  554. display: block;
  555. font-size: $font-size-28;
  556. color: #b2b2b2;
  557. }
  558. }
  559. .order-section {
  560. display: flex;
  561. justify-content: space-around;
  562. align-items: center;
  563. flex-wrap: wrap;
  564. height: 99rpx;
  565. padding: 24rpx 0;
  566. }
  567. .order-item {
  568. flex: 1;
  569. display: flex;
  570. flex-direction: column;
  571. align-items: center;
  572. position: relative;
  573. &:last-child {
  574. margin-right: 0;
  575. }
  576. .order-icon {
  577. width: 52rpx;
  578. height: 52rpx;
  579. position: relative;
  580. image {
  581. width: 52rpx;
  582. height: 52rpx;
  583. }
  584. .icon-num {
  585. position: absolute;
  586. right: -24rpx;
  587. top: -9rpx;
  588. }
  589. .icon-num.goleft {
  590. right: -12rpx;
  591. }
  592. }
  593. .order-t {
  594. line-height: 50rpx;
  595. font-size: $font-size-24;
  596. color: $text-color;
  597. }
  598. }
  599. .header-main-last {
  600. width: 100%;
  601. height: 20rpx;
  602. float: left;
  603. box-sizing: border-box;
  604. }
  605. .header-main-listcell {
  606. width: 100%;
  607. height: auto;
  608. box-sizing: border-box;
  609. padding: 0 24rpx;
  610. margin-bottom: 60rpx;
  611. }
  612. .list-cell-item {
  613. width: 654rpx;
  614. height: auto;
  615. margin-bottom: 24rpx;
  616. padding: 0 24rpx;
  617. background: $bg-color;
  618. border-radius: 20rpx;
  619. }
  620. .list-cell {
  621. width: 100%;
  622. line-height: 100rpx;
  623. position: relative;
  624. background: $bg-color;
  625. border-bottom: 1px solid #ebebeb;
  626. height: 100rpx;
  627. &:last-child {
  628. border-bottom: none;
  629. }
  630. &.cell-hover {
  631. background: #fafafa;
  632. }
  633. .cell-icon {
  634. width: 60rpx;
  635. height: 100rpx;
  636. text-align: center;
  637. box-sizing: border-box;
  638. padding: 32rpx 12rpx;
  639. float: left;
  640. .cell-icon-image {
  641. width: 36rpx;
  642. height: 36rpx;
  643. display: block;
  644. }
  645. }
  646. .cell-more {
  647. height: 100rpx;
  648. line-height: 100rpx;
  649. text-align: right;
  650. position: absolute;
  651. right: 0;
  652. top: 0;
  653. font-size: $font-size-28;
  654. color: #b2b2b2;
  655. &.cont {
  656. width: 250rpx;
  657. }
  658. .txt {
  659. color: #fb4343;
  660. padding-right: 10rpx;
  661. }
  662. }
  663. .cell-tit {
  664. width: 465rpx;
  665. display: block;
  666. float: left;
  667. font-size: $font-size-28;
  668. color: #666666;
  669. margin-right: 10rpx;
  670. text-align: left;
  671. &.cont {
  672. width: 300rpx;
  673. }
  674. .cell-tips {
  675. width: 74rpx;
  676. height: 32rpx;
  677. line-height: 32rpx;
  678. padding: 0 7rpx;
  679. border-radius: 16rpx;
  680. background-color: #ffe6dc;
  681. color: $color-system;
  682. text-align: center;
  683. font-size: $font-size-20;
  684. margin-left: 8rpx;
  685. }
  686. }
  687. .cell-tip {
  688. font-size: $font-size-28;
  689. color: $text-color;
  690. }
  691. }
  692. .list-cell.last {
  693. border-bottom: none;
  694. }
  695. .uni-badge--small {
  696. -webkit-transform: scale(0.8);
  697. -ms-transform: scale(0.8);
  698. transform: scale(0.8);
  699. -webkit-transform-origin: center center;
  700. -ms-transform-origin: center center;
  701. transform-origin: center center;
  702. }
  703. .uni-badge {
  704. font-family: 'Helvetica Neue', Helvetica, sans-serif;
  705. -webkit-box-sizing: border-box;
  706. box-sizing: border-box;
  707. font-size: 12px;
  708. line-height: 1;
  709. display: inline-block;
  710. padding: 3px 6px;
  711. color: #333;
  712. border-radius: 100px;
  713. background-color: #f1f1f1;
  714. }
  715. .uni-badge-error {
  716. color: #fff;
  717. background-color: #dd524d;
  718. }
  719. .copyright {
  720. width: 100%;
  721. position: absolute;
  722. bottom: 40rpx;
  723. display: flex;
  724. flex-direction: column;
  725. align-items: center;
  726. image {
  727. width: 180rpx;
  728. height: 60rpx;
  729. }
  730. .text {
  731. font-size: 20rpx;
  732. color: #cccccc;
  733. }
  734. }
  735. </style>