cart.vue 36 KB

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