order_addcart.vue 48 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791
  1. <template>
  2. <view :style="colorStyle">
  3. <view class='shoppingCart copy-data' v-if="canShow">
  4. <view class='labelNav acea-row row-around row-middle'>
  5. <view class='item'><text class='iconfont icon-xuanzhong'></text>{{ $t(`100%正品保证`) }}</view>
  6. <view class='item'><text class='iconfont icon-xuanzhong'></text>{{ $t(`所有商品精挑细选`) }}</view>
  7. <view class='item'><text class='iconfont icon-xuanzhong'></text>{{ $t(`售后无忧`) }}</view>
  8. </view>
  9. <view class='nav acea-row row-between-wrapper'>
  10. <view>{{ $t(`购物数量`) }} <text class='num font-num'>{{ cartCount }}</text></view>
  11. <view v-if="cartList.valid.length > 0 || cartList.invalid.length > 0"
  12. class='administrate acea-row row-center-wrapper' @click='manage'>{{ footerswitch ? $t(`管理`) :
  13. $t(`取消`)
  14. }}
  15. </view>
  16. </view>
  17. <view v-if="(cartList.valid.length > 0 || cartList.invalid.length > 0) && canShow">
  18. <view class='list'>
  19. <checkbox-group @change="checkboxChange">
  20. <block v-for="(item, index) in cartList.valid" :key="index">
  21. <view class='item acea-row row-between-wrapper'>
  22. <!-- #ifndef MP -->
  23. <checkbox :value="(item.id).toString()" :checked="item.checked"
  24. :disabled="!item.attrStatus && footerswitch" />
  25. <!-- <checkbox :value="(item.id).toString()" :checked="item.checked" :disabled="item.attrStatus?false:true" /> -->
  26. <!-- #endif -->
  27. <!-- #ifdef MP -->
  28. <checkbox :value="item.id" :checked="item.checked"
  29. :disabled="!item.attrStatus && footerswitch" />
  30. <!-- #endif -->
  31. <navigator :url='"/pages/goods_details/index?id=" + item.product_id' hover-class='none'
  32. class='picTxt acea-row row-between-wrapper'>
  33. <view class='pictrue'>
  34. <image v-if="item.productInfo.attrInfo" :src='item.productInfo.attrInfo.image'>
  35. </image>
  36. <image v-else :src='item.productInfo.image'></image>
  37. </view>
  38. <view class='text'>
  39. <view class='line1' :class="item.attrStatus ? '' : 'reColor'">
  40. {{ item.productInfo.store_name }}
  41. </view>
  42. <view class='infor line1' v-if="item.productInfo.attrInfo">
  43. {{ $t(`属性`) }}:{{ item.productInfo.attrInfo.suk }}</view>
  44. <view class='money' v-if="item.attrStatus">{{ $t(`¥`) }}{{ item.truePrice }}
  45. </view>
  46. <view class="reElection acea-row row-between-wrapper" v-else>
  47. <view class="title">{{ $t(`请重新选择商品规格`) }}</view>
  48. <view class="reBnt cart-color acea-row row-center-wrapper"
  49. @click.stop="reElection(item)">{{ $t(`重选`) }}</view>
  50. </view>
  51. </view>
  52. <view class='carnum acea-row row-center-wrapper' v-if="item.attrStatus">
  53. <view class="reduce" :class="item.numSub ? 'on' : ''"
  54. @click.stop='subCart(index)'>-</view>
  55. <!-- <view class='num'>{{item.cart_num}}</view> -->
  56. <view class="num">
  57. <input type="number" v-model="item.cart_num" @click.stop
  58. @input="iptCartNum(index)" @blur="blurInput(index)" />
  59. </view>
  60. <view class="plus" :class="item.numAdd ? 'on' : ''"
  61. @click.stop='addCart(index)'>+</view>
  62. </view>
  63. </navigator>
  64. </view>
  65. </block>
  66. </checkbox-group>
  67. </view>
  68. <view class='invalidGoods' v-if="cartList.invalid.length > 0">
  69. <view class='goodsNav acea-row row-between-wrapper'>
  70. <view @click='goodsOpen'><text class='iconfont'
  71. :class='goodsHidden == true ? "icon-xiangxia" : "icon-xiangshang"'></text>{{ $t(`失效商品`)
  72. }}
  73. </view>
  74. <view class='del' @click='unsetCart'><text class='iconfont icon-shanchu1'></text>{{ $t(`清空`) }}
  75. </view>
  76. </view>
  77. <view class='goodsList' :hidden='goodsHidden'>
  78. <block v-for="(item, index) in cartList.invalid" :key='index'>
  79. <view class='item acea-row row-between-wrapper'>
  80. <view class='invalid'>{{ $t(`失效`) }}</view>
  81. <view class='pictrue'>
  82. <image v-if="item.productInfo.attrInfo" :src='item.productInfo.attrInfo.image'>
  83. </image>
  84. <image v-else :src='item.productInfo.image'></image>
  85. </view>
  86. <view class='text acea-row row-column-between'>
  87. <view class='line1 name'>{{ item.productInfo.store_name }}</view>
  88. <view class='infor line1' v-if="item.productInfo.attrInfo">
  89. {{ $t(`属性`) }}:{{ item.productInfo.attrInfo.suk }}</view>
  90. <view class='acea-row row-between-wrapper'>
  91. <!-- <view>¥{{item.truePrice}}</view> -->
  92. <view class='end'>{{ $t(`该商品已失效`) }}</view>
  93. </view>
  94. </view>
  95. </view>
  96. </block>
  97. </view>
  98. </view>
  99. <!-- <view class='loadingicon acea-row row-center-wrapper' v-if="cartList.valid.length&&!loadend">
  100. <text class='loading iconfont icon-jiazai' :hidden='loading==false'></text>{{loadTitle}}
  101. </view> -->
  102. <view class='loadingicon acea-row row-center-wrapper' v-if="cartList.invalid.length && loadend">
  103. <text class='loading iconfont icon-jiazai' :hidden='loadingInvalid == false'></text>{{
  104. loadTitleInvalid
  105. }}
  106. </view>
  107. </view>
  108. <view class='noCart' v-if="cartList.valid.length == 0 && cartList.invalid.length == 0 && canShow">
  109. <view class='emptyBox'>
  110. <image :src="imgHost + '/statics/images/no-thing.png'"></image>
  111. <view class="tips">{{ $t(`全选`) }}</view>
  112. </view>
  113. <recommend :hostProduct='hostProduct'></recommend>
  114. </view>
  115. <view style='height:120rpx;color: #F5F5F5;'></view>
  116. <view class='footer acea-row row-between-wrapper' v-if="cartList.valid.length > 0 && canShow"
  117. :class="is_diy && is_diy_set ? 'on' : ''">
  118. <view>
  119. <checkbox-group @change="checkboxAllChange">
  120. <checkbox value="all" :checked="!!isAllSelect" />
  121. <text class='checkAll'>{{ $t(`全选`) }}({{ selectValue.length }})</text>
  122. </checkbox-group>
  123. </view>
  124. <view class='money acea-row row-middle' v-if="footerswitch == true">
  125. <text class='font-color'>{{ $t(`¥`) }}{{ selectCountPrice }}</text>
  126. <form @submit="subOrder">
  127. <button class='placeOrder bg-color' formType="submit">{{ $t(`立即下单`) }}</button>
  128. </form>
  129. </view>
  130. <view class='button acea-row row-middle' v-else>
  131. <form @submit="subCollect">
  132. <button class='bnt cart-color' formType="submit">{{ $t(`收藏`) }}</button>
  133. </form>
  134. <form @submit="subDel">
  135. <button class='bnt' formType="submit">{{ $t(`删除`) }}</button>
  136. </form>
  137. </view>
  138. </view>
  139. </view>
  140. <productWindow :attr="attr" :isShow='1' :iSplus='1' :iScart='1' @myevent="onMyEvent" @ChangeAttr="ChangeAttr"
  141. @ChangeCartNum="ChangeCartNum" @attrVal="attrVal" @iptCartNum="iptCartNum" @goCat="reGoCat"
  142. id='product-window'></productWindow>
  143. <!-- #ifdef MP -->
  144. <!-- <authorize :isAuto="isAuto" :isShowAuth="isShowAuth" @authColse="authColse"></authorize> -->
  145. <!-- #endif -->
  146. <!-- <view class="uni-p-b-96"></view> -->
  147. <view class="uni-p-b-98"></view>
  148. <!-- <pageFooter :countNum="cartCount"></pageFooter> -->
  149. <view class="foot" v-if="is_diy && newData.status && newData.status.status">
  150. <view class="page-footer" id="target" :style="{ 'background-color': newData.bgColor.color[0].item }">
  151. <view class="foot-item" v-for="(item, index) in newData.menuList" :key="index" @click="goRouter(item)">
  152. <block v-if="item.link == activeRouter">
  153. <image :src="item.imgList[0]"></image>
  154. <view class="txt" :style="{ color: newData.activeTxtColor.color[0].item }">{{ item.name }}
  155. </view>
  156. </block>
  157. <block v-else>
  158. <image :src="item.imgList[1]"></image>
  159. <view class="txt" :style="{ color: newData.txtColor.color[0].item }">{{ item.name }}</view>
  160. </block>
  161. <div class="count-num" v-if="item.link === '/pages/order_addcart/order_addcart' && cartCount > 0">
  162. {{ cartCount }}
  163. </div>
  164. </view>
  165. </view>
  166. </view>
  167. </view>
  168. </template>
  169. <script>
  170. // #ifdef APP-PLUS
  171. let sysHeight = uni.getSystemInfoSync().statusBarHeight + 'px';
  172. // #endif
  173. // #ifndef APP-PLUS
  174. let sysHeight = 0
  175. // #endif
  176. import {
  177. getCartList,
  178. getCartCounts,
  179. changeCartNum,
  180. cartDel,
  181. getResetCart
  182. } from '@/api/order.js';
  183. import {
  184. getProductHot,
  185. collectAll,
  186. getProductDetail
  187. } from '@/api/store.js';
  188. import {
  189. toLogin
  190. } from '@/libs/login.js';
  191. import {
  192. mapGetters
  193. } from "vuex";
  194. import recommend from '@/components/recommend';
  195. import productWindow from '@/components/productWindow';
  196. // #ifdef MP
  197. import authorize from '@/components/Authorize';
  198. // #endif
  199. import pageFooter from '@/components/pageFooter/index.vue'
  200. import colors from "@/mixins/color";
  201. import { HTTP_REQUEST_URL } from '@/config/app';
  202. const hot_res = require('@/mock/json/hot_res.json')
  203. import {
  204. getNavigation
  205. } from '@/api/public.js'
  206. export default {
  207. components: {
  208. pageFooter,
  209. recommend,
  210. productWindow,
  211. // #ifdef MP
  212. authorize
  213. // #endif
  214. },
  215. mixins: [colors],
  216. data() {
  217. return {
  218. imgHost: HTTP_REQUEST_URL,
  219. is_diy: uni.getStorageSync('is_diy'),
  220. canShow: false,
  221. cartCount: 0,
  222. goodsHidden: true,
  223. footerswitch: true,
  224. hostProduct: [],
  225. cartList: {
  226. valid: [],
  227. invalid: []
  228. },
  229. isAllSelect: false, //全选
  230. selectValue: [], //选中的数据
  231. selectCountPrice: 0.00,
  232. isAuto: false, //没有授权的不会自动授权
  233. isShowAuth: false, //是否隐藏授权
  234. hotScroll: false,
  235. hotPage: 1,
  236. hotLimit: 10,
  237. loading: false,
  238. loadend: false,
  239. loadTitle: this.$t(`我也是有底线的`), //提示语
  240. page: 1,
  241. limit: 20,
  242. loadingInvalid: false,
  243. loadendInvalid: false,
  244. loadTitleInvalid: this.$t(`加载更多`), //提示语
  245. pageInvalid: 1,
  246. limitInvalid: 20,
  247. attr: {
  248. cartAttr: false,
  249. productAttr: [],
  250. productSelect: {}
  251. },
  252. productValue: [], //系统属性
  253. storeInfo: {},
  254. attrValue: '', //已选属性
  255. attrTxt: this.$t(`请选择`), //属性页面提示
  256. cartId: 0,
  257. product_id: 0,
  258. sysHeight: sysHeight,
  259. newData: {},
  260. activeRouter: '',
  261. is_diy_set: false
  262. };
  263. },
  264. computed: mapGetters(['isLogin']),
  265. onLoad(options) {
  266. // if (this.is_diy) {
  267. // if (uni.getStorageSync('FOOTER_BAR')) {
  268. // uni.hideTabBar()
  269. // } else {
  270. // this.is_diy_set = true
  271. // }
  272. // uni.request({
  273. // url:'api/mock/navigation',
  274. // success:res=>{
  275. // this.newData = res.data
  276. // if (this.newData.status && this.newData.status.status) {
  277. // uni.hideTabBar()
  278. // } else {
  279. // uni.showTabBar()
  280. // }
  281. // }
  282. // })
  283. // // getNavigation().then(res => {
  284. // // this.newData = res.data
  285. // // if (this.newData.status && this.newData.status.status) {
  286. // // uni.hideTabBar()
  287. // // } else {
  288. // // uni.showTabBar()
  289. // // }
  290. // // })
  291. // } else {
  292. // uni.hideTabBar()
  293. // }
  294. let that = this;
  295. if (that.isLogin == false) {
  296. toLogin();
  297. }
  298. let routes = getCurrentPages(); // 获取当前打开过的页面路由数组
  299. let curRoute = routes[routes.length - 1].route //获取当前页面路由
  300. this.activeRouter = '/' + curRoute
  301. },
  302. onShow() {
  303. this.canShow = false
  304. if (this.isLogin == true) {
  305. this.hotPage = 1;
  306. this.hostProduct = [],
  307. this.hotScroll = false,
  308. this.getHostProduct();
  309. this.loadend = false;
  310. this.page = 1;
  311. this.cartList.valid = [];
  312. this.getCartList();
  313. this.loadendInvalid = false;
  314. this.pageInvalid = 1;
  315. this.cartList.invalid = [];
  316. this.getInvalidList();
  317. this.getCartNum();
  318. this.goodsHidden = true;
  319. this.footerswitch = true;
  320. this.hostProduct = [];
  321. this.hotScroll = false;
  322. this.hotPage = 1;
  323. this.hotLimit = 10;
  324. this.cartList = {
  325. valid: [],
  326. invalid: []
  327. },
  328. this.isAllSelect = false; //全选
  329. this.selectValue = []; //选中的数据
  330. this.selectCountPrice = 0.00;
  331. this.cartCount = 0;
  332. this.isShowAuth = false;
  333. };
  334. },
  335. methods: {
  336. // 授权关闭
  337. authColse: function (e) {
  338. this.isShowAuth = e;
  339. },
  340. // 修改购物车
  341. reGoCat: function () {
  342. let that = this,
  343. productSelect = that.productValue[this.attrValue];
  344. //如果有属性,没有选择,提示用户选择
  345. if (
  346. that.attr.productAttr.length &&
  347. productSelect === undefined
  348. )
  349. return that.$util.Tips({
  350. title: that.$t(`产品库存不足,请选择其它`)
  351. });
  352. let q = {
  353. id: that.cartId,
  354. product_id: that.product_id,
  355. num: that.attr.productSelect.cart_num,
  356. unique: that.attr.productSelect !== undefined ?
  357. that.attr.productSelect.unique : ""
  358. };
  359. getResetCart(q)
  360. .then(function (res) {
  361. that.attr.cartAttr = false;
  362. that.$util.Tips({
  363. title: that.$t(`添加购物车成功`),
  364. success: () => {
  365. that.loadend = false;
  366. that.page = 1;
  367. that.cartList.valid = [];
  368. that.getCartList();
  369. that.getCartNum();
  370. }
  371. });
  372. })
  373. .catch(res => {
  374. return that.$util.Tips({
  375. title: res.msg
  376. });
  377. });
  378. },
  379. onMyEvent: function () {
  380. this.$set(this.attr, 'cartAttr', false);
  381. },
  382. reElection: function (item) {
  383. this.getGoodsDetails(item)
  384. },
  385. /**
  386. * 获取产品详情
  387. *
  388. */
  389. getGoodsDetails: function (item) {
  390. uni.showLoading({
  391. title: this.$t(`加载中`),
  392. mask: true
  393. });
  394. let that = this;
  395. that.cartId = item.id;
  396. that.product_id = item.product_id;
  397. getProductDetail(item.product_id).then(res => {
  398. uni.hideLoading();
  399. that.attr.cartAttr = true;
  400. let storeInfo = res.data.storeInfo;
  401. that.$set(that, 'storeInfo', storeInfo);
  402. that.$set(that.attr, 'productAttr', res.data.productAttr);
  403. that.$set(that, 'productValue', res.data.productValue);
  404. that.DefaultSelect();
  405. }).catch(err => {
  406. uni.hideLoading();
  407. })
  408. },
  409. /**
  410. * 属性变动赋值
  411. *
  412. */
  413. ChangeAttr: function (res) {
  414. let productSelect = this.productValue[res];
  415. if (productSelect && productSelect.stock > 0) {
  416. this.$set(this.attr.productSelect, "image", productSelect.image);
  417. this.$set(this.attr.productSelect, "price", productSelect.price);
  418. this.$set(this.attr.productSelect, "stock", productSelect.stock);
  419. this.$set(this.attr.productSelect, "unique", productSelect.unique);
  420. this.$set(this.attr.productSelect, "cart_num", 1);
  421. this.$set(this, "attrValue", res);
  422. this.$set(this, "attrTxt", this.$t(`已选择`));
  423. } else {
  424. this.$set(this.attr.productSelect, "image", this.storeInfo.image);
  425. this.$set(this.attr.productSelect, "price", this.storeInfo.price);
  426. this.$set(this.attr.productSelect, "stock", 0);
  427. this.$set(this.attr.productSelect, "unique", "");
  428. this.$set(this.attr.productSelect, "cart_num", 0);
  429. this.$set(this, "attrValue", "");
  430. this.$set(this, "attrTxt", this.$t(`请选择`));
  431. }
  432. },
  433. /**
  434. * 默认选中属性
  435. *
  436. */
  437. DefaultSelect: function () {
  438. let productAttr = this.attr.productAttr;
  439. let value = [];
  440. for (var key in this.productValue) {
  441. if (this.productValue[key].stock > 0) {
  442. value = this.attr.productAttr.length ? key.split(",") : [];
  443. break;
  444. }
  445. }
  446. for (let i = 0; i < productAttr.length; i++) {
  447. this.$set(productAttr[i], "index", value[i]);
  448. }
  449. //sort();排序函数:数字-英文-汉字;
  450. let productSelect = this.productValue[value.sort().join(",")];
  451. if (productSelect && productAttr.length) {
  452. this.$set(
  453. this.attr.productSelect,
  454. "store_name",
  455. this.storeInfo.store_name
  456. );
  457. this.$set(this.attr.productSelect, "image", productSelect.image);
  458. this.$set(this.attr.productSelect, "price", productSelect.price);
  459. this.$set(this.attr.productSelect, "stock", productSelect.stock);
  460. this.$set(this.attr.productSelect, "unique", productSelect.unique);
  461. this.$set(this.attr.productSelect, "cart_num", 1);
  462. this.$set(this, "attrValue", value.sort().join(","));
  463. this.$set(this, "attrTxt", this.$t(`已选择`));
  464. } else if (!productSelect && productAttr.length) {
  465. this.$set(
  466. this.attr.productSelect,
  467. "store_name",
  468. this.storeInfo.store_name
  469. );
  470. this.$set(this.attr.productSelect, "image", this.storeInfo.image);
  471. this.$set(this.attr.productSelect, "price", this.storeInfo.price);
  472. this.$set(this.attr.productSelect, "stock", 0);
  473. this.$set(this.attr.productSelect, "unique", "");
  474. this.$set(this.attr.productSelect, "cart_num", 0);
  475. this.$set(this, "attrValue", "");
  476. this.$set(this, "attrTxt", this.$t(`请选择`));
  477. } else if (!productSelect && !productAttr.length) {
  478. this.$set(
  479. this.attr.productSelect,
  480. "store_name",
  481. this.storeInfo.store_name
  482. );
  483. this.$set(this.attr.productSelect, "image", this.storeInfo.image);
  484. this.$set(this.attr.productSelect, "price", this.storeInfo.price);
  485. this.$set(this.attr.productSelect, "stock", this.storeInfo.stock);
  486. this.$set(
  487. this.attr.productSelect,
  488. "unique",
  489. this.storeInfo.unique || ""
  490. );
  491. this.$set(this.attr.productSelect, "cart_num", 1);
  492. this.$set(this, "attrValue", "");
  493. this.$set(this, "attrTxt", this.$t(`请选择`));
  494. }
  495. },
  496. attrVal(val) {
  497. this.$set(this.attr.productAttr[val.indexw], 'index', this.attr.productAttr[val.indexw].attr_values[val
  498. .indexn]);
  499. },
  500. /**
  501. * 购物车数量加和数量减
  502. *
  503. */
  504. ChangeCartNum: function (changeValue) {
  505. //changeValue:是否 加|减
  506. //获取当前变动属性
  507. let productSelect = this.productValue[this.attrValue];
  508. //如果没有属性,赋值给商品默认库存
  509. if (productSelect === undefined && !this.attr.productAttr.length)
  510. productSelect = this.attr.productSelect;
  511. //无属性值即库存为0;不存在加减;
  512. if (productSelect === undefined) return;
  513. let stock = productSelect.stock || 0;
  514. let num = this.attr.productSelect;
  515. if (changeValue) {
  516. num.cart_num++;
  517. if (num.cart_num > stock) {
  518. this.$set(this.attr.productSelect, "cart_num", stock ? stock : 1);
  519. this.$set(this, "cart_num", stock ? stock : 1);
  520. }
  521. } else {
  522. num.cart_num--;
  523. if (num.cart_num < 1) {
  524. this.$set(this.attr.productSelect, "cart_num", 1);
  525. this.$set(this, "cart_num", 1);
  526. }
  527. }
  528. },
  529. /**
  530. * 购物车手动填写
  531. *
  532. */
  533. iptCartNum: function (e) {
  534. this.$set(this.attr.productSelect, 'cart_num', e);
  535. },
  536. subDel: function (event) {
  537. let that = this,
  538. selectValue = that.selectValue;
  539. if (selectValue.length > 0)
  540. cartDel(selectValue).then(res => {
  541. that.loadend = false;
  542. that.page = 1;
  543. that.cartList.valid = [];
  544. that.getCartList();
  545. that.getCartNum();
  546. });
  547. else
  548. return that.$util.Tips({
  549. title: that.$t(`请选择产品`)
  550. });
  551. },
  552. getSelectValueProductId: function () {
  553. let that = this;
  554. let validList = that.cartList.valid;
  555. let selectValue = that.selectValue;
  556. let productId = [];
  557. if (selectValue.length > 0) {
  558. for (let index in validList) {
  559. if (that.inArray(validList[index].id, selectValue)) {
  560. productId.push(validList[index].product_id);
  561. }
  562. }
  563. };
  564. return productId;
  565. },
  566. subCollect: function (event) {
  567. let that = this,
  568. selectValue = that.selectValue;
  569. if (selectValue.length > 0) {
  570. let selectValueProductId = that.getSelectValueProductId();
  571. collectAll(that.getSelectValueProductId().join(',')).then(res => {
  572. return that.$util.Tips({
  573. title: res.msg,
  574. icon: 'success'
  575. });
  576. }).catch(err => {
  577. return that.$util.Tips({
  578. title: err
  579. });
  580. });
  581. } else {
  582. return that.$util.Tips({
  583. title: that.$t(`请选择产品`)
  584. });
  585. }
  586. },
  587. subOrder(event) {
  588. console.log(event)
  589. let that = this,
  590. selectValue = that.selectValue;
  591. if (selectValue.length > 0) {
  592. uni.navigateTo({
  593. url: '/pages/goods/order_confirm/index?cartId=' + selectValue.join(',')
  594. });
  595. } else {
  596. return that.$util.Tips({
  597. title: that.$t(`请选择产品`)
  598. });
  599. }
  600. },
  601. checkboxAllChange: function (event) {
  602. let value = event.detail.value;
  603. if (value.length > 0) {
  604. this.setAllSelectValue(1)
  605. } else {
  606. this.setAllSelectValue(0)
  607. }
  608. },
  609. setAllSelectValue: function (status) {
  610. let that = this;
  611. let selectValue = [];
  612. let valid = that.cartList.valid;
  613. if (valid.length > 0) {
  614. let newValid = valid.map(item => {
  615. if (status) {
  616. if (that.footerswitch) {
  617. if (item.attrStatus) {
  618. item.checked = true;
  619. selectValue.push(item.id);
  620. } else {
  621. item.checked = false;
  622. }
  623. } else {
  624. item.checked = true;
  625. selectValue.push(item.id);
  626. }
  627. that.isAllSelect = true;
  628. } else {
  629. item.checked = false;
  630. that.isAllSelect = false;
  631. }
  632. return item;
  633. });
  634. that.$set(that.cartList, 'valid', newValid);
  635. that.selectValue = selectValue;
  636. that.switchSelect();
  637. }
  638. },
  639. checkboxChange: function (event) {
  640. let that = this;
  641. let value = event.detail.value;
  642. let valid = that.cartList.valid;
  643. let arr1 = [];
  644. let arr2 = [];
  645. let arr3 = [];
  646. let newValid = valid.map(item => {
  647. if (that.inArray(item.id, value)) {
  648. if (that.footerswitch) {
  649. if (item.attrStatus) {
  650. item.checked = true;
  651. arr1.push(item);
  652. } else {
  653. item.checked = false;
  654. }
  655. } else {
  656. item.checked = true;
  657. arr1.push(item);
  658. }
  659. } else {
  660. item.checked = false;
  661. arr2.push(item);
  662. }
  663. return item;
  664. });
  665. if (that.footerswitch) {
  666. arr3 = arr2.filter(item => !item.attrStatus);
  667. }
  668. // for (let index in valid) {
  669. // if (that.inArray(valid[index].id, value)){
  670. // if(valid[index].attrStatus){
  671. // valid[index].checked = true;
  672. // }else{
  673. // valid[index].checked = false;
  674. // }
  675. // } else {
  676. // valid[index].checked = false;
  677. // }
  678. // }
  679. that.$set(that.cartList, 'valid', newValid);
  680. // let newArr = that.cartList.valid.filter(item => item.attrStatus);
  681. that.isAllSelect = newValid.length === arr1.length + arr3.length;
  682. that.selectValue = value;
  683. that.switchSelect();
  684. },
  685. inArray: function (search, array) {
  686. for (let i in array) {
  687. if (array[i] == search) {
  688. return true;
  689. }
  690. }
  691. return false;
  692. },
  693. switchSelect: function () {
  694. let that = this;
  695. let validList = that.cartList.valid;
  696. let selectValue = that.selectValue;
  697. let selectCountPrice = 0.00;
  698. if (selectValue.length < 1) {
  699. that.selectCountPrice = selectCountPrice;
  700. } else {
  701. for (let index in validList) {
  702. if (that.inArray(validList[index].id, selectValue)) {
  703. selectCountPrice = that.$util.$h.Add(selectCountPrice, that.$util.$h.Mul(validList[index]
  704. .cart_num, validList[
  705. index].truePrice))
  706. }
  707. }
  708. that.selectCountPrice = selectCountPrice;
  709. }
  710. },
  711. /**
  712. * 购物车手动填写
  713. *
  714. */
  715. iptCartNum: function (index) {
  716. let item = this.cartList.valid[index];
  717. if (item.cart_num) {
  718. this.setCartNum(item.id, item.cart_num);
  719. }
  720. this.switchSelect();
  721. },
  722. blurInput: function (index) {
  723. let item = this.cartList.valid[index];
  724. console.log(item)
  725. if (!item.cart_num) {
  726. item.cart_num = 1;
  727. this.$set(this.cartList, 'valid', this.cartList.valid)
  728. }
  729. },
  730. subCart: function (index) {
  731. let that = this;
  732. let status = false;
  733. let item = that.cartList.valid[index];
  734. item.cart_num = Number(item.cart_num) - 1;
  735. if (item.cart_num < 1) status = true;
  736. if (item.cart_num <= 1) {
  737. item.cart_num = 1;
  738. item.numSub = true;
  739. } else {
  740. item.numSub = false;
  741. item.numAdd = false;
  742. }
  743. if (false == status) {
  744. that.setCartNum(item.id, item.cart_num, function (data) {
  745. that.cartList.valid[index] = item;
  746. that.getCartNum();
  747. that.switchSelect();
  748. });
  749. }
  750. },
  751. addCart: function (index) {
  752. let that = this;
  753. let item = that.cartList.valid[index];
  754. item.cart_num = Number(item.cart_num) + 1;
  755. let productInfo = item.productInfo;
  756. if (productInfo.hasOwnProperty('attrInfo') && item.cart_num >= item.productInfo.attrInfo.stock) {
  757. item.cart_num = item.productInfo.attrInfo.stock;
  758. item.numAdd = true;
  759. item.numSub = false;
  760. } else {
  761. item.numAdd = false;
  762. item.numSub = false;
  763. }
  764. that.setCartNum(item.id, item.cart_num, function (data) {
  765. that.cartList.valid[index] = item;
  766. that.getCartNum();
  767. that.switchSelect();
  768. });
  769. },
  770. setCartNum(cartId, cartNum, successCallback) {
  771. let that = this;
  772. changeCartNum(cartId, cartNum).then(res => {
  773. console.log(res)
  774. successCallback && successCallback(res.data);
  775. }).catch(err => {
  776. console.log(err)
  777. return that.$util.Tips({
  778. title: err
  779. });
  780. })
  781. },
  782. getCartNum: function () {
  783. let that = this;
  784. // getCartCounts().then(res => {
  785. that.cartCount = 3;
  786. this.$store.commit('indexData/setCartNum', 3 > 99 ? '..' : 3)
  787. if (3 > 0) {
  788. wx.setTabBarBadge({
  789. index: 2,
  790. text: 3 + ''
  791. })
  792. } else {
  793. wx.hideTabBarRedDot({
  794. index: 2
  795. })
  796. }
  797. // });
  798. },
  799. getCartData(data) {
  800. let resData = {
  801. "valid": [],
  802. "invalid": [],
  803. "deduction": {
  804. "seckill_id": 0,
  805. "bargain_id": 0,
  806. "combination_id": 0,
  807. "discount_id": 0
  808. }
  809. }
  810. this.loading = false;
  811. this.canShow = true
  812. return resData;
  813. // return new Promise((resolve, reject) => {
  814. // getCartList(data).then((res) => {
  815. // resolve(res.data);
  816. // }).catch((err) => {
  817. // this.loading = false;
  818. // this.canShow = true
  819. // this.$util.Tips({
  820. // title: err
  821. // });
  822. // })
  823. // });
  824. },
  825. async getCartList() {
  826. uni.showLoading({
  827. title: this.$t(`加载中`),
  828. mask: true
  829. });
  830. let that = this;
  831. let data = {
  832. page: that.page,
  833. limit: that.limit,
  834. status: 1
  835. }
  836. let countResData = {
  837. "count": 3,
  838. "ids": [
  839. 9671,
  840. 9670,
  841. 9669
  842. ],
  843. "sum_price": "955.00"
  844. }
  845. // getCartCounts().then(async c => {
  846. that.cartCount = countResData.count;
  847. let n = Math.ceil(countResData.ids.length / that.limit)
  848. console.log(n);
  849. for (let i = 0; i < n; i++) {
  850. // let cartList = await this.getCartData(data)
  851. let cartListData = {
  852. "valid": [
  853. {
  854. "id": 9671,
  855. "uid": 34391,
  856. "type": "0",
  857. "product_id": 97,
  858. "product_attr_unique": "fd6d98f3",
  859. "cart_num": 1,
  860. "add_time": 1666709939,
  861. "is_pay": 0,
  862. "is_del": 0,
  863. "is_new": 0,
  864. "combination_id": 0,
  865. "seckill_id": 0,
  866. "bargain_id": 0,
  867. "advance_id": 0,
  868. "status": 1,
  869. "productInfo": {
  870. "id": 97,
  871. "mer_id": 0,
  872. "image": "https://demo26.crmeb.net/uploads/attach/2021/11/20211113/small_0d407b8541efd8c8f87e5ac581d1421c.png",
  873. "recommend_image": "",
  874. "slider_image": [
  875. "https://demo26.crmeb.net/uploads/attach/2021/11/13/2d97c9bd7abcdb65049c97bbe9ba61d1.jpg",
  876. "https://demo26.crmeb.net/uploads/attach/2021/11/13/a48cce02122f4046193bdda67d970b55.jpg",
  877. "https://demo26.crmeb.net/uploads/attach/2021/11/13/5c4754f2b647b9e240e08f48c9889ebf.jpg",
  878. "https://demo26.crmeb.net/uploads/attach/2021/11/13/e8f6b1235f10f83d8a43bd91def20332.jpg",
  879. "https://demo26.crmeb.net/uploads/attach/2021/11/13/634a51ad34590eab005063742d086b87.jpg"
  880. ],
  881. "store_name": "仟佰家 干花花束真花手工落地高枝装饰摆件招财莲蓬插花居客厅摆设 干花组合6025【不含花瓶】 干花包",
  882. "store_info": "仟佰家 干花花束真花手工落地高枝装饰摆件招财莲蓬插花居客厅摆设 干花组合6025【不含花瓶】 干花包",
  883. "keyword": "",
  884. "bar_code": "",
  885. "cate_id": "22,24",
  886. "price": "306.00",
  887. "vip_price": "0.00",
  888. "ot_price": "299.00",
  889. "postage": "0.00",
  890. "unit_name": "件",
  891. "sort": 100,
  892. "sales": 2,
  893. "stock": 12384,
  894. "is_show": 1,
  895. "is_hot": 0,
  896. "is_benefit": 0,
  897. "is_best": 0,
  898. "is_new": 1,
  899. "is_virtual": 0,
  900. "virtual_type": 0,
  901. "add_time": 1636791973,
  902. "is_postage": 0,
  903. "is_del": 0,
  904. "mer_use": 0,
  905. "give_integral": "0.00",
  906. "cost": "258.00",
  907. "is_seckill": 0,
  908. "is_bargain": null,
  909. "is_good": 0,
  910. "is_sub": 0,
  911. "is_vip": 0,
  912. "ficti": 0,
  913. "browse": 0,
  914. "code_path": "",
  915. "soure_link": "",
  916. "temp_id": 57,
  917. "spec_type": 1,
  918. "activity": "0,1,2,3",
  919. "spu": "5310153503736",
  920. "label_id": "0",
  921. "video_link": "",
  922. "command_word": "",
  923. "recommend_list": "",
  924. "vip_product": 0,
  925. "presale": 0,
  926. "presale_start_time": 0,
  927. "presale_end_time": 0,
  928. "presale_day": 0,
  929. "logistics": "1,2",
  930. "freight": 2,
  931. "custom_form": "",
  932. "is_limit": 0,
  933. "limit_type": 0,
  934. "limit_num": 0,
  935. "express_delivery": true,
  936. "store_mention": true,
  937. "attrInfo": {
  938. "id": 967,
  939. "product_id": 97,
  940. "suk": "干花组合6025【不含花瓶】,干花包",
  941. "stock": 562,
  942. "sales": 1,
  943. "price": "306.00",
  944. "image": "https://demo26.crmeb.net/uploads/attach/2021/11/13/small_634a51ad34590eab005063742d086b87.jpg",
  945. "bar_code": "",
  946. "ot_price": "299.00",
  947. "volume": "0.00",
  948. "weight": "0.00",
  949. "brokerage": "0.00",
  950. "brokerage_two": "0.00",
  951. "type": 0,
  952. "unique": "fd6d98f3",
  953. "cost": "258.00",
  954. "quota": 0,
  955. "quota_show": 0,
  956. "vip_price": "0.00",
  957. "is_virtual": 0,
  958. "coupon_id": 0,
  959. "disk_info": ""
  960. }
  961. },
  962. "attrStatus": true,
  963. "vip_truePrice": 0,
  964. "costPrice": "258.00",
  965. "trueStock": 562,
  966. "truePrice": 306,
  967. "sum_price": "306.00",
  968. "price_type": "level",
  969. "is_valid": 1
  970. },
  971. {
  972. "id": 9670,
  973. "uid": 34391,
  974. "type": "0",
  975. "product_id": 102,
  976. "product_attr_unique": "02cce37e",
  977. "cart_num": 1,
  978. "add_time": 1666709927,
  979. "is_pay": 0,
  980. "is_del": 0,
  981. "is_new": 0,
  982. "combination_id": 0,
  983. "seckill_id": 0,
  984. "bargain_id": 0,
  985. "advance_id": 0,
  986. "status": 1,
  987. "productInfo": {
  988. "id": 102,
  989. "mer_id": 0,
  990. "image": "https://demo26.crmeb.net/uploads/attach/2021/11/15/small_a79f5d2ea6bf0c3c11b2127332dfe2df.jpg",
  991. "recommend_image": "",
  992. "slider_image": [
  993. "https://demo26.crmeb.net/uploads/attach/2021/11/15/a79f5d2ea6bf0c3c11b2127332dfe2df.jpg",
  994. "https://demo26.crmeb.net/uploads/attach/2021/11/15/7f46e98ece1920e1a4082dfc72bcd72a.jpg",
  995. "https://demo26.crmeb.net/uploads/attach/2021/11/15/bfb275263d02ab081b8670a752f2823f.jpg",
  996. "https://demo26.crmeb.net/uploads/attach/2021/11/15/e499a4dc489cda7b8d472cb3a3b348b7.jpg",
  997. "https://demo26.crmeb.net/uploads/attach/2021/11/15/06fa150a47163e973bb4806a380afaab.jpg"
  998. ],
  999. "store_name": "索尼(SONY)WH-CH510 无线立体声耳机 学生网课 白色",
  1000. "store_info": "索尼(SONY)WH-CH510 无线立体声耳机 学生网课 白色",
  1001. "keyword": "耳机",
  1002. "bar_code": "",
  1003. "cate_id": "18,27,25",
  1004. "price": "299.00",
  1005. "vip_price": "0.00",
  1006. "ot_price": "349.00",
  1007. "postage": "0.00",
  1008. "unit_name": "件",
  1009. "sort": 0,
  1010. "sales": 3,
  1011. "stock": 297,
  1012. "is_show": 1,
  1013. "is_hot": 0,
  1014. "is_benefit": 0,
  1015. "is_best": 0,
  1016. "is_new": 0,
  1017. "is_virtual": 0,
  1018. "virtual_type": 0,
  1019. "add_time": 1636958921,
  1020. "is_postage": 0,
  1021. "is_del": 0,
  1022. "mer_use": 0,
  1023. "give_integral": "0.00",
  1024. "cost": "259.00",
  1025. "is_seckill": 0,
  1026. "is_bargain": null,
  1027. "is_good": 0,
  1028. "is_sub": 0,
  1029. "is_vip": 0,
  1030. "ficti": 0,
  1031. "browse": 0,
  1032. "code_path": "",
  1033. "soure_link": "",
  1034. "temp_id": 57,
  1035. "spec_type": 1,
  1036. "activity": "0,1,2,3",
  1037. "spu": "5757529716664",
  1038. "label_id": "0",
  1039. "video_link": "",
  1040. "command_word": "",
  1041. "recommend_list": "",
  1042. "vip_product": 0,
  1043. "presale": 0,
  1044. "presale_start_time": 0,
  1045. "presale_end_time": 0,
  1046. "presale_day": 0,
  1047. "logistics": "1,2",
  1048. "freight": 2,
  1049. "custom_form": "",
  1050. "is_limit": 0,
  1051. "limit_type": 0,
  1052. "limit_num": 0,
  1053. "express_delivery": true,
  1054. "store_mention": true,
  1055. "attrInfo": {
  1056. "id": 9,
  1057. "product_id": 102,
  1058. "suk": "黑色,CH510",
  1059. "stock": 98,
  1060. "sales": 2,
  1061. "price": "299.00",
  1062. "image": "https://demo26.crmeb.net/uploads/attach/2021/11/15/small_a79f5d2ea6bf0c3c11b2127332dfe2df.jpg",
  1063. "bar_code": "",
  1064. "ot_price": "349.00",
  1065. "volume": "0.00",
  1066. "weight": "0.00",
  1067. "brokerage": "0.00",
  1068. "brokerage_two": "0.00",
  1069. "type": 0,
  1070. "unique": "02cce37e",
  1071. "cost": "259.00",
  1072. "quota": 0,
  1073. "quota_show": 0,
  1074. "vip_price": "0.00",
  1075. "is_virtual": 0,
  1076. "coupon_id": 0,
  1077. "disk_info": ""
  1078. }
  1079. },
  1080. "attrStatus": true,
  1081. "vip_truePrice": 0,
  1082. "costPrice": "259.00",
  1083. "trueStock": 98,
  1084. "truePrice": 299,
  1085. "sum_price": "299.00",
  1086. "price_type": "level",
  1087. "is_valid": 1
  1088. },
  1089. {
  1090. "id": 9669,
  1091. "uid": 34391,
  1092. "type": "0",
  1093. "product_id": 89,
  1094. "product_attr_unique": "89807c67",
  1095. "cart_num": 1,
  1096. "add_time": 1666709911,
  1097. "is_pay": 0,
  1098. "is_del": 0,
  1099. "is_new": 0,
  1100. "combination_id": 0,
  1101. "seckill_id": 0,
  1102. "bargain_id": 0,
  1103. "advance_id": 0,
  1104. "status": 1,
  1105. "productInfo": {
  1106. "id": 89,
  1107. "mer_id": 0,
  1108. "image": "https://demo26.crmeb.net/uploads/attach/2021/11/20211113/small_2fbe723632427b0768df24c4f23c6cad.png",
  1109. "recommend_image": "",
  1110. "slider_image": [
  1111. "https://demo26.crmeb.net/uploads/attach/2021/11/20211113/2fbe723632427b0768df24c4f23c6cad.png",
  1112. "https://demo26.crmeb.net/uploads/attach/2021/11/20211113/64d188477292aa4ae2df8da7e63aca79.png"
  1113. ],
  1114. "store_name": "家居梵高系列联名款饭盒袋大容量手拎保温实用方便 星月夜饭盒袋",
  1115. "store_info": "",
  1116. "keyword": "家居梵高系列联名款饭盒袋大容量手拎保温实用方便 星月夜饭盒袋",
  1117. "bar_code": "",
  1118. "cate_id": "35",
  1119. "price": "350.00",
  1120. "vip_price": "0.00",
  1121. "ot_price": "300.00",
  1122. "postage": "0.00",
  1123. "unit_name": "件",
  1124. "sort": 553,
  1125. "sales": 19,
  1126. "stock": 185,
  1127. "is_show": 1,
  1128. "is_hot": 1,
  1129. "is_benefit": 0,
  1130. "is_best": 0,
  1131. "is_new": 0,
  1132. "is_virtual": 0,
  1133. "virtual_type": 0,
  1134. "add_time": 1636777038,
  1135. "is_postage": 0,
  1136. "is_del": 0,
  1137. "mer_use": 0,
  1138. "give_integral": "0.00",
  1139. "cost": "300.00",
  1140. "is_seckill": 0,
  1141. "is_bargain": null,
  1142. "is_good": 1,
  1143. "is_sub": 0,
  1144. "is_vip": 0,
  1145. "ficti": 0,
  1146. "browse": 0,
  1147. "code_path": "",
  1148. "soure_link": "",
  1149. "temp_id": 0,
  1150. "spec_type": 1,
  1151. "activity": "0,1,2,3",
  1152. "spu": "1015710267816",
  1153. "label_id": "",
  1154. "video_link": "",
  1155. "command_word": "",
  1156. "recommend_list": "",
  1157. "vip_product": 0,
  1158. "presale": 0,
  1159. "presale_start_time": 0,
  1160. "presale_end_time": 0,
  1161. "presale_day": 0,
  1162. "logistics": "1,2",
  1163. "freight": 2,
  1164. "custom_form": "[]",
  1165. "is_limit": 0,
  1166. "limit_type": 0,
  1167. "limit_num": 0,
  1168. "express_delivery": true,
  1169. "store_mention": true,
  1170. "attrInfo": {
  1171. "id": 1017,
  1172. "product_id": 89,
  1173. "suk": "梵高自画像饭盒",
  1174. "stock": 88,
  1175. "sales": 8,
  1176. "price": "350.00",
  1177. "image": "https://demo26.crmeb.net/uploads/attach/2021/11/20211113/small_2fbe723632427b0768df24c4f23c6cad.png",
  1178. "bar_code": "",
  1179. "ot_price": "300.00",
  1180. "volume": "0.00",
  1181. "weight": "0.00",
  1182. "brokerage": "0.00",
  1183. "brokerage_two": "0.00",
  1184. "type": 0,
  1185. "unique": "89807c67",
  1186. "cost": "300.00",
  1187. "quota": 0,
  1188. "quota_show": 0,
  1189. "vip_price": "0.00",
  1190. "is_virtual": 0,
  1191. "coupon_id": 0,
  1192. "disk_info": ""
  1193. }
  1194. },
  1195. "attrStatus": true,
  1196. "vip_truePrice": 0,
  1197. "costPrice": "300.00",
  1198. "trueStock": 88,
  1199. "truePrice": 350,
  1200. "sum_price": "350.00",
  1201. "price_type": "level",
  1202. "is_valid": 1
  1203. }
  1204. ],
  1205. "invalid": [],
  1206. "deduction": {
  1207. "seckill_id": 0,
  1208. "bargain_id": 0,
  1209. "combination_id": 0,
  1210. "discount_id": 0
  1211. }
  1212. }
  1213. let cartList = cartListData
  1214. let valid = cartList.valid
  1215. let validList = that.$util.SplitArray(valid, that.cartList.valid);
  1216. let numSub = [{
  1217. numSub: true
  1218. }, {
  1219. numSub: false
  1220. }];
  1221. let numAdd = [{
  1222. numAdd: true
  1223. }, {
  1224. numAdd: false
  1225. }],
  1226. selectValue = [];
  1227. if (validList.length > 0) {
  1228. for (let index in validList) {
  1229. if (validList[index].cart_num == 1) {
  1230. validList[index].numSub = true;
  1231. } else {
  1232. validList[index].numSub = false;
  1233. }
  1234. let productInfo = validList[index].productInfo;
  1235. if (productInfo.hasOwnProperty('attrInfo') && validList[index].cart_num ==
  1236. validList[index].productInfo.attrInfo
  1237. .stock) {
  1238. validList[index].numAdd = true;
  1239. } else if (validList[index].cart_num == validList[index].productInfo
  1240. .stock) {
  1241. validList[index].numAdd = true;
  1242. } else {
  1243. validList[index].numAdd = false;
  1244. }
  1245. if (validList[index].attrStatus) {
  1246. validList[index].checked = true;
  1247. selectValue.push(validList[index].id);
  1248. } else {
  1249. validList[index].checked = false;
  1250. }
  1251. }
  1252. }
  1253. that.$set(that.cartList, 'valid', validList);
  1254. data.page = that.page + 1;
  1255. // that.goodsHidden = cartList.valid.length <= 0 ? false : true;
  1256. that.selectValue = selectValue;
  1257. let newArr = validList.filter(item => item.attrStatus);
  1258. that.isAllSelect = newArr.length == selectValue.length && newArr.length;
  1259. that.switchSelect();
  1260. }
  1261. that.loading = false;
  1262. this.canShow = true
  1263. uni.hideLoading();
  1264. // });
  1265. },
  1266. getInvalidList: function () {
  1267. let that = this;
  1268. if (this.loadendInvalid) return false;
  1269. if (this.loadingInvalid) return false;
  1270. let data = {
  1271. page: that.pageInvalid,
  1272. limit: that.limitInvalid,
  1273. status: 0
  1274. }
  1275. let resData = {
  1276. "valid": [],
  1277. "invalid": [],
  1278. "deduction": {
  1279. "seckill_id": 0,
  1280. "bargain_id": 0,
  1281. "combination_id": 0,
  1282. "discount_id": 0
  1283. }
  1284. }
  1285. // getCartList(data).then(res => {
  1286. let cartList = resData,
  1287. invalid = cartList.invalid,
  1288. loadendInvalid = invalid.length < that.limitInvalid;
  1289. let invalidList = that.$util.SplitArray(invalid, that.cartList.invalid);
  1290. that.$set(that.cartList, 'invalid', invalidList);
  1291. that.loadendInvalid = loadendInvalid;
  1292. that.loadTitleInvalid = loadendInvalid ? that.$t(`我也是有底线的`) : that.$t(`加载更多`);
  1293. that.pageInvalid = that.pageInvalid + 1;
  1294. that.loadingInvalid = false;
  1295. // }).catch(res => {
  1296. // that.loadingInvalid = false;
  1297. // that.loadTitleInvalid = that.$t(`加载更多`);
  1298. // })
  1299. },
  1300. getHostProduct: function () {
  1301. let that = this;
  1302. if (that.hotScroll) return
  1303. that.hotPage++
  1304. that.hotScroll = hot_res.length < that.hotLimit
  1305. that.hostProduct = that.hostProduct.concat(hot_res)
  1306. // getProductHot(
  1307. // that.hotPage,
  1308. // that.hotLimit,
  1309. // ).then(res => {
  1310. // that.hotPage++
  1311. // that.hotScroll = res.data.length < that.hotLimit
  1312. // that.hostProduct = that.hostProduct.concat(res.data)
  1313. // });
  1314. },
  1315. goodsOpen: function () {
  1316. let that = this;
  1317. that.goodsHidden = !that.goodsHidden;
  1318. },
  1319. goRouter(item) {
  1320. var pages = getCurrentPages();
  1321. var page = (pages[pages.length - 1]).$page.fullPath;
  1322. if (item.link == page) return
  1323. uni.switchTab({
  1324. url: item.link,
  1325. fail(err) {
  1326. uni.redirectTo({
  1327. url: item.link
  1328. })
  1329. }
  1330. })
  1331. },
  1332. manage: function () {
  1333. let that = this;
  1334. that.footerswitch = !that.footerswitch;
  1335. let arr1 = [];
  1336. let arr2 = [];
  1337. let newValid = that.cartList.valid.map(item => {
  1338. if (that.footerswitch) {
  1339. if (item.attrStatus) {
  1340. if (item.checked) {
  1341. arr1.push(item.id);
  1342. }
  1343. } else {
  1344. item.checked = false;
  1345. arr2.push(item);
  1346. }
  1347. } else {
  1348. if (item.checked) {
  1349. arr1.push(item.id);
  1350. }
  1351. }
  1352. return item;
  1353. });
  1354. that.cartList.valid = newValid;
  1355. if (that.footerswitch) {
  1356. that.isAllSelect = newValid.length === arr1.length + arr2.length;
  1357. } else {
  1358. that.isAllSelect = newValid.length === arr1.length;
  1359. }
  1360. that.selectValue = arr1;
  1361. that.switchSelect();
  1362. },
  1363. unsetCart: function () {
  1364. let that = this,
  1365. ids = [];
  1366. for (let i = 0, len = that.cartList.invalid.length; i < len; i++) {
  1367. ids.push(that.cartList.invalid[i].id);
  1368. }
  1369. cartDel(ids).then(res => {
  1370. that.$util.Tips({
  1371. title: that.$t(`清除成功`)
  1372. });
  1373. that.$set(that.cartList, 'invalid', []);
  1374. that.getCartNum();
  1375. }).catch(res => {
  1376. });
  1377. }
  1378. },
  1379. onReachBottom() {
  1380. let that = this;
  1381. if (that.loadend) {
  1382. that.getInvalidList();
  1383. }
  1384. if (that.cartList.valid.length == 0 && that.cartList.invalid.length == 0) {
  1385. that.getHostProduct();
  1386. }
  1387. }
  1388. }
  1389. </script>
  1390. <style scoped lang="scss">
  1391. .page-footer {
  1392. position: fixed;
  1393. bottom: 0;
  1394. z-index: 30;
  1395. display: flex;
  1396. align-items: center;
  1397. justify-content: space-around;
  1398. width: 100%;
  1399. height: calc(98rpx+ constant(safe-area-inset-bottom)); ///兼容 IOS<11.2/
  1400. height: calc(98rpx + env(safe-area-inset-bottom)); ///兼容 IOS>11.2/
  1401. box-sizing: border-box;
  1402. border-top: solid 1rpx #F3F3F3;
  1403. background-color: #fff;
  1404. box-shadow: 0px 0px 17rpx 1rpx rgba(206, 206, 206, 0.32);
  1405. padding-bottom: constant(safe-area-inset-bottom); ///兼容 IOS<11.2/
  1406. padding-bottom: env(safe-area-inset-bottom); ///兼容 IOS>11.2/
  1407. .foot-item {
  1408. display: flex;
  1409. width: max-content;
  1410. align-items: center;
  1411. justify-content: center;
  1412. flex-direction: column;
  1413. position: relative;
  1414. .count-num {
  1415. position: absolute;
  1416. display: flex;
  1417. justify-content: center;
  1418. align-items: center;
  1419. width: 40rpx;
  1420. height: 40rpx;
  1421. top: 0rpx;
  1422. right: -15rpx;
  1423. color: #fff;
  1424. font-size: 20rpx;
  1425. background-color: #FD502F;
  1426. border-radius: 50%;
  1427. padding: 4rpx;
  1428. }
  1429. }
  1430. .foot-item image {
  1431. height: 50rpx;
  1432. width: 50rpx;
  1433. text-align: center;
  1434. margin: 0 auto;
  1435. }
  1436. .foot-item .txt {
  1437. font-size: 24rpx;
  1438. &.active {}
  1439. }
  1440. }
  1441. .shoppingCart {
  1442. /* #ifdef H5 */
  1443. // padding-bottom: 0;
  1444. // padding-bottom: constant(safe-area-inset-bottom);
  1445. // padding-bottom: env(safe-area-inset-bottom);
  1446. /* #endif */
  1447. }
  1448. .shoppingCart .labelNav {
  1449. height: 76rpx;
  1450. padding: 0 30rpx;
  1451. font-size: 22rpx;
  1452. color: #8c8c8c;
  1453. position: fixed;
  1454. left: 0;
  1455. width: 100%;
  1456. box-sizing: border-box;
  1457. background-color: #f5f5f5;
  1458. z-index: 5;
  1459. top: 0;
  1460. }
  1461. .shoppingCart .labelNav .item .iconfont {
  1462. font-size: 25rpx;
  1463. margin-right: 10rpx;
  1464. }
  1465. .shoppingCart .nav {
  1466. width: 100%;
  1467. height: 80rpx;
  1468. background-color: #fff;
  1469. padding: 0 30rpx;
  1470. box-sizing: border-box;
  1471. font-size: 28rpx;
  1472. color: #282828;
  1473. position: fixed;
  1474. left: 0;
  1475. z-index: 5;
  1476. top: 76rpx;
  1477. }
  1478. .shoppingCart .nav .num {
  1479. margin-left: 12rpx;
  1480. }
  1481. .shoppingCart .nav .administrate {
  1482. font-size: 26rpx;
  1483. color: #282828;
  1484. width: 110rpx;
  1485. height: 46rpx;
  1486. border-radius: 6rpx;
  1487. border: 1px solid #a4a4a4;
  1488. }
  1489. .shoppingCart .noCart {
  1490. margin-top: 171rpx;
  1491. background-color: #fff;
  1492. padding-top: 0.1rpx;
  1493. }
  1494. .shoppingCart .noCart .pictrue {
  1495. width: 414rpx;
  1496. height: 336rpx;
  1497. margin: 78rpx auto 56rpx auto;
  1498. }
  1499. .shoppingCart .noCart .pictrue image {
  1500. width: 100%;
  1501. height: 100%;
  1502. }
  1503. .shoppingCart .list {
  1504. margin-top: 171rpx;
  1505. }
  1506. .shoppingCart .list .item {
  1507. padding: 25rpx 30rpx;
  1508. background-color: #fff;
  1509. margin-bottom: 15rpx;
  1510. }
  1511. .shoppingCart .list .item .picTxt {
  1512. width: 627rpx;
  1513. position: relative;
  1514. }
  1515. .shoppingCart .list .item .picTxt .pictrue {
  1516. width: 160rpx;
  1517. height: 160rpx;
  1518. }
  1519. .shoppingCart .list .item .picTxt .pictrue image {
  1520. width: 100%;
  1521. height: 100%;
  1522. border-radius: 6rpx;
  1523. }
  1524. .shoppingCart .list .item .picTxt .text {
  1525. width: 444rpx;
  1526. font-size: 28rpx;
  1527. color: #282828;
  1528. }
  1529. .shoppingCart .list .item .picTxt .text .reColor {
  1530. color: #999;
  1531. }
  1532. .shoppingCart .list .item .picTxt .text .reElection {
  1533. margin-top: 20rpx;
  1534. }
  1535. .shoppingCart .list .item .picTxt .text .reElection .title {
  1536. font-size: 24rpx;
  1537. }
  1538. .shoppingCart .list .item .picTxt .text .reElection .reBnt {
  1539. width: 120rpx;
  1540. height: 46rpx;
  1541. border-radius: 23rpx;
  1542. font-size: 26rpx;
  1543. }
  1544. .shoppingCart .list .item .picTxt .text .infor {
  1545. font-size: 24rpx;
  1546. color: #868686;
  1547. margin-top: 16rpx;
  1548. }
  1549. .shoppingCart .list .item .picTxt .text .money {
  1550. font-size: 32rpx;
  1551. color: var(--view-theme);
  1552. margin-top: 28rpx;
  1553. }
  1554. .shoppingCart .list .item .picTxt .carnum {
  1555. height: 47rpx;
  1556. position: absolute;
  1557. bottom: 7rpx;
  1558. right: 0;
  1559. }
  1560. .shoppingCart .list .item .picTxt .carnum view {
  1561. border: 1rpx solid #a4a4a4;
  1562. width: 66rpx;
  1563. text-align: center;
  1564. height: 100%;
  1565. line-height: 40rpx;
  1566. font-size: 28rpx;
  1567. color: #a4a4a4;
  1568. }
  1569. .shoppingCart .list .item .picTxt .carnum .reduce {
  1570. border-right: 0;
  1571. border-radius: 3rpx 0 0 3rpx;
  1572. }
  1573. .shoppingCart .list .item .picTxt .carnum .reduce.on {
  1574. border-color: #e3e3e3;
  1575. color: #dedede;
  1576. }
  1577. .shoppingCart .list .item .picTxt .carnum .plus {
  1578. border-left: 0;
  1579. border-radius: 0 3rpx 3rpx 0;
  1580. }
  1581. .shoppingCart .list .item .picTxt .carnum .plus.on {
  1582. border-color: #e3e3e3;
  1583. color: #dedede;
  1584. }
  1585. .shoppingCart .list .item .picTxt .carnum .num {
  1586. color: #282828;
  1587. }
  1588. .shoppingCart .invalidGoods {
  1589. background-color: #fff;
  1590. }
  1591. .shoppingCart .invalidGoods .goodsNav {
  1592. width: 100%;
  1593. height: 66rpx;
  1594. padding: 0 30rpx;
  1595. box-sizing: border-box;
  1596. font-size: 28rpx;
  1597. color: #282828;
  1598. }
  1599. .shoppingCart .invalidGoods .goodsNav .iconfont {
  1600. color: #424242;
  1601. font-size: 28rpx;
  1602. margin-right: 17rpx;
  1603. }
  1604. .shoppingCart .invalidGoods .goodsNav .del {
  1605. font-size: 26rpx;
  1606. color: #999;
  1607. }
  1608. .shoppingCart .invalidGoods .goodsNav .del .icon-shanchu1 {
  1609. color: #999;
  1610. font-size: 33rpx;
  1611. vertical-align: -2rpx;
  1612. margin-right: 8rpx;
  1613. }
  1614. .shoppingCart .invalidGoods .goodsList .item {
  1615. padding: 20rpx 30rpx;
  1616. border-top: 1rpx solid #f5f5f5;
  1617. }
  1618. .shoppingCart .invalidGoods .goodsList .item .invalid {
  1619. font-size: 22rpx;
  1620. color: #fff;
  1621. width: 70rpx;
  1622. height: 36rpx;
  1623. background-color: #aaa;
  1624. border-radius: 3rpx;
  1625. text-align: center;
  1626. line-height: 36rpx;
  1627. }
  1628. .shoppingCart .invalidGoods .goodsList .item .pictrue {
  1629. width: 140rpx;
  1630. height: 140rpx;
  1631. }
  1632. .shoppingCart .invalidGoods .goodsList .item .pictrue image {
  1633. width: 100%;
  1634. height: 100%;
  1635. border-radius: 6rpx;
  1636. }
  1637. .shoppingCart .invalidGoods .goodsList .item .text {
  1638. width: 433rpx;
  1639. font-size: 28rpx;
  1640. color: #999;
  1641. height: 140rpx;
  1642. }
  1643. .shoppingCart .invalidGoods .goodsList .item .text .name {
  1644. width: 100%;
  1645. }
  1646. .shoppingCart .invalidGoods .goodsList .item .text .infor {
  1647. font-size: 24rpx;
  1648. }
  1649. .shoppingCart .invalidGoods .goodsList .item .text .end {
  1650. font-size: 26rpx;
  1651. color: #bbb;
  1652. }
  1653. .shoppingCart .footer {
  1654. z-index: 999;
  1655. width: 100%;
  1656. height: 96rpx;
  1657. background-color: #fafafa;
  1658. position: fixed;
  1659. padding: 0 30rpx;
  1660. box-sizing: border-box;
  1661. border-top: 1rpx solid #eee;
  1662. bottom: 98rpx;
  1663. bottom: calc(98rpx + constant(safe-area-inset-bottom)); ///兼容 IOS<11.2/
  1664. bottom: calc(98rpx + env(safe-area-inset-bottom)); ///兼容 IOS>11.2/
  1665. }
  1666. .shoppingCart .footer.on {
  1667. // #ifndef H5
  1668. bottom: 0rpx;
  1669. // #endif
  1670. }
  1671. .shoppingCart .footer .checkAll {
  1672. font-size: 28rpx;
  1673. color: #282828;
  1674. margin-left: 16rpx;
  1675. }
  1676. // .shoppingCart .footer checkbox .wx-checkbox-input{background-color:#fafafa;}
  1677. .shoppingCart .footer .money {
  1678. font-size: 30rpx;
  1679. }
  1680. .shoppingCart .footer .placeOrder {
  1681. color: #fff;
  1682. font-size: 30rpx;
  1683. width: 226rpx;
  1684. height: 70rpx;
  1685. border-radius: 50rpx;
  1686. text-align: center;
  1687. line-height: 70rpx;
  1688. margin-left: 22rpx;
  1689. }
  1690. .shoppingCart .footer .button .bnt {
  1691. font-size: 28rpx;
  1692. color: #999;
  1693. border-radius: 50rpx;
  1694. border: 1px solid #999;
  1695. width: 160rpx;
  1696. height: 60rpx;
  1697. text-align: center;
  1698. line-height: 60rpx;
  1699. }
  1700. .shoppingCart .footer .button form~form {
  1701. margin-left: 17rpx;
  1702. }
  1703. .uni-p-b-96 {
  1704. height: 96rpx;
  1705. }
  1706. .uni-p-b-98 {
  1707. height: 100rpx;
  1708. /* 兼容 IOS<11.2 */
  1709. height: calc(100rpx + constant(safe-area-inset-bottom));
  1710. /* 兼容 IOS>11.2 */
  1711. height: calc(100rpx + env(safe-area-inset-bottom));
  1712. }
  1713. .emptyBox {
  1714. text-align: center;
  1715. padding-top: 20rpx;
  1716. .tips {
  1717. color: #aaa;
  1718. font-size: 26rpx;
  1719. }
  1720. image {
  1721. width: 414rpx;
  1722. height: 304rpx;
  1723. }
  1724. }
  1725. </style>