order_addcart.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756
  1. <template>
  2. <view class="order_addcart" :style="colorStyle">
  3. <view class="order_addcart-header-area">
  4. <view class="received">
  5. <view class="pictrue">
  6. <image
  7. src="http://wine.gzzzyd.com/wx/order_addcart/qiandai.png"
  8. ></image>
  9. </view>
  10. <view class="text-info" @click="goReceived()">
  11. <view class="received-count">
  12. {{ moneyObj.receiveItemAmount }}
  13. </view>
  14. <view class="received-info"> 已领取红包 </view>
  15. </view>
  16. </view>
  17. <view class="loss" @click="goMissed()">
  18. <view class="text-info">
  19. <view class="received-count">
  20. {{ moneyObj.lossTotalAmount }}
  21. </view>
  22. <view class="received-info"> 已错失红包 </view>
  23. </view>
  24. </view>
  25. </view>
  26. <view class="loop">
  27. <view class="loop-title"> 当前红包池 </view>
  28. <view class="loop-count">
  29. {{ moneyObj.totalRemainItemAmount }}
  30. </view>
  31. </view>
  32. <view class="tab-area">
  33. <view
  34. @click="
  35. isactiveTab = 'todayRank';
  36. leaderboard();
  37. "
  38. :class="{
  39. 'tab-area-active1': isactiveTab === 'todayRank',
  40. 'base-tab': true,
  41. }"
  42. >
  43. <text> 今日红包排行榜</text>
  44. </view>
  45. <view
  46. @click="
  47. isactiveTab = 'allRank';
  48. leaderboard();
  49. "
  50. :class="{
  51. 'tab-area-active2': isactiveTab === 'allRank',
  52. 'base-tab': true,
  53. }"
  54. >
  55. <text> 红包领取总榜</text>
  56. </view>
  57. </view>
  58. <view class="rank-list">
  59. <view class="rank-list-item" v-for="(src, i) in rankList" :key="src.id">
  60. <img
  61. v-show="i === 0"
  62. src="http://wine.gzzzyd.com/wx/order_addcart/rank1.png"
  63. alt=""
  64. />
  65. <img
  66. v-show="i === 1"
  67. src="http://wine.gzzzyd.com/wx/order_addcart/rank2.png"
  68. alt=""
  69. />
  70. <img
  71. v-show="i === 2"
  72. src="http://wine.gzzzyd.com/wx/order_addcart/rank3.png"
  73. alt=""
  74. />
  75. <img v-show="i !== 0 && i !== 1 && i !== 2" :src="src.avatar" alt="" />
  76. <text class="nuber"> {{ src.userName }}</text>
  77. <text class="mosaic"> {{ src.phone }}</text>
  78. <text class="litem-info"> 共领取了</text>
  79. <text class="balance">{{ src.totalAmount }}</text>
  80. </view>
  81. </view>
  82. <u-overlay :show="show" @click="show = false">
  83. <view class="warp">
  84. <view class="rect" @tap.stop>
  85. <view class="paper_list">
  86. <text
  87. :class="{
  88. acitiveRedper: activeRedPer.type === item.type,
  89. }"
  90. @click="activeRedPer = item;grabAmountFlag = false;"
  91. v-for="item in redPaper"
  92. :key="item.type"
  93. >
  94. {{ ["随机红包", "专属红包", "共富红包"][item.type] }}
  95. </text>
  96. </view>
  97. <view class="cover-img">
  98. <img class="avatar" :src="userInfo.avatar" />
  99. </view>
  100. <view class="h-info"
  101. >当前红包
  102. {{ ["随机红包", "专属红包", "共富红包"][activeRedPer.type] }}
  103. <view class="grabAmount_count" v-if="grabAmountFlag">
  104. <text>恭喜您获得</text>
  105. <text>¥ {{ currentRedpaper.grabAmount }}</text>
  106. </view>
  107. <view class="grabAmount_count" v-if="(activeRedPer.msg && !grabAmountFlag)">
  108. <text>{{ activeRedPer.msg }}</text>
  109. </view>
  110. </view>
  111. <img
  112. class="op-img"
  113. @click="doGrab"
  114. src="http://wine.gzzzyd.com/wx/order_addcart/ling.png"
  115. alt=""
  116. />
  117. <!-- <img class="op-img" src="http://wine.gzzzyd.com/wx/order_addcart/kai.png" alt=""> -->
  118. <view class="b-info">
  119. 今日已领取{{
  120. redPaper.filter((e) => {
  121. return e.flag === 0;
  122. }).length
  123. }}/3
  124. </view>
  125. <view class="b-box">
  126. <text> 参与共富模式,用户可下单领取红包 </text>
  127. </view>
  128. </view>
  129. </view>
  130. </u-overlay>
  131. </view>
  132. </template>
  133. <script>
  134. // #ifdef APP-PLUS
  135. let sysHeight = uni.getSystemInfoSync().statusBarHeight + 'px';
  136. // #endif
  137. // #ifndef APP-PLUS
  138. let sysHeight = 0
  139. // #endif
  140. import {
  141. grabFlag,
  142. leaderboard,
  143. doGrab,
  144. todayStatistics
  145. } from '@/api/home.js';
  146. import {
  147. getProductHot,
  148. collectAll,
  149. getProductDetail
  150. } from '@/api/store.js';
  151. import {
  152. toLogin
  153. } from '@/libs/login.js';
  154. import {
  155. mapGetters
  156. } from "vuex";
  157. import recommend from '@/components/recommend';
  158. import productWindow from '@/components/productWindow';
  159. // #ifdef MP
  160. import authorize from '@/components/Authorize';
  161. // #endif
  162. import pageFooter from '@/components/pageFooter/index.vue'
  163. import colors from "@/mixins/color";
  164. import {
  165. HTTP_REQUEST_URL
  166. } from '@/config/app';
  167. const hot_res = require('@/mock/json/hot_res.json')
  168. import {
  169. getNavigation
  170. } from '@/api/public.js'
  171. import {
  172. colorChange
  173. } from '../../api/api';
  174. export default {
  175. components: {
  176. pageFooter,
  177. recommend,
  178. productWindow,
  179. // #ifdef MP
  180. authorize
  181. // #endif
  182. },
  183. mixins: [colors],
  184. data () {
  185. return {
  186. isactiveTab: 'todayRank',
  187. grabFlagisOpen: false,
  188. grabAmountFlag: false,
  189. show: false,
  190. userInfo: {},
  191. activeRedPer: {
  192. type: 0
  193. },
  194. currentRedpaper: {
  195. // 抢到的金额
  196. grabAmount: '0.00'
  197. },
  198. moneyObj: {
  199. lossTotalAmount: "0",
  200. receiveItemAmount: "0",
  201. receiveItemCount: 0,
  202. redEnvelopeItemCount: 0,
  203. remainItemCount: 0,
  204. totalReceivedRedEnvelopeAmount: "0",
  205. totalRedEnvelopeAmount: "0",
  206. totalRemainItemAmount: "0"
  207. },
  208. imgHost: HTTP_REQUEST_URL,
  209. is_diy: uni.getStorageSync('is_diy'),
  210. canShow: false,
  211. cartCount: 0,
  212. goodsHidden: true,
  213. footerswitch: true,
  214. hostProduct: [],
  215. cartList: {
  216. valid: [],
  217. invalid: []
  218. },
  219. isAllSelect: false, //全选
  220. selectValue: [], //选中的数据
  221. selectCountPrice: 0.00,
  222. isAuto: false, //没有授权的不会自动授权
  223. isShowAuth: false, //是否隐藏授权
  224. hotScroll: false,
  225. hotPage: 1,
  226. hotLimit: 10,
  227. loading: false,
  228. loadend: false,
  229. loadTitle: this.$t(`我也是有底线的`), //提示语
  230. page: 1,
  231. limit: 20,
  232. loadingInvalid: false,
  233. loadendInvalid: false,
  234. loadTitleInvalid: this.$t(`加载更多`), //提示语
  235. pageInvalid: 1,
  236. limitInvalid: 20,
  237. attr: {
  238. cartAttr: false,
  239. productAttr: [],
  240. productSelect: {}
  241. },
  242. rankList: [],
  243. redPaper: [],
  244. productValue: [], //系统属性
  245. storeInfo: {},
  246. attrValue: '', //已选属性
  247. attrTxt: this.$t(`请选择`), //属性页面提示
  248. cartId: 0,
  249. product_id: 0,
  250. sysHeight: sysHeight,
  251. newData: {},
  252. activeRouter: '',
  253. is_diy_set: false
  254. };
  255. },
  256. computed: mapGetters(['isLogin']),
  257. onPullDownRefresh () {
  258. this.grabFlag()
  259. console.log('下拉刷新');
  260. },
  261. onLoad (options) {
  262. let that = this;
  263. if (that.isLogin == false) {
  264. toLogin();
  265. }
  266. let routes = getCurrentPages(); // 获取当前打开过的页面路由数组
  267. let curRoute = routes[routes.length - 1].route //获取当前页面路由
  268. this.activeRouter = '/' + curRoute
  269. },
  270. onShow () {
  271. },
  272. created () {
  273. this.userInfo = JSON.parse(this.$Cache.get("USER_INFO"));
  274. console.log(this.userInfo, this.userInfo.avatar);
  275. this.grabFlag('created')
  276. this.leaderboard()
  277. this.todayStatistics()
  278. },
  279. methods: {
  280. change (e) {
  281. this.show = e.show
  282. },
  283. goReceived () {
  284. uni.navigateTo({
  285. url: '/pages/order_addcart/wallet_received/index'
  286. })
  287. },
  288. goMissed () {
  289. uni.navigateTo({
  290. url: '/pages/order_addcart/wallet_missed/index'
  291. })
  292. },
  293. // 授权关闭
  294. authColse: function (e) {
  295. this.isShowAuth = e;
  296. },
  297. leaderboard () {
  298. let that = this
  299. uni.showLoading({
  300. title: this.$t(`加载中`),
  301. mask: true
  302. });
  303. let postData = {
  304. flag: this.isactiveTab === 'todayRank' ? 1 : 0
  305. }
  306. leaderboard(postData).then(res => {
  307. if (res.data.length > 0) {
  308. that.$set(that, "rankList", res.data)
  309. } else {
  310. that.$set(that, "rankList", [])
  311. }
  312. uni.hideLoading();
  313. })
  314. },
  315. doGrab () {
  316. doGrab({
  317. type: this.activeRedPer.type
  318. }).then(res => {
  319. // if (res.code === 200) {
  320. // this.grabFlag('dograbAmountFlag')
  321. // }
  322. this.currentRedpaper = res.data
  323. this.grabAmountFlag = true
  324. this.grabFlag('dograbAmountFlag')
  325. })
  326. },
  327. grabFlag (params) {
  328. grabFlag().then(res => {
  329. this.redPaper = res.data
  330. if (!params) {
  331. this.grabAmountFlag = false
  332. }
  333. if (params === 'created') {
  334. this.activeRedPer = res.data[0]
  335. let flag = this.redPaper.filter((e) => {
  336. return e.flag === 1;
  337. }).length
  338. console.log(flag,this.activeRedPer);
  339. if (flag === 0) {
  340. this.show = false
  341. uni.stopPullDownRefresh();
  342. return
  343. }
  344. }
  345. this.show = true
  346. uni.stopPullDownRefresh();
  347. })
  348. },
  349. todayStatistics () {
  350. uni.showLoading({
  351. title: this.$t(`加载中`),
  352. mask: true
  353. });
  354. let postData = {
  355. flag: this.isactiveTab === 'todayRank' ? 1 : 0
  356. }
  357. todayStatistics().then(res => {
  358. this.moneyObj = res.data
  359. uni.hideLoading();
  360. })
  361. },
  362. /**
  363. * 购物车手动填写
  364. *
  365. */
  366. iptCartNum: function (e) {
  367. this.$set(this.attr.productSelect, 'cart_num', e);
  368. },
  369. inArray: function (search, array) {
  370. for (let i in array) {
  371. if (array[i] == search) {
  372. return true;
  373. }
  374. }
  375. return false;
  376. },
  377. switchSelect: function () {
  378. let that = this;
  379. let validList = that.cartList.valid;
  380. let selectValue = that.selectValue;
  381. let selectCountPrice = 0.00;
  382. if (selectValue.length < 1) {
  383. that.selectCountPrice = selectCountPrice;
  384. } else {
  385. for (let index in validList) {
  386. if (that.inArray(validList[index].id, selectValue)) {
  387. selectCountPrice = that.$util.$h.Add(selectCountPrice, that.$util.$h.Mul(validList[index]
  388. .cart_num, validList[
  389. index].truePrice))
  390. }
  391. }
  392. that.selectCountPrice = selectCountPrice;
  393. }
  394. },
  395. getInvalidList: function () {
  396. let that = this;
  397. if (this.loadendInvalid) return false;
  398. if (this.loadingInvalid) return false;
  399. let data = {
  400. page: that.pageInvalid,
  401. limit: that.limitInvalid,
  402. status: 0
  403. }
  404. let resData = {
  405. "valid": [],
  406. "invalid": [],
  407. "deduction": {
  408. "seckill_id": 0,
  409. "bargain_id": 0,
  410. "combination_id": 0,
  411. "discount_id": 0
  412. }
  413. }
  414. // getCartList(data).then(res => {
  415. let cartList = resData,
  416. invalid = cartList.invalid,
  417. loadendInvalid = invalid.length < that.limitInvalid;
  418. let invalidList = that.$util.SplitArray(invalid, that.cartList.invalid);
  419. that.$set(that.cartList, 'invalid', invalidList);
  420. that.loadendInvalid = loadendInvalid;
  421. that.loadTitleInvalid = loadendInvalid ? that.$t(`我也是有底线的`) : that.$t(`加载更多`);
  422. that.pageInvalid = that.pageInvalid + 1;
  423. that.loadingInvalid = false;
  424. // }).catch(res => {
  425. // that.loadingInvalid = false;
  426. // that.loadTitleInvalid = that.$t(`加载更多`);
  427. // })
  428. },
  429. getHostProduct: function () {
  430. let that = this;
  431. if (that.hotScroll) return
  432. that.hotPage++
  433. that.hotScroll = hot_res.length < that.hotLimit
  434. that.hostProduct = that.hostProduct.concat(hot_res)
  435. },
  436. },
  437. onReachBottom () {
  438. let that = this;
  439. if (that.loadend) {
  440. that.getInvalidList();
  441. }
  442. if (that.cartList.valid.length == 0 && that.cartList.invalid.length == 0) {
  443. that.getHostProduct();
  444. }
  445. }
  446. }
  447. </script>
  448. <style scoped lang="scss">
  449. .order_addcart {
  450. padding: 20rpx;
  451. }
  452. .rank-list {
  453. background: white;
  454. margin-top: 20rpx;
  455. padding-top: 20rpx;
  456. padding-bottom: 10rpx;
  457. height: 600rpx;
  458. overflow: auto;
  459. .rank-list-item {
  460. margin: 20rpx;
  461. margin-bottom: 40rpx;
  462. width: calc(100% - 40rpx);
  463. height: 50rpx;
  464. display: flex;
  465. image {
  466. width: 50rpx;
  467. height: 50rpx;
  468. margin-right: 20rpx;
  469. margin-left: 10rpx;
  470. }
  471. .nuber {
  472. font-size: 18rpx;
  473. margin-right: 20rpx;
  474. line-height: 0rpx;
  475. }
  476. .mosaic {
  477. font-size: 18rpx;
  478. margin-right: 20rpx;
  479. color: #999999;
  480. line-height: 0rpx;
  481. }
  482. .litem-info {
  483. text-align: right;
  484. flex-grow: 1;
  485. font-size: 24rpx;
  486. line-height: 50rpx;
  487. margin-right: 20rpx;
  488. color: #666666;
  489. }
  490. .balance {
  491. line-height: 50rpx;
  492. color: #eb4c63;
  493. }
  494. }
  495. }
  496. .loop {
  497. background: url("http://wine.gzzzyd.com/wx/order_addcart/hongbaochi.png")
  498. no-repeat;
  499. width: 100%;
  500. height: 250rpx;
  501. background-size: 100% 100%;
  502. position: relative;
  503. .loop-title {
  504. padding: 20rpx;
  505. padding-left: 35rpx;
  506. font-size: 32rpx;
  507. }
  508. .loop-count {
  509. text-align: center;
  510. line-height: 97rpx;
  511. font-size: 48rpx;
  512. color: #eb4c63;
  513. width: 420rpx;
  514. height: 97rpx;
  515. background: #ffffff;
  516. border-radius: 23px;
  517. border: 1px solid #eb4c63;
  518. position: absolute;
  519. left: 50%;
  520. top: 47%;
  521. transform: translateX(-50%);
  522. }
  523. // image {
  524. // width: 100%;
  525. // }
  526. }
  527. .tab-area {
  528. margin-top: 20rpx;
  529. display: flex;
  530. flex-wrap: nowrap;
  531. justify-content: space-between;
  532. line-height: 90rpx;
  533. text-align: center;
  534. .base-tab {
  535. width: 48%;
  536. height: 90rpx;
  537. }
  538. .tab-area-active1 {
  539. background: url("http://wine.gzzzyd.com/wx/order_addcart/tab1.png")
  540. no-repeat;
  541. background-size: 340rpx 120rpx;
  542. }
  543. .tab-area-active2 {
  544. background: url("http://wine.gzzzyd.com/wx/order_addcart/tab2.png")
  545. no-repeat;
  546. background-size: 340rpx 120rpx;
  547. }
  548. }
  549. .order_addcart-header-area {
  550. display: flex;
  551. .received {
  552. width: 405rpx;
  553. height: 175rpx;
  554. padding: 20rpx;
  555. margin-bottom: 20rpx;
  556. margin-right: 20rpx;
  557. background-color: #fff;
  558. border-radius: 20rpx;
  559. overflow: hidden;
  560. position: relative;
  561. display: flex;
  562. .pictrue {
  563. display: flex;
  564. align-items: center;
  565. image {
  566. width: 98rpx;
  567. height: 98rpx;
  568. }
  569. margin-right: 20rpx;
  570. }
  571. .text-info {
  572. display: flex;
  573. flex-direction: column;
  574. justify-content: center;
  575. color: #6eb03a;
  576. .received-count {
  577. font-size: 38rpx;
  578. margin-bottom: 10rpx;
  579. letter-spacing: 2px;
  580. }
  581. .received-info {
  582. font-size: 28rpx;
  583. }
  584. }
  585. }
  586. .loss {
  587. flex-grow: 1;
  588. height: 175rpx;
  589. padding: 20rpx;
  590. margin-bottom: 20rpx;
  591. background-color: #fff;
  592. border-radius: 20rpx;
  593. overflow: hidden;
  594. position: relative;
  595. display: flex;
  596. .text-info {
  597. width: 100%;
  598. display: flex;
  599. flex-direction: column;
  600. justify-content: center;
  601. text-align: center;
  602. color: #d08d5b;
  603. .received-count {
  604. font-size: 38rpx;
  605. margin-bottom: 10rpx;
  606. letter-spacing: 2px;
  607. }
  608. .received-info {
  609. font-size: 28rpx;
  610. }
  611. }
  612. }
  613. }
  614. .warp {
  615. display: flex;
  616. align-items: center;
  617. justify-content: center;
  618. height: 100%;
  619. }
  620. .rect {
  621. position: relative;
  622. width: 700rpx;
  623. height: 950rpx;
  624. background: url("http://wine.gzzzyd.com/wx/order_addcart/hongbao_bg.png")
  625. no-repeat;
  626. padding-top: 60rpx;
  627. background-size: 700rpx 950rpx;
  628. .cover-img {
  629. margin-top: 40rpx;
  630. position: relative;
  631. left: 50%;
  632. transform: translate(-50%, 0%);
  633. width: 120rpx;
  634. height: 120rpx;
  635. border-radius: 50%;
  636. overflow: hidden;
  637. .avatar {
  638. position: absolute;
  639. z-index: 9999;
  640. width: 120rpx;
  641. height: 120rpx;
  642. }
  643. }
  644. .paper_list {
  645. display: flex;
  646. margin: 0 auto;
  647. justify-content: space-between;
  648. color: rgb(244, 180, 53);
  649. border-radius: 50rpx;
  650. width: 80%;
  651. font-size: 32rpx;
  652. height: 80rpx;
  653. line-height: 60rpx;
  654. background: rgb(196, 40, 62);
  655. text-align: center;
  656. text {
  657. flex:31%;
  658. border-radius: 50rpx;
  659. margin: 10rpx;
  660. }
  661. }
  662. .h-info {
  663. position: relative;
  664. text-align: center;
  665. padding: 10rpx;
  666. height: 290rpx;
  667. color: white;
  668. .grabAmount_count {
  669. position: relative;
  670. left: 50%;
  671. transform: translate(-50%, 0rpx);
  672. width: 60%;
  673. text-align:center;
  674. margin-top: 80rpx;
  675. font-size: 32rpx;
  676. font-weight: 600;
  677. color: rgb(244, 180, 53);
  678. &:nth-child(1) {
  679. font-size: 32rpx;
  680. }
  681. }
  682. }
  683. .op-img {
  684. cursor: pointer;
  685. position: relative;
  686. left: 50%;
  687. transform: translate(-50%, 0rpx);
  688. width: 150rpx;
  689. height: 150rpx;
  690. }
  691. .b-info {
  692. font-size: 22rpx;
  693. width: 100%;
  694. text-align: center;
  695. color: rgb(244, 180, 53);
  696. margin-bottom: 30rpx;
  697. }
  698. .b-box {
  699. margin: 0 auto;
  700. color: rgb(244, 180, 53);
  701. border-radius: 50rpx;
  702. width: 55%;
  703. font-size: 22rpx;
  704. height: 40rpx;
  705. line-height: 40rpx;
  706. background: rgb(196, 40, 62);
  707. text-align: center;
  708. }
  709. }
  710. .acitiveRedper {
  711. background: rgb(244, 180, 53);
  712. border-radius: 50rpx;
  713. color: white;
  714. }
  715. </style>