cart.vue 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981
  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>{{pros.retailPrice?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/login/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. showDelManager(){//显示删除商品管理
  483. this.isshowDelbtn = true;
  484. this.isNnder = true;
  485. if(this.isCheckAll) {
  486. this.updateBothCheckBtn();
  487. } else {
  488. // 失效也被勾选
  489. this.goodsList.forEach(item => {
  490. if(item.checked) {
  491. item.productsList.forEach(pros => {
  492. pros.productsChecked = true;
  493. })
  494. }
  495. })
  496. this.updateCheckAllBtn();
  497. }
  498. },
  499. hideDelManage(){//隐藏删除商品管理
  500. this.isshowDelbtn = false;
  501. if(this.isCheckAll) {
  502. this.updateBothCheckBtn();
  503. } else {
  504. // 失效商品取消勾选
  505. this.goodsList.forEach(item => {
  506. if(item.isDisabled) {
  507. item.checked = false;
  508. }
  509. item.productsList.forEach(pros => {
  510. if(pros.validFlag == '3') {
  511. pros.productsChecked = false;
  512. }
  513. })
  514. })
  515. this.updateCheckAllBtn();
  516. }
  517. },
  518. deleteList(){//删除购物车商品
  519. this.delGoodsList=[];
  520. this.goodsList.forEach(delitem=>{
  521. let products = delitem.productsList
  522. products.forEach(pros=>{
  523. if(pros.productsChecked){
  524. this.delGoodsList += pros.productID+','
  525. }
  526. })
  527. })
  528. if(this.delGoodsList.length == 0){
  529. this.$util.msg("请选择要删除的商品~",2000);
  530. return
  531. }else{
  532. this.$util.modal('','确定删除选中的商品吗?','确定','取消',true,() =>{
  533. shoppingCartDelete({userID:this.userID,productIDs:this.delGoodsList}).then(response =>{
  534. this.$util.msg('删除成功',2000);
  535. setTimeout(()=>{
  536. this.isshowDelbtn = false;
  537. this.initGetCartGoodsList();
  538. },2000)
  539. }).catch(response =>{
  540. this.$util.msg(response.msg,2000)
  541. })
  542. })
  543. }
  544. },
  545. goIndex(){
  546. uni.switchTab({
  547. url: '/pages/tabBar/home/home'
  548. });
  549. },
  550. goNavto(url){
  551. uni.navigateTo ({
  552. url
  553. })
  554. },
  555. navToListPage(id){
  556. this.isModallayer = true;
  557. this.$api.navigateTo(`/pages/goods/product?id=${id}`)
  558. }
  559. },
  560. watch:{//深度监听所有数据,每次改变重新计算总价和总数
  561. goodsList:{
  562. deep:true,
  563. handler(val,oldval){
  564. this.totalPeice()
  565. this.totalCount()
  566. }
  567. }
  568. },
  569. onReachBottom() {
  570. if(this.hasNextPage){
  571. this.loadding = true
  572. this.pullUpOn = true
  573. this.getOnReachBottomData()
  574. }
  575. },
  576. onPullDownRefresh() {//下拉刷新
  577. this.initGetCartGoodsList()
  578. uni.stopPullDownRefresh()
  579. },
  580. onShow(){
  581. if(!this.hasLogin){
  582. this.initLogin()
  583. }else{
  584. this.initData()
  585. }
  586. },
  587. }
  588. </script>
  589. <style lang="scss">
  590. page{
  591. background: #f7f7f7;
  592. }
  593. .cart-content{
  594. position: relative;
  595. padding-bottom:74rpx;
  596. }
  597. .container-cart-main.none{
  598. display: none;
  599. }
  600. .container-cart-main.show{
  601. display: block;
  602. }
  603. .cart-content.empty.none{
  604. display: none;
  605. }
  606. .cart-content.empty.show{
  607. display: block;
  608. }
  609. .container-cart.show{
  610. display: block;
  611. }
  612. .container-cart.none{
  613. display: none;
  614. }
  615. .empty-container.none{
  616. display: none;
  617. }
  618. .empty-container.show{
  619. display: flex;
  620. }
  621. .checkbox-box{
  622. display: flex;
  623. align-items: center;
  624. .checkbox{
  625. display: flex;
  626. margin: 0;
  627. padding: 0;
  628. display: flex;
  629. flex-direction: column;
  630. align-items: center;
  631. box-sizing: border-box;
  632. text-align: center;
  633. text-decoration: none;
  634. border-radius: 0;
  635. -webkit-tap-highlight-color: transparent;
  636. overflow: hidden;
  637. background-color:#FFFFFF;
  638. font-size: 36rpx;
  639. color:$color-system;
  640. }
  641. &.disabled{
  642. .checkbox{
  643. color:#999999
  644. }
  645. }
  646. .text{
  647. font-size: $font-size-24;
  648. margin-left: 10rpx;
  649. }
  650. }
  651. .goods-list{
  652. width: 100%;
  653. height: auto;
  654. border-top: 1px solid #EBEBEB;
  655. background-color: #F7F7F7;
  656. .goods-item{
  657. width: 702rpx;
  658. padding: 0 24rpx;
  659. background: #FFFFFF;
  660. margin-bottom: 24rpx;
  661. }
  662. .shoptitle{
  663. display: flex;
  664. align-items: center;
  665. height: 80rpx;
  666. // border-bottom: 1px solid #EBEBEB;
  667. line-height: 80rpx;
  668. .checkbox-box{
  669. margin-left: 18rpx;
  670. }
  671. .text{
  672. margin-left: 37rpx;
  673. font-size: $font-size-28;
  674. color: $text-color;
  675. text-align: left;
  676. font-weight: bold;
  677. }
  678. }
  679. .goods-pros{
  680. width: 100%;
  681. height: auto;
  682. }
  683. .goods-pros-t{
  684. display: flex;
  685. align-items: center;
  686. width: 100%;
  687. height: 217rpx;
  688. padding:0 0 26rpx 0;
  689. .checkbox-box{
  690. margin-left: 22rpx;
  691. }
  692. .pros-img{
  693. width: 210rpx;
  694. height: 100%;
  695. border-radius: 10rpx;
  696. margin:0 26rpx 0 38rpx;
  697. border:1px solid #f3f3f3;
  698. image{
  699. width: 100%;
  700. height: 100%;
  701. border-radius: 10rpx;
  702. }
  703. }
  704. }
  705. .goods-pros-b{
  706. width:622rpx;
  707. margin-left: 84rpx;
  708. height: 40rpx;
  709. padding:0 0 26rpx 0;
  710. // border-top: 1px solid #EBEBEB;
  711. &.show{
  712. display: block;
  713. }
  714. &.none{
  715. display: none;
  716. }
  717. .sum{
  718. font-size: $font-size-28;
  719. line-height: 40rpx;
  720. color: $text-color;
  721. display: flex;
  722. justify-content: flex-end;
  723. .money{
  724. color: #FF2A2A;
  725. font-size: $font-size-28;
  726. }
  727. .money-sign{
  728. font-size: $font-size-24;
  729. color: #FF2A2A;
  730. }
  731. }
  732. }
  733. .pros-product{
  734. width: 386rpx;
  735. height: 100%;
  736. line-height: 36rpx;
  737. font-size: $font-size-26;
  738. position: relative;
  739. .producttitle{
  740. width: 100%;
  741. display: inline-block;
  742. height: auto;
  743. text-overflow:ellipsis;
  744. display: -webkit-box;
  745. word-break: break-all;
  746. -webkit-box-orient: vertical;
  747. -webkit-line-clamp: 2;
  748. overflow: hidden;
  749. margin-bottom: 8rpx;
  750. .no-text{
  751. display: inline-block;
  752. height:36rpx;
  753. padding: 0 12rpx;
  754. line-height: 36rpx;
  755. background:linear-gradient(315deg,rgba(231,0,0,1) 0%,rgba(255,104,1,1) 100%);
  756. border-radius:18rpx;
  757. text-align: center;
  758. color: #FFFFFF;
  759. font-size: $font-size-24;
  760. margin-right: 24rpx;
  761. }
  762. }
  763. .productspec{
  764. height: 36rpx;
  765. color: #999999;
  766. }
  767. .productprice{
  768. height: 48rpx;
  769. position: absolute;
  770. width: 100%;
  771. bottom: 0;
  772. .price{
  773. line-height: 48rpx;
  774. font-size: $font-size-28;
  775. width: 48%;
  776. color: #FF2A2A;
  777. float: left;
  778. &.disabled{
  779. color: #999999;
  780. }
  781. .money-sign{
  782. font-size: $font-size-24;
  783. color: #FF2A2A;
  784. }
  785. }
  786. .count{
  787. height: 100%;
  788. float: right;
  789. position: relative;
  790. &.show{
  791. display: block;
  792. }
  793. &.none{
  794. display: none;
  795. }
  796. .number-box{
  797. display: flex;
  798. justify-content: center;
  799. align-items: center;
  800. .iconfont{
  801. font-size: $font-size-24;
  802. padding:0 20rpx;
  803. color: $text-color;
  804. text-align: center;
  805. line-height: 48rpx;
  806. font-weight: bold;
  807. }
  808. .btn-input{
  809. width: 62rpx;
  810. height: 48rpx;
  811. line-height: 48rpx;
  812. background: #F8F8F8;
  813. border-radius: 4rpx;
  814. text-align: center;
  815. font-size: $font-size-24;
  816. }
  817. }
  818. .uni-numbox{
  819. position: absolute;
  820. left: 45rpx;
  821. bottom: 0;
  822. .uni-numbox-minus, .uni-numbox-plus{
  823. width: 50rpx;
  824. line-height: 40rpx;
  825. }
  826. .uni-numbox-value {
  827. font-size: $font-size-28;
  828. width: 60rpx;
  829. }
  830. }
  831. }
  832. }
  833. }
  834. }
  835. .footer{
  836. width: 100%;
  837. background-color: #FFFFFF;
  838. height: 110rpx;
  839. position: fixed;
  840. bottom: 0rpx;
  841. z-index: 10;
  842. .footer-le{
  843. width: 490rpx;
  844. height: 100%;
  845. padding:0 30rpx;
  846. float: left;
  847. .text{
  848. font-weight: bold;
  849. }
  850. .foot-check{
  851. width: 100rpx;
  852. float: left;
  853. line-height: 110rpx;
  854. font-size: $font-size-24;
  855. .checkbox{
  856. width: 40rpx;
  857. text-align: center;
  858. }
  859. .text{
  860. width: 60rpx;
  861. float: right;
  862. }
  863. }
  864. .foot-check-delbtn{
  865. float: left;
  866. .delBtn{
  867. margin: 0;
  868. padding: 0;
  869. display: flex;
  870. flex-direction: column;
  871. align-items: center;
  872. box-sizing: border-box;
  873. font-size: $font-size-24;
  874. text-align: center;
  875. text-decoration: none;
  876. border-radius: 0;
  877. -webkit-tap-highlight-color: transparent;
  878. overflow: hidden;
  879. background-color:#FFFFFF;
  880. color: #FF2A2A;
  881. padding: 0 24rpx;
  882. display: flex;
  883. justify-content: center;
  884. align-items: center;
  885. line-height: 110rpx;
  886. font-weight: bold;
  887. &.none{
  888. display: none;
  889. }
  890. }
  891. }
  892. .sum{
  893. font-size: $font-size-28;
  894. line-height: 110rpx;
  895. color: $text-color;
  896. display: flex;
  897. justify-content: flex-end;
  898. .money{
  899. color: #FF2A2A;
  900. }
  901. .money-sign{
  902. font-size: $font-size-24;
  903. color: #FF2A2A;
  904. }
  905. }
  906. }
  907. .footer-ri{
  908. width: 200rpx;
  909. height: 100%;
  910. background:linear-gradient(135deg,rgba(242,143,49,1) 0%,rgba(225,86,22,1) 100%);
  911. float: right;
  912. display: flex;
  913. justify-content: space-between;
  914. align-items: center;
  915. z-index: 999;
  916. &.none{
  917. display: none;
  918. }
  919. .btn{
  920. width: 200rpx;
  921. height: 100%;
  922. font-size: $font-size-28;
  923. line-height: 110rpx;
  924. color: #FFFFFF;
  925. display: flex;
  926. justify-content: center;
  927. align-items: center;
  928. }
  929. }
  930. .footer-del{
  931. width: 400rpx;
  932. height: 100%;
  933. position: absolute;
  934. padding-left: 200rpx;
  935. background: #FFFFFF;
  936. right: 0;
  937. top: 0;
  938. z-index: 1000;
  939. &.show{
  940. animation: showDelbtn 0s linear both;
  941. }
  942. &.none{
  943. animation: hideDelbtn 0s linear both;
  944. }
  945. .btn{
  946. width: 50%;
  947. height: 100%;
  948. line-height: 110rpx;
  949. font-size: $font-size-28;
  950. color: #FFFFFF;
  951. text-align: center;
  952. float: left;
  953. }
  954. .btn.btn-cancel{
  955. background:#EEC1AB;
  956. }
  957. .btn.btn-confirm{
  958. background:#FF2A2A;
  959. }
  960. @keyframes showDelbtn {
  961. 0% {
  962. transform: translateX(0);
  963. }
  964. 100% {
  965. transform: translateX(-100%);
  966. }
  967. }
  968. @keyframes hideDelbtn {
  969. 0% {
  970. transform: translateX(-100%);
  971. }
  972. 100% {
  973. transform: translateX(0);
  974. }
  975. }
  976. }
  977. }
  978. </style>