user.vue 16 KB

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