order_addcart.vue 47 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636
  1. <template>
  2. <!-- 购物车模块 -->
  3. <view :style="colorStyle">
  4. <!-- #ifdef MP -->
  5. <view class="sys-head" :style="{height:sysHeight + 'px'}"></view>
  6. <view class="sys-title" :style="{top:sysHeight + 'px'}">购物车</view>
  7. <!-- #endif -->
  8. <view class='shoppingCart copy-data'>
  9. <!-- #ifdef MP -->
  10. <view class='labelNav acea-row row-around row-middle' :style="{top:(sysHeight+40) + 'px'}">
  11. <!-- #endif -->
  12. <!-- #ifdef APP-PLUS || H5 -->
  13. <view class='labelNav acea-row row-around row-middle'>
  14. <!-- #endif -->
  15. <view class='item'><text class='iconfont icon-xuanzhong'></text>100%正品保证</view>
  16. <view class='item'><text class='iconfont icon-xuanzhong'></text>所有商品精挑细选</view>
  17. <view class='item'><text class='iconfont icon-xuanzhong'></text>售后无忧</view>
  18. </view>
  19. <!-- #ifdef MP -->
  20. <view class='nav acea-row row-between-wrapper' :style="{top:(sysHeight+78) + 'px'}">
  21. <!-- #endif -->
  22. <!-- #ifdef APP-PLUS || H5 -->
  23. <view class='nav acea-row row-between-wrapper' style="top:38px;">
  24. <!-- #endif -->
  25. <view><text class='num font-num'>{{cartNum || 0}}</text>购物数量</view>
  26. <view v-if="cartList.valid.length > 0 || cartList.invalid.length > 0"
  27. class='administrate acea-row row-center-wrapper' @click='manage'>{{ footerswitch ? '管理' : '取消'}}
  28. </view>
  29. </view>
  30. <view v-if="cartList.valid.length > 0 || cartList.invalid.length > 0">
  31. <!-- #ifdef MP -->
  32. <view :style="{height: (sysHeight+130) + 'px'}"></view>
  33. <!-- #endif -->
  34. <!-- #ifdef APP-PLUS || H5 -->
  35. <view style="height:90px;"></view>
  36. <!-- #endif -->
  37. <view class='list'>
  38. <checkbox-group @change="checkboxChange">
  39. <view class="title acea-row row-between-wrapper" v-if="cartList.valid.length && Object.prototype.toString.call(discountInfo.coupon) === '[object Object]'">
  40. <view style="width:530rpx;"><text class="label">优惠券</text>最高可优惠{{discountInfo.deduction.coupon_price}}元</view>
  41. <view class="font-color" @click="couponTap">点击领用<text class="iconfont icon-jinru2"></text></view>
  42. </view>
  43. <view v-for="(j,jindex) in cartList.valid" :key="jindex">
  44. <view class="title acea-row row-between-wrapper" v-for="(p,proIndex) in j.promotions"
  45. :key="proIndex">
  46. <view style="width:530rpx;"><text class="label">{{p.title}}</text>{{p.desc}}<text v-if="p.differ_threshold>0">,还差{{p.differ_threshold}}{{p.threshold_type==1?'元':'件'}}</text></view>
  47. <view class="font-color" @click="goCollect(p)">{{p.is_valid == 1?'去逛逛':'去凑单'}}<text
  48. class="iconfont icon-jinru2"></text></view>
  49. </view>
  50. <!-- <checkbox-group @change="checkboxChange"> -->
  51. <block v-for="(item,index) in j.valid" :key="index">
  52. <view class='item acea-row row-between-wrapper'>
  53. <!-- #ifndef MP -->
  54. <checkbox :value="(item.id).toString()" :checked="item.checked"
  55. :disabled="(!item.attrStatus || item.is_gift?true:false) && footerswitch" />
  56. <!-- <checkbox :value="(item.id).toString()" :checked="item.checked" :disabled="item.attrStatus?false:true" /> -->
  57. <!-- #endif -->
  58. <!-- #ifdef MP -->
  59. <checkbox :value="item.id" :checked="item.checked"
  60. :disabled="(!item.attrStatus || item.is_gift?true:false) && footerswitch" />
  61. <!-- #endif -->
  62. <view class='picTxt acea-row row-between-wrapper'>
  63. <navigator class='pictrue' :url='"/pages/goods_details/index?id="+item.product_id' hover-class='none'>
  64. <image v-if="item.productInfo.attrInfo" :src='item.productInfo.attrInfo.image'>
  65. </image>
  66. <image v-else :src='item.productInfo.image'></image>
  67. </navigator>
  68. <view class='text'>
  69. <view class='line1' :class="item.attrStatus?'':'reColor'">
  70. {{item.productInfo.store_name}}
  71. </view>
  72. <view class='infor line1' v-if="item.productInfo.attrInfo && item.productInfo.spec_type && !item.is_gift && item.attrStatus" @click.stop="cartAttr(item)">
  73. <text class="name line1">属性:{{item.productInfo.attrInfo.suk}}</text>
  74. <text class="iconfont icon-xiangxia"></text>
  75. </view>
  76. <view class='infor line1' v-else>
  77. <text class="name line1">属性:{{item.productInfo.attrInfo.suk}}</text>
  78. </view>
  79. <view class='money' v-if="item.attrStatus && !item.is_gift">¥{{item.sum_price}}</view>
  80. <view class="isGift" v-if="item.is_gift">赠品</view>
  81. <view class="reElection acea-row row-between-wrapper" v-if="!item.attrStatus">
  82. <view class="titles">请重新选择商品规格</view>
  83. <view class="reBnt cart-color acea-row row-center-wrapper"
  84. @click.stop="reElection(item)">重选</view>
  85. </view>
  86. </view>
  87. <view class='carnum acea-row row-center-wrapper' v-if="item.attrStatus && !item.is_gift">
  88. <view class="reduce" :class="item.numSub ? 'on' : ''"
  89. @click.stop='subCart(jindex,index)'>-</view>
  90. <view class='num'>{{(item.productInfo.limit_num>0 && item.cart_num>=item.productInfo.limit_num)?item.productInfo.limit_num:item.cart_num}}</view>
  91. <!-- <view class="num">
  92. <input type="number" v-model="item.cart_num" @click.stop @input="iptCartNum(index)" @blur="blurInput(index)"/>
  93. </view> -->
  94. <view class="plus" :class="(item.numAdd || (item.productInfo.limit_num>0 && item.cart_num>=item.productInfo.limit_num)) ? 'on' : ''"
  95. @click.stop='addCart(jindex,index,item)'>+</view>
  96. </view>
  97. </view>
  98. <view class="evaluate" v-if="item.attrStatus && !item.is_gift && item.sum_price != item.truePrice">预估到手价<text class="num">¥{{item.truePrice}}</text></view>
  99. </view>
  100. </block>
  101. <!-- </checkbox-group> -->
  102. </view>
  103. </checkbox-group>
  104. </view>
  105. <view class='invalidGoods' v-if="cartList.invalid.length > 0">
  106. <view class='goodsNav acea-row row-between-wrapper'>
  107. <view @click='goodsOpen'><text class='iconfont'
  108. :class='goodsHidden==true?"icon-xiangxia":"icon-xiangshang"'></text>失效商品</view>
  109. <view class='del' @click='unsetCart'><text class='iconfont icon-shanchu1'></text>清空</view>
  110. </view>
  111. <view class='goodsList' :hidden='goodsHidden'>
  112. <block v-for="(item,index) in cartList.invalid" :key='index'>
  113. <view class='item acea-row row-between-wrapper'>
  114. <view class='invalid'>失效</view>
  115. <view class='pictrue'>
  116. <image v-if="item.productInfo.attrInfo" :src='item.productInfo.attrInfo.image'>
  117. </image>
  118. <image v-else :src='item.productInfo.image'></image>
  119. </view>
  120. <view class='text acea-row row-column-between'>
  121. <view class='line1 name'>{{item.productInfo.store_name}}</view>
  122. <view class='infor line1' v-if="item.productInfo.attrInfo">
  123. 属性:{{item.productInfo.attrInfo.suk}}</view>
  124. <view class='acea-row row-between-wrapper'>
  125. <!-- <view>¥{{item.truePrice}}</view> -->
  126. <view class='end'>{{item.invalid_desc}}</view>
  127. </view>
  128. </view>
  129. </view>
  130. </block>
  131. </view>
  132. </view>
  133. <!-- <view class='loadingicon acea-row row-center-wrapper' v-if="cartList.invalid.length && loadend">
  134. <text class='loading iconfont icon-jiazai'
  135. :hidden='loadingInvalid==false'></text>{{loadTitleInvalid}}
  136. </view> -->
  137. </view>
  138. <view class='noCart' v-if="cartList.valid.length == 0 && cartList.invalid.length == 0 && loadend">
  139. <view class='pictrue'>
  140. <image :src="imgHost + '/statics/images/no-thing.png'"></image>
  141. <view>暂无商品,去添加点什么吧</view>
  142. </view>
  143. <!-- 热门推荐显示 -->
  144. <recommend :hostProduct='hostProduct'></recommend>
  145. </view>
  146. <view v-if="cartList.valid.length == 0 && cartList.invalid.length == 0 && loadend" style='height:30rpx;color: #F5F5F5;'></view>
  147. <view v-else style='height:190rpx;color: #F5F5F5;'></view>
  148. <view class="tips acea-row row-middle" :class="isFooter?'':'on'" v-if="isTips"><text class="iconfont icon-tishi"></text>部分活动不能叠加,系统已自动为您计算最优惠的价格</view>
  149. <!-- 订单结算 -->
  150. <view class='footer acea-row row-between-wrapper' :class="isFooter?'':'on'"
  151. v-if="cartList.valid.length > 0">
  152. <view>
  153. <checkbox-group @change="checkboxAllChange">
  154. <checkbox value="all" :checked="!!isAllSelect" />
  155. <text class='checkAll'>全选</text>
  156. </checkbox-group>
  157. </view>
  158. <view class='money acea-row row-middle' v-if="footerswitch==true && discountInfo.deduction">
  159. <view class="left">
  160. 实付:
  161. <text class="font-color">¥{{selectValue.length?discountInfo.deduction.pay_price:0}}</text>
  162. <view class="acea-row row-right">
  163. <view class="detailed" @click="discountTap" v-if="(Object.prototype.toString.call(discountInfo.coupon) === '[object Object]' || discountInfo.deduction.first_order_price || discountInfo.deduction.promotions_price) && selectValue.length">优惠明细</view>
  164. </view>
  165. </view>
  166. <form @submit="subOrder">
  167. <button v-if="selectValue.length" class='placeOrder bg-color' formType="submit">{{Object.prototype.toString.call(discountInfo.coupon) === "[object Array]" || discountInfo.coupon.used?'去':'领券'}}结算({{selectValue.length}})</button>
  168. <button v-else class='placeOrder on'formType="submit">{{Object.prototype.toString.call(discountInfo.coupon) === "[object Array]" || discountInfo.coupon.used?'去':'领券'}}结算({{selectValue.length}})</button>
  169. </form>
  170. </view>
  171. <view class='button acea-row row-middle' v-else>
  172. <form @submit="subCollect">
  173. <button class='bnt cart-color' formType="submit">收藏</button>
  174. </form>
  175. <form @submit="subDel">
  176. <button class='bnt' formType="submit">删除</button>
  177. </form>
  178. </view>
  179. </view>
  180. </view>
  181. <!-- 产品属性显示 -->
  182. <productWindow :attr="attr" :isShow='1' :iSplus='1' :iScart='1' :storeInfo="storeInfo" :is_vip="is_vip" @myevent="onMyEvent" @ChangeAttr="ChangeAttr"
  183. @ChangeCartNum="ChangeCartNum" @attrVal="attrVal" @iptCartNum="iptCartNum" @goCat="reGoCat"
  184. id='product-window'></productWindow>
  185. <!-- 优惠明细显示 -->
  186. <cartDiscount :discountInfo="discountInfo" @myevent="myDiscount"></cartDiscount>
  187. <view class="uni-p-b-98"></view>
  188. <pageFooter @newDataStatus="newDataStatus"></pageFooter>
  189. <!-- 优惠券列表弹框显示 -->
  190. <couponListWindow :coupon="coupon" v-if="coupon" @ChangCouponsClone="ChangCouponsClone"
  191. @ChangCouponsUseState="ChangCouponsUseState" @tabCouponType="tabCouponType">
  192. </couponListWindow>
  193. <!-- #ifdef MP -->
  194. <!-- <authorize v-if="isShowAuth" @authColse="authColse" @onLoadFun="onLoadFun"></authorize> -->
  195. <!-- #endif -->
  196. </view>
  197. </template>
  198. <script>
  199. // #ifdef APP-PLUS || MP
  200. let sysHeight = uni.getSystemInfoSync().statusBarHeight;
  201. // #endif
  202. // #ifdef H5
  203. let sysHeight = 0
  204. // #endif
  205. import {
  206. getCartList,
  207. getCartCounts,
  208. changeCartNum,
  209. cartDel,
  210. getResetCart,
  211. cartCompute
  212. } from '@/api/order.js';
  213. import {
  214. setCouponReceive,
  215. getCoupons
  216. } from '@/api/api.js';
  217. import {
  218. getProductHot,
  219. collectAll,
  220. getProductDetail
  221. } from '@/api/store.js';
  222. import {
  223. toLogin
  224. } from '@/libs/login.js';
  225. import {
  226. mapGetters
  227. } from "vuex";
  228. import recommend from '@/components/recommend';
  229. import productWindow from '@/components/productWindow';
  230. import cartDiscount from '@/components/cartDiscount';
  231. import couponListWindow from '@/components/couponListWindow';
  232. import pageFooter from '@/components/pageFooter/index.vue'
  233. import colors from "@/mixins/color";
  234. import {HTTP_REQUEST_URL} from '@/config/app';
  235. import {Debounce} from '@/utils/validate.js'
  236. export default {
  237. components: {
  238. couponListWindow,
  239. pageFooter,
  240. recommend,
  241. productWindow,
  242. cartDiscount
  243. },
  244. mixins: [colors],
  245. data() {
  246. return {
  247. isFooter:false,
  248. isTips:false,
  249. //属性是否打开
  250. coupon: {
  251. coupon: false,
  252. type: -1,
  253. list: [],
  254. count: [],
  255. goFrom:1
  256. },
  257. discountInfo:{
  258. discount:false,
  259. deduction:{},
  260. coupon:{}
  261. },
  262. goodsHidden: true,
  263. footerswitch: true,
  264. hostProduct: [],
  265. cartList: {
  266. valid: [],
  267. invalid: []
  268. },
  269. isAllSelect: false, //全选
  270. selectValue: [], //选中的数据
  271. selectCountPrice: 0.00,
  272. isAuto: false, //没有授权的不会自动授权
  273. isShowAuth: false, //是否隐藏授权
  274. hotScroll: false,
  275. hotPage: 1,
  276. hotLimit: 10,
  277. loading: false,
  278. loadend: false,
  279. loadTitle: '没有更多内容啦~', //提示语
  280. page: 1,
  281. limit: 20,
  282. loadingInvalid: false,
  283. loadendInvalid: false,
  284. loadTitleInvalid: '加载更多', //提示语
  285. pageInvalid: 1,
  286. limitInvalid: 20,
  287. attr: {
  288. cartAttr: false,
  289. productAttr: [],
  290. productSelect: {}
  291. },
  292. productValue: [], //系统属性
  293. storeInfo: {},
  294. attrValue: '', //已选属性
  295. attrTxt: '请选择', //属性页面提示
  296. cartId: 0,
  297. product_id: 0,
  298. sysHeight: sysHeight,
  299. footerSee: false,
  300. isCart: 0,
  301. imgHost:HTTP_REQUEST_URL,
  302. is_vip: 0 //是否是会员
  303. };
  304. },
  305. computed: mapGetters(['isLogin','cartNum']),
  306. onLoad: function(options) {
  307. this.hotPage = 1;
  308. this.hostProduct = [],
  309. this.hotScroll = false,
  310. this.getHostProduct();
  311. },
  312. onShow: function() {
  313. uni.setStorageSync('form_type_cart', 1);
  314. uni.pageScrollTo({
  315. duration:0,
  316. scrollTop:0
  317. })
  318. if (this.isLogin == true){
  319. this.resetData();
  320. }else{
  321. toLogin()
  322. }
  323. },
  324. methods: {
  325. onLoadFun(){
  326. this.resetData();
  327. },
  328. resetData(){
  329. this.loadend = false;
  330. this.page = 1;
  331. this.cartList.valid = [];
  332. // 1:表示只有在onShow里面调用;
  333. this.getCartList();
  334. this.loadendInvalid = false;
  335. this.pageInvalid = 1;
  336. this.cartList.invalid = [];
  337. this.goodsHidden = true;
  338. this.footerswitch = true;
  339. this.hotLimit = 10;
  340. this.isAllSelect = false; //全选
  341. this.selectValue = []; //选中的数据
  342. this.selectCountPrice = 0.00;
  343. this.isShowAuth = false;
  344. },
  345. newDataStatus(val){
  346. this.isFooter = val;
  347. },
  348. tabCouponType: function(type) {
  349. this.$set(this.coupon, 'type', type);
  350. this.getCouponList(type);
  351. },
  352. ChangCouponsUseState(index) {
  353. let that = this;
  354. that.coupon.list[index].is_use = true;
  355. that.$set(that.coupon, 'list', that.coupon.list);
  356. that.$set(that.coupon, 'coupon', false);
  357. },
  358. ChangCouponsClone: function() {
  359. this.$set(this.coupon, 'coupon', false);
  360. },
  361. /**
  362. * 获取优惠券
  363. *
  364. */
  365. getCouponList(type) {
  366. let that = this,
  367. obj = {
  368. page: 1,
  369. limit: 20,
  370. product_id: that.id
  371. };
  372. if (type !== undefined || type !== null) {
  373. obj.type = type;
  374. }
  375. getCoupons(obj).then(res => {
  376. that.$set(that.coupon, 'count', res.data.count);
  377. if (type === undefined || type === null) {
  378. let count = [...that.coupon.count],
  379. indexs = '';
  380. let index = count.findIndex(item => item);
  381. let delCount = that.coupon.count,
  382. newDelCount = [];
  383. let countIndex = 0;
  384. delCount.forEach((item, index) => {
  385. if (item === 0) {
  386. countIndex = index;
  387. } else {
  388. newDelCount.push(item)
  389. }
  390. });
  391. if (newDelCount.length == 3) {
  392. indexs = 2;
  393. } else if (newDelCount.length == 2) {
  394. if (countIndex === 2) {
  395. indexs = 1;
  396. } else {
  397. indexs = 2;
  398. }
  399. } else {
  400. indexs = delCount.findIndex(item => item === count[index]);
  401. }
  402. that.$set(that.coupon, 'type', indexs);
  403. that.getCouponList(indexs);
  404. } else {
  405. that.$set(that.coupon, 'list', res.data.list);
  406. }
  407. });
  408. },
  409. /**
  410. * 打开优惠券插件
  411. */
  412. couponTap: function() {
  413. let that = this;
  414. that.getCouponList();
  415. that.$set(that.coupon, 'coupon', true);
  416. },
  417. goCollect(item){
  418. uni.navigateTo({
  419. url: `/pages/goods/goods_list/index?sid=0&title=默认&promotions_type=${item.promotions_type}&promotions_id=${item.id}`
  420. })
  421. },
  422. myDiscount(){
  423. this.discountInfo.discount = false;
  424. },
  425. discountTap(){
  426. this.coupon.coupon=false;
  427. this.discountInfo.discount = !this.discountInfo.discount;
  428. },
  429. // 授权关闭
  430. authColse: function(e) {
  431. this.isShowAuth = e;
  432. },
  433. // 修改购物车
  434. reGoCat: function() {
  435. let that = this,
  436. productSelect = that.productValue[this.attrValue];
  437. //如果有属性,没有选择,提示用户选择
  438. if (
  439. that.attr.productAttr.length &&
  440. productSelect === undefined
  441. ){
  442. return that.$util.Tips({
  443. title: "产品库存不足,请选择其它"
  444. });
  445. }
  446. let q = {
  447. id: that.cartId,
  448. product_id: that.product_id,
  449. num: that.attr.productSelect.cart_num,
  450. unique: that.attr.productSelect !== undefined ?
  451. that.attr.productSelect.unique : ""
  452. };
  453. getResetCart(q)
  454. .then(function(res) {
  455. that.attr.cartAttr = false;
  456. that.$util.Tips({
  457. title: "添加购物车成功",
  458. success: () => {
  459. that.loadend = false;
  460. that.page = 1;
  461. that.cartList.valid = [];
  462. that.getCartList();
  463. that.getCartNum();
  464. }
  465. });
  466. })
  467. .catch(res => {
  468. return that.$util.Tips({
  469. title: res.msg
  470. });
  471. });
  472. },
  473. onMyEvent: function() {
  474. this.$set(this.attr, 'cartAttr', false);
  475. },
  476. // 点击切换属性
  477. cartAttr(item){
  478. this.isCart = 1;
  479. this.getGoodsDetails(item);
  480. },
  481. // 重选
  482. reElection: function(item) {
  483. this.isCart = 0;
  484. this.getGoodsDetails(item)
  485. },
  486. /**
  487. * 获取产品详情
  488. *
  489. */
  490. getGoodsDetails: function(item) {
  491. uni.showLoading({
  492. title: '加载中',
  493. mask: true
  494. });
  495. let that = this;
  496. that.cartId = item.id;
  497. that.product_id = item.product_id;
  498. getProductDetail(item.product_id).then(res => {
  499. uni.hideLoading();
  500. that.attr.cartAttr = true;
  501. let storeInfo = res.data.storeInfo;
  502. that.$set(that, 'storeInfo', storeInfo);
  503. that.$set(that, 'is_vip', res.data.storeInfo.is_vip);
  504. that.$set(that.attr, 'productAttr', res.data.productAttr);
  505. that.$set(that, 'productValue', res.data.productValue);
  506. that.DefaultSelect();
  507. }).catch(err => {
  508. uni.hideLoading();
  509. })
  510. },
  511. /**
  512. * 属性变动赋值
  513. *
  514. */
  515. ChangeAttr: function(res) {
  516. let productSelect = this.productValue[res];
  517. if (productSelect && productSelect.stock > 0) {
  518. this.$set(this.attr.productSelect, "image", productSelect.image);
  519. this.$set(this.attr.productSelect, "price", productSelect.price);
  520. this.$set(this.attr.productSelect, "stock", productSelect.stock);
  521. this.$set(this.attr.productSelect, "unique", productSelect.unique);
  522. this.$set(this.attr.productSelect, "cart_num", 1);
  523. this.$set(this.attr.productSelect, 'vip_price', productSelect.vip_price);
  524. this.$set(this, "attrValue", res);
  525. this.$set(this, "attrTxt", "已选择");
  526. } else {
  527. this.$set(this.attr.productSelect, "image", this.storeInfo.image);
  528. this.$set(this.attr.productSelect, "price", this.storeInfo.price);
  529. this.$set(this.attr.productSelect, "stock", 0);
  530. this.$set(this.attr.productSelect, "unique", "");
  531. this.$set(this.attr.productSelect, "cart_num", 0);
  532. this.$set(this.attr.productSelect, 'vip_price', this.storeInfo.vip_price);
  533. this.$set(this, "attrValue", "");
  534. this.$set(this, "attrTxt", "请选择");
  535. }
  536. },
  537. /**
  538. * 默认选中属性
  539. *
  540. */
  541. DefaultSelect: function() {
  542. let productAttr = this.attr.productAttr;
  543. let value = [],stock = 0,attrValue = [];
  544. for (var key in this.productValue) {
  545. if (this.productValue[key].stock > 0) {
  546. value = this.attr.productAttr.length ? key.split(",") : [];
  547. break;
  548. }
  549. }
  550. //isCart 1切换属性 0为重选
  551. if (this.isCart) {
  552. //购物车默认打开时,随着选中的属性改变
  553. // let attrValue = [];
  554. this.cartList.valid.forEach(j=>{
  555. j.valid.forEach(item=>{
  556. if (item.id == this.cartId) {
  557. attrValue = item.productInfo.attrInfo.suk.split(",");
  558. }
  559. })
  560. })
  561. let key = attrValue.join(",");
  562. stock = this.productValue[key].stock;
  563. for (let i = 0; i < productAttr.length; i++) {
  564. this.$set(productAttr[i], "index", stock?attrValue[i]:value[i]);
  565. }
  566. } else {
  567. for (let i = 0; i < productAttr.length; i++) {
  568. this.$set(productAttr[i], "index", value[i]);
  569. }
  570. }
  571. //sort();排序函数:数字-英文-汉字;
  572. let productSelect = this.productValue[(this.isCart&&stock)?attrValue.join(","):value.join(",")];
  573. if (productSelect && productAttr.length) {
  574. this.$set(
  575. this.attr.productSelect,
  576. "store_name",
  577. this.storeInfo.store_name
  578. );
  579. this.$set(this.attr.productSelect, "image", productSelect.image);
  580. this.$set(this.attr.productSelect, "price", productSelect.price);
  581. this.$set(this.attr.productSelect, "stock", productSelect.stock);
  582. this.$set(this.attr.productSelect, "unique", productSelect.unique);
  583. this.$set(this.attr.productSelect, "cart_num", 1);
  584. this.$set(this, "attrValue", value.join(","));
  585. this.$set(this.attr.productSelect, 'vip_price', productSelect.vip_price);
  586. this.$set(this, "attrTxt", "已选择");
  587. } else if (!productSelect && productAttr.length) {
  588. this.$set(
  589. this.attr.productSelect,
  590. "store_name",
  591. this.storeInfo.store_name
  592. );
  593. this.$set(this.attr.productSelect, "image", this.storeInfo.image);
  594. this.$set(this.attr.productSelect, "price", this.storeInfo.price);
  595. this.$set(this.attr.productSelect, "stock", 0);
  596. this.$set(this.attr.productSelect, "unique", "");
  597. this.$set(this.attr.productSelect, "cart_num", 0);
  598. this.$set(this.attr.productSelect, 'vip_price', productSelect.vip_price);
  599. this.$set(this, "attrValue", "");
  600. this.$set(this, "attrTxt", "请选择");
  601. } else if (!productSelect && !productAttr.length) {
  602. this.$set(
  603. this.attr.productSelect,
  604. "store_name",
  605. this.storeInfo.store_name
  606. );
  607. this.$set(this.attr.productSelect, "image", this.storeInfo.image);
  608. this.$set(this.attr.productSelect, "price", this.storeInfo.price);
  609. this.$set(this.attr.productSelect, "stock", this.storeInfo.stock);
  610. this.$set(
  611. this.attr.productSelect,
  612. "unique",
  613. this.storeInfo.unique || ""
  614. );
  615. this.$set(this.attr.productSelect, "cart_num", 1);
  616. this.$set(this.attr.productSelect, 'vip_price', productSelect.vip_price);
  617. this.$set(this, "attrValue", "");
  618. this.$set(this, "attrTxt", "请选择");
  619. }
  620. },
  621. attrVal(val) {
  622. this.$set(this.attr.productAttr[val.indexw], 'index', this.attr.productAttr[val.indexw].attr_values[val
  623. .indexn]);
  624. },
  625. /**
  626. * 购物车数量加和数量减
  627. *
  628. */
  629. ChangeCartNum: function(changeValue) {
  630. //changeValue:是否 加|减
  631. //获取当前变动属性
  632. let productSelect = this.productValue[this.attrValue];
  633. //如果没有属性,赋值给商品默认库存
  634. if (productSelect === undefined && !this.attr.productAttr.length)
  635. productSelect = this.attr.productSelect;
  636. //无属性值即库存为0;不存在加减;
  637. if (productSelect === undefined) return;
  638. let stock = productSelect.stock || 0;
  639. let num = this.attr.productSelect;
  640. if (changeValue) {
  641. num.cart_num++;
  642. if (num.cart_num > stock) {
  643. this.$set(this.attr.productSelect, "cart_num", stock ? stock : 1);
  644. this.$set(this, "cart_num", stock ? stock : 1);
  645. }
  646. } else {
  647. num.cart_num--;
  648. if (num.cart_num < 1) {
  649. this.$set(this.attr.productSelect, "cart_num", 1);
  650. this.$set(this, "cart_num", 1);
  651. }
  652. }
  653. },
  654. /**
  655. * 购物车手动填写
  656. *
  657. */
  658. iptCartNum: function(e) {
  659. this.$set(this.attr.productSelect, 'cart_num', e);
  660. },
  661. subDel: function(event) {
  662. let that = this,
  663. selectValue = that.selectValue,
  664. storeId = uni.getStorageSync('user_store_id');
  665. if (selectValue.length > 0)
  666. cartDel(selectValue,storeId).then(res => {
  667. that.loadend = false;
  668. that.page = 1;
  669. that.cartList.valid = [];
  670. that.getCartList();
  671. that.getCartNum();
  672. });
  673. else
  674. return that.$util.Tips({
  675. title: '请选择产品'
  676. });
  677. },
  678. getSelectValueProductId: function() {
  679. let that = this;
  680. let validList = that.cartList.valid;
  681. let selectValue = that.selectValue;
  682. let productId = [];
  683. if (selectValue.length > 0) {
  684. for (let j in validList) {
  685. for (let index in validList[j].valid){
  686. if (that.inArray(validList[j].valid[index].id, selectValue)) {
  687. productId.push(validList[j].valid[index].product_id);
  688. }
  689. }
  690. }
  691. };
  692. return productId;
  693. },
  694. subCollect: function(event) {
  695. let that = this,
  696. selectValue = that.selectValue;
  697. if (selectValue.length > 0) {
  698. let selectValueProductId = that.getSelectValueProductId();
  699. collectAll(that.getSelectValueProductId().join(',')).then(res => {
  700. return that.$util.Tips({
  701. title: res.msg,
  702. icon: 'success'
  703. });
  704. }).catch(err => {
  705. return that.$util.Tips({
  706. title: err
  707. });
  708. });
  709. } else {
  710. return that.$util.Tips({
  711. title: '请选择产品'
  712. });
  713. }
  714. },
  715. subOrder(event) {
  716. let that = this,
  717. selectValue = that.selectValue,delivery_type = 1,storeId = 0
  718. if (selectValue.length > 0) {
  719. that.cartList.valid.forEach(item=>{
  720. item.valid.forEach(j=>{
  721. if(j.id == selectValue[0]){
  722. let deliverySort = j.productInfo.delivery_type.sort((x,y)=>x - y);
  723. delivery_type = deliverySort[0];
  724. storeId = j.productInfo.type == 1?j.productInfo.relation_id:0
  725. }
  726. })
  727. })
  728. let coupon = this.discountInfo.coupon;
  729. if(Object.prototype.toString.call(coupon) === '[object Object]' && !coupon.used){
  730. setCouponReceive(this.discountInfo.coupon.id).then(res=>{
  731. uni.navigateTo({
  732. url: '/pages/goods/order_confirm/index?cartId=' + selectValue.join(',') + '&couponId=' + res.data.id +'&couponTitle='+ coupon.coupon_title+'&delivery_type='+delivery_type + '&store_id=' + storeId
  733. });
  734. }).catch(err=>{
  735. return that.$util.Tips({
  736. title: err
  737. });
  738. })
  739. }else{
  740. let url = '';
  741. if(Object.prototype.toString.call(coupon) === '[object Array]'){
  742. url = '/pages/goods/order_confirm/index?cartId=' + selectValue.join(',')+'&delivery_type='+delivery_type+ '&store_id=' + storeId
  743. }else{
  744. url = '/pages/goods/order_confirm/index?cartId=' + selectValue.join(',') + '&couponId=' + coupon.used.id +'&couponTitle='+ coupon.coupon_title+'&delivery_type='+delivery_type+ '&store_id=' + storeId
  745. }
  746. uni.navigateTo({
  747. url: url
  748. });
  749. }
  750. } else {
  751. return that.$util.Tips({
  752. title: '请选择产品'
  753. });
  754. }
  755. },
  756. checkboxAllChange: function(event) {
  757. let value = event.detail.value;
  758. if (value.length > 0) {
  759. this.setAllSelectValue(1)
  760. } else {
  761. this.setAllSelectValue(0)
  762. }
  763. },
  764. setAllSelectValue: function(status) {
  765. let that = this;
  766. let selectValue = [];
  767. let valid = that.cartList.valid;
  768. if (valid.length > 0) {
  769. valid.forEach(j=>{
  770. j.valid.forEach(item=>{
  771. if (status) {
  772. if (that.footerswitch) {
  773. if (item.attrStatus && !item.is_gift) {
  774. item.checked = true;
  775. selectValue.push(item.id);
  776. } else {
  777. item.checked = false;
  778. }
  779. } else {
  780. item.checked = true;
  781. selectValue.push(item.id);
  782. }
  783. that.isAllSelect = true;
  784. } else {
  785. item.checked = false;
  786. that.isAllSelect = false;
  787. }
  788. })
  789. })
  790. that.$set(that.cartList, 'valid', valid);
  791. that.selectValue = selectValue;
  792. that.switchSelect();
  793. }
  794. },
  795. checkboxChange: function(event) {
  796. let that = this;
  797. let value = event.detail.value;
  798. let valid = that.cartList.valid;
  799. let arr1 = [];
  800. let arr2 = [];
  801. let arr3 = [];
  802. let len = 0;
  803. valid.forEach(j=>{
  804. j.valid.forEach(item=>{
  805. len = len + 1;
  806. if (that.inArray(item.id, value)) {
  807. if (that.footerswitch) {
  808. if (item.attrStatus && !item.is_gift) {
  809. item.checked = true;
  810. arr1.push(item);
  811. } else {
  812. item.checked = false;
  813. }
  814. } else {
  815. item.checked = true;
  816. arr1.push(item);
  817. }
  818. } else {
  819. item.checked = false;
  820. arr2.push(item);
  821. }
  822. })
  823. })
  824. if (that.footerswitch) {
  825. arr3 = arr2.filter(item => !item.attrStatus || item.is_gift);
  826. }
  827. that.$set(that.cartList, 'valid', valid);
  828. that.isAllSelect = len === arr1.length + arr3.length;
  829. that.selectValue = value;
  830. that.switchSelect();
  831. },
  832. inArray: function(search, array) {
  833. for (let i in array) {
  834. if (array[i] == search) {
  835. return true;
  836. }
  837. }
  838. return false;
  839. },
  840. switchSelect: function() {
  841. let that = this;
  842. let validList = that.cartList.valid;
  843. let selectValue = that.selectValue;
  844. let selectCountPrice = 0.00;
  845. let cartId = [];
  846. if (selectValue.length < 1) {
  847. that.selectCountPrice = selectCountPrice;
  848. } else {
  849. for (let j in validList) {
  850. for(let index in validList[j].valid){
  851. if (that.inArray(validList[j].valid[index].id, selectValue)) {
  852. cartId.push(validList[j].valid[index].id)
  853. selectCountPrice = that.$util.$h.Add(selectCountPrice, that.$util.$h.Mul(validList[j].valid[index]
  854. .cart_num, validList[j].valid[
  855. index].truePrice))
  856. }
  857. }
  858. }
  859. that.selectCountPrice = selectCountPrice;
  860. }
  861. let data = {cartId:cartId.join(',')}
  862. if(cartId.length){
  863. this.getCartCompute(data);
  864. }
  865. },
  866. /**
  867. * 购物车手动填写
  868. *
  869. */
  870. // iptCartNum: function(index) {
  871. // let item = this.cartList.valid[index];
  872. // if (item.cart_num) {
  873. // this.setCartNum(item.id, item.cart_num);
  874. // }
  875. // this.switchSelect();
  876. // },
  877. // blurInput: function(index) {
  878. // let item = this.cartList.valid[index];
  879. // if (!item.cart_num) {
  880. // item.cart_num = 1;
  881. // this.$set(this.cartList, 'valid', this.cartList.valid)
  882. // }
  883. // },
  884. subCart: Debounce(function(jindex,index) {
  885. let that = this;
  886. let status = false;
  887. let item = that.cartList.valid[jindex].valid[index];
  888. item.cart_num = Number(item.cart_num) - 1;
  889. if (item.cart_num < 1) status = true;
  890. if (item.cart_num <= 1) {
  891. item.cart_num = 1;
  892. item.numSub = true;
  893. } else {
  894. item.numSub = false;
  895. item.numAdd = false;
  896. }
  897. if (false == status) {
  898. that.setCartNum(item.id, item.cart_num, function(data) {
  899. that.cartList.valid[jindex].valid[index] = item;
  900. that.getCartNum();
  901. // that.switchSelect();
  902. that.loadend = false;
  903. that.page = 1;
  904. // that.cartList.valid = [];
  905. that.getCartList();
  906. });
  907. }
  908. }),
  909. addCart: Debounce(function(jindex,index,obj) {
  910. if(obj.numAdd || (obj.productInfo.limit_num>0 && obj.cart_num>=obj.productInfo.limit_num)){
  911. return false
  912. }
  913. let that = this;
  914. let item = that.cartList.valid[jindex].valid[index];
  915. item.cart_num = Number(item.cart_num) + 1;
  916. let productInfo = item.productInfo;
  917. if (productInfo.hasOwnProperty('attrInfo') && item.cart_num >= item.productInfo.attrInfo.stock) {
  918. item.cart_num = item.productInfo.attrInfo.stock;
  919. item.numAdd = true;
  920. item.numSub = false;
  921. } else {
  922. item.numAdd = false;
  923. item.numSub = false;
  924. }
  925. that.setCartNum(item.id, item.cart_num, function(data) {
  926. that.cartList.valid[jindex].valid[index] = item;
  927. that.getCartNum();
  928. // that.switchSelect();
  929. that.loadend = false;
  930. that.page = 1;
  931. // that.cartList.valid = [];
  932. that.getCartList();
  933. });
  934. }),
  935. setCartNum(cartId, cartNum, successCallback) {
  936. let that = this;
  937. changeCartNum(cartId, cartNum).then(res => {
  938. successCallback && successCallback(res.data);
  939. });
  940. },
  941. getCartNum: function() {
  942. let that = this;
  943. let id = uni.getStorageSync('user_store_id') || 0;
  944. getCartCounts(0,id).then(res => {
  945. this.$store.commit('indexData/setCartNum', res.data.count)
  946. if (res.data.count > 0) {
  947. uni.setTabBarBadge({
  948. index: 3,
  949. text: res.data.count>99?'99+':res.data.count+''
  950. })
  951. } else {
  952. uni.hideTabBarRedDot({
  953. index: 3
  954. })
  955. }
  956. });
  957. },
  958. // 购物车计算
  959. getCartCompute(cartId){
  960. cartCompute(cartId).then(res=>{
  961. this.discountInfo.coupon = res.data.coupon;
  962. this.discountInfo.deduction = res.data.deduction;
  963. }).catch(err=>{
  964. this.$util.Tips({
  965. title: err
  966. })
  967. })
  968. },
  969. getCartList: function() {
  970. let that = this;
  971. if (this.loadend) return false;
  972. if (this.loading) return false;
  973. let data = {
  974. page: that.page,
  975. limit: that.limit,
  976. status: 1,
  977. latitude: uni.getStorageSync('user_latitude'),
  978. longitude: uni.getStorageSync('user_longitude'),
  979. store_id: uni.getStorageSync('user_store_id'),
  980. }
  981. getCartList(data).then(res => {
  982. this.getInvalidList();
  983. // this.discountInfo.deduction = res.data.deduction;
  984. // this.discountInfo.coupon = res.data.coupon;
  985. this.isTips = false;
  986. let cartList = res.data.valid;
  987. let valid = cartList.map(x =>{
  988. return {
  989. valid : x.cart,
  990. promotions : x.promotions
  991. }
  992. })
  993. let loadend = valid.length < that.limit;
  994. // let validList = that.$util.SplitArray(valid, that.cartList.valid);
  995. let validList = valid;
  996. let numSub = [{
  997. numSub: true
  998. }, {
  999. numSub: false
  1000. }];
  1001. let numAdd = [{
  1002. numAdd: true
  1003. }, {
  1004. numAdd: false
  1005. }],
  1006. selectValue = [];
  1007. if (validList.length > 0) {
  1008. for (let j in validList) {
  1009. if(validList[j].promotions.length>1){
  1010. that.isTips = true;
  1011. }
  1012. for (let index in validList[j].valid){
  1013. if (validList[j].valid[index].cart_num == 1) {
  1014. validList[j].valid[index].numSub = true;
  1015. } else {
  1016. validList[j].valid[index].numSub = false;
  1017. }
  1018. let productInfo = validList[j].valid[index].productInfo;
  1019. if (productInfo.hasOwnProperty('attrInfo') && validList[j].valid[index].cart_num == validList[j].valid[index].productInfo.attrInfo.stock) {
  1020. validList[j].valid[index].numAdd = true;
  1021. } else if (validList[j].valid[index].cart_num == validList[j].valid[index].productInfo.stock) {
  1022. validList[j].valid[index].numAdd = true;
  1023. } else {
  1024. validList[j].valid[index].numAdd = false;
  1025. }
  1026. if(validList[j].valid[index].attrStatus && !validList[j].valid[index].is_gift){
  1027. validList[j].valid[index].checked = true;
  1028. selectValue.push(validList[j].valid[index].id);
  1029. }else if(!this.footerswitch){
  1030. validList[j].valid[index].checked = true;
  1031. }else{
  1032. validList[j].valid[index].checked = false;
  1033. }
  1034. }
  1035. }
  1036. }
  1037. that.$set(that.cartList, 'valid', res.data.valid.length?validList:[]);
  1038. that.loadend = true;
  1039. that.loadTitle = loadend ? '没有更多内容啦~' : '加载更多';
  1040. that.page = that.page + 1;
  1041. that.loading = false;
  1042. // that.goodsHidden = cartList.valid.length <= 0 ? false : true;
  1043. that.selectValue = selectValue;
  1044. let newArr = [],newAttr=[];
  1045. validList.forEach(j=>{
  1046. j.valid.forEach(item=>{
  1047. if(item.attrStatus && !item.is_gift){
  1048. newArr.push(item)
  1049. }
  1050. let obj = {
  1051. id:item.product_id,
  1052. num:item.cart_num
  1053. }
  1054. newAttr.push(obj)
  1055. })
  1056. })
  1057. that.isAllSelect = newArr.length == selectValue.length && newArr.length;
  1058. that.switchSelect();
  1059. uni.$emit('newAttrNum',newAttr)
  1060. }).catch(function(err) {
  1061. that.loading = false;
  1062. that.loadTitle = '加载失败';
  1063. that.$util.Tips({
  1064. title: err
  1065. })
  1066. })
  1067. },
  1068. getInvalidList: function() {
  1069. let that = this;
  1070. if (this.loadendInvalid) return false;
  1071. if (this.loadingInvalid) return false;
  1072. let data = {
  1073. page: that.pageInvalid,
  1074. limit: that.limitInvalid,
  1075. status: 0,
  1076. store_id: uni.getStorageSync('user_store_id'),
  1077. }
  1078. getCartList(data).then(res => {
  1079. let cartList = res.data,
  1080. invalid = cartList.invalid,
  1081. loadendInvalid = invalid.length < that.limitInvalid;
  1082. // let invalidList = that.$util.SplitArray(invalid, that.cartList.invalid);
  1083. let invalidList = invalid;
  1084. that.$set(that.cartList, 'invalid', invalidList);
  1085. that.loadendInvalid = loadendInvalid;
  1086. that.loadTitleInvalid = loadendInvalid ? '没有更多内容啦~' : '加载更多';
  1087. that.pageInvalid = that.pageInvalid + 1;
  1088. that.loadingInvalid = false;
  1089. }).catch(res => {
  1090. that.loadingInvalid = false;
  1091. that.loadTitleInvalid = '加载更多';
  1092. })
  1093. },
  1094. getHostProduct: function() {
  1095. let that = this;
  1096. if (that.hotScroll) return
  1097. getProductHot(
  1098. that.hotPage,
  1099. that.hotLimit,
  1100. ).then(res => {
  1101. that.hotPage++
  1102. that.hotScroll = res.data.length < that.hotLimit
  1103. that.hostProduct = that.hostProduct.concat(res.data)
  1104. });
  1105. },
  1106. goodsOpen: function() {
  1107. let that = this;
  1108. that.goodsHidden = !that.goodsHidden;
  1109. },
  1110. manage: function() {
  1111. let that = this;
  1112. that.footerswitch = !that.footerswitch;
  1113. let arr1 = [];
  1114. let arr2 = [];
  1115. let len = 0;
  1116. that.cartList.valid.forEach(j=>{
  1117. j.valid.forEach(item=>{
  1118. len = len+1;
  1119. if (that.footerswitch) {
  1120. if (item.attrStatus && !item.is_gift) {
  1121. if (item.checked) {
  1122. arr1.push(item.id);
  1123. }
  1124. } else {
  1125. item.checked = false;
  1126. arr2.push(item);
  1127. }
  1128. } else {
  1129. if (item.checked) {
  1130. arr1.push(item.id);
  1131. }
  1132. }
  1133. })
  1134. })
  1135. if (that.footerswitch) {
  1136. that.isAllSelect = len === arr1.length + arr2.length;
  1137. } else {
  1138. that.isAllSelect = len === arr1.length;
  1139. }
  1140. that.selectValue = arr1;
  1141. if(that.footerswitch){
  1142. that.switchSelect();
  1143. }
  1144. },
  1145. unsetCart: function() {
  1146. let that = this,
  1147. ids = [],
  1148. storeId = uni.getStorageSync('user_store_id');
  1149. for (let i = 0, len = that.cartList.invalid.length; i < len; i++) {
  1150. ids.push(that.cartList.invalid[i].id);
  1151. }
  1152. cartDel(ids,storeId).then(res => {
  1153. that.$util.Tips({
  1154. title: '清除成功'
  1155. });
  1156. that.$set(that.cartList, 'invalid', []);
  1157. that.getCartNum();
  1158. }).catch(res => {
  1159. });
  1160. }
  1161. },
  1162. onReachBottom() {
  1163. let that = this;
  1164. // if (that.loadend) {
  1165. // that.getInvalidList();
  1166. // } else {
  1167. // that.getCartList();
  1168. // }
  1169. if(that.cartList.invalid.length){
  1170. that.getInvalidList();
  1171. }
  1172. if (that.cartList.valid.length == 0 && that.cartList.invalid.length == 0) {
  1173. that.getHostProduct();
  1174. }
  1175. }
  1176. }
  1177. </script>
  1178. <style scoped lang="scss">
  1179. .sys-title {
  1180. z-index: 10;
  1181. position: fixed;
  1182. height: 40px;
  1183. line-height: 40px;
  1184. font-size: 34rpx;
  1185. color: #333;
  1186. background-color: #fff;
  1187. text-align: center;
  1188. left:0;
  1189. width: 100%;
  1190. }
  1191. .sys-head {
  1192. background-color: #fff;
  1193. position: fixed;
  1194. left:0;
  1195. top:0;
  1196. width: 100%;
  1197. z-index: 10;
  1198. }
  1199. .shoppingCart .labelNav {
  1200. height: 38px;
  1201. padding: 0 30rpx;
  1202. font-size: 22rpx;
  1203. color: #8c8c8c;
  1204. position: fixed;
  1205. left: 0;
  1206. top: 0;
  1207. width: 100%;
  1208. box-sizing: border-box;
  1209. background-color: #f5f5f5;
  1210. z-index: 5;
  1211. }
  1212. .shoppingCart .labelNav .item .iconfont {
  1213. font-size: 25rpx;
  1214. margin-right: 10rpx;
  1215. }
  1216. .shoppingCart .nav {
  1217. width: 100%;
  1218. height: 40px;
  1219. background-color: #fff;
  1220. padding: 0 30rpx;
  1221. box-sizing: border-box;
  1222. font-size: 28rpx;
  1223. color: #282828;
  1224. position: fixed;
  1225. left: 0;
  1226. z-index: 5;
  1227. }
  1228. .shoppingCart .nav .num {
  1229. margin-right: 12rpx;
  1230. }
  1231. .shoppingCart .nav .administrate {
  1232. font-size: 26rpx;
  1233. color: #666;
  1234. width: 110rpx;
  1235. height: 46rpx;
  1236. border-radius: 6rpx;
  1237. }
  1238. .shoppingCart .noCart {
  1239. margin-top: 171rpx;
  1240. /* #ifdef APP-PLUS */
  1241. margin-top: 78px;
  1242. /* #endif */
  1243. background-color: #fff;
  1244. padding-top: 0.1rpx;
  1245. }
  1246. .shoppingCart .noCart .pictrue {
  1247. margin: 78rpx auto 56rpx auto;
  1248. text-align: center;
  1249. color: #999;
  1250. }
  1251. .shoppingCart .noCart .pictrue image {
  1252. width: 414rpx;
  1253. height: 304rpx;
  1254. display: block;
  1255. margin: 0 auto;
  1256. }
  1257. .shoppingCart .list {
  1258. margin: 0 20rpx 0 20rpx;
  1259. border-radius: 12rpx;
  1260. background-color: #fff;
  1261. }
  1262. .shoppingCart .list .title{
  1263. height: 74rpx;
  1264. padding: 0 24rpx;
  1265. font-size: 22rpx;
  1266. color: #333;
  1267. border-bottom: 1rpx solid #eee;
  1268. }
  1269. .shoppingCart .list .title .iconfont{
  1270. font-size: 18rpx;
  1271. }
  1272. .shoppingCart .list .title .label{
  1273. border-radius: 4rpx;
  1274. padding: 2rpx 8rpx;
  1275. background-color: var(--view-minorColorT);
  1276. font-size: 20rpx;
  1277. color: var(--view-theme);
  1278. margin-right: 8rpx;
  1279. }
  1280. .shoppingCart .list .item {
  1281. padding: 25rpx 30rpx;
  1282. position: relative;
  1283. }
  1284. .shoppingCart .list .item .evaluate{
  1285. font-size: 20rpx;
  1286. color: var(--view-theme);
  1287. margin-left: 248rpx;
  1288. .num{
  1289. font-size: 25rpx;
  1290. }
  1291. }
  1292. .shoppingCart .list .item::after{
  1293. position: absolute;
  1294. content: " ";
  1295. width: 618rpx;
  1296. height: 1px;
  1297. background: #EEEEEE;
  1298. bottom: 0;
  1299. right: 0;
  1300. }
  1301. .shoppingCart .list .item .picTxt {
  1302. width: 585rpx;
  1303. position: relative;
  1304. }
  1305. .shoppingCart .list .item .picTxt .pictrue {
  1306. width: 160rpx;
  1307. height: 160rpx;
  1308. border-radius: 6rpx;
  1309. }
  1310. .shoppingCart .list .item .picTxt .pictrue image {
  1311. width: 100%;
  1312. height: 100%;
  1313. border-radius: 6rpx;
  1314. }
  1315. .shoppingCart .list .item .picTxt .text {
  1316. width: 400rpx;
  1317. font-size: 28rpx;
  1318. color: #282828;
  1319. }
  1320. .shoppingCart .list .item .picTxt .text .reColor {
  1321. color: #999;
  1322. }
  1323. .shoppingCart .list .item .picTxt .text .reElection {
  1324. margin-top: 20rpx;
  1325. }
  1326. .shoppingCart .list .item .picTxt .text .reElection .titles {
  1327. font-size: 24rpx;
  1328. }
  1329. .shoppingCart .list .item .picTxt .text .reElection .reBnt {
  1330. width: 120rpx;
  1331. height: 46rpx;
  1332. border-radius: 23rpx;
  1333. font-size: 26rpx;
  1334. }
  1335. .shoppingCart .list .item .picTxt .text .infor {
  1336. font-size: 24rpx;
  1337. color: #868686;
  1338. margin-top: 16rpx;
  1339. }
  1340. .shoppingCart .list .item .picTxt .text .infor .name{
  1341. max-width: 320rpx;
  1342. display: inline-block;
  1343. vertical-align: bottom;
  1344. }
  1345. .shoppingCart .list .item .picTxt .text .infor .iconfont{
  1346. font-size: 20rpx;
  1347. display: inline-block;
  1348. padding: 3rpx 40rpx 0 10rpx;
  1349. }
  1350. .shoppingCart .list .item .picTxt .text .isGift{
  1351. margin-top: 16rpx;
  1352. color: var(--view-theme);
  1353. }
  1354. .shoppingCart .list .item .picTxt .text .money {
  1355. font-size: 32rpx;
  1356. color: #282828;
  1357. margin-top: 28rpx;
  1358. }
  1359. .shoppingCart .list .item .picTxt .carnum {
  1360. height: 47rpx;
  1361. position: absolute;
  1362. bottom: 7rpx;
  1363. right: 0;
  1364. }
  1365. .shoppingCart .list .item .picTxt .carnum view {
  1366. border: 1rpx solid #a4a4a4;
  1367. width: 66rpx;
  1368. text-align: center;
  1369. height: 100%;
  1370. line-height: 40rpx;
  1371. font-size: 28rpx;
  1372. color: #a4a4a4;
  1373. }
  1374. .shoppingCart .list .item .picTxt .carnum .reduce {
  1375. border-right: 0;
  1376. border-radius: 22rpx 0 0 22rpx;
  1377. }
  1378. .shoppingCart .list .item .picTxt .carnum .reduce.on {
  1379. border-color: #e3e3e3;
  1380. color: #dedede;
  1381. }
  1382. .shoppingCart .list .item .picTxt .carnum .plus {
  1383. border-left: 0;
  1384. border-radius: 0 22rpx 22rpx 0;
  1385. }
  1386. .shoppingCart .list .item .picTxt .carnum .plus.on{
  1387. border-color: #e3e3e3;
  1388. color: #dedede;
  1389. }
  1390. .shoppingCart .list .item .picTxt .carnum .num {
  1391. color: #282828;
  1392. }
  1393. .shoppingCart .invalidGoods {
  1394. background-color: #fff;
  1395. margin: 12rpx 20rpx 0 20rpx;
  1396. border-radius: 12rpx;
  1397. }
  1398. .shoppingCart .invalidGoods .goodsNav {
  1399. width: 100%;
  1400. height: 66rpx;
  1401. padding: 0 30rpx;
  1402. box-sizing: border-box;
  1403. font-size: 28rpx;
  1404. color: #282828;
  1405. }
  1406. .shoppingCart .invalidGoods .goodsNav .iconfont {
  1407. color: #424242;
  1408. font-size: 28rpx;
  1409. margin-right: 17rpx;
  1410. }
  1411. .shoppingCart .invalidGoods .goodsNav .del {
  1412. font-size: 26rpx;
  1413. color: #999;
  1414. }
  1415. .shoppingCart .invalidGoods .goodsNav .del .icon-shanchu1 {
  1416. color: #999;
  1417. font-size: 33rpx;
  1418. vertical-align: -2rpx;
  1419. margin-right: 8rpx;
  1420. }
  1421. .shoppingCart .invalidGoods .goodsList .item {
  1422. padding: 20rpx 30rpx;
  1423. border-top: 1rpx solid #f5f5f5;
  1424. }
  1425. .shoppingCart .invalidGoods .goodsList .item .invalid {
  1426. font-size: 22rpx;
  1427. color: #fff;
  1428. width: 70rpx;
  1429. height: 36rpx;
  1430. background-color: #aaa;
  1431. border-radius: 3rpx;
  1432. text-align: center;
  1433. line-height: 36rpx;
  1434. }
  1435. .shoppingCart .invalidGoods .goodsList .item .pictrue {
  1436. width: 140rpx;
  1437. height: 140rpx;
  1438. }
  1439. .shoppingCart .invalidGoods .goodsList .item .pictrue image {
  1440. width: 100%;
  1441. height: 100%;
  1442. border-radius: 6rpx;
  1443. }
  1444. .shoppingCart .invalidGoods .goodsList .item .text {
  1445. width: 400rpx;
  1446. font-size: 28rpx;
  1447. color: #ccc;
  1448. height: 140rpx;
  1449. }
  1450. .shoppingCart .invalidGoods .goodsList .item .text .name {
  1451. width: 100%;
  1452. }
  1453. .shoppingCart .invalidGoods .goodsList .item .text .infor {
  1454. font-size: 24rpx;
  1455. width: 100%;
  1456. }
  1457. .shoppingCart .invalidGoods .goodsList .item .text .end {
  1458. font-size: 26rpx;
  1459. color: #999;
  1460. width: 100%;
  1461. }
  1462. .shoppingCart .tips{
  1463. position: fixed;
  1464. z-index:9;
  1465. width: 100%;
  1466. height: 56rpx;
  1467. background: #FEF4E7;
  1468. color: #FE960F;
  1469. font-size: 24rpx;
  1470. padding: 0 20rpx;
  1471. box-sizing: border-box;
  1472. bottom: 192rpx;
  1473. bottom: calc(192rpx+ constant(safe-area-inset-bottom)); ///兼容 IOS<11.2/
  1474. bottom: calc(192rpx + env(safe-area-inset-bottom)); ///兼容 IOS>11.2/
  1475. .iconfont{
  1476. margin-right: 12rpx;
  1477. }
  1478. &.on{
  1479. // #ifndef H5
  1480. bottom: 96rpx;
  1481. // #endif
  1482. }
  1483. }
  1484. .shoppingCart .footer {
  1485. z-index: 999;
  1486. width: 100%;
  1487. height: 96rpx;
  1488. background-color: #fafafa;
  1489. position: fixed;
  1490. padding: 0 30rpx;
  1491. box-sizing: border-box;
  1492. border-top: 1rpx solid #eee;
  1493. // #ifdef H5
  1494. bottom: 94rpx;
  1495. bottom: calc(94rpx+ constant(safe-area-inset-bottom)); ///兼容 IOS<11.2/
  1496. bottom: calc(94rpx + env(safe-area-inset-bottom)); ///兼容 IOS>11.2/
  1497. // #endif
  1498. // #ifndef H5
  1499. bottom: 98rpx;
  1500. bottom: calc(98rpx+ constant(safe-area-inset-bottom)); ///兼容 IOS<11.2/
  1501. bottom: calc(98rpx + env(safe-area-inset-bottom)); ///兼容 IOS>11.2/
  1502. // #endif
  1503. }
  1504. .shoppingCart .footer.on {
  1505. // #ifndef H5
  1506. bottom: 0rpx;
  1507. // #endif
  1508. }
  1509. .shoppingCart .footer .checkAll {
  1510. font-size: 28rpx;
  1511. color: #282828;
  1512. margin-left: 16rpx;
  1513. }
  1514. // .shoppingCart .footer checkbox .wx-checkbox-input{background-color:#fafafa;}
  1515. .shoppingCart .footer .money {
  1516. font-size: 30rpx;
  1517. }
  1518. .shoppingCart .footer .money .left{
  1519. text-align: right;
  1520. font-size: 24rpx;
  1521. }
  1522. .shoppingCart .footer .money .left .font-color{
  1523. font-size: 30rpx;
  1524. font-weight: 600;
  1525. }
  1526. .shoppingCart .footer .money .left .detailed{
  1527. font-size: 20rpx;
  1528. background: #f1f1f1;
  1529. padding: 2rpx;
  1530. text-align: center;
  1531. border-radius: 20rpx;
  1532. width: 120rpx;
  1533. }
  1534. .shoppingCart .footer .money .left .detailed .iconfont{
  1535. font-size: 24rpx;
  1536. margin-left: 8rpx;
  1537. }
  1538. .shoppingCart .footer .placeOrder {
  1539. color: #fff;
  1540. font-size: 26rpx;
  1541. width: 226rpx;
  1542. height: 70rpx;
  1543. border-radius: 50rpx;
  1544. text-align: center;
  1545. line-height: 70rpx;
  1546. margin-left: 22rpx;
  1547. &.on{
  1548. background-color: #ccc!important;
  1549. }
  1550. }
  1551. .shoppingCart .footer .button .bnt {
  1552. font-size: 28rpx;
  1553. color: #999;
  1554. border-radius: 50rpx;
  1555. border: 1px solid #999;
  1556. width: 160rpx;
  1557. height: 60rpx;
  1558. text-align: center;
  1559. line-height: 60rpx;
  1560. }
  1561. .shoppingCart .footer .button form~form {
  1562. margin-left: 17rpx;
  1563. }
  1564. .uni-p-b-96 {
  1565. height: 96rpx;
  1566. }
  1567. </style>