user.vue 14 KB

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