order_addcart.vue 46 KB

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