order_addcart.vue 46 KB

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