cart.vue 26 KB

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