user.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591
  1. <template>
  2. <view class="container">
  3. <view class="vheigh"></view>
  4. <scroll-view class="content-box" scroll-y="true">
  5. <view class="user-section">
  6. <view class="user-info-box ">
  7. <view class="detail flex">
  8. <view class="portrait-box" @click="navTo('/pages/set/userinfo')">
  9. <image class="portrait" :src="user.avatar || '/static/error/missing-face.png'"></image>
  10. </view>
  11. <view class="info-box">
  12. <view class="username flex-start">
  13. <text class="clamp padding-r-20">
  14. {{ user.nickname || '游客' }}
  15. </text>
  16. <image v-if="user.level>0" class="tipLevel flex-shrink-false"
  17. :src="`../../static/image/level${user.level-1}.png`" mode="heightFix"></image>
  18. </view>
  19. <view class="flex-start flex">
  20. <view class="authentication"
  21. @click="navTo('/pages/user/realName/realNameAuthentication')"
  22. v-if="userInfo.is_real==0||!userInfo.is_real">未实名认证</view>
  23. <view class="authentication success" v-else>已认证</view>
  24. </view>
  25. </view>
  26. </view>
  27. </view>
  28. </view>
  29. <view class="cover-container">
  30. <view class="tj-sction">
  31. <view class="tj-item" @click="navTo('./money/wallet')">
  32. <text class="num">{{ user.now_money || '0.00' }}</text>
  33. <text>余额</text>
  34. </view>
  35. <view v-if="fx" class="tj-item" @click="navTo('/pages/user/award/award')">
  36. <text class="num">{{ user.brokerage_price || '0.00' }}</text>
  37. <text>佣金</text>
  38. </view>
  39. <!-- <view class="tj-item" @click="navTo('/pages/index/route')">
  40. <text class="num">{{ user.record_sum || '0' }}</text>
  41. <text>行程</text>
  42. </view> -->
  43. <view class="tj-item" @click="navTo('/pages/index/notice')">
  44. <text class="num">{{ notic|| '0' }}</text>
  45. <text>消息</text>
  46. </view>
  47. </view>
  48. <!-- 订单 -->
  49. <view class="item-box">
  50. <view class="box-title flex">
  51. <view class="title"><text>我的订单</text></view>
  52. <!-- <view class="link" @click="navTo('/pages/order/order?state=0')" hover-class="common-hover">
  53. <text>全部订单</text>
  54. <text class="iconfont iconenter"></text>
  55. </view> -->
  56. </view>
  57. <view class="order-section">
  58. <view class="order-item" @click="navTo('/pages/order/order?state=3')" hover-class="common-hover"
  59. :hover-stay-time="50">
  60. <view class=" icon position-relative">
  61. <image class="icon-img" src="../../static/icon/userIconAll.png" mode="aspectFit">
  62. </image>
  63. <!-- <view class="corner" v-if="orderInfo.unshipped_count > 0">
  64. <text>{{ orderInfo.unshipped_count }}</text>
  65. </view> -->
  66. </view>
  67. <text>已完成</text>
  68. </view>
  69. <view class="order-item" @click="navTo('/pages/order/order?state=0')" hover-class="common-hover"
  70. :hover-stay-time="50">
  71. <view class=" icon position-relative">
  72. <image class="icon-img" src="../../static/icon/userIconPay.png" mode="aspectFit">
  73. </image>
  74. <view class="corner" v-if="user.unpaid_count > 0">
  75. <text>{{ user.unpaid_count }}</text>
  76. </view>
  77. </view>
  78. <text>待付款</text>
  79. </view>
  80. <view class="order-item" @click="navTo('/pages/order/order?state=2')" hover-class="common-hover"
  81. :hover-stay-time="50">
  82. <view class="icon position-relative">
  83. <image class="icon-img" src="../../static/icon/userIconGet.png" mode="aspectFit">
  84. </image>
  85. <view class="corner" v-if="user.received_count > 0">
  86. <text>{{ user.received_count }}</text>
  87. </view>
  88. </view>
  89. <text>待收货</text>
  90. </view>
  91. <view class="order-item" @click="navTo('/pages/order/orderAfter?state=0')"
  92. hover-class="common-hover" :hover-stay-time="50">
  93. <view class="icon position-relative">
  94. <image class="icon-img" src="../../static/icon/userIconout.png" mode="aspectFit">
  95. </image>
  96. <!-- <view class="corner" v-if="orderInfo.complete_count > 0">
  97. <text>{{ orderInfo.complete_count }}</text>
  98. </view> -->
  99. </view>
  100. <text>售后</text>
  101. </view>
  102. </view>
  103. </view>
  104. <view class="listBox">
  105. <view class="list">
  106. <view class="flex listItem" @click="navTo('/pages/user/myCart/myCart')">
  107. <view class="flex titleBox">
  108. <image class="listIconImg" src="../../static/icon/myCart.png" mode="widthFix"></image>
  109. <text class="title">我的车辆</text>
  110. </view>
  111. <view class="right flex">
  112. <text></text>
  113. <!-- <image class="img" src="../../static/icon/next1.png" mode="widthFix"></image> -->
  114. </view>
  115. </view>
  116. <view class="flex listItem" @click="navTo('/pages/user/repair/userRepair')">
  117. <view class="flex titleBox">
  118. <image class="listIconImg" src="../../static/icon/myWx.png" mode="widthFix"></image>
  119. <text class="title">维修历史</text>
  120. </view>
  121. <view class="right flex">
  122. <text></text>
  123. <!-- <image class="img" src="../../static/icon/next1.png" mode="widthFix"></image> -->
  124. </view>
  125. </view>
  126. <view class="flex listItem" v-if="fx" @click="navTo('/pages/user/myteam')">
  127. <view class="flex titleBox">
  128. <image class="listIconImg" src="../../static/icon/myitem.png" mode="widthFix"></image>
  129. <text class="title">我的团队</text>
  130. </view>
  131. <view class="right flex">
  132. <text></text>
  133. <!-- <image class="img" src="../../static/icon/next1.png" mode="widthFix"></image> -->
  134. </view>
  135. </view>
  136. <view class="flex listItem" @click="navTo('/pages/set/address')">
  137. <view class="flex titleBox">
  138. <image class="listIconImg" src="../../static/icon/myAddress.png" mode="widthFix">
  139. </image>
  140. <text class="title">我的地址</text>
  141. </view>
  142. <view class="right flex">
  143. <text></text>
  144. <!-- <image class="img" src="../../static/icon/next1.png" mode="widthFix"></image> -->
  145. </view>
  146. </view>
  147. <!-- #ifndef APP -->
  148. <view class="flex listItem" @click="navTo('/pages/user/shareQrCode')">
  149. <view class="flex titleBox">
  150. <image class="listIconImg" src="../../static/icon/myitem.png" mode="widthFix"></image>
  151. <text class="title">邀请好友</text>
  152. </view>
  153. <view class="right flex">
  154. <text></text>
  155. </view>
  156. </view>
  157. <!-- #endif -->
  158. <!-- #ifdef APP -->
  159. <view class="flex listItem" @click="shareDomApp">
  160. <view class="flex titleBox">
  161. <image class="listIconImg" src="../../static/icon/myitem.png" mode="widthFix"></image>
  162. <text class="title">邀请好友</text>
  163. </view>
  164. <view class="right flex">
  165. <text></text>
  166. </view>
  167. </view>
  168. <!-- #endif -->
  169. <!-- #ifndef MP -->
  170. <view class="flex listItem" @click="navTo('/pages/public/workwork')">
  171. <view class="flex titleBox">
  172. <image class="listIconImg" src="../../static/icon/myServer.png" mode="widthFix"></image>
  173. <text class="title">关于我们</text>
  174. </view>
  175. <view class="right flex">
  176. <text></text>
  177. </view>
  178. </view>
  179. <!-- #endif -->
  180. <view class="flex listItem" @click="navTo('/pages/set/set')">
  181. <view class="flex titleBox">
  182. <image class="listIconImg" src="../../static/icon/mySet.png" mode="widthFix"></image>
  183. <text class="title">设置</text>
  184. </view>
  185. <view class="right flex">
  186. <text></text>
  187. <!-- <image class="img" src="../../static/icon/next1.png" mode="widthFix"></image> -->
  188. </view>
  189. </view>
  190. </view>
  191. </view>
  192. <view class="tapBottom" v-if='user.adminid' @click="changeTab">
  193. 前往商家界面
  194. </view>
  195. </view>
  196. </scroll-view>
  197. </view>
  198. </template>
  199. <script>
  200. import {
  201. mapState,
  202. mapMutations
  203. } from 'vuex';
  204. import {
  205. share
  206. } from '@/api/wx';
  207. import {
  208. getUser
  209. } from '@/api/user.js';
  210. import {
  211. articleList,
  212. notify
  213. } from '@/api/index.js';
  214. import {
  215. saveUrl,
  216. interceptor
  217. } from '@/utils/loginUtils.js';
  218. export default {
  219. data() {
  220. return {
  221. user: {
  222. avatar: '', //头像
  223. nickname: '', //昵称
  224. now_money: 0, //余额
  225. brokerage_price: 0, //佣金
  226. record_sum: 0, //行程
  227. notice_sum: 0, //报警信息
  228. question_sum: 0, //系统消息
  229. // 订单数据类型
  230. orderStatusNum: {
  231. unpaid_count: 0, //待付款
  232. received_count: 0, //待收货
  233. },
  234. },
  235. shareData: {}
  236. };
  237. },
  238. computed: {
  239. ...mapState('user', ['userInfo', 'orderInfo', 'hasLogin']),
  240. ...mapState(['baseURL', 'urlFile']),
  241. ...mapState(['fx']),
  242. // 总消息条数
  243. notic() {
  244. return this.user.question_sum + this.user.notice_sum;
  245. },
  246. },
  247. onLoad() {
  248. share().then((res) => {
  249. this.shareData = res.data.data
  250. }).catch((res) => {
  251. console.log(res, '分享加载失败');
  252. })
  253. },
  254. onShow() {
  255. if (this.hasLogin) {
  256. this.loadBaseData();
  257. this.getUser();
  258. }
  259. },
  260. // 创建时获取分享信息
  261. methods: {
  262. loadBaseData() {
  263. getUserInfo({})
  264. .then(({
  265. data
  266. }) => {
  267. this.setUserInfo(data);
  268. // 获取用户数据完毕后在获取订单数据防止多次跳转到登录页
  269. orderData({})
  270. .then(({
  271. data
  272. }) => {
  273. this.setOrderInfo(data);
  274. })
  275. .catch(e => {
  276. this.setOrderInfo({
  277. complete_count: 0, //完成
  278. received_count: 0, //待收货
  279. unshipped_count: 0, //待发货
  280. order_count: 0, //订单总数
  281. unpaid_count: 0 //待付款
  282. });
  283. });
  284. })
  285. .catch(e => {
  286. console.log(e);
  287. });
  288. },
  289. //#ifdef APP
  290. shareDomApp() {
  291. uni.share({
  292. provider: 'weixin',
  293. type: 0,
  294. title: '绿津智能电动车',
  295. summary: '新一代智能电动车,手机开关锁、智能防盗、卫星定位,时刻掌握爱车位置。品牌大厂生产,质量好,款式多,售后优,所有车辆支持0元购新车!',
  296. imageUrl: this.shareData.img,
  297. href: this.baseURL + this.urlFile + '/pages/public/register?spread=' + this.userInfo.uid
  298. })
  299. },
  300. //#endif
  301. // 获取用户数据
  302. getUser() {
  303. const that = this;
  304. getUser({}).then((e) => {
  305. this.user = e.data;
  306. }).catch((e) => {
  307. console.log(e);
  308. })
  309. // 系统消息
  310. articleList({}, 1).then((e) => {
  311. that.user.question_sum = e.data.count
  312. console.log(that, 1);
  313. }).catch((e) => {
  314. console.log(e);
  315. })
  316. // 报警消息
  317. notify().then((e) => {
  318. that.user.notice_sum = e.data.count
  319. }).catch((e) => {
  320. console.log(e);
  321. })
  322. },
  323. changeTab() {
  324. this.$emit('tab', true)
  325. },
  326. navTo(url) {
  327. if (!this.hasLogin) {
  328. // 保存地址
  329. saveUrl();
  330. // 登录拦截
  331. interceptor();
  332. } else {
  333. uni.navigateTo({
  334. url,
  335. fail(e) {
  336. console.log(e);
  337. }
  338. });
  339. }
  340. },
  341. }
  342. };
  343. </script>
  344. <style lang="scss">
  345. page {
  346. height: 100%;
  347. }
  348. .tapBottom {
  349. margin: 0 50rpx;
  350. text-align: center;
  351. color: #FFFFFF;
  352. border: 1px solid $color-red;
  353. background-color: $color-red;
  354. line-height: 1;
  355. padding: 25rpx;
  356. border-radius: 100rpx;
  357. margin-top: 50rpx;
  358. }
  359. .listBox {
  360. margin-top: 20rpx;
  361. background-color: #FFFFFF;
  362. border-radius: 20rpx;
  363. overflow: hidden;
  364. }
  365. .list {
  366. .listItem {
  367. padding: 35rpx 40rpx;
  368. border-bottom: 1px solid $page-color-light;
  369. }
  370. .listIconImg {
  371. width: 36rpx;
  372. height: 36rpx;
  373. }
  374. .right {
  375. .img {
  376. width: 26rpx;
  377. }
  378. }
  379. .titleBox {
  380. .title {
  381. padding-left: 20rpx;
  382. color: $font-color-base;
  383. font-size: $font-base;
  384. }
  385. }
  386. }
  387. %flex-center {
  388. display: flex;
  389. flex-direction: column;
  390. justify-content: center;
  391. align-items: center;
  392. }
  393. %section {
  394. display: flex;
  395. justify-content: space-around;
  396. align-content: center;
  397. border-radius: 10rpx;
  398. }
  399. .container {
  400. height: 100%;
  401. background-color: $page-color-base;
  402. }
  403. .content-box {
  404. height: 100%;
  405. }
  406. .vheigh {
  407. height: var(--status-bar-height);
  408. }
  409. .user-section {
  410. padding: 15rpx 30rpx 0;
  411. position: relative;
  412. }
  413. .user-info-box {
  414. height: 180rpx;
  415. color: white;
  416. display: flex;
  417. align-items: center;
  418. justify-content: space-between;
  419. position: relative;
  420. z-index: 1;
  421. .detail {
  422. height: 130rpx;
  423. flex-grow: 1;
  424. overflow: hidden;
  425. .portrait-box {
  426. height: 100%;
  427. .portrait {
  428. width: 130rpx;
  429. height: 100%;
  430. border: 5rpx solid #fff;
  431. border-radius: 50%;
  432. }
  433. }
  434. .info-box {
  435. margin-left: 20rpx;
  436. line-height: 1.5;
  437. flex-grow: 1;
  438. overflow: hidden;
  439. .tipLevel {
  440. height: 36rpx;
  441. margin-right: 20rpx;
  442. }
  443. .username {
  444. font-size: 40rpx;
  445. color: $font-color-dark;
  446. font-weight: bold;
  447. height: 100%;
  448. }
  449. .authentication {
  450. border: 2rpx solid #FF4241;
  451. border-radius: 20px;
  452. padding: 0 25rpx;
  453. font-size: 24rpx;
  454. color: #FF4241;
  455. float: left;
  456. &.success {
  457. border: 2rpx solid $color-green;
  458. color: $color-green;
  459. }
  460. }
  461. }
  462. }
  463. }
  464. .cover-container {
  465. padding: 0 30rpx;
  466. position: relative;
  467. padding-bottom: 20rpx;
  468. }
  469. .tj-sction {
  470. @extend %section;
  471. .tj-item {
  472. @extend %flex-center;
  473. flex-direction: column;
  474. height: 100rpx;
  475. font-size: $font-sm;
  476. color: $font-color-light;
  477. }
  478. .num {
  479. font-size: $font-base;
  480. color: $font-color-dark;
  481. margin-bottom: 8rpx;
  482. font-weight: bold;
  483. }
  484. }
  485. .item-box {
  486. border-radius: 20rpx;
  487. background-color: white;
  488. margin-top: 20rpx;
  489. .box-title {
  490. line-height: 1;
  491. padding: 30rpx;
  492. .title {
  493. font-size: $font-lg;
  494. font-weight: bold;
  495. }
  496. .link {
  497. font-size: $font-base - 2rpx;
  498. color: $font-color-light;
  499. }
  500. }
  501. .order-section {
  502. @extend %section;
  503. padding: 28rpx 0;
  504. padding-top: 0;
  505. .order-item {
  506. @extend %flex-center;
  507. width: 120rpx;
  508. height: 120rpx;
  509. border-radius: 10rpx;
  510. font-size: $font-sm;
  511. color: $font-color-dark;
  512. }
  513. .iconfont {
  514. font-size: 48rpx;
  515. margin-bottom: 18rpx;
  516. color: #fa436a;
  517. }
  518. .icon-shouhoutuikuan {
  519. font-size: 44rpx;
  520. }
  521. .icon {
  522. height: 50rpx;
  523. width: 48rpx;
  524. margin-bottom: 18rpx;
  525. background-size: 100%;
  526. background-repeat: no-repeat;
  527. background-position: center;
  528. .icon-img {
  529. width: 100%;
  530. height: 100%;
  531. }
  532. }
  533. }
  534. }
  535. .history-section {
  536. // padding: 30rpx 0 0;
  537. margin-top: 20rpx;
  538. background: #fff;
  539. border-radius: 10rpx;
  540. .h-list {
  541. white-space: nowrap;
  542. padding: 30rpx 30rpx 0;
  543. .h-list-image {
  544. display: inline-block;
  545. width: 160rpx;
  546. height: 160rpx;
  547. margin-right: 20rpx;
  548. border-radius: 10rpx;
  549. }
  550. }
  551. }
  552. </style>