order_addcart.vue 51 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024
  1. <template>
  2. <view :data-theme="theme">
  3. <view class="cart_nav" :style='"height:"+navH+"rpx;"'>
  4. <!-- #ifndef APP-PLUS -->
  5. <nav-bar iconColor='#fff' ref="navBarRef" :isBackgroundColor="false" navTitle="购物车">
  6. </nav-bar>
  7. <!-- #endif -->
  8. </view>
  9. <view class='shoppingCart copy-data' :style='"top:"+navH+"rpx;"' @touchstart="touchStart">
  10. <view class='labelNav'>
  11. <view
  12. v-if="(cartList.valid.length === 0 && cartList.invalid.length === 0) || (cartList.valid.length > 0)"
  13. class='acea-row row-between-wrapper'>
  14. <view>共 <text class='num'>{{cartCount}}</text>件商品</view>
  15. <view v-if="cartList.valid.length > 0 || cartList.invalid.length > 0"
  16. class='administrate acea-row row-center-wrapper' @click='manage'>{{ footerswitch ? '管理' : '取消'}}
  17. </view>
  18. </view>
  19. </view>
  20. <view class="fixheight"></view>
  21. <view class="borRadius14 cartBox">
  22. <view v-if="cartList.valid.length > 0 || cartList.invalid.length > 0" class="borderPad">
  23. <view class='list'>
  24. <view v-for="(itemn,index) in cartList.valid" :key="index" class="mb24 borRadius14"
  25. style="overflow: hidden;">
  26. <view class="store-title nav">
  27. <view class="checkbox" @click="storeAllCheck(itemn,index)">
  28. <view v-if="itemn.noCheck" class="noCheck"></view>
  29. <view v-else>
  30. <text v-if="!itemn.allCheck" class="iconfont icon-weixuan"></text>
  31. <text v-else class="iconfont icon-xuanzhong11 font-color"></text>
  32. </view>
  33. </view>
  34. <navigator :url="'/pages/merchant/home/index?merId='+itemn.merId "
  35. class="info acea-row">
  36. <text class="iconfont icon-shangjiadingdan"></text>
  37. <view class="name">{{itemn.merName}}</view>
  38. <text class="iconfont icon-jiantou"></text>
  39. </navigator>
  40. </view>
  41. <block v-for="(item,indexn) in itemn.cartInfoList" :key="indexn">
  42. <view class='item acea-row row-between-wrapper'>
  43. <view class="checkbox" @click.stop="goodsCheck(item,indexn)">
  44. <block v-if="!footerswitch">
  45. <text v-if="!item.check" class="iconfont icon-weixuan"></text>
  46. <text v-else class="iconfont icon-xuanzhong11 font-color"></text>
  47. </block>
  48. <block v-else>
  49. <text v-if="!item.check && item.stock>0"
  50. class="iconfont icon-weixuan"></text>
  51. <text v-if="item.check && item.stock>0"
  52. class="iconfont icon-xuanzhong11 font-color"></text>
  53. <view v-if="!item.check && (item.stock===0 || !item.stock)" class="noCheck">
  54. </view>
  55. </block>
  56. </view>
  57. <navigator :url="`/pages/goods/goods_details/index?id=${item.productId}&mt=0`"
  58. hover-class='none' class='picTxt acea-row row-between-wrapper'>
  59. <view class='pictrue'>
  60. <image :src="item.image"></image>
  61. <!-- <easy-loadimage mode="widthFix" :image-src="item.image"></easy-loadimage> -->
  62. </view>
  63. <view class='text'>
  64. <view class='line1 line-heightOne' :class="item.attrStatus?'':'reColor'">
  65. {{item.proName}}
  66. </view>
  67. <view class='infor line1 line-heightOne' v-if="item.sku">规格:{{item.sku}}
  68. </view>
  69. <view class='money mt-20' v-if="item.attrStatus">
  70. <svip-price :svipIconStyle="svipIconStyle" :productPrice="item"
  71. :svipPriceStyle="svipPriceStyle"></svip-price>
  72. <!-- ¥{{item.vipPrice ? item.vipPrice :item.price}} -->
  73. </view>
  74. <view class="reElection acea-row row-between-wrapper" v-else>
  75. <view class="title">请重新选择商品规格</view>
  76. <view class="reBnt cart-color acea-row row-center-wrapper"
  77. @click.stop="reElection(item)">重选</view>
  78. </view>
  79. </view>
  80. <view class='carnum acea-row row-center-wrapper' v-if="item.attrStatus">
  81. <view class="reduce" :class="item.numSub ? 'on' : ''"
  82. @click.stop='subCart(item)'>-</view>
  83. <view class='num ml-8 mr-8'>{{item.cartNum}}</view>
  84. <view class="plus" :class="item.numAdd ? 'on' : ''"
  85. @click.stop='addCart(item)'>+</view>
  86. </view>
  87. </navigator>
  88. </view>
  89. </block>
  90. </view>
  91. </view>
  92. <view v-if="cartList.invalid.length > 0" class='invalidGoods borRadius14'
  93. :style="cartList.valid.length===0 && cartList.invalid.length > 0 ? 'position: relative;z-index: 111;':'position: static;'">
  94. <view class='goodsNav acea-row row-between-wrapper'>
  95. <view v-if="cartList.invalid.length > 1 || cartList.valid.length > 0" @click='goodsOpen'>
  96. <text class='iconfont'
  97. :class='goodsHidden==true?"icon-xiangxia":"icon-xiangshang"'></text>失效商品
  98. </view>
  99. <view v-else>
  100. 失效商品
  101. </view>
  102. <view class='del' @click='unsetCart'><text class='iconfont icon-shanchu1'></text>清空</view>
  103. </view>
  104. <view class='goodsList' :hidden='goodsHidden'>
  105. <view v-for="(itemn,indexn) in cartList.invalid" :key='indexn'>
  106. <view v-for="(item,index) in itemn.cartInfoList" :key='index'>
  107. <view class='item acea-row row-between-wrapper'>
  108. <view class='invalid'>失效</view>
  109. <view class='picTxt acea-row row-between-wrapper'>
  110. <view class='pictrue'>
  111. <easy-loadimage mode="widthFix" :image-src="item.image">
  112. </easy-loadimage>
  113. </view>
  114. <view class='text acea-row row-column-between'>
  115. <view class='line1 name'>{{item.proName}}</view>
  116. <view class='infor line1' v-if="item.sku">
  117. 属性:{{item.sku}}
  118. </view>
  119. <view class='acea-row row-between-wrapper'>
  120. <view class='end'>该商品已失效</view>
  121. </view>
  122. </view>
  123. </view>
  124. </view>
  125. </view>
  126. </view>
  127. </view>
  128. </view>
  129. <!-- #ifdef H5 -->
  130. <view v-if="!bottomNavigationIsCustom" style="height:60rpx;"></view>
  131. <!-- #endif -->
  132. </view>
  133. <view class='loadingicon acea-row row-center-wrapper' :hidden='loading==false'>
  134. <text class='loading iconfont icon-jiazai'></text>
  135. </view>
  136. <view class='noCart noCommodity'
  137. v-if="(cartList.valid.length == 0 && cartList.invalid.length == 0 && !loading ) || !isLogin">
  138. <view class='pictrue'>
  139. <image :src="urlDomain+'crmebimage/presets/noShopper.png'"></image>
  140. <view class="text-ccc">购物车为空哦~</view>
  141. </view>
  142. <recommend ref="recommendIndex"></recommend>
  143. </view>
  144. <!-- #ifdef H5 -->
  145. <view v-if="cartList.valid.length > 0 || cartList.invalid.length > 0" class="uni-p-b-96"></view>
  146. <!-- #endif -->
  147. <view v-if="cartList.valid.length > 0 || cartList.invalid.length > 0" class="uni-p-b-98"></view>
  148. <view v-if="bottomNavigationIsCustom" class="footerBottom"></view>
  149. </view>
  150. </view>
  151. <view :class="bottomNavigationIsCustom?'footerTop':''" class='footer acea-row row-between-wrapper'
  152. v-if="cartList.valid.length > 0">
  153. <view>
  154. <view class="allcheckbox flex-y-center" @click.stop="checkboxAllChange">
  155. <text v-if="!isAllSelect" class="iconfont icon-weixuan"></text>
  156. <text v-else class="iconfont icon-xuanzhong11 font-color"></text>
  157. 全选
  158. </view>
  159. </view>
  160. <view class='money acea-row row-middle' v-if="footerswitch==true">
  161. <view class="text-right">
  162. <view>
  163. <text class="all_text">合计:</text>
  164. <text class='price-color'>
  165. <text class="symbol">¥</text>
  166. <text
  167. class="all_money">{{calculatePriceData.totalPrice?calculatePriceData.totalPrice:0}}</text>
  168. </text>
  169. </view>
  170. <view class="acea-row row-middle" @click="popupChange()"
  171. v-show="calculatePriceData.totalCouponPrice>0">
  172. <text
  173. class="youhui">优惠:¥{{calculatePriceData.totalCouponPrice?calculatePriceData.totalCouponPrice:0}}</text>
  174. <text class="mingxi price-color">优惠明细</text>
  175. <text class="iconfont icon-xiala1"></text>
  176. <!-- <text class="iconfont icon-xiangshang2"></text> -->
  177. </view>
  178. </view>
  179. <form @submit="subOrder" report-submit='true'>
  180. <button class='placeOrder bg_color' formType="submit">去结算 ({{bayCount}})</button>
  181. </form>
  182. </view>
  183. <view class='button acea-row row-middle' v-else>
  184. <form @submit="subCollect" report-submit='true'>
  185. <button class='btn_cart_color' formType="submit">移入收藏</button>
  186. </form>
  187. <form @submit="subDel" report-submit='true'>
  188. <button class='bnt' formType="submit">删除</button>
  189. </form>
  190. </view>
  191. </view>
  192. <productWindow :attr="attr" :isShow='1' :iSplus='1' :iScart='1' @myevent="onMyEvent" @ChangeAttr="ChangeAttr"
  193. @ChangeCartNum="ChangeCartNum" @attrVal="attrVal" @iptCartNum="iptCartNum" @goCat="reGoCat"
  194. id='product-window'></productWindow>
  195. <!-- 优惠券详情弹窗 -->
  196. <view class="window" :class="popupShow ? 'on': ''">
  197. <view v-show="popupShow">
  198. <scroll-view scroll-y="true" class="popup_content">
  199. <view class="_tit text-center">
  200. {{calculatePriceData.proTotalPrice>0&& calculatePriceData.totalCouponPrice!=0?'优惠明细':'商品详情'}}
  201. </view>
  202. <view v-show="calculatePriceData.proTotalPrice>0&& calculatePriceData.totalCouponPrice!=0"
  203. class="_desc text-center">实际优惠详情以下单页为准</view>
  204. <view class="_pro_content">
  205. <view class="_pro_box">
  206. <view class="_pic_item" @click.stop="popupCheck(item)"
  207. v-for="item in showMore ? checkProList : checkProList.slice(0,4)" :key="item.id">
  208. <view class="checkbox">
  209. <text v-if="item.check" class="iconfont icon-xuanzhong11 font-color"></text>
  210. <text v-else class="noCheckd"></text>
  211. </view>
  212. <image :src="item.image" mode="aspectFill"></image>
  213. </view>
  214. </view>
  215. <view class="acea-row row-center-wrapper _more"
  216. v-show="checkProList.length && checkProList.length > 4" @click="showMore = !showMore">
  217. <text>已选{{checkProList.length}}件商品</text>
  218. <text v-if="showMore" class="iconfont icon-xiangshang"></text>
  219. <text v-else class="iconfont icon-xiangxia"></text>
  220. </view>
  221. </view>
  222. <block v-if="calculatePriceData.proTotalPrice>0 && calculatePriceData.totalCouponPrice!=0">
  223. <view class="_cell acea-row row-between-wrapper">
  224. <text class="_label">商品总价:</text>
  225. <text class="_count">¥{{calculatePriceData.proTotalPrice}}</text>
  226. </view>
  227. <view class="_cell acea-row row-between-wrapper">
  228. <text class="_label">会员优惠:</text>
  229. <text class="_count">-¥{{calculatePriceData.svipDiscountPrice}}</text>
  230. </view>
  231. <view class="_cell acea-row row-between-wrapper">
  232. <text class="_label">店铺优惠:</text>
  233. <text class="_count">-¥{{calculatePriceData.merCouponPrice}}</text>
  234. </view>
  235. <view class="_cell acea-row row-between-wrapper">
  236. <text class="_label">平台优惠:</text>
  237. <text class="_count">-¥{{calculatePriceData.platCouponPrice}}</text>
  238. </view>
  239. <view class="_cell_all acea-row row-between-wrapper">
  240. <text class="_label">共优惠:</text>
  241. <text class="_count">-¥{{calculatePriceData.totalCouponPrice}}</text>
  242. </view>
  243. </block>
  244. </scroll-view>
  245. </view>
  246. <text v-show="popupShow" class="iconfont icon-guanbi5" @click="popupShow = false"></text>
  247. </view>
  248. <view class="mask" v-show="popupShow" @touchmove.stop.prevent="moveStop" @click="popupShow = false"></view>
  249. <pageFooter></pageFooter>
  250. </view>
  251. </template>
  252. <script>
  253. // +----------------------------------------------------------------------
  254. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  255. // +----------------------------------------------------------------------
  256. // | Copyright (c) 2016~2025 https://www.crmeb.com All rights reserved.
  257. // +----------------------------------------------------------------------
  258. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  259. // +----------------------------------------------------------------------
  260. // | Author: CRMEB Team <admin@crmeb.com>
  261. // +----------------------------------------------------------------------
  262. import recommend from "@/components/base/recommend.vue";
  263. import easyLoadimage from '@/components/base/easy-loadimage.vue';
  264. import pageFooter from "@/components/pageFooter/index.vue";
  265. import svipPrice from '@/components/svipPrice.vue';
  266. import navBar from '@/components/navBar';
  267. import {
  268. onGetPreOrder
  269. } from '@/libs/order';
  270. // #ifdef APP-PLUS
  271. let sysHeight = uni.getSystemInfoSync().statusBarHeight + 'px';
  272. // #endif
  273. // #ifndef APP-PLUS
  274. let sysHeight = 0
  275. // #endif
  276. import {
  277. getCartList,
  278. getCartCounts,
  279. changeCartNum,
  280. cartDel,
  281. getResetCart,
  282. cartCalculatePriceApi
  283. } from '@/api/order.js';
  284. import {
  285. getProductHot,
  286. cartToCollect,
  287. getProductDetail
  288. } from '@/api/product.js';
  289. import {
  290. tokenIsExistApi
  291. } from '@/api/api.js';
  292. import {
  293. getShare
  294. } from '@/api/public.js';
  295. import {
  296. mapGetters
  297. } from "vuex";
  298. import productWindow from '@/components/productWindow';
  299. import {
  300. Debounce
  301. } from '@/utils/validate.js'
  302. import animationType from '@/utils/animationType.js'
  303. let app = getApp();
  304. export default {
  305. components: {
  306. productWindow,
  307. recommend,
  308. easyLoadimage,
  309. pageFooter,
  310. svipPrice,
  311. navBar
  312. },
  313. data() {
  314. return {
  315. //普通价格
  316. svipPriceStyle: {
  317. svipBox: {
  318. height: '22rpx',
  319. borderRadius: '50rpx 56rpx 56rpx 20rpx',
  320. },
  321. icon: {
  322. fontSize: '14rpx',
  323. height: '22rpx',
  324. borderRadius: '8rpx 0 8rpx 2rpx'
  325. },
  326. price: {
  327. fontSize: '32rpx'
  328. },
  329. svipPrice: {
  330. fontSize: '16rpx'
  331. },
  332. topStyle: {
  333. top: '0'
  334. }
  335. },
  336. //svip价格
  337. svipIconStyle: {
  338. svipBox: {
  339. height: '22rpx',
  340. lineHeight: '22rpx',
  341. borderRadius: '20rpx 40rpx 40rpx 0.4rpx',
  342. },
  343. price: {
  344. fontSize: '32rpx'
  345. },
  346. svipPrice: {
  347. fontSize: '14rpx'
  348. }
  349. },
  350. urlDomain: this.$Cache.get("imgHost"),
  351. categoryId: 0,
  352. cartCount: 0, //购物车规格数,
  353. bayCount: 0, //去结算总数
  354. goodsHidden: false,
  355. footerswitch: true, //管理按钮是否开启
  356. hostProduct: [],
  357. cartList: {
  358. valid: [],
  359. invalid: []
  360. },
  361. isAllSelect: false, //全选
  362. selectValue: [], //选中的数据
  363. selectCountPrice: 0.00,
  364. isAuto: false, //没有授权的不会自动授权
  365. isShowAuth: false, //是否隐藏授权
  366. hotScroll: false,
  367. hotPage: 1,
  368. hotLimit: 10,
  369. loading: false,
  370. loadend: false,
  371. loadTitle: '加载更多', //提示语
  372. page: 1,
  373. limit: 20,
  374. loadingInvalid: false,
  375. loadendInvalid: false,
  376. limitInvalid: 20,
  377. attr: {
  378. cartAttr: false,
  379. productAttr: [],
  380. productSelect: {}
  381. },
  382. productValue: [], //系统属性
  383. productInfo: {},
  384. attrValue: '', //已选属性
  385. attrTxt: '请选择', //属性页面提示
  386. cartId: 0,
  387. product_id: 0,
  388. sysHeight: sysHeight,
  389. canShow: false,
  390. configApi: {}, //分享类容配置
  391. theme: app.globalData.theme,
  392. navH: "",
  393. homeTop: 20,
  394. currentPage: false,
  395. type: "", //视频号普通商品类型
  396. tokenIsExist: false, //校验token是否有效
  397. popupShow: false,
  398. showMore: false,
  399. checkProList: [],
  400. calculatePriceData: {}
  401. };
  402. },
  403. computed: {
  404. ...mapGetters(['isLogin', 'productType', 'globalData', 'bottomNavigationIsCustom']),
  405. },
  406. onLoad: function(options) {
  407. this.getTokenIsExist();
  408. let that = this;
  409. // #ifdef MP
  410. that.navH = this.globalData.navHeight;
  411. // #endif
  412. // #ifndef MP
  413. that.navH = 96;
  414. // #endif
  415. },
  416. onReady() {
  417. this.$nextTick(function() {
  418. //// #ifdef MP
  419. const menuButton = uni.getMenuButtonBoundingClientRect();
  420. const query = uni.createSelectorQuery().in(this);
  421. query
  422. .select('#home')
  423. .boundingClientRect(data => {
  424. this.homeTop = menuButton.top * 2 + menuButton.height - data.height;
  425. })
  426. .exec();
  427. //// #endif
  428. });
  429. },
  430. onShow: function() {
  431. this.canShow = false
  432. this.calculatePriceData = {};
  433. this.popupShow = false;
  434. // this.getTokenIsExist();
  435. if (this.isLogin && this.tokenIsExist) {
  436. this.getIndex();
  437. this.getCartNum();
  438. };
  439. },
  440. // 滚动监听
  441. onPageScroll(e) {
  442. // 传入scrollTop值并触发所有easy-loadimage组件下的滚动监听事件
  443. uni.$emit('scroll');
  444. },
  445. methods: {
  446. //首次进入加载的接口
  447. getIndex() {
  448. this.hotPage = 1;
  449. this.hostProduct = [],
  450. this.hotScroll = false,
  451. this.loadend = false;
  452. this.page = 1;
  453. this.cartList.valid = [];
  454. this.getCartList();
  455. this.loadendInvalid = false;
  456. this.cartList.invalid = [];
  457. this.getInvalidList();
  458. //this.getCartNum();
  459. this.footerswitch = true;
  460. this.hotScroll = false;
  461. this.hotPage = 1;
  462. this.hotLimit = 10;
  463. this.cartList = {
  464. valid: [],
  465. invalid: []
  466. },
  467. this.isAllSelect = false; //全选
  468. this.selectValue = []; //选中的数据
  469. this.selectCountPrice = 0.00;
  470. this.bayCount = 0;
  471. this.isShowAuth = false;
  472. },
  473. //校验token是否有效,true为有效,false为无效
  474. getTokenIsExist() {
  475. tokenIsExistApi().then(res => {
  476. this.tokenIsExist = res.data;
  477. if (this.isLogin && this.tokenIsExist) {
  478. this.getIndex();
  479. this.getCartNum();
  480. }
  481. })
  482. },
  483. // 修改购物车
  484. reGoCat: function() {
  485. let that = this,
  486. productSelect = that.productValue[this.attrValue];
  487. //如果有属性,没有选择,提示用户选择
  488. if (
  489. that.attr.productAttr.length &&
  490. productSelect === undefined
  491. )
  492. return that.$util.Tips({
  493. title: "产品库存不足,请选择其它"
  494. });
  495. let q = {
  496. id: that.cartId,
  497. productId: that.product_id,
  498. num: that.attr.productSelect.cart_num,
  499. unique: that.attr.productSelect !== undefined ?
  500. that.attr.productSelect.unique : that.productInfo.id
  501. };
  502. getResetCart(q)
  503. .then(function(res) {
  504. that.attr.cartAttr = false;
  505. that.$util.Tips({
  506. title: "添加购物车成功",
  507. success: () => {
  508. that.loadend = false;
  509. that.page = 1;
  510. that.cartList.valid = [];
  511. that.getCartList();
  512. that.getCartNum();
  513. }
  514. });
  515. })
  516. .catch(res => {
  517. return that.$util.Tips({
  518. title: res
  519. });
  520. });
  521. },
  522. onMyEvent: function() {
  523. this.$set(this.attr, 'cartAttr', false);
  524. },
  525. reElection: function(item) {
  526. this.getGoodsDetails(item)
  527. },
  528. /**
  529. * 获取产品详情
  530. *
  531. */
  532. getGoodsDetails: function(item) {
  533. uni.showLoading({
  534. title: '加载中',
  535. mask: true
  536. });
  537. let that = this;
  538. that.cartId = item.id;
  539. that.product_id = item.productId;
  540. getProductDetail(item.productId, 'normal').then(res => {
  541. uni.hideLoading();
  542. that.attr.cartAttr = true;
  543. let productInfo = res.data.productInfo;
  544. that.$set(that, 'productInfo', productInfo);
  545. that.$set(that, 'productValue', res.data.productValue);
  546. let productAttr = res.data.productAttr.map(item => {
  547. return {
  548. attrName: item.attrName,
  549. attrValues: item.attrValues.split(','),
  550. id: item.id,
  551. isDel: item.isDel,
  552. productId: item.productId,
  553. type: item.type
  554. }
  555. });
  556. this.$set(that.attr, 'productAttr', productAttr);
  557. that.DefaultSelect();
  558. }).catch(err => {
  559. uni.hideLoading();
  560. })
  561. },
  562. /**
  563. * 属性变动赋值
  564. *
  565. */
  566. ChangeAttr: function(res) {
  567. let productSelect = this.productValue[res];
  568. if (productSelect && productSelect.stock > 0) {
  569. this.$set(this.attr.productSelect, "image", productSelect.image);
  570. this.$set(this.attr.productSelect, "price", productSelect.price);
  571. this.$set(this.attr.productSelect, "stock", productSelect.stock);
  572. this.$set(this.attr.productSelect, "unique", productSelect.id);
  573. this.$set(this.attr.productSelect, "cart_num", 1);
  574. this.$set(this, "attrValue", res);
  575. this.$set(this, "attrTxt", "已选择");
  576. } else {
  577. this.$set(this.attr.productSelect, "image", this.productInfo.image);
  578. this.$set(this.attr.productSelect, "price", this.productInfo.price);
  579. this.$set(this.attr.productSelect, "stock", 0);
  580. this.$set(this.attr.productSelect, "unique", this.productInfo.id);
  581. this.$set(this.attr.productSelect, "cart_num", 0);
  582. this.$set(this, "attrValue", "");
  583. this.$set(this, "attrTxt", "请选择");
  584. }
  585. },
  586. /**
  587. * 默认选中属性
  588. *
  589. */
  590. DefaultSelect: function() {
  591. let productAttr = this.attr.productAttr;
  592. let value = [];
  593. for (let key in this.productValue) {
  594. if (this.productValue[key].stock > 0) {
  595. value = this.attr.productAttr.length ? key.split(",") : [];
  596. break;
  597. }
  598. }
  599. for (let i = 0; i < productAttr.length; i++) {
  600. this.$set(productAttr[i], "index", value[i]);
  601. }
  602. //sort();排序函数:数字-英文-汉字;
  603. let productSelect = this.productValue[value.sort().join(",")];
  604. if (productSelect && productAttr.length) {
  605. this.$set(
  606. this.attr.productSelect,
  607. "storeName",
  608. this.productInfo.storeName
  609. );
  610. this.$set(this.attr.productSelect, "image", productSelect.image);
  611. this.$set(this.attr.productSelect, "price", productSelect.price);
  612. this.$set(this.attr.productSelect, "stock", productSelect.stock);
  613. this.$set(this.attr.productSelect, "unique", productSelect.id);
  614. this.$set(this.attr.productSelect, "cart_num", 1);
  615. this.$set(this, "attrValue", value.sort().join(","));
  616. this.$set(this, "attrTxt", "已选择");
  617. } else if (!productSelect && productAttr.length) {
  618. this.$set(
  619. this.attr.productSelect,
  620. "storeName",
  621. this.productInfo.storeName
  622. );
  623. this.$set(this.attr.productSelect, "image", this.productInfo.image);
  624. this.$set(this.attr.productSelect, "price", this.productInfo.price);
  625. this.$set(this.attr.productSelect, "stock", 0);
  626. this.$set(this.attr.productSelect, "unique", this.productInfo.id);
  627. this.$set(this.attr.productSelect, "cart_num", 0);
  628. this.$set(this, "attrValue", "");
  629. this.$set(this, "attrTxt", "请选择");
  630. } else if (!productSelect && !productAttr.length) {
  631. this.$set(
  632. this.attr.productSelect,
  633. "storeName",
  634. this.productInfo.storeName
  635. );
  636. this.$set(this.attr.productSelect, "image", this.productInfo.image);
  637. this.$set(this.attr.productSelect, "price", this.productInfo.price);
  638. this.$set(this.attr.productSelect, "stock", this.productInfo.stock);
  639. this.$set(
  640. this.attr.productSelect,
  641. "unique",
  642. this.productInfo.id || ""
  643. );
  644. this.$set(this.attr.productSelect, "cart_num", 1);
  645. this.$set(this, "attrValue", "");
  646. this.$set(this, "attrTxt", "请选择");
  647. }
  648. },
  649. attrVal(val) {
  650. this.$set(this.attr.productAttr[val.indexw], 'index', this.attr.productAttr[val.indexw].attrValues[val
  651. .indexn]);
  652. },
  653. /**
  654. * 购物车数量加和数量减
  655. *
  656. */
  657. ChangeCartNum: function(changeValue) {
  658. //changeValue:是否 加|减
  659. //获取当前变动属性
  660. let productSelect = this.productValue[this.attrValue];
  661. //如果没有属性,赋值给商品默认库存
  662. if (productSelect === undefined && !this.attr.productAttr.length)
  663. productSelect = this.attr.productSelect;
  664. //无属性值即库存为0;不存在加减;
  665. if (productSelect === undefined) return;
  666. let stock = productSelect.stock || 0;
  667. let num = this.attr.productSelect;
  668. if (changeValue) {
  669. num.cart_num++;
  670. if (num.cart_num > stock) {
  671. this.$set(this.attr.productSelect, "cart_num", stock ? stock : 1);
  672. this.$set(this, "cart_num", stock ? stock : 1);
  673. }
  674. } else {
  675. num.cart_num--;
  676. if (num.cart_num < 1) {
  677. this.$set(this.attr.productSelect, "cart_num", 1);
  678. this.$set(this, "cart_num", 1);
  679. }
  680. }
  681. },
  682. /**
  683. * 购物车手动填写
  684. *
  685. */
  686. iptCartNum: function(e) {
  687. this.$set(this.attr.productSelect, 'cart_num', e);
  688. },
  689. subDel: Debounce(function(event) {
  690. let selectValue = []
  691. this.cartList.valid.forEach(el => {
  692. el.cartInfoList.forEach(goods => {
  693. if (goods.check) {
  694. selectValue.push(goods.id)
  695. }
  696. })
  697. })
  698. if (selectValue.length > 0) {
  699. uni.showLoading({
  700. title: '加载中...'
  701. });
  702. cartDel(selectValue).then(res => {
  703. this.loadend = false;
  704. this.cartList.valid = [];
  705. this.calculatePriceData = {};
  706. this.bayCount = 0
  707. this.getCartList();
  708. this.getCartNum();
  709. uni.hideLoading();
  710. }).catch(err => {
  711. uni.hideLoading();
  712. });
  713. } else {
  714. return this.$util.Tips({
  715. title: '请选择产品'
  716. });
  717. }
  718. }),
  719. getSelectValueProductId: function() {
  720. let that = this;
  721. let validList = that.cartList.valid;
  722. let selectValue = that.selectValue;
  723. let productId = [];
  724. if (selectValue.length > 0) {
  725. for (let index in validList) {
  726. if (that.inArray(validList[index].id, selectValue)) {
  727. productId.push(validList[index].productId);
  728. }
  729. }
  730. };
  731. return productId;
  732. },
  733. subCollect: function(event) {
  734. let that = this;
  735. let type_id = []
  736. this.cartList.valid.forEach(el => {
  737. el.cartInfoList.forEach(goods => {
  738. if (goods.check) {
  739. type_id.push(goods.id)
  740. }
  741. })
  742. })
  743. if (type_id.length > 0) {
  744. cartToCollect(type_id).then(res => {
  745. that.$util.Tips({
  746. title: '收藏成功',
  747. icon: 'success'
  748. });
  749. this.cartList.valid = [];
  750. this.calculatePriceData = {};
  751. this.bayCount = 0
  752. this.getCartNum();
  753. this.getCartList();
  754. }).catch(err => {
  755. return that.$util.Tips({
  756. title: err
  757. });
  758. });
  759. } else {
  760. return that.$util.Tips({
  761. title: '请选择产品'
  762. });
  763. }
  764. },
  765. // 立即下单
  766. subOrder: Debounce(function(event) {
  767. this.$store.commit("PRODUCT_TYPE", 'normal');
  768. uni.showLoading({
  769. title: '加载中...'
  770. });
  771. this.selectValue = [];
  772. this.cartList.valid.forEach(el => {
  773. el.cartInfoList.forEach(goods => {
  774. if (goods.check) {
  775. this.selectValue.push(goods.id)
  776. }
  777. })
  778. })
  779. if (this.selectValue.length > 0) {
  780. this.getPreOrder();
  781. } else {
  782. uni.hideLoading();
  783. return this.$util.Tips({
  784. title: '请选择产品'
  785. });
  786. }
  787. }),
  788. /**
  789. * 预下单
  790. */
  791. getPreOrder: function() {
  792. let shoppingCartId = this.selectValue.map(item => {
  793. return {
  794. "shoppingCartId": Number(item)
  795. }
  796. })
  797. uni.hideLoading();
  798. onGetPreOrder("shoppingCart", shoppingCartId);
  799. },
  800. inArray: function(search, array) {
  801. for (let i in array) {
  802. if (array[i] == search) {
  803. return true;
  804. }
  805. }
  806. return false;
  807. },
  808. switchSelect: function() {
  809. let that = this;
  810. let validList = that.cartList.valid;
  811. let selectValue = that.selectValue;
  812. let selectCountPrice = 0.00;
  813. if (selectValue.length < 1) {
  814. that.selectCountPrice = selectCountPrice;
  815. } else {
  816. for (let index in validList) {
  817. if (that.inArray(validList[index].id, selectValue)) {
  818. selectCountPrice = that.$util.$h.Add(selectCountPrice, that.$util.$h.Mul(validList[index]
  819. .cartNum, validList[index].vipPrice ? validList[index].vipPrice : validList[
  820. index].price))
  821. }
  822. }
  823. that.selectCountPrice = selectCountPrice;
  824. }
  825. },
  826. checkboxAllChange() {
  827. this.popupShow = false
  828. this.isAllSelect = !this.isAllSelect
  829. this.cartAllCheck('cartCheck');
  830. },
  831. setAllSelectValue: function(status) {
  832. let that = this;
  833. let selectValue = [];
  834. let valid = that.cartList.valid;
  835. if (valid.length > 0) {
  836. let newValid = valid.map(item => {
  837. if (status) {
  838. if (that.footerswitch) {
  839. if (item.attrStatus) {
  840. item.checked = true;
  841. selectValue.push(item.id);
  842. } else {
  843. item.checked = false;
  844. }
  845. } else {
  846. item.checked = true;
  847. selectValue.push(item.id);
  848. }
  849. that.isAllSelect = true;
  850. } else {
  851. item.checked = false;
  852. that.isAllSelect = false;
  853. }
  854. return item;
  855. });
  856. that.$set(that.cartList, 'valid', newValid);
  857. that.selectValue = selectValue;
  858. that.switchSelect();
  859. }
  860. },
  861. checkboxChange: function(event) {
  862. let that = this;
  863. let value = event.detail.value;
  864. let valid = that.cartList.valid;
  865. let arr1 = [];
  866. let arr2 = [];
  867. let arr3 = [];
  868. let newValid = valid.map(item => {
  869. if (that.inArray(item.id, value)) {
  870. if (that.footerswitch) {
  871. if (item.attrStatus) {
  872. item.checked = true;
  873. arr1.push(item);
  874. } else {
  875. item.checked = false;
  876. }
  877. } else {
  878. item.checked = true;
  879. arr1.push(item);
  880. }
  881. } else {
  882. item.checked = false;
  883. arr2.push(item);
  884. }
  885. return item;
  886. });
  887. if (that.footerswitch) {
  888. arr3 = arr2.filter(item => !item.attrStatus);
  889. }
  890. that.$set(that.cartList, 'valid', newValid);
  891. that.isAllSelect = newValid.length === arr1.length + arr3.length;
  892. that.selectValue = value;
  893. that.switchSelect();
  894. },
  895. inArray: function(search, array) {
  896. for (let i in array) {
  897. if (array[i] == search) {
  898. return true;
  899. }
  900. }
  901. return false;
  902. },
  903. //计算总价
  904. switchSelect: function() {
  905. let that = this;
  906. let validList = that.cartList.valid;
  907. let selectValue = that.selectValue;
  908. let selectCountPrice = 0.00;
  909. if (selectValue.length < 1) {
  910. that.selectCountPrice = selectCountPrice;
  911. } else {
  912. for (let index in validList) {
  913. if (that.inArray(validList[index].id, selectValue)) {
  914. selectCountPrice = that.$util.$h.Add(selectCountPrice, that.$util.$h.Mul(validList[index]
  915. .cartNum, validList[index].vipPrice ? validList[index].vipPrice : validList[
  916. index]
  917. .price))
  918. }
  919. }
  920. that.selectCountPrice = selectCountPrice;
  921. }
  922. },
  923. /**
  924. * 购物车手动填写
  925. *
  926. */
  927. iptCartNum: function(index) {
  928. let item = this.cartList.valid[index];
  929. if (item.cartNum) {
  930. this.setCartNum(item.id, item.cartNum);
  931. }
  932. this.switchSelect();
  933. },
  934. blurInput: function(index) {
  935. let item = this.cartList.valid[index];
  936. if (!item.cartNum) {
  937. item.cartNum = 1;
  938. this.$set(this.cartList, 'valid', this.cartList.valid)
  939. }
  940. },
  941. subCart: Debounce(function(item) {
  942. let that = this;
  943. let status = false;
  944. if (item.cartNum < 1) status = true;
  945. if (item.cartNum <= 1) {
  946. item.cartNum = 1;
  947. item.numSub = true;
  948. status = true;
  949. } else {
  950. item.cartNum = Number(item.cartNum) - 1;
  951. if (false == status) {
  952. that.setCartNum(item.id, item.cartNum, function(data) {
  953. item.numSub = false;
  954. item.numAdd = false;
  955. if (item.cartNum <= 1) {
  956. item.numSub = true;
  957. }
  958. that.cartAllCheck('goodsCheck')
  959. });
  960. }
  961. }
  962. }),
  963. addCart: Debounce(function(item) {
  964. let that = this;
  965. item.cartNum = Number(item.cartNum) + 1;
  966. if (item.cartNum < item.stock) {
  967. item.numAdd = false;
  968. item.numSub = false;
  969. that.setCartNum(item.id, item.cartNum, function(data) {
  970. that.cartAllCheck('goodsCheck')
  971. })
  972. } else if (item.cartNum === item.stock) {
  973. item.numAdd = true;
  974. item.numSub = false;
  975. that.setCartNum(item.id, item.cartNum, function(data) {
  976. that.cartAllCheck('goodsCheck')
  977. })
  978. } else {
  979. item.cartNum = item.stock;
  980. item.numAdd = true;
  981. item.numSub = false;
  982. }
  983. }),
  984. setCartNum(cartId, cartNum, successCallback) {
  985. let that = this;
  986. changeCartNum(cartId, cartNum).then(res => {
  987. successCallback && successCallback(res.data);
  988. }).catch(err => {
  989. return that.$util.Tips({
  990. title: err
  991. });
  992. });
  993. },
  994. //购物车数量
  995. getCartNum: function() {
  996. let that = this;
  997. getCartCounts(true, 'total').then(res => {
  998. that.cartCount = res.data.count;
  999. });
  1000. },
  1001. // 商铺全选
  1002. storeAllCheck(item, index) {
  1003. // item.noCheck为true表示店铺全是无库存商品,店铺不能操作选择功能
  1004. if (item.noCheck) return;
  1005. if (item.allCheck) {
  1006. item.allCheck = false
  1007. item.cartInfoList.forEach((el, index) => {
  1008. el.check = false
  1009. })
  1010. } else {
  1011. item.allCheck = true
  1012. item.cartInfoList.forEach((el, index) => {
  1013. if (!this.footerswitch) {
  1014. el.check = true
  1015. } else {
  1016. if (parseFloat(el.stock) > 0) el.check = true
  1017. }
  1018. })
  1019. }
  1020. this.cartAllCheck('goodsCheck');
  1021. },
  1022. // 商品选中
  1023. goodsCheck(goods) {
  1024. goods.check = !goods.check
  1025. this.cartAllCheck('goodsCheck')
  1026. },
  1027. // 全选判断
  1028. cartAllCheck(type) {
  1029. let allArr = [];
  1030. let totalMoney = 0;
  1031. let totalNum = 0;
  1032. this.cartList.valid.forEach((el, index) => {
  1033. //单独选中,else为点击全选功能
  1034. if (type == 'goodsCheck') {
  1035. //this.footerswitch管理开关,true是正常状态,false是开启管理状态
  1036. if (this.footerswitch) {
  1037. let tempStock = el.cartInfoList.filter(goods => {
  1038. return goods.stock > 0
  1039. })
  1040. let tempArr = el.cartInfoList.filter(goods => {
  1041. return goods.check == true
  1042. })
  1043. if ((tempStock.length == tempArr.length) && tempStock.length > 0 && tempArr.length >
  1044. 0) {
  1045. el.allCheck = true
  1046. allArr.push(el)
  1047. } else {
  1048. el.allCheck = false
  1049. }
  1050. } else {
  1051. let tempArr = el.cartInfoList.filter(goods => {
  1052. return goods.check == true
  1053. })
  1054. if (el.cartInfoList.length == tempArr.length) {
  1055. el.allCheck = true
  1056. allArr.push(el)
  1057. } else {
  1058. el.allCheck = false
  1059. }
  1060. }
  1061. let allCheck = this.cartList.valid.filter(goods => {
  1062. return goods.allCheck == true
  1063. })
  1064. // 全选
  1065. this.isAllSelect = allArr.length == this.cartList.valid.length ? true : false
  1066. } else {
  1067. // 刚进入页面的全选功能
  1068. el.cartInfoList.forEach((goods) => {
  1069. if (this.footerswitch) {
  1070. goods.check = this.isAllSelect && parseFloat(goods.stock) > 0
  1071. } else {
  1072. goods.check = this.isAllSelect
  1073. }
  1074. })
  1075. if (this.footerswitch) {
  1076. let tempStock = el.cartInfoList.filter(goods => {
  1077. return goods.stock > 0
  1078. })
  1079. let tempArr = el.cartInfoList.filter(goods => {
  1080. return goods.check == true
  1081. })
  1082. if (tempStock.length !== tempArr.length) {
  1083. el.allCheck = false
  1084. } else if (tempStock.length > 0 && tempArr.length > 0) {
  1085. el.allCheck = true
  1086. } else {
  1087. el.noCheck = true
  1088. }
  1089. } else {
  1090. el.allCheck = this.isAllSelect
  1091. if (el.allCheck) allArr.push(el)
  1092. }
  1093. if (el.allCheck) allArr.push(el)
  1094. }
  1095. // 总金额 //总数
  1096. el.cartInfoList.forEach(e => {
  1097. if (e.check && e.stock > 0 && this.footerswitch) {
  1098. totalMoney = this.$util.$h.Add(totalMoney, this.$util.$h.Mul(e.price, e
  1099. .cartNum))
  1100. totalNum += e.cartNum
  1101. } else if (e.check && !this.footerswitch) {
  1102. totalMoney = this.$util.$h.Add(totalMoney, this.$util.$h.Mul(e.price, e
  1103. .cartNum))
  1104. totalNum += e.cartNum
  1105. }
  1106. })
  1107. })
  1108. this.bayCount = totalNum
  1109. this.selectCountPrice = totalMoney
  1110. this.changePrice();
  1111. },
  1112. //购物车正常商品列表
  1113. getCartList() {
  1114. if (this.loading) return false;
  1115. let data = {
  1116. isValid: true
  1117. }
  1118. this.loading = true;
  1119. getCartList(data).then(res => {
  1120. let valid = res.data;
  1121. this.$set(this.cartList, 'valid', valid);
  1122. valid.forEach((item, index) => {
  1123. item.cartInfoList.forEach((goods, j) => {
  1124. if (goods.cartNum == 1) {
  1125. goods.numSub = true;
  1126. } else {
  1127. goods.numSub = false;
  1128. }
  1129. if (goods.cartNum == goods.stock) {
  1130. goods.numAdd = true;
  1131. } else {
  1132. goods.numAdd = false;
  1133. }
  1134. })
  1135. })
  1136. this.loading = false;
  1137. if (this.cartList.valid) this.canShow = true;
  1138. uni.hideLoading();
  1139. }).catch(res => {
  1140. uni.hideLoading();
  1141. });
  1142. },
  1143. // 判断商品的初始状态是全部选中的
  1144. getCheckGoods(valid) {
  1145. let totalNum = 0;
  1146. valid.forEach((item, index) => {
  1147. item.cartInfoList.forEach((goods, j) => {
  1148. if (this.footerswitch && this.isAllSelect) {
  1149. goods.check = true
  1150. totalNum += goods.cartNum
  1151. } else {
  1152. if (parseFloat(goods.stock) === 0) {
  1153. goods.check = false
  1154. } else {
  1155. goods.check = true
  1156. totalNum += goods.cartNum
  1157. }
  1158. }
  1159. if (goods.cartNum == 1) {
  1160. goods.numSub = true;
  1161. } else {
  1162. goods.numSub = false;
  1163. }
  1164. if (goods.cartNum == goods.stock) {
  1165. goods.numAdd = true;
  1166. } else {
  1167. goods.numAdd = false;
  1168. }
  1169. })
  1170. let tempStock = item.cartInfoList.filter(goods => {
  1171. return goods.stock > 0
  1172. })
  1173. let tempArr = item.cartInfoList.filter(goods => {
  1174. return goods.check == true
  1175. })
  1176. if (tempStock.length === 0 && tempArr.length === 0 && tempStock.length === tempArr.length) {
  1177. item.allCheck = false
  1178. } else {
  1179. item.allCheck = true
  1180. }
  1181. })
  1182. this.bayCount = totalNum;
  1183. },
  1184. //失效商品列表
  1185. getInvalidList: function() {
  1186. let that = this;
  1187. if (this.loadingInvalid) return false;
  1188. let data = {
  1189. isValid: false
  1190. }
  1191. getCartList(data).then(res => {
  1192. let invalidList = res.data;
  1193. that.$set(that.cartList, 'invalid', invalidList);
  1194. that.loadingInvalid = false;
  1195. uni.hideLoading();
  1196. }).catch(res => {
  1197. uni.hideLoading();
  1198. that.loadingInvalid = false;
  1199. })
  1200. },
  1201. goodsOpen: function() {
  1202. this.goodsHidden = !this.goodsHidden;
  1203. },
  1204. //管理按钮
  1205. manage: function() {
  1206. if (this.isAllSelect) {
  1207. this.getCheckGoods(this.cartList.valid);
  1208. }
  1209. this.footerswitch = !this.footerswitch;
  1210. },
  1211. unsetCart: function() {
  1212. let that = this,
  1213. ids = [];
  1214. this.cartList.invalid.forEach((el, index) => {
  1215. el.cartInfoList.forEach(e => {
  1216. ids.push(e.id);
  1217. })
  1218. })
  1219. cartDel(ids).then(res => {
  1220. that.$util.Tips({
  1221. title: '清除成功'
  1222. });
  1223. that.$set(that.cartList, 'invalid', []);
  1224. }).catch(res => {
  1225. });
  1226. },
  1227. // 微信分享;
  1228. setOpenShare: function(data) {
  1229. let that = this;
  1230. if (that.$wechat.isWeixin()) {
  1231. let configAppMessage = {
  1232. desc: data.synopsis,
  1233. title: data.title,
  1234. link: location.href,
  1235. imgUrl: data.img
  1236. };
  1237. that.$wechat.wechatEvevt(["updateAppMessageShareData", "updateTimelineShareData"],
  1238. configAppMessage);
  1239. }
  1240. },
  1241. touchStart() {
  1242. this.$refs.navBarRef.currentPage = false;
  1243. },
  1244. //点击优惠明细
  1245. popupChange() {
  1246. this.popupShow = !this.popupShow;
  1247. },
  1248. //改变价格
  1249. changePrice() {
  1250. let ids = [];
  1251. this.checkProList = [];
  1252. this.cartList.valid.forEach(item => {
  1253. item.cartInfoList.forEach(item1 => {
  1254. this.$set(item1, 'popupCheck', true);
  1255. if (item1.check) {
  1256. this.checkProList.push(item1);
  1257. ids.push(item1.id);
  1258. }
  1259. })
  1260. })
  1261. this.getcartCalculatePrice(ids);
  1262. },
  1263. //弹窗中选中
  1264. popupCheck(item) {
  1265. let ids = [];
  1266. let totalNum = 0;
  1267. let allArr = []; //所有的数据
  1268. let checkArr = []; //选中的数据
  1269. this.$set(item, 'popupCheck', !item.popupCheck);
  1270. this.cartList.valid.forEach(item1 => {
  1271. item1.cartInfoList.forEach(item2 => {
  1272. if (item2.id == item.id) {
  1273. item2.check = !item2.check;
  1274. }
  1275. allArr.push(item)
  1276. })
  1277. })
  1278. this.checkProList.forEach(item => {
  1279. if (item.check) {
  1280. ids.push(item.id);
  1281. checkArr.push(item)
  1282. }
  1283. })
  1284. this.getcartCalculatePrice(ids);
  1285. this.checkProList.forEach(e => {
  1286. if (e.check && e.stock > 0 && this.footerswitch) {
  1287. totalNum += e.cartNum
  1288. } else if (e.check && !this.footerswitch) {
  1289. totalNum += e.cartNum
  1290. }
  1291. })
  1292. // 全选
  1293. this.isAllSelect = allArr.length === checkArr.length ? true : false
  1294. this.bayCount = totalNum;
  1295. },
  1296. //计算价格
  1297. getcartCalculatePrice(ids) {
  1298. if (ids.length === 0) {
  1299. this.selectCountPrice = 0.00;
  1300. this.calculatePriceData.totalCouponPrice = 0.00;
  1301. this.calculatePriceData.merCouponPrice = 0.00;
  1302. this.calculatePriceData.platCouponPrice = 0.00;
  1303. this.calculatePriceData.totalCouponPrice = 0.00;
  1304. this.calculatePriceData.totalPrice = 0.00;
  1305. return
  1306. }
  1307. cartCalculatePriceApi({
  1308. ids: ids
  1309. }).then(res => {
  1310. this.calculatePriceData = res.data;
  1311. this.selectCountPrice = this.calculatePriceData.proTotalPrice;
  1312. }).catch(err => {
  1313. this.bayCount = 0;
  1314. this.selectCountPrice = 0.00;
  1315. this.calculatePriceData.proTotalPrice = 0.00;
  1316. this.calculatePriceData.totalCouponPrice = 0.00;
  1317. this.calculatePriceData.merCouponPrice = 0.00;
  1318. this.calculatePriceData.platCouponPrice = 0.00;
  1319. this.calculatePriceData.totalCouponPrice = 0.00;
  1320. this.calculatePriceData.totalPrice = 0.00;
  1321. return this.$util.Tips({
  1322. title: err
  1323. });
  1324. })
  1325. }
  1326. },
  1327. onReachBottom() {
  1328. let that = this;
  1329. if (that.loadend) {
  1330. that.getInvalidList();
  1331. }
  1332. if ((that.cartList.valid.length == 0 && that.cartList.invalid.length == 0 && !that.loading)) {
  1333. that.$refs.recommendIndex.get_host_product();
  1334. }
  1335. }
  1336. }
  1337. </script>
  1338. <style scoped lang="scss">
  1339. .noCheckd {
  1340. display: inline-block;
  1341. width: 34rpx;
  1342. height: 34rpx;
  1343. border-radius: 50%;
  1344. background-color: #fff;
  1345. border: 1px solid #ccc;
  1346. }
  1347. .footerTop {
  1348. bottom: 98rpx !important;
  1349. bottom: calc(98rpx+ constant(safe-area-inset-bottom)) !important; ///兼容 IOS<11.2/
  1350. bottom: calc(98rpx + env(safe-area-inset-bottom)) !important; ///兼容 IOS>11.2/
  1351. }
  1352. .fixheight {
  1353. width: 100%;
  1354. height: 152rpx;
  1355. @include main_bg_color(theme);
  1356. position: fixed;
  1357. }
  1358. .icon-jiantou {
  1359. font-size: 20rpx;
  1360. }
  1361. .noCheck {
  1362. width: 32rpx;
  1363. height: 32rpx;
  1364. border-radius: 50%;
  1365. overflow: hidden;
  1366. border: 1px solid #999999;
  1367. background-color: #eee;
  1368. }
  1369. .invalidClas {
  1370. position: relative;
  1371. z-index: 111;
  1372. top: -120rpx;
  1373. }
  1374. .invalidClasNO {
  1375. position: static;
  1376. margin-top: 15px;
  1377. }
  1378. .store-title {
  1379. display: flex;
  1380. align-items: center;
  1381. width: 100%;
  1382. padding: 0 30rpx;
  1383. height: 85rpx;
  1384. border-bottom: 1px solid #f0f0f0;
  1385. .info {
  1386. margin-left: 28rpx;
  1387. align-items: center;
  1388. }
  1389. .name {
  1390. margin-left: 8rpx;
  1391. }
  1392. }
  1393. .cartBox {
  1394. position: relative;
  1395. /* #ifndef APP */
  1396. top: 64rpx;
  1397. /* #endif */
  1398. /* #ifdef APP */
  1399. top: 76rpx;
  1400. /* #endif */
  1401. }
  1402. .cart_nav {
  1403. position: fixed;
  1404. @include main_bg_color(theme);
  1405. top: 0;
  1406. left: 0;
  1407. z-index: 99;
  1408. width: 100%;
  1409. }
  1410. .px-20 {
  1411. padding: 0 20rpx 0;
  1412. }
  1413. .pl-20 {
  1414. padding-left: 20rpx;
  1415. }
  1416. .justify-center {
  1417. justify-content: center;
  1418. }
  1419. .align-center {
  1420. align-items: center;
  1421. }
  1422. .px-20 {
  1423. padding: 0 20rpx 0;
  1424. }
  1425. .container_detail {
  1426. /* #ifdef MP */
  1427. margin-top: 32rpx;
  1428. /* #endif */
  1429. }
  1430. .tab_nav {
  1431. width: 100%;
  1432. height: 48px;
  1433. padding: 0 30rpx 0;
  1434. }
  1435. .nav_title {
  1436. width: 200rpx;
  1437. color: #fff;
  1438. font-size: 36rpx;
  1439. position: fixed;
  1440. text-align: center;
  1441. left: 0;
  1442. right: 0;
  1443. margin: auto;
  1444. }
  1445. .pl-20 {
  1446. padding-left: 20rpx;
  1447. }
  1448. .px-20 {
  1449. padding: 0 20rpx 0;
  1450. }
  1451. .justify-center {
  1452. justify-content: center;
  1453. }
  1454. .align-center {
  1455. align-items: center;
  1456. }
  1457. .shoppingCart {
  1458. /* #ifdef H5 */
  1459. padding-bottom: constant(safe-area-inset-bottom);
  1460. padding-bottom: env(safe-area-inset-bottom);
  1461. /* #endif */
  1462. position: absolute;
  1463. width: 100%;
  1464. margin-bottom: 280rpx;
  1465. }
  1466. .shoppingCart .labelNav {
  1467. height: 62rpx;
  1468. padding: 0 24rpx;
  1469. font-size: 28rpx;
  1470. color: #fff;
  1471. width: 100%;
  1472. box-sizing: border-box;
  1473. @include main_bg_color(theme);
  1474. z-index: 5;
  1475. position: fixed;
  1476. }
  1477. .shoppingCart .labelNav .item .iconfont {
  1478. font-size: 26rpx;
  1479. margin-right: 10rpx;
  1480. }
  1481. .shoppingCart .nav {
  1482. height: 92rpx;
  1483. background-color: #fff;
  1484. padding: 0 20rpx;
  1485. -webkit-box-sizing: border-box;
  1486. box-sizing: border-box;
  1487. font-size: 28rpx;
  1488. color: #282828;
  1489. z-index: 6;
  1490. border-top-left-radius: 14rpx;
  1491. border-top-right-radius: 14rpx;
  1492. }
  1493. .shoppingCart .nav .num {
  1494. margin-left: 12rpx;
  1495. }
  1496. .shoppingCart .nav .administrate {
  1497. font-size: 28rpx;
  1498. color: #333333;
  1499. }
  1500. .shoppingCart .noCart {
  1501. background-color: #f5f5f5;
  1502. padding-top: 0.1rpx;
  1503. }
  1504. .shoppingCart .noCart .pictrue {
  1505. width: 414rpx;
  1506. height: 336rpx;
  1507. margin: 30rpx auto 90rpx auto;
  1508. }
  1509. .shoppingCart .noCart .pictrue image {
  1510. width: 100%;
  1511. height: 100%;
  1512. }
  1513. .shoppingCart .list {
  1514. width: 100%;
  1515. // margin-top: 178rpx;
  1516. /* #ifdef MP */
  1517. // margin-bottom:120rpx;
  1518. /* #endif */
  1519. /* #ifndef MP */
  1520. // margin-bottom:240rpx;
  1521. /* #endif */
  1522. overflow: hidden;
  1523. border-bottom-left-radius: 14rpx;
  1524. border-bottom-right-radius: 14rpx;
  1525. }
  1526. .shoppingCart .list .item {
  1527. padding: 20rpx;
  1528. background-color: #fff;
  1529. }
  1530. .shoppingCart .list .item .picTxt {
  1531. width: 610rpx;
  1532. position: relative;
  1533. }
  1534. .shoppingCart .list .item .picTxt .pictrue {
  1535. width: 160rpx;
  1536. height: 160rpx;
  1537. }
  1538. .shoppingCart .list .item .picTxt .pictrue image {
  1539. width: 100%;
  1540. height: 100%;
  1541. border-radius: 6rpx;
  1542. }
  1543. .shoppingCart .list .item .picTxt .text {
  1544. width: 432rpx;
  1545. font-size: 28rpx;
  1546. color: #282828;
  1547. }
  1548. .shoppingCart .list .item .picTxt .text .reColor {
  1549. color: #999;
  1550. }
  1551. .shoppingCart .list .item .picTxt .text .reElection {
  1552. margin-top: 20rpx;
  1553. }
  1554. .shoppingCart .list .item .picTxt .text .reElection .title {
  1555. font-size: 24rpx;
  1556. color: #666;
  1557. }
  1558. .shoppingCart .list .item .picTxt .text .reElection .reBnt {
  1559. width: 120rpx;
  1560. height: 46rpx;
  1561. border-radius: 23rpx;
  1562. font-size: 26rpx;
  1563. @include coupons_border_color(theme);
  1564. @include main_color(theme);
  1565. }
  1566. .shoppingCart .list .item .picTxt .text .infor {
  1567. font-size: 24rpx;
  1568. color: #999999;
  1569. margin-top: 20rpx;
  1570. }
  1571. .money {
  1572. font-size: 32rpx;
  1573. font-weight: 600;
  1574. @include price_color(theme);
  1575. .price-color {
  1576. @include price_color(theme);
  1577. }
  1578. }
  1579. .mt-28 {
  1580. margin-top: 28rpx;
  1581. }
  1582. .bg_color {
  1583. @include main_bg_color(theme);
  1584. }
  1585. .icon-xuanzhong11,
  1586. .icon-weixuan {
  1587. font-size: 36rpx;
  1588. }
  1589. .shoppingCart .list .item .picTxt .carnum {
  1590. height: 47rpx;
  1591. position: absolute;
  1592. bottom: 7rpx;
  1593. right: 0;
  1594. }
  1595. .shoppingCart .list .item .picTxt .carnum view {
  1596. text-align: center;
  1597. height: 100%;
  1598. line-height: 44rpx;
  1599. font-size: 28rpx;
  1600. color: #333;
  1601. }
  1602. .shoppingCart .list .item .picTxt .carnum .reduce {
  1603. border-right: 0;
  1604. border-radius: 3rpx 0 0 3rpx;
  1605. border-radius: 22rpx 0rpx 0rpx 22rpx;
  1606. font-size: 34rpx;
  1607. line-height: 46rpx;
  1608. }
  1609. .shoppingCart .list .item .picTxt .carnum .on {
  1610. color: #CCCCCC;
  1611. }
  1612. .shoppingCart .list .item .picTxt .carnum .plus {
  1613. border-left: 0;
  1614. border-radius: 0 3rpx 3rpx 0;
  1615. border-radius: 0rpx 22rpx 22rpx 0rpx;
  1616. font-size: 34rpx;
  1617. line-height: 46rpx;
  1618. }
  1619. .shoppingCart .list .item .picTxt .carnum .num {
  1620. color: #282828;
  1621. width: 72rpx;
  1622. height: 36rpx;
  1623. line-height: 36rpx;
  1624. background-color: #F5F5F5;
  1625. border-radius: 4rpx;
  1626. font-size: 24rpx;
  1627. }
  1628. .shoppingCart .invalidGoods {
  1629. background-color: #fff;
  1630. // margin-top: 30rpx;
  1631. /* #ifdef MP */
  1632. // margin-top: 140rpx;
  1633. /* #endif */
  1634. }
  1635. .shoppingCart .invalidGoods .goodsNav {
  1636. width: 100%;
  1637. height: 90rpx;
  1638. padding: 0 24rpx;
  1639. box-sizing: border-box;
  1640. font-size: 28rpx;
  1641. color: #333333;
  1642. }
  1643. .shoppingCart .invalidGoods .goodsNav .iconfont {
  1644. color: #424242;
  1645. font-size: 28rpx;
  1646. margin-right: 17rpx;
  1647. }
  1648. .shoppingCart .invalidGoods .goodsNav .del {
  1649. font-size: 26rpx;
  1650. color: #333;
  1651. }
  1652. .shoppingCart .invalidGoods .goodsNav .del .icon-shanchu1 {
  1653. color: #333;
  1654. font-size: 33rpx;
  1655. vertical-align: -2rpx;
  1656. margin-right: 8rpx;
  1657. }
  1658. .shoppingCart .invalidGoods .goodsList .item {
  1659. padding: 24rpx;
  1660. }
  1661. .shoppingCart .invalidGoods .goodsList .picTxt {
  1662. width: 592rpx;
  1663. }
  1664. .shoppingCart .invalidGoods .goodsList .item .invalid {
  1665. font-size: 22rpx;
  1666. color: #CCCCCC;
  1667. height: 36rpx;
  1668. border-radius: 3rpx;
  1669. text-align: center;
  1670. line-height: 36rpx;
  1671. }
  1672. .shoppingCart .invalidGoods .goodsList .item .pictrue {
  1673. width: 160rpx;
  1674. height: 160rpx;
  1675. }
  1676. .shoppingCart .invalidGoods .goodsList .item .pictrue image {
  1677. width: 100%;
  1678. height: 100%;
  1679. border-radius: 6rpx;
  1680. }
  1681. .shoppingCart .invalidGoods .goodsList .item .text {
  1682. width: 414rpx;
  1683. font-size: 28rpx;
  1684. color: #999;
  1685. height: 140rpx;
  1686. }
  1687. .shoppingCart .invalidGoods .goodsList .item .text .name {
  1688. width: 100%;
  1689. }
  1690. .shoppingCart .invalidGoods .goodsList .item .text .infor {
  1691. font-size: 24rpx;
  1692. }
  1693. .shoppingCart .invalidGoods .goodsList .item .text .end {
  1694. font-size: 26rpx;
  1695. color: #bbb;
  1696. }
  1697. .footer {
  1698. z-index: 999;
  1699. width: 100%;
  1700. height: 100rpx;
  1701. background-color: #fff;
  1702. position: fixed;
  1703. padding: 0 24rpx;
  1704. box-sizing: border-box;
  1705. border-top: 1rpx solid #eee;
  1706. bottom: var(--window-bottom);
  1707. }
  1708. .footer .checkAll {
  1709. font-size: 28rpx;
  1710. color: #282828;
  1711. margin-left: 14rpx;
  1712. }
  1713. .footer .money {
  1714. .font-color {
  1715. font-weight: 600;
  1716. }
  1717. .all_text {
  1718. font-size: 24rpx;
  1719. color: #333;
  1720. font-weight: 400;
  1721. }
  1722. .symbol {
  1723. font-size: 26rpx;
  1724. }
  1725. .all_money {
  1726. font-size: 38rpx;
  1727. }
  1728. .youhui {
  1729. font-size: 20rpx;
  1730. color: #999;
  1731. font-weight: 400;
  1732. }
  1733. .mingxi {
  1734. font-size: 22rpx;
  1735. color: #999;
  1736. font-weight: 400;
  1737. padding-left: 14rpx;
  1738. }
  1739. }
  1740. .footer .placeOrder {
  1741. color: #fff;
  1742. font-size: 30rpx;
  1743. padding: 0 20rpx;
  1744. height: 70rpx;
  1745. border-radius: 50rpx;
  1746. text-align: center;
  1747. line-height: 70rpx;
  1748. margin-left: 22rpx;
  1749. }
  1750. .footer .button .bnt {
  1751. font-size: 28rpx;
  1752. color: #999;
  1753. border-radius: 50rpx;
  1754. border: 1px solid #999;
  1755. width: 160rpx;
  1756. height: 60rpx;
  1757. text-align: center;
  1758. line-height: 60rpx;
  1759. }
  1760. .btn_cart_color {
  1761. font-size: 14px;
  1762. border-radius: 25px;
  1763. width: 80px;
  1764. height: 30px;
  1765. text-align: center;
  1766. line-height: 30px;
  1767. @include coupons_border_color(theme);
  1768. @include main_color(theme);
  1769. }
  1770. .footer .button form~form {
  1771. margin-left: 17rpx;
  1772. }
  1773. .uni-p-b-96 {
  1774. height: 96rpx;
  1775. }
  1776. /deep/ checkbox .uni-checkbox-input.uni-checkbox-input-checked {
  1777. @include main_bg_color(theme);
  1778. border: none !important;
  1779. color: #fff !important
  1780. }
  1781. /deep/ checkbox .wx-checkbox-input.wx-checkbox-input-checked {
  1782. @include main_bg_color(theme);
  1783. border: none !important;
  1784. color: #fff !important;
  1785. margin-right: 0 !important;
  1786. }
  1787. .allcheckbox .iconfont {
  1788. margin-right: 16rpx;
  1789. }
  1790. .window {
  1791. position: fixed;
  1792. bottom: calc(var(--window-bottom) + 100rpx);
  1793. width: 100%;
  1794. left: 0;
  1795. background-color: #fff;
  1796. z-index: 77;
  1797. border-radius: 20rpx 20rpx 0 0;
  1798. padding-bottom: 0;
  1799. transform: translate3d(0, 100%, 0);
  1800. transition: all .2s cubic-bezier(0, 0, .25, 1);
  1801. }
  1802. .window.on {
  1803. transform: translate3d(0, 0, 0);
  1804. }
  1805. .popup_content {
  1806. height: 900rpx;
  1807. padding: 40rpx 16rpx;
  1808. box-sizing: border-box;
  1809. ._tit {
  1810. font-weight: 500;
  1811. color: #333;
  1812. font-size: 32rpx;
  1813. margin-bottom: 20rpx;
  1814. }
  1815. ._desc {
  1816. font-size: 24rpx;
  1817. color: #999;
  1818. }
  1819. ._pro_content {
  1820. width: 100%;
  1821. background: #F8F8F8;
  1822. border-radius: 14rpx;
  1823. margin: 20rpx 0 40rpx;
  1824. padding: 30rpx 14rpx;
  1825. }
  1826. ._pro_box {
  1827. width: 100%;
  1828. display: grid;
  1829. grid-template-columns: repeat(4, 1fr);
  1830. grid-template-rows: auto;
  1831. grid-gap: 16rpx;
  1832. ._pic_item {
  1833. width: 160rpx;
  1834. height: 160rpx;
  1835. position: relative;
  1836. image {
  1837. width: 100%;
  1838. height: 100%;
  1839. border-radius: 14rpx;
  1840. }
  1841. .checkbox {
  1842. width: 34rpx;
  1843. height: 34rpx;
  1844. position: absolute;
  1845. top: 6rpx;
  1846. right: 10rpx;
  1847. z-index: 9;
  1848. .iconfont {
  1849. font-size: 34rpx;
  1850. color: #fff;
  1851. }
  1852. }
  1853. }
  1854. }
  1855. ._more {
  1856. width: 100%;
  1857. color: #666;
  1858. font-size: 24rpx;
  1859. margin-top: 30rpx;
  1860. .iconfont {
  1861. font-size: 24rpx;
  1862. margin-left: 10rpx;
  1863. }
  1864. }
  1865. ._cell {
  1866. font-size: 28rpx;
  1867. margin-bottom: 40rpx;
  1868. padding: 0 14rpx;
  1869. ._label {
  1870. color: #666;
  1871. font-weight: 400;
  1872. }
  1873. ._count {
  1874. color: #333;
  1875. }
  1876. }
  1877. ._cell_all {
  1878. font-size: 32rpx;
  1879. font-weight: 600;
  1880. padding: 0 14rpx;
  1881. ._label {
  1882. color: #333;
  1883. }
  1884. ._count {
  1885. color: #333;
  1886. @include price_color(theme);
  1887. }
  1888. }
  1889. }
  1890. .window .icon-guanbi5 {
  1891. position: absolute;
  1892. font-size: 28rpx;
  1893. color: #aaa;
  1894. top: 30rpx;
  1895. right: 30rpx;
  1896. z-index: 1;
  1897. }
  1898. </style>