cart.vue 34 KB

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