checkout.vue 48 KB

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