order_addcart.vue 45 KB

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