user.vue 17 KB

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