order_addcart.vue 47 KB

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