index.vue 35 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387
  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. }).finally(()=>{
  618. this.GetCartNumber()
  619. })
  620. }
  621. this.modal = false;
  622. },
  623. hideMobel(){
  624. this.modal = false;
  625. },
  626. GetCartNumber(){//查询购物车数量
  627. this.ProductService.QueryShoppingQuantity(
  628. {
  629. userId:this.userId,
  630. }
  631. )
  632. .then(response => {
  633. this.$store.commit('updateAllNum',response.data)
  634. })
  635. .catch(error =>{
  636. console.log('查询购物车数量错误信息',error)
  637. })
  638. },
  639. navToListPage(item){
  640. this.isModallayer = true;
  641. this.$api.navigateTo(`/pages/goods/product?productId=${item.productId}`)
  642. },
  643. setHeaderBtnPosi(){
  644. // 获得胶囊按钮位置信息
  645. let headerBtnPosi = uni.getMenuButtonBoundingClientRect();
  646. return headerBtnPosi
  647. },
  648. setSysteminfo(){
  649. let systeminfo;
  650. uni.getSystemInfo({ // 获取设备信息
  651. success: (res) => {
  652. systeminfo = res
  653. },
  654. })
  655. return systeminfo
  656. },
  657. PromotionsFormat(promo){//促销活动类型数据处理
  658. if(promo!=null){
  659. if(promo.type == 1 && promo.mode == 1){
  660. return true
  661. }else{
  662. return false
  663. }
  664. }
  665. return false
  666. }
  667. },
  668. watch:{//深度监听所有数据,每次改变重新计算总价和总数
  669. goodsList:{
  670. deep:true,
  671. handler(val,oldval){
  672. this.totalPeice()
  673. this.totalCount()
  674. }
  675. }
  676. },
  677. onPullDownRefresh() {//下拉刷新
  678. this.InitGetCartGoodsList()
  679. uni.stopPullDownRefresh()
  680. },
  681. onShow(){
  682. if(this.hasLogin){
  683. this.initData()
  684. }else{
  685. this.$api.redirectTo('/pages/login/login')
  686. }
  687. },
  688. }
  689. </script>
  690. <style lang="scss">
  691. page{
  692. background: #f7f7f7;
  693. height: auto;
  694. }
  695. .cart-content{
  696. position: relative;
  697. }
  698. .container-cart-main.none{
  699. display: none;
  700. }
  701. .container-cart-main.show{
  702. display: block;
  703. }
  704. .cart-content.empty.none{
  705. display: none;
  706. }
  707. .cart-content.empty.show{
  708. display: block;
  709. }
  710. .container-cart.show{
  711. display: block;
  712. }
  713. .container-cart.none{
  714. display: none;
  715. }
  716. .empty-container.none{
  717. display: none;
  718. }
  719. .empty-container.show{
  720. display: flex;
  721. }
  722. .foot-check-delbtn{
  723. width: 100%;
  724. height: 80rpx;
  725. position: fixed;
  726. top: 0;
  727. left: 0;
  728. box-sizing: border-box;
  729. padding: 15rpx 24rpx;
  730. background-color: #F7F7F7;
  731. z-index: 990;
  732. .foot-text{
  733. font-size: $font-size-26;
  734. height: 50rpx;
  735. line-height: 50rpx;
  736. color:#666666;
  737. float: left;
  738. padding-left: 10rpx;
  739. text{
  740. margin: 0 6rpx;
  741. }
  742. }
  743. .delBtn{
  744. width: 100rpx;
  745. display: inline-block;
  746. padding: 0 15rpx;
  747. font-size: $font-size-26;
  748. height: 50rpx;
  749. line-height: 50rpx;
  750. border-radius: 30rpx;
  751. background:#FFFFFF;
  752. border: 1px solid #ff457b;
  753. color: #ff457b;
  754. float: right;
  755. text-align: center;
  756. &.none{
  757. display: none;
  758. }
  759. }
  760. }
  761. .checkbox-box{
  762. display: flex;
  763. align-items: center;
  764. .checkbox{
  765. display: flex;
  766. margin: 0;
  767. padding:0 5rpx;
  768. display: flex;
  769. flex-direction: column;
  770. align-items: center;
  771. box-sizing: border-box;
  772. text-align: center;
  773. text-decoration: none;
  774. border-radius: 0;
  775. -webkit-tap-highlight-color: transparent;
  776. overflow: hidden;
  777. background-color:#FFFFFF;
  778. font-size: 36rpx;
  779. color:#999999;
  780. &.icon-xuanze{
  781. color: $color-system;
  782. }
  783. }
  784. &.disabled{
  785. .checkbox{
  786. color:#999999
  787. }
  788. }
  789. .text{
  790. font-size: $font-size-24;
  791. margin-left: 10rpx;
  792. }
  793. }
  794. .goods-list{
  795. width: 100%;
  796. height: auto;
  797. background-color: #F7F7F7;
  798. .goods-item{
  799. width: 702rpx;
  800. padding: 0 24rpx;
  801. background: #FFFFFF;
  802. margin-bottom: 24rpx;
  803. }
  804. .shoptitle{
  805. display: flex;
  806. align-items: center;
  807. height: 80rpx;
  808. line-height: 80rpx;
  809. .checkbox-box{
  810. padding: 10rpx;
  811. }
  812. .text{
  813. width: 450rpx;
  814. display: block;
  815. overflow: hidden;
  816. text-overflow:ellipsis;
  817. white-space: nowrap;
  818. margin-left: 20rpx;
  819. font-size: $font-size-28;
  820. color: $text-color;
  821. text-align: left;
  822. font-weight: bold;
  823. }
  824. }
  825. .goods-pros{
  826. width: 100%;
  827. height: auto;
  828. margin-bottom: 20rpx;
  829. }
  830. .goods-pros-t{
  831. display: flex;
  832. align-items: center;
  833. width: 100%;
  834. height: 210rpx;
  835. padding:0 0 26rpx 0;
  836. .checkbox-box{
  837. padding: 10rpx;
  838. }
  839. .pros-img{
  840. width: 210rpx;
  841. height: 100%;
  842. border-radius: 10rpx;
  843. margin:0 20rpx;
  844. border:1px solid #f3f3f3;
  845. image{
  846. width: 100%;
  847. height: 100%;
  848. border-radius: 10rpx;
  849. }
  850. }
  851. }
  852. .goods-pros-b{
  853. width:100%;
  854. height: auto;
  855. padding:0 0 24rpx 0;
  856. box-sizing: border-box;
  857. &.show{
  858. display: block;
  859. }
  860. &.none{
  861. display: none;
  862. }
  863. .sum-none{
  864. width: 100%;
  865. height: 48rpx;
  866. line-height: 48rpx;
  867. color: $text-color;
  868. float: left;
  869. text-align: right;
  870. .money{
  871. font-size: $font-size-26;
  872. color: #999999;
  873. text-decoration: line-through;
  874. }
  875. .money-sign{
  876. font-size: $font-size-26;
  877. color: #999999;
  878. text-decoration: line-through;
  879. }
  880. .money-reduced{
  881. margin-left: 10rpx;
  882. font-size: $font-size-26;
  883. color: $color-system;
  884. .iconfont{
  885. font-size: $font-size-34;
  886. }
  887. }
  888. }
  889. .sum{
  890. width: 100%;
  891. height: 40rpx;
  892. font-size: $font-size-26;
  893. line-height: 40rpx;
  894. color: $text-color;
  895. float: left;
  896. display: flex;
  897. justify-content: flex-end;
  898. font-weight: bold;
  899. .money{
  900. color: $color-system;
  901. font-size: $font-size-26;
  902. }
  903. .money-sign{
  904. font-size: $font-size-24;
  905. color: $color-system;
  906. }
  907. }
  908. }
  909. .pros-product{
  910. width: 416rpx;
  911. height: 100%;
  912. line-height: 36rpx;
  913. font-size: $font-size-28;
  914. position: relative;
  915. .producttitle{
  916. width: 100%;
  917. display: inline-block;
  918. height: auto;
  919. text-overflow:ellipsis;
  920. display: -webkit-box;
  921. word-break: break-all;
  922. -webkit-box-orient: vertical;
  923. -webkit-line-clamp: 2;
  924. overflow: hidden;
  925. margin-bottom: 15rpx;
  926. .no-text{
  927. display: inline-block;
  928. height:36rpx;
  929. padding: 0 12rpx;
  930. line-height: 36rpx;
  931. background:linear-gradient(315deg,rgba(231,0,0,1) 0%,rgba(255,104,1,1) 100%);
  932. border-radius:18rpx;
  933. text-align: center;
  934. color: #FFFFFF;
  935. font-size:$font-size-28;
  936. margin-right: 24rpx;
  937. }
  938. }
  939. .productspec{
  940. height: 36rpx;
  941. color: #999999;
  942. font-size: $font-size-26;
  943. }
  944. .productprice{
  945. position: absolute;
  946. bottom: 0;
  947. width: 100%;
  948. height: 48rpx;
  949. margin: 30rpx 0 0 0;
  950. .price{
  951. line-height: 48rpx;
  952. font-size: $font-size-26;
  953. width: 48%;
  954. color: $color-system;
  955. float: left;
  956. font-weight: bold;
  957. &.disabled{
  958. color: #999999;
  959. text-decoration: line-through;
  960. }
  961. .money-sign{
  962. font-size: $font-size-24;
  963. color: $color-system;
  964. }
  965. }
  966. .count{
  967. height: 100%;
  968. float: right;
  969. position: relative;
  970. &.show{
  971. display: block;
  972. }
  973. &.none{
  974. display: none;
  975. }
  976. .count-tips{
  977. width: auto;
  978. display: inline-block;
  979. padding: 0 15rpx;
  980. line-height: 44rpx;
  981. height: 44rpx;
  982. border-radius: 22rpx;
  983. background: $btn-confirm;
  984. font-size: $font-size-24;
  985. text-align: center;
  986. color: #FFFFFF;
  987. position: absolute;
  988. top:-60rpx;
  989. left: -5rpx;
  990. z-index: 5;
  991. &.step{
  992. left:-217rpx
  993. }
  994. &::before{
  995. content: "";
  996. position: absolute;
  997. bottom: -30rpx;
  998. right: 15rpx;
  999. z-index:1;
  1000. width: 0;
  1001. height: 0;
  1002. border-width: 18rpx;
  1003. border-style: solid;
  1004. border-color:$color-system transparent transparent transparent;
  1005. }
  1006. }
  1007. .number-box {
  1008. display: flex;
  1009. justify-content: center;
  1010. align-items: center;
  1011. border: 2rpx solid #e1e1e1;
  1012. border-radius: 30rpx;
  1013. height: 48rpx;
  1014. margin-left: 20rpx;
  1015. .iconfont {
  1016. font-size: $font-size-24;
  1017. padding: 0 14rpx;
  1018. color: #666666;
  1019. text-align: center;
  1020. line-height: 48rpx;
  1021. font-weight: bold;
  1022. background: #ffffff;
  1023. &.icon-jianhao {
  1024. border-radius: 30rpx 0 0 30rpx;
  1025. }
  1026. &.icon-jiahao {
  1027. border-radius: 0 30rpx 30rpx 0;
  1028. }
  1029. }
  1030. .btn-input {
  1031. width: 56rpx;
  1032. height: 44rpx;
  1033. line-height: 44rpx;
  1034. border-radius: 4rpx;
  1035. text-align: center;
  1036. font-size: $font-size-24;
  1037. color: #333333;
  1038. background-color: #f7f7f7;
  1039. }
  1040. }
  1041. .uni-numbox{
  1042. position: absolute;
  1043. left: 45rpx;
  1044. bottom: 0;
  1045. .uni-numbox-minus, .uni-numbox-plus{
  1046. width: 50rpx;
  1047. line-height: 40rpx;
  1048. }
  1049. .uni-numbox-value {
  1050. font-size: $font-size-28;
  1051. width: 60rpx;
  1052. }
  1053. }
  1054. }
  1055. }
  1056. .floor-item-act{
  1057. width: 100%;
  1058. height: 30rpx;
  1059. margin-top: 8rpx;
  1060. float: left;
  1061. .tag{
  1062. display: inline-block;
  1063. height: 32rpx;
  1064. font-size: 22rpx;
  1065. line-height: 30rpx;
  1066. text-align: center;
  1067. color: #f83c6c;
  1068. float: left;
  1069. margin-right: 10rpx;
  1070. &.tag-02{
  1071. width: 80rpx;
  1072. background: url(https://static.caimei365.com/app/mini-hehe/icon/icon-active.png)top center no-repeat;
  1073. background-size: contain;
  1074. }
  1075. &.tag-01{
  1076. width: 56rpx;
  1077. color: #fff;
  1078. background-color: #f83c6c;
  1079. border-radius: 4rpx;
  1080. }
  1081. }
  1082. }
  1083. }
  1084. }
  1085. .failure-list{
  1086. width: 702rpx;
  1087. height: auto;
  1088. padding: 0 24rpx;
  1089. margin-top: 20rpx;
  1090. background: #FFFFFF;
  1091. .failure-title{
  1092. width: 100%;
  1093. height: 82rpx;
  1094. line-height: 82rpx;
  1095. font-size: $font-size-28;
  1096. border-bottom: 1px solid #EBEBEB;
  1097. .title-txt{
  1098. float: left;
  1099. color:#666666;
  1100. text-align: left;
  1101. }
  1102. .title-btn{
  1103. float: right;
  1104. color: $color-system;
  1105. text-align: right;
  1106. line-height: 80rpx;
  1107. .butto{
  1108. display: inline-block;
  1109. padding: 0 15rpx;
  1110. font-size: $font-size-26;
  1111. height: 50rpx;
  1112. line-height: 50rpx;
  1113. border-radius: 30rpx;
  1114. background:#fff8fd;
  1115. border: 1px solid #ff457b;
  1116. color: #ff457b;
  1117. margin-top: 15rpx;
  1118. }
  1119. }
  1120. }
  1121. .productlist{
  1122. padding-top: 10rpx;
  1123. .goods-pros{
  1124. width: 100%;
  1125. height: auto;
  1126. padding: 20rpx 0;
  1127. }
  1128. .goods-pros-t{
  1129. display: flex;
  1130. align-items: center;
  1131. width: 100%;
  1132. height: 210rpx;
  1133. position: relative;
  1134. .img-tip{
  1135. display: block;
  1136. width: 72rpx;
  1137. height: 36rpx;
  1138. line-height: 36rpx;
  1139. font-size: $font-size-24;
  1140. text-align: center;
  1141. color: #FFFFFF;
  1142. border-radius: 24rpx;
  1143. background:rgba(51,51,51,0.3);
  1144. // position: absolute;
  1145. // left: 0;
  1146. // top: 0;
  1147. }
  1148. .checkbox-box{
  1149. padding: 10rpx;
  1150. }
  1151. .pros-img{
  1152. width: 180rpx;
  1153. height: 100%;
  1154. border-radius: 10rpx;
  1155. margin:0 20rpx;
  1156. border:1px solid #f3f3f3;
  1157. position: relative;
  1158. image{
  1159. width: 100%;
  1160. height: 100%;
  1161. border-radius: 10rpx;
  1162. }
  1163. }
  1164. .pros-marks{
  1165. width: 730rpx; height: 250rpx;
  1166. z-index: 90;
  1167. background: rgba(0,0,0,.05);
  1168. position: absolute;
  1169. left:-20rpx;
  1170. top: -20rpx;
  1171. }
  1172. }
  1173. .goods-pros-b{
  1174. width:622rpx;
  1175. margin-left: 84rpx;
  1176. height: 40rpx;
  1177. padding:0 0 26rpx 0;
  1178. // border-top: 1px solid #EBEBEB;
  1179. &.show{
  1180. display: block;
  1181. }
  1182. &.none{
  1183. display: none;
  1184. }
  1185. .sum{
  1186. font-size: $font-size-28;
  1187. line-height: 40rpx;
  1188. color: $text-color;
  1189. display: flex;
  1190. justify-content: flex-end;
  1191. .money{
  1192. color: #FF2A2A;
  1193. font-size: $font-size-28;
  1194. }
  1195. .money-sign{
  1196. font-size: $font-size-24;
  1197. color: #FF2A2A;
  1198. }
  1199. }
  1200. }
  1201. .pros-product{
  1202. width: 402rpx;
  1203. height: 100%;
  1204. line-height: 36rpx;
  1205. font-size: $font-size-28;
  1206. position: relative;
  1207. .producttitle{
  1208. width: 100%;
  1209. display: inline-block;
  1210. height: auto;
  1211. text-overflow:ellipsis;
  1212. display: -webkit-box;
  1213. word-break: break-all;
  1214. -webkit-box-orient: vertical;
  1215. -webkit-line-clamp: 2;
  1216. overflow: hidden;
  1217. margin-bottom: 8rpx;
  1218. .no-text{
  1219. display: inline-block;
  1220. height:36rpx;
  1221. padding: 0 12rpx;
  1222. line-height: 36rpx;
  1223. background:linear-gradient(315deg,rgba(231,0,0,1) 0%,rgba(255,104,1,1) 100%);
  1224. border-radius:18rpx;
  1225. text-align: center;
  1226. color: #FFFFFF;
  1227. font-size: $font-size-28;
  1228. margin-right: 24rpx;
  1229. }
  1230. }
  1231. .productspec{
  1232. height: 36rpx;
  1233. color: #999999;
  1234. font-size: $font-size-26;
  1235. margin-top: 20rpx;
  1236. }
  1237. .productstate{
  1238. font-size: $font-size-28;
  1239. height: 44rpx;
  1240. color: #FF2A2A;
  1241. position: absolute;
  1242. bottom: 0;
  1243. left: 0;
  1244. }
  1245. }
  1246. }
  1247. }
  1248. .footer{
  1249. width: 100%;
  1250. background-color: #FFFFFF;
  1251. height: 100rpx;
  1252. position: fixed;
  1253. bottom: 0rpx;
  1254. z-index: 100;
  1255. .footer-le{
  1256. width: 520rpx;
  1257. height: 100%;
  1258. padding:10rpx 24rpx;
  1259. float: left;
  1260. box-sizing: border-box;
  1261. .foot-check{
  1262. width: 100rpx;
  1263. float: left;
  1264. line-height: 80rpx;
  1265. font-size: $font-size-24;
  1266. .checkbox{
  1267. width: 40rpx;
  1268. text-align: center;
  1269. }
  1270. .text{
  1271. width: 60rpx;
  1272. float: right;
  1273. }
  1274. }
  1275. .sum{
  1276. width: 360rpx;
  1277. height: 100%;
  1278. float: right;
  1279. box-sizing: border-box;
  1280. padding:0 10rpx;
  1281. .sum-price{
  1282. text-align: right;
  1283. width: 100%;
  1284. height: 80rpx;
  1285. line-height: 80rpx;
  1286. font-size: $font-size-30;
  1287. color: $text-color;
  1288. float: left;
  1289. font-weight: normal;
  1290. .money{
  1291. color: $color-system;
  1292. }
  1293. .money-sign{
  1294. font-size: $font-size-24;
  1295. color: $color-system;
  1296. }
  1297. }
  1298. }
  1299. }
  1300. .footer-ri{
  1301. width: 230rpx;
  1302. height: 100%;
  1303. float: right;
  1304. display: flex;
  1305. justify-content: space-between;
  1306. align-items: center;
  1307. z-index: 999;
  1308. box-sizing: border-box;
  1309. padding: 13rpx 15rpx;
  1310. &.none{
  1311. display: none;
  1312. }
  1313. .btn{
  1314. width: 200rpx;
  1315. height: 100%;
  1316. background:$btn-confirm;
  1317. font-size: $font-size-28;
  1318. line-height: 80rpx;
  1319. color: #FFFFFF;
  1320. display: flex;
  1321. border-radius: 40rpx;
  1322. justify-content: center;
  1323. align-items: center;
  1324. }
  1325. }
  1326. .footer-del{
  1327. width: 420rpx;
  1328. height: 100rpx;
  1329. position: absolute;
  1330. padding-left: 200rpx;
  1331. background: #FFFFFF;
  1332. right: 0;
  1333. top: 0;
  1334. z-index: 1000;
  1335. box-sizing: border-box;
  1336. padding: 10rpx 0;
  1337. display: flex;
  1338. &.show{
  1339. animation: showDelbtn 0s linear both;
  1340. }
  1341. &.none{
  1342. animation: hideDelbtn 0s linear both;
  1343. }
  1344. .btn{
  1345. flex: 1;
  1346. margin: 0 8rpx;
  1347. height: 100%;
  1348. line-height: 80rpx;
  1349. font-size: $font-size-28;
  1350. color: #FFFFFF;
  1351. text-align: center;
  1352. float: left;
  1353. border-radius: 40rpx;
  1354. }
  1355. .btn.btn-cancel{
  1356. background:#f7f7f7;
  1357. color: #B2B2B2;
  1358. }
  1359. .btn.btn-confirm{
  1360. background:$btn-confirm;
  1361. color: #FFFFFF;
  1362. }
  1363. @keyframes showDelbtn {
  1364. 0% {
  1365. transform: translateX(0);
  1366. }
  1367. 100% {
  1368. transform: translateX(-100%);
  1369. }
  1370. }
  1371. @keyframes hideDelbtn {
  1372. 0% {
  1373. transform: translateX(-100%);
  1374. }
  1375. 100% {
  1376. transform: translateX(0);
  1377. }
  1378. }
  1379. }
  1380. }
  1381. </style>