user.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641
  1. <template>
  2. <view class="container">
  3. <!-- #ifdef APP-PLUS -->
  4. <view class="bar-height"></view>
  5. <!-- #endif -->
  6. <!-- <scroll-view class="content-box" scroll-y="true"> -->
  7. <view class="user-section">
  8. <view class="bg">
  9. <image src="../../static/user/ground.png" mode=""></image>
  10. </view>
  11. <!-- top -->
  12. <view class="user-info-box ">
  13. <view class="detail flex" @click="navTo('/pages/userinfo/userinfo')">
  14. <view class="portrait-box"><image class="portrait" :src="userInfo.avatar || '/static/error/missing-face.png'"></image></view>
  15. <view class="info-box">
  16. <view class="username">{{ userInfo.nickname || '游客' }}</view>
  17. <view class="font-size-sm" v-if="userInfo.uid">19999999999</view>
  18. </view>
  19. </view>
  20. <view class="config">
  21. <text class="setting " @click="navTo('/pages/set/set')">
  22. <image src="../../static/user/set.png" mode=""></image>
  23. </text>
  24. 设置
  25. </view>
  26. </view>
  27. <!-- 会员卡功能 -->
  28. </view>
  29. <view class="item-box">
  30. <view class="box-title flex borde-b">
  31. <view class="title"><text>我的订单</text></view>
  32. <view class="link" @click="navTo('/pages/order/order?state=5')" hover-class="common-hover">
  33. <text class="iconfont iconenter"></text>
  34. </view>
  35. </view>
  36. <view class="order-section">
  37. <view class="order-item" @click="navTo('/pages/order/order?state=1')" hover-class="common-hover" :hover-stay-time="50">
  38. <view class=" icon1 position-relative">
  39. <image class="icon-img" src="/static/icon/i2.png" mode="aspectFit"></image>
  40. <view class="corner" v-if="orderInfo.unshipped_count > 0">
  41. <text>{{ orderInfo.unshipped_count }}</text>
  42. </view>
  43. </view>
  44. <text>待发货</text>
  45. </view>
  46. <view class="order-item" @click="navTo('/pages/order/order?state=2')" hover-class="common-hover" :hover-stay-time="50">
  47. <view class="icon1 position-relative">
  48. <image class="icon-img" src="/static/icon/i3.png" mode="aspectFit"></image>
  49. <view class="corner" v-if="orderInfo.received_count > 0">
  50. <text>{{ orderInfo.received_count }}</text>
  51. </view>
  52. </view>
  53. <text>待收货</text>
  54. </view>
  55. <view class="order-item" @click="navTo('/pages/order/order?state=3')" hover-class="common-hover" :hover-stay-time="50">
  56. <view class="icon1 position-relative">
  57. <image class="icon-img" src="/static/icon/i4.png" mode="aspectFit"></image>
  58. <view class="corner" v-if="orderInfo.evaluated_count > 0">
  59. <text>{{ orderInfo.evaluated_count }}</text>
  60. </view>
  61. </view>
  62. <text>待评价</text>
  63. </view>
  64. <view class="order-item" @click="navTo('/pages/order/refundOrder?state=0')" hover-class="common-hover" :hover-stay-time="50">
  65. <view class=" icon1 position-relative">
  66. <image class="icon-img" src="/static/icon/i1.png" mode="aspectFit"></image>
  67. </view>
  68. <text>退款</text>
  69. </view>
  70. </view>
  71. </view>
  72. <!-- <view class="cover-container"> -->
  73. <view class="vip">
  74. <image src="../../static/user/upgrade.png" mode=""></image>
  75. </view>
  76. <!-- 订单 -->
  77. <view class="item-box " v-if="isShowIllegality">
  78. <view class="order-section order">
  79. <view class="order-item" @click="navTo('/pages/wallet/wallet')" hover-class="common-hover" :hover-stay-time="50">
  80. <view class=" icon position-relative"><image class="icon-img" src="../../static/user/balance.png" mode="aspectFit"></image></view>
  81. <text>我的余额</text>
  82. </view>
  83. <view class="order-item" @click="navTo('/pages/award/award')" hover-class="common-hover" :hover-stay-time="50">
  84. <view class=" icon position-relative"><image class="icon-img" src="../../static/user/commission.png" mode="aspectFit"></image></view>
  85. <text>我的佣金</text>
  86. </view>
  87. <view class="order-item" @click="navTo('/pages/scoreAccumulate/scoreAccumulate')" hover-class="common-hover" :hover-stay-time="50">
  88. <view class=" icon position-relative"><image class="icon-img" src="../../static/user/integral.png" mode="aspectFit"></image></view>
  89. <text>我的积分</text>
  90. </view>
  91. <view class="order-item" @click="navTo('/pages/coupon/consumer')" hover-class="common-hover" :hover-stay-time="50">
  92. <view class=" icon position-relative"><image class="icon-img" src="../../static/user/coupon.png" mode="aspectFit"></image></view>
  93. <text>我的消费券</text>
  94. </view>
  95. <!-- <view v-if="userInfo.is_store == 1" class="order-item" @click="openQr" hover-class="common-hover" :hover-stay-time="50">
  96. <view class=" icon position-relative"><image class="icon-img" src="/static/icon/u4.png" mode="aspectFit"></image></view>
  97. <text>核销</text>
  98. </view> -->
  99. </view>
  100. <!-- <image class="arc" v-if="isShowIllegality" src="/static/img/arc.png"></image> -->
  101. <!-- <view class="tj-sction" v-if="isShowIllegality">
  102. <view class="tj-item" @click="navTo('/pages/wallet/wallet')">
  103. <text class="num">{{ userInfo.now_money || '0.00' }}</text>
  104. <text>余额</text>
  105. </view>
  106. <view class="tj-item" @click="navTo('/pages/award/award')">
  107. <text class="num">{{ userInfo.brokerage_price || '0.00' }}</text>
  108. <text>佣金</text>
  109. </view>
  110. <view class="tj-item" @click="navTo('/pages/scoreAccumulate/scoreAccumulate')">
  111. <text class="num">{{ userInfo.integral || '0.00' }}</text>
  112. <text>积分</text>
  113. </view>
  114. <view class="tj-item" @click="navTo('/pages/coupon/consumer')">
  115. <text class="num">{{ userInfo.consumer || '0.00' }}</text>
  116. <text>消费券</text>
  117. </view>
  118. </view> -->
  119. <!-- 浏览历史 -->
  120. <view class="history-section ">
  121. <uni-list>
  122. <uni-list-item v-if="isShowIllegality" title="我的推广" @click="navTo('/pages/wallet/wallet')" thumb="/static/user/tuiguang.png"></uni-list-item>
  123. <uni-list-item title="邀请海报" @click="navTo('/pages/myteam/myteam')" thumb="/static/user/haibao.png"></uni-list-item>
  124. <uni-list-item title="我的收藏" @click="navTo('/pages/favorites/favorites')" thumb="/static/user/collect.png"></uni-list-item>
  125. <uni-list-item title="收货地址" @click="navTo('/pages/shareQrCode/index')" thumb="/static/user/address.png"></uni-list-item>
  126. <uni-list-item title="商家入口" @click="navTo('/pages/merchant/merchant')" thumb="/static/user/shopping.png"></uni-list-item>
  127. </uni-list>
  128. </view>
  129. </view>
  130. <!-- </scroll-view> -->
  131. </view>
  132. </template>
  133. <script>
  134. import { mapState, mapMutations } from 'vuex';
  135. import uniList from '@/components/uni-list/uni-list.vue';
  136. import uniListItem from '@/components/uni-list-item/uni-list-item.vue';
  137. import { orderData, orderVerific } from '@/api/user.js';
  138. import { getUserInfo } from '@/api/login.js';
  139. let startY = 0,
  140. moveY = 0,
  141. pageAtTop = true;
  142. export default {
  143. components: {
  144. uniList,
  145. uniListItem
  146. },
  147. data() {
  148. return {
  149. coverTransform: 'translateY(0px)',
  150. coverTransition: '0s',
  151. moving: false,
  152. userDowm: 0, //卡片升级专属高度
  153. userMaxDowm: 0, //卡片最高高度
  154. orderinfo: {
  155. complete_count: 0,
  156. received_count: 0,
  157. unshipped_count: 0,
  158. order_count: 0
  159. },
  160. // 判断是否已经点击过一次取消关注公众号
  161. watchful: true
  162. };
  163. },
  164. onShow() {
  165. // 判断是否已经登录
  166. if (this.hasLogin) {
  167. this.loadBaseData();
  168. }
  169. },
  170. onReady() {
  171. // 初始化获取页面宽度
  172. uni.createSelectorQuery()
  173. .select('.container')
  174. .fields(
  175. {
  176. size: true
  177. },
  178. data => {
  179. // 计算最多下拉的高度
  180. this.userDowm = Math.floor((data.width / 750) * 200);
  181. // 计算最大触发修改高度事件
  182. this.userMaxDowm = Math.floor((data.width / 750) * 250);
  183. }
  184. )
  185. .exec();
  186. },
  187. computed: {
  188. ...mapState('user', ['userInfo', 'orderInfo', 'hasLogin']),
  189. // #ifdef H5
  190. ...mapState(['weichatObj']),
  191. // #endif
  192. ...mapState(['isShowIllegality'])
  193. },
  194. methods: {
  195. ...mapMutations('user', ['setUserInfo', 'setOrderInfo']),
  196. // 加载初始数据
  197. loadBaseData() {
  198. let obj = this;
  199. getUserInfo({})
  200. .then(({ data }) => {
  201. orderData({})
  202. .then(({ data }) => {
  203. obj.setOrderInfo(data);
  204. })
  205. .catch(e => {
  206. obj.setOrderInfo({
  207. complete_count: 0, //完成
  208. received_count: 0, //待收货
  209. unshipped_count: 0, //待发货
  210. order_count: 0, //订单总数
  211. unpaid_count: 0 //待付款
  212. });
  213. });
  214. obj.setUserInfo(data);
  215. // 判断是否已经关注公众号
  216. if (data.subscribe == 0 && obj.watchful) {
  217. uni.showModal({
  218. title: '温馨提醒',
  219. content: '为提供更好的服务,请关注公众号。',
  220. success: res => {
  221. obj.watchful = false;
  222. // 判断是否点击了确认
  223. if (res.confirm) {
  224. uni.navigateTo({
  225. url: '/pages/shareQrCode/wechatQr'
  226. });
  227. }
  228. }
  229. });
  230. }
  231. })
  232. .catch(e => {
  233. console.log(e);
  234. });
  235. },
  236. /**
  237. * 统一跳转接口,拦截未登录路由
  238. * navigator标签现在默认没有转场动画,所以用view
  239. */
  240. navTo(url) {
  241. if (!this.hasLogin) {
  242. url = '/pages/public/login';
  243. // #ifdef H5
  244. let weichatBrowser = uni.getStorageSync('weichatBrowser');
  245. // 判断是否为微信浏览器
  246. if (weichatBrowser) {
  247. url = '/pages/public/wxLogin';
  248. }
  249. // #endif
  250. // #ifdef MP-WEIXIN
  251. url = '/pages/public/wxLogin';
  252. // #endif
  253. }
  254. uni.navigateTo({
  255. url
  256. });
  257. },
  258. /**
  259. * 会员卡下拉和回弹
  260. * 1.关闭bounce避免ios端下拉冲突
  261. * 2.由于touchmove事件的缺陷(以前做小程序就遇到,比如20跳到40,h5反而好很多),下拉的时候会有掉帧的感觉
  262. * transition设置0.1秒延迟,让css来过渡这段空窗期
  263. * 3.回弹效果可修改曲线值来调整效果,推荐一个好用的bezier生成工具 http://cubic-bezier.com/
  264. */
  265. coverTouchstart(e) {
  266. // console.log(e);
  267. if (pageAtTop === false) {
  268. return;
  269. }
  270. this.coverTransition = 'transform .1s linear';
  271. startY = e.touches[0].clientY;
  272. },
  273. coverTouchmove(e) {
  274. // console.log(e);
  275. moveY = e.touches[0].clientY;
  276. let moveDistance = moveY - startY;
  277. let maxDowm = this.userMaxDowm;
  278. let Dowm = this.userDowm;
  279. if (moveDistance < 0) {
  280. this.moving = false;
  281. return;
  282. }
  283. this.moving = true;
  284. if (moveDistance >= Dowm && moveDistance < maxDowm) {
  285. moveDistance = Dowm;
  286. }
  287. if (moveDistance > 0 && moveDistance <= Dowm) {
  288. this.coverTransform = `translateY(${moveDistance}px)`;
  289. }
  290. },
  291. coverTouchend() {
  292. if (this.moving === false) {
  293. return;
  294. }
  295. this.moving = false;
  296. this.coverTransition = 'transform 0.3s cubic-bezier(.21,1.93,.53,.64)';
  297. this.coverTransform = 'translateY(0px)';
  298. },
  299. // 核销
  300. openQr() {
  301. let obj = this;
  302. // #ifndef H5
  303. uni.scanCode({
  304. success(e) {
  305. obj.orderVerific(e.result);
  306. }
  307. });
  308. // #endif
  309. // #ifdef H5
  310. this.weichatObj.scanQRCode({
  311. needResult: 1, // 默认为0,扫描结果由微信处理,1则直接返回扫描结果,
  312. scanType: ['qrCode', 'barCode'], // 可以指定扫二维码还是一维码,默认二者都有
  313. success: function(res) {
  314. obj.orderVerific(res.resultStr); // 当needResult 为 1 时,扫码返回的结果
  315. }
  316. });
  317. // #endif
  318. },
  319. // 核销请求
  320. orderVerific(data) {
  321. orderVerific({
  322. verify_code: data
  323. })
  324. .then(e => {
  325. uni.showModal({
  326. title: '核销',
  327. content: '已核销成功',
  328. showCancel: false
  329. });
  330. })
  331. .catch(e => {
  332. uni.showModal({
  333. title: '错误',
  334. content: JSON.stringify(e),
  335. showCancel: false
  336. });
  337. console.log(e);
  338. });
  339. }
  340. }
  341. };
  342. </script>
  343. <style lang="scss">
  344. %flex-center {
  345. display: flex;
  346. flex-direction: column;
  347. justify-content: center;
  348. align-items: center;
  349. }
  350. %section {
  351. display: flex;
  352. justify-content: space-around;
  353. align-content: center;
  354. background: #fff;
  355. border-radius: 10rpx;
  356. }
  357. .container {
  358. height: 100%;
  359. background-color: #FFFFFF;
  360. /* #ifdef APP-PLUS */
  361. .bar-height {
  362. height: var(--status-bar-height);
  363. background-color: $base-color;
  364. }
  365. /* #endif */
  366. }
  367. .content-box {
  368. height: 100%;
  369. }
  370. .user-section {
  371. height: 435rpx;
  372. padding: 60rpx 0 0 30rpx;
  373. position: relative;
  374. .bg {
  375. position: absolute;
  376. height: 480rpx;
  377. width: 100%;
  378. left: 0;
  379. top: 0;
  380. image{
  381. width: 100%;
  382. height: 100%;
  383. }
  384. // background-color: $base-color;
  385. }
  386. }
  387. .user-info-box {
  388. height: 180rpx;
  389. color: white;
  390. display: flex;
  391. align-items: center;
  392. justify-content: space-between;
  393. position: relative;
  394. z-index: 1;
  395. .detail {
  396. height: 130rpx;
  397. .portrait-box {
  398. height: 100%;
  399. .portrait {
  400. width: 130rpx;
  401. height: 100%;
  402. border: 5rpx solid #fff;
  403. border-radius: 50%;
  404. }
  405. }
  406. .info-box {
  407. margin-left: 20rpx;
  408. line-height: 1.5;
  409. .username {
  410. font-size: $font-lg + 6rpx;
  411. height: 100%;
  412. }
  413. }
  414. }
  415. .config {
  416. font-size: 28rpx;
  417. font-family: PingFang SC;
  418. font-weight: 500;
  419. color: #52C696;
  420. display: flex;
  421. justify-content: center;
  422. align-items: center;
  423. width: 165rpx;
  424. height: 64rpx;
  425. background: #FFFFFF;
  426. border-radius: 32px 0px 0px 32px;
  427. .setting {
  428. width: 32rpx;
  429. height: 32rpx;
  430. image{
  431. width: 100%;
  432. height: 100%;
  433. }
  434. // margin-right: 51rpx;
  435. }
  436. }
  437. }
  438. .vip-card-box {
  439. display: flex;
  440. flex-direction: column;
  441. color: #f7d680;
  442. height: 240rpx;
  443. background: linear-gradient(left, rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0.8));
  444. border-radius: 16rpx 16rpx 0 0;
  445. overflow: hidden;
  446. position: relative;
  447. padding: 20rpx 24rpx;
  448. .card-bg {
  449. position: absolute;
  450. top: 20rpx;
  451. right: 0;
  452. width: 380rpx;
  453. height: 260rpx;
  454. }
  455. .b-btn {
  456. position: absolute;
  457. right: 20rpx;
  458. top: 16rpx;
  459. width: 132rpx;
  460. height: 40rpx;
  461. text-align: center;
  462. line-height: 40rpx;
  463. font-size: 22rpx;
  464. color: #36343c;
  465. border-radius: 20px;
  466. background: linear-gradient(left, #f9e6af, #ffd465);
  467. z-index: 1;
  468. }
  469. .tit {
  470. font-size: $font-base + 2rpx;
  471. color: #f7d680;
  472. margin-bottom: 28rpx;
  473. .iconfont {
  474. color: #f6e5a3;
  475. margin-right: 16rpx;
  476. font-size: 30rpx;
  477. }
  478. }
  479. .e-b {
  480. font-size: $font-sm;
  481. color: #d8cba9;
  482. margin-top: 10rpx;
  483. }
  484. }
  485. .vip{
  486. margin-top: -110rpx;
  487. padding: 0 30rpx;
  488. height: 170rpx;
  489. image{
  490. height: 100%;
  491. width: 100%;
  492. }
  493. }
  494. .cover-container {
  495. display: flex;
  496. flex-direction: column;
  497. background: $page-color-base;
  498. padding: 0 30rpx;
  499. position: relative;
  500. background: #f5f5f5;
  501. padding-bottom: 20rpx;
  502. margin-top: -110rpx;
  503. .arc {
  504. position: absolute;
  505. left: 0;
  506. top: -34rpx;
  507. width: 100%;
  508. height: 36rpx;
  509. }
  510. }
  511. .tj-sction {
  512. @extend %section;
  513. .tj-item {
  514. @extend %flex-center;
  515. flex-direction: column;
  516. height: 140rpx;
  517. font-size: $font-sm;
  518. color: #75787d;
  519. }
  520. .num {
  521. font-size: $font-lg;
  522. color: $font-color-dark;
  523. margin-bottom: 8rpx;
  524. }
  525. }
  526. .item-box {
  527. position: relative;
  528. border-radius: 10rpx;
  529. background-color: white;
  530. top: -130rpx;
  531. margin: 0 30rpx;
  532. .box-title {
  533. line-height: 1;
  534. padding: 30rpx;
  535. .title {
  536. font-size: $font-lg;
  537. font-weight: bold;
  538. }
  539. .link {
  540. font-size: $font-base - 2rpx;
  541. color: $font-color-light;
  542. }
  543. }
  544. .order{
  545. margin-top: 70rpx;
  546. }
  547. .order-section {
  548. @extend %section;
  549. padding: 28rpx 0;
  550. .order-item {
  551. @extend %flex-center;
  552. width: 120rpx;
  553. height: 120rpx;
  554. border-radius: 10rpx;
  555. font-size: $font-sm;
  556. color: $font-color-dark;
  557. }
  558. .iconfont {
  559. font-size: 48rpx;
  560. margin-bottom: 18rpx;
  561. color: #fa436a;
  562. }
  563. .icon-shouhoutuikuan {
  564. font-size: 44rpx;
  565. }
  566. .icon {
  567. height: 88rpx;
  568. width: 90rpx;
  569. margin-bottom: 18rpx;
  570. background-size: 100%;
  571. background-repeat: no-repeat;
  572. background-position: center;
  573. .icon-img {
  574. width: 100%;
  575. height: 100%;
  576. }
  577. }
  578. .icon1 {
  579. height: 50rpx;
  580. width: 48rpx;
  581. margin-bottom: 18rpx;
  582. background-size: 100%;
  583. background-repeat: no-repeat;
  584. background-position: center;
  585. .icon-img {
  586. width: 100%;
  587. height: 100%;
  588. }
  589. }
  590. }
  591. }
  592. .history-section {
  593. // padding: 30rpx 0 0;
  594. margin-top: 20rpx;
  595. background: #fff;
  596. border-radius: 10rpx;
  597. .sec-header {
  598. display: flex;
  599. align-items: center;
  600. font-size: $font-base;
  601. color: $font-color-dark;
  602. line-height: 40rpx;
  603. margin-left: 30rpx;
  604. padding-top: 30rpx;
  605. .iconfont {
  606. font-size: 44rpx;
  607. color: $color-red;
  608. margin-right: 16rpx;
  609. line-height: 40rpx;
  610. }
  611. }
  612. .h-list {
  613. white-space: nowrap;
  614. padding: 30rpx 30rpx 0;
  615. image {
  616. display: inline-block;
  617. width: 160rpx;
  618. height: 160rpx;
  619. margin-right: 20rpx;
  620. border-radius: 10rpx;
  621. }
  622. }
  623. }
  624. </style>