user.vue 15 KB

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