checkout.vue 50 KB

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