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" 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-if="isEmpty" 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. if(pros.productCount>=pros.stock){
  389. pros.productCount= pros.stock
  390. this.isStock =true
  391. return
  392. }else{
  393. pros.productCount++
  394. this.processActivityPrice(pros)
  395. this.isStock =false
  396. }
  397. this.updateShoppogNum(pros)
  398. this.totalShopPeice();
  399. },
  400. changeCountSub(item,pros){//商品数量减减
  401. if(pros.productCount<=pros.minBuyNumber){
  402. pros.productCount= pros.minBuyNumber
  403. this.$util.msg(`该商品最小起订量为${pros.minBuyNumber}`,2000);
  404. return
  405. }else{
  406. pros.productCount--
  407. this.processActivityPrice(pros)
  408. }
  409. this.updateShoppogNum(pros)
  410. this.totalShopPeice();
  411. },
  412. changeNnmber(e,item,pros){//输入商品数量更新
  413. let _value = e.detail.value;
  414. if(!this.$api.isNumber(_value)){
  415. pros.productCount = pros.minBuyNumber
  416. }else if(_value < pros.minBuyNumber){
  417. this.$util.msg(`该商品最小起订量为${pros.minBuyNumber}`,2000);
  418. pros.productCount = pros.minBuyNumber
  419. }else{
  420. pros.productCount = e.detail.value
  421. this.processActivityPrice(pros)
  422. }
  423. this.updateShoppogNum(pros)
  424. this.totalShopPeice();
  425. },
  426. processActivityPrice(pros){//单独处理活动价格和阶梯价格
  427. let ladderPriceList = pros.ladderPriceList;
  428. if(pros.ladderPriceFlag == '0' || pros.actFlag == 1){
  429. pros.retailPrice = pros.retailPrice
  430. }else{
  431. ladderPriceList.forEach((item,index)=>{
  432. if(pros.productCount>=item.buyNum){
  433. pros.retailPrice = item.buyPrice
  434. }
  435. })
  436. }
  437. },
  438. updateShoppogNum(pros){//加减购物车商品更新到后台
  439. let params ={userID:this.userID,productID:pros.productID,productCount:pros.productCount}
  440. shoppingCartUpdate(params).then(response =>{
  441. this.isshowDelbtn = false;
  442. this.initGetCartGoodsList();
  443. }).catch(response =>{
  444. this.$util.msg(response.msg,2000);
  445. })
  446. },
  447. toConfirmation(){//跳转确认订单页面
  448. let setGoodsList=[];
  449. this.goodsList.forEach(res=>{
  450. let products = res.productsList
  451. products.forEach(pros=>{
  452. if(pros.productsChecked){
  453. setGoodsList.push(pros.productID)
  454. }
  455. })
  456. })
  457. if(setGoodsList == ''){
  458. this.$util.msg("请先选择结算商品~",2000);
  459. return
  460. }else{
  461. /**
  462. * @获取勾选的商品ID拼接字符串逗号隔开,最后一个逗号去掉
  463. * @获取勾选的商品分类ID拼接字符串格式逗号隔开,最后一个逗号去掉
  464. */
  465. let productID = '';
  466. this.goodsList.forEach(el=>{
  467. el.productsList.forEach(pros=>{
  468. if(pros.productsChecked){
  469. productID += pros.productID+','
  470. }
  471. })
  472. })
  473. let cartPramsData={
  474. allPrice:this.allPrice,
  475. allCount:this.allCount,
  476. productID:productID.substring(0,productID.lastIndexOf(',')),
  477. productCount:''
  478. }
  479. this.$api.navigateTo(`/pages/user/order/create-order?data=${JSON.stringify({data:cartPramsData})}`)
  480. }
  481. },
  482. setOrderGoods(){//本地获取勾选商品信息***暂时丢弃***
  483. let setGoodData = {}
  484. let prosPrice =0;
  485. let prosCount =0;
  486. let goodsArr = this.goodsList.map(el => {
  487. el.productsList = el.productsList.filter(item => item.productsChecked)
  488. prosPrice=el.productsList.reduce((p,e)=>p+e.retailPrice*e.productCount,0);
  489. el.productsList.forEach(pros=>{
  490. el.totalCount += pros.productCount;
  491. })
  492. el.totalPrice = prosPrice
  493. return el
  494. }).filter(el => el.productsList && el.productsList.length !==0);
  495. setGoodData = {
  496. allPrice:this.allPrice,
  497. allCount:this.allCount,
  498. goodList:goodsArr
  499. }
  500. return setGoodData
  501. },
  502. showDelManager(){//显示删除商品管理
  503. this.isshowDelbtn = true;
  504. this.isNnder = true;
  505. if(this.isCheckAll) {
  506. this.updateBothCheckBtn();
  507. } else {
  508. // 失效也被勾选
  509. this.goodsList.forEach(item => {
  510. if(item.checked) {
  511. item.productsList.forEach(pros => {
  512. pros.productsChecked = true;
  513. })
  514. }
  515. })
  516. this.updateCheckAllBtn();
  517. }
  518. },
  519. hideDelManage(){//隐藏删除商品管理
  520. this.isshowDelbtn = false;
  521. if(this.isCheckAll) {
  522. this.updateBothCheckBtn();
  523. } else {
  524. // 失效商品取消勾选
  525. this.goodsList.forEach(item => {
  526. if(item.isDisabled) {
  527. item.checked = false;
  528. }
  529. item.productsList.forEach(pros => {
  530. if(pros.validFlag == '3') {
  531. pros.productsChecked = false;
  532. }
  533. })
  534. })
  535. this.updateCheckAllBtn();
  536. }
  537. },
  538. deleteList(){//删除购物车商品
  539. this.delGoodsList=[];
  540. this.goodsList.forEach(delitem=>{
  541. let products = delitem.productsList
  542. products.forEach(pros=>{
  543. if(pros.productsChecked){
  544. this.delGoodsList += pros.productID+','
  545. }
  546. })
  547. })
  548. // console.log(this.delGoodsList);
  549. if(this.delGoodsList.length == 0){
  550. this.$util.msg("请选择要删除的商品~",2000);
  551. return
  552. }else{
  553. this.$util.modal('','确定删除选中的商品吗?','确定','取消',true,() =>{
  554. shoppingCartDelete({userID:this.userID,productIDs:this.delGoodsList}).then(response =>{
  555. console.log(response)
  556. this.$util.msg('删除成功',2000);
  557. setTimeout(()=>{
  558. this.isshowDelbtn = false;
  559. this.initGetCartGoodsList();
  560. },2000)
  561. }).catch(response =>{
  562. this.$util.msg(response.msg,2000)
  563. })
  564. })
  565. }
  566. },
  567. goIndex(){
  568. uni.switchTab({
  569. url: '/pages/tabBar/home/home'
  570. });
  571. },
  572. goNavto(url){
  573. uni.navigateTo ({
  574. url
  575. })
  576. },
  577. navToListPage(id){
  578. this.isModallayer = true;
  579. this.$api.navigateTo(`/pages/goods/product?id=${id}`)
  580. }
  581. },
  582. watch:{//深度监听所有数据,每次改变重新计算总价和总数
  583. goodsList:{
  584. deep:true,
  585. handler(val,oldval){
  586. this.totalPeice()
  587. this.totalCount()
  588. }
  589. }
  590. },
  591. onReachBottom() {
  592. if(this.hasNextPage){
  593. this.loadding = true
  594. this.pullUpOn = true
  595. this.getOnReachBottomData()
  596. }
  597. },
  598. onPullDownRefresh() {//下拉刷新
  599. this.initGetCartGoodsList()
  600. uni.stopPullDownRefresh()
  601. },
  602. onShow(){
  603. if(!this.hasLogin){
  604. this.initLogin()
  605. }else{
  606. this.initData()
  607. }
  608. },
  609. }
  610. </script>
  611. <style lang="scss">
  612. page{
  613. background: #f7f7f7;
  614. }
  615. .cart-content{
  616. position: relative;
  617. padding-bottom:74rpx;
  618. }
  619. .container-cart-main.none{
  620. display: none;
  621. }
  622. .container-cart-main.show{
  623. display: block;
  624. }
  625. .cart-content.empty.none{
  626. display: none;
  627. }
  628. .cart-content.empty.show{
  629. display: block;
  630. }
  631. .container-cart.show{
  632. display: block;
  633. }
  634. .container-cart.none{
  635. display: none;
  636. }
  637. .empty-container.none{
  638. display: none;
  639. }
  640. .empty-container.show{
  641. display: flex;
  642. }
  643. .checkbox-box{
  644. display: flex;
  645. align-items: center;
  646. .checkbox{
  647. display: flex;
  648. margin: 0;
  649. padding: 0;
  650. display: flex;
  651. flex-direction: column;
  652. align-items: center;
  653. box-sizing: border-box;
  654. text-align: center;
  655. text-decoration: none;
  656. border-radius: 0;
  657. -webkit-tap-highlight-color: transparent;
  658. overflow: hidden;
  659. background-color:#FFFFFF;
  660. font-size: 36rpx;
  661. color:$color-system;
  662. }
  663. &.disabled{
  664. .checkbox{
  665. color:#999999
  666. }
  667. }
  668. .text{
  669. font-size: $font-size-24;
  670. margin-left: 10rpx;
  671. }
  672. }
  673. .goods-list{
  674. width: 100%;
  675. height: auto;
  676. border-top: 1px solid #EBEBEB;
  677. background-color: #F7F7F7;
  678. .goods-item{
  679. width: 702rpx;
  680. padding: 0 24rpx;
  681. background: #FFFFFF;
  682. margin-bottom: 24rpx;
  683. }
  684. .shoptitle{
  685. display: flex;
  686. align-items: center;
  687. height: 80rpx;
  688. // border-bottom: 1px solid #EBEBEB;
  689. line-height: 80rpx;
  690. .checkbox-box{
  691. margin-left: 18rpx;
  692. }
  693. .text{
  694. margin-left: 37rpx;
  695. font-size: $font-size-28;
  696. color: $text-color;
  697. text-align: left;
  698. font-weight: bold;
  699. }
  700. }
  701. .goods-pros{
  702. width: 100%;
  703. height: auto;
  704. }
  705. .goods-pros-t{
  706. display: flex;
  707. align-items: center;
  708. width: 100%;
  709. height: 217rpx;
  710. padding:0 0 26rpx 0;
  711. .checkbox-box{
  712. margin-left: 22rpx;
  713. }
  714. .pros-img{
  715. width: 210rpx;
  716. height: 100%;
  717. border-radius: 10rpx;
  718. margin:0 26rpx 0 38rpx;
  719. border:1px solid #f3f3f3;
  720. image{
  721. width: 100%;
  722. height: 100%;
  723. border-radius: 10rpx;
  724. }
  725. }
  726. }
  727. .goods-pros-b{
  728. width:622rpx;
  729. margin-left: 84rpx;
  730. height: 40rpx;
  731. padding:0 0 26rpx 0;
  732. // border-top: 1px solid #EBEBEB;
  733. &.show{
  734. display: block;
  735. }
  736. &.none{
  737. display: none;
  738. }
  739. .sum{
  740. font-size: $font-size-28;
  741. line-height: 40rpx;
  742. color: $text-color;
  743. display: flex;
  744. justify-content: flex-end;
  745. .money{
  746. color: #FF2A2A;
  747. font-size: $font-size-28;
  748. }
  749. .money-sign{
  750. font-size: $font-size-24;
  751. color: #FF2A2A;
  752. }
  753. }
  754. }
  755. .pros-product{
  756. width: 386rpx;
  757. height: 100%;
  758. line-height: 36rpx;
  759. font-size: $font-size-26;
  760. position: relative;
  761. .producttitle{
  762. width: 100%;
  763. display: inline-block;
  764. height: auto;
  765. text-overflow:ellipsis;
  766. display: -webkit-box;
  767. word-break: break-all;
  768. -webkit-box-orient: vertical;
  769. -webkit-line-clamp: 2;
  770. overflow: hidden;
  771. margin-bottom: 8rpx;
  772. .no-text{
  773. display: inline-block;
  774. height:36rpx;
  775. padding: 0 12rpx;
  776. line-height: 36rpx;
  777. background:linear-gradient(315deg,rgba(231,0,0,1) 0%,rgba(255,104,1,1) 100%);
  778. border-radius:18rpx;
  779. text-align: center;
  780. color: #FFFFFF;
  781. font-size: $font-size-24;
  782. margin-right: 24rpx;
  783. }
  784. }
  785. .productspec{
  786. height: 36rpx;
  787. color: #999999;
  788. }
  789. .productprice{
  790. height: 48rpx;
  791. position: absolute;
  792. width: 100%;
  793. bottom: 0;
  794. .price{
  795. line-height: 48rpx;
  796. font-size: $font-size-28;
  797. width: 48%;
  798. color: #FF2A2A;
  799. float: left;
  800. &.disabled{
  801. color: #999999;
  802. }
  803. .money-sign{
  804. font-size: $font-size-24;
  805. color: #FF2A2A;
  806. }
  807. }
  808. .count{
  809. height: 100%;
  810. float: right;
  811. position: relative;
  812. &.show{
  813. display: block;
  814. }
  815. &.none{
  816. display: none;
  817. }
  818. .number-box{
  819. display: flex;
  820. justify-content: center;
  821. align-items: center;
  822. .iconfont{
  823. font-size: $font-size-24;
  824. padding:0 20rpx;
  825. color: $text-color;
  826. text-align: center;
  827. line-height: 48rpx;
  828. font-weight: bold;
  829. }
  830. .btn-input{
  831. width: 62rpx;
  832. height: 48rpx;
  833. line-height: 48rpx;
  834. background: #F8F8F8;
  835. border-radius: 4rpx;
  836. text-align: center;
  837. font-size: $font-size-24;
  838. }
  839. }
  840. .uni-numbox{
  841. position: absolute;
  842. left: 45rpx;
  843. bottom: 0;
  844. .uni-numbox-minus, .uni-numbox-plus{
  845. width: 50rpx;
  846. line-height: 40rpx;
  847. }
  848. .uni-numbox-value {
  849. font-size: $font-size-28;
  850. width: 60rpx;
  851. }
  852. }
  853. }
  854. }
  855. }
  856. }
  857. .footer{
  858. width: 100%;
  859. background-color: #FFFFFF;
  860. height: 110rpx;
  861. position: fixed;
  862. bottom: 0rpx;
  863. z-index: 10;
  864. .footer-le{
  865. width: 490rpx;
  866. height: 100%;
  867. padding:0 30rpx;
  868. float: left;
  869. .text{
  870. font-weight: bold;
  871. }
  872. .foot-check{
  873. width: 100rpx;
  874. float: left;
  875. line-height: 110rpx;
  876. font-size: $font-size-24;
  877. .checkbox{
  878. width: 40rpx;
  879. text-align: center;
  880. }
  881. .text{
  882. width: 60rpx;
  883. float: right;
  884. }
  885. }
  886. .foot-check-delbtn{
  887. float: left;
  888. .delBtn{
  889. margin: 0;
  890. padding: 0;
  891. display: flex;
  892. flex-direction: column;
  893. align-items: center;
  894. box-sizing: border-box;
  895. font-size: $font-size-24;
  896. text-align: center;
  897. text-decoration: none;
  898. border-radius: 0;
  899. -webkit-tap-highlight-color: transparent;
  900. overflow: hidden;
  901. background-color:#FFFFFF;
  902. color: #FF2A2A;
  903. padding: 0 24rpx;
  904. display: flex;
  905. justify-content: center;
  906. align-items: center;
  907. line-height: 110rpx;
  908. font-weight: bold;
  909. &.none{
  910. display: none;
  911. }
  912. }
  913. }
  914. .sum{
  915. font-size: $font-size-28;
  916. line-height: 110rpx;
  917. color: $text-color;
  918. display: flex;
  919. justify-content: flex-end;
  920. .money{
  921. color: #FF2A2A;
  922. }
  923. .money-sign{
  924. font-size: $font-size-24;
  925. color: #FF2A2A;
  926. }
  927. }
  928. }
  929. .footer-ri{
  930. width: 200rpx;
  931. height: 100%;
  932. background:linear-gradient(135deg,rgba(242,143,49,1) 0%,rgba(225,86,22,1) 100%);
  933. float: right;
  934. display: flex;
  935. justify-content: space-between;
  936. align-items: center;
  937. z-index: 999;
  938. &.none{
  939. display: none;
  940. }
  941. .btn{
  942. width: 200rpx;
  943. height: 100%;
  944. font-size: $font-size-28;
  945. line-height: 110rpx;
  946. color: #FFFFFF;
  947. display: flex;
  948. justify-content: center;
  949. align-items: center;
  950. }
  951. }
  952. .footer-del{
  953. width: 400rpx;
  954. height: 100%;
  955. position: absolute;
  956. padding-left: 200rpx;
  957. background: #FFFFFF;
  958. right: 0;
  959. top: 0;
  960. z-index: 1000;
  961. &.show{
  962. animation: showDelbtn 0s linear both;
  963. }
  964. &.none{
  965. animation: hideDelbtn 0s linear both;
  966. }
  967. .btn{
  968. width: 50%;
  969. height: 100%;
  970. line-height: 110rpx;
  971. font-size: $font-size-28;
  972. color: #FFFFFF;
  973. text-align: center;
  974. float: left;
  975. }
  976. .btn.btn-cancel{
  977. background:#EEC1AB;
  978. }
  979. .btn.btn-confirm{
  980. background:#FF2A2A;
  981. }
  982. @keyframes showDelbtn {
  983. 0% {
  984. transform: translateX(0);
  985. }
  986. 100% {
  987. transform: translateX(-100%);
  988. }
  989. }
  990. @keyframes hideDelbtn {
  991. 0% {
  992. transform: translateX(-100%);
  993. }
  994. 100% {
  995. transform: translateX(0);
  996. }
  997. }
  998. }
  999. }
  1000. </style>