user.vue 14 KB

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