user.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696
  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.is_promoter != 0">
  18. <view class="setting">
  19. <image src="../../static/icon/set.png" mode=""></image>
  20. </view>
  21. <view class="config-font">VIP会员</view>
  22. </view>
  23. </view>
  24. <view class="user-money flex">
  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">
  31. <view class="user-money-num">{{ userInfo.pay_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">{{ userInfo.award_range *1|| 0 }}</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')">
  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: '',
  141. text: 'tingjiu1688' //客服微信
  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. },
  275. /**
  276. * 统一跳转接口,拦截未登录路由
  277. * navigator标签现在默认没有转场动画,所以用view
  278. */
  279. navTo(url) {
  280. console.log(url);
  281. // if (!this.hasLogin) {
  282. // // 保存地址
  283. // saveUrl();
  284. // // 登录拦截
  285. // interceptor();
  286. // } else {
  287. // uni.navigateTo({
  288. // url
  289. // });
  290. // }
  291. uni.navigateTo({
  292. url
  293. });
  294. },
  295. close() {
  296. this.$refs.popuphx.close();
  297. this.code = '';
  298. },
  299. // 打开客服
  300. openKf() {
  301. this.$refs.popupkf.open();
  302. },
  303. // 关闭客服
  304. cancel() {
  305. this.$refs.popupkf.close();
  306. },
  307. // 打开绑定
  308. open() {
  309. this.$refs.gspass.open();
  310. },
  311. cast() {
  312. set_waiter({
  313. uid: this.id
  314. })
  315. .then(e => {
  316. this.$api.msg('绑定成功');
  317. this.$refs.gspass.close();
  318. this.id = '';
  319. })
  320. .catch(err => {
  321. this.$refs.gspass.close();
  322. this.id = '';
  323. });
  324. },
  325. cancelpass() {
  326. this.$refs.gspass.close();
  327. this.id = '';
  328. }
  329. }
  330. };
  331. </script>
  332. <style lang="scss">
  333. %flex-center {
  334. display: flex;
  335. flex-direction: column;
  336. justify-content: center;
  337. align-items: center;
  338. }
  339. %section {
  340. display: flex;
  341. justify-content: space-around;
  342. align-content: center;
  343. background: #fff;
  344. border-radius: 10rpx;
  345. }
  346. .container,
  347. page {
  348. min-height: 100%;
  349. height: auto;
  350. background-color: $page-color-base;
  351. }
  352. .vheigh {
  353. height: var(--status-bar-height);
  354. background-color: $base-color;
  355. }
  356. .bg {
  357. position: absolute;
  358. top: 0;
  359. left: 0;
  360. height: 420rpx;
  361. width: 100%;
  362. image {
  363. width: 100%;
  364. height: 100%;
  365. }
  366. }
  367. .user-section {
  368. padding: 112rpx 42rpx 0 38rpx;
  369. position: relative;
  370. z-index: 10;
  371. .detail {
  372. display: flex;
  373. align-items: center;
  374. .portrait-box {
  375. height: 120rpx;
  376. width: 120rpx;
  377. .portrait {
  378. width: 100%;
  379. height: 100%;
  380. border: 4rpx solid #fff;
  381. border-radius: 50%;
  382. }
  383. }
  384. .info-box {
  385. margin-left: 20rpx;
  386. line-height: 1;
  387. .username {
  388. font-size: 32rpx;
  389. font-family: PingFang SC;
  390. font-weight: bold;
  391. color: #ffffff;
  392. }
  393. .phone {
  394. font-size: 25rpx;
  395. font-family: PingFang SC;
  396. font-weight: 500;
  397. color: #ffffff;
  398. margin-top: 18rpx;
  399. }
  400. }
  401. }
  402. .config {
  403. width: 161rpx;
  404. height: 51rpx;
  405. background: #ffffff;
  406. border-radius: 25rpx;
  407. display: flex;
  408. align-items: center;
  409. justify-content: center;
  410. line-height: 1;
  411. .setting {
  412. width: 25rpx;
  413. height: 36rpx;
  414. image {
  415. width: 25rpx;
  416. height: 36rpx;
  417. }
  418. }
  419. .config-font {
  420. margin-left: 10rpx;
  421. font-size: 25rpx;
  422. font-family: PingFang SC;
  423. font-weight: 500;
  424. color: #ee2f72;
  425. }
  426. }
  427. }
  428. .user-money {
  429. position: relative;
  430. z-index: 2;
  431. width: 100%;
  432. margin-top: 50rpx;
  433. justify-content: center;
  434. .user-money-item {
  435. line-height: 1;
  436. width: 33%;
  437. display: flex;
  438. flex-direction: column;
  439. justify-content: center;
  440. align-items: center;
  441. .user-money-num {
  442. font-size: 40rpx;
  443. font-family: PingFang SC;
  444. font-weight: bold;
  445. color: #ffffff;
  446. }
  447. .user-money-font {
  448. margin-top: 20rpx;
  449. font-size: 28rpx;
  450. font-family: PingFang SC;
  451. font-weight: 500;
  452. color: #FCFCFC;
  453. }
  454. }
  455. .user-xian {
  456. width: 1px;
  457. height: 34rpx;
  458. background: rgba(255, 255, 255, 0.3);
  459. }
  460. }
  461. .popup-box {
  462. width: 522rpx;
  463. height: 605rpx;
  464. background-color: #ffffff;
  465. border-radius: 20rpx;
  466. position: relative;
  467. .img {
  468. position: relative;
  469. top: -56rpx;
  470. left: 0;
  471. width: 522rpx;
  472. height: 132rpx;
  473. display: flex;
  474. justify-content: center;
  475. image {
  476. border-radius: 20rpx 20rpx 0 0;
  477. width: 450rpx;
  478. height: 132rpx;
  479. }
  480. }
  481. .mian {
  482. margin-top: -44rpx;
  483. display: flex;
  484. flex-direction: column;
  485. align-items: center;
  486. // padding: 32rpx 32rpx;
  487. background-color: #ffffff;
  488. border-radius: 0 0 20rpx 20rpx;
  489. text-align: center;
  490. .delivery {
  491. font-size: 40rpx;
  492. color: #333333;
  493. display: flex;
  494. align-items: center;
  495. flex-direction: column;
  496. image {
  497. margin-top: 48rpx;
  498. width: 172rpx;
  499. height: 160rpx;
  500. }
  501. }
  502. .nocancel {
  503. font-size: 32rpx;
  504. color: #333333;
  505. margin-top: 14rpx;
  506. }
  507. .comfirm-box {
  508. margin-top: 52rpx;
  509. display: flex;
  510. // margin-bottom: 32rpx;
  511. // justify-content: space-around;
  512. .cancel {
  513. display: flex;
  514. align-items: center;
  515. justify-content: center;
  516. width: 197rpx;
  517. height: 74rpx;
  518. border: 1px solid #dcc786;
  519. border-radius: 38rpx;
  520. font-size: 32rpx;
  521. color: #605128;
  522. }
  523. .comfirm {
  524. margin-left: 32rpx;
  525. display: flex;
  526. align-items: center;
  527. justify-content: center;
  528. width: 197rpx;
  529. height: 74rpx;
  530. background: linear-gradient(-90deg, #d1ba77 0%, #f7e8ad 100%);
  531. border-radius: 38px;
  532. font-size: 32rpx;
  533. color: #605128;
  534. }
  535. }
  536. }
  537. }
  538. .main-box {
  539. position: relative;
  540. z-index: 2;
  541. margin: 20rpx auto 0;
  542. width: 710rpx;
  543. background: #ffffff;
  544. box-shadow: 0px 4rpx 14rpx 0px rgba(229, 229, 229, 0.46);
  545. border-radius: 20rpx;
  546. .title {
  547. display: flex;
  548. justify-content: space-between;
  549. align-items: center;
  550. padding: 24rpx;
  551. border-bottom: 1px solid #eeeeee;
  552. .title-left {
  553. display: flex;
  554. align-items: center;
  555. .title-icon {
  556. width: 32rpx;
  557. height: 32rpx;
  558. }
  559. .title-font {
  560. margin-left: 20rpx;
  561. font-size: 28rpx;
  562. font-family: PingFang SC;
  563. font-weight: bold;
  564. color: #333333;
  565. }
  566. }
  567. .title-right {
  568. width: 14rpx;
  569. height: 24rpx;
  570. }
  571. }
  572. .main {
  573. padding: 50rpx 0 30rpx;
  574. .jg {
  575. width: 1px;
  576. height: 100rpx;
  577. background: #eeeeee;
  578. }
  579. .item {
  580. padding-bottom: 20rpx;
  581. width: 25%;
  582. display: flex;
  583. flex-direction: column;
  584. align-items: center;
  585. .item-num {
  586. font-size: 36rpx;
  587. font-family: PingFang SC;
  588. font-weight: bold;
  589. color: #333333;
  590. }
  591. .item-font {
  592. margin-top: 18rpx;
  593. font-size: 22rpx;
  594. font-family: PingFang SC;
  595. font-weight: 500;
  596. color: #666666;
  597. }
  598. }
  599. .oitem {
  600. width: 33%;
  601. display: flex;
  602. flex-direction: column;
  603. align-items: center;
  604. .oitem-image {
  605. height: 40rpx;
  606. width: 42rpx;
  607. }
  608. .oitem-font {
  609. margin-top: 20rpx;
  610. font-size: 24rpx;
  611. font-family: PingFang SC;
  612. font-weight: 500;
  613. color: #333333;
  614. }
  615. }
  616. }
  617. }
  618. .user-list {
  619. background: #ffffff;
  620. padding: 30rpx 25rpx;
  621. width: 690rpx;
  622. border-radius: 28rpx;
  623. margin: 14rpx auto 0;
  624. .left-img {
  625. width: 40rpx;
  626. height: 40rpx;
  627. }
  628. view {
  629. padding-left: 20rpx;
  630. flex-grow: 1;
  631. font-size: 29rpx;
  632. font-weight: bold;
  633. color: #5d5d5d;
  634. }
  635. .right-img {
  636. width: 13rpx;
  637. height: 23rpx;
  638. }
  639. }
  640. </style>