order_addcart.vue 47 KB

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