order_addcart.vue 45 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634
  1. <template>
  2. <view>
  3. <view class="shoppingCart copy-data">
  4. <view class="borRadius14">
  5. <view
  6. v-if="
  7. (cartList.valid.length === 0 && cartList.invalid.length === 0) ||
  8. cartList.valid.length > 0
  9. "
  10. class="nav acea-row row-between-wrapper"
  11. >
  12. <view
  13. >购物车数量
  14. <!-- <text class="num font-color">{{ cartCount }}</text></view> -->
  15. <text class="num font-color">{{ orderGoodsCount }}</text></view>
  16. <view
  17. v-if="cartList.valid.length > 0 || cartList.invalid.length > 0"
  18. class="administrate acea-row row-center-wrapper"
  19. @click="manage"
  20. >{{ footerswitch ? "管理" : "取消" }}
  21. </view>
  22. </view>
  23. </view>
  24. <view class="borRadius14 cartBox">
  25. <view
  26. v-if="cartList.valid.length > 0 || cartList.invalid.length > 0"
  27. class="pad20"
  28. >
  29. <!-- 按商家分组的商品列表 -->
  30. <view class="merchant-groups">
  31. <block v-for="(merchant, merchantIndex) in groupedCartList" :key="merchantIndex">
  32. <view class="merchant-group">
  33. <!-- 商家头部 -->
  34. <view class="merchant-header acea-row row-between-wrapper" @click="toMerchant(merchant)">
  35. <view class="merchant-info acea-row row-middle">
  36. <image class="merchant-logo" :src="merchant.logo" mode="aspectFill"></image>
  37. <text class="merchant-name">{{ merchant.name }}</text>
  38. <uni-icons type="right" size="14" color="#333333"></uni-icons>
  39. </view>
  40. </view>
  41. <!-- 商家下的商品列表 -->
  42. <view class="list">
  43. <up-checkbox-group
  44. @change="checkboxChange"
  45. shape="circle"
  46. v-model="shopCheckbox"
  47. >
  48. <block v-for="(item, index) in merchant.products" :key="index">
  49. <view class="item acea-row row-between-wrapper">
  50. <up-checkbox
  51. activeColor="#F8C008"
  52. :name="item.id"
  53. :disabled="!item.attrStatus && footerswitch"
  54. :checked="item.checked"
  55. :customStyle="{ marginRight: '10px' }"
  56. ></up-checkbox>
  57. <navigator
  58. :render-link="false"
  59. :url="'/pages/goods/goods_details/index?id=' + item.productId"
  60. hover-class="none"
  61. class="picTxt row-between-wrapper"
  62. >
  63. <view class="pictrue">
  64. <image :src="item.image"></image>
  65. </view>
  66. <view class="item-info">
  67. <view class="text">
  68. <view
  69. class="line1 namAndNum"
  70. :class="item.attrStatus ? '' : 'reColor'"
  71. >
  72. <view class="storeName line1 ">
  73. {{ item.storeName }}
  74. </view>
  75. <view v-if="item.attrStatus">
  76. <view
  77. class="carnum acea-row row-center-wrapper"
  78. v-show="item.editNum"
  79. >
  80. <view
  81. class="reduce"
  82. :class="item.numSub ? 'on' : ''"
  83. @click.stop="subCart(item.id, merchantIndex, index)"
  84. >-</view
  85. >
  86. <view class="num">{{ item.cartNum }}</view>
  87. <view
  88. class="plus"
  89. :class="item.numAdd ? 'on' : ''"
  90. @click.stop="addCart(item.id, merchantIndex, index)"
  91. >+</view
  92. >
  93. </view>
  94. <view class="carnumTag" v-show="!item.editNum" @click.stop="item.editNum = true">
  95. X{{ item.cartNum }}
  96. </view>
  97. </view>
  98. </view>
  99. <view class="attribute-box infor line1">
  100. <view class="attribute-suk" v-show="item.suk">属性:{{ item.suk }}</view>
  101. <view v-show="!item.attrStatus" class="invalid-count">数量:{{ item.cartNum }}</view>
  102. </view>
  103. <view class="money" v-if="item.attrStatus"
  104. >¥{{ item.storePrice }}</view
  105. >
  106. <view class="labor-costs line1" v-if="item.attrStatus"
  107. >
  108. <text class="tag">工费:{{ item.price }}/克</text>
  109. <text class="tag" style="margin-left: 10rpx;">附加费:{{ item.additionalAmount }}</text>
  110. </view>
  111. <!-- <view class='money' v-if="item.attrStatus">¥{{item.truePrice}}</view> -->
  112. <view
  113. class="reElection acea-row row-between-wrapper"
  114. v-else
  115. >
  116. <view class="title">请重新选择商品规格</view>
  117. <view
  118. class="reBnt cart-color acea-row row-center-wrapper"
  119. @click.stop="reElection(item)"
  120. >重选
  121. </view>
  122. </view>
  123. </view>
  124. </view>
  125. </navigator>
  126. </view>
  127. </block>
  128. </up-checkbox-group>
  129. </view>
  130. </view>
  131. </block>
  132. </view>
  133. <!-- <view class="list">-->
  134. <!-- <up-checkbox-group-->
  135. <!-- @change="checkboxChange"-->
  136. <!-- shape="circle"-->
  137. <!-- v-model="shopCheckbox"-->
  138. <!-- >-->
  139. <!-- <block v-for="(item, index) in cartList.valid" :key="index">-->
  140. <!-- <view class="item acea-row row-between-wrapper">-->
  141. <!-- <up-checkbox-->
  142. <!-- activeColor="#F8C008"-->
  143. <!-- :name="item.id"-->
  144. <!-- :disabled="!item.attrStatus && footerswitch"-->
  145. <!-- :checked="item.checked"-->
  146. <!-- :customStyle="{ marginRight: '10px' }"-->
  147. <!-- ></up-checkbox>-->
  148. <!-- <navigator-->
  149. <!-- :render-link="false"-->
  150. <!-- :url="'/pages/goods_details/index?id=' + item.productId"-->
  151. <!-- hover-class="none"-->
  152. <!-- class="picTxt row-between-wrapper"-->
  153. <!-- >-->
  154. <!-- <view class="pictrue">-->
  155. <!-- <image :src="item.image"></image>-->
  156. <!-- </view>-->
  157. <!-- <view class="item-info">-->
  158. <!-- <view class="text">-->
  159. <!-- <view-->
  160. <!-- class="line1"-->
  161. <!-- :class="item.attrStatus ? '' : 'reColor'"-->
  162. <!-- >{{ item.storeName }}-->
  163. <!-- </view>-->
  164. <!-- <view class="attribute-box infor line1">-->
  165. <!-- <view class="attribute-suk" v-show="item.suk">属性:{{ item.suk }}</view>-->
  166. <!-- <view v-show="!item.attrStatus" class="invalid-count">数量:{{ item.cartNum }}</view>-->
  167. <!-- </view>-->
  168. <!-- <view class="labor-costs line1" v-if="item.attrStatus"-->
  169. <!-- >工费:{{ item.price }}/克</view-->
  170. <!-- >-->
  171. <!-- <view class="money" v-if="item.attrStatus"-->
  172. <!-- >¥{{ item.storePrice }}</view-->
  173. <!-- >-->
  174. <!-- &lt;!&ndash; <view class='money' v-if="item.attrStatus">¥{{item.truePrice}}</view> &ndash;&gt;-->
  175. <!-- <view-->
  176. <!-- class="reElection acea-row row-between-wrapper"-->
  177. <!-- v-else-->
  178. <!-- >-->
  179. <!-- <view class="title">请重新选择商品规格</view>-->
  180. <!-- <view-->
  181. <!-- class="reBnt cart-color acea-row row-center-wrapper"-->
  182. <!-- @click.stop="reElection(item)"-->
  183. <!-- >重选-->
  184. <!-- </view>-->
  185. <!-- </view>-->
  186. <!-- </view>-->
  187. <!-- <view-->
  188. <!-- class="carnum acea-row row-center-wrapper"-->
  189. <!-- v-if="item.attrStatus"-->
  190. <!-- >-->
  191. <!-- <view-->
  192. <!-- class="reduce"-->
  193. <!-- :class="item.numSub ? 'on' : ''"-->
  194. <!-- @click.stop="subCart(index)"-->
  195. <!-- >-</view-->
  196. <!-- >-->
  197. <!-- <view class="num">{{ item.cartNum }}</view>-->
  198. <!-- <view-->
  199. <!-- class="plus"-->
  200. <!-- :class="item.numAdd ? 'on' : ''"-->
  201. <!-- @click.stop="addCart(index)"-->
  202. <!-- >+</view-->
  203. <!-- >-->
  204. <!-- </view>-->
  205. <!-- </view>-->
  206. <!-- </navigator>-->
  207. <!-- </view>-->
  208. <!-- </block>-->
  209. <!-- </up-checkbox-group>-->
  210. <!-- </view>-->
  211. <!-- cartList.valid.length===0 && cartList.invalid.length > 0 -->
  212. <view
  213. v-if="cartList.invalid.length > 0"
  214. class="invalidGoods borRadius14"
  215. >
  216. <view class="goodsNav acea-row row-between-wrapper">
  217. <view
  218. v-if="cartList.invalid.length > 1 || cartList.valid.length > 0"
  219. @click="goodsOpen"
  220. >
  221. <text
  222. class="iconfont"
  223. :class="
  224. goodsHidden == true ? 'icon-xiangxia' : 'icon-xiangshang'
  225. "
  226. ></text
  227. >失效商品
  228. </view>
  229. <view v-else> 失效商品 </view>
  230. <view class="del" @click="unsetCart"
  231. ><text class="iconfont icon-shanchu1"></text>清空</view
  232. >
  233. </view>
  234. <view class="goodsList" :hidden="goodsHidden">
  235. <block v-for="(item, index) in cartList.invalid" :key="index">
  236. <view class="item acea-row row-between-wrapper">
  237. <view class="invalid">失效</view>
  238. <view class="picTxt acea-row row-between-wrapper">
  239. <view class="pictrue">
  240. <image :src="item.image"></image>
  241. </view>
  242. <view class="text acea-row row-column-between">
  243. <view class="line1 name">{{ item.storeName }}</view>
  244. <view class="infor line1" v-if="item.suk"
  245. >属性:{{ item.suk }}</view
  246. >
  247. <view class="acea-row row-between-wrapper">
  248. <view class="end">该商品已失效</view>
  249. </view>
  250. </view>
  251. </view>
  252. </view>
  253. </block>
  254. </view>
  255. </view>
  256. <!-- <view class='loadingicon acea-row row-center-wrapper' v-if="cartList.valid.length&&!loadend">
  257. <text class='loading iconfont icon-jiazai' :hidden='loading==false'></text>{{loadTitle}}
  258. </view> -->
  259. <view
  260. class="loadingicon acea-row row-center-wrapper"
  261. v-if="cartList.invalid.length && loadend"
  262. >
  263. <text
  264. class="loading iconfont icon-jiazai"
  265. :hidden="loadingInvalid == false"
  266. ></text
  267. >{{ loadTitleInvalid }}
  268. </view>
  269. </view>
  270. <view
  271. class="noCart"
  272. v-if="
  273. cartList.valid.length == 0 &&
  274. cartList.invalid.length == 0 &&
  275. canShow
  276. "
  277. >
  278. <view class="pictrue">
  279. <image :src="HTTP_REQUEST_URL_IMG+'noCart.png'"></image>
  280. </view>
  281. <recommend :hostProduct="hostProduct"></recommend>
  282. </view>
  283. </view>
  284. </view>
  285. <view
  286. class="footer acea-row row-between-wrapper"
  287. v-if="cartList.valid.length > 0"
  288. >
  289. <view>
  290. <up-checkbox-group shape="circle" @change="checkboxAllChange" v-model="allCheckboxValue">
  291. <!-- <checkbox value="all" :checked="!!isAllSelect" /> -->
  292. <up-checkbox
  293. :name="'all'"
  294. activeColor="#F8C008"
  295. :checked="!!isAllSelect"
  296. ></up-checkbox>
  297. <text class="checkAll">全选({{ selectValue.length }})</text>
  298. </up-checkbox-group>
  299. </view>
  300. <view class="money acea-row row-middle" v-if="footerswitch == true">
  301. <text style="font-size: 24rpx;color: #333;">合计:</text>
  302. <text class="font-color">¥{{ selectCountPrice }}</text>
  303. <form @submit="subOrder" report-submit="true">
  304. <button class="placeOrder bg-color" formType="submit">
  305. 结算
  306. </button>
  307. </form>
  308. </view>
  309. <view class="button acea-row row-middle" v-else>
  310. <form @submit="subCollect" report-submit="true">
  311. <button class="bnt cart-color" formType="submit">收藏</button>
  312. </form>
  313. <form @submit="subDel" report-submit="true">
  314. <button class="bnt" formType="submit">删除</button>
  315. </form>
  316. </view>
  317. </view>
  318. <productWindow
  319. :attr="attr"
  320. :isShow="1"
  321. :iSplus="1"
  322. :iScart="1"
  323. :showPopup="showProductPopup"
  324. @closePopup="closeProductPopup"
  325. @submit="handleSubmit"
  326. @myevent="onMyEvent"
  327. @ChangeAttr="ChangeAttr"
  328. @ChangeCartNum="ChangeCartNumFn"
  329. @attrVal="attrVal"
  330. @iptCartNum="iptCartNum"
  331. id="product-window"
  332. >
  333. </productWindow>
  334. <!-- <view class="uni-p-b-96"></view> -->
  335. <!-- <view class="uni-p-b-98"></view> -->
  336. <!-- #ifdef MP -->
  337. <!-- <authorize :isAuto="isAuto" :isShowAuth="isShowAuth" @authColse="authColse"></authorize> -->
  338. <!-- #endif -->
  339. </view>
  340. </template>
  341. <script setup>
  342. import { ref, reactive, computed,watch } from "vue";
  343. import { onLoad, onShow, onReachBottom } from "@dcloudio/uni-app";
  344. import { useAppStore } from "@/stores/app.js";
  345. import {
  346. getCartList,
  347. getCartCounts,
  348. changeCartNum,
  349. cartDel,
  350. getResetCart,
  351. } from "@/api/order.js";
  352. import { getProductHot, collectAll, getProductDetail } from "@/api/store.js";
  353. import { toLogin } from "@/libs/login.js";
  354. import recommend from "@/components/recommend";
  355. import productWindow from "@/components/productWindow";
  356. import util from "@/utils/util";
  357. import { getPreOrder } from "@/libs/order";
  358. import { useToast } from "@/hooks/useToast";
  359. import { HTTP_REQUEST_URL_IMG } from "@/config/app";
  360. const appStore = useAppStore();
  361. const { Toast } = useToast();
  362. const cartCount = ref(0);
  363. const goodsHidden = ref(false);
  364. const footerswitch = ref(true);
  365. const hostProduct = ref([]);
  366. const cartList = reactive({
  367. valid: [],
  368. invalid: [],
  369. });
  370. const isAllSelect = ref(false); //全选
  371. const selectValue = ref([]); //选中的数据
  372. const selectCountPrice = ref(0.0);
  373. const isShowAuth = ref(false); //是否隐藏授权
  374. const hotScroll = ref(false);
  375. const hotPage = ref(1);
  376. const hotLimit = ref(10);
  377. const loading = ref(false);
  378. const loadend = ref(false);
  379. const page = ref(1);
  380. const limit = ref(20);
  381. const loadingInvalid = ref(false);
  382. const loadendInvalid = ref(false);
  383. const loadTitleInvalid = ref("加载更多");
  384. const pageInvalid = ref(1);
  385. const limitInvalid = ref(20);
  386. const attr = reactive({
  387. cartAttr: false,
  388. productAttr: [],
  389. productSelect: {},
  390. });
  391. const productValue = ref([]);
  392. const productInfo = ref({});
  393. const attrValue = ref("");
  394. const attrTxt = ref("请选择");
  395. const cartId = ref(0);
  396. const product_id = ref(0);
  397. const canShow = ref(false);
  398. const shopCheckbox = ref([]);
  399. const showProductPopup = ref(false);
  400. const isLogin = computed(()=>appStore.isLogin);
  401. // 添加全选的值控制
  402. const allCheckboxValue = ref([]);
  403. // 监听isAllSelect的变化,同步到allCheckboxValue
  404. watch(isAllSelect, (newVal) => {
  405. if (newVal) {
  406. allCheckboxValue.value = ['all'];
  407. } else {
  408. allCheckboxValue.value = [];
  409. }
  410. });
  411. onLoad((options) => {
  412. if (!isLogin) {
  413. toLogin();
  414. }
  415. });
  416. onShow(() => {
  417. canShow.value = false;
  418. if (isLogin) {
  419. hotPage.value = 1;
  420. hostProduct.value = [];
  421. hotScroll.value = false;
  422. loadend.value = false;
  423. page.value = 1;
  424. cartList.valid = [];
  425. getCartListFn();
  426. loadendInvalid.value = false;
  427. pageInvalid.value = 1;
  428. cartList.invalid = [];
  429. getInvalidList();
  430. footerswitch.value = true;
  431. hotScroll.value = false;
  432. hotPage.value = 1;
  433. hotLimit.value = 10;
  434. cartList.valid = [];
  435. cartList.invalid = [];
  436. // 不要重置选中状态
  437. // isAllSelect.value = false;
  438. // selectValue.value = [];
  439. // selectCountPrice.value = 0.0;
  440. cartCount.value = 0;
  441. isShowAuth.value = false;
  442. }
  443. });
  444. onReachBottom(() => {
  445. if (loadend.value) {
  446. getInvalidList();
  447. }
  448. if (
  449. cartList.valid.length == 0 &&
  450. cartList.invalid.length == 0 &&
  451. hotPage.value != 1
  452. ) {
  453. getHostProduct();
  454. }
  455. });
  456. // 计算属性:按商家分组购物车商品
  457. const groupedCartList = computed(() => {
  458. const groups = {};
  459. cartList.valid.forEach(item => {
  460. const merchant = item.sbMerchant;
  461. if (merchant && merchant.id) {
  462. const merchantId = merchant.id;
  463. if (!groups[merchantId]) {
  464. groups[merchantId] = {
  465. id: merchantId,
  466. name: merchant.merchantName || '未知商家',
  467. logo: merchant.merchantLogo || '/static/avator.png',
  468. products: []
  469. };
  470. }
  471. item.editNum = false;
  472. groups[merchantId].products.push(item);
  473. } else {
  474. // 如果没有商家信息,放到默认分组
  475. const defaultId = 'default';
  476. if (!groups[defaultId]) {
  477. groups[defaultId] = {
  478. id: defaultId,
  479. name: '其他商家',
  480. logo: '/static/avator.png',
  481. products: []
  482. };
  483. }
  484. groups[defaultId].products.push(item);
  485. }
  486. });
  487. return Object.values(groups);
  488. });
  489. const orderGoodsCount = computed(() => {
  490. // console.log('fsdfsdfsd', cartList, cartList)
  491. return cartList.valid.length + cartList.invalid.length;
  492. });
  493. // 监听购物车数据变化,重新计算选中状态
  494. watch(() => cartList.valid, (newVal) => {
  495. calculateSelectStatus();
  496. }, { deep: true });
  497. // 重新计算选中状态
  498. function calculateSelectStatus() {
  499. const validList = cartList.valid;
  500. const selectValueArr = selectValue.value;
  501. let checkedCount = 0;
  502. let totalValidCount = 0;
  503. validList.forEach(item => {
  504. if (item.attrStatus) {
  505. totalValidCount++;
  506. if (selectValueArr.includes(item.id)) {
  507. checkedCount++;
  508. }
  509. }
  510. });
  511. isAllSelect.value = totalValidCount > 0 && checkedCount === totalValidCount;
  512. switchSelect();
  513. }
  514. const closeProductPopup = () => {
  515. showProductPopup.value = false;
  516. };
  517. function authColse(e) {
  518. isShowAuth.value = e;
  519. }
  520. async function handleSubmit() {
  521. try {
  522. const productSelect = productValue.value[attrValue.value];
  523. if (attr.productAttr.length && productSelect === undefined)
  524. return Toast({
  525. title: "产品库存不足,请选择其它",
  526. });
  527. const params = {
  528. id: cartId.value,
  529. productId: product_id.value,
  530. num: attr.productSelect.cart_num,
  531. unique:
  532. attr.productSelect !== undefined
  533. ? attr.productSelect.unique
  534. : productInfo.value.id,
  535. };
  536. await getResetCart(params);
  537. attr.cartAttr = false;
  538. Toast({
  539. title: "添加购物车成功",
  540. success: () => {
  541. loadend.value = false;
  542. page.value = 1;
  543. cartList.valid = [];
  544. getCartListFn();
  545. getCartNum();
  546. },
  547. });
  548. } catch (error) {
  549. Toast({
  550. title: error,
  551. });
  552. } finally {
  553. showProductPopup.value = false;
  554. }
  555. }
  556. function onMyEvent() {
  557. attr.cartAttr = false;
  558. }
  559. function reElection(item) {
  560. showProductPopup.value = true;
  561. getGoodsDetails(item);
  562. }
  563. function getGoodsDetails(item) {
  564. console.log("item", item);
  565. uni.showLoading({
  566. title: "加载中",
  567. mask: true,
  568. });
  569. cartId.value = item.id;
  570. product_id.value = item.productId;
  571. getProductDetail(item.productId)
  572. .then((res) => {
  573. uni.hideLoading();
  574. attr.cartAttr = true;
  575. productInfo.value = res.data.productInfo;
  576. attr.productAttr = res.data.productAttr.map((item) => ({
  577. ...item,
  578. attrValues: item.attrValues.split(","),
  579. }));
  580. productValue.value = res.data.productValue;
  581. DefaultSelect();
  582. })
  583. .catch((err) => {
  584. uni.hideLoading();
  585. });
  586. }
  587. function ChangeAttr(res) {
  588. const productSelect = productValue.value[res];
  589. if (productSelect && productSelect.stock > 0) {
  590. attr.productSelect = {
  591. ...attr.productSelect,
  592. image: productSelect.image,
  593. sales: productSelect.sales,
  594. weight: productSelect.weight,
  595. price: productSelect.price,
  596. storePrice: productSelect.storePrice,
  597. stock: productSelect.stock,
  598. unique: productSelect.id,
  599. cart_num: 1,
  600. };
  601. attrValue.value = res;
  602. attrTxt.value = "已选择";
  603. } else {
  604. attr.productSelect = {
  605. ...attr.productSelect,
  606. image: productInfo.value.image,
  607. weight: productSelect.weight,
  608. price: productInfo.value.price,
  609. storePrice: productSelect.storePrice,
  610. stock: 0,
  611. unique: productInfo.value.id,
  612. cart_num: 1,
  613. };
  614. attrValue.value = "";
  615. attrTxt.value = "请选择";
  616. }
  617. }
  618. function DefaultSelect() {
  619. const productAttr = attr.productAttr;
  620. console.log("productValue", productValue);
  621. let value = [];
  622. for (let key in productValue.value) {
  623. if (productValue.value[key].stock > 0) {
  624. value = attr.productAttr.length ? key.split(",") : [];
  625. break;
  626. }
  627. }
  628. for (let i = 0; i < productAttr.length; i++) {
  629. productAttr[i].index = value[i];
  630. }
  631. let productSelect = productValue.value[value.sort().join(",")];
  632. if (productSelect && productAttr.length) {
  633. attr.productSelect.storeName = productInfo.value.storeName;
  634. attr.productSelect.image = productSelect.image;
  635. attr.productSelect.price = productSelect.price;
  636. attr.productSelect.storePrice = productSelect.storePrice;
  637. attr.productSelect.stock = productSelect.stock;
  638. attr.productSelect.unique = productSelect.id;
  639. attr.productSelect.cart_num = 1;
  640. attrValue.value = value.sort().join(",");
  641. attrTxt.value = "已选择";
  642. } else if (!productSelect && productAttr.length) {
  643. attr.productSelect.storeName = productInfo.value.storeName;
  644. attr.productSelect.image = productInfo.value.image;
  645. attr.productSelect.price = productInfo.value.price;
  646. attr.productSelect.storePrice = productSelect.storePrice;
  647. attr.productSelect.stock = 0;
  648. attr.productSelect.unique = productInfo.value.id;
  649. attr.productSelect.cart_num = 0;
  650. attrValue.value = "";
  651. attrTxt.value = "请选择";
  652. } else if (!productSelect && !productAttr.length) {
  653. attr.productSelect.storeName = productInfo.value.storeName;
  654. attr.productSelect.image = productInfo.value.image;
  655. attr.productSelect.price = productInfo.value.price;
  656. attr.productSelect.storePrice = productSelect.storePrice;
  657. attr.productSelect.stock = productInfo.value.stock;
  658. attr.productSelect.unique = productInfo.value.id || "";
  659. attr.productSelect.cart_num = 1;
  660. attrValue.value = "";
  661. attrTxt.value = "请选择";
  662. }
  663. }
  664. function attrVal(val) {
  665. attr.productAttr[val.indexw].index =
  666. attr.productAttr[val.indexw].attrValues[val.indexn];
  667. }
  668. function ChangeCartNumFn(changeValue) {
  669. let productSelect = productValue.value[attrValue.value];
  670. if (productSelect === undefined && !attr.productAttr.length)
  671. productSelect = attr.productSelect;
  672. if (productSelect === undefined) return;
  673. let stock = productSelect.stock || 0;
  674. let num = attr.productSelect;
  675. if (changeValue) {
  676. num.cart_num++;
  677. if (num.cart_num > stock) {
  678. num.cart_num = stock ? stock : 1;
  679. }
  680. } else {
  681. num.cart_num--;
  682. if (num.cart_num < 1) {
  683. num.cart_num = 1;
  684. }
  685. }
  686. }
  687. function iptCartNum(e) {
  688. attr.productSelect.cart_num = e;
  689. }
  690. function subDel(event) {
  691. const selectValueArr = selectValue.value;
  692. if (selectValueArr.length > 0)
  693. cartDel(selectValueArr).then((res) => {
  694. loadend.value = false;
  695. page.value = 1;
  696. cartList.valid = [];
  697. getCartListFn();
  698. getCartNum();
  699. });
  700. else
  701. return Toast({
  702. title: "请选择产品",
  703. });
  704. }
  705. function getSelectValueProductId() {
  706. const validList = cartList.valid;
  707. const selectValueArr = selectValue.value;
  708. let productId = [];
  709. if (selectValueArr.length > 0) {
  710. for (let index in validList) {
  711. if (inArray(validList[index].id, selectValueArr)) {
  712. productId.push(validList[index].productId);
  713. }
  714. }
  715. }
  716. return productId;
  717. }
  718. function subCollect(event) {
  719. const selectValueArr = selectValue.value;
  720. if (selectValueArr.length > 0) {
  721. const selectValueProductId = getSelectValueProductId();
  722. collectAll(selectValueProductId)
  723. .then((res) => {
  724. return Toast({
  725. title: "收藏成功",
  726. icon: "success",
  727. });
  728. })
  729. .catch((err) => {
  730. return Toast({
  731. title: err,
  732. });
  733. });
  734. } else {
  735. return Toast({
  736. title: "请选择产品",
  737. });
  738. }
  739. }
  740. function subOrder(event) {
  741. if(appStore.userInfo.merchant){
  742. uni.showToast({
  743. title:'商家用户不能下单!',
  744. icon:'none',
  745. })
  746. return ;
  747. }
  748. const selectValueArr = selectValue.value;
  749. if (selectValueArr.length > 0) {
  750. // 检查是否选择了多个商家的商品
  751. if (hasMultipleMerchants()) {
  752. return Toast({
  753. title: "只能结算同一商家的商品",
  754. });
  755. }
  756. getPreOrderFn();
  757. } else {
  758. return Toast({
  759. title: "请选择产品",
  760. });
  761. }
  762. }
  763. // 检查是否选择了多个商家的商品
  764. function hasMultipleMerchants() {
  765. const selectValueArr = selectValue.value;
  766. const validList = cartList.valid;
  767. // 获取选中的商品
  768. const selectedItems = validList.filter(item =>
  769. selectValueArr.includes(item.id) && item.attrStatus
  770. );
  771. // 提取商家ID
  772. const merchantIds = new Set();
  773. selectedItems.forEach(item => {
  774. if (item.sbMerchant && item.sbMerchant.id) {
  775. merchantIds.add(item.sbMerchant.id);
  776. } else {
  777. // 如果没有商家信息,也作为一个独立的商家
  778. merchantIds.add('default');
  779. }
  780. });
  781. return merchantIds.size > 1;
  782. }
  783. function getPreOrderFn() {
  784. const shoppingCartId = selectValue.value.map((item) => {
  785. return {
  786. shoppingCartId: Number(item),
  787. };
  788. });
  789. const params = {
  790. mallType: 0,
  791. preOrderType: "shoppingCart",
  792. orderDetails: shoppingCartId,
  793. };
  794. getPreOrder(params);
  795. }
  796. function checkboxAllChange(value) {
  797. if (value.length > 0) {
  798. // 检查全选是否会选择多个商家
  799. if (footerswitch.value && willSelectMultipleMerchants()) {
  800. Toast({
  801. title: "只能选择同一商家的商品进行结算",
  802. });
  803. // 重置全选状态为未选中
  804. isAllSelect.value = false;
  805. allCheckboxValue.value = [];
  806. // 清空shopCheckbox的值
  807. shopCheckbox.value = [];
  808. setAllSelectValue(0);
  809. return;
  810. }else{
  811. setAllSelectValue(1);
  812. }
  813. } else {
  814. setAllSelectValue(0);
  815. }
  816. }
  817. // 检查全选是否会选择多个商家
  818. function willSelectMultipleMerchants() {
  819. const validList = cartList.valid.filter(item => item.attrStatus);
  820. const merchantIds = new Set();
  821. validList.forEach(item => {
  822. if (item.sbMerchant && item.sbMerchant.id) {
  823. merchantIds.add(item.sbMerchant.id);
  824. } else {
  825. merchantIds.add('default');
  826. }
  827. });
  828. return merchantIds.size > 1;
  829. }
  830. function setAllSelectValue(status) {
  831. const valid = cartList.valid;
  832. let selectValueArr = [];
  833. valid.forEach(item => {
  834. if (status) {
  835. if (footerswitch.value) {
  836. if (item.attrStatus) {
  837. item.checked = true;
  838. selectValueArr.push(item.id);
  839. } else {
  840. item.checked = false;
  841. }
  842. } else {
  843. item.checked = true;
  844. selectValueArr.push(item.id);
  845. }
  846. } else {
  847. item.checked = false;
  848. }
  849. });
  850. cartList.valid = [...valid];
  851. selectValue.value = selectValueArr;
  852. isAllSelect.value = status === 1;
  853. console.log(isAllSelect.value)
  854. switchSelect();
  855. }
  856. function checkboxChange(value) {
  857. const valid = cartList.valid;
  858. // 更新所有商品的选中状态
  859. valid.forEach(item => {
  860. item.checked = value.includes(item.id);
  861. });
  862. cartList.valid = [...valid];
  863. selectValue.value = value;
  864. // 计算全选状态
  865. if (footerswitch.value) {
  866. // 结算模式下,只计算有效商品
  867. const validItems = valid.filter(item => item.attrStatus);
  868. isAllSelect.value = validItems.length > 0 && value.length === validItems.length;
  869. } else {
  870. // 管理模式下,计算所有商品
  871. isAllSelect.value = valid.length > 0 && value.length === valid.length;
  872. }
  873. switchSelect();
  874. }
  875. function inArray(search, array) {
  876. for (let i in array) {
  877. if (array[i] == search) {
  878. return true;
  879. }
  880. }
  881. return false;
  882. }
  883. // 选中商品的价格
  884. function switchSelect() {
  885. const validList = cartList.valid;
  886. const selectValueArr = selectValue.value;
  887. let selectCount = 0.0;
  888. console.log('switchSelect called', {
  889. validListLength: validList.length,
  890. selectValueArrLength: selectValueArr.length,
  891. selectValueArr: selectValueArr
  892. });
  893. if (selectValueArr.length < 1) {
  894. selectCountPrice.value = '0.00';
  895. } else {
  896. for (let index in validList) {
  897. if (inArray(validList[index].id, selectValueArr)) {
  898. console.log('Calculating item:', {
  899. id: validList[index].id,
  900. cartNum: validList[index].cartNum,
  901. storePrice: validList[index].storePrice,
  902. checked: validList[index].checked
  903. });
  904. const itemTotal = util.$h.Mul(validList[index].cartNum, validList[index].storePrice);
  905. selectCount = util.$h.Add(selectCount, itemTotal);
  906. }
  907. }
  908. // 保留两位小数
  909. selectCountPrice.value = selectCount.toFixed(2);
  910. }
  911. console.log('Final selectCountPrice:', selectCountPrice.value);
  912. }
  913. function iptCartNumInput(index) {
  914. const item = cartList.valid[index];
  915. if (item.cartNum) {
  916. setCartNum(item.id, item.cartNum);
  917. }
  918. switchSelect();
  919. }
  920. function blurInput(index) {
  921. const item = cartList.valid[index];
  922. if (!item.cartNum) {
  923. item.cartNum = 1;
  924. }
  925. }
  926. function subCart(cartIdVal, merchantIndex, productIndex) {
  927. const item = groupedCartList.value[merchantIndex].products[productIndex];
  928. let status = false;
  929. item.cartNum = Number(item.cartNum) - 1;
  930. if (item.cartNum < 1) status = true;
  931. if (item.cartNum <= 1) {
  932. item.cartNum = 1;
  933. item.numSub = true;
  934. } else {
  935. item.numSub = false;
  936. item.numAdd = false;
  937. }
  938. if (false == status) {
  939. setCartNum(item.id, item.cartNum, function (data) {
  940. switchSelect();
  941. getCartNum();
  942. });
  943. }
  944. }
  945. function addCart(cartIdVal, merchantIndex, productIndex) {
  946. console.log(cartIdVal)
  947. const item = groupedCartList.value[merchantIndex].products[productIndex];
  948. item.cartNum = Number(item.cartNum) + 1;
  949. if (item.cartNum >= item.stock) {
  950. item.cartNum = item.stock;
  951. item.numAdd = true;
  952. item.numSub = false;
  953. } else {
  954. item.numAdd = false;
  955. item.numSub = false;
  956. }
  957. setCartNum(item.id, item.cartNum, function (data) {
  958. // 更新UI
  959. switchSelect();
  960. getCartNum();
  961. });
  962. }
  963. function setCartNum(cartIdVal, cartNum, successCallback) {
  964. changeCartNum(cartIdVal, cartNum).then((res) => {
  965. successCallback && successCallback(res.data);
  966. });
  967. }
  968. function getCartNum() {
  969. getCartCounts(true, "sum").then((res) => {
  970. cartCount.value = res.data.count;
  971. });
  972. }
  973. function getCartData(data) {
  974. return new Promise((resolve, reject) => {
  975. getCartList(data)
  976. .then((res) => {
  977. // 加载数据后,同步选中状态
  978. const data = res.data;
  979. if (data.list && data.list.length > 0) {
  980. data.list.forEach(item => {
  981. // 如果这个商品ID在选中列表中,设置checked为true
  982. item.checked = selectValue.value.includes(item.id);
  983. });
  984. }
  985. resolve(data);
  986. })
  987. .catch(function (err) {
  988. loading.value = false;
  989. canShow.value = true;
  990. Toast({
  991. title: err,
  992. });
  993. });
  994. });
  995. }
  996. async function getCartListFn() {
  997. uni.showLoading({
  998. title: "加载中",
  999. mask: true,
  1000. });
  1001. let data = {
  1002. page: page.value,
  1003. limit: limit.value,
  1004. isValid: true,
  1005. };
  1006. getCartCounts(true, "sum").then(async (c) => {
  1007. // 获取购物车商品数量
  1008. cartCount.value = c.data.count;
  1009. // 当没有商品时,获取推荐商品
  1010. if (c.data.count === 0) getHostProduct();
  1011. for (let i = 0; i < Math.ceil(cartCount.value / limit.value); i++) {
  1012. let cartListData = await getCartData(data);
  1013. let valid = cartListData.list;
  1014. let validList = [...cartList.valid, ...valid];
  1015. let selectValueArr = [];
  1016. if (validList.length > 0) {
  1017. for (let index in validList) {
  1018. // 购物车加减状态
  1019. if (validList[index].cartNum == 1) {
  1020. validList[index].numSub = true;
  1021. } else {
  1022. validList[index].numSub = false;
  1023. }
  1024. // 库存
  1025. let stock = validList[index].stock ? validList[index].stock : 0;
  1026. // 当购物车数量大于库存时,设置购物车数量为库存
  1027. if (validList[index].cartNum == stock) {
  1028. validList[index].numAdd = true;
  1029. } else if (validList[index].cartNum == validList[index].stock) {
  1030. validList[index].numAdd = true;
  1031. } else {
  1032. validList[index].numAdd = false;
  1033. }
  1034. // attrStatus 判断商品是否有效
  1035. if (validList[index].attrStatus) {
  1036. // 关键修改:根据 selectValue 中的ID来设置选中状态
  1037. if (selectValue.value.includes(validList[index].id)) {
  1038. validList[index].checked = true;
  1039. selectValueArr.push(validList[index].id);
  1040. } else {
  1041. validList[index].checked = false;
  1042. }
  1043. } else {
  1044. validList[index].checked = false;
  1045. }
  1046. }
  1047. }
  1048. cartList.valid = validList;
  1049. data.page += 1;
  1050. // 不要重置 selectValue,保持原来的选中状态
  1051. // selectValue.value = selectValueArr;
  1052. let newArr = validList.filter((item) => item.attrStatus);
  1053. // 全选状态
  1054. isAllSelect.value = newArr.length > 0 && selectValue.value.length === newArr.length;
  1055. switchSelect();
  1056. }
  1057. loading.value = false;
  1058. canShow.value = true;
  1059. uni.hideLoading();
  1060. });
  1061. }
  1062. function getInvalidList() {
  1063. if (loadendInvalid.value) return false;
  1064. if (loadingInvalid.value) return false;
  1065. let data = {
  1066. page: pageInvalid.value,
  1067. limit: limitInvalid.value,
  1068. isValid: false,
  1069. };
  1070. getCartList(data)
  1071. .then((res) => {
  1072. let invalid = res.data.list,
  1073. loadendInvalidFlag = invalid.length < limitInvalid.value;
  1074. cartList.invalid = [...invalid, ...cartList.invalid];
  1075. loadendInvalid.value = loadendInvalidFlag;
  1076. loadTitleInvalid.value = loadendInvalidFlag
  1077. ? "我也是有底线的"
  1078. : "加载更多";
  1079. pageInvalid.value = pageInvalid.value + 1;
  1080. loadingInvalid.value = false;
  1081. })
  1082. .catch((res) => {
  1083. loadingInvalid.value = false;
  1084. loadTitleInvalid.value = "加载更多";
  1085. });
  1086. }
  1087. function getHostProduct() {
  1088. if (hotScroll.value) return;
  1089. getProductHot(hotPage.value, hotLimit.value).then((res) => {
  1090. hotPage.value++;
  1091. hotScroll.value = res.data.list.length < hotLimit.value;
  1092. hostProduct.value = hostProduct.value.concat(res.data.list);
  1093. });
  1094. }
  1095. function goodsOpen() {
  1096. goodsHidden.value = !goodsHidden.value;
  1097. }
  1098. function manage() {
  1099. footerswitch.value = !footerswitch.value;
  1100. let arr1 = [];
  1101. let arr2 = [];
  1102. let newValid = cartList.valid.map((item) => {
  1103. if (footerswitch.value) {
  1104. if (item.attrStatus) {
  1105. if (item.checked) {
  1106. arr1.push(item.id);
  1107. }
  1108. } else {
  1109. item.checked = false;
  1110. arr2.push(item);
  1111. }
  1112. } else {
  1113. if (item.checked) {
  1114. arr1.push(item.id);
  1115. }
  1116. }
  1117. return item;
  1118. });
  1119. cartList.valid = newValid;
  1120. if (footerswitch.value) {
  1121. isAllSelect.value = newValid.length === arr1.length + arr2.length;
  1122. } else {
  1123. isAllSelect.value = newValid.length === arr1.length;
  1124. }
  1125. selectValue.value = arr1;
  1126. switchSelect();
  1127. }
  1128. function unsetCart() {
  1129. let ids = [];
  1130. for (let i = 0, len = cartList.invalid.length; i < len; i++) {
  1131. ids.push(cartList.invalid[i].id);
  1132. }
  1133. cartDel(ids)
  1134. .then((res) => {
  1135. Toast({
  1136. title: "清除成功",
  1137. });
  1138. cartList.invalid = [];
  1139. getHostProduct();
  1140. })
  1141. .catch((res) => {});
  1142. }
  1143. const toMerchant = (obj) => {
  1144. uni.navigateTo({ url:"/pages/merchantCenters/merchant?merchantId="+obj.id });
  1145. }
  1146. </script>
  1147. <style scoped lang="scss">
  1148. .cartBox {
  1149. margin-top: 20rpx;
  1150. }
  1151. .shoppingCart {
  1152. // .labelNav
  1153. .labelNav {
  1154. position: sticky;
  1155. height: 178rpx;
  1156. padding: 30rpx 30rpx 0 30rpx;
  1157. font-size: 22rpx;
  1158. color: #fff;
  1159. position: fixed;
  1160. left: 0;
  1161. width: 100%;
  1162. box-sizing: border-box;
  1163. background-color: $theme-color;
  1164. z-index: 5;
  1165. top: 0;
  1166. height: calc(178rpx + 44px + 45rpx);
  1167. padding-top: calc(44px + 50rpx);
  1168. .item {
  1169. .iconfont {
  1170. font-size: 25rpx;
  1171. margin-right: 10rpx;
  1172. }
  1173. }
  1174. }
  1175. // .nav
  1176. .nav {
  1177. height: 90rpx;
  1178. background-color: #fff;
  1179. padding: 0 24rpx;
  1180. box-sizing: border-box;
  1181. font-size: 28rpx;
  1182. color: #282828;
  1183. border-top-left-radius: 14rpx;
  1184. border-top-right-radius: 14rpx;
  1185. .num {
  1186. margin-left: 12rpx;
  1187. }
  1188. .administrate {
  1189. font-size: 28rpx;
  1190. color: #333;
  1191. }
  1192. }
  1193. // .noCart
  1194. .noCart {
  1195. background-color: #fff;
  1196. padding-top: 0.1rpx;
  1197. .pictrue {
  1198. width: 414rpx;
  1199. height: 336rpx;
  1200. margin: 78rpx auto 56rpx auto;
  1201. image {
  1202. width: 100%;
  1203. height: 100%;
  1204. }
  1205. }
  1206. }
  1207. // .list
  1208. .list {
  1209. width: 100%;
  1210. overflow: hidden;
  1211. border-bottom-left-radius: 14rpx;
  1212. border-bottom-right-radius: 14rpx;
  1213. .item {
  1214. width: 100%;
  1215. padding: 24rpx;
  1216. background-color: #fff;
  1217. display: flex;
  1218. .picTxt {
  1219. flex: 1;
  1220. position: relative;
  1221. display: flex;
  1222. align-items: center;
  1223. .pictrue {
  1224. width: 160rpx;
  1225. height: 160rpx;
  1226. margin-right: 15rpx;
  1227. image {
  1228. width: 100%;
  1229. height: 100%;
  1230. border-radius: 6rpx;
  1231. }
  1232. }
  1233. .item-info,
  1234. .text {
  1235. width: 402rpx;
  1236. font-size: 28rpx;
  1237. color: #282828;
  1238. .storeName{
  1239. width: 40%;
  1240. }
  1241. .reColor {
  1242. color: #999;
  1243. }
  1244. .reElection {
  1245. margin-top: 20rpx;
  1246. .title {
  1247. font-size: 24rpx;
  1248. }
  1249. .reBnt {
  1250. width: 120rpx;
  1251. height: 46rpx;
  1252. border-radius: 23rpx;
  1253. font-size: 26rpx;
  1254. }
  1255. }
  1256. .attribute-box {
  1257. display: flex;
  1258. justify-content: space-between;
  1259. .attribute-suk {
  1260. }
  1261. .invalid-count {
  1262. text-align: right;
  1263. }
  1264. }
  1265. .infor {
  1266. font-size: 24rpx;
  1267. color: #999;
  1268. //margin-top: 10rpx;
  1269. }
  1270. .labor-costs {
  1271. font-size: 24rpx;
  1272. color: #FD5F3C;
  1273. margin-top: 10rpx;
  1274. .tag{
  1275. padding: 10rpx 16rpx;
  1276. background-color: #FFEFEC;
  1277. border-radius: 8rpx;
  1278. display: inline-block;
  1279. }
  1280. }
  1281. .money {
  1282. font-size: 32rpx;
  1283. color: #e93323;
  1284. margin-top: 20rpx;
  1285. font-weight: 600;
  1286. }
  1287. }
  1288. .carnum {
  1289. height: 47rpx;
  1290. //position: absolute;
  1291. //bottom: 7rpx;
  1292. //right: 0;
  1293. view {
  1294. border: 1rpx solid #a4a4a4;
  1295. width: 66rpx;
  1296. text-align: center;
  1297. height: 100%;
  1298. line-height: 44rpx;
  1299. font-size: 28rpx;
  1300. color: #a4a4a4;
  1301. }
  1302. .reduce {
  1303. border-right: 0;
  1304. border-radius: 22rpx 0 0 22rpx;
  1305. font-size: 34rpx;
  1306. line-height: 40rpx;
  1307. &.on {
  1308. border-color: #e3e3e3;
  1309. color: #dedede;
  1310. }
  1311. }
  1312. .plus {
  1313. border-left: 0;
  1314. border-radius: 0 22rpx 22rpx 0;
  1315. font-size: 34rpx;
  1316. line-height: 40rpx;
  1317. }
  1318. .num {
  1319. color: #282828;
  1320. }
  1321. }
  1322. }
  1323. }
  1324. }
  1325. // .invalidGoods
  1326. .invalidGoods {
  1327. background-color: #fff;
  1328. margin-top: 30rpx;
  1329. .goodsNav {
  1330. width: 100%;
  1331. height: 90rpx;
  1332. padding: 0 24rpx;
  1333. box-sizing: border-box;
  1334. font-size: 28rpx;
  1335. color: #333;
  1336. .iconfont {
  1337. color: #424242;
  1338. font-size: 28rpx;
  1339. margin-right: 17rpx;
  1340. }
  1341. .del {
  1342. font-size: 26rpx;
  1343. color: #333;
  1344. .icon-shanchu1 {
  1345. color: #333;
  1346. font-size: 33rpx;
  1347. vertical-align: -2rpx;
  1348. margin-right: 8rpx;
  1349. }
  1350. }
  1351. }
  1352. .goodsList {
  1353. .item {
  1354. padding: 24rpx;
  1355. .invalid {
  1356. font-size: 22rpx;
  1357. color: #ccc;
  1358. height: 36rpx;
  1359. border-radius: 3rpx;
  1360. text-align: center;
  1361. line-height: 36rpx;
  1362. }
  1363. .picTxt {
  1364. width: 576rpx;
  1365. .pictrue {
  1366. width: 160rpx;
  1367. height: 160rpx;
  1368. image {
  1369. width: 100%;
  1370. height: 100%;
  1371. border-radius: 6rpx;
  1372. }
  1373. }
  1374. .text {
  1375. width: 396rpx;
  1376. font-size: 28rpx;
  1377. color: #999;
  1378. height: 140rpx;
  1379. .name {
  1380. width: 100%;
  1381. }
  1382. .infor {
  1383. font-size: 24rpx;
  1384. }
  1385. .end {
  1386. font-size: 26rpx;
  1387. color: #bbb;
  1388. }
  1389. }
  1390. }
  1391. }
  1392. }
  1393. }
  1394. }
  1395. // footer
  1396. .footer {
  1397. z-index: 9;
  1398. width: 100%;
  1399. height: 132rpx;
  1400. background-color: #fff;
  1401. position: fixed;
  1402. padding: 0 24rpx;
  1403. box-sizing: border-box;
  1404. border-top: 1rpx solid #eee;
  1405. bottom: 0;
  1406. .checkAll {
  1407. font-size: 28rpx;
  1408. line-height: 56rpx;
  1409. color: #333333;
  1410. margin-left: 14rpx;
  1411. }
  1412. .money {
  1413. font-size: 30rpx;
  1414. .font-color {
  1415. font-weight: 600;
  1416. }
  1417. }
  1418. .placeOrder {
  1419. color: #333;
  1420. font-size: 32rpx;
  1421. width: 192rpx;
  1422. height: 88rpx;
  1423. border-radius: 16rpx;
  1424. text-align: center;
  1425. line-height: 88rpx;
  1426. margin-left: 22rpx;
  1427. }
  1428. .button {
  1429. .bnt {
  1430. font-size: 28rpx;
  1431. color: #999;
  1432. border-radius: 50rpx;
  1433. border: 1px solid #999;
  1434. width: 160rpx;
  1435. height: 60rpx;
  1436. text-align: center;
  1437. line-height: 60rpx;
  1438. }
  1439. form ~ form {
  1440. margin-left: 17rpx;
  1441. }
  1442. }
  1443. }
  1444. // 其它样式
  1445. .invalidClas {
  1446. position: relative;
  1447. z-index: 111;
  1448. top: -120rpx;
  1449. }
  1450. .invalidClasNO {
  1451. position: static;
  1452. margin-top: 15px;
  1453. }
  1454. .uni-p-b-96 {
  1455. height: 96rpx;
  1456. }
  1457. .merchant-groups {
  1458. margin-bottom: 20rpx;
  1459. }
  1460. .merchant-group {
  1461. background: #fff;
  1462. border-radius: 16rpx;
  1463. margin-bottom: 20rpx;
  1464. overflow: hidden;
  1465. .merchant-header {
  1466. padding: 24rpx;
  1467. .merchant-info {
  1468. .merchant-logo {
  1469. width: 40rpx;
  1470. height: 40rpx;
  1471. border-radius: 50%;
  1472. margin-right: 20rpx;
  1473. }
  1474. .merchant-name {
  1475. font-size: 24rpx;
  1476. color: #333;
  1477. }
  1478. }
  1479. .merchant-action {
  1480. display: flex;
  1481. align-items: center;
  1482. color: #999;
  1483. font-size: 24rpx;
  1484. text {
  1485. margin-right: 8rpx;
  1486. }
  1487. }
  1488. }
  1489. .merchant-products {
  1490. padding: 0 24rpx;
  1491. }
  1492. }
  1493. // 调整商品项样式以适应分组布局
  1494. .item {
  1495. padding: 24rpx 0;
  1496. border-bottom: 1rpx solid #f5f5f5;
  1497. &:last-child {
  1498. border-bottom: none;
  1499. }
  1500. }
  1501. // 其他原有样式保持不变
  1502. .cartBox {
  1503. margin-top: 20rpx;
  1504. }
  1505. .namAndNum{
  1506. display: flex;
  1507. align-items: center;
  1508. justify-content: space-between;
  1509. }
  1510. .carnumTag{
  1511. font-size: 24rpx;
  1512. color: #666666;
  1513. background: #F1F3F8;
  1514. border-radius: 8rpx;
  1515. padding: 10rpx 16rpx;
  1516. }
  1517. </style>