order_addcart.vue 47 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722
  1. <template>
  2. <!-- <view style="min-height: 100%;">-->
  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,onPullDownRefresh } 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. canShow.value = false;
  419. if (isLogin.value) {
  420. resetAllState();
  421. Promise.allSettled([
  422. getCartListFn(),
  423. getInvalidList(),
  424. getHostProduct()
  425. ]).finally(() => {
  426. // 添加一个短暂延迟,确保 DOM 更新完成
  427. setTimeout(() => {
  428. canShow.value = true;
  429. uni.hideLoading();
  430. }, 50);
  431. });
  432. }
  433. });
  434. onShow(() => {
  435. console.log('appStore.cartRefreshFlag',appStore.cartRefreshFlag)
  436. // 隐藏原生 tabBar
  437. uni.hideTabBar();
  438. if(appStore.cartRefreshFlag){
  439. refresh();
  440. appStore.SET_CART_REFRESH(false)
  441. }
  442. });
  443. onPullDownRefresh(async () => {
  444. refresh()
  445. })
  446. const refresh = ()=>{
  447. canShow.value = false;
  448. if (isLogin.value) {
  449. // 重置所有状态
  450. resetAllState();
  451. Promise.allSettled([
  452. getCartListFn(),
  453. getInvalidList(),
  454. getHostProduct()
  455. ]).finally(() => {
  456. // 添加一个短暂延迟,确保 DOM 更新完成
  457. setTimeout(() => {
  458. canShow.value = true;
  459. try {
  460. uni.stopPullDownRefresh();
  461. } catch (error) {
  462. //TODO handle the exception
  463. }
  464. uni.hideLoading();
  465. }, 50);
  466. });
  467. }
  468. }
  469. function resetAllState() {
  470. footerswitch.value = true;
  471. goodsHidden.value = false;
  472. hotScroll.value = false;
  473. hotPage.value = 1;
  474. page.value = 1;
  475. pageInvalid.value = 1;
  476. // 不直接清空数组,而是先保留引用
  477. // 避免立即触发响应式更新
  478. isAllSelect.value = false;
  479. selectValue.value = [];
  480. selectCountPrice.value = 0.0;
  481. shopCheckbox.value = [];
  482. loading.value = false;
  483. loadend.value = false;
  484. loadendInvalid.value = false;
  485. loadingInvalid.value = false;
  486. loadTitleInvalid.value = "加载更多";
  487. // 先重置购物车数据
  488. // 使用 Object.assign 保持响应式
  489. Object.assign(cartList, {
  490. valid: [],
  491. invalid: [],
  492. });
  493. // 清空推荐商品
  494. hostProduct.value = [];
  495. }
  496. onReachBottom(() => {
  497. if (loadend.value) {
  498. getInvalidList();
  499. }
  500. if (
  501. cartList.valid.length == 0 &&
  502. cartList.invalid.length == 0 &&
  503. hotPage.value != 1
  504. ) {
  505. getHostProduct();
  506. }
  507. });
  508. // 计算属性:按商家分组购物车商品
  509. const groupedCartList = computed(() => {
  510. const groups = {};
  511. cartList.valid.forEach(item => {
  512. const merchant = item.sbMerchant;
  513. if (merchant && merchant.id) {
  514. const merchantId = merchant.id;
  515. if (!groups[merchantId]) {
  516. groups[merchantId] = {
  517. id: merchantId,
  518. name: merchant.merchantName || '未知商家',
  519. logo: merchant.merchantLogo || '/static/avator.png',
  520. products: []
  521. };
  522. }
  523. item.editNum = false;
  524. groups[merchantId].products.push(item);
  525. } else {
  526. // 如果没有商家信息,放到默认分组
  527. const defaultId = 'default';
  528. if (!groups[defaultId]) {
  529. groups[defaultId] = {
  530. id: defaultId,
  531. name: '自营',
  532. logo: '/static/avator.png',
  533. products: []
  534. };
  535. }
  536. groups[defaultId].products.push(item);
  537. }
  538. });
  539. return Object.values(groups);
  540. });
  541. const orderGoodsCount = computed(() => {
  542. // console.log('fsdfsdfsd', cartList, cartList)
  543. return cartList.valid.length + cartList.invalid.length;
  544. });
  545. // 监听购物车数据变化,重新计算选中状态
  546. watch(() => cartList.valid, (newVal) => {
  547. calculateSelectStatus();
  548. }, { deep: true });
  549. // 重新计算选中状态
  550. function calculateSelectStatus() {
  551. const validList = cartList.valid;
  552. const selectValueArr = selectValue.value;
  553. let checkedCount = 0;
  554. let totalValidCount = 0;
  555. validList.forEach(item => {
  556. if (item.attrStatus) {
  557. totalValidCount++;
  558. if (selectValueArr.includes(item.id)) {
  559. checkedCount++;
  560. }
  561. }
  562. });
  563. isAllSelect.value = totalValidCount > 0 && checkedCount === totalValidCount;
  564. switchSelect();
  565. }
  566. const closeProductPopup = () => {
  567. showProductPopup.value = false;
  568. };
  569. function authColse(e) {
  570. isShowAuth.value = e;
  571. }
  572. async function handleSubmit() {
  573. try {
  574. const productSelect = productValue.value[attrValue.value];
  575. if (attr.productAttr.length && productSelect === undefined)
  576. return Toast({
  577. title: "产品库存不足,请选择其它",
  578. });
  579. const params = {
  580. id: cartId.value,
  581. productId: product_id.value,
  582. num: attr.productSelect.cart_num,
  583. unique:
  584. attr.productSelect !== undefined
  585. ? attr.productSelect.unique
  586. : productInfo.value.id,
  587. };
  588. await getResetCart(params);
  589. attr.cartAttr = false;
  590. Toast({
  591. title: "添加购物车成功",
  592. success: () => {
  593. loadend.value = false;
  594. page.value = 1;
  595. cartList.valid = [];
  596. getCartListFn();
  597. getCartNum();
  598. },
  599. });
  600. } catch (error) {
  601. Toast({
  602. title: error,
  603. });
  604. } finally {
  605. showProductPopup.value = false;
  606. }
  607. }
  608. function onMyEvent() {
  609. attr.cartAttr = false;
  610. }
  611. function reElection(item) {
  612. showProductPopup.value = true;
  613. getGoodsDetails(item);
  614. }
  615. function getGoodsDetails(item) {
  616. console.log("item", item);
  617. // uni.showLoading({
  618. // title: "加载中",
  619. // mask: true,
  620. // });
  621. cartId.value = item.id;
  622. product_id.value = item.productId;
  623. getProductDetail(item.productId)
  624. .then((res) => {
  625. uni.hideLoading();
  626. attr.cartAttr = true;
  627. productInfo.value = res.data.productInfo;
  628. attr.productAttr = res.data.productAttr.map((item) => ({
  629. ...item,
  630. attrValues: item.attrValues.split(","),
  631. }));
  632. productValue.value = res.data.productValue;
  633. DefaultSelect();
  634. })
  635. .catch((err) => {
  636. uni.hideLoading();
  637. });
  638. }
  639. function ChangeAttr(res) {
  640. const productSelect = productValue.value[res];
  641. if (productSelect && productSelect.stock > 0) {
  642. attr.productSelect = {
  643. ...attr.productSelect,
  644. image: productSelect.image,
  645. sales: productSelect.sales,
  646. weight: productSelect.weight,
  647. price: productSelect.price,
  648. storePrice: productSelect.storePrice,
  649. stock: productSelect.stock,
  650. unique: productSelect.id,
  651. cart_num: 1,
  652. };
  653. attrValue.value = res;
  654. attrTxt.value = "已选择";
  655. } else {
  656. attr.productSelect = {
  657. ...attr.productSelect,
  658. image: productInfo.value.image,
  659. weight: productSelect.weight,
  660. price: productInfo.value.price,
  661. storePrice: productSelect.storePrice,
  662. stock: 0,
  663. unique: productInfo.value.id,
  664. cart_num: 1,
  665. };
  666. attrValue.value = "";
  667. attrTxt.value = "请选择";
  668. }
  669. }
  670. function DefaultSelect() {
  671. const productAttr = attr.productAttr;
  672. console.log("productValue", productValue);
  673. let value = [];
  674. for (let key in productValue.value) {
  675. if (productValue.value[key].stock > 0) {
  676. value = attr.productAttr.length ? key.split(",") : [];
  677. break;
  678. }
  679. }
  680. for (let i = 0; i < productAttr.length; i++) {
  681. productAttr[i].index = value[i];
  682. }
  683. let productSelect = productValue.value[value.sort().join(",")];
  684. if (productSelect && productAttr.length) {
  685. attr.productSelect.storeName = productInfo.value.storeName;
  686. attr.productSelect.image = productSelect.image;
  687. attr.productSelect.price = productSelect.price;
  688. attr.productSelect.storePrice = productSelect.storePrice;
  689. attr.productSelect.stock = productSelect.stock;
  690. attr.productSelect.unique = productSelect.id;
  691. attr.productSelect.cart_num = 1;
  692. attrValue.value = value.sort().join(",");
  693. attrTxt.value = "已选择";
  694. } else if (!productSelect && productAttr.length) {
  695. attr.productSelect.storeName = productInfo.value.storeName;
  696. attr.productSelect.image = productInfo.value.image;
  697. attr.productSelect.price = productInfo.value.price;
  698. attr.productSelect.storePrice = productSelect.storePrice;
  699. attr.productSelect.stock = 0;
  700. attr.productSelect.unique = productInfo.value.id;
  701. attr.productSelect.cart_num = 0;
  702. attrValue.value = "";
  703. attrTxt.value = "请选择";
  704. } else if (!productSelect && !productAttr.length) {
  705. attr.productSelect.storeName = productInfo.value.storeName;
  706. attr.productSelect.image = productInfo.value.image;
  707. attr.productSelect.price = productInfo.value.price;
  708. attr.productSelect.storePrice = productSelect.storePrice;
  709. attr.productSelect.stock = productInfo.value.stock;
  710. attr.productSelect.unique = productInfo.value.id || "";
  711. attr.productSelect.cart_num = 1;
  712. attrValue.value = "";
  713. attrTxt.value = "请选择";
  714. }
  715. }
  716. function attrVal(val) {
  717. attr.productAttr[val.indexw].index =
  718. attr.productAttr[val.indexw].attrValues[val.indexn];
  719. }
  720. function ChangeCartNumFn(changeValue) {
  721. let productSelect = productValue.value[attrValue.value];
  722. if (productSelect === undefined && !attr.productAttr.length)
  723. productSelect = attr.productSelect;
  724. if (productSelect === undefined) return;
  725. let stock = productSelect.stock || 0;
  726. let num = attr.productSelect;
  727. if (changeValue) {
  728. num.cart_num++;
  729. if (num.cart_num > stock) {
  730. num.cart_num = stock ? stock : 1;
  731. }
  732. } else {
  733. num.cart_num--;
  734. if (num.cart_num < 1) {
  735. num.cart_num = 1;
  736. }
  737. }
  738. }
  739. function iptCartNum(e) {
  740. attr.productSelect.cart_num = e;
  741. }
  742. function subDel(event) {
  743. const selectValueArr = selectValue.value;
  744. if (selectValueArr.length > 0)
  745. cartDel(selectValueArr).then((res) => {
  746. loadend.value = false;
  747. page.value = 1;
  748. cartList.valid = [];
  749. getCartListFn();
  750. getCartNum();
  751. });
  752. else
  753. return Toast({
  754. title: "请选择产品",
  755. });
  756. }
  757. function getSelectValueProductId() {
  758. const validList = cartList.valid;
  759. const selectValueArr = selectValue.value;
  760. let productId = [];
  761. if (selectValueArr.length > 0) {
  762. for (let index in validList) {
  763. if (inArray(validList[index].id, selectValueArr)) {
  764. productId.push(validList[index].productId);
  765. }
  766. }
  767. }
  768. return productId;
  769. }
  770. function subCollect(event) {
  771. const selectValueArr = selectValue.value;
  772. if (selectValueArr.length > 0) {
  773. const selectValueProductId = getSelectValueProductId();
  774. collectAll(selectValueProductId)
  775. .then((res) => {
  776. return Toast({
  777. title: "收藏成功",
  778. icon: "success",
  779. });
  780. })
  781. .catch((err) => {
  782. return Toast({
  783. title: err,
  784. });
  785. });
  786. } else {
  787. return Toast({
  788. title: "请选择产品",
  789. });
  790. }
  791. }
  792. function subOrder(event) {
  793. if(appStore.userInfo.merchant){
  794. uni.showToast({
  795. title:'商家用户不能下单!',
  796. icon:'none',
  797. })
  798. return ;
  799. }
  800. const selectValueArr = selectValue.value;
  801. if (selectValueArr.length > 0) {
  802. // 检查是否选择了多个商家的商品
  803. if (hasMultipleMerchants()) {
  804. return Toast({
  805. title: "只能结算同一商家的商品",
  806. });
  807. }
  808. getPreOrderFn();
  809. } else {
  810. return Toast({
  811. title: "请选择产品",
  812. });
  813. }
  814. }
  815. // 检查是否选择了多个商家的商品
  816. function hasMultipleMerchants() {
  817. const selectValueArr = selectValue.value;
  818. const validList = cartList.valid;
  819. // 获取选中的商品
  820. const selectedItems = validList.filter(item =>
  821. selectValueArr.includes(item.id) && item.attrStatus
  822. );
  823. // 提取商家ID
  824. const merchantIds = new Set();
  825. selectedItems.forEach(item => {
  826. if (item.sbMerchant && item.sbMerchant.id) {
  827. merchantIds.add(item.sbMerchant.id);
  828. } else {
  829. // 如果没有商家信息,也作为一个独立的商家
  830. merchantIds.add('default');
  831. }
  832. });
  833. return merchantIds.size > 1;
  834. }
  835. function getPreOrderFn() {
  836. const shoppingCartId = selectValue.value.map((item) => {
  837. return {
  838. shoppingCartId: Number(item),
  839. };
  840. });
  841. const params = {
  842. mallType: 0,
  843. preOrderType: "shoppingCart",
  844. orderDetails: shoppingCartId,
  845. };
  846. getPreOrder(params);
  847. }
  848. function checkboxAllChange(value) {
  849. if (value.length > 0) {
  850. // 检查全选是否会选择多个商家
  851. if (footerswitch.value && willSelectMultipleMerchants()) {
  852. Toast({
  853. title: "只能选择同一商家的商品进行结算",
  854. });
  855. // 重置全选状态为未选中
  856. isAllSelect.value = false;
  857. allCheckboxValue.value = [];
  858. // 清空shopCheckbox的值
  859. shopCheckbox.value = [];
  860. setAllSelectValue(0);
  861. return;
  862. }else{
  863. setAllSelectValue(1);
  864. }
  865. } else {
  866. setAllSelectValue(0);
  867. }
  868. }
  869. // 检查全选是否会选择多个商家
  870. function willSelectMultipleMerchants() {
  871. const validList = cartList.valid.filter(item => item.attrStatus);
  872. const merchantIds = new Set();
  873. validList.forEach(item => {
  874. if (item.sbMerchant && item.sbMerchant.id) {
  875. merchantIds.add(item.sbMerchant.id);
  876. } else {
  877. merchantIds.add('default');
  878. }
  879. });
  880. return merchantIds.size > 1;
  881. }
  882. function setAllSelectValue(status) {
  883. const valid = cartList.valid;
  884. let selectValueArr = [];
  885. valid.forEach(item => {
  886. if (status) {
  887. if (footerswitch.value) {
  888. if (item.attrStatus) {
  889. item.checked = true;
  890. selectValueArr.push(item.id);
  891. } else {
  892. item.checked = false;
  893. }
  894. } else {
  895. item.checked = true;
  896. selectValueArr.push(item.id);
  897. }
  898. } else {
  899. item.checked = false;
  900. }
  901. });
  902. cartList.valid = [...valid];
  903. selectValue.value = selectValueArr;
  904. isAllSelect.value = status === 1;
  905. console.log(isAllSelect.value)
  906. switchSelect();
  907. }
  908. function checkboxChange(value) {
  909. const valid = cartList.valid;
  910. // 更新所有商品的选中状态
  911. valid.forEach(item => {
  912. item.checked = value.includes(item.id);
  913. });
  914. cartList.valid = [...valid];
  915. selectValue.value = value;
  916. // 计算全选状态
  917. if (footerswitch.value) {
  918. // 结算模式下,只计算有效商品
  919. const validItems = valid.filter(item => item.attrStatus);
  920. isAllSelect.value = validItems.length > 0 && value.length === validItems.length;
  921. } else {
  922. // 管理模式下,计算所有商品
  923. isAllSelect.value = valid.length > 0 && value.length === valid.length;
  924. }
  925. switchSelect();
  926. }
  927. function inArray(search, array) {
  928. for (let i in array) {
  929. if (array[i] == search) {
  930. return true;
  931. }
  932. }
  933. return false;
  934. }
  935. // 选中商品的价格
  936. function switchSelect() {
  937. const validList = cartList.valid;
  938. const selectValueArr = selectValue.value;
  939. let selectCount = 0.0;
  940. console.log('switchSelect called', {
  941. validListLength: validList.length,
  942. selectValueArrLength: selectValueArr.length,
  943. selectValueArr: selectValueArr
  944. });
  945. if (selectValueArr.length < 1) {
  946. selectCountPrice.value = '0.00';
  947. } else {
  948. for (let index in validList) {
  949. if (inArray(validList[index].id, selectValueArr)) {
  950. console.log('Calculating item:', {
  951. id: validList[index].id,
  952. cartNum: validList[index].cartNum,
  953. storePrice: validList[index].storePrice,
  954. checked: validList[index].checked
  955. });
  956. const itemTotal = util.$h.Mul(validList[index].cartNum, validList[index].storePrice);
  957. selectCount = util.$h.Add(selectCount, itemTotal);
  958. }
  959. }
  960. // 保留两位小数
  961. selectCountPrice.value = selectCount.toFixed(2);
  962. }
  963. console.log('Final selectCountPrice:', selectCountPrice.value);
  964. }
  965. function iptCartNumInput(index) {
  966. const item = cartList.valid[index];
  967. if (item.cartNum) {
  968. setCartNum(item.id, item.cartNum);
  969. }
  970. switchSelect();
  971. }
  972. function blurInput(index) {
  973. const item = cartList.valid[index];
  974. if (!item.cartNum) {
  975. item.cartNum = 1;
  976. }
  977. }
  978. function subCart(cartIdVal, merchantIndex, productIndex) {
  979. const item = groupedCartList.value[merchantIndex].products[productIndex];
  980. let status = false;
  981. item.cartNum = Number(item.cartNum) - 1;
  982. if (item.cartNum < 1) status = true;
  983. if (item.cartNum <= 1) {
  984. item.cartNum = 1;
  985. item.numSub = true;
  986. } else {
  987. item.numSub = false;
  988. item.numAdd = false;
  989. }
  990. if (false == status) {
  991. setCartNum(item.id, item.cartNum, function (data) {
  992. switchSelect();
  993. getCartNum();
  994. });
  995. }
  996. }
  997. function addCart(cartIdVal, merchantIndex, productIndex) {
  998. console.log(cartIdVal)
  999. const item = groupedCartList.value[merchantIndex].products[productIndex];
  1000. item.cartNum = Number(item.cartNum) + 1;
  1001. if (item.cartNum >= item.stock) {
  1002. item.cartNum = item.stock;
  1003. item.numAdd = true;
  1004. item.numSub = false;
  1005. } else {
  1006. item.numAdd = false;
  1007. item.numSub = false;
  1008. }
  1009. setCartNum(item.id, item.cartNum, function (data) {
  1010. // 更新UI
  1011. switchSelect();
  1012. getCartNum();
  1013. });
  1014. }
  1015. function setCartNum(cartIdVal, cartNum, successCallback) {
  1016. changeCartNum(cartIdVal, cartNum).then((res) => {
  1017. successCallback && successCallback(res.data);
  1018. });
  1019. }
  1020. function getCartNum() {
  1021. getCartCounts(true, "sum").then((res) => {
  1022. cartCount.value = res.data.count;
  1023. });
  1024. }
  1025. function getCartData(data) {
  1026. return new Promise((resolve, reject) => {
  1027. getCartList(data)
  1028. .then((res) => {
  1029. // 加载数据后,同步选中状态
  1030. const data = res.data;
  1031. if (data.list && data.list.length > 0) {
  1032. data.list.forEach(item => {
  1033. // 如果这个商品ID在选中列表中,设置checked为true
  1034. item.checked = selectValue.value.includes(item.id);
  1035. });
  1036. }
  1037. resolve(data);
  1038. })
  1039. .catch(function (err) {
  1040. loading.value = false;
  1041. canShow.value = true;
  1042. Toast({
  1043. title: err,
  1044. });
  1045. });
  1046. });
  1047. }
  1048. async function getCartListFn() {
  1049. if (loading.value) return;
  1050. loading.value = true;
  1051. try {
  1052. let data = {
  1053. page: page.value,
  1054. limit: limit.value,
  1055. isValid: true,
  1056. };
  1057. const c = await getCartCounts(true, "sum");
  1058. cartCount.value = c.data.count;
  1059. // 当没有商品时,获取推荐商品
  1060. if (c.data.count === 0) {
  1061. await getHostProduct();
  1062. }
  1063. // 收集所有有效的商品
  1064. const allValidItems = [];
  1065. for (let i = 0; i < Math.ceil(cartCount.value / limit.value); i++) {
  1066. let cartListData = await getCartData(data);
  1067. let valid = cartListData.list;
  1068. // 处理商品数据
  1069. if (valid.length > 0) {
  1070. for (let index in valid) {
  1071. // 购物车加减状态
  1072. if (valid[index].cartNum == 1) {
  1073. valid[index].numSub = true;
  1074. } else {
  1075. valid[index].numSub = false;
  1076. }
  1077. let stock = valid[index].stock ? valid[index].stock : 0;
  1078. if (valid[index].cartNum == stock) {
  1079. valid[index].numAdd = true;
  1080. } else if (valid[index].cartNum == valid[index].stock) {
  1081. valid[index].numAdd = true;
  1082. } else {
  1083. valid[index].numAdd = false;
  1084. }
  1085. if (valid[index].attrStatus) {
  1086. valid[index].checked = true;
  1087. } else {
  1088. valid[index].checked = false;
  1089. }
  1090. }
  1091. allValidItems.push(...valid);
  1092. }
  1093. data.page += 1;
  1094. }
  1095. // 一次性更新数组,避免多次响应式更新
  1096. cartList.valid = allValidItems;
  1097. // 更新选中状态
  1098. const selectValueArr = allValidItems
  1099. .filter(item => item.attrStatus && item.checked)
  1100. .map(item => item.id);
  1101. selectValue.value = selectValueArr;
  1102. let newArr = allValidItems.filter((item) => item.attrStatus);
  1103. isAllSelect.value = newArr.length == selectValueArr.length && newArr.length;
  1104. switchSelect();
  1105. } catch (error) {
  1106. Toast({
  1107. title: error.message || '加载失败',
  1108. });
  1109. } finally {
  1110. loading.value = false;
  1111. }
  1112. }
  1113. async function getInvalidList() {
  1114. if (loadendInvalid.value) return false;
  1115. if (loadingInvalid.value) return false;
  1116. loadingInvalid.value = true;
  1117. try {
  1118. let data = {
  1119. page: pageInvalid.value,
  1120. limit: limitInvalid.value,
  1121. isValid: false,
  1122. };
  1123. const res = await getCartList(data);
  1124. let invalid = res.data.list;
  1125. let loadendInvalidFlag = invalid.length < limitInvalid.value;
  1126. // 一次性更新数组
  1127. cartList.invalid = [...cartList.invalid, ...invalid];
  1128. loadendInvalid.value = loadendInvalidFlag;
  1129. loadTitleInvalid.value = loadendInvalidFlag ?
  1130. "我也是有底线的" :
  1131. "加载更多";
  1132. pageInvalid.value = pageInvalid.value + 1;
  1133. } catch (res) {
  1134. console.error('获取失效商品失败:', res);
  1135. } finally {
  1136. loadingInvalid.value = false;
  1137. }
  1138. }
  1139. function getHostProduct() {
  1140. if (hotScroll.value) return;
  1141. getProductHot(hotPage.value, hotLimit.value).then((res) => {
  1142. hotPage.value++;
  1143. hotScroll.value = res.data.list.length < hotLimit.value;
  1144. hostProduct.value = hostProduct.value.concat(res.data.list);
  1145. });
  1146. }
  1147. function goodsOpen() {
  1148. goodsHidden.value = !goodsHidden.value;
  1149. }
  1150. function manage() {
  1151. footerswitch.value = !footerswitch.value;
  1152. let arr1 = [];
  1153. let arr2 = [];
  1154. let newValid = cartList.valid.map((item) => {
  1155. if (footerswitch.value) {
  1156. if (item.attrStatus) {
  1157. if (item.checked) {
  1158. arr1.push(item.id);
  1159. }
  1160. } else {
  1161. item.checked = false;
  1162. arr2.push(item);
  1163. }
  1164. } else {
  1165. if (item.checked) {
  1166. arr1.push(item.id);
  1167. }
  1168. }
  1169. return item;
  1170. });
  1171. cartList.valid = newValid;
  1172. if (footerswitch.value) {
  1173. isAllSelect.value = newValid.length === arr1.length + arr2.length;
  1174. } else {
  1175. isAllSelect.value = newValid.length === arr1.length;
  1176. }
  1177. selectValue.value = arr1;
  1178. switchSelect();
  1179. }
  1180. function unsetCart() {
  1181. let ids = [];
  1182. for (let i = 0, len = cartList.invalid.length; i < len; i++) {
  1183. ids.push(cartList.invalid[i].id);
  1184. }
  1185. cartDel(ids)
  1186. .then((res) => {
  1187. Toast({
  1188. title: "清除成功",
  1189. });
  1190. cartList.invalid = [];
  1191. getHostProduct();
  1192. })
  1193. .catch((res) => {});
  1194. }
  1195. const toMerchant = (obj) => {
  1196. if(obj.id == 'default'){
  1197. return;
  1198. }else{
  1199. uni.navigateTo({ url:"/pages/merchantCenters/merchant?merchantId="+obj.id });
  1200. }
  1201. }
  1202. </script>
  1203. <style scoped lang="scss">
  1204. .cartBox {
  1205. margin-top: 20rpx;
  1206. }
  1207. .shoppingCart {
  1208. // .labelNav
  1209. padding-bottom: 300rpx;
  1210. .labelNav {
  1211. position: sticky;
  1212. height: 178rpx;
  1213. padding: 30rpx 30rpx 0 30rpx;
  1214. font-size: 22rpx;
  1215. color: #fff;
  1216. position: fixed;
  1217. left: 0;
  1218. width: 100%;
  1219. box-sizing: border-box;
  1220. background-color: $theme-color;
  1221. z-index: 5;
  1222. top: 0;
  1223. height: calc(178rpx + 44px + 45rpx);
  1224. padding-top: calc(44px + 50rpx);
  1225. .item {
  1226. .iconfont {
  1227. font-size: 25rpx;
  1228. margin-right: 10rpx;
  1229. }
  1230. }
  1231. }
  1232. // .nav
  1233. .nav {
  1234. height: 90rpx;
  1235. background-color: #fff;
  1236. padding: 0 24rpx;
  1237. box-sizing: border-box;
  1238. font-size: 28rpx;
  1239. color: #282828;
  1240. border-top-left-radius: 14rpx;
  1241. border-top-right-radius: 14rpx;
  1242. .num {
  1243. margin-left: 12rpx;
  1244. }
  1245. .administrate {
  1246. font-size: 28rpx;
  1247. color: #333;
  1248. }
  1249. }
  1250. // .noCart
  1251. .noCart {
  1252. background-color: #fff;
  1253. padding-top: 0.1rpx;
  1254. .pictrue {
  1255. width: 414rpx;
  1256. height: 336rpx;
  1257. margin: 78rpx auto 56rpx auto;
  1258. padding-bottom: 40rpx;
  1259. image {
  1260. width: 100%;
  1261. height: 100%;
  1262. }
  1263. }
  1264. }
  1265. // .list
  1266. .list {
  1267. width: 100%;
  1268. overflow: hidden;
  1269. border-bottom-left-radius: 14rpx;
  1270. border-bottom-right-radius: 14rpx;
  1271. .item {
  1272. width: 100%;
  1273. padding: 24rpx;
  1274. background-color: #fff;
  1275. display: flex;
  1276. .picTxt {
  1277. flex: 1;
  1278. position: relative;
  1279. display: flex;
  1280. align-items: center;
  1281. .pictrue {
  1282. width: 176rpx;
  1283. height: 176rpx;
  1284. margin-right: 16rpx;
  1285. image {
  1286. width: 100%;
  1287. height: 100%;
  1288. border-radius: 6rpx;
  1289. }
  1290. }
  1291. .item-info,
  1292. .text {
  1293. width: 402rpx;
  1294. font-size: 28rpx;
  1295. font-weight: bold;
  1296. color: #333;
  1297. .storeName{
  1298. width: 50%;
  1299. }
  1300. .reColor {
  1301. color: #999;
  1302. }
  1303. .reElection {
  1304. margin-top: 20rpx;
  1305. .title {
  1306. font-size: 24rpx;
  1307. }
  1308. .reBnt {
  1309. width: 120rpx;
  1310. height: 46rpx;
  1311. border-radius: 23rpx;
  1312. font-size: 26rpx;
  1313. }
  1314. }
  1315. .attribute-box {
  1316. display: flex;
  1317. justify-content: space-between;
  1318. .attribute-suk {
  1319. font-weight: normal;
  1320. }
  1321. .invalid-count {
  1322. text-align: right;
  1323. }
  1324. }
  1325. .infor {
  1326. font-size: 24rpx;
  1327. color: #999;
  1328. //margin-top: 10rpx;
  1329. }
  1330. .labor-costs {
  1331. font-size: 24rpx;
  1332. color: #FD5F3C;
  1333. margin-top: 10rpx;
  1334. .tag{
  1335. padding: 10rpx 16rpx;
  1336. background-color: #FFEFEC;
  1337. border-radius: 8rpx;
  1338. display: inline-block;
  1339. }
  1340. }
  1341. .money {
  1342. font-size: 32rpx;
  1343. color: #e93323;
  1344. margin-top: 20rpx;
  1345. font-weight: 600;
  1346. }
  1347. }
  1348. .carnum {
  1349. height: 47rpx;
  1350. //position: absolute;
  1351. //bottom: 7rpx;
  1352. //right: 0;
  1353. view {
  1354. border: 1rpx solid #a4a4a4;
  1355. width: 66rpx;
  1356. text-align: center;
  1357. height: 100%;
  1358. line-height: 44rpx;
  1359. font-size: 28rpx;
  1360. color: #a4a4a4;
  1361. }
  1362. .reduce {
  1363. border-right: 0;
  1364. border-radius: 22rpx 0 0 22rpx;
  1365. font-size: 34rpx;
  1366. line-height: 40rpx;
  1367. &.on {
  1368. border-color: #e3e3e3;
  1369. color: #dedede;
  1370. }
  1371. }
  1372. .plus {
  1373. border-left: 0;
  1374. border-radius: 0 22rpx 22rpx 0;
  1375. font-size: 34rpx;
  1376. line-height: 40rpx;
  1377. }
  1378. .num {
  1379. color: #282828;
  1380. }
  1381. }
  1382. }
  1383. }
  1384. }
  1385. // .invalidGoods
  1386. .invalidGoods {
  1387. background-color: #fff;
  1388. margin-top: 30rpx;
  1389. .goodsNav {
  1390. width: 100%;
  1391. height: 90rpx;
  1392. padding: 0 24rpx;
  1393. box-sizing: border-box;
  1394. font-size: 28rpx;
  1395. color: #333;
  1396. .iconfont {
  1397. color: #424242;
  1398. font-size: 28rpx;
  1399. margin-right: 17rpx;
  1400. }
  1401. .del {
  1402. font-size: 26rpx;
  1403. color: #333;
  1404. .icon-shanchu1 {
  1405. color: #333;
  1406. font-size: 33rpx;
  1407. vertical-align: -2rpx;
  1408. margin-right: 8rpx;
  1409. }
  1410. }
  1411. }
  1412. .goodsList {
  1413. .item {
  1414. padding: 24rpx;
  1415. .invalid {
  1416. font-size: 22rpx;
  1417. color: #ccc;
  1418. height: 36rpx;
  1419. border-radius: 3rpx;
  1420. text-align: center;
  1421. line-height: 36rpx;
  1422. }
  1423. .picTxt {
  1424. width: 576rpx;
  1425. .pictrue {
  1426. width: 176rpx;
  1427. height: 176rpx;
  1428. image {
  1429. width: 100%;
  1430. height: 100%;
  1431. border-radius: 6rpx;
  1432. }
  1433. }
  1434. .text {
  1435. width: 396rpx;
  1436. font-size: 28rpx;
  1437. color: #999;
  1438. height: 140rpx;
  1439. .name {
  1440. width: 100%;
  1441. }
  1442. .infor {
  1443. font-size: 24rpx;
  1444. }
  1445. .end {
  1446. font-size: 26rpx;
  1447. color: #bbb;
  1448. }
  1449. }
  1450. }
  1451. }
  1452. }
  1453. }
  1454. }
  1455. // footer
  1456. .footer {
  1457. z-index: 9;
  1458. width: 100%;
  1459. height: 132rpx;
  1460. background-color: #fff;
  1461. position: fixed;
  1462. padding: 0 24rpx;
  1463. box-sizing: border-box;
  1464. border-top: 1rpx solid #eee;
  1465. bottom: 160rpx;
  1466. .checkAll {
  1467. font-size: 28rpx;
  1468. line-height: 56rpx;
  1469. color: #333333;
  1470. margin-left: 14rpx;
  1471. }
  1472. .money {
  1473. font-size: 30rpx;
  1474. .font-color {
  1475. font-weight: 600;
  1476. }
  1477. }
  1478. .placeOrder {
  1479. color: #333;
  1480. font-weight: bold;
  1481. font-size: 32rpx;
  1482. width: 192rpx;
  1483. height: 88rpx;
  1484. border-radius: 16rpx;
  1485. text-align: center;
  1486. line-height: 88rpx;
  1487. margin-left: 22rpx;
  1488. }
  1489. .button {
  1490. .bnt {
  1491. font-size: 28rpx;
  1492. color: #999;
  1493. border-radius: 50rpx;
  1494. border: 1px solid #999;
  1495. width: 160rpx;
  1496. height: 60rpx;
  1497. text-align: center;
  1498. line-height: 60rpx;
  1499. }
  1500. form ~ form {
  1501. margin-left: 17rpx;
  1502. }
  1503. }
  1504. }
  1505. // 其它样式
  1506. .invalidClas {
  1507. position: relative;
  1508. z-index: 111;
  1509. top: -120rpx;
  1510. }
  1511. .invalidClasNO {
  1512. position: static;
  1513. margin-top: 15px;
  1514. }
  1515. .uni-p-b-96 {
  1516. height: 96rpx;
  1517. }
  1518. .merchant-groups {
  1519. margin-bottom: 20rpx;
  1520. }
  1521. .merchant-group {
  1522. background: #fff;
  1523. border-radius: 16rpx;
  1524. margin-bottom: 20rpx;
  1525. overflow: hidden;
  1526. .merchant-header {
  1527. padding: 24rpx;
  1528. .merchant-info {
  1529. .merchant-logo {
  1530. width: 40rpx;
  1531. height: 40rpx;
  1532. border-radius: 50%;
  1533. margin-right: 8rpx;
  1534. }
  1535. .merchant-name {
  1536. font-size: 26rpx;
  1537. line-height: 40rpx;
  1538. margin-right: 16rpx;
  1539. color: #333;
  1540. }
  1541. }
  1542. .merchant-action {
  1543. display: flex;
  1544. align-items: center;
  1545. color: #999;
  1546. font-size: 24rpx;
  1547. text {
  1548. margin-right: 8rpx;
  1549. }
  1550. }
  1551. }
  1552. .merchant-products {
  1553. padding: 0 24rpx;
  1554. }
  1555. }
  1556. // 调整商品项样式以适应分组布局
  1557. .item {
  1558. padding: 24rpx 0;
  1559. border-bottom: 1rpx solid #f5f5f5;
  1560. &:last-child {
  1561. border-bottom: none;
  1562. }
  1563. }
  1564. // 其他原有样式保持不变
  1565. .cartBox {
  1566. margin-top: 20rpx;
  1567. }
  1568. .namAndNum{
  1569. display: flex;
  1570. align-items: center;
  1571. justify-content: space-between;
  1572. }
  1573. .carnumTag{
  1574. font-size: 24rpx;
  1575. color: #666666;
  1576. background: #F1F3F8;
  1577. border-radius: 8rpx;
  1578. padding: 10rpx 16rpx;
  1579. }
  1580. </style>