index.vue 35 KB

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