cart.vue 36 KB

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