cart.vue 27 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003
  1. <template>
  2. <view class="container cart clearfix">
  3. <tui-skeleton v-if="skeletonShow" backgroundColor="#fafafa" borderRadius="10rpx" :isLoading ="true" :loadingType="9"></tui-skeleton>
  4. <view class="container-cart-main tui-skeleton">
  5. <view v-if="!isEmpty" class="container-cart">
  6. <scroll-view class="cart-content" scroll-y @scrolltolower="toLower">
  7. <view class="goods-list">
  8. <view v-for="(item, index) in goodsList" :key="index" class="goods-item">
  9. <view class="shoptitle">
  10. <!--选择商店的全部商品 :disabled="isNnder"-->
  11. <view class="checkbox-box">
  12. <button class="checkbox iconfont"
  13. :class="[item.checked ?'icon-gouxuanl':'icon-weigouxuan']"
  14. @click.stop="checkShop(item)" :disabled="item.isDisabled && !isshowDelbtn">
  15. </button>
  16. </view>
  17. <view class="text">{{item.name}}</view>
  18. </view>
  19. <view class="productlist">
  20. <view class="goods-pros"
  21. v-for="(pros,idx) in item.productsList"
  22. :key="idx"
  23. >
  24. <view class="goods-pros-t">
  25. <!--选择商品-->
  26. <view class="checkbox-box" :class="[pros.validFlag == '3' && !isshowDelbtn ?'disabled' : '']">
  27. <button class="checkbox iconfont"
  28. :disabled="pros.validFlag == '3' && !isshowDelbtn"
  29. :class="[pros.productsChecked ?'icon-gouxuanl':'icon-weigouxuan']"
  30. @click.stop="ischeck(item,pros,idx)">
  31. </button>
  32. </view>
  33. <view class="pros-img" @click.stop="navToListPage(pros.productID)" ><image :src="pros.mainImage ? pros.mainImage :''" alt="" /></view>
  34. <view class="pros-product">
  35. <view class="producttitle" @click.stop="navToListPage(pros.id)" >
  36. <text v-if="pros.validFlag == '3'" class="no-text">商品已下架</text>{{pros.name}}
  37. </view>
  38. <view class="productspec">规格:{{pros.unit ? pros.unit : ''}}</view>
  39. <view class="productprice">
  40. <!--使用过滤器对总价改变-->
  41. <view class="price"
  42. :class="[pros.validFlag == '3' ?'disabled' : '']">
  43. <text :class="[pros.validFlag == '3' ?'disabled' : 'money-sign']">¥</text>
  44. {{pros.retailPrice ? pros.retailPrice.toFixed(2) : ''}}
  45. </view>
  46. <view class="count" v-if="pros.validFlag == '2'" :class="[isshowDelbtn ? 'none':'show']">
  47. <view class="number-box">
  48. <view class="iconfont icon-jianhao" :class="[pros.validFlag == '3'?'disabled':'']" @click="changeCountSub(item,pros)"></view>
  49. <input class="btn-input" type="number" maxlength='4' v-model="pros.productCount" @blur="changeNnmber($event,item,pros)">
  50. <view class="iconfont icon-jiahao" :class="[pros.validFlag == '3'?'disabled':'']" @click="changeCountAdd(item,pros)"></view>
  51. </view>
  52. </view>
  53. </view>
  54. </view>
  55. </view>
  56. </view>
  57. </view>
  58. <view class="goods-pros-b" :class="[isshowDelbtn ? 'none':'show']" >
  59. <view class="sum">合计:<text class="money"><text class="money-sign">¥</text>{{item.totalPrice.toFixed(2)}}</text></view>
  60. </view>
  61. </view>
  62. </view>
  63. <!--加载loadding-->
  64. <tui-loadmore :visible="loadding" :index="3" type="black"></tui-loadmore>
  65. <tui-nomore :visible="!pullUpOn" bgcolor="#F7F7F7" :text='nomoreText'></tui-nomore>
  66. <!--加载loadding-->
  67. </scroll-view>
  68. <!-- 脚部菜单 -->
  69. <view class="footer">
  70. <view class="footer-le">
  71. <view class="foot-check checkbox-box" @tap.stop="checkAll()">
  72. <button class="checkbox iconfont" :class="[isCheckAll?'icon-gouxuan':'icon-weigouxuan']"></button>
  73. <view class="text">全选</view>
  74. </view>
  75. <view class="foot-check-delbtn">
  76. <button class="delBtn" @tap.stop="showDelManager">删除</button>
  77. </view>
  78. <view class="sum">总价:<text class="money-sign">¥</text><text class="money">{{allPrice.toFixed(2)}}</text></view>
  79. </view>
  80. <view v-if="!isshowDelbtn" class="footer-ri" >
  81. <view class="btn" @tap="toConfirmation">去结算({{allCount}})</view>
  82. </view>
  83. <view v-else class="footer-del">
  84. <view class="btn btn-cancel" @tap.stop="hideDelManage">取消</view>
  85. <view class="btn btn-confirm" @tap.stop="deleteList">删除</view>
  86. </view>
  87. </view>
  88. </view>
  89. <view v-if="isEmpty" class="cart-content empty">
  90. <view class="empty-container">
  91. <image class="empty-container-image" src="https://img.caimei365.com/group1/M00/03/71/Cmis2F3wna6AWdWzAAGlgAP0das422.png" mode="aspectFit"></image>
  92. <text class="error-text">购物车空空如也,快去商城逛逛吧~</text>
  93. <view class="login-btn" @click="goIndex">去商城</view>
  94. </view>
  95. </view>
  96. </view>
  97. <!-- 透明模态层 -->
  98. <modal-layer v-if='modallayer'></modal-layer>
  99. </view>
  100. </template>
  101. <script>
  102. import tuiSkeleton from "@/components/tui-skeleton/tui-skeleton"
  103. import tuiLoadmore from "@/components/tui-components/loadmore/loadmore"
  104. import tuiNomore from "@/components/tui-components/nomore/nomore"
  105. import modalLayer from "@/components/modal-layer"
  106. import { mapState,mapMutations } from 'vuex';
  107. import { getSellerShoppingInfo,sellerAddProductNum } from "@/api/seller.js"
  108. export default{
  109. components:{
  110. tuiSkeleton,
  111. tuiLoadmore,
  112. tuiNomore,
  113. modalLayer
  114. },
  115. data(){
  116. return{
  117. clubId:'', //机构ID
  118. serviceProviderId:'',//协销ID
  119. isStock:'',
  120. goodsList:[], //购物车的商品
  121. delGoodsList:'',//要删除的商品
  122. setGoodData:'', //确认订单的商品
  123. isCheckAll:false,//是否全选
  124. allPrice:0,//所有价格
  125. allCount:0,//被选中的产品数量
  126. isNnder:true,
  127. isModallayer:false,
  128. skeletonShow:true,
  129. isshowDelbtn:false,
  130. isDisabled: false, // 供应商/店铺全选是否禁用状态
  131. isEmpty:false,//显示空购物车
  132. scrollHeight: 'auto',
  133. nomoreText: '上拉显示更多',
  134. hasNextPage: false,
  135. loadding: false,
  136. pullUpOn: true,
  137. pullFlag: true,
  138. pageSize: 10,
  139. pageNum: 1,
  140. }
  141. },
  142. onLoad(option){
  143. this.clubId = option.clubId
  144. this.setScrollHeight();
  145. this.initData()
  146. },
  147. computed: {
  148. ...mapState(['hasLogin','userInfo'])
  149. },
  150. filters:{//单件商品的价格 × 数量
  151. totalprice(val,count){
  152. return (val * count).toFixed(2)
  153. }
  154. },
  155. methods:{
  156. initData(){
  157. this.isModallayer = false //遮罩层 防止多次点击
  158. this.skeletonShow = true //预加载圆圈
  159. this.isCheckAll=false//是否全选
  160. this.$api.getStorage().then((resolve) => {
  161. this.serviceProviderId = resolve.serviceProviderID;
  162. this.initGetCartGoodsList();
  163. })
  164. },
  165. initLogin(){
  166. this.$api.redirectTo('/pages/login/login-accont?type=4')
  167. },
  168. setScrollHeight() {
  169. // 窗口高度-footer高度
  170. const {windowHeight, pixelRatio} = uni.getSystemInfoSync();
  171. setTimeout(()=> {
  172. const query = uni.createSelectorQuery().in(this);
  173. query.selectAll('.footer').boundingClientRect();
  174. query.exec(res => {
  175. this.windowHeight = windowHeight;
  176. if(res[0][0]) {
  177. this.scrollHeight = windowHeight - res[0][0].height;
  178. }
  179. })
  180. }, 500)
  181. },
  182. initGetCartGoodsList(){//初始化购物车 index:1
  183. let params = {clubId:this.clubId,serviceProviderId:this.serviceProviderId,pageNum:1,pageSize:this.pageSize}
  184. getSellerShoppingInfo(params).then(response =>{
  185. this.skeletonShow = false
  186. this.$store.commit('updateAllNum',response.data.cartQuantity)
  187. const resultsData = response.data.pageDate;
  188. if(resultsData.results&&resultsData.results.length > 0){
  189. this.isEmpty =false
  190. this.hasNextPage = resultsData.hasNextPage;
  191. this.goodsList = resultsData.results;
  192. this.goodsList.forEach((item,index) => {
  193. let productsListLength = item.productsList.length,
  194. invalidLength = 0;
  195. item.productsList.forEach(pros => {
  196. pros.shopID = item.shopID;
  197. if(pros.validFlag == '3') {invalidLength++;}
  198. })
  199. item.isDisabled = invalidLength === productsListLength;
  200. })
  201. this.pullFlag = false;
  202. setTimeout(()=>{this.pullFlag = true;},500)
  203. if(this.hasNextPage){
  204. this.pullUpOn = false
  205. this.nomoreText = '上拉显示更多'
  206. }else{
  207. if(this.goodsList.length < 4){
  208. this.pullUpOn = true
  209. }else{
  210. this.pullUpOn = false
  211. this.nomoreText = '已至底部'
  212. }
  213. }
  214. } else {
  215. this.goodsList = [];
  216. this.isEmpty =true
  217. }
  218. }).catch(response =>{
  219. this.$util.msg(response.msg,2000);
  220. })
  221. },
  222. getOnReachBottomData(){//上拉加载
  223. this.pageNum+=1
  224. let params = {clubId:this.clubId,serviceProviderId:this.serviceProviderId,pageNum:this.pageNum,pageSize:this.pageSize}
  225. getSellerShoppingInfo(params).then(response =>{
  226. let resultsData = response.data.pageDate
  227. this.hasNextPage = resultsData.hasNextPage;
  228. this.goodsList = this.goodsList.concat(resultsData.results)
  229. this.pullFlag = false;// 防上拉暴滑
  230. setTimeout(()=>{this.pullFlag = true;},500)
  231. if(this.hasNextPage){
  232. this.pullUpOn = false
  233. this.nomoreText = '上拉显示更多'
  234. }else{
  235. this.loadding = false
  236. this.pullUpOn = false
  237. this.nomoreText = '已至底部'
  238. }
  239. }).catch(response =>{
  240. this.$util.msg(response.msg,2000);
  241. })
  242. },
  243. ischeck(item,pro){//为未选中的时候改变为true,反之为true
  244. pro.productsChecked = !pro.productsChecked;
  245. this.updateProductCheckedAllBtn(item);
  246. this.updateCheckAllBtn();
  247. },
  248. updateProductCheckedAllBtn(item) {// 单独每个供应商的勾选判断
  249. let productsList = item.productsList,
  250. productsCheckedLength = 0,
  251. disabledLength = 0;
  252. if(this.isshowDelbtn) {
  253. productsList.forEach(pros => {
  254. if(pros.productsChecked) {
  255. productsCheckedLength++;
  256. }
  257. })
  258. } else {
  259. productsList.forEach(pros => {
  260. if(pros.productsChecked && pros.validFlag != '3') {
  261. productsCheckedLength++;
  262. }
  263. if(pros.validFlag == '3') {
  264. disabledLength++;
  265. }
  266. })
  267. }
  268. item.checked = productsCheckedLength === productsList.length - disabledLength;
  269. },
  270. updateCheckAllBtn() {// 全选勾选判断
  271. let goodsCheckedLength = 0,
  272. disabledListLength = 0,
  273. goodsList = this.goodsList;
  274. goodsList.forEach(item => {
  275. if(item.checked) {
  276. goodsCheckedLength++;
  277. }
  278. if(item.isDisabled && !this.isshowDelbtn) {
  279. disabledListLength++;
  280. }
  281. })
  282. this.isCheckAll = goodsCheckedLength === goodsList.length - disabledListLength;
  283. },
  284. checkShop(item){//与单选商品类似
  285. item.checked = !item.checked;
  286. this.setProductChecked(item);
  287. this.updateCheckAllBtn();
  288. },
  289. setProductChecked(item) {
  290. let products = item.productsList;
  291. products.forEach(pros=>{
  292. if(item.checked) {
  293. if(pros.validFlag =='3'){
  294. // 无效
  295. this.isNnder = true;
  296. pros.productsChecked = this.isshowDelbtn ?true :false;
  297. }else{
  298. // 有效
  299. this.isNnder = false;
  300. pros.productsChecked = true;
  301. }
  302. } else {
  303. pros.productsChecked = false;
  304. }
  305. })
  306. },
  307. updateBothCheckBtn() {
  308. if(this.isshowDelbtn) {
  309. // 当管理删除按钮出现时,失效的商品可被选择
  310. this.goodsList.forEach((item)=>{
  311. item.checked = this.isCheckAll;
  312. this.setProductChecked(item);
  313. })
  314. } else {
  315. this.goodsList.forEach((item)=>{
  316. item.checked = this.isCheckAll && !item.isDisabled;
  317. this.setProductChecked(item);
  318. })
  319. }
  320. },
  321. checkAll(){//全选方法内调用方法
  322. this.isCheckAll = !this.isCheckAll;
  323. this.updateBothCheckBtn();
  324. },
  325. totalShopPeice(){//每次所属会所下的商品增减重新计算合计价格&减去含有下架的商品
  326. let prosPrice=0;
  327. let validPrice =0;
  328. let validList=[];
  329. let productsList=[];
  330. this.goodsList.map((item,index)=>{
  331. productsList=item.productsList;
  332. prosPrice=productsList.reduce((p,e)=>p+e.retailPrice*e.productCount,0);
  333. productsList.forEach(pros =>{
  334. if(pros.validFlag =='3'){
  335. validList.push(pros)
  336. validPrice = validList.reduce((p,e)=>p+e.retailPrice*e.productCount,0);
  337. item.totalPrice = prosPrice - validPrice
  338. }else{
  339. item.totalPrice = prosPrice
  340. }
  341. })
  342. })
  343. },
  344. totalPeice(){ //计算总价格,每次调用此方法,将初始值为0,遍历价格并累加
  345. this.allPrice = 0
  346. let prosPrice=0;
  347. let validPrice=0;
  348. let validList =[];
  349. let productsList =[];
  350. this.goodsList.forEach((item,index)=>{
  351. productsList=item.productsList;
  352. productsList.forEach(pros=>{
  353. if(pros.productsChecked){
  354. prosPrice+=pros.retailPrice*pros.productCount;
  355. if(pros.validFlag =='3'){
  356. validList.push(pros)
  357. validPrice = validList.reduce((p,e)=>p+e.retailPrice*e.productCount,0);
  358. this.allPrice = prosPrice - validPrice
  359. }else{
  360. this.allPrice = prosPrice
  361. }
  362. }
  363. })
  364. })
  365. },
  366. totalCount(){//计算总数量
  367. this.allCount = 0
  368. let prosAllCount=0
  369. let validCount = 0
  370. let validList =[];
  371. let productsList =[];
  372. this.goodsList.forEach(item=>{
  373. productsList = item.productsList
  374. productsList.forEach(pros=>{
  375. if(pros.productsChecked){
  376. prosAllCount+=parseInt(pros.productCount);
  377. if(pros.validFlag =='3'){
  378. validList.push(pros)
  379. validList.forEach(val =>{
  380. validCount += val.productCount
  381. })
  382. this.allCount = prosAllCount - validCount
  383. }else{
  384. this.allCount = prosAllCount
  385. }
  386. }
  387. })
  388. })
  389. },
  390. changeCountAdd(item,pros){//商品数量加加
  391. if(pros.productCount>=pros.stock){
  392. pros.productCount= pros.stock
  393. this.isStock =true
  394. return
  395. }else{
  396. pros.productCount++
  397. this.processActivityPrice(pros)
  398. this.isStock =false
  399. }
  400. this.updateShoppogNum(pros)
  401. this.totalShopPeice();
  402. },
  403. changeCountSub(item,pros){//商品数量减减
  404. if(pros.productCount<=pros.minBuyNumber){
  405. pros.productCount= pros.minBuyNumber
  406. this.$util.msg(`该商品最小起订量为${pros.minBuyNumber}`,2000);
  407. return
  408. }else{
  409. pros.productCount--
  410. this.processActivityPrice(pros)
  411. }
  412. this.updateShoppogNum(pros)
  413. this.totalShopPeice();
  414. },
  415. changeNnmber(e,item,pros){//输入商品数量更新
  416. let _value = e.detail.value;
  417. if(!this.$api.isNumber(_value)){
  418. pros.productCount = pros.minBuyNumber
  419. }else if(_value < pros.minBuyNumber){
  420. this.$util.msg(`该商品最小起订量为${pros.minBuyNumber}`,2000);
  421. pros.productCount = pros.minBuyNumber
  422. }else{
  423. pros.productCount = e.detail.value
  424. this.processActivityPrice(pros)
  425. }
  426. this.updateShoppogNum(pros)
  427. this.totalShopPeice();
  428. },
  429. processActivityPrice(pros){//单独处理活动价格和阶梯价格
  430. let ladderPriceList = pros.ladderPriceList;
  431. if(pros.ladderPriceFlag == '0' || pros.actFlag == 1){
  432. pros.retailPrice = pros.retailPrice
  433. }else{
  434. ladderPriceList.forEach((item,index)=>{
  435. if(pros.productCount>=item.buyNum){
  436. pros.retailPrice = item.buyPrice
  437. }
  438. })
  439. }
  440. },
  441. updateShoppogNum(pros){//加减购物车商品更新到后台
  442. let params ={id:pros.sellerCartId,productID:pros.productID,num:pros.productCount}
  443. sellerAddProductNum(params).then(response =>{
  444. this.isshowDelbtn = false;
  445. this.initGetCartGoodsList();
  446. }).catch(response =>{
  447. this.$util.msg(response.msg,2000);
  448. })
  449. },
  450. toConfirmation(){//跳转确认订单页面
  451. let setGoodsList=[];
  452. this.goodsList.forEach(res=>{
  453. let products = res.productsList
  454. products.forEach(pros=>{
  455. if(pros.productsChecked){
  456. setGoodsList.push(pros.productID)
  457. }
  458. })
  459. })
  460. if(setGoodsList == ''){
  461. this.$util.msg("请先选择结算商品~",2000);
  462. return
  463. }else{
  464. /**
  465. * @获取勾选的商品ID拼接字符串逗号隔开,最后一个逗号去掉
  466. * @获取勾选的商品分类ID拼接字符串格式逗号隔开,最后一个逗号去掉
  467. */
  468. let productID = '';
  469. this.goodsList.forEach(el=>{
  470. el.productsList.forEach(pros=>{
  471. if(pros.productsChecked){
  472. productID += pros.productID+','
  473. }
  474. })
  475. })
  476. let cartPramsData={
  477. clubId:this.clubId,
  478. allPrice:this.allPrice,
  479. allCount:this.allCount,
  480. productID:productID.substring(0,productID.lastIndexOf(',')),
  481. productCount:''
  482. }
  483. this.$api.navigateTo(`/market/pages/order/create-order?data=${JSON.stringify({data:cartPramsData})}`)
  484. }
  485. },
  486. setOrderGoods(){//本地获取勾选商品信息***暂时丢弃***
  487. let setGoodData = {}
  488. let prosPrice =0;
  489. let prosCount =0;
  490. let goodsArr = this.goodsList.map(el => {
  491. el.productsList = el.productsList.filter(item => item.productsChecked)
  492. prosPrice=el.productsList.reduce((p,e)=>p+e.retailPrice*e.productCount,0);
  493. el.productsList.forEach(pros=>{
  494. el.totalCount += pros.productCount;
  495. })
  496. el.totalPrice = prosPrice
  497. return el
  498. }).filter(el => el.productsList && el.productsList.length !==0);
  499. setGoodData = {
  500. allPrice:this.allPrice,
  501. allCount:this.allCount,
  502. goodList:goodsArr
  503. }
  504. return setGoodData
  505. },
  506. showDelManager(){//显示删除商品管理
  507. this.isshowDelbtn = true;
  508. this.isNnder = true;
  509. if(this.isCheckAll) {
  510. this.updateBothCheckBtn();
  511. } else {
  512. // 失效也被勾选
  513. this.goodsList.forEach(item => {
  514. if(item.checked) {
  515. item.productsList.forEach(pros => {
  516. pros.productsChecked = true;
  517. })
  518. }
  519. })
  520. this.updateCheckAllBtn();
  521. }
  522. },
  523. hideDelManage(){//隐藏删除商品管理
  524. this.isshowDelbtn = false;
  525. if(this.isCheckAll) {
  526. this.updateBothCheckBtn();
  527. } else {
  528. // 失效商品取消勾选
  529. this.goodsList.forEach(item => {
  530. if(item.isDisabled) {
  531. item.checked = false;
  532. }
  533. item.productsList.forEach(pros => {
  534. if(pros.validFlag == '3') {
  535. pros.productsChecked = false;
  536. }
  537. })
  538. })
  539. this.updateCheckAllBtn();
  540. }
  541. },
  542. deleteList(){//删除购物车商品
  543. this.delGoodsList=[];
  544. this.goodsList.forEach(delitem=>{
  545. let products = delitem.productsList
  546. products.forEach(pros=>{
  547. if(pros.productsChecked){
  548. this.delGoodsList += pros.productID+','
  549. }
  550. })
  551. })
  552. // console.log(this.delGoodsList);
  553. if(this.delGoodsList.length == 0){
  554. this.$util.msg("请选择要删除的商品~",2000);
  555. return
  556. }else{
  557. this.$util.modal('','确定删除选中的商品吗?','确定','取消',true,() =>{
  558. shoppingCartDelete({userID:this.userID,productIDs:this.delGoodsList}).then(response =>{
  559. console.log(response)
  560. this.$util.msg('删除成功',2000);
  561. setTimeout(()=>{
  562. this.isshowDelbtn = false;
  563. this.initGetCartGoodsList();
  564. },2000)
  565. }).catch(response =>{
  566. this.$util.msg(response.msg,2000)
  567. })
  568. })
  569. }
  570. },
  571. goIndex(){
  572. uni.switchTab({
  573. url: '/pages/tabBar/home/home'
  574. });
  575. },
  576. goNavto(url){
  577. uni.navigateTo ({
  578. url
  579. })
  580. },
  581. navToListPage(id){
  582. this.isModallayer = true;
  583. this.$api.navigateTo(`/pages/goods/product?id=${id}`)
  584. }
  585. },
  586. watch:{//深度监听所有数据,每次改变重新计算总价和总数
  587. goodsList:{
  588. deep:true,
  589. handler(val,oldval){
  590. this.totalPeice()
  591. this.totalCount()
  592. }
  593. }
  594. },
  595. onReachBottom() {
  596. if(this.hasNextPage){
  597. this.loadding = true
  598. this.pullUpOn = true
  599. this.getOnReachBottomData()
  600. }
  601. },
  602. onPullDownRefresh() {//下拉刷新
  603. this.initGetCartGoodsList()
  604. uni.stopPullDownRefresh()
  605. },
  606. onShow(){
  607. },
  608. }
  609. </script>
  610. <style lang="scss">
  611. page{
  612. background: #f7f7f7;
  613. }
  614. .cart-content{
  615. position: relative;
  616. padding-bottom:74rpx;
  617. }
  618. .container-cart-main.none{
  619. display: none;
  620. }
  621. .container-cart-main.show{
  622. display: block;
  623. }
  624. .cart-content.empty.none{
  625. display: none;
  626. }
  627. .cart-content.empty.show{
  628. display: block;
  629. }
  630. .container-cart.show{
  631. display: block;
  632. }
  633. .container-cart.none{
  634. display: none;
  635. }
  636. .empty-container.none{
  637. display: none;
  638. }
  639. .empty-container.show{
  640. display: flex;
  641. }
  642. .checkbox-box{
  643. display: flex;
  644. align-items: center;
  645. .checkbox{
  646. display: flex;
  647. margin: 0;
  648. padding: 0;
  649. display: flex;
  650. flex-direction: column;
  651. align-items: center;
  652. box-sizing: border-box;
  653. text-align: center;
  654. text-decoration: none;
  655. border-radius: 0;
  656. -webkit-tap-highlight-color: transparent;
  657. overflow: hidden;
  658. background-color:#FFFFFF;
  659. font-size: 36rpx;
  660. color:$color-system;
  661. }
  662. &.disabled{
  663. .checkbox{
  664. color:#999999
  665. }
  666. }
  667. .text{
  668. font-size: $font-size-24;
  669. margin-left: 10rpx;
  670. }
  671. }
  672. .goods-list{
  673. width: 100%;
  674. height: auto;
  675. border-top: 1px solid #EBEBEB;
  676. background-color: #F7F7F7;
  677. .goods-item{
  678. width: 702rpx;
  679. padding: 0 24rpx;
  680. background: #FFFFFF;
  681. margin-bottom: 24rpx;
  682. }
  683. .shoptitle{
  684. display: flex;
  685. align-items: center;
  686. height: 80rpx;
  687. // border-bottom: 1px solid #EBEBEB;
  688. line-height: 80rpx;
  689. .checkbox-box{
  690. margin-left: 18rpx;
  691. }
  692. .text{
  693. margin-left: 37rpx;
  694. font-size: $font-size-28;
  695. color: $text-color;
  696. text-align: left;
  697. font-weight: bold;
  698. }
  699. }
  700. .goods-pros{
  701. width: 100%;
  702. height: auto;
  703. }
  704. .goods-pros-t{
  705. display: flex;
  706. align-items: center;
  707. width: 100%;
  708. height: 217rpx;
  709. padding:0 0 26rpx 0;
  710. .checkbox-box{
  711. margin-left: 22rpx;
  712. }
  713. .pros-img{
  714. width: 210rpx;
  715. height: 100%;
  716. border-radius: 10rpx;
  717. margin:0 26rpx 0 38rpx;
  718. border:1px solid #f3f3f3;
  719. image{
  720. width: 100%;
  721. height: 100%;
  722. border-radius: 10rpx;
  723. }
  724. }
  725. }
  726. .goods-pros-b{
  727. width:622rpx;
  728. margin-left: 84rpx;
  729. height: 40rpx;
  730. padding:0 0 26rpx 0;
  731. // border-top: 1px solid #EBEBEB;
  732. &.show{
  733. display: block;
  734. }
  735. &.none{
  736. display: none;
  737. }
  738. .sum{
  739. font-size: $font-size-28;
  740. line-height: 40rpx;
  741. color: $text-color;
  742. display: flex;
  743. justify-content: flex-end;
  744. .money{
  745. color: #FF2A2A;
  746. font-size: $font-size-28;
  747. }
  748. .money-sign{
  749. font-size: $font-size-24;
  750. color: #FF2A2A;
  751. }
  752. }
  753. }
  754. .pros-product{
  755. width: 386rpx;
  756. height: 100%;
  757. line-height: 36rpx;
  758. font-size: $font-size-26;
  759. position: relative;
  760. .producttitle{
  761. width: 100%;
  762. display: inline-block;
  763. height: auto;
  764. text-overflow:ellipsis;
  765. display: -webkit-box;
  766. word-break: break-all;
  767. -webkit-box-orient: vertical;
  768. -webkit-line-clamp: 2;
  769. overflow: hidden;
  770. margin-bottom: 8rpx;
  771. .no-text{
  772. display: inline-block;
  773. height:36rpx;
  774. padding: 0 12rpx;
  775. line-height: 36rpx;
  776. background:linear-gradient(315deg,rgba(231,0,0,1) 0%,rgba(255,104,1,1) 100%);
  777. border-radius:18rpx;
  778. text-align: center;
  779. color: #FFFFFF;
  780. font-size: $font-size-24;
  781. margin-right: 24rpx;
  782. }
  783. }
  784. .productspec{
  785. height: 36rpx;
  786. color: #999999;
  787. }
  788. .productprice{
  789. height: 48rpx;
  790. position: absolute;
  791. width: 100%;
  792. bottom: 0;
  793. .price{
  794. line-height: 48rpx;
  795. font-size: $font-size-28;
  796. width: 48%;
  797. color: #FF2A2A;
  798. float: left;
  799. &.disabled{
  800. color: #999999;
  801. }
  802. .money-sign{
  803. font-size: $font-size-24;
  804. color: #FF2A2A;
  805. }
  806. }
  807. .count{
  808. height: 100%;
  809. float: right;
  810. position: relative;
  811. &.show{
  812. display: block;
  813. }
  814. &.none{
  815. display: none;
  816. }
  817. .number-box{
  818. display: flex;
  819. justify-content: center;
  820. align-items: center;
  821. .iconfont{
  822. font-size: $font-size-24;
  823. padding:0 20rpx;
  824. color: $text-color;
  825. text-align: center;
  826. line-height: 48rpx;
  827. font-weight: bold;
  828. }
  829. .btn-input{
  830. width: 62rpx;
  831. height: 48rpx;
  832. line-height: 48rpx;
  833. background: #F8F8F8;
  834. border-radius: 4rpx;
  835. text-align: center;
  836. font-size: $font-size-24;
  837. }
  838. }
  839. .uni-numbox{
  840. position: absolute;
  841. left: 45rpx;
  842. bottom: 0;
  843. .uni-numbox-minus, .uni-numbox-plus{
  844. width: 50rpx;
  845. line-height: 40rpx;
  846. }
  847. .uni-numbox-value {
  848. font-size: $font-size-28;
  849. width: 60rpx;
  850. }
  851. }
  852. }
  853. }
  854. }
  855. }
  856. .footer{
  857. width: 100%;
  858. background-color: #FFFFFF;
  859. height: 110rpx;
  860. position: fixed;
  861. bottom: 0rpx;
  862. z-index: 10;
  863. .footer-le{
  864. width: 490rpx;
  865. height: 100%;
  866. padding:0 30rpx;
  867. float: left;
  868. .text{
  869. font-weight: bold;
  870. }
  871. .foot-check{
  872. width: 100rpx;
  873. float: left;
  874. line-height: 110rpx;
  875. font-size: $font-size-24;
  876. .checkbox{
  877. width: 40rpx;
  878. text-align: center;
  879. }
  880. .text{
  881. width: 60rpx;
  882. float: right;
  883. }
  884. }
  885. .foot-check-delbtn{
  886. float: left;
  887. .delBtn{
  888. margin: 0;
  889. padding: 0;
  890. display: flex;
  891. flex-direction: column;
  892. align-items: center;
  893. box-sizing: border-box;
  894. font-size: $font-size-24;
  895. text-align: center;
  896. text-decoration: none;
  897. border-radius: 0;
  898. -webkit-tap-highlight-color: transparent;
  899. overflow: hidden;
  900. background-color:#FFFFFF;
  901. color: #FF2A2A;
  902. padding: 0 24rpx;
  903. display: flex;
  904. justify-content: center;
  905. align-items: center;
  906. line-height: 110rpx;
  907. font-weight: bold;
  908. &.none{
  909. display: none;
  910. }
  911. }
  912. }
  913. .sum{
  914. font-size: $font-size-28;
  915. line-height: 110rpx;
  916. color: $text-color;
  917. display: flex;
  918. justify-content: flex-end;
  919. .money{
  920. color: #FF2A2A;
  921. }
  922. .money-sign{
  923. font-size: $font-size-24;
  924. color: #FF2A2A;
  925. }
  926. }
  927. }
  928. .footer-ri{
  929. width: 200rpx;
  930. height: 100%;
  931. background:linear-gradient(135deg,rgba(242,143,49,1) 0%,rgba(225,86,22,1) 100%);
  932. float: right;
  933. display: flex;
  934. justify-content: space-between;
  935. align-items: center;
  936. z-index: 999;
  937. &.none{
  938. display: none;
  939. }
  940. .btn{
  941. width: 200rpx;
  942. height: 100%;
  943. font-size: $font-size-28;
  944. line-height: 110rpx;
  945. color: #FFFFFF;
  946. display: flex;
  947. justify-content: center;
  948. align-items: center;
  949. }
  950. }
  951. .footer-del{
  952. width: 400rpx;
  953. height: 100%;
  954. position: absolute;
  955. padding-left: 200rpx;
  956. background: #FFFFFF;
  957. right: 0;
  958. top: 0;
  959. z-index: 1000;
  960. &.show{
  961. animation: showDelbtn 0s linear both;
  962. }
  963. &.none{
  964. animation: hideDelbtn 0s linear both;
  965. }
  966. .btn{
  967. width: 50%;
  968. height: 100%;
  969. line-height: 110rpx;
  970. font-size: $font-size-28;
  971. color: #FFFFFF;
  972. text-align: center;
  973. float: left;
  974. }
  975. .btn.btn-cancel{
  976. background:#EEC1AB;
  977. }
  978. .btn.btn-confirm{
  979. background:#FF2A2A;
  980. }
  981. @keyframes showDelbtn {
  982. 0% {
  983. transform: translateX(0);
  984. }
  985. 100% {
  986. transform: translateX(-100%);
  987. }
  988. }
  989. @keyframes hideDelbtn {
  990. 0% {
  991. transform: translateX(-100%);
  992. }
  993. 100% {
  994. transform: translateX(0);
  995. }
  996. }
  997. }
  998. }
  999. </style>