user.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591
  1. <template>
  2. <view class="container">
  3. <!-- #ifdef APP-PLUS -->
  4. <view class="vheigh"></view>
  5. <!-- #endif -->
  6. <view class="user-top">
  7. <image src="../../static/index/index13.png" mode="" class="user-top-bg"></image>
  8. <view class="user-info" @click="navTo('/pages/set/set')">
  9. <image class="avtar" :src="userInfo.avatar" mode=""></image>
  10. <view class="name">{{ userInfo.nickname }}</view>
  11. <view class="phone">{{ userInfo.phone }}</view>
  12. <view class="vip-box">
  13. <view class="vip">
  14. <image class="vip-bg" src="../../static/img/vip.png" mode=""></image>
  15. <view class="vip-title">V{{ userInfo.level }}</view>
  16. </view>
  17. </view>
  18. </view>
  19. <view class="sy-box flex">
  20. <view class="sy-item" @click="navTo('/pages/user/whiteJf')">
  21. <view class="sy-item-name">我的肥料</view>
  22. <view class="sy-item-val">{{ userInfo.white_integral || '0.00' }}</view>
  23. </view>
  24. <view class="jg"></view>
  25. <view class="sy-item" @click="navTo('/pages/user/greenJf')">
  26. <view class="sy-item-name">我的水滴</view>
  27. <view class="sy-item-val">{{ userInfo.green_integral || '0.00' }}</view>
  28. </view>
  29. <view class="jg"></view>
  30. <view class="sy-item" @click="navTo('/pages/user/myGreenCard')">
  31. <view class="sy-item-name">我的洒水壶</view>
  32. <view class="sy-item-val">{{ greenNum }}</view>
  33. </view>
  34. </view>
  35. </view>
  36. <view class="item-box">
  37. <view class="order-section">
  38. <view class="order-item" @click="navTo('/pages/user/purpleJf')" hover-class="common-hover" :hover-stay-time="50">
  39. <view class="icon"><image class="icon-img" src="/static/icon/myyj.png" mode="aspectFit"></image></view>
  40. <text>我的阳光</text>
  41. </view>
  42. <view class="order-item" @click="navTo('/pages/user/shopJf')" hover-class="common-hover" :hover-stay-time="50">
  43. <view class="icon"><image class="icon-img" src="/static/icon/myqb.png" mode="aspectFit"></image></view>
  44. <text>能量金豆</text>
  45. </view>
  46. <view class="order-item" @click="navTo('/pages/user/mallJf')" hover-class="common-hover" :hover-stay-time="50">
  47. <view class="icon"><image class="icon-img" src="/static/icon/mygx.png" mode="aspectFit"></image></view>
  48. <text>商城积分</text>
  49. </view>
  50. <view class="order-item" @click="navTo('/pages/user/team')" hover-class="common-hover" :hover-stay-time="50">
  51. <view class="icon"><image class="icon-img" src="/static/icon/myjd.png" mode="aspectFit"></image></view>
  52. <text>我的推广</text>
  53. </view>
  54. </view>
  55. </view>
  56. <!-- 订单 -->
  57. <view class="item-box item-box-b" style="margin-top: -200rpx;">
  58. <view class="box-title flex ">
  59. <view class="title"><text>我的订单</text></view>
  60. <view class="link" @click="navTo('/pages/order/order?state=0')" hover-class="common-hover"><text class="iconfont iconenter"></text></view>
  61. </view>
  62. <view class="order-section">
  63. <view class="order-item" @click="navTo('/pages/order/order?state=0')" hover-class="common-hover" :hover-stay-time="50">
  64. <view class=" icon position-relative">
  65. <image class="icon-img" src="/static/icon/i1.png" mode="aspectFit"></image>
  66. <view class="corner" v-if="orderInfo.unpaid_count > 0">
  67. <text>{{ orderInfo.unpaid_count }}</text>
  68. </view>
  69. </view>
  70. <text>待付款</text>
  71. </view>
  72. <view class="order-item" @click="navTo('/pages/order/order?state=1')" hover-class="common-hover" :hover-stay-time="50">
  73. <view class=" icon position-relative">
  74. <image class="icon-img" src="/static/icon/i2.png" mode="aspectFit"></image>
  75. <view class="corner" v-if="orderInfo.unshipped_count > 0">
  76. <text>{{ orderInfo.unshipped_count }}</text>
  77. </view>
  78. </view>
  79. <text>待发货</text>
  80. </view>
  81. <view class="order-item" @click="navTo('/pages/order/order?state=2')" hover-class="common-hover" :hover-stay-time="50">
  82. <view class="icon position-relative">
  83. <image class="icon-img" src="/static/icon/i3.png" mode="aspectFit"></image>
  84. <view class="corner" v-if="orderInfo.received_count > 0">
  85. <text>{{ orderInfo.received_count }}</text>
  86. </view>
  87. </view>
  88. <text>待收货</text>
  89. </view>
  90. <view class="order-item" @click="navTo('/pages/order/order?state=4')" hover-class="common-hover" :hover-stay-time="50">
  91. <view class="icon position-relative">
  92. <image class="icon-img" src="/static/icon/i4.png" mode="aspectFit"></image>
  93. <!-- <view class="corner" v-if="orderInfo.complete_count > 0">
  94. <text>{{ orderInfo.complete_count }}</text>
  95. </view> -->
  96. </view>
  97. <text>已完成</text>
  98. </view>
  99. </view>
  100. </view>
  101. <!-- -->
  102. <view class="btm-box flex" @click="navTo('/pages/user/favorites')">
  103. <image src="../../static/icon/mytg.png" mode="widthFix" class="left-img"></image>
  104. <view class="">我的收藏</view>
  105. <image src="../../static/icon/goto.png" mode="widthFix" class="right-img"></image>
  106. </view>
  107. <view class="btm-box flex" @click="navTo('/pages/user/shareQrCode')">
  108. <image src="../../static/icon/tghb.png" mode="widthFix" class="left-img"></image>
  109. <view class="">推广海报</view>
  110. <image src="../../static/icon/goto.png" mode="widthFix" class="right-img"></image>
  111. </view>
  112. <view class="btm-box flex" @click="navTo('/pages/set/address')">
  113. <image src="../../static/icon/shdz.png" mode="widthFix" class="left-img"></image>
  114. <view class="">收货地址</view>
  115. <image src="../../static/icon/goto.png" mode="widthFix" class="right-img"></image>
  116. </view>
  117. <view class="btm-box flex" @click="kfOpen">
  118. <image src="../../static/icon/kf.png" mode="widthFix" class="left-img"></image>
  119. <view class="">客服</view>
  120. <image src="../../static/icon/goto.png" mode="widthFix" class="right-img"></image>
  121. </view>
  122. <view class="btm-box flex" @click="navTo('/pages/set/set')">
  123. <image src="../../static/icon/bdsj.png" mode="widthFix" class="left-img"></image>
  124. <view class="">设置</view>
  125. <image src="../../static/icon/goto.png" mode="widthFix" class="right-img"></image>
  126. </view>
  127. <view class="btm" style="height: 44px;"></view>
  128. <!-- 客服 -->
  129. <uni-popup ref="popupkf" type="center">
  130. <view class="popup-box">
  131. <view class="img"><image src="../../static/img/img009.png" mode=""></image></view>
  132. <view class="mian">
  133. <view class="delivery">
  134. <view class="title">已经为您定制专属客服</view>
  135. <image src="../../static/img/img010.png" mode=""></image>
  136. </view>
  137. <view class="nocancel">客服VX:{{ text }}</view>
  138. <view class="comfirm-box">
  139. <view class="cancel" @click="kfClose()">取消</view>
  140. <view class="comfirm" @click="comfirm(text)">复制微信</view>
  141. </view>
  142. </view>
  143. </view>
  144. </uni-popup>
  145. </view>
  146. </template>
  147. <script>
  148. import { mapState, mapMutations } from 'vuex';
  149. import uniList from '@/components/uni-list/uni-list.vue';
  150. import uniListItem from '@/components/uni-list-item/uni-list-item.vue';
  151. import { orderData, userinfo, greenList } from '@/api/user.js';
  152. import { saveUrl, interceptor } from '@/utils/loginUtils.js';
  153. import uniCopy from '@/js_sdk/xb-copy/uni-copy.js';
  154. let startY = 0,
  155. moveY = 0,
  156. pageAtTop = true;
  157. export default {
  158. components: {
  159. uniList,
  160. uniListItem
  161. },
  162. data() {
  163. return {
  164. greenNum: 0,
  165. text: '',
  166. coverTransform: 'translateY(0px)',
  167. coverTransition: '0s',
  168. moving: false,
  169. userDowm: 0, //卡片升级专属高度
  170. userMaxDowm: 0 //卡片最高高度
  171. };
  172. },
  173. onShow() {
  174. this.loadBaseData();
  175. // 判断是否已经登录
  176. if (this.hasLogin) {
  177. this.loadBaseData();
  178. this.getGreenList();
  179. }
  180. },
  181. onReady() {
  182. // 初始化获取页面宽度
  183. uni.createSelectorQuery()
  184. .select('.container')
  185. .fields(
  186. {
  187. size: true
  188. },
  189. data => {
  190. // 计算最多下拉的高度
  191. this.userDowm = Math.floor((data.width / 750) * 185);
  192. // 计算最大触发修改高度事件
  193. this.userMaxDowm = Math.floor((data.width / 750) * 250);
  194. }
  195. )
  196. .exec();
  197. },
  198. computed: {
  199. ...mapState('user', ['userInfo', 'orderInfo', 'hasLogin'])
  200. },
  201. methods: {
  202. ...mapMutations('user', ['setUserInfo', 'setOrderInfo']),
  203. // 绿卡记录
  204. getGreenList() {
  205. greenList({}).then(res => {
  206. console.log('greenList', res);
  207. this.greenNum = res.data.count;
  208. });
  209. },
  210. // 加载初始数据
  211. loadBaseData() {
  212. console.log(this.userInfo);
  213. userinfo({})
  214. .then(({ data }) => {
  215. this.setUserInfo(data);
  216. // 获取用户数据完毕后在获取订单数据防止多次跳转到登录页
  217. orderData({})
  218. .then(({ data }) => {
  219. this.setOrderInfo(data);
  220. })
  221. .catch(e => {
  222. this.setOrderInfo({
  223. complete_count: 0, //完成
  224. received_count: 0, //待收货
  225. unshipped_count: 0, //待发货
  226. order_count: 0, //订单总数
  227. unpaid_count: 0 //待付款
  228. });
  229. });
  230. })
  231. .catch(e => {
  232. console.log(e);
  233. });
  234. },
  235. /**
  236. * 统一跳转接口,拦截未登录路由
  237. * navigator标签现在默认没有转场动画,所以用view
  238. */
  239. navTo(url) {
  240. if (url == '') {
  241. this.$api.msg('敬请期待');
  242. }
  243. if (!this.hasLogin) {
  244. // 保存地址
  245. saveUrl();
  246. // 登录拦截
  247. interceptor();
  248. } else {
  249. uni.navigateTo({
  250. url,
  251. fail() {
  252. uni.switchTab({
  253. url
  254. });
  255. }
  256. });
  257. }
  258. },
  259. kfOpen() {
  260. this.$refs.popupkf.open();
  261. },
  262. kfClose() {
  263. this.$refs.popupkf.close();
  264. },
  265. comfirm(text) {
  266. console.log(text);
  267. const result = uniCopy(text);
  268. if (result === false) {
  269. uni.showToast({
  270. title: '不支持'
  271. });
  272. } else {
  273. uni.showToast({
  274. title: '复制成功',
  275. icon: 'none'
  276. });
  277. }
  278. this.$refs.popup.close();
  279. }
  280. }
  281. };
  282. </script>
  283. <style lang="scss">
  284. page {
  285. height: 100%;
  286. }
  287. .vheigh {
  288. height: var(--status-bar-height);
  289. // background-color: #fff;
  290. }
  291. .user-top {
  292. height: 564rpx;
  293. position: relative;
  294. .user-top-bg {
  295. width: 750rpx;
  296. height: 564rpx;
  297. // width: 100%;
  298. // position: absolute;
  299. }
  300. .user-info {
  301. width: 750rpx;
  302. position: absolute;
  303. top: 50rpx;
  304. display: flex;
  305. flex-direction: column;
  306. justify-content: center;
  307. align-items: center;
  308. .avtar {
  309. width: 134rpx;
  310. height: 134rpx;
  311. border-radius: 50%;
  312. }
  313. .name {
  314. margin-top: 10rpx;
  315. font-size: 39rpx;
  316. font-family: PingFang SC;
  317. font-weight: bold;
  318. color: #ffffff;
  319. }
  320. .phone {
  321. margin-top: 8rpx;
  322. font-size: 29rpx;
  323. font-family: PingFang SC;
  324. font-weight: 500;
  325. color: #ffffff;
  326. }
  327. .vip-box {
  328. margin-top: 10rpx;
  329. display: flex;
  330. align-items: center;
  331. line-height: 1;
  332. .vip {
  333. position: relative;
  334. margin-left: 12rpx;
  335. width: 130rpx;
  336. height: 40rpx;
  337. .vip-bg {
  338. position: absolute;
  339. top: 0;
  340. left: 0;
  341. right: 0;
  342. width: 100%;
  343. height: 100%;
  344. }
  345. .vip-title {
  346. position: relative;
  347. z-index: 10;
  348. font-size: 20rpx;
  349. font-family: PingFang SC;
  350. font-weight: 500;
  351. color: #93794b;
  352. padding-left: 46rpx;
  353. line-height: 40rpx;
  354. }
  355. }
  356. }
  357. }
  358. .sy-box {
  359. position: absolute;
  360. bottom: 30rpx;
  361. height: 148rpx;
  362. width: 750rpx;
  363. // background-color: #bfa;
  364. .sy-item {
  365. width: 30%;
  366. flex-grow: 1;
  367. text-align: center;
  368. font-size: 28rpx;
  369. font-family: PingFang SC;
  370. font-weight: 500;
  371. color: #ffffff;
  372. .sy-item-val {
  373. font-size: 39rpx;
  374. }
  375. }
  376. .jg {
  377. width: 2rpx;
  378. height: 68rpx;
  379. background-color: #fff;
  380. }
  381. }
  382. }
  383. %flex-center {
  384. display: flex;
  385. flex-direction: column;
  386. justify-content: center;
  387. align-items: center;
  388. }
  389. %section {
  390. display: flex;
  391. justify-content: space-around;
  392. align-content: center;
  393. background: #fff;
  394. border-radius: 10rpx;
  395. }
  396. .item-box {
  397. width: 708rpx;
  398. height: 163rpx;
  399. background: #fff;
  400. border-radius: 28rpx;
  401. background-color: white;
  402. margin: -40rpx auto 30rpx;
  403. position: relative;
  404. // margin-top: 20rpx;
  405. .box-title {
  406. line-height: 1;
  407. padding: 30rpx;
  408. .title {
  409. font-size: $font-lg;
  410. font-weight: bold;
  411. }
  412. .link {
  413. font-size: $font-base - 2rpx;
  414. color: $font-color-light;
  415. }
  416. }
  417. .order-section {
  418. @extend %section;
  419. padding: 28rpx 0;
  420. .order-item {
  421. @extend %flex-center;
  422. width: 120rpx;
  423. height: 120rpx;
  424. border-radius: 10rpx;
  425. font-size: $font-sm;
  426. color: $font-color-dark;
  427. }
  428. .iconfont {
  429. font-size: 48rpx;
  430. margin-bottom: 18rpx;
  431. color: #fa436a;
  432. }
  433. .icon-shouhoutuikuan {
  434. font-size: 44rpx;
  435. }
  436. .icon {
  437. height: 50rpx;
  438. width: 48rpx;
  439. margin-bottom: 18rpx;
  440. background-size: 100%;
  441. background-repeat: no-repeat;
  442. background-position: center;
  443. .icon-img {
  444. width: 100%;
  445. height: 100%;
  446. }
  447. }
  448. }
  449. }
  450. .item-box-b {
  451. width: 710rpx;
  452. height: 221rpx;
  453. background: #ffffff;
  454. margin: 20rpx auto 60rpx;
  455. }
  456. .btm-box {
  457. width: 706rpx;
  458. height: 104rpx;
  459. background: #ffffff;
  460. box-shadow: 0px 0px 20rpx 0px rgba(50, 50, 52, 0.06);
  461. border-radius: 28rpx;
  462. margin: 20rpx auto;
  463. position: relative;
  464. padding: 0 33rpx 0 24rpx;
  465. font-size: 29rpx;
  466. font-weight: bold;
  467. color: #5d5d5d;
  468. .left-img {
  469. width: 40rpx;
  470. }
  471. .right-img {
  472. width: 14rpx;
  473. }
  474. view {
  475. flex-grow: 1;
  476. padding-left: 12rpx;
  477. }
  478. }
  479. .popup-box {
  480. width: 522rpx;
  481. height: 605rpx;
  482. background-color: #ffffff;
  483. border-radius: 20rpx;
  484. position: relative;
  485. .img {
  486. position: relative;
  487. top: -56rpx;
  488. left: 0;
  489. width: 522rpx;
  490. height: 132rpx;
  491. display: flex;
  492. justify-content: center;
  493. image {
  494. border-radius: 20rpx 20rpx 0 0;
  495. width: 450rpx;
  496. height: 132rpx;
  497. }
  498. }
  499. .mian {
  500. margin-top: -44rpx;
  501. display: flex;
  502. flex-direction: column;
  503. align-items: center;
  504. // padding: 32rpx 32rpx;
  505. background-color: #ffffff;
  506. border-radius: 0 0 20rpx 20rpx;
  507. text-align: center;
  508. .delivery {
  509. font-size: 40rpx;
  510. color: #333333;
  511. display: flex;
  512. align-items: center;
  513. flex-direction: column;
  514. .title {
  515. }
  516. image {
  517. margin-top: 48rpx;
  518. width: 172rpx;
  519. height: 160rpx;
  520. }
  521. }
  522. .nocancel {
  523. font-size: 32rpx;
  524. color: #333333;
  525. margin-top: 14rpx;
  526. }
  527. .comfirm-box {
  528. margin-top: 52rpx;
  529. display: flex;
  530. // margin-bottom: 32rpx;
  531. // justify-content: space-around;
  532. .cancel {
  533. display: flex;
  534. align-items: center;
  535. justify-content: center;
  536. width: 197rpx;
  537. height: 74rpx;
  538. border: 1px solid #dcc786;
  539. border-radius: 38rpx;
  540. font-size: 32rpx;
  541. color: #605128;
  542. }
  543. .comfirm {
  544. margin-left: 32rpx;
  545. display: flex;
  546. align-items: center;
  547. justify-content: center;
  548. width: 197rpx;
  549. height: 74rpx;
  550. background: linear-gradient(-90deg, #d1ba77 0%, #f7e8ad 100%);
  551. border-radius: 38px;
  552. font-size: 32rpx;
  553. color: #605128;
  554. }
  555. }
  556. }
  557. }
  558. </style>