cart.vue 36 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289
  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-yixuanze':'icon-weixuanze']"></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-yixuanze':'icon-weixuanze']"></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-yixuanze':'icon-weixuanze']"></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: #666666;
  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 #E15616;
  799. color: $color-system;
  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. &.icon-yixuanze{
  827. color: #b2b2b2;
  828. }
  829. }
  830. &.disabled{
  831. .checkbox{
  832. color:#999999
  833. }
  834. }
  835. .text{
  836. font-size: $font-size-24;
  837. margin-left: 10rpx;
  838. }
  839. }
  840. .goods-list{
  841. width: 100%;
  842. height: auto;
  843. border-top: 1px solid #EBEBEB;
  844. background-color: #F7F7F7;
  845. .goods-item{
  846. width: 702rpx;
  847. padding: 0 24rpx;
  848. background: #FFFFFF;
  849. margin-bottom: 24rpx;
  850. }
  851. .shoptitle{
  852. display: flex;
  853. align-items: center;
  854. height: 80rpx;
  855. line-height: 80rpx;
  856. .checkbox-box{
  857. padding: 10rpx;
  858. }
  859. .text{
  860. width: 450rpx;
  861. display: block;
  862. overflow: hidden;
  863. text-overflow:ellipsis;
  864. white-space: nowrap;
  865. margin-left: 20rpx;
  866. font-size: $font-size-28;
  867. color: $text-color;
  868. text-align: left;
  869. font-weight: bold;
  870. }
  871. .floor-item-act{
  872. height: 56rpx;
  873. text-align: center;
  874. box-sizing: border-box;
  875. float: left;
  876. padding:10rpx 0;
  877. margin-left: 20rpx;
  878. .floor-tags{
  879. float: right;
  880. height: 36rpx;
  881. border-radius: 4rpx;
  882. background-color: rgba(225, 86, 22, 0.1);
  883. line-height: 36rpx;
  884. color: $color-system;
  885. text-align: center;
  886. display: inline-block;
  887. padding:0 16rpx;
  888. font-size: $font-size-20;
  889. }
  890. }
  891. }
  892. .goods-pros{
  893. width: 100%;
  894. height: auto;
  895. }
  896. .goods-pros-t{
  897. display: flex;
  898. align-items: center;
  899. width: 100%;
  900. height: auto;
  901. padding:0 0 20rpx 0;
  902. .checkbox-box{
  903. padding: 10rpx;
  904. }
  905. .pros-img{
  906. width: 210rpx;
  907. height: 210rpx;
  908. border-radius: 10rpx;
  909. margin:0 20rpx;
  910. border:1px solid #f3f3f3;
  911. image{
  912. width: 210rpx;
  913. height: 210rpx;
  914. border-radius: 10rpx;
  915. }
  916. }
  917. }
  918. .goods-pros-b{
  919. width:100%;
  920. height: auto;
  921. padding:0 0 24rpx 0;
  922. box-sizing: border-box;
  923. &.show{
  924. display: block;
  925. }
  926. &.none{
  927. display: none;
  928. }
  929. .sum-none{
  930. width: 100%;
  931. height: 48rpx;
  932. line-height: 48rpx;
  933. color: $text-color;
  934. float: left;
  935. text-align: right;
  936. .money{
  937. font-size: $font-size-26;
  938. color: #999999;
  939. text-decoration: line-through;
  940. }
  941. .money-sign{
  942. font-size: $font-size-26;
  943. color: #999999;
  944. text-decoration: line-through;
  945. }
  946. .money-reduced{
  947. margin-left: 10rpx;
  948. font-size: $font-size-26;
  949. color: $color-system;
  950. .iconfont{
  951. font-size: $font-size-34;
  952. }
  953. }
  954. }
  955. .sum{
  956. width: 100%;
  957. height: 40rpx;
  958. font-size: $font-size-28;
  959. line-height: 40rpx;
  960. color: $text-color;
  961. float: left;
  962. display: flex;
  963. justify-content: flex-end;
  964. .money{
  965. color: #FF2A2A;
  966. font-size: $font-size-28;
  967. }
  968. .money-sign{
  969. font-size: $font-size-24;
  970. color: #FF2A2A;
  971. }
  972. }
  973. }
  974. .pros-product{
  975. width: 386rpx;
  976. height: 100%;
  977. line-height: 36rpx;
  978. font-size: $font-size-26;
  979. position: relative;
  980. .producttitle{
  981. width: 100%;
  982. display: inline-block;
  983. height: auto;
  984. text-overflow:ellipsis;
  985. display: -webkit-box;
  986. word-break: break-all;
  987. -webkit-box-orient: vertical;
  988. -webkit-line-clamp: 2;
  989. overflow: hidden;
  990. margin-bottom: 8rpx;
  991. .no-text{
  992. display: inline-block;
  993. height:36rpx;
  994. padding: 0 12rpx;
  995. line-height: 36rpx;
  996. background:linear-gradient(315deg,rgba(231,0,0,1) 0%,rgba(255,104,1,1) 100%);
  997. border-radius:18rpx;
  998. text-align: center;
  999. color: #FFFFFF;
  1000. font-size: $font-size-24;
  1001. margin-right: 24rpx;
  1002. }
  1003. }
  1004. .productspec{
  1005. height: 36rpx;
  1006. color: #999999;
  1007. text-overflow:ellipsis;
  1008. display: -webkit-box;
  1009. word-break: break-all;
  1010. -webkit-box-orient: vertical;
  1011. -webkit-line-clamp: 2;
  1012. overflow: hidden;
  1013. margin-top: 10rpX;
  1014. }
  1015. .productCode{
  1016. color: #666666;
  1017. }
  1018. .productprice{
  1019. width: 100%;
  1020. height: 48rpx;
  1021. margin: 10rpx 0 0 0;
  1022. .price{
  1023. line-height: 48rpx;
  1024. font-size: $font-size-28;
  1025. width: 48%;
  1026. color: #FF2A2A;
  1027. float: left;
  1028. &.disabled{
  1029. color: #999999;
  1030. text-decoration: line-through;
  1031. }
  1032. .money-sign{
  1033. font-size: $font-size-24;
  1034. color: #FF2A2A;
  1035. }
  1036. }
  1037. .count{
  1038. height: 100%;
  1039. float: right;
  1040. position: relative;
  1041. &.show{
  1042. display: block;
  1043. }
  1044. &.none{
  1045. display: none;
  1046. }
  1047. .count-tips{
  1048. width: auto;
  1049. display: inline-block;
  1050. padding: 0 15rpx;
  1051. line-height: 44rpx;
  1052. height: 44rpx;
  1053. border-radius: 22rpx;
  1054. background: $btn-confirm;
  1055. font-size: $font-size-24;
  1056. text-align: center;
  1057. color: #FFFFFF;
  1058. position: absolute;
  1059. top:-60rpx;
  1060. left: -5rpx;
  1061. z-index: 5;
  1062. &.step{
  1063. left:-217rpx
  1064. }
  1065. &::before{
  1066. content: "";
  1067. position: absolute;
  1068. bottom: -30rpx;
  1069. right: 15rpx;
  1070. z-index:1;
  1071. width: 0;
  1072. height: 0;
  1073. border-width: 18rpx;
  1074. border-style: solid;
  1075. border-color:$color-system transparent transparent transparent;
  1076. }
  1077. }
  1078. .number-box{
  1079. display: flex;
  1080. justify-content: center;
  1081. align-items: center;
  1082. .iconfont{
  1083. font-size: $font-size-24;
  1084. padding:0 20rpx;
  1085. color: $text-color;
  1086. text-align: center;
  1087. line-height: 48rpx;
  1088. font-weight: bold;
  1089. }
  1090. .btn-input{
  1091. width: 62rpx;
  1092. height: 48rpx;
  1093. line-height: 48rpx;
  1094. background: #F8F8F8;
  1095. border-radius: 4rpx;
  1096. text-align: center;
  1097. font-size: $font-size-24;
  1098. }
  1099. }
  1100. .uni-numbox{
  1101. position: absolute;
  1102. left: 45rpx;
  1103. bottom: 0;
  1104. .uni-numbox-minus, .uni-numbox-plus{
  1105. width: 50rpx;
  1106. line-height: 40rpx;
  1107. }
  1108. .uni-numbox-value {
  1109. font-size: $font-size-28;
  1110. width: 60rpx;
  1111. }
  1112. }
  1113. }
  1114. }
  1115. .floor-item-act{
  1116. width: 100%;
  1117. height: 56rpx;
  1118. text-align: center;
  1119. box-sizing: border-box;
  1120. float: left;
  1121. padding:0 0 10rpx 0;
  1122. margin-left: 10rpx;
  1123. .floor-tags{
  1124. float: left;
  1125. height: 36rpx;
  1126. border-radius: 4rpx;
  1127. background-color: rgba(225, 86, 22, 0.1);
  1128. line-height: 36rpx;
  1129. color: $color-system;
  1130. text-align: center;
  1131. display: inline-block;
  1132. padding:0 16rpx;
  1133. font-size: $font-size-20;
  1134. }
  1135. }
  1136. }
  1137. }
  1138. .footer{
  1139. width: 100%;
  1140. background-color: #FFFFFF;
  1141. height: 110rpx;
  1142. position: fixed;
  1143. bottom: 0rpx;
  1144. z-index: 100;
  1145. .footer-le{
  1146. width: 520rpx;
  1147. height: 100%;
  1148. padding:0 24rpx;
  1149. float: left;
  1150. .foot-check{
  1151. width: 100rpx;
  1152. float: left;
  1153. line-height: 110rpx;
  1154. font-size: $font-size-24;
  1155. .checkbox{
  1156. width: 40rpx;
  1157. text-align: center;
  1158. }
  1159. .text{
  1160. width: 60rpx;
  1161. float: right;
  1162. }
  1163. }
  1164. .sum{
  1165. width: 380rpx;
  1166. height: 110rpx;
  1167. float: right;
  1168. box-sizing: border-box;
  1169. padding: 10rpx;
  1170. .sum-none{
  1171. width: 100%;
  1172. height: 45rpx;
  1173. line-height: 45rpx;
  1174. color: $text-color;
  1175. float: left;
  1176. text-align: right;
  1177. .money{
  1178. font-size: $font-size-24;
  1179. color: #999999;
  1180. text-decoration: line-through;
  1181. }
  1182. .money-sign{
  1183. font-size: $font-size-24;
  1184. color: #999999;
  1185. text-decoration: line-through;
  1186. }
  1187. .money-reduced{
  1188. margin-left: 10rpx;
  1189. font-size: $font-size-24;
  1190. color: $color-system;
  1191. }
  1192. }
  1193. .sum-price{
  1194. text-align: right;
  1195. width: 100%;
  1196. height: 45rpx;
  1197. line-height: 45rpx;
  1198. font-size: $font-size-30;
  1199. color: $text-color;
  1200. float: left;
  1201. font-weight: normal;
  1202. &.none{
  1203. height: 90rpx;
  1204. line-height: 90rpx;
  1205. }
  1206. .money{
  1207. color: #FF2A2A;
  1208. }
  1209. .money-sign{
  1210. font-size: $font-size-24;
  1211. color: #FF2A2A;
  1212. }
  1213. }
  1214. }
  1215. }
  1216. .footer-ri{
  1217. width: 180rpx;
  1218. height: 100%;
  1219. background:linear-gradient(135deg,rgba(242,143,49,1) 0%,rgba(225,86,22,1) 100%);
  1220. float: right;
  1221. display: flex;
  1222. justify-content: space-between;
  1223. align-items: center;
  1224. z-index: 999;
  1225. &.none{
  1226. display: none;
  1227. }
  1228. .btn{
  1229. width: 200rpx;
  1230. height: 100%;
  1231. font-size: $font-size-28;
  1232. line-height: 110rpx;
  1233. color: #FFFFFF;
  1234. display: flex;
  1235. justify-content: center;
  1236. align-items: center;
  1237. }
  1238. }
  1239. .footer-del{
  1240. width: 400rpx;
  1241. height: 110rpx;
  1242. position: absolute;
  1243. padding-left: 200rpx;
  1244. background: #FFFFFF;
  1245. right: 0;
  1246. top: 0;
  1247. z-index: 1000;
  1248. &.show{
  1249. animation: showDelbtn 0s linear both;
  1250. }
  1251. &.none{
  1252. animation: hideDelbtn 0s linear both;
  1253. }
  1254. .btn{
  1255. width: 50%;
  1256. height: 100%;
  1257. line-height: 110rpx;
  1258. font-size: $font-size-28;
  1259. color: #FFFFFF;
  1260. text-align: center;
  1261. float: left;
  1262. }
  1263. .btn.btn-cancel{
  1264. background:#EEC1AB;
  1265. }
  1266. .btn.btn-confirm{
  1267. background:#FF2A2A;
  1268. }
  1269. @keyframes showDelbtn {
  1270. 0% {
  1271. transform: translateX(0);
  1272. }
  1273. 100% {
  1274. transform: translateX(-100%);
  1275. }
  1276. }
  1277. @keyframes hideDelbtn {
  1278. 0% {
  1279. transform: translateX(-100%);
  1280. }
  1281. 100% {
  1282. transform: translateX(0);
  1283. }
  1284. }
  1285. }
  1286. }
  1287. </style>