user.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776
  1. <template>
  2. <view class="container">
  3. <view class="vheigh"></view>
  4. <view class="top-image">
  5. <image src="../../static/user/user-top.png" mode=""></image>
  6. </view>
  7. <view class="user-set flex">
  8. <view class="set-logo" @click="navTo('/pages/set/userinfo')">
  9. <image src="../../static/user/user1.png" mode=""></image>
  10. </view>
  11. <!-- <view class="xx-logo"><image src="../../static/user/user2.png" mode=""></image></view> -->
  12. </view>
  13. <view class="user-wrap">
  14. <view class="info-left flex">
  15. <view class="user-name">
  16. <image :src="userInfo.avatar" mode="" v-if="userInfo.avatar"></image>
  17. <image src="../../static/error/missing-face.png" mode="" v-else></image>
  18. <view class="gpai" v-if="userInfo.is_real">团队长</view>
  19. <view class="user-font">
  20. <view class="name clamp">{{ userInfo.nickname }}</view>
  21. <view class="phone">{{ userInfo.phone }}</view>
  22. <view class="phone" v-if="userInfo.uid">邀请码:{{ userInfo.uid }}</view>
  23. </view>
  24. </view>
  25. <view class="kpi">今日KPI:{{userInfo.kpi|| 0}}</view>
  26. </view>
  27. <view class="info-right" @click="navTo('/pages/user/myxfjf')">
  28. <image class="iright-icon" src="../../static/user/user3.png" mode=""></image>
  29. <view class="iright-font">消费积分:{{ userInfo.now_money || 0}}</view>
  30. </view>
  31. </view>
  32. <view class="main-box">
  33. <view class="title flex">
  34. <view class="title-left">
  35. <image class="title-icon" src="../../static/user/user4.png" mode=""></image>
  36. <view class="title-font">我的资产</view>
  37. </view>
  38. <image class="title-right" src="../../static/img/back.png" mode=""></image>
  39. </view>
  40. <view class="main flex">
  41. <view class="item" @click="navTo('/pages/user/mygwjf')">
  42. <view class="item-num">{{ userInfo.sp_final || 0}}</view>
  43. <view class="item-font">购物积分</view>
  44. </view>
  45. <view class="item" @click="navTo('/pages/user/mythq')">
  46. <view class="item-num">{{userInfo.top_ticket || 0}}</view>
  47. <view class="item-font">提货券</view>
  48. </view>
  49. <view class="item" @click="navTo('/pages/user/myggz')">
  50. <view class="item-num">{{userInfo.aid_val || 0}}</view>
  51. <view class="item-font">广告值</view>
  52. </view>
  53. </view>
  54. </view>
  55. <view class="main-box">
  56. <view class="title flex" @click="navTo('/pages/order/order1?state=0')">
  57. <view class="title-left">
  58. <image class="title-icon" src="../../static/user/user5.png" mode=""></image>
  59. <view class="title-font">我的订单</view>
  60. </view>
  61. <image class="title-right" src="../../static/img/back.png" mode=""></image>
  62. </view>
  63. <view class="main flex">
  64. <view class="oitem" @click="navTo('/pages/order/order1?state=0')">
  65. <image class="oitem-image" src="../../static/user/user6.png" mode=""></image>
  66. <view class="oitem-font">待付款</view>
  67. </view>
  68. <view class="oitem" @click="navTo('/pages/order/order1?state=1')">
  69. <image class="oitem-image" src="../../static/user/user7.png" mode=""></image>
  70. <view class="oitem-font">待发货</view>
  71. </view>
  72. <view class="oitem" @click="navTo('/pages/order/order1?state=2')">
  73. <image class="oitem-image" src="../../static/user/user8.png" mode=""></image>
  74. <view class="oitem-font">待收货</view>
  75. </view>
  76. <view class="oitem" @click="navTo('/pages/order/order1?state=3')">
  77. <image class="oitem-image" src="../../static/user/user9.png" mode=""></image>
  78. <view class="oitem-font">已完成</view>
  79. </view>
  80. </view>
  81. </view>
  82. <uni-list class="tool-list">
  83. <uni-list-item title="邀请有礼" @click="navTo('/pages/user/shareQrCode')" thumb="/static/user/user10.png">
  84. </uni-list-item>
  85. <uni-list-item title="我的推广" @click="navTo('/pages/user/mytg')" thumb="/static/icon/mytg.png">
  86. </uni-list-item>
  87. <uni-list-item title="支付密码" @click="navTo('/pages/money/moneyPwd')" thumb="/static/icon/g9.png">
  88. </uni-list-item>
  89. <uni-list-item title="我的收藏" @click="navTo('/pages/user/favorites')" thumb="/static/user/user11.png">
  90. </uni-list-item>
  91. <uni-list-item title="收款方式" @click="navTo('/pages/collection/collection')" thumb="/static/user/user12.png">
  92. </uni-list-item>
  93. <uni-list-item title="客服中心" @click="openKf()" thumb="/static/user/user13.png"></uni-list-item>
  94. </uni-list>
  95. <uni-popup ref="popupkf" type="center">
  96. <view class="popup-box">
  97. <view class="img">
  98. <image src="../../static/img/img009.png" mode=""></image>
  99. </view>
  100. <view class="mian">
  101. <view class="delivery">
  102. <view class="title">已经为您定制专属客服</view>
  103. <image src="../../static/img/img010.png" mode=""></image>
  104. </view>
  105. <view class="nocancel">客服VX:{{ text }}</view>
  106. <view class="comfirm-box">
  107. <view class="cancel" @click="cancel">取消</view>
  108. <view class="comfirm" @click="comfirm(text)">复制微信</view>
  109. </view>
  110. </view>
  111. </view>
  112. </uni-popup>
  113. <uni-popup ref="popupqd" type="center">
  114. <view class="popup">
  115. <view class="popup-dox">
  116. <image class="popup-logo" src="../../static/img/sign-popup.png"></image>
  117. </view>
  118. <view class="popup-title">
  119. 获得
  120. <text>{{ today_integral }}</text>
  121. {{ today_type }}
  122. </view>
  123. <view class="popup-tip">
  124. 明天签到可得
  125. <text>{{ tom_integral }}</text>
  126. {{ tom_type }}
  127. </view>
  128. <view class="popup-btn" @click="closeQd">知道了</view>
  129. </view>
  130. <!-- <view class="close_icon" @click="close">
  131. <image src="../../static/img/Close.png"></image>
  132. </view> -->
  133. </uni-popup>
  134. </view>
  135. </template>
  136. <script>
  137. import {
  138. tabbar1
  139. } from '@/utils/tabbar.js';
  140. import {
  141. mapState,
  142. mapMutations
  143. } from 'vuex';
  144. import uniList from '@/components/uni-list/uni-list.vue';
  145. import uniListItem from '@/components/uni-list-item/uni-list-item.vue';
  146. import {
  147. orderData,
  148. getUserInfo
  149. } from '@/api/user.js';
  150. import {
  151. saveUrl,
  152. interceptor
  153. } from '@/utils/loginUtils.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. current: 4,
  165. tabbar: tabbar1,
  166. qded: false, //是否已签到
  167. text: '15606861277', //客服微信
  168. today_integral: '', //签到获得的数值
  169. today_type: '', //签到获得的数值单位
  170. tom_integral: '', //明天签到获得的数值
  171. tom_type: '', //签到获得的数值单位
  172. userDowm: 0, //卡片升级专属高度
  173. userMaxDowm: 0, //卡片最高高度
  174. toolList: [{
  175. id: 't1',
  176. name: '新人通道',
  177. width: '56rpx',
  178. heigt: '54rpx',
  179. img: '../../static/icon/tool-1.png',
  180. path: '/pages/user/xrtd'
  181. },
  182. {
  183. id: 't2',
  184. name: '邀请好友',
  185. width: '56rpx',
  186. heigt: '57rpx',
  187. img: '../../static/icon/tool-2.png',
  188. path: '/pages/user/shareQrCode'
  189. },
  190. {
  191. id: 't3',
  192. name: '我的粉丝',
  193. width: '68rpx',
  194. heigt: '53rpx',
  195. img: '../../static/icon/tool-3.png',
  196. path: '/pages/user/myfans'
  197. },
  198. {
  199. id: 't4',
  200. name: '我的订单',
  201. width: '55rpx',
  202. heigt: '54rpx',
  203. img: '../../static/icon/tool-4.png',
  204. path: '/pages/order/order'
  205. },
  206. {
  207. id: 't5',
  208. name: '我的商品',
  209. width: '50rpx',
  210. heigt: '58rpx',
  211. img: '../../static/icon/tool-5.png',
  212. path: '/pages/order/order'
  213. },
  214. {
  215. id: 't6',
  216. name: '馆长申请',
  217. width: '59rpx',
  218. heigt: '56rpx',
  219. img: '../../static/icon/tool-6.png',
  220. path: '/pages/user/gzsq'
  221. }
  222. ]
  223. };
  224. },
  225. onShow() {
  226. // 判断是否已经登录
  227. if (this.hasLogin) {
  228. this.loadBaseData();
  229. }
  230. this.loadBaseData();
  231. },
  232. onReady() {
  233. // 初始化获取页面宽度
  234. uni.createSelectorQuery()
  235. .select('.container')
  236. .fields({
  237. size: true
  238. },
  239. data => {
  240. // 计算最多下拉的高度
  241. this.userDowm = Math.floor((data.width / 750) * 185);
  242. // 计算最大触发修改高度事件
  243. this.userMaxDowm = Math.floor((data.width / 750) * 250);
  244. }
  245. )
  246. .exec();
  247. },
  248. // #ifndef MP
  249. // onNavigationBarButtonTap(e) {
  250. // const index = e.index;
  251. // if (index === 0) {
  252. // this.navTo('/pages/set/set');
  253. // } else if (index === 1) {
  254. // // #ifdef APP-PLUS
  255. // const pages = getCurrentPages();
  256. // const page = pages[pages.length - 1];
  257. // const currentWebview = page.$getAppWebview();
  258. // currentWebview.hideTitleNViewButtonRedDot({
  259. // index
  260. // });
  261. // // #endif
  262. // uni.navigateTo({
  263. // url: '/pages/user/notice'
  264. // });
  265. // }
  266. // },
  267. // #endif
  268. computed: {
  269. ...mapState('user', ['userInfo', 'orderInfo', 'hasLogin'])
  270. },
  271. methods: {
  272. ...mapMutations('user', ['setUserInfo', 'setOrderInfo']),
  273. comfirm(text) {
  274. console.log(text);
  275. const result = this.uniCopy(text);
  276. if (result === false) {
  277. uni.showToast({
  278. title: '不支持'
  279. });
  280. } else {
  281. uni.showToast({
  282. title: '复制成功',
  283. icon: 'none'
  284. });
  285. }
  286. this.$refs.popupkf.close();
  287. },
  288. uniCopy(content) {
  289. /**
  290. * 小程序端 和 app端的复制逻辑
  291. */
  292. //#ifndef H5
  293. uni.setClipboardData({
  294. data: content,
  295. success: function() {
  296. console.log('success');
  297. return true;
  298. }
  299. });
  300. //#endif
  301. /**
  302. * H5端的复制逻辑
  303. */
  304. // #ifdef H5
  305. if (!document.queryCommandSupported('copy')) {
  306. //为了兼容有些浏览器 queryCommandSupported 的判断
  307. // 不支持
  308. return false;
  309. }
  310. let textarea = document.createElement('textarea');
  311. textarea.value = content;
  312. textarea.readOnly = 'readOnly';
  313. document.body.appendChild(textarea);
  314. textarea.select(); // 选择对象
  315. textarea.setSelectionRange(0, content.length); //核心
  316. let result = document.execCommand('copy'); // 执行浏览器复制命令
  317. textarea.remove();
  318. return result;
  319. // #endif
  320. },
  321. // 加载初始数据
  322. loadBaseData() {
  323. getUserInfo({})
  324. .then(({
  325. data
  326. }) => {
  327. this.setUserInfo(data);
  328. // 获取用户数据完毕后在获取订单数据防止多次跳转到登录页
  329. orderData({})
  330. .then(({
  331. data
  332. }) => {
  333. this.setOrderInfo(data);
  334. })
  335. .catch(e => {
  336. this.setOrderInfo({
  337. complete_count: 0, //完成
  338. received_count: 0, //待收货
  339. unshipped_count: 0, //待发货
  340. order_count: 0, //订单总数
  341. unpaid_count: 0 //待付款
  342. });
  343. });
  344. })
  345. .catch(e => {
  346. console.log(e);
  347. });
  348. },
  349. /**
  350. * 统一跳转接口,拦截未登录路由
  351. * navigator标签现在默认没有转场动画,所以用view
  352. */
  353. navTo(url) {
  354. console.log(url);
  355. if (!this.hasLogin) {
  356. // 保存地址
  357. saveUrl();
  358. // 登录拦截
  359. interceptor();
  360. } else {
  361. uni.navigateTo({
  362. url
  363. });
  364. }
  365. },
  366. useTool(e) {
  367. this.navTo(e.path);
  368. },
  369. // 签到弹窗
  370. goQd() {
  371. this.$refs.popupqd.open();
  372. this.qded = true;
  373. },
  374. // 关闭签到弹窗
  375. closeQd() {
  376. this.$refs.popupqd.close();
  377. },
  378. // 打开客服
  379. openKf() {
  380. this.$refs.popupkf.open();
  381. },
  382. // 关闭客服
  383. cancel() {
  384. this.$refs.popupkf.close();
  385. }
  386. }
  387. };
  388. </script>
  389. <style lang="scss">
  390. %flex-center {
  391. display: flex;
  392. flex-direction: column;
  393. justify-content: center;
  394. align-items: center;
  395. }
  396. %section {
  397. display: flex;
  398. justify-content: space-around;
  399. align-content: center;
  400. background: #fff;
  401. border-radius: 10rpx;
  402. }
  403. .container,
  404. page {
  405. min-height: 100%;
  406. height: auto;
  407. background-color: $page-color-base;
  408. }
  409. .vheigh {
  410. height: var(--status-bar-height);
  411. background-color: $base-color;
  412. }
  413. .top-image {
  414. position: absolute;
  415. top: 0;
  416. left: 0;
  417. right: 0;
  418. height: 230rpx;
  419. image {
  420. width: 100%;
  421. height: 100%;
  422. }
  423. }
  424. .tool-list {
  425. width: 690rpx;
  426. margin: auto;
  427. margin-top: 20rpx;
  428. background: #ffffff;
  429. box-shadow: 0px 0px 20rpx 0px rgba(50, 50, 52, 0.06);
  430. border-radius: 20rpx;
  431. }
  432. .popup-box {
  433. width: 522rpx;
  434. height: 605rpx;
  435. background-color: #ffffff;
  436. border-radius: 20rpx;
  437. position: relative;
  438. .img {
  439. position: relative;
  440. top: -56rpx;
  441. left: 0;
  442. width: 522rpx;
  443. height: 132rpx;
  444. display: flex;
  445. justify-content: center;
  446. image {
  447. border-radius: 20rpx 20rpx 0 0;
  448. width: 450rpx;
  449. height: 132rpx;
  450. }
  451. }
  452. .mian {
  453. margin-top: -44rpx;
  454. display: flex;
  455. flex-direction: column;
  456. align-items: center;
  457. // padding: 32rpx 32rpx;
  458. background-color: #ffffff;
  459. border-radius: 0 0 20rpx 20rpx;
  460. text-align: center;
  461. .delivery {
  462. font-size: 40rpx;
  463. color: #333333;
  464. display: flex;
  465. align-items: center;
  466. flex-direction: column;
  467. image {
  468. margin-top: 48rpx;
  469. width: 172rpx;
  470. height: 160rpx;
  471. }
  472. }
  473. .nocancel {
  474. font-size: 32rpx;
  475. color: #333333;
  476. margin-top: 14rpx;
  477. }
  478. .comfirm-box {
  479. margin-top: 52rpx;
  480. display: flex;
  481. // margin-bottom: 32rpx;
  482. // justify-content: space-around;
  483. .cancel {
  484. display: flex;
  485. align-items: center;
  486. justify-content: center;
  487. width: 197rpx;
  488. height: 74rpx;
  489. border: 1px solid #dcc786;
  490. border-radius: 38rpx;
  491. font-size: 32rpx;
  492. color: #605128;
  493. }
  494. .comfirm {
  495. margin-left: 32rpx;
  496. display: flex;
  497. align-items: center;
  498. justify-content: center;
  499. width: 197rpx;
  500. height: 74rpx;
  501. background: linear-gradient(-90deg, #d1ba77 0%, #f7e8ad 100%);
  502. border-radius: 38px;
  503. font-size: 32rpx;
  504. color: #605128;
  505. }
  506. }
  507. }
  508. }
  509. .popup {
  510. width: 560rpx;
  511. padding-bottom: 45rpx;
  512. background-color: #ffffff;
  513. border-radius: 15rpx;
  514. text-align: center;
  515. line-height: 1;
  516. .popup-dox {
  517. position: relative;
  518. .popup-logo {
  519. margin: -160rpx auto 0;
  520. width: 400rpx;
  521. height: 200rpx;
  522. }
  523. }
  524. .popup-title {
  525. margin-top: 85rpx;
  526. font-size: 40rpx;
  527. font-family: PingFang SC;
  528. font-weight: bold;
  529. color: #2a2a2a;
  530. text {
  531. font-size: 56rpx;
  532. color: #e83f30;
  533. }
  534. }
  535. .popup-tip {
  536. margin-top: 20rpx;
  537. font-size: 28rpx;
  538. font-family: PingFang SC;
  539. font-weight: 500;
  540. color: #8c8c8c;
  541. text {
  542. color: #e83f30;
  543. }
  544. }
  545. .popup-btn {
  546. margin: 58rpx auto 0;
  547. width: 270rpx;
  548. height: 66rpx;
  549. background: #f0c838;
  550. border-radius: 34rpx;
  551. text-align: center;
  552. line-height: 66rpx;
  553. font-size: 36rpx;
  554. font-family: Source Han Sans CN;
  555. font-weight: 500;
  556. color: #ffffff;
  557. }
  558. }
  559. .user-wrap {
  560. position: relative;
  561. z-index: 10;
  562. width: 690rpx;
  563. height: 283rpx;
  564. background: #ffffff;
  565. box-shadow: 0px 4rpx 13rpx 0px rgba(229, 229, 229, 0.46);
  566. border-radius: 20rpx;
  567. padding: 34rpx 0 40rpx;
  568. margin: auto;
  569. .info-left {
  570. padding-left: 34rpx;
  571. .user-name {
  572. display: flex;
  573. align-items: center;
  574. image {
  575. width: 120rpx;
  576. height: 120rpx;
  577. border-radius: 50%;
  578. }
  579. .user-font {
  580. padding-left: 34rpx;
  581. .name {
  582. width: 250rpx;
  583. font-size: 40rpx;
  584. font-family: Source Han Sans CN;
  585. font-weight: 400;
  586. color: #333333;
  587. }
  588. .phone {
  589. margin-top: 10rpx;
  590. font-size: 20rpx;
  591. font-family: PingFang SC;
  592. font-weight: 500;
  593. color: #999999;
  594. }
  595. }
  596. }
  597. .kpi {
  598. background: #f5eede;
  599. border-radius: 30rpx 0px 0px 30rpx;
  600. padding: 18rpx 24rpx;
  601. font-size: 26rpx;
  602. font-family: PingFang SC;
  603. font-weight: bold;
  604. color: #c6914e;
  605. }
  606. }
  607. .info-right {
  608. display: flex;
  609. align-items: center;
  610. margin-top: 54rpx;
  611. padding: 0 34rpx;
  612. .iright-icon {
  613. width: 32rpx;
  614. height: 32rpx;
  615. }
  616. .iright-font {
  617. margin-left: 12rpx;
  618. font-size: 28rpx;
  619. font-family: PingFang SC;
  620. font-weight: bold;
  621. color: #333333;
  622. }
  623. }
  624. }
  625. .user-set {
  626. justify-content: flex-end;
  627. view {
  628. flex-shrink: 0;
  629. }
  630. padding: 30rpx;
  631. image {
  632. height: 40rpx;
  633. width: 40rpx;
  634. }
  635. }
  636. .main-box {
  637. margin: 20rpx auto 0;
  638. width: 690rpx;
  639. background: #ffffff;
  640. box-shadow: 0px 4rpx 14rpx 0px rgba(229, 229, 229, 0.46);
  641. border-radius: 20rpx;
  642. .title {
  643. display: flex;
  644. justify-content: space-between;
  645. align-items: center;
  646. padding: 24rpx;
  647. border-bottom: 1px solid #EEEEEE;
  648. .title-left {
  649. display: flex;
  650. align-items: center;
  651. .title-icon {
  652. width: 32rpx;
  653. height: 32rpx;
  654. }
  655. .title-font {
  656. margin-left: 20rpx;
  657. font-size: 28rpx;
  658. font-family: PingFang SC;
  659. font-weight: bold;
  660. color: #333333;
  661. }
  662. }
  663. .title-right {
  664. width: 14rpx;
  665. height: 24rpx;
  666. }
  667. }
  668. .main {
  669. padding: 50rpx 0 30rpx;
  670. .item {
  671. padding-bottom: 20rpx;
  672. width: 33%;
  673. display: flex;
  674. flex-direction: column;
  675. align-items: center;
  676. .item-num {
  677. font-size: 36rpx;
  678. font-family: PingFang SC;
  679. font-weight: bold;
  680. color: #333333;
  681. }
  682. .item-font {
  683. margin-top: 18rpx;
  684. font-size: 22rpx;
  685. font-family: PingFang SC;
  686. font-weight: 500;
  687. color: #666666;
  688. }
  689. }
  690. .oitem {
  691. width: 25%;
  692. display: flex;
  693. flex-direction: column;
  694. align-items: center;
  695. .oitem-image {
  696. height: 50rpx;
  697. width: 48rpx;
  698. }
  699. .oitem-font {
  700. margin-top: 20rpx;
  701. font-size: 24rpx;
  702. font-family: PingFang SC;
  703. font-weight: 500;
  704. color: #333333;
  705. }
  706. }
  707. }
  708. }
  709. .gpai {
  710. width: 100rpx;
  711. line-height: 40rpx;
  712. border-radius: 25rpx;
  713. position: absolute;
  714. top: 120rpx;
  715. left: 40rpx;
  716. font-size: 24rpx;
  717. color: #c6914e;
  718. text-align: center;
  719. background-color: #f2d4ae;
  720. }
  721. </style>