cart.vue 26 KB

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