order_addcart.vue 41 KB

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