index.vue 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371
  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" :style="{paddingTop:isshowDelbtn ? '0rpx':'80rpx'}">
  5. <view class="foot-check-delbtn" v-if="!isshowDelbtn && goodsList.length>0">
  6. <view class="foot-text">共<text>{{kindCount}}</text>件商品</view>
  7. <view class="delBtn" @tap.stop="showDelManager">删除</view>
  8. </view>
  9. <view v-if="!isEmpty" class="container-cart">
  10. <view class="cart-content" :style="{paddingBottom :isIphoneX ? '130rpx' : '100rpx'}">
  11. <view class="goods-list">
  12. <view v-for="(item, index) in goodsList" :key="index" class="goods-item clearfix">
  13. <view class="shoptitle">
  14. <!--选择商店的全部商品"-->
  15. <view class="checkbox-box" @click.stop="checkShop(item)">
  16. <view class="checkbox iconfont" :class="[item.checked ?'icon-xuanze':'icon-weixuanze']"></view>
  17. </view>
  18. <view class="text">{{item.name}}</view>
  19. </view>
  20. <view class="productlist">
  21. <view class="goods-pros" v-for="(pros,idx) in item.productList" :key="idx" >
  22. <view class="goods-pros-t">
  23. <!--选择商品-->
  24. <view class="checkbox-box" @click.stop="ischeck(item,pros)">
  25. <view class="checkbox iconfont" :class="[pros.productsChecked ? 'icon-xuanze':'icon-weixuanze']"></view>
  26. </view>
  27. <view class="pros-img" @click.stop="navToListPage(pros)" ><image :src="pros.mainImage ? pros.mainImage:''" alt="" /></view>
  28. <view class="pros-product">
  29. <view class="producttitle" @click.stop="navToListPage(pros)" >{{pros.productName}}</view>
  30. <view class="productspec">规格:{{pros.unit ? pros.unit : ''}}</view>
  31. <view class="floor-item-act" v-if="pros.activeStatus == 1">
  32. <text class="tag tag-01" v-if="!pros.heUserId">自营</text>
  33. <text class="tag tag-01" v-else>促销</text>
  34. <text class="tag tag-02" @click.stop="clickPopupShow(pros,2)">活动价</text>
  35. </view>
  36. <view class="productprice">
  37. <!--使用过滤器对总价改变-->
  38. <view class="price"><text>¥</text>{{ pros.price | NumFormat }}</view>
  39. <view class="count">
  40. <view class="number-box">
  41. <view class="iconfont icon-jianhao" @click="changeCountSub(item,pros)"></view>
  42. <input class="btn-input" type="number" maxlength='4' v-model="pros.productCount" @blur="changeNnmber($event,item,pros)" @focus="changeInput(pros)">
  43. <view class="iconfont icon-jiahao" @click="changeCountAdd(item,pros)"></view>
  44. </view>
  45. </view>
  46. </view>
  47. </view>
  48. </view>
  49. </view>
  50. </view>
  51. <view class="goods-pros-b clearfix" :class="[isshowDelbtn ? 'none':'show']" >
  52. <view class="sum-none" v-if="item.reducedPrice>0">
  53. <text class="money-sign">¥</text>
  54. <text class="money">{{ item.totalOriginalPrice | NumFormat }}</text>
  55. <text class="money-reduced">减<text>¥{{ item.reducedPrice | NumFormat}}</text></text>
  56. </view>
  57. <view class="sum">合计:<text class="money"><text class="money-sign">¥</text>{{item.totalPrice | NumFormat}}</text></view>
  58. </view>
  59. </view>
  60. </view>
  61. <view class="failure-list" v-if="failureList.length>0">
  62. <view class="failure-title">
  63. <view class="title-txt">失效商品<text>{{failureList.length}}件</text></view>
  64. <view class="title-btn" @click.stop="deletefailureList"><text class="butto">清空失效商品</text></view>
  65. </view>
  66. <view class="productlist">
  67. <view class="goods-pros" v-for="(failure,failureIdx) in failureList" :key="failureIdx" >
  68. <view class="goods-pros-t" @click.stop="navToListPage(failure)">
  69. <!--选择商品-->
  70. <view class="checkbox-box" @click.stop="ischeckFailure(failure)" v-if="isshowDelbtn">
  71. <button class="checkbox iconfont"
  72. :class="[ failure.productsChecked ? 'icon-xuanze':'icon-weixuanze']">
  73. </button>
  74. </view>
  75. <text class="img-tip">失效</text>
  76. <view class="pros-img">
  77. <image :src="failure.mainImage ? failure.mainImage:''" alt="" />
  78. </view>
  79. <view class="pros-product">
  80. <view class="producttitle">{{failure.name}}</view>
  81. <view class="productspec">规格:{{failure.unit ? failure.unit : ''}}</view>
  82. <view class="productstate">商品已下架</view>
  83. </view>
  84. </view>
  85. </view>
  86. </view>
  87. </view>
  88. </view>
  89. <!-- 脚部菜单 -->
  90. <view class="footer">
  91. <view class="footer-le">
  92. <view class="foot-check checkbox-box" @tap.stop="checkAll()">
  93. <button class="checkbox iconfont" :class="[isCheckAll?'icon-xuanze':'icon-weixuanze']"></button>
  94. <view class="text">全选</view>
  95. </view>
  96. <view class="sum">
  97. <view v-if="!isshowDelbtn" class="sum-price">
  98. 总价:<text class="money-sign">¥</text><text class="money">{{allPrice | NumFormat}}</text>
  99. </view>
  100. </view>
  101. </view>
  102. <view v-if="!isshowDelbtn" class="footer-ri" >
  103. <view class="btn hanld-btn" @tap="toConfirmation">去结算({{allCount}})</view>
  104. </view>
  105. <view v-else class="footer-del">
  106. <view class="btn btn-cancel" @tap.stop="hideDelManage">取消</view>
  107. <view class="btn btn-confirm" @tap.stop="deleteList">删除</view>
  108. </view>
  109. </view>
  110. </view>
  111. <view v-else class="cart-content empty">
  112. <view class="empty-container">
  113. <image class="empty-container-image" :src="StaticUrl+'icon-empty-cart.png'" mode="aspectFit"></image>
  114. <text class="error-text">购物车空空的,快去逛逛吧~</text>
  115. </view>
  116. </view>
  117. </view>
  118. <!-- 操作弹窗 -->
  119. <tui-modal :show="modal" @click="handleClick" @cancel="hideMobel" :content="contentModalText" color="#333" :size="32" shape="circle" :maskClosable="false"></tui-modal>
  120. <!-- 促销活动弹窗 -->
  121. <activi-popup :product="handlerPros" :popupShow="popupShow"></activi-popup>
  122. <!-- 透明模态层 -->
  123. <modal-layer v-if='modallayer'></modal-layer>
  124. </view>
  125. </template>
  126. <script>
  127. import authorize from '@/common/config/authorize.js'
  128. import tuiSkeleton from "@/components/tui-skeleton/tui-skeleton"
  129. import tuiLoadmore from "@/components/tui-components/loadmore/loadmore"
  130. import tuiNomore from "@/components/tui-components/nomore/nomore"
  131. import activiPopup from "@/components/cm-module/productDetails/cm-activipopu"
  132. import modalLayer from "@/components/modal-layer"
  133. import { mapState,mapMutations } from 'vuex';
  134. export default{
  135. components:{
  136. tuiSkeleton,
  137. tuiLoadmore,
  138. tuiNomore,
  139. activiPopup,
  140. modalLayer
  141. },
  142. data(){
  143. return{
  144. StaticUrl:this.$Static,
  145. CustomBar:this.CustomBar,// 顶部导航栏高度
  146. isIphoneX:this.$store.state.isIphoneX,
  147. userId:'',
  148. popupShow:false,
  149. handlerPros:{},//监听单挑促销商品
  150. failureList:[], //失效商品列表
  151. goodsList:[], //购物车的商品
  152. delGoodsList:'',//要删除的商品
  153. setGoodData:'', //确认订单的商品
  154. isCheckAll:false,//是否全选
  155. kindCount:0,//购物车宝贝数量
  156. allPrice:0,//所有价格
  157. totalOriginalPrice:0,//所有原价价
  158. reducedPrice:0,//满减
  159. allCount:0,//被选中的产品数量
  160. isModallayer:false,
  161. skeletonShow:true,
  162. isshowDelbtn:false,
  163. isDisabled: false, // 供应商/店铺全选是否禁用状态
  164. isEmpty:false,//显示空购物车
  165. scrollHeight: 'auto',
  166. nomoreText: '上拉显示更多',
  167. hasNextPage: false,
  168. loadding: false,
  169. pullUpOn: true,
  170. pullFlag: true,
  171. pageSize: 10,
  172. pageNum: 1,
  173. submitIds:[],
  174. modal:false,
  175. contentModalText:'',
  176. deleteType:0,
  177. }
  178. },
  179. onLoad(){
  180. this.setScrollHeight();
  181. },
  182. computed: {
  183. ...mapState(['hasLogin','userInfo'])
  184. },
  185. filters:{
  186. NumFormat(value) {//处理金额
  187. return Number(value).toFixed(2);
  188. },
  189. totalprice(val,count){//单件商品的价格 × 数量
  190. return (val * count).toFixed(2)
  191. }
  192. },
  193. methods:{
  194. initData(){
  195. this.isModallayer = false //遮罩层 防止多次点击
  196. this.isCheckAll=false//是否全选
  197. this.submitIds = []
  198. this.$api.getStorage().then((resolve) => {
  199. this.userId = resolve.userId ? resolve.userId : 0;
  200. this.InitGetCartGoodsList();
  201. })
  202. },
  203. clickPopupShow(pros,type){
  204. if(pros.ladderList.length>0){
  205. this.popupShow = true;
  206. this.handlerPros = pros;
  207. }
  208. },
  209. setScrollHeight() {
  210. // 窗口高度-footer高度
  211. const {windowHeight, pixelRatio} = uni.getSystemInfoSync();
  212. setTimeout(()=> {
  213. const query = uni.createSelectorQuery().in(this);
  214. query.selectAll('.footer').boundingClientRect();
  215. query.exec(res => {
  216. this.windowHeight = windowHeight;
  217. if(res[0][0]) {
  218. this.scrollHeight = windowHeight - res[0][0].height;
  219. }
  220. })
  221. }, 500)
  222. },
  223. InitGetCartGoodsList(){//初始化购物车 index:1
  224. this.ProductService.QueryShoppingCartList({userId:this.userId}).then(response =>{
  225. this.skeletonShow = false
  226. let data = response.data
  227. this.kindCount = data.cartQuantity
  228. if( data.shopList.length > 0 || data.products.length > 0){
  229. this.isEmpty =false
  230. }else{
  231. this.isEmpty =true
  232. }
  233. if(data.shopList && data.shopList.length > 0 ){
  234. this.goodsList = data.shopList;
  235. console.log(this.goodsList)
  236. this.totalShopPeice()
  237. } else {
  238. this.goodsList = [];
  239. }
  240. if( data.products && data.products.length > 0){
  241. this.failureList = data.products
  242. } else {
  243. this.failureList = [];
  244. }
  245. }).catch(error =>{
  246. this.$util.msg(error.msg,2000);
  247. })
  248. },
  249. ischeckFailure(failure){
  250. failure.productsChecked = !failure.productsChecked
  251. this.updateCheckAllBtn()
  252. },
  253. ischeck(item,pro){//为未选中的时候改变为true,反之为true
  254. pro.productsChecked = !pro.productsChecked;
  255. if(pro.productsChecked) {
  256. if(!this.submitIds.includes(pro.productID*1)){
  257. this.submitIds.push(pro.productID);
  258. }
  259. } else {
  260. var lent = this.submitIds.indexOf(pro.productID*1);
  261. if(lent >=0 ){
  262. this.submitIds.splice(lent, 1);
  263. }
  264. }
  265. this.updateProductCheckedAllBtn(item);
  266. this.updateCheckAllBtn();
  267. },
  268. updateProductCheckedAllBtn(item) {// 单独每个供应商的勾选判断
  269. let productList = item.productList,
  270. productsCheckedLength = 0,
  271. disabledLength = 0;
  272. if(this.isshowDelbtn) {
  273. productList.forEach(pros => {
  274. if(pros.productsChecked) {
  275. productsCheckedLength++;
  276. }
  277. })
  278. } else {
  279. productList.forEach(pros => {
  280. if(pros.productsChecked) {
  281. productsCheckedLength++;
  282. }
  283. })
  284. }
  285. item.checked = productsCheckedLength === productList.length;
  286. },
  287. updateCheckAllBtn() {// 全选勾选判断
  288. let goodsCheckedLength = 0,
  289. goodsList = this.goodsList,
  290. failureList = this.failureList;
  291. goodsList.forEach(item => {
  292. if(item.checked) {
  293. goodsCheckedLength++;
  294. }
  295. })
  296. failureList.forEach(failureItem=>{
  297. if(failureItem.productsChecked){
  298. goodsCheckedLength++;
  299. }
  300. })
  301. if(this.isshowDelbtn){
  302. this.isCheckAll = goodsCheckedLength === goodsList.length + failureList.length;
  303. }else{
  304. this.isCheckAll = goodsCheckedLength === goodsList.length;
  305. }
  306. },
  307. checkShop(item){//与单选商品类似
  308. item.checked = !item.checked;
  309. this.setProductChecked(item);
  310. this.updateCheckAllBtn();
  311. },
  312. setProductChecked(item) {
  313. item.productList.forEach(pros=>{
  314. if(item.checked) {
  315. pros.productsChecked = true;
  316. if(!this.submitIds.includes(pros.productId*1)){
  317. this.submitIds.push(pros.productId);
  318. }
  319. } else {
  320. pros.productsChecked = false;
  321. var lent = this.submitIds.indexOf(pros.productId*1);
  322. if(lent >=0 ){
  323. this.submitIds.splice(lent, 1);
  324. }
  325. }
  326. })
  327. },
  328. updateBothCheckBtn() {
  329. if(this.isshowDelbtn) {
  330. // 当管理删除按钮出现时,失效的商品可被选择
  331. this.goodsList.forEach((item)=>{
  332. item.checked = this.isCheckAll;
  333. this.setProductChecked(item);
  334. })
  335. //删除按钮 全选包括失效商品勾选
  336. this.failureList.forEach(failureItem=>{
  337. failureItem.productsChecked = this.isCheckAll;
  338. })
  339. } else {
  340. this.goodsList.forEach((item)=>{
  341. item.checked = this.isCheckAll && !item.isDisabled;
  342. this.setProductChecked(item);
  343. })
  344. }
  345. },
  346. checkAll(){//全选方法内调用方法
  347. this.isCheckAll = !this.isCheckAll;
  348. this.updateBothCheckBtn();
  349. },
  350. totalShopPeice(){//每次所属会所下的商品增减重新计算合计价格&减去含有下架的商品
  351. let touchPrice = 0;
  352. let reducedPrice = 0;//商铺合计满减价
  353. this.goodsList.map((item,index)=>{
  354. let _totalPrice = 0;
  355. let _reducedPrice = 0;
  356. let _totalOriginalPrice =0;
  357. item.productList.forEach(pros=>{
  358. let _price = pros.price*pros.productCount
  359. _totalOriginalPrice += pros.price*pros.productCount;
  360. if(pros.promotion && pros.promotion.type != 2 && pros.promotion.mode == 2){
  361. if(_price >= pros.promotion.touchPrice){
  362. _price = _price - pros.promotion.reducedPrice
  363. _reducedPrice += pros.promotion.reducedPrice
  364. }
  365. _totalPrice += _price
  366. }else{
  367. _reducedPrice = 0;
  368. _totalPrice += pros.price*pros.productCount;
  369. }
  370. })
  371. item.reducedPrice = _reducedPrice
  372. item.totalOriginalPrice = _totalOriginalPrice
  373. item.totalPrice = _totalPrice
  374. })
  375. },
  376. totalPeice(){//计算总价格,每次调用此方法,将初始值为0,遍历价格并累加
  377. let totalPrice = 0;
  378. let reducedPrice = 0;
  379. let originalPrice = 0;
  380. this.goodsList.forEach((item,index)=>{
  381. let supplierPrice = 0;
  382. let supplierReducedPrice = 0;
  383. item.totalprice = 0;
  384. item.reducedprice = 0;
  385. item.originalprice = 0;
  386. item.productList.forEach(pros=>{
  387. if(pros.productsChecked){
  388. supplierPrice += pros.price*pros.productCount;
  389. // 单品满减
  390. if(pros.promotion && pros.promotion.type*1===1 && pros.promotion.mode*1===2){
  391. // 单品满减-重新计算供应商总价/满减金额
  392. if(pros.price*pros.productCount >= pros.promotion.touchPrice){
  393. supplierPrice -= pros.promotion.reducedPrice;
  394. supplierReducedPrice += pros.promotion.reducedPrice;
  395. }
  396. }
  397. }
  398. })
  399. item.totalprice = supplierPrice;
  400. item.reducedprice = supplierReducedPrice;
  401. item.originalprice = (supplierPrice+supplierReducedPrice);
  402. totalPrice += item.totalprice;
  403. reducedPrice += item.reducedprice;
  404. originalPrice += item.originalprice;
  405. })
  406. //最后统计商品原价
  407. this.totalOriginalPrice = originalPrice;
  408. //最后满减金额 = 店铺减去金额 + 单品减去金额 + 凑单减去金额
  409. this.reducedPrice = reducedPrice;
  410. //最终合计价格 = 店铺满减合计 + 单品满减 + 正常合计 + 凑单满减
  411. this.allPrice = totalPrice ;
  412. },
  413. totalCount(){//计算总数量
  414. this.allCount = 0
  415. let prosAllCount=0
  416. let validCount = 0
  417. let validList =[];
  418. let productList =[];
  419. this.goodsList.forEach(item=>{
  420. productList = item.productList
  421. productList.forEach(pros=>{
  422. if(pros.productsChecked){
  423. prosAllCount+=parseInt(pros.productCount);
  424. this.allCount = prosAllCount
  425. }
  426. })
  427. })
  428. },
  429. changeCountAdd(item,pros){//商品数量加加
  430. pros.productCount++
  431. this.processActivityPrice(pros)
  432. this.updateShoppogNum(pros)
  433. this.totalShopPeice();
  434. },
  435. changeCountSub(item,pros){//商品数量减减
  436. if(pros.productCount<=1){
  437. pros.productCount= 1
  438. this.$util.msg(`购买数量不能少于1`,2000);
  439. return
  440. }else{
  441. pros.productCount--
  442. }
  443. this.processActivityPrice(pros)
  444. this.updateShoppogNum(pros)
  445. this.totalShopPeice();
  446. },
  447. changeInput(pros){//输入商品数量更新
  448. },
  449. changeNnmber(e,item,pros){//输入商品数量更新
  450. let _value = Number(e.detail.value);
  451. if(!this.$api.isNumber(_value)){
  452. pros.productCount = 1
  453. }else if(_value <= 1){
  454. this.$util.msg(`购买数量不能少于1`,2000);
  455. pros.productCount = 1
  456. }else{
  457. pros.productCount = e.detail.value
  458. }
  459. this.processActivityPrice(pros)
  460. this.updateShoppogNum(pros)
  461. this.totalShopPeice();
  462. },
  463. processActivityPrice(pros){//单独处理活动价格和阶梯价格
  464. if(pros.activeStatus == 1){
  465. pros.ladderList.forEach((item,index)=>{
  466. if(pros.productCount>=item.buyNum){
  467. pros.price = item.buyPrice
  468. }
  469. })
  470. }else{
  471. pros.price = pros.price
  472. }
  473. },
  474. updateShoppogNum(pros){//加减购物车商品更新到后台
  475. this.ProductService.ShoppingCartUpdate(
  476. {
  477. cartId:pros.cartId,
  478. productCount:pros.productCount,
  479. }
  480. )
  481. .then(response =>{
  482. this.isshowDelbtn = false;
  483. this.InitGetCartGoodsList();
  484. })
  485. .catch(error =>{
  486. this.$util.msg(error.msg,2000);
  487. })
  488. },
  489. toConfirmation(){//跳转确认订单页面
  490. let setGoodsList=[];
  491. this.goodsList.forEach(res=>{
  492. let products = res.productList
  493. products.forEach(pros=>{
  494. if(pros.productsChecked){
  495. setGoodsList.push(pros.productId)
  496. }
  497. })
  498. })
  499. if(setGoodsList == ''){
  500. this.$util.msg("请先选择结算商品~",2000);
  501. return
  502. }
  503. let cartIds = '';
  504. this.goodsList.forEach(el=>{//获取勾选的商品ID拼接字符串逗号隔开,最后一个逗号去掉
  505. el.productList.forEach(pros=>{
  506. if(pros.productsChecked){
  507. cartIds += pros.cartId+','
  508. }
  509. })
  510. })
  511. let cartPramsData={
  512. allPrice:this.allPrice,
  513. allCount:this.allCount,
  514. cartIds:cartIds.substring(0,cartIds.lastIndexOf(',')),
  515. productCount:''
  516. }
  517. this.$api.navigateTo(`/pages/user/order/create-order?data=${JSON.stringify({data:cartPramsData})}`)
  518. },
  519. showDelManager(){//显示删除商品管理
  520. this.isshowDelbtn = true;
  521. if(this.isCheckAll) {
  522. this.updateBothCheckBtn();
  523. } else {
  524. this.goodsList.forEach(item => {
  525. if(item.checked) {
  526. item.productList.forEach(pros => {
  527. pros.productsChecked = true;
  528. })
  529. }
  530. })
  531. this.updateCheckAllBtn();
  532. }
  533. // 失效也被勾选
  534. this.failureList.forEach(failureItem => {
  535. if(failureItem.isFailureLayer){
  536. failureItem.isFailureLayer = false
  537. }
  538. })
  539. },
  540. hideDelManage(){//隐藏删除商品管理
  541. this.isshowDelbtn = false;
  542. let isFailureLayer,newFailureList =[];
  543. if(this.isCheckAll) {
  544. this.updateBothCheckBtn();
  545. } else {
  546. // 失效商品取消勾选
  547. this.goodsList.forEach(item => {
  548. if(item.isDisabled) {
  549. item.checked = false;
  550. }
  551. item.productList.forEach(pros => {
  552. if(pros.validFlag == 3) {
  553. pros.productsChecked = false;
  554. }
  555. })
  556. })
  557. this.updateCheckAllBtn();
  558. }
  559. this.failureList.forEach((failure,index) => {
  560. if(failure.failureState == 1 || failure.failureState == 2) {
  561. isFailureLayer = true
  562. }else{
  563. isFailureLayer = false
  564. }
  565. newFailureList.push(Object.assign({},failure,{isFailureLayer:isFailureLayer}))
  566. })
  567. this.failureList = newFailureList;
  568. },
  569. deleteList(){//删除购物车商品
  570. this.delGoodsList=[];
  571. this.goodsList.forEach(delitem=>{
  572. let products = delitem.productList
  573. products.forEach(pros=>{
  574. if(pros.productsChecked){
  575. this.delGoodsList += pros.cartId+','
  576. }
  577. })
  578. })
  579. this.failureList.forEach(failure=>{
  580. if(failure.productsChecked){
  581. this.delGoodsList += failure.cartId+','
  582. }
  583. })
  584. if(this.delGoodsList.length == 0){
  585. this.$util.msg("请选择要删除的商品~",2000);
  586. return
  587. }else{
  588. this.modal = true;
  589. this.contentModalText = '确定删除选中的商品吗?';
  590. this.deleteType = 1
  591. }
  592. },
  593. deletefailureList(){
  594. this.delGoodsList = ''
  595. this.failureList.forEach(failure=>{ this.delGoodsList += failure.cartId+',' })
  596. this.modal = true;
  597. this.contentModalText = '确定清除所有失效商品吗?';
  598. this.deleteType = 2
  599. },
  600. handleClick(e) {//用户操作订单
  601. let index = e.index;
  602. if(index == 1){
  603. this.ProductService.ShoppingCartDelete(
  604. {
  605. cartIds:this.delGoodsList,
  606. }
  607. )
  608. .then(response =>{
  609. this.$util.msg('删除成功',2000);
  610. setTimeout(()=>{
  611. this.isshowDelbtn = false;
  612. this.InitGetCartGoodsList();
  613. },1000)
  614. }).catch(error =>{
  615. this.$util.msg(error.msg,2000)
  616. })
  617. }
  618. this.modal = false;
  619. },
  620. hideMobel(){
  621. this.modal = false;
  622. },
  623. navToListPage(item){
  624. this.isModallayer = true;
  625. this.$api.navigateTo(`/pages/goods/product?productId=${item.productId}`)
  626. },
  627. setHeaderBtnPosi(){
  628. // 获得胶囊按钮位置信息
  629. let headerBtnPosi = uni.getMenuButtonBoundingClientRect();
  630. return headerBtnPosi
  631. },
  632. setSysteminfo(){
  633. let systeminfo;
  634. uni.getSystemInfo({ // 获取设备信息
  635. success: (res) => {
  636. systeminfo = res
  637. },
  638. })
  639. return systeminfo
  640. },
  641. PromotionsFormat(promo){//促销活动类型数据处理
  642. if(promo!=null){
  643. if(promo.type == 1 && promo.mode == 1){
  644. return true
  645. }else{
  646. return false
  647. }
  648. }
  649. return false
  650. }
  651. },
  652. watch:{//深度监听所有数据,每次改变重新计算总价和总数
  653. goodsList:{
  654. deep:true,
  655. handler(val,oldval){
  656. this.totalPeice()
  657. this.totalCount()
  658. }
  659. }
  660. },
  661. onPullDownRefresh() {//下拉刷新
  662. this.InitGetCartGoodsList()
  663. uni.stopPullDownRefresh()
  664. },
  665. onShow(){
  666. if(this.hasLogin){
  667. this.initData()
  668. }else{
  669. this.$api.redirectTo('/pages/login/login')
  670. }
  671. },
  672. }
  673. </script>
  674. <style lang="scss">
  675. page{
  676. background: #f7f7f7;
  677. height: auto;
  678. }
  679. .cart-content{
  680. position: relative;
  681. }
  682. .container-cart-main.none{
  683. display: none;
  684. }
  685. .container-cart-main.show{
  686. display: block;
  687. }
  688. .cart-content.empty.none{
  689. display: none;
  690. }
  691. .cart-content.empty.show{
  692. display: block;
  693. }
  694. .container-cart.show{
  695. display: block;
  696. }
  697. .container-cart.none{
  698. display: none;
  699. }
  700. .empty-container.none{
  701. display: none;
  702. }
  703. .empty-container.show{
  704. display: flex;
  705. }
  706. .foot-check-delbtn{
  707. width: 100%;
  708. height: 80rpx;
  709. position: fixed;
  710. top: 0;
  711. left: 0;
  712. box-sizing: border-box;
  713. padding: 15rpx 24rpx;
  714. background-color: #F7F7F7;
  715. z-index: 990;
  716. .foot-text{
  717. font-size: $font-size-26;
  718. height: 50rpx;
  719. line-height: 50rpx;
  720. color:#666666;
  721. float: left;
  722. padding-left: 10rpx;
  723. text{
  724. margin: 0 6rpx;
  725. }
  726. }
  727. .delBtn{
  728. width: 100rpx;
  729. display: inline-block;
  730. padding: 0 15rpx;
  731. font-size: $font-size-26;
  732. height: 50rpx;
  733. line-height: 50rpx;
  734. border-radius: 30rpx;
  735. background:#FFFFFF;
  736. border: 1px solid #ff457b;
  737. color: #ff457b;
  738. float: right;
  739. text-align: center;
  740. &.none{
  741. display: none;
  742. }
  743. }
  744. }
  745. .checkbox-box{
  746. display: flex;
  747. align-items: center;
  748. .checkbox{
  749. display: flex;
  750. margin: 0;
  751. padding:0 5rpx;
  752. display: flex;
  753. flex-direction: column;
  754. align-items: center;
  755. box-sizing: border-box;
  756. text-align: center;
  757. text-decoration: none;
  758. border-radius: 0;
  759. -webkit-tap-highlight-color: transparent;
  760. overflow: hidden;
  761. background-color:#FFFFFF;
  762. font-size: 36rpx;
  763. color:#999999;
  764. &.icon-xuanze{
  765. color: $color-system;
  766. }
  767. }
  768. &.disabled{
  769. .checkbox{
  770. color:#999999
  771. }
  772. }
  773. .text{
  774. font-size: $font-size-24;
  775. margin-left: 10rpx;
  776. }
  777. }
  778. .goods-list{
  779. width: 100%;
  780. height: auto;
  781. background-color: #F7F7F7;
  782. .goods-item{
  783. width: 702rpx;
  784. padding: 0 24rpx;
  785. background: #FFFFFF;
  786. margin-bottom: 24rpx;
  787. }
  788. .shoptitle{
  789. display: flex;
  790. align-items: center;
  791. height: 80rpx;
  792. line-height: 80rpx;
  793. .checkbox-box{
  794. padding: 10rpx;
  795. }
  796. .text{
  797. width: 450rpx;
  798. display: block;
  799. overflow: hidden;
  800. text-overflow:ellipsis;
  801. white-space: nowrap;
  802. margin-left: 20rpx;
  803. font-size: $font-size-28;
  804. color: $text-color;
  805. text-align: left;
  806. font-weight: bold;
  807. }
  808. }
  809. .goods-pros{
  810. width: 100%;
  811. height: auto;
  812. margin-bottom: 20rpx;
  813. }
  814. .goods-pros-t{
  815. display: flex;
  816. align-items: center;
  817. width: 100%;
  818. height: 210rpx;
  819. padding:0 0 26rpx 0;
  820. .checkbox-box{
  821. padding: 10rpx;
  822. }
  823. .pros-img{
  824. width: 210rpx;
  825. height: 100%;
  826. border-radius: 10rpx;
  827. margin:0 20rpx;
  828. border:1px solid #f3f3f3;
  829. image{
  830. width: 100%;
  831. height: 100%;
  832. border-radius: 10rpx;
  833. }
  834. }
  835. }
  836. .goods-pros-b{
  837. width:100%;
  838. height: auto;
  839. padding:0 0 24rpx 0;
  840. box-sizing: border-box;
  841. &.show{
  842. display: block;
  843. }
  844. &.none{
  845. display: none;
  846. }
  847. .sum-none{
  848. width: 100%;
  849. height: 48rpx;
  850. line-height: 48rpx;
  851. color: $text-color;
  852. float: left;
  853. text-align: right;
  854. .money{
  855. font-size: $font-size-26;
  856. color: #999999;
  857. text-decoration: line-through;
  858. }
  859. .money-sign{
  860. font-size: $font-size-26;
  861. color: #999999;
  862. text-decoration: line-through;
  863. }
  864. .money-reduced{
  865. margin-left: 10rpx;
  866. font-size: $font-size-26;
  867. color: $color-system;
  868. .iconfont{
  869. font-size: $font-size-34;
  870. }
  871. }
  872. }
  873. .sum{
  874. width: 100%;
  875. height: 40rpx;
  876. font-size: $font-size-26;
  877. line-height: 40rpx;
  878. color: $text-color;
  879. float: left;
  880. display: flex;
  881. justify-content: flex-end;
  882. font-weight: bold;
  883. .money{
  884. color: $color-system;
  885. font-size: $font-size-26;
  886. }
  887. .money-sign{
  888. font-size: $font-size-24;
  889. color: $color-system;
  890. }
  891. }
  892. }
  893. .pros-product{
  894. width: 416rpx;
  895. height: 100%;
  896. line-height: 36rpx;
  897. font-size: $font-size-28;
  898. position: relative;
  899. .producttitle{
  900. width: 100%;
  901. display: inline-block;
  902. height: auto;
  903. text-overflow:ellipsis;
  904. display: -webkit-box;
  905. word-break: break-all;
  906. -webkit-box-orient: vertical;
  907. -webkit-line-clamp: 2;
  908. overflow: hidden;
  909. margin-bottom: 15rpx;
  910. .no-text{
  911. display: inline-block;
  912. height:36rpx;
  913. padding: 0 12rpx;
  914. line-height: 36rpx;
  915. background:linear-gradient(315deg,rgba(231,0,0,1) 0%,rgba(255,104,1,1) 100%);
  916. border-radius:18rpx;
  917. text-align: center;
  918. color: #FFFFFF;
  919. font-size:$font-size-28;
  920. margin-right: 24rpx;
  921. }
  922. }
  923. .productspec{
  924. height: 36rpx;
  925. color: #999999;
  926. font-size: $font-size-26;
  927. }
  928. .productprice{
  929. position: absolute;
  930. bottom: 0;
  931. width: 100%;
  932. height: 48rpx;
  933. margin: 30rpx 0 0 0;
  934. .price{
  935. line-height: 48rpx;
  936. font-size: $font-size-26;
  937. width: 48%;
  938. color: $color-system;
  939. float: left;
  940. font-weight: bold;
  941. &.disabled{
  942. color: #999999;
  943. text-decoration: line-through;
  944. }
  945. .money-sign{
  946. font-size: $font-size-24;
  947. color: $color-system;
  948. }
  949. }
  950. .count{
  951. height: 100%;
  952. float: right;
  953. position: relative;
  954. &.show{
  955. display: block;
  956. }
  957. &.none{
  958. display: none;
  959. }
  960. .count-tips{
  961. width: auto;
  962. display: inline-block;
  963. padding: 0 15rpx;
  964. line-height: 44rpx;
  965. height: 44rpx;
  966. border-radius: 22rpx;
  967. background: $btn-confirm;
  968. font-size: $font-size-24;
  969. text-align: center;
  970. color: #FFFFFF;
  971. position: absolute;
  972. top:-60rpx;
  973. left: -5rpx;
  974. z-index: 5;
  975. &.step{
  976. left:-217rpx
  977. }
  978. &::before{
  979. content: "";
  980. position: absolute;
  981. bottom: -30rpx;
  982. right: 15rpx;
  983. z-index:1;
  984. width: 0;
  985. height: 0;
  986. border-width: 18rpx;
  987. border-style: solid;
  988. border-color:$color-system transparent transparent transparent;
  989. }
  990. }
  991. .number-box {
  992. display: flex;
  993. justify-content: center;
  994. align-items: center;
  995. border: 2rpx solid #e1e1e1;
  996. border-radius: 30rpx;
  997. height: 48rpx;
  998. margin-left: 20rpx;
  999. .iconfont {
  1000. font-size: $font-size-24;
  1001. padding: 0 14rpx;
  1002. color: #666666;
  1003. text-align: center;
  1004. line-height: 48rpx;
  1005. font-weight: bold;
  1006. background: #ffffff;
  1007. &.icon-jianhao {
  1008. border-radius: 30rpx 0 0 30rpx;
  1009. }
  1010. &.icon-jiahao {
  1011. border-radius: 0 30rpx 30rpx 0;
  1012. }
  1013. }
  1014. .btn-input {
  1015. width: 56rpx;
  1016. height: 44rpx;
  1017. line-height: 44rpx;
  1018. border-radius: 4rpx;
  1019. text-align: center;
  1020. font-size: $font-size-24;
  1021. color: #333333;
  1022. background-color: #f7f7f7;
  1023. }
  1024. }
  1025. .uni-numbox{
  1026. position: absolute;
  1027. left: 45rpx;
  1028. bottom: 0;
  1029. .uni-numbox-minus, .uni-numbox-plus{
  1030. width: 50rpx;
  1031. line-height: 40rpx;
  1032. }
  1033. .uni-numbox-value {
  1034. font-size: $font-size-28;
  1035. width: 60rpx;
  1036. }
  1037. }
  1038. }
  1039. }
  1040. .floor-item-act{
  1041. width: 100%;
  1042. height: 30rpx;
  1043. margin-top: 8rpx;
  1044. float: left;
  1045. .tag{
  1046. display: inline-block;
  1047. height: 32rpx;
  1048. font-size: 22rpx;
  1049. line-height: 30rpx;
  1050. text-align: center;
  1051. color: #f83c6c;
  1052. float: left;
  1053. margin-right: 10rpx;
  1054. &.tag-02{
  1055. width: 80rpx;
  1056. background: url(https://static.caimei365.com/app/mini-hehe/icon/icon-active.png)top center no-repeat;
  1057. background-size: contain;
  1058. }
  1059. &.tag-01{
  1060. width: 56rpx;
  1061. color: #fff;
  1062. background-color: #f83c6c;
  1063. border-radius: 4rpx;
  1064. }
  1065. }
  1066. }
  1067. }
  1068. }
  1069. .failure-list{
  1070. width: 702rpx;
  1071. height: auto;
  1072. padding: 0 24rpx;
  1073. margin-top: 20rpx;
  1074. background: #FFFFFF;
  1075. .failure-title{
  1076. width: 100%;
  1077. height: 82rpx;
  1078. line-height: 82rpx;
  1079. font-size: $font-size-28;
  1080. border-bottom: 1px solid #EBEBEB;
  1081. .title-txt{
  1082. float: left;
  1083. color:#666666;
  1084. text-align: left;
  1085. }
  1086. .title-btn{
  1087. float: right;
  1088. color: $color-system;
  1089. text-align: right;
  1090. line-height: 80rpx;
  1091. .butto{
  1092. display: inline-block;
  1093. padding: 0 15rpx;
  1094. font-size: $font-size-26;
  1095. height: 50rpx;
  1096. line-height: 50rpx;
  1097. border-radius: 30rpx;
  1098. background:#fff8fd;
  1099. border: 1px solid #ff457b;
  1100. color: #ff457b;
  1101. margin-top: 15rpx;
  1102. }
  1103. }
  1104. }
  1105. .productlist{
  1106. padding-top: 10rpx;
  1107. .goods-pros{
  1108. width: 100%;
  1109. height: auto;
  1110. padding: 20rpx 0;
  1111. }
  1112. .goods-pros-t{
  1113. display: flex;
  1114. align-items: center;
  1115. width: 100%;
  1116. height: 210rpx;
  1117. position: relative;
  1118. .img-tip{
  1119. display: block;
  1120. width: 72rpx;
  1121. height: 36rpx;
  1122. line-height: 36rpx;
  1123. font-size: $font-size-24;
  1124. text-align: center;
  1125. color: #FFFFFF;
  1126. border-radius: 24rpx;
  1127. background:rgba(51,51,51,0.3);
  1128. // position: absolute;
  1129. // left: 0;
  1130. // top: 0;
  1131. }
  1132. .checkbox-box{
  1133. padding: 10rpx;
  1134. }
  1135. .pros-img{
  1136. width: 180rpx;
  1137. height: 100%;
  1138. border-radius: 10rpx;
  1139. margin:0 20rpx;
  1140. border:1px solid #f3f3f3;
  1141. position: relative;
  1142. image{
  1143. width: 100%;
  1144. height: 100%;
  1145. border-radius: 10rpx;
  1146. }
  1147. }
  1148. .pros-marks{
  1149. width: 730rpx; height: 250rpx;
  1150. z-index: 90;
  1151. background: rgba(0,0,0,.05);
  1152. position: absolute;
  1153. left:-20rpx;
  1154. top: -20rpx;
  1155. }
  1156. }
  1157. .goods-pros-b{
  1158. width:622rpx;
  1159. margin-left: 84rpx;
  1160. height: 40rpx;
  1161. padding:0 0 26rpx 0;
  1162. // border-top: 1px solid #EBEBEB;
  1163. &.show{
  1164. display: block;
  1165. }
  1166. &.none{
  1167. display: none;
  1168. }
  1169. .sum{
  1170. font-size: $font-size-28;
  1171. line-height: 40rpx;
  1172. color: $text-color;
  1173. display: flex;
  1174. justify-content: flex-end;
  1175. .money{
  1176. color: #FF2A2A;
  1177. font-size: $font-size-28;
  1178. }
  1179. .money-sign{
  1180. font-size: $font-size-24;
  1181. color: #FF2A2A;
  1182. }
  1183. }
  1184. }
  1185. .pros-product{
  1186. width: 402rpx;
  1187. height: 100%;
  1188. line-height: 36rpx;
  1189. font-size: $font-size-28;
  1190. position: relative;
  1191. .producttitle{
  1192. width: 100%;
  1193. display: inline-block;
  1194. height: auto;
  1195. text-overflow:ellipsis;
  1196. display: -webkit-box;
  1197. word-break: break-all;
  1198. -webkit-box-orient: vertical;
  1199. -webkit-line-clamp: 2;
  1200. overflow: hidden;
  1201. margin-bottom: 8rpx;
  1202. .no-text{
  1203. display: inline-block;
  1204. height:36rpx;
  1205. padding: 0 12rpx;
  1206. line-height: 36rpx;
  1207. background:linear-gradient(315deg,rgba(231,0,0,1) 0%,rgba(255,104,1,1) 100%);
  1208. border-radius:18rpx;
  1209. text-align: center;
  1210. color: #FFFFFF;
  1211. font-size: $font-size-28;
  1212. margin-right: 24rpx;
  1213. }
  1214. }
  1215. .productspec{
  1216. height: 36rpx;
  1217. color: #999999;
  1218. font-size: $font-size-26;
  1219. margin-top: 20rpx;
  1220. }
  1221. .productstate{
  1222. font-size: $font-size-28;
  1223. height: 44rpx;
  1224. color: #FF2A2A;
  1225. position: absolute;
  1226. bottom: 0;
  1227. left: 0;
  1228. }
  1229. }
  1230. }
  1231. }
  1232. .footer{
  1233. width: 100%;
  1234. background-color: #FFFFFF;
  1235. height: 100rpx;
  1236. position: fixed;
  1237. bottom: 0rpx;
  1238. z-index: 100;
  1239. .footer-le{
  1240. width: 520rpx;
  1241. height: 100%;
  1242. padding:10rpx 24rpx;
  1243. float: left;
  1244. box-sizing: border-box;
  1245. .foot-check{
  1246. width: 100rpx;
  1247. float: left;
  1248. line-height: 80rpx;
  1249. font-size: $font-size-24;
  1250. .checkbox{
  1251. width: 40rpx;
  1252. text-align: center;
  1253. }
  1254. .text{
  1255. width: 60rpx;
  1256. float: right;
  1257. }
  1258. }
  1259. .sum{
  1260. width: 360rpx;
  1261. height: 100%;
  1262. float: right;
  1263. box-sizing: border-box;
  1264. padding:0 10rpx;
  1265. .sum-price{
  1266. text-align: right;
  1267. width: 100%;
  1268. height: 80rpx;
  1269. line-height: 80rpx;
  1270. font-size: $font-size-30;
  1271. color: $text-color;
  1272. float: left;
  1273. font-weight: normal;
  1274. .money{
  1275. color: $color-system;
  1276. }
  1277. .money-sign{
  1278. font-size: $font-size-24;
  1279. color: $color-system;
  1280. }
  1281. }
  1282. }
  1283. }
  1284. .footer-ri{
  1285. width: 230rpx;
  1286. height: 100%;
  1287. float: right;
  1288. display: flex;
  1289. justify-content: space-between;
  1290. align-items: center;
  1291. z-index: 999;
  1292. box-sizing: border-box;
  1293. padding: 13rpx 15rpx;
  1294. &.none{
  1295. display: none;
  1296. }
  1297. .btn{
  1298. width: 200rpx;
  1299. height: 100%;
  1300. background:$btn-confirm;
  1301. font-size: $font-size-28;
  1302. line-height: 80rpx;
  1303. color: #FFFFFF;
  1304. display: flex;
  1305. border-radius: 40rpx;
  1306. justify-content: center;
  1307. align-items: center;
  1308. }
  1309. }
  1310. .footer-del{
  1311. width: 420rpx;
  1312. height: 100rpx;
  1313. position: absolute;
  1314. padding-left: 200rpx;
  1315. background: #FFFFFF;
  1316. right: 0;
  1317. top: 0;
  1318. z-index: 1000;
  1319. box-sizing: border-box;
  1320. padding: 10rpx 0;
  1321. display: flex;
  1322. &.show{
  1323. animation: showDelbtn 0s linear both;
  1324. }
  1325. &.none{
  1326. animation: hideDelbtn 0s linear both;
  1327. }
  1328. .btn{
  1329. flex: 1;
  1330. margin: 0 8rpx;
  1331. height: 100%;
  1332. line-height: 80rpx;
  1333. font-size: $font-size-28;
  1334. color: #FFFFFF;
  1335. text-align: center;
  1336. float: left;
  1337. border-radius: 40rpx;
  1338. }
  1339. .btn.btn-cancel{
  1340. background:#f7f7f7;
  1341. color: #B2B2B2;
  1342. }
  1343. .btn.btn-confirm{
  1344. background:$btn-confirm;
  1345. color: #FFFFFF;
  1346. }
  1347. @keyframes showDelbtn {
  1348. 0% {
  1349. transform: translateX(0);
  1350. }
  1351. 100% {
  1352. transform: translateX(-100%);
  1353. }
  1354. }
  1355. @keyframes hideDelbtn {
  1356. 0% {
  1357. transform: translateX(-100%);
  1358. }
  1359. 100% {
  1360. transform: translateX(0);
  1361. }
  1362. }
  1363. }
  1364. }
  1365. </style>