index.vue 35 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375
  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.productId)" ><image :src="pros.mainImage ? pros.mainImage:''" alt="" /></view>
  28. <view class="pros-product">
  29. <view class="producttitle" @click.stop="navToListPage(pros.productId)" >{{pros.productName}}</view>
  30. <view class="productspec">规格:{{pros.unit ? pros.unit : ''}}</view>
  31. <view class="floor-item-act" v-if="pros.activeStatus == 1">
  32. <view class="tag"@click.stop="clickPopupShow(pros,2)">活动价</view>
  33. </view>
  34. <view class="productprice">
  35. <!--使用过滤器对总价改变-->
  36. <view class="price"><text>¥</text>{{ pros.price | NumFormat }}</view>
  37. <view class="count">
  38. <view class="number-box">
  39. <view class="iconfont icon-jianhao" @click="changeCountSub(item,pros)"></view>
  40. <input class="btn-input" type="number" maxlength='4' v-model="pros.productCount" @blur="changeNnmber($event,item,pros)" @focus="changeInput(pros)">
  41. <view class="iconfont icon-jiahao" @click="changeCountAdd(item,pros)"></view>
  42. </view>
  43. </view>
  44. </view>
  45. </view>
  46. </view>
  47. </view>
  48. </view>
  49. <view class="goods-pros-b clearfix" :class="[isshowDelbtn ? 'none':'show']" >
  50. <view class="sum-none" v-if="item.reducedPrice>0">
  51. <text class="money-sign">¥</text>
  52. <text class="money">{{ item.totalOriginalPrice | NumFormat }}</text>
  53. <text class="money-reduced">减<text>¥{{ item.reducedPrice | NumFormat}}</text></text>
  54. </view>
  55. <view class="sum">合计:<text class="money"><text class="money-sign">¥</text>{{item.totalPrice | NumFormat}}</text></view>
  56. </view>
  57. </view>
  58. </view>
  59. <view class="failure-list" v-if="failureList.length>0">
  60. <view class="failure-title">
  61. <view class="title-txt">失效商品<text>{{failureList.length}}件</text></view>
  62. <view class="title-btn" @click.stop="deletefailureList"><text class="butto">清空失效商品</text></view>
  63. </view>
  64. <view class="productlist">
  65. <view class="goods-pros" v-for="(failure,failureIdx) in failureList" :key="failureIdx" >
  66. <view class="goods-pros-t" @click.stop="navToListPage(failure)">
  67. <!--选择商品-->
  68. <view class="checkbox-box" @click.stop="ischeckFailure(failure)" v-if="isshowDelbtn">
  69. <button class="checkbox iconfont"
  70. :class="[ failure.productsChecked ? 'icon-xuanze':'icon-weixuanze']">
  71. </button>
  72. </view>
  73. <text class="img-tip">失效</text>
  74. <view class="pros-img">
  75. <image :src="failure.mainImage ? failure.mainImage:''" alt="" />
  76. </view>
  77. <view class="pros-product">
  78. <view class="producttitle">{{failure.name}}</view>
  79. <view class="productspec">规格:{{failure.unit ? failure.unit : ''}}</view>
  80. <view class="productstate">商品已下架</view>
  81. </view>
  82. </view>
  83. </view>
  84. </view>
  85. </view>
  86. </view>
  87. <!-- 脚部菜单 -->
  88. <view class="footer">
  89. <view class="footer-le">
  90. <view class="foot-check checkbox-box" @tap.stop="checkAll()">
  91. <button class="checkbox iconfont" :class="[isCheckAll?'icon-xuanze':'icon-weixuanze']"></button>
  92. <view class="text">全选</view>
  93. </view>
  94. <view class="sum">
  95. <view v-if="!isshowDelbtn" class="sum-price">
  96. 总价:<text class="money-sign">¥</text><text class="money">{{allPrice | NumFormat}}</text>
  97. </view>
  98. </view>
  99. </view>
  100. <view v-if="!isshowDelbtn" class="footer-ri" >
  101. <view class="btn hanld-btn" @tap="toConfirmation">去结算({{allCount}})</view>
  102. </view>
  103. <view v-else class="footer-del">
  104. <view class="btn btn-cancel" @tap.stop="hideDelManage">取消</view>
  105. <view class="btn btn-confirm" @tap.stop="deleteList">删除</view>
  106. </view>
  107. </view>
  108. </view>
  109. <view v-else class="cart-content empty">
  110. <view class="empty-container">
  111. <image class="empty-container-image" :src="StaticUrl+'icon-empty-cart.png'" mode="aspectFit"></image>
  112. <text class="error-text">购物车空空的,快去逛逛吧~</text>
  113. </view>
  114. </view>
  115. </view>
  116. <!-- 操作弹窗 -->
  117. <tui-modal :show="modal" @click="handleClick" @cancel="hideMobel" :content="contentModalText" color="#333" :size="32" shape="circle" :maskClosable="false"></tui-modal>
  118. <!-- 促销活动弹窗 -->
  119. <activi-popup :product="handlerPros" :popupShow="popupShow"></activi-popup>
  120. <!-- 透明模态层 -->
  121. <modal-layer v-if='modallayer'></modal-layer>
  122. </view>
  123. </template>
  124. <script>
  125. import authorize from '@/common/config/authorize.js'
  126. import tuiSkeleton from "@/components/tui-skeleton/tui-skeleton"
  127. import tuiLoadmore from "@/components/tui-components/loadmore/loadmore"
  128. import tuiNomore from "@/components/tui-components/nomore/nomore"
  129. import activiPopup from "@/components/cm-module/productDetails/cm-activipopu"
  130. import modalLayer from "@/components/modal-layer"
  131. import { mapState,mapMutations } from 'vuex';
  132. export default{
  133. components:{
  134. tuiSkeleton,
  135. tuiLoadmore,
  136. tuiNomore,
  137. activiPopup,
  138. modalLayer
  139. },
  140. data(){
  141. return{
  142. StaticUrl:this.$Static,
  143. CustomBar:this.CustomBar,// 顶部导航栏高度
  144. isIphoneX:this.$store.state.isIphoneX,
  145. userId:'',
  146. alertType:'',
  147. popupShow:false,
  148. handlerPros:{},//监听单挑促销商品
  149. failureList:[], //失效商品列表
  150. goodsList:[], //购物车的商品
  151. delGoodsList:'',//要删除的商品
  152. setGoodData:'', //确认订单的商品
  153. isCheckAll:false,//是否全选
  154. kindCount:0,//购物车宝贝数量
  155. allPrice:0,//所有价格
  156. totalOriginalPrice:0,//所有原价价
  157. reducedPrice:0,//满减
  158. allCount:0,//被选中的产品数量
  159. isModallayer:false,
  160. skeletonShow:true,
  161. isshowDelbtn:false,
  162. isDisabled: false, // 供应商/店铺全选是否禁用状态
  163. isEmpty:false,//显示空购物车
  164. scrollHeight: 'auto',
  165. nomoreText: '上拉显示更多',
  166. hasNextPage: false,
  167. loadding: false,
  168. pullUpOn: true,
  169. pullFlag: true,
  170. pageSize: 10,
  171. pageNum: 1,
  172. submitIds:[],
  173. modal:false,
  174. contentModalText:'',
  175. deleteType:0,
  176. }
  177. },
  178. onLoad(){
  179. this.setScrollHeight();
  180. },
  181. computed: {
  182. ...mapState(['hasLogin','userInfo'])
  183. },
  184. filters:{
  185. NumFormat(value) {//处理金额
  186. return Number(value).toFixed(2);
  187. },
  188. totalprice(val,count){//单件商品的价格 × 数量
  189. return (val * count).toFixed(2)
  190. }
  191. },
  192. methods:{
  193. initData(){
  194. this.isModallayer = false //遮罩层 防止多次点击
  195. this.isCheckAll=false//是否全选
  196. this.submitIds = []
  197. this.$api.getStorage().then((resolve) => {
  198. this.userId = resolve.userId ? resolve.userId : 0;
  199. this.InitGetCartGoodsList();
  200. })
  201. },
  202. clickPopupShow(pros,type){
  203. this.popupShow = true;
  204. this.handlerPros = pros;
  205. },
  206. setScrollHeight() {
  207. // 窗口高度-footer高度
  208. const {windowHeight, pixelRatio} = uni.getSystemInfoSync();
  209. setTimeout(()=> {
  210. const query = uni.createSelectorQuery().in(this);
  211. query.selectAll('.footer').boundingClientRect();
  212. query.exec(res => {
  213. this.windowHeight = windowHeight;
  214. if(res[0][0]) {
  215. this.scrollHeight = windowHeight - res[0][0].height;
  216. }
  217. })
  218. }, 500)
  219. },
  220. InitGetCartGoodsList(){//初始化购物车 index:1
  221. this.ProductService.QueryShoppingCartList({userId:this.userId}).then(response =>{
  222. this.skeletonShow = false
  223. let data = response.data
  224. this.kindCount = data.cartQuantity
  225. if( data.shopList.length > 0 || data.products.length > 0){
  226. this.isEmpty =false
  227. }else{
  228. this.isEmpty =true
  229. }
  230. if(data.shopList && data.shopList.length > 0 ){
  231. this.goodsList = data.shopList;
  232. console.log(this.goodsList)
  233. this.totalShopPeice()
  234. } else {
  235. this.goodsList = [];
  236. }
  237. if( data.products && data.products.length > 0){
  238. this.failureList = data.products
  239. } else {
  240. this.failureList = [];
  241. }
  242. }).catch(error =>{
  243. this.$util.msg(error.msg,2000);
  244. })
  245. },
  246. ischeckFailure(failure){
  247. failure.productsChecked = !failure.productsChecked
  248. this.updateCheckAllBtn()
  249. },
  250. ischeck(item,pro){//为未选中的时候改变为true,反之为true
  251. pro.productsChecked = !pro.productsChecked;
  252. if(pro.productsChecked) {
  253. if(!this.submitIds.includes(pro.productID*1)){
  254. this.submitIds.push(pro.productID);
  255. }
  256. } else {
  257. var lent = this.submitIds.indexOf(pro.productID*1);
  258. if(lent >=0 ){
  259. this.submitIds.splice(lent, 1);
  260. }
  261. }
  262. this.updateProductCheckedAllBtn(item);
  263. this.updateCheckAllBtn();
  264. },
  265. updateProductCheckedAllBtn(item) {// 单独每个供应商的勾选判断
  266. let productList = item.productList,
  267. productsCheckedLength = 0,
  268. disabledLength = 0;
  269. if(this.isshowDelbtn) {
  270. productList.forEach(pros => {
  271. if(pros.productsChecked) {
  272. productsCheckedLength++;
  273. }
  274. })
  275. } else {
  276. productList.forEach(pros => {
  277. if(pros.productsChecked) {
  278. productsCheckedLength++;
  279. }
  280. })
  281. }
  282. item.checked = productsCheckedLength === productList.length;
  283. },
  284. updateCheckAllBtn() {// 全选勾选判断
  285. let goodsCheckedLength = 0,
  286. goodsList = this.goodsList,
  287. failureList = this.failureList;
  288. goodsList.forEach(item => {
  289. if(item.checked) {
  290. goodsCheckedLength++;
  291. }
  292. })
  293. failureList.forEach(failureItem=>{
  294. if(failureItem.productsChecked){
  295. goodsCheckedLength++;
  296. }
  297. })
  298. if(this.isshowDelbtn){
  299. this.isCheckAll = goodsCheckedLength === goodsList.length + failureList.length;
  300. }else{
  301. this.isCheckAll = goodsCheckedLength === goodsList.length;
  302. }
  303. },
  304. checkShop(item){//与单选商品类似
  305. item.checked = !item.checked;
  306. this.setProductChecked(item);
  307. this.updateCheckAllBtn();
  308. },
  309. setProductChecked(item) {
  310. item.productList.forEach(pros=>{
  311. if(item.checked) {
  312. pros.productsChecked = true;
  313. if(!this.submitIds.includes(pros.productId*1)){
  314. this.submitIds.push(pros.productId);
  315. }
  316. } else {
  317. pros.productsChecked = false;
  318. var lent = this.submitIds.indexOf(pros.productId*1);
  319. if(lent >=0 ){
  320. this.submitIds.splice(lent, 1);
  321. }
  322. }
  323. })
  324. },
  325. updateBothCheckBtn() {
  326. if(this.isshowDelbtn) {
  327. // 当管理删除按钮出现时,失效的商品可被选择
  328. this.goodsList.forEach((item)=>{
  329. item.checked = this.isCheckAll;
  330. this.setProductChecked(item);
  331. })
  332. //删除按钮 全选包括失效商品勾选
  333. this.failureList.forEach(failureItem=>{
  334. failureItem.productsChecked = this.isCheckAll;
  335. })
  336. } else {
  337. this.goodsList.forEach((item)=>{
  338. item.checked = this.isCheckAll && !item.isDisabled;
  339. this.setProductChecked(item);
  340. })
  341. }
  342. },
  343. checkAll(){//全选方法内调用方法
  344. this.isCheckAll = !this.isCheckAll;
  345. this.updateBothCheckBtn();
  346. },
  347. totalShopPeice(){//每次所属会所下的商品增减重新计算合计价格&减去含有下架的商品
  348. let touchPrice = 0;
  349. let reducedPrice = 0;//商铺合计满减价
  350. this.goodsList.map((item,index)=>{
  351. let _totalPrice = 0;
  352. let _reducedPrice = 0;
  353. let _totalOriginalPrice =0;
  354. item.productList.forEach(pros=>{
  355. let _price = pros.price*pros.productCount
  356. _totalOriginalPrice += pros.price*pros.productCount;
  357. if(pros.promotion && pros.promotion.type != 2 && pros.promotion.mode == 2){
  358. if(_price >= pros.promotion.touchPrice){
  359. _price = _price - pros.promotion.reducedPrice
  360. _reducedPrice += pros.promotion.reducedPrice
  361. }
  362. _totalPrice += _price
  363. }else{
  364. _reducedPrice = 0;
  365. _totalPrice += pros.price*pros.productCount;
  366. }
  367. })
  368. item.reducedPrice = _reducedPrice
  369. item.totalOriginalPrice = _totalOriginalPrice
  370. item.totalPrice = _totalPrice
  371. console.log('合计',item.totalPrice)
  372. })
  373. },
  374. totalPeice(){//计算总价格,每次调用此方法,将初始值为0,遍历价格并累加
  375. let totalPrice = 0;
  376. let reducedPrice = 0;
  377. let originalPrice = 0;
  378. this.goodsList.forEach((item,index)=>{
  379. let supplierPrice = 0;
  380. let supplierReducedPrice = 0;
  381. item.totalprice = 0;
  382. item.reducedprice = 0;
  383. item.originalprice = 0;
  384. item.productList.forEach(pros=>{
  385. if(pros.productsChecked){
  386. supplierPrice += pros.price*pros.productCount;
  387. // 单品满减
  388. if(pros.promotion && pros.promotion.type*1===1 && pros.promotion.mode*1===2){
  389. // 单品满减-重新计算供应商总价/满减金额
  390. if(pros.price*pros.productCount >= pros.promotion.touchPrice){
  391. supplierPrice -= pros.promotion.reducedPrice;
  392. supplierReducedPrice += pros.promotion.reducedPrice;
  393. }
  394. }
  395. }
  396. })
  397. item.totalprice = supplierPrice;
  398. item.reducedprice = supplierReducedPrice;
  399. item.originalprice = (supplierPrice+supplierReducedPrice);
  400. totalPrice += item.totalprice;
  401. reducedPrice += item.reducedprice;
  402. originalPrice += item.originalprice;
  403. })
  404. //最后统计商品原价
  405. this.totalOriginalPrice = originalPrice;
  406. //最后满减金额 = 店铺减去金额 + 单品减去金额 + 凑单减去金额
  407. this.reducedPrice = reducedPrice;
  408. //最终合计价格 = 店铺满减合计 + 单品满减 + 正常合计 + 凑单满减
  409. this.allPrice = totalPrice ;
  410. },
  411. totalCount(){//计算总数量
  412. this.allCount = 0
  413. let prosAllCount=0
  414. let validCount = 0
  415. let validList =[];
  416. let productList =[];
  417. this.goodsList.forEach(item=>{
  418. productList = item.productList
  419. productList.forEach(pros=>{
  420. if(pros.productsChecked){
  421. prosAllCount+=parseInt(pros.productCount);
  422. this.allCount = prosAllCount
  423. }
  424. })
  425. })
  426. },
  427. changeCountAdd(item,pros){//商品数量加加
  428. if(pros.step === 2){
  429. pros.isStep = false
  430. pros.productCount += pros.min
  431. this.processActivityPrice(pros)
  432. }else{
  433. pros.productCount++
  434. this.processActivityPrice(pros)
  435. }
  436. this.updateShoppogNum(pros)
  437. this.totalShopPeice();
  438. },
  439. changeCountSub(item,pros){//商品数量减减
  440. if(pros.productCount<=pros.min){
  441. pros.productCount= pros.min
  442. this.$util.msg(`该商品最小起订量为${pros.min}`,2000);
  443. return
  444. }else{
  445. if(pros.step === 2){
  446. pros.isStep = false
  447. pros.productCount -= pros.min
  448. }else{
  449. pros.productCount--
  450. }
  451. this.processActivityPrice(pros)
  452. }
  453. this.updateShoppogNum(pros)
  454. this.totalShopPeice();
  455. },
  456. changeInput(pros){//输入商品数量更新
  457. pros.isStep = false
  458. },
  459. changeNnmber(e,item,pros){//输入商品数量更新
  460. let _value = Number(e.detail.value);
  461. if(!this.$api.isNumber(_value)){
  462. pros.productCount = pros.min
  463. }else if(_value < pros.min){
  464. this.$util.msg(`该商品最小起订量为${pros.min}`,2000);
  465. pros.productCount = pros.min
  466. }else if(_value % pros.min != 0){
  467. pros.isStep = true
  468. pros.productCount = pros.min
  469. }else{
  470. pros.isStep = false
  471. pros.productCount = e.detail.value
  472. this.processActivityPrice(pros)
  473. }
  474. this.updateShoppogNum(pros)
  475. this.totalShopPeice();
  476. },
  477. processActivityPrice(pros){//单独处理活动价格和阶梯价格
  478. if(pros.ladderFlag == '0' || pros.actStatus == 1){
  479. pros.price = pros.price
  480. }else{
  481. pros.ladderList.forEach((item,index)=>{
  482. if(pros.productCount>=item.buyNum){
  483. pros.price = item.buyPrice
  484. }
  485. })
  486. }
  487. },
  488. updateShoppogNum(pros){//加减购物车商品更新到后台
  489. this.ProductService.ShoppingCartUpdate(
  490. {
  491. cartId:pros.cartId,
  492. productCount:pros.productCount,
  493. }
  494. )
  495. .then(response =>{
  496. this.isshowDelbtn = false;
  497. this.InitGetCartGoodsList();
  498. })
  499. .catch(error =>{
  500. this.$util.msg(error.msg,2000);
  501. })
  502. },
  503. toConfirmation(){//跳转确认订单页面
  504. let setGoodsList=[];
  505. this.goodsList.forEach(res=>{
  506. let products = res.productList
  507. products.forEach(pros=>{
  508. if(pros.productsChecked){
  509. setGoodsList.push(pros.productId)
  510. }
  511. })
  512. })
  513. if(setGoodsList == ''){
  514. this.$util.msg("请先选择结算商品~",2000);
  515. return
  516. }
  517. let productIds = '';
  518. this.goodsList.forEach(el=>{//获取勾选的商品ID拼接字符串逗号隔开,最后一个逗号去掉
  519. el.productList.forEach(pros=>{
  520. if(pros.productsChecked){
  521. productIds += pros.productId+','
  522. }
  523. })
  524. })
  525. let cartPramsData={
  526. allPrice:this.allPrice,
  527. allCount:this.allCount,
  528. productIds:productIds.substring(0,productIds.lastIndexOf(',')),
  529. productCount:''
  530. }
  531. this.$api.navigateTo(`/pages/user/order/create-order?data=${JSON.stringify({data:cartPramsData})}`)
  532. },
  533. showDelManager(){//显示删除商品管理
  534. this.isshowDelbtn = true;
  535. if(this.isCheckAll) {
  536. this.updateBothCheckBtn();
  537. } else {
  538. this.goodsList.forEach(item => {
  539. if(item.checked) {
  540. item.productList.forEach(pros => {
  541. pros.productsChecked = true;
  542. })
  543. }
  544. })
  545. this.updateCheckAllBtn();
  546. }
  547. // 失效也被勾选
  548. this.failureList.forEach(failureItem => {
  549. if(failureItem.isFailureLayer){
  550. failureItem.isFailureLayer = false
  551. }
  552. })
  553. },
  554. hideDelManage(){//隐藏删除商品管理
  555. this.isshowDelbtn = false;
  556. let isFailureLayer,newFailureList =[];
  557. if(this.isCheckAll) {
  558. this.updateBothCheckBtn();
  559. } else {
  560. // 失效商品取消勾选
  561. this.goodsList.forEach(item => {
  562. if(item.isDisabled) {
  563. item.checked = false;
  564. }
  565. item.productList.forEach(pros => {
  566. if(pros.validFlag == 3) {
  567. pros.productsChecked = false;
  568. }
  569. })
  570. })
  571. this.updateCheckAllBtn();
  572. }
  573. this.failureList.forEach((failure,index) => {
  574. if(failure.failureState == 1 || failure.failureState == 2) {
  575. isFailureLayer = true
  576. }else{
  577. isFailureLayer = false
  578. }
  579. newFailureList.push(Object.assign({},failure,{isFailureLayer:isFailureLayer}))
  580. })
  581. this.failureList = newFailureList;
  582. },
  583. deleteList(){//删除购物车商品
  584. this.delGoodsList=[];
  585. this.goodsList.forEach(delitem=>{
  586. let products = delitem.productList
  587. products.forEach(pros=>{
  588. if(pros.productsChecked){
  589. this.delGoodsList += pros.cartId+','
  590. }
  591. })
  592. })
  593. this.failureList.forEach(failure=>{
  594. if(failure.productsChecked){
  595. this.delGoodsList += failure.cartId+','
  596. }
  597. })
  598. if(this.delGoodsList.length == 0){
  599. this.$util.msg("请选择要删除的商品~",2000);
  600. return
  601. }else{
  602. this.modal = true;
  603. this.contentModalText = '确定删除选中的商品吗?';
  604. this.deleteType = 1
  605. }
  606. },
  607. deletefailureList(){
  608. this.delGoodsList = ''
  609. this.failureList.forEach(failure=>{ this.delGoodsList += failure.cartId+',' })
  610. this.modal = true;
  611. this.contentModalText = '确定清除所有失效商品吗?';
  612. this.deleteType = 2
  613. },
  614. handleClick(e) {//用户操作订单
  615. let index = e.index;
  616. if(index == 1){
  617. this.ProductService.ShoppingCartDelete(
  618. {
  619. cartIds:this.delGoodsList,
  620. }
  621. )
  622. .then(response =>{
  623. this.$util.msg('删除成功',2000);
  624. setTimeout(()=>{
  625. this.isshowDelbtn = false;
  626. this.InitGetCartGoodsList();
  627. },1000)
  628. }).catch(error =>{
  629. this.$util.msg(error.msg,2000)
  630. })
  631. }
  632. this.modal = false;
  633. },
  634. hideMobel(){
  635. this.modal = false;
  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. width: 80rpx;
  1062. height: 30rpx;
  1063. background: url(https://static.caimei365.com/app/mini-hehe/icon/icon-active.png)top center no-repeat;
  1064. background-size: contain;
  1065. font-size: 22rpx;
  1066. line-height: 30rpx;
  1067. text-align: center;
  1068. color: #f83c6c;
  1069. float: left;
  1070. }
  1071. }
  1072. }
  1073. }
  1074. .failure-list{
  1075. width: 702rpx;
  1076. height: auto;
  1077. padding: 0 24rpx;
  1078. margin-top: 20rpx;
  1079. background: #FFFFFF;
  1080. .failure-title{
  1081. width: 100%;
  1082. height: 82rpx;
  1083. line-height: 82rpx;
  1084. font-size: $font-size-28;
  1085. border-bottom: 1px solid #EBEBEB;
  1086. .title-txt{
  1087. float: left;
  1088. color:#666666;
  1089. text-align: left;
  1090. }
  1091. .title-btn{
  1092. float: right;
  1093. color: $color-system;
  1094. text-align: right;
  1095. line-height: 80rpx;
  1096. .butto{
  1097. display: inline-block;
  1098. padding: 0 15rpx;
  1099. font-size: $font-size-26;
  1100. height: 50rpx;
  1101. line-height: 50rpx;
  1102. border-radius: 30rpx;
  1103. background:#fff8fd;
  1104. border: 1px solid #ff457b;
  1105. color: #ff457b;
  1106. margin-top: 15rpx;
  1107. }
  1108. }
  1109. }
  1110. .productlist{
  1111. padding-top: 10rpx;
  1112. .goods-pros{
  1113. width: 100%;
  1114. height: auto;
  1115. padding: 20rpx 0;
  1116. }
  1117. .goods-pros-t{
  1118. display: flex;
  1119. align-items: center;
  1120. width: 100%;
  1121. height: 210rpx;
  1122. position: relative;
  1123. .img-tip{
  1124. display: block;
  1125. width: 72rpx;
  1126. height: 36rpx;
  1127. line-height: 36rpx;
  1128. font-size: $font-size-24;
  1129. text-align: center;
  1130. color: #FFFFFF;
  1131. border-radius: 24rpx;
  1132. background:rgba(51,51,51,0.3);
  1133. // position: absolute;
  1134. // left: 0;
  1135. // top: 0;
  1136. }
  1137. .checkbox-box{
  1138. padding: 10rpx;
  1139. }
  1140. .pros-img{
  1141. width: 180rpx;
  1142. height: 100%;
  1143. border-radius: 10rpx;
  1144. margin:0 20rpx;
  1145. border:1px solid #f3f3f3;
  1146. position: relative;
  1147. image{
  1148. width: 100%;
  1149. height: 100%;
  1150. border-radius: 10rpx;
  1151. }
  1152. }
  1153. .pros-marks{
  1154. width: 730rpx; height: 250rpx;
  1155. z-index: 90;
  1156. background: rgba(0,0,0,.05);
  1157. position: absolute;
  1158. left:-20rpx;
  1159. top: -20rpx;
  1160. }
  1161. }
  1162. .goods-pros-b{
  1163. width:622rpx;
  1164. margin-left: 84rpx;
  1165. height: 40rpx;
  1166. padding:0 0 26rpx 0;
  1167. // border-top: 1px solid #EBEBEB;
  1168. &.show{
  1169. display: block;
  1170. }
  1171. &.none{
  1172. display: none;
  1173. }
  1174. .sum{
  1175. font-size: $font-size-28;
  1176. line-height: 40rpx;
  1177. color: $text-color;
  1178. display: flex;
  1179. justify-content: flex-end;
  1180. .money{
  1181. color: #FF2A2A;
  1182. font-size: $font-size-28;
  1183. }
  1184. .money-sign{
  1185. font-size: $font-size-24;
  1186. color: #FF2A2A;
  1187. }
  1188. }
  1189. }
  1190. .pros-product{
  1191. width: 402rpx;
  1192. height: 100%;
  1193. line-height: 36rpx;
  1194. font-size: $font-size-28;
  1195. position: relative;
  1196. .producttitle{
  1197. width: 100%;
  1198. display: inline-block;
  1199. height: auto;
  1200. text-overflow:ellipsis;
  1201. display: -webkit-box;
  1202. word-break: break-all;
  1203. -webkit-box-orient: vertical;
  1204. -webkit-line-clamp: 2;
  1205. overflow: hidden;
  1206. margin-bottom: 8rpx;
  1207. .no-text{
  1208. display: inline-block;
  1209. height:36rpx;
  1210. padding: 0 12rpx;
  1211. line-height: 36rpx;
  1212. background:linear-gradient(315deg,rgba(231,0,0,1) 0%,rgba(255,104,1,1) 100%);
  1213. border-radius:18rpx;
  1214. text-align: center;
  1215. color: #FFFFFF;
  1216. font-size: $font-size-28;
  1217. margin-right: 24rpx;
  1218. }
  1219. }
  1220. .productspec{
  1221. height: 36rpx;
  1222. color: #999999;
  1223. font-size: $font-size-26;
  1224. margin-top: 20rpx;
  1225. }
  1226. .productstate{
  1227. font-size: $font-size-28;
  1228. height: 44rpx;
  1229. color: #FF2A2A;
  1230. position: absolute;
  1231. bottom: 0;
  1232. left: 0;
  1233. }
  1234. }
  1235. }
  1236. }
  1237. .footer{
  1238. width: 100%;
  1239. background-color: #FFFFFF;
  1240. height: 100rpx;
  1241. position: fixed;
  1242. bottom: 0rpx;
  1243. z-index: 100;
  1244. .footer-le{
  1245. width: 520rpx;
  1246. height: 100%;
  1247. padding:10rpx 24rpx;
  1248. float: left;
  1249. box-sizing: border-box;
  1250. .foot-check{
  1251. width: 100rpx;
  1252. float: left;
  1253. line-height: 80rpx;
  1254. font-size: $font-size-24;
  1255. .checkbox{
  1256. width: 40rpx;
  1257. text-align: center;
  1258. }
  1259. .text{
  1260. width: 60rpx;
  1261. float: right;
  1262. }
  1263. }
  1264. .sum{
  1265. width: 360rpx;
  1266. height: 100%;
  1267. float: right;
  1268. box-sizing: border-box;
  1269. padding:0 10rpx;
  1270. .sum-price{
  1271. text-align: right;
  1272. width: 100%;
  1273. height: 80rpx;
  1274. line-height: 80rpx;
  1275. font-size: $font-size-30;
  1276. color: $text-color;
  1277. float: left;
  1278. font-weight: normal;
  1279. .money{
  1280. color: $color-system;
  1281. }
  1282. .money-sign{
  1283. font-size: $font-size-24;
  1284. color: $color-system;
  1285. }
  1286. }
  1287. }
  1288. }
  1289. .footer-ri{
  1290. width: 230rpx;
  1291. height: 100%;
  1292. float: right;
  1293. display: flex;
  1294. justify-content: space-between;
  1295. align-items: center;
  1296. z-index: 999;
  1297. box-sizing: border-box;
  1298. padding: 13rpx 15rpx;
  1299. &.none{
  1300. display: none;
  1301. }
  1302. .btn{
  1303. width: 200rpx;
  1304. height: 100%;
  1305. background:$btn-confirm;
  1306. font-size: $font-size-28;
  1307. line-height: 80rpx;
  1308. color: #FFFFFF;
  1309. display: flex;
  1310. border-radius: 40rpx;
  1311. justify-content: center;
  1312. align-items: center;
  1313. }
  1314. }
  1315. .footer-del{
  1316. width: 420rpx;
  1317. height: 100rpx;
  1318. position: absolute;
  1319. padding-left: 200rpx;
  1320. background: #FFFFFF;
  1321. right: 0;
  1322. top: 0;
  1323. z-index: 1000;
  1324. box-sizing: border-box;
  1325. padding: 10rpx 0;
  1326. display: flex;
  1327. &.show{
  1328. animation: showDelbtn 0s linear both;
  1329. }
  1330. &.none{
  1331. animation: hideDelbtn 0s linear both;
  1332. }
  1333. .btn{
  1334. flex: 1;
  1335. margin: 0 8rpx;
  1336. height: 100%;
  1337. line-height: 80rpx;
  1338. font-size: $font-size-28;
  1339. color: #FFFFFF;
  1340. text-align: center;
  1341. float: left;
  1342. border-radius: 40rpx;
  1343. }
  1344. .btn.btn-cancel{
  1345. background:#f7f7f7;
  1346. color: #B2B2B2;
  1347. }
  1348. .btn.btn-confirm{
  1349. background:$btn-confirm;
  1350. color: #FFFFFF;
  1351. }
  1352. @keyframes showDelbtn {
  1353. 0% {
  1354. transform: translateX(0);
  1355. }
  1356. 100% {
  1357. transform: translateX(-100%);
  1358. }
  1359. }
  1360. @keyframes hideDelbtn {
  1361. 0% {
  1362. transform: translateX(-100%);
  1363. }
  1364. 100% {
  1365. transform: translateX(0);
  1366. }
  1367. }
  1368. }
  1369. }
  1370. </style>