order_addcart.vue 46 KB

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