cart.vue 26 KB

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