cart.vue 26 KB

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