order_addcart.vue 49 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726
  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. this.canShow = false
  272. if (this.isLogin == true) {
  273. this.hotPage = 1;
  274. this.hostProduct = [],
  275. this.hotScroll = false,
  276. this.getHostProduct();
  277. this.loadend = false;
  278. this.page = 1;
  279. this.cartList.valid = [];
  280. this.getCartList();
  281. this.loadendInvalid = false;
  282. this.pageInvalid = 1;
  283. this.cartList.invalid = [];
  284. this.getInvalidList();
  285. this.getCartNum();
  286. this.goodsHidden = true;
  287. this.footerswitch = true;
  288. this.hostProduct = [];
  289. this.hotScroll = false;
  290. this.hotPage = 1;
  291. this.hotLimit = 10;
  292. this.cartList = {
  293. valid: [],
  294. invalid: []
  295. },
  296. this.isAllSelect = false; //全选
  297. this.selectValue = []; //选中的数据
  298. this.selectCountPrice = 0.00;
  299. this.cartCount = 0;
  300. this.isShowAuth = false;
  301. };
  302. },
  303. created () {
  304. this.userInfo = JSON.parse(this.$Cache.get("USER_INFO"));
  305. console.log(this.userInfo, this.userInfo.avatar);
  306. this.grabFlag('created')
  307. this.leaderboard()
  308. this.todayStatistics()
  309. },
  310. methods: {
  311. change (e) {
  312. this.show = e.show
  313. },
  314. goReceived () {
  315. uni.navigateTo({
  316. url: '/pages/order_addcart/wallet_received/index'
  317. })
  318. },
  319. goMissed () {
  320. uni.navigateTo({
  321. url: '/pages/order_addcart/wallet_missed/index'
  322. })
  323. },
  324. // 授权关闭
  325. authColse: function (e) {
  326. this.isShowAuth = e;
  327. },
  328. // 修改购物车
  329. reGoCat: function () {
  330. let that = this,
  331. productSelect = that.productValue[this.attrValue];
  332. //如果有属性,没有选择,提示用户选择
  333. if (
  334. that.attr.productAttr.length &&
  335. productSelect === undefined
  336. )
  337. return that.$util.Tips({
  338. title: that.$t(`产品库存不足,请选择其它`)
  339. });
  340. let q = {
  341. id: that.cartId,
  342. product_id: that.product_id,
  343. num: that.attr.productSelect.cart_num,
  344. unique: that.attr.productSelect !== undefined ?
  345. that.attr.productSelect.unique : ""
  346. };
  347. getResetCart(q)
  348. .then(function (res) {
  349. that.attr.cartAttr = false;
  350. that.$util.Tips({
  351. title: that.$t(`添加购物车成功`),
  352. success: () => {
  353. that.loadend = false;
  354. that.page = 1;
  355. that.cartList.valid = [];
  356. that.getCartList();
  357. that.getCartNum();
  358. }
  359. });
  360. })
  361. .catch(res => {
  362. return that.$util.Tips({
  363. title: res.msg
  364. });
  365. });
  366. },
  367. onMyEvent: function () {
  368. this.$set(this.attr, 'cartAttr', false);
  369. },
  370. reElection: function (item) {
  371. this.getGoodsDetails(item)
  372. },
  373. leaderboard () {
  374. let that = this
  375. uni.showLoading({
  376. title: this.$t(`加载中`),
  377. mask: true
  378. });
  379. let postData = {
  380. flag: this.isactiveTab === 'todayRank' ? 1 : 0
  381. }
  382. leaderboard(postData).then(res => {
  383. if (res.data.length > 0) {
  384. that.$set(that, "rankList", res.data)
  385. } else {
  386. that.$set(that, "rankList", [])
  387. }
  388. uni.hideLoading();
  389. })
  390. },
  391. doGrab () {
  392. doGrab({
  393. type: this.activeRedPer.type
  394. }).then(res => {
  395. // if (res.code === 200) {
  396. // this.grabFlag('dograbAmountFlag')
  397. // }
  398. this.currentRedpaper = res.data
  399. this.grabAmountFlag = true
  400. this.grabFlag('dograbAmountFlag')
  401. })
  402. },
  403. grabFlag (params) {
  404. grabFlag().then(res => {
  405. this.redPaper = res.data
  406. if (!params) {
  407. this.grabAmountFlag = false
  408. }
  409. if (params === 'created') {
  410. this.activeRedPer = res.data[0]
  411. let flag = this.redPaper.filter((e) => {
  412. return e.flag === 1;
  413. }).length
  414. console.log(flag,this.activeRedPer);
  415. if (flag === 0) {
  416. this.show = false
  417. uni.stopPullDownRefresh();
  418. return
  419. }
  420. }
  421. this.show = true
  422. uni.stopPullDownRefresh();
  423. })
  424. },
  425. todayStatistics () {
  426. uni.showLoading({
  427. title: this.$t(`加载中`),
  428. mask: true
  429. });
  430. let postData = {
  431. flag: this.isactiveTab === 'todayRank' ? 1 : 0
  432. }
  433. todayStatistics().then(res => {
  434. this.moneyObj = res.data
  435. uni.hideLoading();
  436. })
  437. },
  438. /**
  439. * 属性变动赋值
  440. *
  441. */
  442. ChangeAttr: function (res) {
  443. let productSelect = this.productValue[res];
  444. if (productSelect && productSelect.stock > 0) {
  445. this.$set(this.attr.productSelect, "image", productSelect.image);
  446. this.$set(this.attr.productSelect, "price", productSelect.price);
  447. this.$set(this.attr.productSelect, "stock", productSelect.stock);
  448. this.$set(this.attr.productSelect, "unique", productSelect.unique);
  449. this.$set(this.attr.productSelect, "cart_num", 1);
  450. this.$set(this, "attrValue", res);
  451. this.$set(this, "attrTxt", this.$t(`已选择`));
  452. } else {
  453. this.$set(this.attr.productSelect, "image", this.storeInfo.image);
  454. this.$set(this.attr.productSelect, "price", this.storeInfo.price);
  455. this.$set(this.attr.productSelect, "stock", 0);
  456. this.$set(this.attr.productSelect, "unique", "");
  457. this.$set(this.attr.productSelect, "cart_num", 0);
  458. this.$set(this, "attrValue", "");
  459. this.$set(this, "attrTxt", this.$t(`请选择`));
  460. }
  461. },
  462. /**
  463. * 默认选中属性
  464. *
  465. */
  466. DefaultSelect: function () {
  467. let productAttr = this.attr.productAttr;
  468. let value = [];
  469. for (var key in this.productValue) {
  470. if (this.productValue[key].stock > 0) {
  471. value = this.attr.productAttr.length ? key.split(",") : [];
  472. break;
  473. }
  474. }
  475. for (let i = 0; i < productAttr.length; i++) {
  476. this.$set(productAttr[i], "index", value[i]);
  477. }
  478. //sort();排序函数:数字-英文-汉字;
  479. let productSelect = this.productValue[value.sort().join(",")];
  480. if (productSelect && productAttr.length) {
  481. this.$set(
  482. this.attr.productSelect,
  483. "store_name",
  484. this.storeInfo.store_name
  485. );
  486. this.$set(this.attr.productSelect, "image", productSelect.image);
  487. this.$set(this.attr.productSelect, "price", productSelect.price);
  488. this.$set(this.attr.productSelect, "stock", productSelect.stock);
  489. this.$set(this.attr.productSelect, "unique", productSelect.unique);
  490. this.$set(this.attr.productSelect, "cart_num", 1);
  491. this.$set(this, "attrValue", value.sort().join(","));
  492. this.$set(this, "attrTxt", this.$t(`已选择`));
  493. } else if (!productSelect && productAttr.length) {
  494. this.$set(
  495. this.attr.productSelect,
  496. "store_name",
  497. this.storeInfo.store_name
  498. );
  499. this.$set(this.attr.productSelect, "image", this.storeInfo.image);
  500. this.$set(this.attr.productSelect, "price", this.storeInfo.price);
  501. this.$set(this.attr.productSelect, "stock", 0);
  502. this.$set(this.attr.productSelect, "unique", "");
  503. this.$set(this.attr.productSelect, "cart_num", 0);
  504. this.$set(this, "attrValue", "");
  505. this.$set(this, "attrTxt", this.$t(`请选择`));
  506. } else if (!productSelect && !productAttr.length) {
  507. this.$set(
  508. this.attr.productSelect,
  509. "store_name",
  510. this.storeInfo.store_name
  511. );
  512. this.$set(this.attr.productSelect, "image", this.storeInfo.image);
  513. this.$set(this.attr.productSelect, "price", this.storeInfo.price);
  514. this.$set(this.attr.productSelect, "stock", this.storeInfo.stock);
  515. this.$set(
  516. this.attr.productSelect,
  517. "unique",
  518. this.storeInfo.unique || ""
  519. );
  520. this.$set(this.attr.productSelect, "cart_num", 1);
  521. this.$set(this, "attrValue", "");
  522. this.$set(this, "attrTxt", this.$t(`请选择`));
  523. }
  524. },
  525. attrVal (val) {
  526. this.$set(this.attr.productAttr[val.indexw], 'index', this.attr.productAttr[val.indexw].attr_values[val
  527. .indexn]);
  528. },
  529. /**
  530. * 购物车数量加和数量减
  531. *
  532. */
  533. ChangeCartNum: function (changeValue) {
  534. //changeValue:是否 加|减
  535. //获取当前变动属性
  536. let productSelect = this.productValue[this.attrValue];
  537. //如果没有属性,赋值给商品默认库存
  538. if (productSelect === undefined && !this.attr.productAttr.length)
  539. productSelect = this.attr.productSelect;
  540. //无属性值即库存为0;不存在加减;
  541. if (productSelect === undefined) return;
  542. let stock = productSelect.stock || 0;
  543. let num = this.attr.productSelect;
  544. if (changeValue) {
  545. num.cart_num++;
  546. if (num.cart_num > stock) {
  547. this.$set(this.attr.productSelect, "cart_num", stock ? stock : 1);
  548. this.$set(this, "cart_num", stock ? stock : 1);
  549. }
  550. } else {
  551. num.cart_num--;
  552. if (num.cart_num < 1) {
  553. this.$set(this.attr.productSelect, "cart_num", 1);
  554. this.$set(this, "cart_num", 1);
  555. }
  556. }
  557. },
  558. /**
  559. * 购物车手动填写
  560. *
  561. */
  562. iptCartNum: function (e) {
  563. this.$set(this.attr.productSelect, 'cart_num', e);
  564. },
  565. subDel: function (event) {
  566. let that = this,
  567. selectValue = that.selectValue;
  568. if (selectValue.length > 0)
  569. cartDel(selectValue).then(res => {
  570. that.loadend = false;
  571. that.page = 1;
  572. that.cartList.valid = [];
  573. that.getCartList();
  574. that.getCartNum();
  575. });
  576. else
  577. return that.$util.Tips({
  578. title: that.$t(`请选择产品`)
  579. });
  580. },
  581. getSelectValueProductId: function () {
  582. let that = this;
  583. let validList = that.cartList.valid;
  584. let selectValue = that.selectValue;
  585. let productId = [];
  586. if (selectValue.length > 0) {
  587. for (let index in validList) {
  588. if (that.inArray(validList[index].id, selectValue)) {
  589. productId.push(validList[index].product_id);
  590. }
  591. }
  592. };
  593. return productId;
  594. },
  595. subCollect: function (event) {
  596. let that = this,
  597. selectValue = that.selectValue;
  598. if (selectValue.length > 0) {
  599. let selectValueProductId = that.getSelectValueProductId();
  600. collectAll(that.getSelectValueProductId().join(',')).then(res => {
  601. return that.$util.Tips({
  602. title: res.msg,
  603. icon: 'success'
  604. });
  605. }).catch(err => {
  606. return that.$util.Tips({
  607. title: err
  608. });
  609. });
  610. } else {
  611. return that.$util.Tips({
  612. title: that.$t(`请选择产品`)
  613. });
  614. }
  615. },
  616. subOrder (event) {
  617. console.log(event)
  618. let that = this,
  619. selectValue = that.selectValue;
  620. if (selectValue.length > 0) {
  621. uni.navigateTo({
  622. url: '/pages/goods/order_confirm/index?cartId=' + selectValue.join(',')
  623. });
  624. } else {
  625. return that.$util.Tips({
  626. title: that.$t(`请选择产品`)
  627. });
  628. }
  629. },
  630. checkboxAllChange: function (event) {
  631. let value = event.detail.value;
  632. if (value.length > 0) {
  633. this.setAllSelectValue(1)
  634. } else {
  635. this.setAllSelectValue(0)
  636. }
  637. },
  638. setAllSelectValue: function (status) {
  639. let that = this;
  640. let selectValue = [];
  641. let valid = that.cartList.valid;
  642. if (valid.length > 0) {
  643. let newValid = valid.map(item => {
  644. if (status) {
  645. if (that.footerswitch) {
  646. if (item.attrStatus) {
  647. item.checked = true;
  648. selectValue.push(item.id);
  649. } else {
  650. item.checked = false;
  651. }
  652. } else {
  653. item.checked = true;
  654. selectValue.push(item.id);
  655. }
  656. that.isAllSelect = true;
  657. } else {
  658. item.checked = false;
  659. that.isAllSelect = false;
  660. }
  661. return item;
  662. });
  663. that.$set(that.cartList, 'valid', newValid);
  664. that.selectValue = selectValue;
  665. that.switchSelect();
  666. }
  667. },
  668. checkboxChange: function (event) {
  669. let that = this;
  670. let value = event.detail.value;
  671. let valid = that.cartList.valid;
  672. let arr1 = [];
  673. let arr2 = [];
  674. let arr3 = [];
  675. let newValid = valid.map(item => {
  676. if (that.inArray(item.id, value)) {
  677. if (that.footerswitch) {
  678. if (item.attrStatus) {
  679. item.checked = true;
  680. arr1.push(item);
  681. } else {
  682. item.checked = false;
  683. }
  684. } else {
  685. item.checked = true;
  686. arr1.push(item);
  687. }
  688. } else {
  689. item.checked = false;
  690. arr2.push(item);
  691. }
  692. return item;
  693. });
  694. if (that.footerswitch) {
  695. arr3 = arr2.filter(item => !item.attrStatus);
  696. }
  697. // for (let index in valid) {
  698. // if (that.inArray(valid[index].id, value)){
  699. // if(valid[index].attrStatus){
  700. // valid[index].checked = true;
  701. // }else{
  702. // valid[index].checked = false;
  703. // }
  704. // } else {
  705. // valid[index].checked = false;
  706. // }
  707. // }
  708. that.$set(that.cartList, 'valid', newValid);
  709. // let newArr = that.cartList.valid.filter(item => item.attrStatus);
  710. that.isAllSelect = newValid.length === arr1.length + arr3.length;
  711. that.selectValue = value;
  712. that.switchSelect();
  713. },
  714. inArray: function (search, array) {
  715. for (let i in array) {
  716. if (array[i] == search) {
  717. return true;
  718. }
  719. }
  720. return false;
  721. },
  722. switchSelect: function () {
  723. let that = this;
  724. let validList = that.cartList.valid;
  725. let selectValue = that.selectValue;
  726. let selectCountPrice = 0.00;
  727. if (selectValue.length < 1) {
  728. that.selectCountPrice = selectCountPrice;
  729. } else {
  730. for (let index in validList) {
  731. if (that.inArray(validList[index].id, selectValue)) {
  732. selectCountPrice = that.$util.$h.Add(selectCountPrice, that.$util.$h.Mul(validList[index]
  733. .cart_num, validList[
  734. index].truePrice))
  735. }
  736. }
  737. that.selectCountPrice = selectCountPrice;
  738. }
  739. },
  740. /**
  741. * 购物车手动填写
  742. *
  743. */
  744. iptCartNum: function (index) {
  745. let item = this.cartList.valid[index];
  746. if (item.cart_num) {
  747. this.setCartNum(item.id, item.cart_num);
  748. }
  749. this.switchSelect();
  750. },
  751. blurInput: function (index) {
  752. let item = this.cartList.valid[index];
  753. console.log(item)
  754. if (!item.cart_num) {
  755. item.cart_num = 1;
  756. this.$set(this.cartList, 'valid', this.cartList.valid)
  757. }
  758. },
  759. subCart: function (index) {
  760. let that = this;
  761. let status = false;
  762. let item = that.cartList.valid[index];
  763. item.cart_num = Number(item.cart_num) - 1;
  764. if (item.cart_num < 1) status = true;
  765. if (item.cart_num <= 1) {
  766. item.cart_num = 1;
  767. item.numSub = true;
  768. } else {
  769. item.numSub = false;
  770. item.numAdd = false;
  771. }
  772. if (false == status) {
  773. that.setCartNum(item.id, item.cart_num, function (data) {
  774. that.cartList.valid[index] = item;
  775. that.getCartNum();
  776. that.switchSelect();
  777. });
  778. }
  779. },
  780. addCart: function (index) {
  781. let that = this;
  782. let item = that.cartList.valid[index];
  783. item.cart_num = Number(item.cart_num) + 1;
  784. let productInfo = item.productInfo;
  785. if (productInfo.hasOwnProperty('attrInfo') && item.cart_num >= item.productInfo.attrInfo.stock) {
  786. item.cart_num = item.productInfo.attrInfo.stock;
  787. item.numAdd = true;
  788. item.numSub = false;
  789. } else {
  790. item.numAdd = false;
  791. item.numSub = false;
  792. }
  793. that.setCartNum(item.id, item.cart_num, function (data) {
  794. that.cartList.valid[index] = item;
  795. that.getCartNum();
  796. that.switchSelect();
  797. });
  798. },
  799. setCartNum (cartId, cartNum, successCallback) {
  800. let that = this;
  801. changeCartNum(cartId, cartNum).then(res => {
  802. console.log(res)
  803. successCallback && successCallback(res.data);
  804. }).catch(err => {
  805. console.log(err)
  806. return that.$util.Tips({
  807. title: err
  808. });
  809. })
  810. },
  811. getCartNum: function () {
  812. let that = this;
  813. // getCartCounts().then(res => {
  814. that.cartCount = 0;
  815. this.$store.commit('indexData/setCartNum', that.cartCount > 99 ? '..' : that.cartCount)
  816. if (that.cartCount > 0) {
  817. wx.setTabBarBadge({
  818. index: 2,
  819. text: that.cartCount + ''
  820. })
  821. } else {
  822. wx.hideTabBarRedDot({
  823. index: 2
  824. })
  825. }
  826. // });
  827. },
  828. getCartData (data) {
  829. let resData = {
  830. "valid": [],
  831. "invalid": [],
  832. "deduction": {
  833. "seckill_id": 0,
  834. "bargain_id": 0,
  835. "combination_id": 0,
  836. "discount_id": 0
  837. }
  838. }
  839. this.loading = false;
  840. this.canShow = true
  841. return resData;
  842. // return new Promise((resolve, reject) => {
  843. // getCartList(data).then((res) => {
  844. // resolve(res.data);
  845. // }).catch((err) => {
  846. // this.loading = false;
  847. // this.canShow = true
  848. // this.$util.Tips({
  849. // title: err
  850. // });
  851. // })
  852. // });
  853. },
  854. async getCartList () {
  855. uni.showLoading({
  856. title: this.$t(`加载中`),
  857. mask: true
  858. });
  859. let that = this;
  860. let data = {
  861. page: that.page,
  862. limit: that.limit,
  863. status: 1
  864. }
  865. let countResData = {
  866. "count": 0,
  867. "ids": [
  868. 9671,
  869. 9670,
  870. 9669
  871. ],
  872. "sum_price": "955.00"
  873. }
  874. // getCartCounts().then(async c => {
  875. that.cartCount = countResData.count;
  876. let n = Math.ceil(countResData.ids.length / that.limit)
  877. for (let i = 0; i < n; i++) {
  878. // let cartList = await this.getCartData(data)
  879. let cartListData = {
  880. "valid": [{
  881. "id": 9671,
  882. "uid": 34391,
  883. "type": "0",
  884. "product_id": 97,
  885. "product_attr_unique": "fd6d98f3",
  886. "cart_num": 1,
  887. "add_time": 1666709939,
  888. "is_pay": 0,
  889. "is_del": 0,
  890. "is_new": 0,
  891. "combination_id": 0,
  892. "seckill_id": 0,
  893. "bargain_id": 0,
  894. "advance_id": 0,
  895. "status": 1,
  896. "productInfo": {
  897. "id": 97,
  898. "mer_id": 0,
  899. "image": "https://demo26.crmeb.net/uploads/attach/2021/11/20211113/small_0d407b8541efd8c8f87e5ac581d1421c.png",
  900. "recommend_image": "",
  901. "slider_image": [
  902. "https://demo26.crmeb.net/uploads/attach/2021/11/13/2d97c9bd7abcdb65049c97bbe9ba61d1.jpg",
  903. "https://demo26.crmeb.net/uploads/attach/2021/11/13/a48cce02122f4046193bdda67d970b55.jpg",
  904. "https://demo26.crmeb.net/uploads/attach/2021/11/13/5c4754f2b647b9e240e08f48c9889ebf.jpg",
  905. "https://demo26.crmeb.net/uploads/attach/2021/11/13/e8f6b1235f10f83d8a43bd91def20332.jpg",
  906. "https://demo26.crmeb.net/uploads/attach/2021/11/13/634a51ad34590eab005063742d086b87.jpg"
  907. ],
  908. "store_name": "仟佰家 干花花束真花手工落地高枝装饰摆件招财莲蓬插花居客厅摆设 干花组合6025【不含花瓶】 干花包",
  909. "store_info": "仟佰家 干花花束真花手工落地高枝装饰摆件招财莲蓬插花居客厅摆设 干花组合6025【不含花瓶】 干花包",
  910. "keyword": "",
  911. "bar_code": "",
  912. "cate_id": "22,24",
  913. "price": "306.00",
  914. "vip_price": "0.00",
  915. "ot_price": "299.00",
  916. "postage": "0.00",
  917. "unit_name": "件",
  918. "sort": 100,
  919. "sales": 2,
  920. "stock": 12384,
  921. "is_show": 1,
  922. "is_hot": 0,
  923. "is_benefit": 0,
  924. "is_best": 0,
  925. "is_new": 1,
  926. "is_virtual": 0,
  927. "virtual_type": 0,
  928. "add_time": 1636791973,
  929. "is_postage": 0,
  930. "is_del": 0,
  931. "mer_use": 0,
  932. "give_integral": "0.00",
  933. "cost": "258.00",
  934. "is_seckill": 0,
  935. "is_bargain": null,
  936. "is_good": 0,
  937. "is_sub": 0,
  938. "is_vip": 0,
  939. "ficti": 0,
  940. "browse": 0,
  941. "code_path": "",
  942. "soure_link": "",
  943. "temp_id": 57,
  944. "spec_type": 1,
  945. "activity": "0,1,2,3",
  946. "spu": "5310153503736",
  947. "label_id": "0",
  948. "video_link": "",
  949. "command_word": "",
  950. "recommend_list": "",
  951. "vip_product": 0,
  952. "presale": 0,
  953. "presale_start_time": 0,
  954. "presale_end_time": 0,
  955. "presale_day": 0,
  956. "logistics": "1,2",
  957. "freight": 2,
  958. "custom_form": "",
  959. "is_limit": 0,
  960. "limit_type": 0,
  961. "limit_num": 0,
  962. "express_delivery": true,
  963. "store_mention": true,
  964. "attrInfo": {
  965. "id": 967,
  966. "product_id": 97,
  967. "suk": "干花组合6025【不含花瓶】,干花包",
  968. "stock": 562,
  969. "sales": 1,
  970. "price": "306.00",
  971. "image": "https://demo26.crmeb.net/uploads/attach/2021/11/13/small_634a51ad34590eab005063742d086b87.jpg",
  972. "bar_code": "",
  973. "ot_price": "299.00",
  974. "volume": "0.00",
  975. "weight": "0.00",
  976. "brokerage": "0.00",
  977. "brokerage_two": "0.00",
  978. "type": 0,
  979. "unique": "fd6d98f3",
  980. "cost": "258.00",
  981. "quota": 0,
  982. "quota_show": 0,
  983. "vip_price": "0.00",
  984. "is_virtual": 0,
  985. "coupon_id": 0,
  986. "disk_info": ""
  987. }
  988. },
  989. "attrStatus": true,
  990. "vip_truePrice": 0,
  991. "costPrice": "258.00",
  992. "trueStock": 562,
  993. "truePrice": 306,
  994. "sum_price": "306.00",
  995. "price_type": "level",
  996. "is_valid": 1
  997. },
  998. {
  999. "id": 9670,
  1000. "uid": 34391,
  1001. "type": "0",
  1002. "product_id": 102,
  1003. "product_attr_unique": "02cce37e",
  1004. "cart_num": 1,
  1005. "add_time": 1666709927,
  1006. "is_pay": 0,
  1007. "is_del": 0,
  1008. "is_new": 0,
  1009. "combination_id": 0,
  1010. "seckill_id": 0,
  1011. "bargain_id": 0,
  1012. "advance_id": 0,
  1013. "status": 1,
  1014. "productInfo": {
  1015. "id": 102,
  1016. "mer_id": 0,
  1017. "image": "https://demo26.crmeb.net/uploads/attach/2021/11/15/small_a79f5d2ea6bf0c3c11b2127332dfe2df.jpg",
  1018. "recommend_image": "",
  1019. "slider_image": [
  1020. "https://demo26.crmeb.net/uploads/attach/2021/11/15/a79f5d2ea6bf0c3c11b2127332dfe2df.jpg",
  1021. "https://demo26.crmeb.net/uploads/attach/2021/11/15/7f46e98ece1920e1a4082dfc72bcd72a.jpg",
  1022. "https://demo26.crmeb.net/uploads/attach/2021/11/15/bfb275263d02ab081b8670a752f2823f.jpg",
  1023. "https://demo26.crmeb.net/uploads/attach/2021/11/15/e499a4dc489cda7b8d472cb3a3b348b7.jpg",
  1024. "https://demo26.crmeb.net/uploads/attach/2021/11/15/06fa150a47163e973bb4806a380afaab.jpg"
  1025. ],
  1026. "store_name": "索尼(SONY)WH-CH510 无线立体声耳机 学生网课 白色",
  1027. "store_info": "索尼(SONY)WH-CH510 无线立体声耳机 学生网课 白色",
  1028. "keyword": "耳机",
  1029. "bar_code": "",
  1030. "cate_id": "18,27,25",
  1031. "price": "299.00",
  1032. "vip_price": "0.00",
  1033. "ot_price": "349.00",
  1034. "postage": "0.00",
  1035. "unit_name": "件",
  1036. "sort": 0,
  1037. "sales": 3,
  1038. "stock": 297,
  1039. "is_show": 1,
  1040. "is_hot": 0,
  1041. "is_benefit": 0,
  1042. "is_best": 0,
  1043. "is_new": 0,
  1044. "is_virtual": 0,
  1045. "virtual_type": 0,
  1046. "add_time": 1636958921,
  1047. "is_postage": 0,
  1048. "is_del": 0,
  1049. "mer_use": 0,
  1050. "give_integral": "0.00",
  1051. "cost": "259.00",
  1052. "is_seckill": 0,
  1053. "is_bargain": null,
  1054. "is_good": 0,
  1055. "is_sub": 0,
  1056. "is_vip": 0,
  1057. "ficti": 0,
  1058. "browse": 0,
  1059. "code_path": "",
  1060. "soure_link": "",
  1061. "temp_id": 57,
  1062. "spec_type": 1,
  1063. "activity": "0,1,2,3",
  1064. "spu": "5757529716664",
  1065. "label_id": "0",
  1066. "video_link": "",
  1067. "command_word": "",
  1068. "recommend_list": "",
  1069. "vip_product": 0,
  1070. "presale": 0,
  1071. "presale_start_time": 0,
  1072. "presale_end_time": 0,
  1073. "presale_day": 0,
  1074. "logistics": "1,2",
  1075. "freight": 2,
  1076. "custom_form": "",
  1077. "is_limit": 0,
  1078. "limit_type": 0,
  1079. "limit_num": 0,
  1080. "express_delivery": true,
  1081. "store_mention": true,
  1082. "attrInfo": {
  1083. "id": 9,
  1084. "product_id": 102,
  1085. "suk": "黑色,CH510",
  1086. "stock": 98,
  1087. "sales": 2,
  1088. "price": "299.00",
  1089. "image": "https://demo26.crmeb.net/uploads/attach/2021/11/15/small_a79f5d2ea6bf0c3c11b2127332dfe2df.jpg",
  1090. "bar_code": "",
  1091. "ot_price": "349.00",
  1092. "volume": "0.00",
  1093. "weight": "0.00",
  1094. "brokerage": "0.00",
  1095. "brokerage_two": "0.00",
  1096. "type": 0,
  1097. "unique": "02cce37e",
  1098. "cost": "259.00",
  1099. "quota": 0,
  1100. "quota_show": 0,
  1101. "vip_price": "0.00",
  1102. "is_virtual": 0,
  1103. "coupon_id": 0,
  1104. "disk_info": ""
  1105. }
  1106. },
  1107. "attrStatus": true,
  1108. "vip_truePrice": 0,
  1109. "costPrice": "259.00",
  1110. "trueStock": 98,
  1111. "truePrice": 299,
  1112. "sum_price": "299.00",
  1113. "price_type": "level",
  1114. "is_valid": 1
  1115. },
  1116. {
  1117. "id": 9669,
  1118. "uid": 34391,
  1119. "type": "0",
  1120. "product_id": 89,
  1121. "product_attr_unique": "89807c67",
  1122. "cart_num": 1,
  1123. "add_time": 1666709911,
  1124. "is_pay": 0,
  1125. "is_del": 0,
  1126. "is_new": 0,
  1127. "combination_id": 0,
  1128. "seckill_id": 0,
  1129. "bargain_id": 0,
  1130. "advance_id": 0,
  1131. "status": 1,
  1132. "productInfo": {
  1133. "id": 89,
  1134. "mer_id": 0,
  1135. "image": "https://demo26.crmeb.net/uploads/attach/2021/11/20211113/small_2fbe723632427b0768df24c4f23c6cad.png",
  1136. "recommend_image": "",
  1137. "slider_image": [
  1138. "https://demo26.crmeb.net/uploads/attach/2021/11/20211113/2fbe723632427b0768df24c4f23c6cad.png",
  1139. "https://demo26.crmeb.net/uploads/attach/2021/11/20211113/64d188477292aa4ae2df8da7e63aca79.png"
  1140. ],
  1141. "store_name": "家居梵高系列联名款饭盒袋大容量手拎保温实用方便 星月夜饭盒袋",
  1142. "store_info": "",
  1143. "keyword": "家居梵高系列联名款饭盒袋大容量手拎保温实用方便 星月夜饭盒袋",
  1144. "bar_code": "",
  1145. "cate_id": "35",
  1146. "price": "350.00",
  1147. "vip_price": "0.00",
  1148. "ot_price": "300.00",
  1149. "postage": "0.00",
  1150. "unit_name": "件",
  1151. "sort": 553,
  1152. "sales": 19,
  1153. "stock": 185,
  1154. "is_show": 1,
  1155. "is_hot": 1,
  1156. "is_benefit": 0,
  1157. "is_best": 0,
  1158. "is_new": 0,
  1159. "is_virtual": 0,
  1160. "virtual_type": 0,
  1161. "add_time": 1636777038,
  1162. "is_postage": 0,
  1163. "is_del": 0,
  1164. "mer_use": 0,
  1165. "give_integral": "0.00",
  1166. "cost": "300.00",
  1167. "is_seckill": 0,
  1168. "is_bargain": null,
  1169. "is_good": 1,
  1170. "is_sub": 0,
  1171. "is_vip": 0,
  1172. "ficti": 0,
  1173. "browse": 0,
  1174. "code_path": "",
  1175. "soure_link": "",
  1176. "temp_id": 0,
  1177. "spec_type": 1,
  1178. "activity": "0,1,2,3",
  1179. "spu": "1015710267816",
  1180. "label_id": "",
  1181. "video_link": "",
  1182. "command_word": "",
  1183. "recommend_list": "",
  1184. "vip_product": 0,
  1185. "presale": 0,
  1186. "presale_start_time": 0,
  1187. "presale_end_time": 0,
  1188. "presale_day": 0,
  1189. "logistics": "1,2",
  1190. "freight": 2,
  1191. "custom_form": "[]",
  1192. "is_limit": 0,
  1193. "limit_type": 0,
  1194. "limit_num": 0,
  1195. "express_delivery": true,
  1196. "store_mention": true,
  1197. "attrInfo": {
  1198. "id": 1017,
  1199. "product_id": 89,
  1200. "suk": "梵高自画像饭盒",
  1201. "stock": 88,
  1202. "sales": 8,
  1203. "price": "350.00",
  1204. "image": "https://demo26.crmeb.net/uploads/attach/2021/11/20211113/small_2fbe723632427b0768df24c4f23c6cad.png",
  1205. "bar_code": "",
  1206. "ot_price": "300.00",
  1207. "volume": "0.00",
  1208. "weight": "0.00",
  1209. "brokerage": "0.00",
  1210. "brokerage_two": "0.00",
  1211. "type": 0,
  1212. "unique": "89807c67",
  1213. "cost": "300.00",
  1214. "quota": 0,
  1215. "quota_show": 0,
  1216. "vip_price": "0.00",
  1217. "is_virtual": 0,
  1218. "coupon_id": 0,
  1219. "disk_info": ""
  1220. }
  1221. },
  1222. "attrStatus": true,
  1223. "vip_truePrice": 0,
  1224. "costPrice": "300.00",
  1225. "trueStock": 88,
  1226. "truePrice": 350,
  1227. "sum_price": "350.00",
  1228. "price_type": "level",
  1229. "is_valid": 1
  1230. }
  1231. ],
  1232. "invalid": [],
  1233. "deduction": {
  1234. "seckill_id": 0,
  1235. "bargain_id": 0,
  1236. "combination_id": 0,
  1237. "discount_id": 0
  1238. }
  1239. }
  1240. let cartList = cartListData
  1241. let valid = cartList.valid
  1242. let validList = that.$util.SplitArray(valid, that.cartList.valid);
  1243. let numSub = [{
  1244. numSub: true
  1245. }, {
  1246. numSub: false
  1247. }];
  1248. let numAdd = [{
  1249. numAdd: true
  1250. }, {
  1251. numAdd: false
  1252. }],
  1253. selectValue = [];
  1254. if (validList.length > 0) {
  1255. for (let index in validList) {
  1256. if (validList[index].cart_num == 1) {
  1257. validList[index].numSub = true;
  1258. } else {
  1259. validList[index].numSub = false;
  1260. }
  1261. let productInfo = validList[index].productInfo;
  1262. if (productInfo.hasOwnProperty('attrInfo') && validList[index].cart_num ==
  1263. validList[index].productInfo.attrInfo
  1264. .stock) {
  1265. validList[index].numAdd = true;
  1266. } else if (validList[index].cart_num == validList[index].productInfo
  1267. .stock) {
  1268. validList[index].numAdd = true;
  1269. } else {
  1270. validList[index].numAdd = false;
  1271. }
  1272. if (validList[index].attrStatus) {
  1273. validList[index].checked = true;
  1274. selectValue.push(validList[index].id);
  1275. } else {
  1276. validList[index].checked = false;
  1277. }
  1278. }
  1279. }
  1280. that.$set(that.cartList, 'valid', validList);
  1281. data.page = that.page + 1;
  1282. // that.goodsHidden = cartList.valid.length <= 0 ? false : true;
  1283. that.selectValue = selectValue;
  1284. let newArr = validList.filter(item => item.attrStatus);
  1285. that.isAllSelect = newArr.length == selectValue.length && newArr.length;
  1286. that.switchSelect();
  1287. }
  1288. that.loading = false;
  1289. this.canShow = true
  1290. uni.hideLoading();
  1291. // });
  1292. },
  1293. getInvalidList: function () {
  1294. let that = this;
  1295. if (this.loadendInvalid) return false;
  1296. if (this.loadingInvalid) return false;
  1297. let data = {
  1298. page: that.pageInvalid,
  1299. limit: that.limitInvalid,
  1300. status: 0
  1301. }
  1302. let resData = {
  1303. "valid": [],
  1304. "invalid": [],
  1305. "deduction": {
  1306. "seckill_id": 0,
  1307. "bargain_id": 0,
  1308. "combination_id": 0,
  1309. "discount_id": 0
  1310. }
  1311. }
  1312. // getCartList(data).then(res => {
  1313. let cartList = resData,
  1314. invalid = cartList.invalid,
  1315. loadendInvalid = invalid.length < that.limitInvalid;
  1316. let invalidList = that.$util.SplitArray(invalid, that.cartList.invalid);
  1317. that.$set(that.cartList, 'invalid', invalidList);
  1318. that.loadendInvalid = loadendInvalid;
  1319. that.loadTitleInvalid = loadendInvalid ? that.$t(`我也是有底线的`) : that.$t(`加载更多`);
  1320. that.pageInvalid = that.pageInvalid + 1;
  1321. that.loadingInvalid = false;
  1322. // }).catch(res => {
  1323. // that.loadingInvalid = false;
  1324. // that.loadTitleInvalid = that.$t(`加载更多`);
  1325. // })
  1326. },
  1327. getHostProduct: function () {
  1328. let that = this;
  1329. if (that.hotScroll) return
  1330. that.hotPage++
  1331. that.hotScroll = hot_res.length < that.hotLimit
  1332. that.hostProduct = that.hostProduct.concat(hot_res)
  1333. // getProductHot(
  1334. // that.hotPage,
  1335. // that.hotLimit,
  1336. // ).then(res => {
  1337. // that.hotPage++
  1338. // that.hotScroll = res.data.length < that.hotLimit
  1339. // that.hostProduct = that.hostProduct.concat(res.data)
  1340. // });
  1341. },
  1342. goodsOpen: function () {
  1343. let that = this;
  1344. that.goodsHidden = !that.goodsHidden;
  1345. },
  1346. goRouter (item) {
  1347. var pages = getCurrentPages();
  1348. var page = (pages[pages.length - 1]).$page.fullPath;
  1349. if (item.link == page) return
  1350. uni.switchTab({
  1351. url: item.link,
  1352. fail (err) {
  1353. uni.redirectTo({
  1354. url: item.link
  1355. })
  1356. }
  1357. })
  1358. },
  1359. manage: function () {
  1360. let that = this;
  1361. that.footerswitch = !that.footerswitch;
  1362. let arr1 = [];
  1363. let arr2 = [];
  1364. let newValid = that.cartList.valid.map(item => {
  1365. if (that.footerswitch) {
  1366. if (item.attrStatus) {
  1367. if (item.checked) {
  1368. arr1.push(item.id);
  1369. }
  1370. } else {
  1371. item.checked = false;
  1372. arr2.push(item);
  1373. }
  1374. } else {
  1375. if (item.checked) {
  1376. arr1.push(item.id);
  1377. }
  1378. }
  1379. return item;
  1380. });
  1381. that.cartList.valid = newValid;
  1382. if (that.footerswitch) {
  1383. that.isAllSelect = newValid.length === arr1.length + arr2.length;
  1384. } else {
  1385. that.isAllSelect = newValid.length === arr1.length;
  1386. }
  1387. that.selectValue = arr1;
  1388. that.switchSelect();
  1389. },
  1390. unsetCart: function () {
  1391. let that = this,
  1392. ids = [];
  1393. for (let i = 0, len = that.cartList.invalid.length; i < len; i++) {
  1394. ids.push(that.cartList.invalid[i].id);
  1395. }
  1396. cartDel(ids).then(res => {
  1397. that.$util.Tips({
  1398. title: that.$t(`清除成功`)
  1399. });
  1400. that.$set(that.cartList, 'invalid', []);
  1401. that.getCartNum();
  1402. }).catch(res => {
  1403. });
  1404. }
  1405. },
  1406. onReachBottom () {
  1407. let that = this;
  1408. if (that.loadend) {
  1409. that.getInvalidList();
  1410. }
  1411. if (that.cartList.valid.length == 0 && that.cartList.invalid.length == 0) {
  1412. that.getHostProduct();
  1413. }
  1414. }
  1415. }
  1416. </script>
  1417. <style scoped lang="scss">
  1418. .order_addcart {
  1419. padding: 20rpx;
  1420. }
  1421. .rank-list {
  1422. background: white;
  1423. margin-top: 20rpx;
  1424. padding-top: 20rpx;
  1425. padding-bottom: 10rpx;
  1426. height: 600rpx;
  1427. overflow: auto;
  1428. .rank-list-item {
  1429. margin: 20rpx;
  1430. margin-bottom: 40rpx;
  1431. width: calc(100% - 40rpx);
  1432. height: 50rpx;
  1433. display: flex;
  1434. image {
  1435. width: 50rpx;
  1436. height: 50rpx;
  1437. margin-right: 20rpx;
  1438. margin-left: 10rpx;
  1439. }
  1440. .nuber {
  1441. font-size: 18rpx;
  1442. margin-right: 20rpx;
  1443. line-height: 0rpx;
  1444. }
  1445. .mosaic {
  1446. font-size: 18rpx;
  1447. margin-right: 20rpx;
  1448. color: #999999;
  1449. line-height: 0rpx;
  1450. }
  1451. .litem-info {
  1452. text-align: right;
  1453. flex-grow: 1;
  1454. font-size: 24rpx;
  1455. line-height: 50rpx;
  1456. margin-right: 20rpx;
  1457. color: #666666;
  1458. }
  1459. .balance {
  1460. line-height: 50rpx;
  1461. color: #eb4c63;
  1462. }
  1463. }
  1464. }
  1465. .loop {
  1466. background: url("http://wine.gzzzyd.com/wx/order_addcart/hongbaochi.png")
  1467. no-repeat;
  1468. width: 100%;
  1469. height: 250rpx;
  1470. background-size: 100% 100%;
  1471. position: relative;
  1472. .loop-title {
  1473. padding: 20rpx;
  1474. padding-left: 35rpx;
  1475. font-size: 32rpx;
  1476. }
  1477. .loop-count {
  1478. text-align: center;
  1479. line-height: 97rpx;
  1480. font-size: 48rpx;
  1481. color: #eb4c63;
  1482. width: 420rpx;
  1483. height: 97rpx;
  1484. background: #ffffff;
  1485. border-radius: 23px;
  1486. border: 1px solid #eb4c63;
  1487. position: absolute;
  1488. left: 50%;
  1489. top: 47%;
  1490. transform: translateX(-50%);
  1491. }
  1492. // image {
  1493. // width: 100%;
  1494. // }
  1495. }
  1496. .tab-area {
  1497. margin-top: 20rpx;
  1498. display: flex;
  1499. flex-wrap: nowrap;
  1500. justify-content: space-between;
  1501. line-height: 90rpx;
  1502. text-align: center;
  1503. .base-tab {
  1504. width: 48%;
  1505. height: 90rpx;
  1506. }
  1507. .tab-area-active1 {
  1508. background: url("http://wine.gzzzyd.com/wx/order_addcart/tab1.png")
  1509. no-repeat;
  1510. background-size: 340rpx 120rpx;
  1511. }
  1512. .tab-area-active2 {
  1513. background: url("http://wine.gzzzyd.com/wx/order_addcart/tab2.png")
  1514. no-repeat;
  1515. background-size: 340rpx 120rpx;
  1516. }
  1517. }
  1518. .order_addcart-header-area {
  1519. display: flex;
  1520. .received {
  1521. width: 405rpx;
  1522. height: 175rpx;
  1523. padding: 20rpx;
  1524. margin-bottom: 20rpx;
  1525. margin-right: 20rpx;
  1526. background-color: #fff;
  1527. border-radius: 20rpx;
  1528. overflow: hidden;
  1529. position: relative;
  1530. display: flex;
  1531. .pictrue {
  1532. display: flex;
  1533. align-items: center;
  1534. image {
  1535. width: 98rpx;
  1536. height: 98rpx;
  1537. }
  1538. margin-right: 20rpx;
  1539. }
  1540. .text-info {
  1541. display: flex;
  1542. flex-direction: column;
  1543. justify-content: center;
  1544. color: #6eb03a;
  1545. .received-count {
  1546. font-size: 38rpx;
  1547. margin-bottom: 10rpx;
  1548. letter-spacing: 2px;
  1549. }
  1550. .received-info {
  1551. font-size: 28rpx;
  1552. }
  1553. }
  1554. }
  1555. .loss {
  1556. flex-grow: 1;
  1557. height: 175rpx;
  1558. padding: 20rpx;
  1559. margin-bottom: 20rpx;
  1560. background-color: #fff;
  1561. border-radius: 20rpx;
  1562. overflow: hidden;
  1563. position: relative;
  1564. display: flex;
  1565. .text-info {
  1566. width: 100%;
  1567. display: flex;
  1568. flex-direction: column;
  1569. justify-content: center;
  1570. text-align: center;
  1571. color: #d08d5b;
  1572. .received-count {
  1573. font-size: 38rpx;
  1574. margin-bottom: 10rpx;
  1575. letter-spacing: 2px;
  1576. }
  1577. .received-info {
  1578. font-size: 28rpx;
  1579. }
  1580. }
  1581. }
  1582. }
  1583. .warp {
  1584. display: flex;
  1585. align-items: center;
  1586. justify-content: center;
  1587. height: 100%;
  1588. }
  1589. .rect {
  1590. position: relative;
  1591. width: 700rpx;
  1592. height: 950rpx;
  1593. background: url("http://wine.gzzzyd.com/wx/order_addcart/hongbao_bg.png")
  1594. no-repeat;
  1595. padding-top: 60rpx;
  1596. background-size: 700rpx 950rpx;
  1597. .cover-img {
  1598. margin-top: 40rpx;
  1599. position: relative;
  1600. left: 50%;
  1601. transform: translate(-50%, 0%);
  1602. width: 120rpx;
  1603. height: 120rpx;
  1604. border-radius: 50%;
  1605. overflow: hidden;
  1606. .avatar {
  1607. position: absolute;
  1608. z-index: 9999;
  1609. width: 120rpx;
  1610. height: 120rpx;
  1611. }
  1612. }
  1613. .paper_list {
  1614. display: flex;
  1615. margin: 0 auto;
  1616. justify-content: space-between;
  1617. color: rgb(244, 180, 53);
  1618. border-radius: 50rpx;
  1619. width: 80%;
  1620. font-size: 32rpx;
  1621. height: 80rpx;
  1622. line-height: 60rpx;
  1623. background: rgb(196, 40, 62);
  1624. text-align: center;
  1625. text {
  1626. flex:31%;
  1627. border-radius: 50rpx;
  1628. margin: 10rpx;
  1629. }
  1630. }
  1631. .h-info {
  1632. position: relative;
  1633. text-align: center;
  1634. padding: 10rpx;
  1635. height: 290rpx;
  1636. color: white;
  1637. .grabAmount_count {
  1638. position: relative;
  1639. left: 50%;
  1640. transform: translate(-50%, 0rpx);
  1641. width: 60%;
  1642. text-align:center;
  1643. margin-top: 80rpx;
  1644. font-size: 32rpx;
  1645. font-weight: 600;
  1646. color: rgb(244, 180, 53);
  1647. &:nth-child(1) {
  1648. font-size: 32rpx;
  1649. }
  1650. }
  1651. }
  1652. .op-img {
  1653. cursor: pointer;
  1654. position: relative;
  1655. left: 50%;
  1656. transform: translate(-50%, 0rpx);
  1657. width: 150rpx;
  1658. height: 150rpx;
  1659. }
  1660. .b-info {
  1661. font-size: 22rpx;
  1662. width: 100%;
  1663. text-align: center;
  1664. color: rgb(244, 180, 53);
  1665. margin-bottom: 30rpx;
  1666. }
  1667. .b-box {
  1668. margin: 0 auto;
  1669. color: rgb(244, 180, 53);
  1670. border-radius: 50rpx;
  1671. width: 55%;
  1672. font-size: 22rpx;
  1673. height: 40rpx;
  1674. line-height: 40rpx;
  1675. background: rgb(196, 40, 62);
  1676. text-align: center;
  1677. }
  1678. }
  1679. .acitiveRedper {
  1680. background: rgb(244, 180, 53);
  1681. border-radius: 50rpx;
  1682. color: white;
  1683. }
  1684. </style>