checkout.vue 49 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655
  1. <template>
  2. <view class="container">
  3. <view v-if="loading" class="loading-wrap">
  4. <text class="loading-text">加载中...</text>
  5. </view>
  6. <scroll-view v-else scroll-y class="content">
  7. <!-- Address Section -->
  8. <view class="section address-section" @click="openAddressPicker">
  9. <view v-if="selectedAddress" class="address-content">
  10. <view class="address-top">
  11. <text class="receiver-name">{{ selectedAddress.receiverName }}</text>
  12. <text class="receiver-phone">{{ formatPhone(selectedAddress.phone) }}</text>
  13. <text v-if="selectedAddress.isDefault === 1" class="default-badge">默认</text>
  14. </view>
  15. <text class="address-detail">
  16. {{ selectedAddress.province }}{{ selectedAddress.city }}{{ selectedAddress.district }}{{ selectedAddress.street }}
  17. </text>
  18. <text class="address-arrow">›</text>
  19. </view>
  20. <view v-else class="address-empty" @click.stop="goAddAddress">
  21. <text class="address-empty-icon">📍</text>
  22. <text class="address-empty-text">请选择收货地址</text>
  23. <text class="address-arrow">›</text>
  24. </view>
  25. </view>
  26. <!-- 配送方式选择 -->
  27. <view class="section" v-if="deliveryMethod > 1">
  28. <text class="section-title">{{ deliveryMethodLabel(deliveryMethod) }}</text>
  29. <!-- 自提/线上服务区域 -->
  30. <view v-if="deliveryMethod === 2 || deliveryMethod === 3">
  31. <view class="delivery-sub-label">自取地点</view>
  32. <view class="picker-row" @click="showPickupLocationPicker">
  33. <text class="picker-value" v-if="selectedPickupLocation">{{ selectedPickupLocation.name }}</text>
  34. <text class="picker-placeholder" v-else>请选择自取地点</text>
  35. <text class="picker-arrow">›</text>
  36. </view>
  37. <view v-if="selectedPickupLocation && selectedPickupLocation.timeSlots && selectedPickupLocation.timeSlots.length > 0" class="picker-row" @click="showTimeSlotPicker">
  38. <text class="picker-value" v-if="selectedTimeSlot">{{ selectedTimeSlot.startTime }} - {{ selectedTimeSlot.endTime }}</text>
  39. <text class="picker-placeholder" v-else>请选择取货时间</text>
  40. <text class="picker-arrow">›</text>
  41. </view>
  42. </view>
  43. <view v-if="deliveryMethod === 4">
  44. <view class="picker-row" @click="showServicePersonPicker">
  45. <text class="picker-value" v-if="selectedServicePerson">{{ selectedServicePerson.name }}({{ selectedServicePerson.title || '服务者' }})</text>
  46. <text class="picker-placeholder" v-else>请选择服务者</text>
  47. <text class="picker-arrow">›</text>
  48. </view>
  49. <view v-if="selectedServicePerson" class="picker-row" @click="showOnlineSlotPicker">
  50. <text class="picker-value" v-if="selectedTimeSlot">{{ formatOnlineTime(selectedTimeSlot.startTime) }} - {{ formatOnlineTime(selectedTimeSlot.endTime) }}</text>
  51. <text class="picker-placeholder" v-else>请选择服务时间</text>
  52. <text class="picker-arrow">›</text>
  53. </view>
  54. </view>
  55. <view v-if="deliveryMethod === 5">
  56. <view class="picker-row" @click="showOnlineSlotPicker">
  57. <text class="picker-value" v-if="selectedTimeSlot">{{ formatOnlineTime(selectedTimeSlot.startTime) }} - {{ formatOnlineTime(selectedTimeSlot.endTime) }}</text>
  58. <text class="picker-placeholder" v-else>请选择预约时段</text>
  59. <text class="picker-arrow">›</text>
  60. </view>
  61. </view>
  62. </view>
  63. <!-- 配送方式选择 -->
  64. <view class="section" v-if="deliveryMethod > 1">
  65. <text class="section-title">{{ deliveryMethodLabel(deliveryMethod) }}</text>
  66. <!-- 自提/线上服务区域 -->
  67. <view v-if="deliveryMethod === 2 || deliveryMethod === 3">
  68. <view class="delivery-sub-label">自取地点</view>
  69. <view class="picker-row" @click="showPickupLocationPicker">
  70. <text class="picker-value" v-if="selectedPickupLocation">{{ selectedPickupLocation.name }}</text>
  71. <text class="picker-placeholder" v-else>请选择自取地点</text>
  72. <text class="picker-arrow">›</text>
  73. </view>
  74. <view v-if="selectedPickupLocation && selectedPickupLocation.timeSlots && selectedPickupLocation.timeSlots.length > 0" class="picker-row" @click="showTimeSlotPicker">
  75. <text class="picker-value" v-if="selectedTimeSlot">{{ selectedTimeSlot.startTime }} - {{ selectedTimeSlot.endTime }}</text>
  76. <text class="picker-placeholder" v-else>请选择取货时间</text>
  77. <text class="picker-arrow">›</text>
  78. </view>
  79. </view>
  80. <view v-if="deliveryMethod === 4">
  81. <view class="picker-row" @click="showServicePersonPicker">
  82. <text class="picker-value" v-if="selectedServicePerson">{{ selectedServicePerson.name }}({{ selectedServicePerson.title || '服务者' }})</text>
  83. <text class="picker-placeholder" v-else>请选择服务者</text>
  84. <text class="picker-arrow">›</text>
  85. </view>
  86. <view v-if="selectedServicePerson" class="picker-row" @click="showOnlineSlotPicker">
  87. <text class="picker-value" v-if="selectedTimeSlot">{{ formatOnlineTime(selectedTimeSlot.startTime) }} - {{ formatOnlineTime(selectedTimeSlot.endTime) }}</text>
  88. <text class="picker-placeholder" v-else>请选择服务时间</text>
  89. <text class="picker-arrow">›</text>
  90. </view>
  91. </view>
  92. <view v-if="deliveryMethod === 5">
  93. <view class="picker-row" @click="showOnlineSlotPicker">
  94. <text class="picker-value" v-if="selectedTimeSlot">{{ formatOnlineTime(selectedTimeSlot.startTime) }} - {{ formatOnlineTime(selectedTimeSlot.endTime) }}</text>
  95. <text class="picker-placeholder" v-else>请选择预约时段</text>
  96. <text class="picker-arrow">›</text>
  97. </view>
  98. </view>
  99. </view>
  100. <!-- Purchase Info Section (when product requires it) -->
  101. <view class="section" v-if="requiredFields.length > 0">
  102. <text class="section-title">购买信息</text>
  103. <view
  104. v-for="field in requiredFields"
  105. :key="field.fieldKey"
  106. class="purchase-field-row"
  107. >
  108. <text class="purchase-field-label">
  109. {{ field.fieldName }}
  110. <text v-if="field.isRequired" class="required-mark">*</text>
  111. </text>
  112. <input
  113. v-model="purchaseForm[field.fieldKey]"
  114. class="purchase-field-input"
  115. :placeholder="'请输入' + field.fieldName + (field.isRequired ? '' : '(选填)')"
  116. :disabled="!!field.prefillValue"
  117. placeholder-style="color: #ccc; font-size: 26rpx;"
  118. />
  119. <text v-if="field.prefillValue" class="purchase-field-prefill">已填写</text>
  120. </view>
  121. </view>
  122. <!-- Order Items Section -->
  123. <view class="section">
  124. <text class="section-title">商品信息</text>
  125. <view
  126. v-for="item in items"
  127. :key="item.productId"
  128. class="order-item"
  129. >
  130. <image
  131. class="item-image"
  132. :src="getImageUrl(item.coverImage) || '/static/default-product.png'"
  133. mode="aspectFill"
  134. />
  135. <view class="item-info">
  136. <text class="item-name">{{ item.productName }}</text>
  137. <text v-if="item.specDesc" class="item-spec-desc">{{ item.specDesc }}</text>
  138. <text v-if="item.supplierName" class="item-supplier-name">供应商: {{ item.supplierName }}</text>
  139. <text class="item-qty">x{{ item.quantity }}</text>
  140. </view>
  141. <text class="item-price">{{ formatPriceWithSymbol(item.unitPrice) }}</text>
  142. </view>
  143. </view>
  144. <!-- Freight Section -->
  145. <view class="section">
  146. <view class="info-row">
  147. <text class="info-label">运费</text>
  148. <text class="info-value">{{ formatPriceWithSymbol(freight) }}</text>
  149. </view>
  150. </view>
  151. <!-- Member Upgrade Hint -->
  152. <view v-if="!isMember" class="section member-upgrade-section" @click="goUpgrade">
  153. <view class="member-upgrade-row">
  154. <text class="member-upgrade-icon">👑</text>
  155. <text class="member-upgrade-text">开通会员享全场商品专享价</text>
  156. <text class="member-upgrade-arrow">›</text>
  157. </view>
  158. </view>
  159. <!-- Limited-Time Discount Section -->
  160. <view v-if="discountInfo" class="section discount-section">
  161. <view class="info-row">
  162. <text class="info-label">限时折扣</text>
  163. <text class="discount-amount">-{{ formatPriceWithSymbol(discountInfo.discountAmount) }}</text>
  164. </view>
  165. <view class="discount-rule-name">{{ discountInfo.ruleName || '' }}</view>
  166. <countdown-tag v-if="discountInfo.endTime" :end-time="discountInfo.endTime" />
  167. </view>
  168. <!-- Coupon Section -->
  169. <view class="section coupon-section" @click="openCouponPicker">
  170. <view class="info-row">
  171. <text class="info-label">优惠券</text>
  172. <view class="coupon-selected" v-if="selectedCoupon">
  173. <text class="coupon-discount">-{{ formatPriceWithSymbol(selectedCoupon.value) }}</text>
  174. <text class="coupon-name-tag">{{ selectedCoupon.name }}</text>
  175. </view>
  176. <view class="coupon-placeholder" v-else>
  177. <text class="placeholder-text">选择优惠券</text>
  178. </view>
  179. <text class="address-arrow">›</text>
  180. </view>
  181. </view>
  182. <view v-if="!isMember" class="section member-coupon-hint">
  183. <view class="member-coupon-hint-content">
  184. <text class="hint-icon">👑</text>
  185. <text class="hint-text">加入会员可使用优惠券享更多优惠</text>
  186. </view>
  187. </view>
  188. <!-- Points Deduction Section -->
  189. <view class="section" v-if="userTotalPoints > 0">
  190. <view class="info-row">
  191. <text class="info-label">积分抵扣</text>
  192. <text class="points-balance">可用 {{ userTotalPoints }} 积分</text>
  193. </view>
  194. <view class="points-input-row">
  195. <input
  196. class="points-input"
  197. type="number"
  198. :value="pointsUsed"
  199. @input="onPointsInput"
  200. placeholder="输入使用积分"
  201. placeholder-style="color: #ccc; font-size: 26rpx;"
  202. />
  203. <text class="points-hint">≈ ¥{{ pointsYuanEquivalent }}</text>
  204. </view>
  205. <view class="points-tip">
  206. <text class="points-tip-text">1积分 = ¥0.01,最多使用 {{ maxPoints }} 积分</text>
  207. </view>
  208. </view>
  209. <!-- Remark Section -->
  210. <view class="section">
  211. <view class="info-row">
  212. <text class="info-label">备注</text>
  213. <input
  214. class="remark-input"
  215. v-model="remark"
  216. placeholder="选填,给商家留言"
  217. placeholder-style="color: #ccc; font-size: 26rpx;"
  218. />
  219. </view>
  220. </view>
  221. <view class="bottom-spacer"></view>
  222. </scroll-view>
  223. <!-- 优惠券选择器必须与 scroll-view 平级,否则 iOS 上 position: fixed 在 scroll-view 内不生效(优惠券弹窗不显示) -->
  224. <view class="modal-mask" v-if="showCouponPicker" @click="closeCouponPicker">
  225. <view class="coupon-picker" @click.stop>
  226. <view class="picker-header">
  227. <text class="picker-title">选择优惠券</text>
  228. <text class="picker-close" @click="closeCouponPicker">关闭</text>
  229. </view>
  230. <scroll-view scroll-y class="picker-list">
  231. <!-- 已拥有优惠券 -->
  232. <view class="picker-section-title" v-if="ownedCoupons.length > 0">已拥有优惠券</view>
  233. <view
  234. v-for="coupon in ownedCoupons"
  235. :key="coupon.id"
  236. class="picker-item"
  237. :class="selectedCoupon && selectedCoupon.id === coupon.id ? 'picker-item-active' : ''"
  238. @click="selectCoupon(coupon)"
  239. >
  240. <view class="picker-item-left">
  241. <text class="picker-item-value">{{ formatPriceWithSymbol(coupon.value) }}</text>
  242. </view>
  243. <view class="picker-item-right">
  244. <text class="picker-item-name">{{ coupon.name }}</text>
  245. <text class="picker-item-condition">{{ getConditionText(coupon.minSpend) }}</text>
  246. </view>
  247. <view class="picker-item-check" v-if="selectedCoupon && selectedCoupon.id === coupon.id">
  248. <text class="check-icon">✓</text>
  249. </view>
  250. </view>
  251. <!-- 可兑换优惠券(需CF值):仅在 CF 足够兑换其中一张券时才提醒 -->
  252. <view class="picker-section-title" v-if="affordableExchangeCoupons.length > 0">
  253. 可用CF值兑换(当前余额 {{ cfBalance }} CF)
  254. </view>
  255. <view
  256. v-for="coupon in affordableExchangeCoupons"
  257. :key="coupon.id"
  258. class="picker-item picker-item-exchange"
  259. >
  260. <view class="picker-item-left">
  261. <text class="picker-item-value">{{ formatPriceWithSymbol(coupon.value) }}</text>
  262. </view>
  263. <view class="picker-item-right">
  264. <text class="picker-item-name">{{ coupon.name }}</text>
  265. <text class="picker-item-condition">{{ getConditionText(coupon.minSpend) }}</text>
  266. </view>
  267. <button
  268. class="exchange-btn"
  269. :disabled="coupon.exchanging"
  270. @click.stop="doExchangeCoupon(coupon)"
  271. >
  272. {{ coupon.exchanging ? '兑换中...' : '兑换' }}
  273. </button>
  274. </view>
  275. <view class="picker-empty" v-if="ownedCoupons.length === 0 && affordableExchangeCoupons.length === 0">
  276. <text>暂无可用优惠券</text>
  277. </view>
  278. </scroll-view>
  279. <view class="picker-footer" v-if="selectedCoupon">
  280. <button class="picker-btn-remove" @click="removeCoupon">不使用优惠券</button>
  281. </view>
  282. </view>
  283. </view>
  284. <!-- 自取地点选择器 -->
  285. <view class="modal-mask" v-if="showPickupLocationModal" @click="showPickupLocationModal=false">
  286. <view class="picker-modal" @click.stop>
  287. <view class="picker-header">
  288. <text class="picker-title">选择自取地点</text>
  289. <text class="picker-close" @click="showPickupLocationModal=false">关闭</text>
  290. </view>
  291. <scroll-view scroll-y class="picker-list">
  292. <view
  293. v-for="(loc, idx) in pickupLocations"
  294. :key="loc.id"
  295. class="picker-item"
  296. :class="selectedPickupLocation && selectedPickupLocation.id === loc.id ? 'picker-item-active' : ''"
  297. @click="selectPickupLocation(loc)"
  298. >
  299. <view class="picker-item-left">
  300. <text class="picker-item-name">{{ loc.name }}</text>
  301. <text class="picker-item-addr">{{ loc.address }}</text>
  302. </view>
  303. <view class="picker-item-check" v-if="selectedPickupLocation && selectedPickupLocation.id === loc.id">
  304. <text class="check-icon">✓</text>
  305. </view>
  306. </view>
  307. </scroll-view>
  308. </view>
  309. </view>
  310. <!-- 时间段选择器 -->
  311. <view class="modal-mask" v-if="showTimeSlotModal" @click="showTimeSlotModal=false">
  312. <view class="picker-modal" @click.stop>
  313. <view class="picker-header">
  314. <text class="picker-title">选择取货时间</text>
  315. <text class="picker-close" @click="showTimeSlotModal=false">关闭</text>
  316. </view>
  317. <scroll-view scroll-y class="picker-list">
  318. <view
  319. v-for="(slot, idx) in (selectedPickupLocation && selectedPickupLocation.timeSlots) || []"
  320. :key="slot.id"
  321. class="picker-item"
  322. :class="selectedTimeSlot && selectedTimeSlot.id === slot.id ? 'picker-item-active' : ''"
  323. @click="selectTimeSlot(slot)"
  324. >
  325. <view class="picker-item-left">
  326. <text class="picker-item-name">{{ slot.startTime }} - {{ slot.endTime }}</text>
  327. </view>
  328. <view class="picker-item-check" v-if="selectedTimeSlot && selectedTimeSlot.id === slot.id">
  329. <text class="check-icon">✓</text>
  330. </view>
  331. </view>
  332. </scroll-view>
  333. </view>
  334. </view>
  335. <!-- 服务者选择器 -->
  336. <view class="modal-mask" v-if="showServicePersonModal" @click="showServicePersonModal=false">
  337. <view class="picker-modal" @click.stop>
  338. <view class="picker-header">
  339. <text class="picker-title">选择服务者</text>
  340. <text class="picker-close" @click="showServicePersonModal=false">关闭</text>
  341. </view>
  342. <scroll-view scroll-y class="picker-list">
  343. <view
  344. v-for="(person, idx) in servicePersons"
  345. :key="person.id"
  346. class="picker-item"
  347. :class="selectedServicePerson && selectedServicePerson.id === person.id ? 'picker-item-active' : ''"
  348. @click="selectServicePerson(person)"
  349. >
  350. <view class="picker-item-left">
  351. <text class="picker-item-name">{{ person.name }}</text>
  352. <text class="picker-item-desc">{{ person.title || '' }}</text>
  353. <text class="picker-item-price">{{ formatPriceWithSymbol(person.price) }}</text>
  354. </view>
  355. <view class="picker-item-check" v-if="selectedServicePerson && selectedServicePerson.id === person.id">
  356. <text class="check-icon">✓</text>
  357. </view>
  358. </view>
  359. </scroll-view>
  360. </view>
  361. </view>
  362. <!-- 线上时间段选择器 -->
  363. <view class="modal-mask" v-if="showOnlineSlotModal" @click="showOnlineSlotModal=false">
  364. <view class="picker-modal" @click.stop>
  365. <view class="picker-header">
  366. <text class="picker-title">选择服务时间</text>
  367. <text class="picker-close" @click="showOnlineSlotModal=false">关闭</text>
  368. </view>
  369. <scroll-view scroll-y class="picker-list">
  370. <view
  371. v-for="slot in onlineTimeSlots"
  372. :key="slot.id"
  373. class="picker-item"
  374. :class="selectedTimeSlot && selectedTimeSlot.id === slot.id ? 'picker-item-active' : ''"
  375. @click="selectOnlineSlot(slot)"
  376. >
  377. <view class="picker-item-left">
  378. <text class="picker-item-name">{{ formatOnlineTime(slot.startTime) }} - {{ formatOnlineTime(slot.endTime) }}</text>
  379. </view>
  380. <view class="picker-item-check" v-if="selectedTimeSlot && selectedTimeSlot.id === slot.id">
  381. <text class="check-icon">✓</text>
  382. </view>
  383. </view>
  384. </scroll-view>
  385. </view>
  386. </view>
  387. <view class="bottom-bar">
  388. <view class="bottom-left">
  389. <text class="total-label">合计: </text>
  390. <text class="total-amount">{{ formatPriceWithSymbol(finalAmount) }}</text>
  391. <text v-if="selectedCoupon" class="total-original">{{ formatPriceWithSymbol(actualAmount + freight) }}</text>
  392. </view>
  393. <button
  394. :class="['submit-btn', submitting ? 'disabled' : '']"
  395. :disabled="submitting"
  396. @click="onSubmit"
  397. >提交订单</button>
  398. </view>
  399. </view>
  400. </template>
  401. <script>
  402. import config from '@/config.js'
  403. import { getCouponList, getCouponCheckoutList, addressList, getProductRequiredFields, getMyMembership, productDetail, getFamilyPlatformBalance, exchangeCouponByCf, shopDiscountCalculate } from '../../../utils/api.js'
  404. import { parseDate } from '@/utils/format.js'
  405. import CountdownTag from '@/components/countdown-tag.vue'
  406. export default {
  407. components: {
  408. CountdownTag
  409. },
  410. data() {
  411. return {
  412. items: [],
  413. selectedAddress: null,
  414. requiredFields: [], // 需要的购买信息字段
  415. purchaseForm: {}, // 用户填写的购买信息
  416. addressList: [],
  417. freight: 0,
  418. remark: '',
  419. loading: false,
  420. submitting: false,
  421. actualAmount: 0,
  422. coupons: [],
  423. exchangeableCoupons: [],
  424. cfBalance: 0,
  425. selectedCoupon: null,
  426. showCouponPicker: false,
  427. pointsUsed: 0,
  428. userTotalPoints: 0,
  429. pointsLoading: false,
  430. isMember: false,
  431. // 配送配置
  432. deliveryMethod: 1,
  433. productDeliveryConfig: null,
  434. pickupLocations: [],
  435. selectedPickupLocation: null,
  436. selectedTimeSlot: null,
  437. servicePersons: [],
  438. selectedServicePerson: null,
  439. onlineSlots: [],
  440. // 弹窗控制
  441. showPickupLocationModal: false,
  442. showTimeSlotModal: false,
  443. showServicePersonModal: false,
  444. showOnlineSlotModal: false,
  445. giftItemIds: [],
  446. discountInfo: null
  447. }
  448. },
  449. computed: {
  450. finalAmount() {
  451. var total = (this.actualAmount || 0) + (this.freight || 0)
  452. if (this.selectedCoupon) {
  453. total = total - this.selectedCoupon.value
  454. }
  455. total = total - (this.pointsUsed || 0)
  456. if (total < 0) total = 0
  457. return total
  458. },
  459. maxPoints() {
  460. var total = (this.actualAmount || 0) + (this.freight || 0)
  461. if (this.selectedCoupon) {
  462. total = total - this.selectedCoupon.value
  463. }
  464. if (total < 0) total = 0
  465. if (this.userTotalPoints < total) {
  466. return this.userTotalPoints
  467. }
  468. return total
  469. },
  470. pointsYuanEquivalent() {
  471. return (this.pointsUsed / 100).toFixed(2)
  472. },
  473. ownedCoupons() {
  474. var self = this
  475. var currentProductId = (self.items && self.items.length > 0) ? self.items[0].productId : null
  476. return this.coupons.filter(function(c) {
  477. if (c.status && c.status !== 'AVAILABLE') return false
  478. if (c.minSpend && c.minSpend > self.actualAmount) return false
  479. if (c.applicableTo === 'PRODUCT' && c.productId != null) {
  480. return c.productId === currentProductId
  481. }
  482. if (c.applicableTo && c.applicableTo !== 'ALL' && c.applicableTo !== 'PRODUCT') return false
  483. return true
  484. })
  485. },
  486. availableCoupons() {
  487. var self = this
  488. var currentProductId = (self.items && self.items.length > 0) ? self.items[0].productId : null
  489. return this.coupons.filter(function(c) {
  490. if (c.status && c.status !== 'AVAILABLE') return false
  491. if (c.minSpend && c.minSpend > self.actualAmount) return false
  492. if (c.applicableTo === 'PRODUCT' && c.productId != null) {
  493. return c.productId === currentProductId
  494. }
  495. if (c.applicableTo && c.applicableTo !== 'ALL' && c.applicableTo !== 'PRODUCT') return false
  496. return true
  497. })
  498. },
  499. affordableExchangeCoupons() {
  500. var self = this
  501. return (this.exchangeableCoupons || []).filter(function(c) {
  502. return c.pointsPrice > 0 && self.cfBalance >= c.pointsPrice
  503. })
  504. },
  505. onlineTimeSlots() {
  506. if (this.deliveryMethod === 4 && this.selectedServicePerson) {
  507. return this.selectedServicePerson.slots || []
  508. }
  509. if (this.deliveryMethod === 5) {
  510. return this.onlineSlots
  511. }
  512. return []
  513. }
  514. },
  515. onLoad(options) {
  516. var that = this
  517. var stored = uni.getStorageSync('checkoutItems')
  518. var giftIds = uni.getStorageSync('checkoutGiftItemIds')
  519. this.giftItemIds = (giftIds && giftIds.length > 0) ? giftIds : []
  520. if (stored && stored.length > 0) {
  521. this.items = stored
  522. this.calcAmount()
  523. } else if (options.productId) {
  524. // Load product directly from detail page
  525. var productData = {
  526. productId: parseInt(options.productId),
  527. productName: options.productName || '商品',
  528. coverImage: options.coverImage || '',
  529. unitPrice: parseInt(options.price) || 0,
  530. quantity: parseInt(options.quantity) || 1
  531. }
  532. if (options.skuId) {
  533. productData.skuId = parseInt(options.skuId)
  534. }
  535. this.items = [productData]
  536. this.calcAmount()
  537. }
  538. this.checkMemberStatus()
  539. this.loadDefaultAddress()
  540. this.loadRequiredFields()
  541. this.loadCoupons()
  542. this.loadExchangeableCoupons()
  543. this.loadCfBalance()
  544. this.loadUserPoints()
  545. this.loadDeliveryConfig()
  546. this.loadDiscount()
  547. this._onLoadFired = true
  548. },
  549. onShow() {
  550. // 从地址选择/编辑页返回后重新加载地址列表(首次进入跳过,避免与 onLoad 双发)
  551. if (this._onLoadFired) {
  552. this._onLoadFired = false
  553. } else {
  554. this.loadDefaultAddress()
  555. }
  556. },
  557. methods: {
  558. calcAmount() {
  559. var total = 0
  560. for (var i = 0; i < this.items.length; i++) {
  561. total = total + (this.items[i].unitPrice * this.items[i].quantity)
  562. }
  563. this.actualAmount = total
  564. },
  565. async loadCoupons() {
  566. try {
  567. var res = await getCouponList()
  568. this.coupons = res.data || []
  569. } catch (e) {
  570. this.coupons = []
  571. }
  572. },
  573. async loadExchangeableCoupons() {
  574. try {
  575. var productId = null
  576. if (this.items && this.items.length > 0) {
  577. productId = this.items[0].productId
  578. }
  579. var res = await getCouponCheckoutList({ productId: productId })
  580. this.exchangeableCoupons = res.data || []
  581. } catch (e) {
  582. console.error('加载可兑换优惠券失败', e)
  583. this.exchangeableCoupons = []
  584. }
  585. },
  586. async loadCfBalance() {
  587. try {
  588. var res = await getFamilyPlatformBalance()
  589. if (res.code === 200 && res.data) {
  590. this.cfBalance = res.data.available || 0
  591. }
  592. } catch (e) {
  593. console.error('加载CF余额失败', e)
  594. }
  595. },
  596. async doExchangeCoupon(coupon) {
  597. if (coupon.pointsPrice > this.cfBalance) {
  598. uni.showToast({ title: 'CF值不足,当前可用 ' + this.cfBalance + ' CF值', icon: 'none' })
  599. return
  600. }
  601. coupon.exchanging = true
  602. uni.showLoading({ title: '兑换中...' })
  603. try {
  604. var res = await exchangeCouponByCf({ couponId: coupon.id })
  605. uni.hideLoading()
  606. coupon.exchanging = false
  607. if (res.code === 200) {
  608. uni.showToast({ title: '兑换成功', icon: 'success' })
  609. // 从可兑换列表移除,加入已拥有列表
  610. var idx = this.exchangeableCoupons.findIndex(function(c) { return c.id === coupon.id })
  611. if (idx >= 0) {
  612. this.exchangeableCoupons.splice(idx, 1)
  613. }
  614. coupon.isExchangeable = false
  615. coupon.status = 'AVAILABLE'
  616. this.coupons.push(coupon)
  617. // 刷新余额
  618. this.loadCfBalance()
  619. } else {
  620. uni.showToast({ title: res.message || '兑换失败', icon: 'none' })
  621. }
  622. } catch (e) {
  623. uni.hideLoading()
  624. coupon.exchanging = false
  625. uni.showToast({ title: '兑换失败', icon: 'none' })
  626. }
  627. },
  628. openCouponPicker() {
  629. if (this.availableCoupons.length === 0 && !this.selectedCoupon) {
  630. uni.showToast({ title: '暂无可用优惠券', icon: 'none' })
  631. return
  632. }
  633. this.showCouponPicker = true
  634. },
  635. closeCouponPicker() {
  636. this.showCouponPicker = false
  637. },
  638. selectCoupon(coupon) {
  639. this.selectedCoupon = coupon
  640. this.showCouponPicker = false
  641. },
  642. removeCoupon() {
  643. this.selectedCoupon = null
  644. this.showCouponPicker = false
  645. },
  646. onPointsInput(e) {
  647. var val = parseInt(e.detail.value) || 0
  648. if (val < 0) val = 0
  649. var maxP = this.maxPoints
  650. if (val > maxP) {
  651. val = maxP
  652. uni.showToast({ title: '最多使用 ' + maxP + ' 积分', icon: 'none' })
  653. }
  654. this.pointsUsed = val
  655. },
  656. getConditionText(minSpend) {
  657. if (!minSpend || minSpend <= 0) return '无门槛'
  658. return '满' + (minSpend / 100).toFixed(2) + '元可用'
  659. },
  660. async loadDefaultAddress() {
  661. this.loading = true
  662. try {
  663. var res = await addressList()
  664. if (res.code === 200) {
  665. var list = res.data || []
  666. this.addressList = list
  667. // 如果当前已有选中地址,保持选中状态
  668. if (this.selectedAddress) {
  669. var stillExists = false
  670. for (var k = 0; k < list.length; k++) {
  671. if (list[k].id === this.selectedAddress.id) {
  672. stillExists = true
  673. break
  674. }
  675. }
  676. if (!stillExists) {
  677. this.selectedAddress = null
  678. }
  679. }
  680. if (!this.selectedAddress) {
  681. for (var i = 0; i < list.length; i++) {
  682. if (list[i].isDefault === 1) {
  683. this.selectedAddress = list[i]
  684. break
  685. }
  686. }
  687. if (!this.selectedAddress && list.length > 0) {
  688. this.selectedAddress = list[0]
  689. }
  690. }
  691. }
  692. } catch (e) {
  693. console.error(e)
  694. } finally {
  695. this.loading = false
  696. }
  697. },
  698. async loadRequiredFields() {
  699. if (this.items.length === 0) return
  700. var productId = this.items[0].productId
  701. try {
  702. var res = await getProductRequiredFields(productId)
  703. if (res.code === 200) {
  704. this.requiredFields = res.data || []
  705. this.autoFillPurchaseForm()
  706. }
  707. } catch (e) {
  708. console.error(e)
  709. }
  710. },
  711. autoFillPurchaseForm() {
  712. if (!this.selectedAddress || this.requiredFields.length === 0) return
  713. var form = {}
  714. for (var i = 0; i < this.requiredFields.length; i++) {
  715. var field = this.requiredFields[i]
  716. if (field.prefillValue) {
  717. form[field.fieldKey] = field.prefillValue
  718. } else {
  719. form[field.fieldKey] = ''
  720. }
  721. }
  722. this.purchaseForm = form
  723. },
  724. openAddressPicker() {
  725. if (this.addressList.length === 0) {
  726. uni.showToast({ title: '暂无地址,请先添加', icon: 'none' })
  727. return
  728. }
  729. uni.navigateTo({ url: '/pages/shop/address/address?selectMode=1' })
  730. },
  731. checkMemberStatus() {
  732. var that = this
  733. getMyMembership().then(function(res) {
  734. if (res.data && res.data.memberLevel) {
  735. that.isMember = res.data.memberLevel !== 'FREE'
  736. }
  737. }).catch(function() {})
  738. },
  739. goUpgrade() {
  740. uni.navigateTo({ url: '/pages/membership/upgrade' })
  741. },
  742. goAddAddress() {
  743. uni.navigateTo({ url: '/pages/shop/address-edit/address-edit' })
  744. },
  745. // ========== 配送方式相关 ==========
  746. loadDeliveryConfig() {
  747. if (this.items.length === 0) return
  748. var productId = this.items[0].productId
  749. if (!productId) return
  750. var stored = uni.getStorageSync('checkoutItems')
  751. var storageData = stored && stored.length > 0 ? stored[0] : {}
  752. var deliveryMethod = storageData.deliveryMethod
  753. if (!deliveryMethod || deliveryMethod <= 1) return
  754. this.deliveryMethod = deliveryMethod
  755. this.productDeliveryConfig = storageData.deliveryConfig || null
  756. // 如果来自产品详情,可能已有选中值
  757. if (storageData.pickupLocationId) {
  758. this.selectedPickupLocation = { id: storageData.pickupLocationId }
  759. }
  760. if (storageData.timeSlotId) {
  761. this.selectedTimeSlot = { id: storageData.timeSlotId }
  762. }
  763. if (storageData.servicePersonId) {
  764. this.selectedServicePerson = { id: storageData.servicePersonId }
  765. }
  766. // 加载完整配置
  767. var that = this
  768. productDetail({ id: productId }).then(function(res) {
  769. if (res.code === 200 && res.data && res.data.deliveryConfig) {
  770. that.productDeliveryConfig = res.data.deliveryConfig
  771. that.deliveryMethod = res.data.deliveryMethod || that.deliveryMethod
  772. that.pickupLocations = res.data.deliveryConfig.pickupLocations || []
  773. that.servicePersons = res.data.deliveryConfig.servicePersons || []
  774. that.onlineSlots = res.data.deliveryConfig.onlineSlots || []
  775. }
  776. }).catch(function() {})
  777. },
  778. loadDiscount() {
  779. var that = this
  780. if (this.items.length === 0) return
  781. var productIds = []
  782. for (var i = 0; i < this.items.length; i++) {
  783. if (this.items[i].productId) productIds.push(this.items[i].productId)
  784. }
  785. if (productIds.length === 0) return
  786. shopDiscountCalculate({
  787. productIds: productIds,
  788. orderAmount: this.actualAmount
  789. }).then(function(res) {
  790. if (res.code === 200 && res.data) {
  791. that.discountInfo = res.data
  792. }
  793. }).catch(function() {})
  794. },
  795. this.deliveryMethod = parseInt(e.detail.value)
  796. this.selectedPickupLocation = null
  797. this.selectedTimeSlot = null
  798. this.selectedServicePerson = null
  799. },
  800. onPickupLocationChange: function(e) {
  801. var idx = parseInt(e.detail.value)
  802. if (this.pickupLocations[idx]) {
  803. this.selectedPickupLocation = this.pickupLocations[idx]
  804. this.selectedTimeSlot = null
  805. }
  806. },
  807. onTimeSlotChange: function(e) {
  808. var idx = parseInt(e.detail.value)
  809. if (this.selectedPickupLocation && this.selectedPickupLocation.timeSlots && this.selectedPickupLocation.timeSlots[idx]) {
  810. this.selectedTimeSlot = this.selectedPickupLocation.timeSlots[idx]
  811. }
  812. },
  813. onServicePersonChange: function(e) {
  814. var idx = parseInt(e.detail.value)
  815. if (this.servicePersons[idx]) {
  816. this.selectedServicePerson = this.servicePersons[idx]
  817. this.selectedTimeSlot = null
  818. }
  819. },
  820. onOnlineSlotChange: function(e) {
  821. var idx = parseInt(e.detail.value)
  822. if (this.onlineSlots[idx]) {
  823. this.selectedTimeSlot = this.onlineSlots[idx]
  824. }
  825. },
  826. deliveryMethodLabel: function(method) {
  827. var map = { 1: '快递配送', 2: '到店自提', 3: '快递/自提', 4: '线上服务', 5: '线上预约' }
  828. return map[method] || '快递配送'
  829. },
  830. deliveryMethodHint: function(method) {
  831. var map = { 1: '', 2: '请选择自取地点和时间段', 3: '请选择配送方式', 4: '请选择服务者和时间', 5: '请选择预约时段' }
  832. return map[method] || ''
  833. },
  834. selectPickupLocation(loc) {
  835. this.selectedPickupLocation = loc
  836. this.selectedTimeSlot = null
  837. this.showPickupLocationModal = false
  838. },
  839. selectTimeSlot(slot) {
  840. this.selectedTimeSlot = slot
  841. this.showTimeSlotModal = false
  842. },
  843. selectServicePerson(person) {
  844. this.selectedServicePerson = person
  845. this.selectedTimeSlot = null
  846. this.showServicePersonModal = false
  847. },
  848. selectOnlineSlot(slot) {
  849. this.selectedTimeSlot = slot
  850. this.showOnlineSlotModal = false
  851. },
  852. loadUserPoints() {
  853. var that = this
  854. uni.request({
  855. url: config.api('/api/user/info'),
  856. method: 'POST',
  857. data: {},
  858. header: {
  859. 'Content-Type': 'application/json',
  860. 'Authorization': 'Bearer ' + uni.getStorageSync('token')
  861. },
  862. success: function(res) {
  863. if (res.data && res.data.code === 200) {
  864. that.userTotalPoints = res.data.data.totalPoints || 0
  865. }
  866. }
  867. })
  868. },
  869. onSubmit() {
  870. if (!this.selectedAddress) {
  871. uni.showToast({ title: '请选择收货地址', icon: 'none' })
  872. return
  873. }
  874. if (this.items.length === 0) {
  875. uni.showToast({ title: '请选择商品', icon: 'none' })
  876. return
  877. }
  878. this.submitting = true
  879. var orderItems = []
  880. for (var i = 0; i < this.items.length; i++) {
  881. var itemData = {
  882. productId: this.items[i].productId,
  883. quantity: this.items[i].quantity
  884. }
  885. if (this.items[i].skuId) {
  886. itemData.skuId = this.items[i].skuId
  887. }
  888. orderItems.push(itemData)
  889. }
  890. var that = this
  891. uni.request({
  892. url: config.api('/api/product/order/create'),
  893. method: 'POST',
  894. data: {
  895. items: orderItems,
  896. giftItemIds: that.giftItemIds,
  897. remark: this.remark,
  898. addressId: that.selectedAddress.id,
  899. purchaseInfo: that.purchaseForm,
  900. pointsUsed: that.pointsUsed,
  901. discountAmount: that.discountInfo ? that.discountInfo.discountAmount : 0,
  902. deliveryMethod: that.deliveryMethod,
  903. pickupLocationId: that.selectedPickupLocation ? that.selectedPickupLocation.id : null,
  904. timeSlotId: that.selectedTimeSlot ? that.selectedTimeSlot.id : null,
  905. servicePersonId: that.selectedServicePerson ? that.selectedServicePerson.id : null
  906. },
  907. header: {
  908. 'Content-Type': 'application/json',
  909. 'Authorization': 'Bearer ' + uni.getStorageSync('token')
  910. },
  911. success: function(res) {
  912. that.submitting = false
  913. if (res.data && res.data.code === 200) {
  914. var order = res.data.data
  915. uni.showToast({ title: '下单成功', icon: 'success' })
  916. uni.removeStorageSync('checkoutItems')
  917. uni.removeStorageSync('checkoutGiftItemIds')
  918. var moneyAmount = order.moneyAmount != null ? order.moneyAmount : order.totalAmount
  919. var pointsUsed = order.pointsUsed || 0
  920. setTimeout(function() {
  921. uni.navigateTo({
  922. url: '/pages/shop/payment/payment?orderNo=' + order.orderNo + '&amount=' + moneyAmount + '&pointsUsed=' + pointsUsed
  923. })
  924. }, 1000)
  925. } else {
  926. uni.showToast({ title: res.data.message || '下单失败', icon: 'none' })
  927. }
  928. },
  929. fail: function() {
  930. that.submitting = false
  931. uni.showToast({ title: '网络请求失败', icon: 'none' })
  932. }
  933. })
  934. },
  935. formatPrice(price) {
  936. if (price === null || price === undefined) return '0.00'
  937. return (Number(price) / 100).toFixed(2)
  938. },
  939. formatPhone(phone) {
  940. if (!phone) return ''
  941. if (phone.length === 11) {
  942. return phone.substr(0, 3) + '****' + phone.substr(7)
  943. }
  944. return phone
  945. },
  946. selectServicePerson(person) {
  947. this.selectedServicePerson = person
  948. this.selectedTimeSlot = null
  949. this.showServicePersonModal = false
  950. },
  951. selectOnlineSlot(slot) {
  952. this.selectedTimeSlot = slot
  953. this.showOnlineSlotModal = false
  954. },
  955. formatOnlineTime: function(timeStr) {
  956. if (!timeStr) return ''
  957. try {
  958. var d = parseDate(timeStr)
  959. if (!d) return timeStr
  960. return (d.getMonth() + 1) + '月' + d.getDate() + '日 ' + String(d.getHours()).padStart(2, '0') + ':' + String(d.getMinutes()).padStart(2, '0')
  961. } catch (e) {
  962. return timeStr
  963. }
  964. },
  965. showPickupLocationPicker: function() {
  966. this.showPickupLocationModal = true
  967. },
  968. showTimeSlotPicker: function() {
  969. if (!this.selectedPickupLocation) return
  970. this.showTimeSlotModal = true
  971. },
  972. showServicePersonPicker: function() {
  973. this.showServicePersonModal = true
  974. },
  975. showOnlineSlotPicker: function() {
  976. this.showOnlineSlotModal = true
  977. },
  978. selectPickupLocation: function(loc) {
  979. this.selectedPickupLocation = loc
  980. this.selectedTimeSlot = null
  981. this.showPickupLocationModal = false
  982. },
  983. selectTimeSlot: function(slot) {
  984. this.selectedTimeSlot = slot
  985. this.showTimeSlotModal = false
  986. },
  987. selectServicePerson: function(person) {
  988. this.selectedServicePerson = person
  989. this.showServicePersonModal = false
  990. },
  991. getImageUrl: function(path) {
  992. return config.API_BASE_URL + path
  993. }
  994. }
  995. }
  996. </script>
  997. <style scoped>
  998. .container {
  999. min-height: 100vh;
  1000. background: #f5f5f5;
  1001. }
  1002. .loading-wrap {
  1003. display: flex;
  1004. justify-content: center;
  1005. padding-top: 200rpx;
  1006. }
  1007. .loading-text {
  1008. font-size: 28rpx;
  1009. color: #999;
  1010. }
  1011. .content {
  1012. height: calc(100vh - 120rpx);
  1013. }
  1014. .section {
  1015. background: #fff;
  1016. margin: 20rpx;
  1017. border-radius: 16rpx;
  1018. padding: 24rpx;
  1019. }
  1020. .section-title {
  1021. font-size: 28rpx;
  1022. font-weight: bold;
  1023. color: #333;
  1024. margin-bottom: 20rpx;
  1025. display: block;
  1026. }
  1027. .address-section {
  1028. position: relative;
  1029. }
  1030. .address-content {
  1031. position: relative;
  1032. }
  1033. .address-top {
  1034. display: flex;
  1035. align-items: center;
  1036. margin-bottom: 10rpx;
  1037. }
  1038. .receiver-name {
  1039. font-size: 30rpx;
  1040. font-weight: bold;
  1041. color: #333;
  1042. margin-right: 20rpx;
  1043. }
  1044. .receiver-phone {
  1045. font-size: 26rpx;
  1046. color: #666;
  1047. }
  1048. .default-badge {
  1049. font-size: 20rpx;
  1050. color: #F97316;
  1051. background: #fff7e6;
  1052. padding: 2rpx 12rpx;
  1053. border-radius: 20rpx;
  1054. margin-left: 12rpx;
  1055. }
  1056. .address-detail {
  1057. font-size: 26rpx;
  1058. color: #999;
  1059. line-height: 1.5;
  1060. }
  1061. .address-arrow {
  1062. position: absolute;
  1063. right: 0;
  1064. top: 50%;
  1065. font-size: 40rpx;
  1066. color: #ccc;
  1067. transform: translateY(-50%);
  1068. }
  1069. .address-empty {
  1070. display: flex;
  1071. align-items: center;
  1072. justify-content: center;
  1073. padding: 30rpx 0;
  1074. position: relative;
  1075. }
  1076. .address-empty-icon {
  1077. font-size: 40rpx;
  1078. margin-right: 12rpx;
  1079. }
  1080. .address-empty-text {
  1081. font-size: 28rpx;
  1082. color: #999;
  1083. }
  1084. .order-item {
  1085. display: flex;
  1086. align-items: center;
  1087. padding: 16rpx 0;
  1088. border-bottom: 1rpx solid #f5f5f5;
  1089. }
  1090. .order-item:last-child {
  1091. border-bottom: none;
  1092. }
  1093. .item-image {
  1094. width: 80rpx;
  1095. height: 80rpx;
  1096. border-radius: 8rpx;
  1097. background: #f0f0f0;
  1098. margin-right: 16rpx;
  1099. }
  1100. .item-info {
  1101. flex: 1;
  1102. display: flex;
  1103. flex-direction: column;
  1104. min-width: 0;
  1105. }
  1106. .item-name {
  1107. font-size: 26rpx;
  1108. color: #333;
  1109. overflow: hidden;
  1110. text-overflow: ellipsis;
  1111. white-space: nowrap;
  1112. margin-bottom: 6rpx;
  1113. }
  1114. .item-spec-desc {
  1115. font-size: 22rpx;
  1116. color: #999;
  1117. display: block;
  1118. margin-top: 2rpx;
  1119. }
  1120. .item-supplier-name {
  1121. font-size: 20rpx;
  1122. color: #0EA5E9;
  1123. display: block;
  1124. margin-top: 2rpx;
  1125. }
  1126. .item-qty {
  1127. font-size: 22rpx;
  1128. color: #999;
  1129. }
  1130. .item-price {
  1131. font-size: 26rpx;
  1132. color: #F97316;
  1133. font-weight: bold;
  1134. margin-left: 16rpx;
  1135. }
  1136. .info-row {
  1137. display: flex;
  1138. justify-content: space-between;
  1139. align-items: center;
  1140. padding: 8rpx 0;
  1141. }
  1142. .info-label {
  1143. font-size: 26rpx;
  1144. color: #999;
  1145. }
  1146. .info-value {
  1147. font-size: 26rpx;
  1148. color: #333;
  1149. }
  1150. .remark-input {
  1151. flex: 1;
  1152. text-align: right;
  1153. font-size: 26rpx;
  1154. color: #333;
  1155. }
  1156. /* ===== Coupon Section ===== */
  1157. .coupon-section {
  1158. position: relative;
  1159. }
  1160. .coupon-section:active {
  1161. background: #fafafa;
  1162. }
  1163. .coupon-selected {
  1164. display: flex;
  1165. align-items: center;
  1166. flex: 1;
  1167. justify-content: flex-end;
  1168. margin-right: 30rpx;
  1169. }
  1170. .coupon-discount {
  1171. font-size: 26rpx;
  1172. color: #F97316;
  1173. font-weight: 600;
  1174. margin-right: 12rpx;
  1175. }
  1176. .coupon-name-tag {
  1177. font-size: 22rpx;
  1178. color: #fff;
  1179. background: #F97316;
  1180. padding: 2rpx 12rpx;
  1181. border-radius: 6rpx;
  1182. max-width: 200rpx;
  1183. overflow: hidden;
  1184. text-overflow: ellipsis;
  1185. white-space: nowrap;
  1186. }
  1187. .coupon-placeholder {
  1188. flex: 1;
  1189. text-align: right;
  1190. margin-right: 30rpx;
  1191. }
  1192. .placeholder-text {
  1193. font-size: 26rpx;
  1194. color: #ccc;
  1195. }
  1196. .total-original {
  1197. font-size: 22rpx;
  1198. color: #bbb;
  1199. text-decoration: line-through;
  1200. margin-left: 8rpx;
  1201. }
  1202. /* ===== Member Upgrade Hint ===== */
  1203. .member-upgrade-section {
  1204. position: relative;
  1205. }
  1206. .member-upgrade-row {
  1207. display: flex;
  1208. align-items: center;
  1209. }
  1210. .member-upgrade-icon {
  1211. font-size: 32rpx;
  1212. margin-right: 12rpx;
  1213. }
  1214. .member-upgrade-text {
  1215. flex: 1;
  1216. font-size: 26rpx;
  1217. color: #F97316;
  1218. font-weight: 500;
  1219. }
  1220. .member-upgrade-arrow {
  1221. font-size: 32rpx;
  1222. color: #F97316;
  1223. }
  1224. /* ===== Member Coupon Hint ===== */
  1225. .member-coupon-hint {
  1226. margin-top: -10rpx;
  1227. margin-bottom: 20rpx;
  1228. }
  1229. .member-coupon-hint-content {
  1230. display: flex;
  1231. align-items: center;
  1232. padding: 20rpx 24rpx;
  1233. background: linear-gradient(135deg, #FFF7ED 0%, #FFEDD5 100%);
  1234. border-radius: 16rpx;
  1235. border: 1rpx solid #FED7AA;
  1236. }
  1237. .hint-icon {
  1238. font-size: 32rpx;
  1239. margin-right: 12rpx;
  1240. }
  1241. .hint-text {
  1242. font-size: 24rpx;
  1243. color: #C2410C;
  1244. font-weight: 500;
  1245. }
  1246. /* ===== Coupon Picker Modal ===== */
  1247. .modal-mask {
  1248. position: fixed;
  1249. top: 0;
  1250. left: 0;
  1251. right: 0;
  1252. bottom: 0;
  1253. background: rgba(0,0,0,0.5);
  1254. z-index: 999;
  1255. display: flex;
  1256. align-items: flex-end;
  1257. }
  1258. .coupon-picker {
  1259. background: #fff;
  1260. border-radius: 24rpx 24rpx 0 0;
  1261. width: 100%;
  1262. max-height: 70vh;
  1263. display: flex;
  1264. flex-direction: column;
  1265. }
  1266. .picker-header {
  1267. display: flex;
  1268. justify-content: space-between;
  1269. align-items: center;
  1270. padding: 30rpx;
  1271. border-bottom: 1rpx solid #eee;
  1272. }
  1273. .picker-title {
  1274. font-size: 30rpx;
  1275. font-weight: 600;
  1276. color: #333;
  1277. }
  1278. .picker-close {
  1279. font-size: 26rpx;
  1280. color: #999;
  1281. }
  1282. .picker-list {
  1283. max-height: 50vh;
  1284. padding: 0 20rpx;
  1285. }
  1286. .picker-item {
  1287. display: flex;
  1288. align-items: center;
  1289. padding: 24rpx 16rpx;
  1290. border-bottom: 1rpx solid #f5f5f5;
  1291. }
  1292. .picker-item:active {
  1293. background: #fafafa;
  1294. }
  1295. .picker-item-active {
  1296. background: #FFF7ED;
  1297. }
  1298. .picker-item-left {
  1299. width: 120rpx;
  1300. text-align: center;
  1301. flex-shrink: 0;
  1302. }
  1303. .picker-item-value {
  1304. font-size: 32rpx;
  1305. font-weight: bold;
  1306. color: #F97316;
  1307. }
  1308. .picker-item-right {
  1309. flex: 1;
  1310. margin: 0 16rpx;
  1311. }
  1312. .picker-item-name {
  1313. font-size: 26rpx;
  1314. color: #333;
  1315. display: block;
  1316. margin-bottom: 4rpx;
  1317. }
  1318. .picker-item-condition {
  1319. font-size: 22rpx;
  1320. color: #999;
  1321. }
  1322. .picker-item-check {
  1323. width: 40rpx;
  1324. height: 40rpx;
  1325. background: #F97316;
  1326. border-radius: 50%;
  1327. display: flex;
  1328. align-items: center;
  1329. justify-content: center;
  1330. flex-shrink: 0;
  1331. }
  1332. .check-icon {
  1333. color: #fff;
  1334. font-size: 24rpx;
  1335. font-weight: bold;
  1336. }
  1337. .picker-empty {
  1338. text-align: center;
  1339. padding: 60rpx 0;
  1340. font-size: 26rpx;
  1341. color: #999;
  1342. }
  1343. .picker-footer {
  1344. padding: 20rpx;
  1345. border-top: 1rpx solid #eee;
  1346. }
  1347. .picker-btn-remove {
  1348. background: #f5f5f5;
  1349. color: #666;
  1350. font-size: 26rpx;
  1351. border-radius: 12rpx;
  1352. border: none;
  1353. }
  1354. .picker-btn-remove::after {
  1355. border: none;
  1356. }
  1357. .bottom-spacer {
  1358. height: 140rpx;
  1359. }
  1360. .bottom-bar {
  1361. position: fixed;
  1362. bottom: 0;
  1363. left: 0;
  1364. right: 0;
  1365. height: 100rpx;
  1366. background: #fff;
  1367. border-top: 1rpx solid #eee;
  1368. display: flex;
  1369. align-items: center;
  1370. justify-content: space-between;
  1371. padding: 0 30rpx;
  1372. z-index: 100;
  1373. }
  1374. .bottom-left {
  1375. display: flex;
  1376. align-items: baseline;
  1377. }
  1378. .total-label {
  1379. font-size: 26rpx;
  1380. color: #666;
  1381. }
  1382. .total-amount {
  1383. font-size: 36rpx;
  1384. color: #F97316;
  1385. font-weight: bold;
  1386. }
  1387. .submit-btn {
  1388. background: linear-gradient(135deg, #F97316, #FB923C);
  1389. color: #fff;
  1390. font-size: 28rpx;
  1391. font-weight: bold;
  1392. padding: 0 60rpx;
  1393. height: 72rpx;
  1394. line-height: 72rpx;
  1395. border-radius: 36rpx;
  1396. border: none;
  1397. }
  1398. .submit-btn::after {
  1399. border: none;
  1400. }
  1401. .submit-btn.disabled {
  1402. background: #ddd;
  1403. color: #999;
  1404. }
  1405. .points-balance {
  1406. font-size: 24rpx;
  1407. color: #F97316;
  1408. }
  1409. .points-input-row {
  1410. display: flex;
  1411. align-items: center;
  1412. margin-top: 16rpx;
  1413. padding: 12rpx 0;
  1414. border-top: 1rpx solid #f5f5f5;
  1415. }
  1416. .points-input {
  1417. flex: 1;
  1418. height: 60rpx;
  1419. font-size: 28rpx;
  1420. color: #333;
  1421. background: #f9f9f9;
  1422. border-radius: 8rpx;
  1423. padding: 0 16rpx;
  1424. }
  1425. .points-hint {
  1426. font-size: 24rpx;
  1427. color: #999;
  1428. margin-left: 12rpx;
  1429. min-width: 100rpx;
  1430. text-align: right;
  1431. }
  1432. .points-tip {
  1433. margin-top: 8rpx;
  1434. }
  1435. .points-tip-text {
  1436. font-size: 22rpx;
  1437. color: #bbb;
  1438. }
  1439. .total-original {
  1440. font-size: 24rpx;
  1441. color: #bbb;
  1442. text-decoration: line-through;
  1443. margin-left: 8rpx;
  1444. }
  1445. /* ===== Purchase Info Fields ===== */
  1446. .purchase-field-row {
  1447. display: flex;
  1448. align-items: center;
  1449. padding: 16rpx 0;
  1450. border-bottom: 1rpx solid #f5f5f5;
  1451. }
  1452. .purchase-field-row:last-child {
  1453. border-bottom: none;
  1454. }
  1455. .purchase-field-label {
  1456. font-size: 26rpx;
  1457. color: #333;
  1458. width: 160rpx;
  1459. flex-shrink: 0;
  1460. }
  1461. .required-mark {
  1462. color: #f56c6c;
  1463. }
  1464. .purchase-field-input {
  1465. flex: 1;
  1466. font-size: 26rpx;
  1467. color: #333;
  1468. text-align: right;
  1469. padding: 8rpx 0;
  1470. }
  1471. .purchase-field-input[disabled] {
  1472. background: transparent;
  1473. color: #999;
  1474. }
  1475. .purchase-field-prefill {
  1476. font-size: 22rpx;
  1477. color: #67c23a;
  1478. margin-left: 8rpx;
  1479. }
  1480. /* 配送方式选择 */
  1481. .delivery-sub-label {
  1482. font-size: 24rpx;
  1483. color: #999;
  1484. margin-bottom: 12rpx;
  1485. margin-top: 16rpx;
  1486. }
  1487. .picker-row {
  1488. display: flex;
  1489. align-items: center;
  1490. justify-content: space-between;
  1491. padding: 20rpx 0;
  1492. border-bottom: 1rpx solid #f5f5f5;
  1493. }
  1494. .picker-row:last-child {
  1495. border-bottom: none;
  1496. }
  1497. .picker-value {
  1498. font-size: 28rpx;
  1499. color: #333;
  1500. flex: 1;
  1501. }
  1502. .picker-placeholder {
  1503. font-size: 28rpx;
  1504. color: #999;
  1505. flex: 1;
  1506. }
  1507. .picker-arrow {
  1508. font-size: 32rpx;
  1509. color: #ccc;
  1510. margin-left: 10rpx;
  1511. }
  1512. .modal-mask {
  1513. position: fixed;
  1514. top: 0;
  1515. left: 0;
  1516. right: 0;
  1517. bottom: 0;
  1518. background: rgba(0,0,0,0.5);
  1519. z-index: 999;
  1520. display: flex;
  1521. align-items: flex-end;
  1522. }
  1523. .picker-modal {
  1524. width: 100%;
  1525. background: #fff;
  1526. border-radius: 24rpx 24rpx 0 0;
  1527. max-height: 70vh;
  1528. display: flex;
  1529. flex-direction: column;
  1530. }
  1531. .picker-modal .picker-header {
  1532. display: flex;
  1533. justify-content: space-between;
  1534. align-items: center;
  1535. padding: 30rpx;
  1536. border-bottom: 1rpx solid #eee;
  1537. }
  1538. .picker-modal .picker-title {
  1539. font-size: 32rpx;
  1540. font-weight: bold;
  1541. color: #333;
  1542. }
  1543. .picker-modal .picker-close {
  1544. font-size: 28rpx;
  1545. color: #999;
  1546. }
  1547. .picker-modal .picker-list {
  1548. flex: 1;
  1549. max-height: 50vh;
  1550. padding: 20rpx 30rpx;
  1551. }
  1552. .picker-modal .picker-item {
  1553. display: flex;
  1554. align-items: center;
  1555. padding: 24rpx 0;
  1556. border-bottom: 1rpx solid #f5f5f5;
  1557. }
  1558. .picker-modal .picker-item:last-child {
  1559. border-bottom: none;
  1560. }
  1561. .picker-modal .picker-item-active {
  1562. background: #fff7e6;
  1563. border-radius: 12rpx;
  1564. padding: 24rpx 16rpx;
  1565. }
  1566. .picker-modal .picker-item-left {
  1567. flex: 1;
  1568. min-width: 0;
  1569. }
  1570. .picker-modal .picker-item-name {
  1571. font-size: 28rpx;
  1572. color: #333;
  1573. display: block;
  1574. }
  1575. .picker-modal .picker-item-addr {
  1576. font-size: 24rpx;
  1577. color: #999;
  1578. margin-top: 6rpx;
  1579. display: block;
  1580. }
  1581. .picker-modal .picker-item-desc {
  1582. font-size: 24rpx;
  1583. color: #999;
  1584. margin-top: 4rpx;
  1585. display: block;
  1586. }
  1587. .picker-modal .picker-item-price {
  1588. font-size: 26rpx;
  1589. color: #F97316;
  1590. font-weight: bold;
  1591. margin-top: 4rpx;
  1592. display: block;
  1593. }
  1594. .picker-modal .picker-item-check {
  1595. margin-left: 16rpx;
  1596. color: #F97316;
  1597. font-size: 32rpx;
  1598. }
  1599. </style>