cart.vue 34 KB

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