index.vue 35 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385
  1. <template>
  2. <view class="container cart clearfix" v-if="hasLogin">
  3. <tui-skeleton v-if="skeletonShow" backgroundColor="#fafafa" borderRadius="10rpx" :isLoading ="true" :loadingType="5"></tui-skeleton>
  4. <view class="container-cart-main tui-skeleton" :style="{paddingTop:isshowDelbtn ? '0rpx':'80rpx'}">
  5. <view class="foot-check-delbtn" v-if="!isshowDelbtn && goodsList.length>0">
  6. <view class="foot-text">共<text>{{kindCount}}</text>件商品</view>
  7. <view class="delBtn" @tap.stop="showDelManager">删除</view>
  8. </view>
  9. <view v-if="!isEmpty" class="container-cart">
  10. <view class="cart-content" :style="{paddingBottom :isIphoneX ? '130rpx' : '100rpx'}">
  11. <view class="goods-list">
  12. <view v-for="(item, index) in goodsList" :key="index" class="goods-item clearfix">
  13. <view class="shoptitle">
  14. <!--选择商店的全部商品"-->
  15. <view class="checkbox-box" @click.stop="checkShop(item)">
  16. <view class="checkbox iconfont" :class="[item.checked ?'icon-xuanze':'icon-weixuanze']"></view>
  17. </view>
  18. <view class="text">{{item.name}}</view>
  19. </view>
  20. <view class="productlist">
  21. <view class="goods-pros" v-for="(pros,idx) in item.productList" :key="idx" >
  22. <view class="goods-pros-t">
  23. <!--选择商品-->
  24. <view class="checkbox-box" @click.stop="ischeck(item,pros)">
  25. <view class="checkbox iconfont" :class="[pros.productsChecked ? 'icon-xuanze':'icon-weixuanze']"></view>
  26. </view>
  27. <view class="pros-img" @click.stop="navToListPage(pros)" ><image :src="pros.mainImage ? pros.mainImage:''" alt="" /></view>
  28. <view class="pros-product">
  29. <view class="producttitle" @click.stop="navToListPage(pros)" >{{pros.productName}}</view>
  30. <view class="productspec">规格:{{pros.unit ? pros.unit : ''}}</view>
  31. <view class="floor-item-act" v-if="pros.activeStatus == 1">
  32. <text class="tag tag-01" v-if="!pros.heUserId">自营</text>
  33. <text class="tag tag-01" v-else>促销</text>
  34. <text class="tag tag-02" @click.stop="clickPopupShow(pros,2)">活动价</text>
  35. </view>
  36. <view class="productprice">
  37. <!--使用过滤器对总价改变-->
  38. <view class="price"><text>¥</text>{{ pros.price | NumFormat }}</view>
  39. <view class="count">
  40. <view class="number-box">
  41. <view class="iconfont icon-jianhao" @click="changeCountSub(item,pros)"></view>
  42. <input class="btn-input" type="number" maxlength='4' v-model="pros.productCount" @blur="changeNnmber($event,item,pros)" @focus="changeInput(pros)">
  43. <view class="iconfont icon-jiahao" @click="changeCountAdd(item,pros)"></view>
  44. </view>
  45. </view>
  46. </view>
  47. </view>
  48. </view>
  49. </view>
  50. </view>
  51. <view class="goods-pros-b clearfix" :class="[isshowDelbtn ? 'none':'show']" >
  52. <view class="sum-none" v-if="item.reducedPrice>0">
  53. <text class="money-sign">¥</text>
  54. <text class="money">{{ item.totalOriginalPrice | NumFormat }}</text>
  55. <text class="money-reduced">减<text>¥{{ item.reducedPrice | NumFormat}}</text></text>
  56. </view>
  57. <view class="sum">合计:<text class="money"><text class="money-sign">¥</text>{{item.totalPrice | NumFormat}}</text></view>
  58. </view>
  59. </view>
  60. </view>
  61. <view class="failure-list" v-if="failureList.length>0">
  62. <view class="failure-title">
  63. <view class="title-txt">失效商品<text>{{failureList.length}}件</text></view>
  64. <view class="title-btn" @click.stop="deletefailureList"><text class="butto">清空失效商品</text></view>
  65. </view>
  66. <view class="productlist">
  67. <view class="goods-pros" v-for="(failure,failureIdx) in failureList" :key="failureIdx" >
  68. <view class="goods-pros-t" @click.stop="navToListPage(failure)">
  69. <!--选择商品-->
  70. <view class="checkbox-box" @click.stop="ischeckFailure(failure)" v-if="isshowDelbtn">
  71. <button class="checkbox iconfont"
  72. :class="[ failure.productsChecked ? 'icon-xuanze':'icon-weixuanze']">
  73. </button>
  74. </view>
  75. <text class="img-tip">失效</text>
  76. <view class="pros-img">
  77. <image :src="failure.mainImage ? failure.mainImage:''" alt="" />
  78. </view>
  79. <view class="pros-product">
  80. <view class="producttitle">{{failure.name}}</view>
  81. <view class="productspec">规格:{{failure.unit ? failure.unit : ''}}</view>
  82. <view class="productstate">商品已下架</view>
  83. </view>
  84. </view>
  85. </view>
  86. </view>
  87. </view>
  88. </view>
  89. <!-- 脚部菜单 -->
  90. <view class="footer">
  91. <view class="footer-le">
  92. <view class="foot-check checkbox-box" @tap.stop="checkAll()">
  93. <button class="checkbox iconfont" :class="[isCheckAll?'icon-xuanze':'icon-weixuanze']"></button>
  94. <view class="text">全选</view>
  95. </view>
  96. <view class="sum">
  97. <view v-if="!isshowDelbtn" class="sum-price">
  98. 总价:<text class="money-sign">¥</text><text class="money">{{allPrice | NumFormat}}</text>
  99. </view>
  100. </view>
  101. </view>
  102. <view v-if="!isshowDelbtn" class="footer-ri" >
  103. <view class="btn hanld-btn" @tap="toConfirmation">去结算({{allCount}})</view>
  104. </view>
  105. <view v-else class="footer-del">
  106. <view class="btn btn-cancel" @tap.stop="hideDelManage">取消</view>
  107. <view class="btn btn-confirm" @tap.stop="deleteList">删除</view>
  108. </view>
  109. </view>
  110. </view>
  111. <view v-else class="cart-content empty">
  112. <view class="empty-container">
  113. <image class="empty-container-image" :src="StaticUrl+'icon-empty-cart.png'" mode="aspectFit"></image>
  114. <text class="error-text">购物车空空的,快去逛逛吧~</text>
  115. </view>
  116. </view>
  117. </view>
  118. <!-- 操作弹窗 -->
  119. <tui-modal :show="modal" @click="handleClick" @cancel="hideMobel" :content="contentModalText" color="#333" :size="32" shape="circle" :maskClosable="false"></tui-modal>
  120. <!-- 促销活动弹窗 -->
  121. <activi-popup :product="handlerPros" :popupShow="popupShow"></activi-popup>
  122. <!-- 透明模态层 -->
  123. <modal-layer v-if='modallayer'></modal-layer>
  124. </view>
  125. </template>
  126. <script>
  127. import authorize from '@/common/config/authorize.js'
  128. import tuiSkeleton from "@/components/tui-skeleton/tui-skeleton"
  129. import tuiLoadmore from "@/components/tui-components/loadmore/loadmore"
  130. import tuiNomore from "@/components/tui-components/nomore/nomore"
  131. import activiPopup from "@/components/cm-module/productDetails/cm-activipopu"
  132. import modalLayer from "@/components/modal-layer"
  133. import { mapState,mapMutations } from 'vuex';
  134. export default{
  135. components:{
  136. tuiSkeleton,
  137. tuiLoadmore,
  138. tuiNomore,
  139. activiPopup,
  140. modalLayer
  141. },
  142. data(){
  143. return{
  144. StaticUrl:this.$Static,
  145. CustomBar:this.CustomBar,// 顶部导航栏高度
  146. isIphoneX:this.$store.state.isIphoneX,
  147. userId:'',
  148. popupShow:false,
  149. handlerPros:{},//监听单挑促销商品
  150. failureList:[], //失效商品列表
  151. goodsList:[], //购物车的商品
  152. delGoodsList:'',//要删除的商品
  153. setGoodData:'', //确认订单的商品
  154. isCheckAll:false,//是否全选
  155. kindCount:0,//购物车宝贝数量
  156. allPrice:0,//所有价格
  157. totalOriginalPrice:0,//所有原价价
  158. reducedPrice:0,//满减
  159. allCount:0,//被选中的产品数量
  160. isModallayer:false,
  161. skeletonShow:true,
  162. isshowDelbtn:false,
  163. isDisabled: false, // 供应商/店铺全选是否禁用状态
  164. isEmpty:false,//显示空购物车
  165. scrollHeight: 'auto',
  166. nomoreText: '上拉显示更多',
  167. hasNextPage: false,
  168. loadding: false,
  169. pullUpOn: true,
  170. pullFlag: true,
  171. pageSize: 10,
  172. pageNum: 1,
  173. submitIds:[],
  174. modal:false,
  175. contentModalText:'',
  176. deleteType:0,
  177. }
  178. },
  179. onLoad(){
  180. this.setScrollHeight();
  181. },
  182. computed: {
  183. ...mapState(['hasLogin','userInfo'])
  184. },
  185. filters:{
  186. NumFormat(value) {//处理金额
  187. return Number(value).toFixed(2);
  188. },
  189. totalprice(val,count){//单件商品的价格 × 数量
  190. return (val * count).toFixed(2)
  191. }
  192. },
  193. methods:{
  194. initData(){
  195. this.isModallayer = false //遮罩层 防止多次点击
  196. this.isCheckAll=false//是否全选
  197. this.submitIds = []
  198. this.$api.getStorage().then((resolve) => {
  199. this.userId = resolve.userId ? resolve.userId : 0;
  200. this.InitGetCartGoodsList();
  201. this.GetCartNumber();
  202. })
  203. },
  204. clickPopupShow(pros,type){
  205. if(pros.ladderList.length>0){
  206. this.popupShow = true;
  207. this.handlerPros = pros;
  208. }
  209. },
  210. setScrollHeight() {
  211. // 窗口高度-footer高度
  212. const {windowHeight, pixelRatio} = uni.getSystemInfoSync();
  213. setTimeout(()=> {
  214. const query = uni.createSelectorQuery().in(this);
  215. query.selectAll('.footer').boundingClientRect();
  216. query.exec(res => {
  217. this.windowHeight = windowHeight;
  218. if(res[0][0]) {
  219. this.scrollHeight = windowHeight - res[0][0].height;
  220. }
  221. })
  222. }, 500)
  223. },
  224. InitGetCartGoodsList(){//初始化购物车 index:1
  225. this.ProductService.QueryShoppingCartList({userId:this.userId}).then(response =>{
  226. this.skeletonShow = false
  227. let data = response.data
  228. this.kindCount = data.cartQuantity
  229. if( data.shopList.length > 0 || data.products.length > 0){
  230. this.isEmpty =false
  231. }else{
  232. this.isEmpty =true
  233. }
  234. if(data.shopList && data.shopList.length > 0 ){
  235. this.goodsList = data.shopList;
  236. console.log(this.goodsList)
  237. this.totalShopPeice()
  238. } else {
  239. this.goodsList = [];
  240. }
  241. if( data.products && data.products.length > 0){
  242. this.failureList = data.products
  243. } else {
  244. this.failureList = [];
  245. }
  246. }).catch(error =>{
  247. this.$util.msg(error.msg,2000);
  248. })
  249. },
  250. ischeckFailure(failure){
  251. failure.productsChecked = !failure.productsChecked
  252. this.updateCheckAllBtn()
  253. },
  254. ischeck(item,pro){//为未选中的时候改变为true,反之为true
  255. pro.productsChecked = !pro.productsChecked;
  256. if(pro.productsChecked) {
  257. if(!this.submitIds.includes(pro.productID*1)){
  258. this.submitIds.push(pro.productID);
  259. }
  260. } else {
  261. var lent = this.submitIds.indexOf(pro.productID*1);
  262. if(lent >=0 ){
  263. this.submitIds.splice(lent, 1);
  264. }
  265. }
  266. this.updateProductCheckedAllBtn(item);
  267. this.updateCheckAllBtn();
  268. },
  269. updateProductCheckedAllBtn(item) {// 单独每个供应商的勾选判断
  270. let productList = item.productList,
  271. productsCheckedLength = 0,
  272. disabledLength = 0;
  273. if(this.isshowDelbtn) {
  274. productList.forEach(pros => {
  275. if(pros.productsChecked) {
  276. productsCheckedLength++;
  277. }
  278. })
  279. } else {
  280. productList.forEach(pros => {
  281. if(pros.productsChecked) {
  282. productsCheckedLength++;
  283. }
  284. })
  285. }
  286. item.checked = productsCheckedLength === productList.length;
  287. },
  288. updateCheckAllBtn() {// 全选勾选判断
  289. let goodsCheckedLength = 0,
  290. goodsList = this.goodsList,
  291. failureList = this.failureList;
  292. goodsList.forEach(item => {
  293. if(item.checked) {
  294. goodsCheckedLength++;
  295. }
  296. })
  297. failureList.forEach(failureItem=>{
  298. if(failureItem.productsChecked){
  299. goodsCheckedLength++;
  300. }
  301. })
  302. if(this.isshowDelbtn){
  303. this.isCheckAll = goodsCheckedLength === goodsList.length + failureList.length;
  304. }else{
  305. this.isCheckAll = goodsCheckedLength === goodsList.length;
  306. }
  307. },
  308. checkShop(item){//与单选商品类似
  309. item.checked = !item.checked;
  310. this.setProductChecked(item);
  311. this.updateCheckAllBtn();
  312. },
  313. setProductChecked(item) {
  314. item.productList.forEach(pros=>{
  315. if(item.checked) {
  316. pros.productsChecked = true;
  317. if(!this.submitIds.includes(pros.productId*1)){
  318. this.submitIds.push(pros.productId);
  319. }
  320. } else {
  321. pros.productsChecked = false;
  322. var lent = this.submitIds.indexOf(pros.productId*1);
  323. if(lent >=0 ){
  324. this.submitIds.splice(lent, 1);
  325. }
  326. }
  327. })
  328. },
  329. updateBothCheckBtn() {
  330. if(this.isshowDelbtn) {
  331. // 当管理删除按钮出现时,失效的商品可被选择
  332. this.goodsList.forEach((item)=>{
  333. item.checked = this.isCheckAll;
  334. this.setProductChecked(item);
  335. })
  336. //删除按钮 全选包括失效商品勾选
  337. this.failureList.forEach(failureItem=>{
  338. failureItem.productsChecked = this.isCheckAll;
  339. })
  340. } else {
  341. this.goodsList.forEach((item)=>{
  342. item.checked = this.isCheckAll && !item.isDisabled;
  343. this.setProductChecked(item);
  344. })
  345. }
  346. },
  347. checkAll(){//全选方法内调用方法
  348. this.isCheckAll = !this.isCheckAll;
  349. this.updateBothCheckBtn();
  350. },
  351. totalShopPeice(){//每次所属会所下的商品增减重新计算合计价格&减去含有下架的商品
  352. let touchPrice = 0;
  353. let reducedPrice = 0;//商铺合计满减价
  354. this.goodsList.map((item,index)=>{
  355. let _totalPrice = 0;
  356. let _reducedPrice = 0;
  357. let _totalOriginalPrice =0;
  358. item.productList.forEach(pros=>{
  359. let _price = pros.price*pros.productCount
  360. _totalOriginalPrice += pros.price*pros.productCount;
  361. if(pros.promotion && pros.promotion.type != 2 && pros.promotion.mode == 2){
  362. if(_price >= pros.promotion.touchPrice){
  363. _price = _price - pros.promotion.reducedPrice
  364. _reducedPrice += pros.promotion.reducedPrice
  365. }
  366. _totalPrice += _price
  367. }else{
  368. _reducedPrice = 0;
  369. _totalPrice += pros.price*pros.productCount;
  370. }
  371. })
  372. item.reducedPrice = _reducedPrice
  373. item.totalOriginalPrice = _totalOriginalPrice
  374. item.totalPrice = _totalPrice
  375. })
  376. },
  377. totalPeice(){//计算总价格,每次调用此方法,将初始值为0,遍历价格并累加
  378. let totalPrice = 0;
  379. let reducedPrice = 0;
  380. let originalPrice = 0;
  381. this.goodsList.forEach((item,index)=>{
  382. let supplierPrice = 0;
  383. let supplierReducedPrice = 0;
  384. item.totalprice = 0;
  385. item.reducedprice = 0;
  386. item.originalprice = 0;
  387. item.productList.forEach(pros=>{
  388. if(pros.productsChecked){
  389. supplierPrice += pros.price*pros.productCount;
  390. // 单品满减
  391. if(pros.promotion && pros.promotion.type*1===1 && pros.promotion.mode*1===2){
  392. // 单品满减-重新计算供应商总价/满减金额
  393. if(pros.price*pros.productCount >= pros.promotion.touchPrice){
  394. supplierPrice -= pros.promotion.reducedPrice;
  395. supplierReducedPrice += pros.promotion.reducedPrice;
  396. }
  397. }
  398. }
  399. })
  400. item.totalprice = supplierPrice;
  401. item.reducedprice = supplierReducedPrice;
  402. item.originalprice = (supplierPrice+supplierReducedPrice);
  403. totalPrice += item.totalprice;
  404. reducedPrice += item.reducedprice;
  405. originalPrice += item.originalprice;
  406. })
  407. //最后统计商品原价
  408. this.totalOriginalPrice = originalPrice;
  409. //最后满减金额 = 店铺减去金额 + 单品减去金额 + 凑单减去金额
  410. this.reducedPrice = reducedPrice;
  411. //最终合计价格 = 店铺满减合计 + 单品满减 + 正常合计 + 凑单满减
  412. this.allPrice = totalPrice ;
  413. },
  414. totalCount(){//计算总数量
  415. this.allCount = 0
  416. let prosAllCount=0
  417. let validCount = 0
  418. let validList =[];
  419. let productList =[];
  420. this.goodsList.forEach(item=>{
  421. productList = item.productList
  422. productList.forEach(pros=>{
  423. if(pros.productsChecked){
  424. prosAllCount+=parseInt(pros.productCount);
  425. this.allCount = prosAllCount
  426. }
  427. })
  428. })
  429. },
  430. changeCountAdd(item,pros){//商品数量加加
  431. pros.productCount++
  432. this.processActivityPrice(pros)
  433. this.updateShoppogNum(pros)
  434. this.totalShopPeice();
  435. },
  436. changeCountSub(item,pros){//商品数量减减
  437. if(pros.productCount<=1){
  438. pros.productCount= 1
  439. this.$util.msg(`购买数量不能少于1`,2000);
  440. return
  441. }else{
  442. pros.productCount--
  443. }
  444. this.processActivityPrice(pros)
  445. this.updateShoppogNum(pros)
  446. this.totalShopPeice();
  447. },
  448. changeInput(pros){//输入商品数量更新
  449. },
  450. changeNnmber(e,item,pros){//输入商品数量更新
  451. let _value = Number(e.detail.value);
  452. if(!this.$api.isNumber(_value)){
  453. pros.productCount = 1
  454. }else if(_value <= 1){
  455. this.$util.msg(`购买数量不能少于1`,2000);
  456. pros.productCount = 1
  457. }else{
  458. pros.productCount = e.detail.value
  459. }
  460. this.processActivityPrice(pros)
  461. this.updateShoppogNum(pros)
  462. this.totalShopPeice();
  463. },
  464. processActivityPrice(pros){//单独处理活动价格和阶梯价格
  465. if(pros.activeStatus == 1){
  466. pros.ladderList.forEach((item,index)=>{
  467. if(pros.productCount>=item.buyNum){
  468. pros.price = item.buyPrice
  469. }
  470. })
  471. }else{
  472. pros.price = pros.price
  473. }
  474. },
  475. updateShoppogNum(pros){//加减购物车商品更新到后台
  476. this.ProductService.ShoppingCartUpdate(
  477. {
  478. cartId:pros.cartId,
  479. productCount:pros.productCount,
  480. }
  481. )
  482. .then(response =>{
  483. this.isshowDelbtn = false;
  484. this.InitGetCartGoodsList();
  485. })
  486. .catch(error =>{
  487. this.$util.msg(error.msg,2000);
  488. })
  489. },
  490. toConfirmation(){//跳转确认订单页面
  491. let setGoodsList=[];
  492. this.goodsList.forEach(res=>{
  493. let products = res.productList
  494. products.forEach(pros=>{
  495. if(pros.productsChecked){
  496. setGoodsList.push(pros.productId)
  497. }
  498. })
  499. })
  500. if(setGoodsList == ''){
  501. this.$util.msg("请先选择结算商品~",2000);
  502. return
  503. }
  504. let cartIds = '';
  505. this.goodsList.forEach(el=>{//获取勾选的商品ID拼接字符串逗号隔开,最后一个逗号去掉
  506. el.productList.forEach(pros=>{
  507. if(pros.productsChecked){
  508. cartIds += pros.cartId+','
  509. }
  510. })
  511. })
  512. let cartPramsData={
  513. allPrice:this.allPrice,
  514. allCount:this.allCount,
  515. cartIds:cartIds.substring(0,cartIds.lastIndexOf(',')),
  516. productCount:''
  517. }
  518. this.$api.navigateTo(`/pages/user/order/create-order?data=${JSON.stringify({data:cartPramsData})}`)
  519. },
  520. showDelManager(){//显示删除商品管理
  521. this.isshowDelbtn = true;
  522. if(this.isCheckAll) {
  523. this.updateBothCheckBtn();
  524. } else {
  525. this.goodsList.forEach(item => {
  526. if(item.checked) {
  527. item.productList.forEach(pros => {
  528. pros.productsChecked = true;
  529. })
  530. }
  531. })
  532. this.updateCheckAllBtn();
  533. }
  534. // 失效也被勾选
  535. this.failureList.forEach(failureItem => {
  536. if(failureItem.isFailureLayer){
  537. failureItem.isFailureLayer = false
  538. }
  539. })
  540. },
  541. hideDelManage(){//隐藏删除商品管理
  542. this.isshowDelbtn = false;
  543. let isFailureLayer,newFailureList =[];
  544. if(this.isCheckAll) {
  545. this.updateBothCheckBtn();
  546. } else {
  547. // 失效商品取消勾选
  548. this.goodsList.forEach(item => {
  549. if(item.isDisabled) {
  550. item.checked = false;
  551. }
  552. item.productList.forEach(pros => {
  553. if(pros.validFlag == 3) {
  554. pros.productsChecked = false;
  555. }
  556. })
  557. })
  558. this.updateCheckAllBtn();
  559. }
  560. this.failureList.forEach((failure,index) => {
  561. if(failure.failureState == 1 || failure.failureState == 2) {
  562. isFailureLayer = true
  563. }else{
  564. isFailureLayer = false
  565. }
  566. newFailureList.push(Object.assign({},failure,{isFailureLayer:isFailureLayer}))
  567. })
  568. this.failureList = newFailureList;
  569. },
  570. deleteList(){//删除购物车商品
  571. this.delGoodsList=[];
  572. this.goodsList.forEach(delitem=>{
  573. let products = delitem.productList
  574. products.forEach(pros=>{
  575. if(pros.productsChecked){
  576. this.delGoodsList += pros.cartId+','
  577. }
  578. })
  579. })
  580. this.failureList.forEach(failure=>{
  581. if(failure.productsChecked){
  582. this.delGoodsList += failure.cartId+','
  583. }
  584. })
  585. if(this.delGoodsList.length == 0){
  586. this.$util.msg("请选择要删除的商品~",2000);
  587. return
  588. }else{
  589. this.modal = true;
  590. this.contentModalText = '确定删除选中的商品吗?';
  591. this.deleteType = 1
  592. }
  593. },
  594. deletefailureList(){
  595. this.delGoodsList = ''
  596. this.failureList.forEach(failure=>{ this.delGoodsList += failure.cartId+',' })
  597. this.modal = true;
  598. this.contentModalText = '确定清除所有失效商品吗?';
  599. this.deleteType = 2
  600. },
  601. handleClick(e) {//用户操作订单
  602. let index = e.index;
  603. if(index == 1){
  604. this.ProductService.ShoppingCartDelete(
  605. {
  606. cartIds:this.delGoodsList,
  607. }
  608. )
  609. .then(response =>{
  610. this.$util.msg('删除成功',2000);
  611. setTimeout(()=>{
  612. this.isshowDelbtn = false;
  613. this.InitGetCartGoodsList();
  614. },1000)
  615. }).catch(error =>{
  616. this.$util.msg(error.msg,2000)
  617. })
  618. }
  619. this.modal = false;
  620. },
  621. hideMobel(){
  622. this.modal = false;
  623. },
  624. GetCartNumber(){//查询购物车数量
  625. this.ProductService.QueryShoppingQuantity(
  626. {
  627. userId:this.userId,
  628. }
  629. )
  630. .then(response => {
  631. this.$store.commit('updateAllNum',response.data)
  632. })
  633. .catch(error =>{
  634. console.log('查询购物车数量错误信息',error)
  635. })
  636. },
  637. navToListPage(item){
  638. this.isModallayer = true;
  639. this.$api.navigateTo(`/pages/goods/product?productId=${item.productId}`)
  640. },
  641. setHeaderBtnPosi(){
  642. // 获得胶囊按钮位置信息
  643. let headerBtnPosi = uni.getMenuButtonBoundingClientRect();
  644. return headerBtnPosi
  645. },
  646. setSysteminfo(){
  647. let systeminfo;
  648. uni.getSystemInfo({ // 获取设备信息
  649. success: (res) => {
  650. systeminfo = res
  651. },
  652. })
  653. return systeminfo
  654. },
  655. PromotionsFormat(promo){//促销活动类型数据处理
  656. if(promo!=null){
  657. if(promo.type == 1 && promo.mode == 1){
  658. return true
  659. }else{
  660. return false
  661. }
  662. }
  663. return false
  664. }
  665. },
  666. watch:{//深度监听所有数据,每次改变重新计算总价和总数
  667. goodsList:{
  668. deep:true,
  669. handler(val,oldval){
  670. this.totalPeice()
  671. this.totalCount()
  672. }
  673. }
  674. },
  675. onPullDownRefresh() {//下拉刷新
  676. this.InitGetCartGoodsList()
  677. uni.stopPullDownRefresh()
  678. },
  679. onShow(){
  680. if(this.hasLogin){
  681. this.initData()
  682. }else{
  683. this.$api.redirectTo('/pages/login/login')
  684. }
  685. },
  686. }
  687. </script>
  688. <style lang="scss">
  689. page{
  690. background: #f7f7f7;
  691. height: auto;
  692. }
  693. .cart-content{
  694. position: relative;
  695. }
  696. .container-cart-main.none{
  697. display: none;
  698. }
  699. .container-cart-main.show{
  700. display: block;
  701. }
  702. .cart-content.empty.none{
  703. display: none;
  704. }
  705. .cart-content.empty.show{
  706. display: block;
  707. }
  708. .container-cart.show{
  709. display: block;
  710. }
  711. .container-cart.none{
  712. display: none;
  713. }
  714. .empty-container.none{
  715. display: none;
  716. }
  717. .empty-container.show{
  718. display: flex;
  719. }
  720. .foot-check-delbtn{
  721. width: 100%;
  722. height: 80rpx;
  723. position: fixed;
  724. top: 0;
  725. left: 0;
  726. box-sizing: border-box;
  727. padding: 15rpx 24rpx;
  728. background-color: #F7F7F7;
  729. z-index: 990;
  730. .foot-text{
  731. font-size: $font-size-26;
  732. height: 50rpx;
  733. line-height: 50rpx;
  734. color:#666666;
  735. float: left;
  736. padding-left: 10rpx;
  737. text{
  738. margin: 0 6rpx;
  739. }
  740. }
  741. .delBtn{
  742. width: 100rpx;
  743. display: inline-block;
  744. padding: 0 15rpx;
  745. font-size: $font-size-26;
  746. height: 50rpx;
  747. line-height: 50rpx;
  748. border-radius: 30rpx;
  749. background:#FFFFFF;
  750. border: 1px solid #ff457b;
  751. color: #ff457b;
  752. float: right;
  753. text-align: center;
  754. &.none{
  755. display: none;
  756. }
  757. }
  758. }
  759. .checkbox-box{
  760. display: flex;
  761. align-items: center;
  762. .checkbox{
  763. display: flex;
  764. margin: 0;
  765. padding:0 5rpx;
  766. display: flex;
  767. flex-direction: column;
  768. align-items: center;
  769. box-sizing: border-box;
  770. text-align: center;
  771. text-decoration: none;
  772. border-radius: 0;
  773. -webkit-tap-highlight-color: transparent;
  774. overflow: hidden;
  775. background-color:#FFFFFF;
  776. font-size: 36rpx;
  777. color:#999999;
  778. &.icon-xuanze{
  779. color: $color-system;
  780. }
  781. }
  782. &.disabled{
  783. .checkbox{
  784. color:#999999
  785. }
  786. }
  787. .text{
  788. font-size: $font-size-24;
  789. margin-left: 10rpx;
  790. }
  791. }
  792. .goods-list{
  793. width: 100%;
  794. height: auto;
  795. background-color: #F7F7F7;
  796. .goods-item{
  797. width: 702rpx;
  798. padding: 0 24rpx;
  799. background: #FFFFFF;
  800. margin-bottom: 24rpx;
  801. }
  802. .shoptitle{
  803. display: flex;
  804. align-items: center;
  805. height: 80rpx;
  806. line-height: 80rpx;
  807. .checkbox-box{
  808. padding: 10rpx;
  809. }
  810. .text{
  811. width: 450rpx;
  812. display: block;
  813. overflow: hidden;
  814. text-overflow:ellipsis;
  815. white-space: nowrap;
  816. margin-left: 20rpx;
  817. font-size: $font-size-28;
  818. color: $text-color;
  819. text-align: left;
  820. font-weight: bold;
  821. }
  822. }
  823. .goods-pros{
  824. width: 100%;
  825. height: auto;
  826. margin-bottom: 20rpx;
  827. }
  828. .goods-pros-t{
  829. display: flex;
  830. align-items: center;
  831. width: 100%;
  832. height: 210rpx;
  833. padding:0 0 26rpx 0;
  834. .checkbox-box{
  835. padding: 10rpx;
  836. }
  837. .pros-img{
  838. width: 210rpx;
  839. height: 100%;
  840. border-radius: 10rpx;
  841. margin:0 20rpx;
  842. border:1px solid #f3f3f3;
  843. image{
  844. width: 100%;
  845. height: 100%;
  846. border-radius: 10rpx;
  847. }
  848. }
  849. }
  850. .goods-pros-b{
  851. width:100%;
  852. height: auto;
  853. padding:0 0 24rpx 0;
  854. box-sizing: border-box;
  855. &.show{
  856. display: block;
  857. }
  858. &.none{
  859. display: none;
  860. }
  861. .sum-none{
  862. width: 100%;
  863. height: 48rpx;
  864. line-height: 48rpx;
  865. color: $text-color;
  866. float: left;
  867. text-align: right;
  868. .money{
  869. font-size: $font-size-26;
  870. color: #999999;
  871. text-decoration: line-through;
  872. }
  873. .money-sign{
  874. font-size: $font-size-26;
  875. color: #999999;
  876. text-decoration: line-through;
  877. }
  878. .money-reduced{
  879. margin-left: 10rpx;
  880. font-size: $font-size-26;
  881. color: $color-system;
  882. .iconfont{
  883. font-size: $font-size-34;
  884. }
  885. }
  886. }
  887. .sum{
  888. width: 100%;
  889. height: 40rpx;
  890. font-size: $font-size-26;
  891. line-height: 40rpx;
  892. color: $text-color;
  893. float: left;
  894. display: flex;
  895. justify-content: flex-end;
  896. font-weight: bold;
  897. .money{
  898. color: $color-system;
  899. font-size: $font-size-26;
  900. }
  901. .money-sign{
  902. font-size: $font-size-24;
  903. color: $color-system;
  904. }
  905. }
  906. }
  907. .pros-product{
  908. width: 416rpx;
  909. height: 100%;
  910. line-height: 36rpx;
  911. font-size: $font-size-28;
  912. position: relative;
  913. .producttitle{
  914. width: 100%;
  915. display: inline-block;
  916. height: auto;
  917. text-overflow:ellipsis;
  918. display: -webkit-box;
  919. word-break: break-all;
  920. -webkit-box-orient: vertical;
  921. -webkit-line-clamp: 2;
  922. overflow: hidden;
  923. margin-bottom: 15rpx;
  924. .no-text{
  925. display: inline-block;
  926. height:36rpx;
  927. padding: 0 12rpx;
  928. line-height: 36rpx;
  929. background:linear-gradient(315deg,rgba(231,0,0,1) 0%,rgba(255,104,1,1) 100%);
  930. border-radius:18rpx;
  931. text-align: center;
  932. color: #FFFFFF;
  933. font-size:$font-size-28;
  934. margin-right: 24rpx;
  935. }
  936. }
  937. .productspec{
  938. height: 36rpx;
  939. color: #999999;
  940. font-size: $font-size-26;
  941. }
  942. .productprice{
  943. position: absolute;
  944. bottom: 0;
  945. width: 100%;
  946. height: 48rpx;
  947. margin: 30rpx 0 0 0;
  948. .price{
  949. line-height: 48rpx;
  950. font-size: $font-size-26;
  951. width: 48%;
  952. color: $color-system;
  953. float: left;
  954. font-weight: bold;
  955. &.disabled{
  956. color: #999999;
  957. text-decoration: line-through;
  958. }
  959. .money-sign{
  960. font-size: $font-size-24;
  961. color: $color-system;
  962. }
  963. }
  964. .count{
  965. height: 100%;
  966. float: right;
  967. position: relative;
  968. &.show{
  969. display: block;
  970. }
  971. &.none{
  972. display: none;
  973. }
  974. .count-tips{
  975. width: auto;
  976. display: inline-block;
  977. padding: 0 15rpx;
  978. line-height: 44rpx;
  979. height: 44rpx;
  980. border-radius: 22rpx;
  981. background: $btn-confirm;
  982. font-size: $font-size-24;
  983. text-align: center;
  984. color: #FFFFFF;
  985. position: absolute;
  986. top:-60rpx;
  987. left: -5rpx;
  988. z-index: 5;
  989. &.step{
  990. left:-217rpx
  991. }
  992. &::before{
  993. content: "";
  994. position: absolute;
  995. bottom: -30rpx;
  996. right: 15rpx;
  997. z-index:1;
  998. width: 0;
  999. height: 0;
  1000. border-width: 18rpx;
  1001. border-style: solid;
  1002. border-color:$color-system transparent transparent transparent;
  1003. }
  1004. }
  1005. .number-box {
  1006. display: flex;
  1007. justify-content: center;
  1008. align-items: center;
  1009. border: 2rpx solid #e1e1e1;
  1010. border-radius: 30rpx;
  1011. height: 48rpx;
  1012. margin-left: 20rpx;
  1013. .iconfont {
  1014. font-size: $font-size-24;
  1015. padding: 0 14rpx;
  1016. color: #666666;
  1017. text-align: center;
  1018. line-height: 48rpx;
  1019. font-weight: bold;
  1020. background: #ffffff;
  1021. &.icon-jianhao {
  1022. border-radius: 30rpx 0 0 30rpx;
  1023. }
  1024. &.icon-jiahao {
  1025. border-radius: 0 30rpx 30rpx 0;
  1026. }
  1027. }
  1028. .btn-input {
  1029. width: 56rpx;
  1030. height: 44rpx;
  1031. line-height: 44rpx;
  1032. border-radius: 4rpx;
  1033. text-align: center;
  1034. font-size: $font-size-24;
  1035. color: #333333;
  1036. background-color: #f7f7f7;
  1037. }
  1038. }
  1039. .uni-numbox{
  1040. position: absolute;
  1041. left: 45rpx;
  1042. bottom: 0;
  1043. .uni-numbox-minus, .uni-numbox-plus{
  1044. width: 50rpx;
  1045. line-height: 40rpx;
  1046. }
  1047. .uni-numbox-value {
  1048. font-size: $font-size-28;
  1049. width: 60rpx;
  1050. }
  1051. }
  1052. }
  1053. }
  1054. .floor-item-act{
  1055. width: 100%;
  1056. height: 30rpx;
  1057. margin-top: 8rpx;
  1058. float: left;
  1059. .tag{
  1060. display: inline-block;
  1061. height: 32rpx;
  1062. font-size: 22rpx;
  1063. line-height: 30rpx;
  1064. text-align: center;
  1065. color: #f83c6c;
  1066. float: left;
  1067. margin-right: 10rpx;
  1068. &.tag-02{
  1069. width: 80rpx;
  1070. background: url(https://static.caimei365.com/app/mini-hehe/icon/icon-active.png)top center no-repeat;
  1071. background-size: contain;
  1072. }
  1073. &.tag-01{
  1074. width: 56rpx;
  1075. color: #fff;
  1076. background-color: #f83c6c;
  1077. border-radius: 4rpx;
  1078. }
  1079. }
  1080. }
  1081. }
  1082. }
  1083. .failure-list{
  1084. width: 702rpx;
  1085. height: auto;
  1086. padding: 0 24rpx;
  1087. margin-top: 20rpx;
  1088. background: #FFFFFF;
  1089. .failure-title{
  1090. width: 100%;
  1091. height: 82rpx;
  1092. line-height: 82rpx;
  1093. font-size: $font-size-28;
  1094. border-bottom: 1px solid #EBEBEB;
  1095. .title-txt{
  1096. float: left;
  1097. color:#666666;
  1098. text-align: left;
  1099. }
  1100. .title-btn{
  1101. float: right;
  1102. color: $color-system;
  1103. text-align: right;
  1104. line-height: 80rpx;
  1105. .butto{
  1106. display: inline-block;
  1107. padding: 0 15rpx;
  1108. font-size: $font-size-26;
  1109. height: 50rpx;
  1110. line-height: 50rpx;
  1111. border-radius: 30rpx;
  1112. background:#fff8fd;
  1113. border: 1px solid #ff457b;
  1114. color: #ff457b;
  1115. margin-top: 15rpx;
  1116. }
  1117. }
  1118. }
  1119. .productlist{
  1120. padding-top: 10rpx;
  1121. .goods-pros{
  1122. width: 100%;
  1123. height: auto;
  1124. padding: 20rpx 0;
  1125. }
  1126. .goods-pros-t{
  1127. display: flex;
  1128. align-items: center;
  1129. width: 100%;
  1130. height: 210rpx;
  1131. position: relative;
  1132. .img-tip{
  1133. display: block;
  1134. width: 72rpx;
  1135. height: 36rpx;
  1136. line-height: 36rpx;
  1137. font-size: $font-size-24;
  1138. text-align: center;
  1139. color: #FFFFFF;
  1140. border-radius: 24rpx;
  1141. background:rgba(51,51,51,0.3);
  1142. // position: absolute;
  1143. // left: 0;
  1144. // top: 0;
  1145. }
  1146. .checkbox-box{
  1147. padding: 10rpx;
  1148. }
  1149. .pros-img{
  1150. width: 180rpx;
  1151. height: 100%;
  1152. border-radius: 10rpx;
  1153. margin:0 20rpx;
  1154. border:1px solid #f3f3f3;
  1155. position: relative;
  1156. image{
  1157. width: 100%;
  1158. height: 100%;
  1159. border-radius: 10rpx;
  1160. }
  1161. }
  1162. .pros-marks{
  1163. width: 730rpx; height: 250rpx;
  1164. z-index: 90;
  1165. background: rgba(0,0,0,.05);
  1166. position: absolute;
  1167. left:-20rpx;
  1168. top: -20rpx;
  1169. }
  1170. }
  1171. .goods-pros-b{
  1172. width:622rpx;
  1173. margin-left: 84rpx;
  1174. height: 40rpx;
  1175. padding:0 0 26rpx 0;
  1176. // border-top: 1px solid #EBEBEB;
  1177. &.show{
  1178. display: block;
  1179. }
  1180. &.none{
  1181. display: none;
  1182. }
  1183. .sum{
  1184. font-size: $font-size-28;
  1185. line-height: 40rpx;
  1186. color: $text-color;
  1187. display: flex;
  1188. justify-content: flex-end;
  1189. .money{
  1190. color: #FF2A2A;
  1191. font-size: $font-size-28;
  1192. }
  1193. .money-sign{
  1194. font-size: $font-size-24;
  1195. color: #FF2A2A;
  1196. }
  1197. }
  1198. }
  1199. .pros-product{
  1200. width: 402rpx;
  1201. height: 100%;
  1202. line-height: 36rpx;
  1203. font-size: $font-size-28;
  1204. position: relative;
  1205. .producttitle{
  1206. width: 100%;
  1207. display: inline-block;
  1208. height: auto;
  1209. text-overflow:ellipsis;
  1210. display: -webkit-box;
  1211. word-break: break-all;
  1212. -webkit-box-orient: vertical;
  1213. -webkit-line-clamp: 2;
  1214. overflow: hidden;
  1215. margin-bottom: 8rpx;
  1216. .no-text{
  1217. display: inline-block;
  1218. height:36rpx;
  1219. padding: 0 12rpx;
  1220. line-height: 36rpx;
  1221. background:linear-gradient(315deg,rgba(231,0,0,1) 0%,rgba(255,104,1,1) 100%);
  1222. border-radius:18rpx;
  1223. text-align: center;
  1224. color: #FFFFFF;
  1225. font-size: $font-size-28;
  1226. margin-right: 24rpx;
  1227. }
  1228. }
  1229. .productspec{
  1230. height: 36rpx;
  1231. color: #999999;
  1232. font-size: $font-size-26;
  1233. margin-top: 20rpx;
  1234. }
  1235. .productstate{
  1236. font-size: $font-size-28;
  1237. height: 44rpx;
  1238. color: #FF2A2A;
  1239. position: absolute;
  1240. bottom: 0;
  1241. left: 0;
  1242. }
  1243. }
  1244. }
  1245. }
  1246. .footer{
  1247. width: 100%;
  1248. background-color: #FFFFFF;
  1249. height: 100rpx;
  1250. position: fixed;
  1251. bottom: 0rpx;
  1252. z-index: 100;
  1253. .footer-le{
  1254. width: 520rpx;
  1255. height: 100%;
  1256. padding:10rpx 24rpx;
  1257. float: left;
  1258. box-sizing: border-box;
  1259. .foot-check{
  1260. width: 100rpx;
  1261. float: left;
  1262. line-height: 80rpx;
  1263. font-size: $font-size-24;
  1264. .checkbox{
  1265. width: 40rpx;
  1266. text-align: center;
  1267. }
  1268. .text{
  1269. width: 60rpx;
  1270. float: right;
  1271. }
  1272. }
  1273. .sum{
  1274. width: 360rpx;
  1275. height: 100%;
  1276. float: right;
  1277. box-sizing: border-box;
  1278. padding:0 10rpx;
  1279. .sum-price{
  1280. text-align: right;
  1281. width: 100%;
  1282. height: 80rpx;
  1283. line-height: 80rpx;
  1284. font-size: $font-size-30;
  1285. color: $text-color;
  1286. float: left;
  1287. font-weight: normal;
  1288. .money{
  1289. color: $color-system;
  1290. }
  1291. .money-sign{
  1292. font-size: $font-size-24;
  1293. color: $color-system;
  1294. }
  1295. }
  1296. }
  1297. }
  1298. .footer-ri{
  1299. width: 230rpx;
  1300. height: 100%;
  1301. float: right;
  1302. display: flex;
  1303. justify-content: space-between;
  1304. align-items: center;
  1305. z-index: 999;
  1306. box-sizing: border-box;
  1307. padding: 13rpx 15rpx;
  1308. &.none{
  1309. display: none;
  1310. }
  1311. .btn{
  1312. width: 200rpx;
  1313. height: 100%;
  1314. background:$btn-confirm;
  1315. font-size: $font-size-28;
  1316. line-height: 80rpx;
  1317. color: #FFFFFF;
  1318. display: flex;
  1319. border-radius: 40rpx;
  1320. justify-content: center;
  1321. align-items: center;
  1322. }
  1323. }
  1324. .footer-del{
  1325. width: 420rpx;
  1326. height: 100rpx;
  1327. position: absolute;
  1328. padding-left: 200rpx;
  1329. background: #FFFFFF;
  1330. right: 0;
  1331. top: 0;
  1332. z-index: 1000;
  1333. box-sizing: border-box;
  1334. padding: 10rpx 0;
  1335. display: flex;
  1336. &.show{
  1337. animation: showDelbtn 0s linear both;
  1338. }
  1339. &.none{
  1340. animation: hideDelbtn 0s linear both;
  1341. }
  1342. .btn{
  1343. flex: 1;
  1344. margin: 0 8rpx;
  1345. height: 100%;
  1346. line-height: 80rpx;
  1347. font-size: $font-size-28;
  1348. color: #FFFFFF;
  1349. text-align: center;
  1350. float: left;
  1351. border-radius: 40rpx;
  1352. }
  1353. .btn.btn-cancel{
  1354. background:#f7f7f7;
  1355. color: #B2B2B2;
  1356. }
  1357. .btn.btn-confirm{
  1358. background:$btn-confirm;
  1359. color: #FFFFFF;
  1360. }
  1361. @keyframes showDelbtn {
  1362. 0% {
  1363. transform: translateX(0);
  1364. }
  1365. 100% {
  1366. transform: translateX(-100%);
  1367. }
  1368. }
  1369. @keyframes hideDelbtn {
  1370. 0% {
  1371. transform: translateX(-100%);
  1372. }
  1373. 100% {
  1374. transform: translateX(0);
  1375. }
  1376. }
  1377. }
  1378. }
  1379. </style>