cart.vue 27 KB

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