user.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730
  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="u-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 20rpx;
  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. .u-none {
  415. font-size: $font-size-32;
  416. line-height: 120rpx;
  417. color: #ffffff;
  418. text-align: left;
  419. }
  420. .u-h1 {
  421. width: 400rpx;
  422. float: left;
  423. font-size: $font-size-30;
  424. color: #ffffff;
  425. text-align: left;
  426. -o-text-overflow: ellipsis;
  427. text-overflow: ellipsis;
  428. display: -webkit-box;
  429. word-break: break-all;
  430. -webkit-box-orient: vertical;
  431. -webkit-line-clamp: 1;
  432. overflow: hidden;
  433. }
  434. .u-p {
  435. font-size: $font-size-24;
  436. line-height: 30rpx;
  437. color: #ffffff;
  438. text-align: left;
  439. }
  440. }
  441. }
  442. .header-icon {
  443. flex: 2;
  444. display: flex;
  445. margin-right: 20rpx;
  446. align-items: center;
  447. justify-content: center;
  448. .header-logo {
  449. width: 120rpx;
  450. height: 120rpx;
  451. box-sizing: border-box;
  452. background-color: #fff;
  453. border-radius: 100%;
  454. image {
  455. width: 120rpx;
  456. height: 120rpx;
  457. display: block;
  458. border-radius: 100%;
  459. }
  460. }
  461. }
  462. }
  463. .header-main-none {
  464. width: 702rpx;
  465. height: 152rpx;
  466. padding: 0 24rpx;
  467. display: flex;
  468. .header-text {
  469. flex: 8;
  470. display: flex;
  471. flex-direction: column;
  472. position: relative;
  473. box-sizing: border-box;
  474. padding: 20rpx 0;
  475. .user-item {
  476. flex: 1;
  477. height: 120rpx;
  478. line-height: 120rpx;
  479. font-size: $font-size-32;
  480. color: #ffffff;
  481. text-align: left;
  482. }
  483. }
  484. .header-icon {
  485. flex: 2;
  486. display: flex;
  487. margin-right: 20rpx;
  488. align-items: center;
  489. justify-content: center;
  490. .header-logo {
  491. width: 120rpx;
  492. height: 120rpx;
  493. box-sizing: border-box;
  494. padding: 21rpx;
  495. background-color: #fff;
  496. border-radius: 100%;
  497. image {
  498. width: 78rpx;
  499. height: 78rpx;
  500. display: block;
  501. }
  502. }
  503. }
  504. }
  505. .header-main-order {
  506. width: 100%;
  507. height: auto;
  508. box-sizing: border-box;
  509. padding: 0 24rpx;
  510. margin-top: 26rpx;
  511. .user-order {
  512. width: 100%;
  513. height: auto;
  514. background-color: $bg-color;
  515. margin-bottom: 24rpx;
  516. border-radius: 20rpx;
  517. box-sizing: border-box;
  518. padding: 0 24rpx;
  519. }
  520. }
  521. .tab-title {
  522. font-size: $font-size-28;
  523. line-height: 80rpx;
  524. color: #333333;
  525. text-align: left;
  526. border-bottom: 1px solid #f8f8f8;
  527. position: relative;
  528. .cell-tit {
  529. font-size: $font-size-28;
  530. color: $text-color;
  531. }
  532. .cell-more {
  533. float: right;
  534. line-height: 80rpx;
  535. font-size: $font-size-24;
  536. color: $text-color;
  537. padding-right: 30rpx;
  538. }
  539. .iconfont {
  540. width: 30rpx;
  541. height: 80rpx;
  542. line-height: 80rpx;
  543. text-align: center;
  544. position: absolute;
  545. right: 0;
  546. top: 0;
  547. display: block;
  548. font-size: $font-size-28;
  549. color: #b2b2b2;
  550. }
  551. }
  552. .order-section {
  553. display: flex;
  554. justify-content: space-around;
  555. align-items: center;
  556. flex-wrap: wrap;
  557. height: 99rpx;
  558. padding: 24rpx 0;
  559. }
  560. .order-item {
  561. flex: 1;
  562. display: flex;
  563. flex-direction: column;
  564. align-items: center;
  565. position: relative;
  566. &:last-child {
  567. margin-right: 0;
  568. }
  569. .order-icon {
  570. width: 52rpx;
  571. height: 52rpx;
  572. position: relative;
  573. image {
  574. width: 52rpx;
  575. height: 52rpx;
  576. }
  577. .icon-num {
  578. position: absolute;
  579. right: -24rpx;
  580. top: -9rpx;
  581. }
  582. .icon-num.goleft {
  583. right: -12rpx;
  584. }
  585. }
  586. .order-t {
  587. line-height: 50rpx;
  588. font-size: $font-size-24;
  589. color: $text-color;
  590. }
  591. }
  592. .header-main-last {
  593. width: 100%;
  594. height: 20rpx;
  595. float: left;
  596. box-sizing: border-box;
  597. }
  598. .header-main-listcell {
  599. width: 100%;
  600. height: auto;
  601. box-sizing: border-box;
  602. padding: 0 24rpx;
  603. margin-bottom: 60rpx;
  604. }
  605. .list-cell-item {
  606. width: 654rpx;
  607. height: auto;
  608. margin-bottom: 24rpx;
  609. padding: 0 24rpx;
  610. background: $bg-color;
  611. border-radius: 20rpx;
  612. }
  613. .list-cell {
  614. width: 100%;
  615. line-height: 100rpx;
  616. position: relative;
  617. background: $bg-color;
  618. border-bottom: 1px solid #ebebeb;
  619. height: 100rpx;
  620. &:last-child {
  621. border-bottom: none;
  622. }
  623. &.cell-hover {
  624. background: #fafafa;
  625. }
  626. .cell-icon {
  627. width: 60rpx;
  628. height: 100rpx;
  629. text-align: center;
  630. box-sizing: border-box;
  631. padding: 32rpx 12rpx;
  632. float: left;
  633. .cell-icon-image {
  634. width: 36rpx;
  635. height: 36rpx;
  636. display: block;
  637. }
  638. }
  639. .cell-more {
  640. height: 100rpx;
  641. line-height: 100rpx;
  642. text-align: right;
  643. position: absolute;
  644. right: 0;
  645. top: 0;
  646. font-size: $font-size-28;
  647. color: #b2b2b2;
  648. &.cont {
  649. width: 250rpx;
  650. }
  651. .txt {
  652. color: #fb4343;
  653. padding-right: 10rpx;
  654. }
  655. }
  656. .cell-tit {
  657. width: 465rpx;
  658. display: block;
  659. float: left;
  660. font-size: $font-size-28;
  661. color: #666666;
  662. margin-right: 10rpx;
  663. text-align: left;
  664. &.cont {
  665. width: 300rpx;
  666. }
  667. .cell-tips {
  668. width: 74rpx;
  669. height: 32rpx;
  670. line-height: 32rpx;
  671. padding: 0 7rpx;
  672. border-radius: 16rpx;
  673. background-color: #ffe6dc;
  674. color: $color-system;
  675. text-align: center;
  676. font-size: $font-size-20;
  677. margin-left: 8rpx;
  678. }
  679. }
  680. .cell-tip {
  681. font-size: $font-size-28;
  682. color: $text-color;
  683. }
  684. }
  685. .list-cell.last {
  686. border-bottom: none;
  687. }
  688. .uni-badge--small {
  689. -webkit-transform: scale(0.8);
  690. -ms-transform: scale(0.8);
  691. transform: scale(0.8);
  692. -webkit-transform-origin: center center;
  693. -ms-transform-origin: center center;
  694. transform-origin: center center;
  695. }
  696. .uni-badge {
  697. font-family: 'Helvetica Neue', Helvetica, sans-serif;
  698. -webkit-box-sizing: border-box;
  699. box-sizing: border-box;
  700. font-size: 12px;
  701. line-height: 1;
  702. display: inline-block;
  703. padding: 3px 6px;
  704. color: #333;
  705. border-radius: 100px;
  706. background-color: #f1f1f1;
  707. }
  708. .uni-badge-error {
  709. color: #fff;
  710. background-color: #dd524d;
  711. }
  712. .copyright {
  713. width: 100%;
  714. position: absolute;
  715. bottom: 40rpx;
  716. display: flex;
  717. flex-direction: column;
  718. align-items: center;
  719. image {
  720. width: 180rpx;
  721. height: 60rpx;
  722. }
  723. .text {
  724. font-size: 20rpx;
  725. color: #cccccc;
  726. }
  727. }
  728. </style>