user.vue 15 KB

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