checkout.vue 66 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021
  1. <template>
  2. <view class="container" :style="{ '--font-scale': fontScale }">
  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. v-if="field.fieldKey !== 'hand_signature'"
  106. :key="field.fieldKey"
  107. class="purchase-field-row"
  108. >
  109. <text class="purchase-field-label">
  110. {{ field.fieldName }}
  111. <text v-if="field.isRequired" class="required-mark">*</text>
  112. </text>
  113. <input
  114. v-model="purchaseForm[field.fieldKey]"
  115. class="purchase-field-input"
  116. :placeholder="'请输入' + field.fieldName + (field.isRequired ? '' : '(选填)')"
  117. :disabled="!!field.prefillValue"
  118. :placeholder-style="placeholderStyle"
  119. />
  120. <text v-if="field.prefillValue" class="purchase-field-prefill">已填写</text>
  121. </view>
  122. <!-- 手签名购买信息:手写签名组件,签名数据 base64 直接存 purchaseForm -->
  123. <view v-if="hasHandSignatureField" class="purchase-signature-block">
  124. <view class="purchase-signature-title">✍️ 手写签名</view>
  125. <hand-signature
  126. :value="purchaseForm.hand_signature"
  127. :require-agree="true"
  128. agree-text="我已阅读并同意,确认以上填写信息真实、准确,且由本人签署"
  129. @confirm="onHandSignatureConfirm"
  130. @clear="onHandSignatureClear"
  131. @agree-change="onHandSignatureAgreeChange"
  132. />
  133. </view>
  134. </view>
  135. <!-- Order Items Section -->
  136. <view class="section">
  137. <text class="section-title">商品信息</text>
  138. <view
  139. v-for="item in items"
  140. :key="item.productId"
  141. class="order-item"
  142. >
  143. <image
  144. class="item-image"
  145. :src="getImageUrl(item.coverImage) || '/static/default-product.png'"
  146. mode="aspectFill"
  147. lazy-load />
  148. <view class="item-info">
  149. <text class="item-name">{{ item.productName }}</text>
  150. <text v-if="item.specDesc" class="item-spec-desc">{{ item.specDesc }}</text>
  151. <text v-if="item.supplierName" class="item-supplier-name">供应商: {{ item.supplierName }}</text>
  152. <text class="item-qty">x{{ item.quantity }}</text>
  153. </view>
  154. <text class="item-price">{{ formatPriceWithSymbol(effectivePrice(item)) }}</text>
  155. </view>
  156. </view>
  157. <!-- 赠会员提示 -->
  158. <view v-if="giftLevelNames.length > 0" class="section gift-member-section">
  159. <view class="gift-member-row">
  160. <text class="gift-member-icon">🎁</text>
  161. <text class="gift-member-text">本单含{{ giftLevelNames.join('、') }}赠送商品,支付成功后将自动开通会员</text>
  162. </view>
  163. </view>
  164. <!-- 赠会员累计进度 -->
  165. <view v-if="giftProgress && !giftIsGranted && giftProgress.threshold > 0" class="section gift-progress-section">
  166. <view class="gift-progress-header">
  167. <text class="gift-progress-icon">🎁</text>
  168. <text class="gift-progress-title">购会员商品累计进度</text>
  169. <text class="gift-progress-percent">{{ giftProgressPercent }}%</text>
  170. </view>
  171. <view class="gift-progress-bar-bg">
  172. <view class="gift-progress-bar-fill" :style="{ width: giftProgressPercent + '%' }"></view>
  173. </view>
  174. <view class="gift-progress-info">
  175. <text class="gift-progress-accumulated">已累 {{ giftAccumulatedYuan }} 元</text>
  176. <text class="gift-progress-remaining">还差 {{ giftRemainingYuan }} 元送会员</text>
  177. </view>
  178. <text class="gift-progress-note">单笔订单送会员商品原价达标即送,折扣订单也计入</text>
  179. <view v-if="giftProgress.grantedLevel" class="gift-progress-level">
  180. <text>达标将赠送 {{ giftProgress.grantedLevel === 'FAMILY' ? '家庭会员' : giftProgress.grantedLevel }} 权益</text>
  181. </view>
  182. </view>
  183. <view v-else-if="giftIsGranted" class="section gift-granted-section">
  184. <view class="gift-granted-row">
  185. <text class="gift-granted-icon">✅</text>
  186. <text class="gift-granted-text">本家庭已赠送会员,可前往会员中心查看</text>
  187. </view>
  188. </view>
  189. <!-- Freight Section -->
  190. <view class="section">
  191. <view class="info-row">
  192. <text class="info-label">运费</text>
  193. <text class="info-value">{{ formatPriceWithSymbol(freight) }}</text>
  194. </view>
  195. </view>
  196. <!-- Member Upgrade Hint -->
  197. <view v-if="!isMember" class="section member-upgrade-section" @click="goUpgrade">
  198. <view class="member-upgrade-row">
  199. <text class="member-upgrade-icon">👑</text>
  200. <text class="member-upgrade-text">开通会员享全场商品专享价</text>
  201. <text class="member-upgrade-arrow">›</text>
  202. </view>
  203. </view>
  204. <!-- Limited-Time Discount Section -->
  205. <view v-if="discountInfo" class="section discount-section">
  206. <view class="info-row">
  207. <text class="info-label">限时折扣</text>
  208. <text class="discount-amount">-{{ formatPriceWithSymbol(discountInfo.discountAmount) }}</text>
  209. </view>
  210. <view class="discount-rule-name">{{ discountInfo.ruleName || '' }}</view>
  211. <countdown-tag v-if="discountInfo.endTime" :end-time="discountInfo.endTime" />
  212. </view>
  213. <!-- Gift Promo Section -->
  214. <view v-if="giftPromo && giftPromo.active" class="section gift-promo-section">
  215. <view class="gift-promo-row">
  216. <text class="gift-promo-icon">🎁</text>
  217. <view class="gift-promo-content">
  218. <text class="gift-promo-title">送会员一口价</text>
  219. <text class="gift-promo-desc">送会员商品原价 {{ formatPriceWithSymbol(giftPromo.giftOriginalTotal) }} 元 → 实付 {{ formatPriceWithSymbol(giftPromo.payPrice) }} 元</text>
  220. <text class="gift-promo-save">已优惠 {{ formatPriceWithSymbol(giftPromoDiscount) }} 元</text>
  221. </view>
  222. </view>
  223. </view>
  224. <!-- Coupon Section -->
  225. <view v-if="!isSpecialCouponDisabled" class="section coupon-section" @click="openCouponPicker">
  226. <view class="info-row">
  227. <text class="info-label">优惠券</text>
  228. <view class="coupon-selected" v-if="selectedCoupon">
  229. <text class="coupon-discount">-{{ formatPriceWithSymbol(couponDiscount) }}</text>
  230. <text class="coupon-name-tag">{{ selectedCoupon.name }}</text>
  231. </view>
  232. <view class="coupon-placeholder" v-else>
  233. <text class="placeholder-text">选择优惠券</text>
  234. </view>
  235. <text class="address-arrow">›</text>
  236. </view>
  237. </view>
  238. <view v-if="!isMember" class="section member-coupon-hint">
  239. <view class="member-coupon-hint-content">
  240. <text class="hint-icon">👑</text>
  241. <text class="hint-text">加入会员可使用优惠券享更多优惠</text>
  242. </view>
  243. </view>
  244. <!-- Points Deduction Section -->
  245. <view class="section" v-if="userTotalPoints > 0">
  246. <view class="info-row">
  247. <text class="info-label">积分抵扣</text>
  248. <text class="points-balance">可用 {{ userTotalPoints }} 积分</text>
  249. </view>
  250. <view class="points-input-row">
  251. <input
  252. class="points-input"
  253. type="number"
  254. :value="pointsUsed"
  255. @input="onPointsInput"
  256. placeholder="输入使用积分"
  257. :placeholder-style="placeholderStyle"
  258. />
  259. <text class="points-hint">≈ ¥{{ pointsYuanEquivalent }}</text>
  260. </view>
  261. <view class="points-tip">
  262. <text class="points-tip-text">1积分 = ¥0.01,最多使用 {{ maxPoints }} 积分</text>
  263. </view>
  264. </view>
  265. <!-- Remark Section -->
  266. <view class="section">
  267. <view class="info-row">
  268. <text class="info-label">备注</text>
  269. <input
  270. class="remark-input"
  271. v-model="remark"
  272. placeholder="选填,给商家留言"
  273. :placeholder-style="placeholderStyle"
  274. />
  275. </view>
  276. </view>
  277. <view class="bottom-spacer"></view>
  278. </scroll-view>
  279. <!-- 优惠券选择器必须与 scroll-view 平级,否则 iOS 上 position: fixed 在 scroll-view 内不生效(优惠券弹窗不显示) -->
  280. <view class="modal-mask" v-if="showCouponPicker" @click="closeCouponPicker">
  281. <view class="coupon-picker" @click.stop>
  282. <view class="picker-header">
  283. <text class="picker-title">选择优惠券</text>
  284. <text class="picker-close" @click="closeCouponPicker">关闭</text>
  285. </view>
  286. <scroll-view scroll-y class="picker-list">
  287. <!-- 已拥有优惠券 -->
  288. <view class="picker-section-title" v-if="ownedCoupons.length > 0">已拥有优惠券</view>
  289. <view
  290. v-for="coupon in ownedCoupons"
  291. :key="coupon.id"
  292. class="picker-item"
  293. :class="selectedCoupon && selectedCoupon.id === coupon.id ? 'picker-item-active' : ''"
  294. @click="selectCoupon(coupon)"
  295. >
  296. <view class="picker-item-left">
  297. <text class="picker-item-value">{{ formatPriceWithSymbol(coupon.value) }}</text>
  298. </view>
  299. <view class="picker-item-right">
  300. <text class="picker-item-name">{{ coupon.name }}</text>
  301. <text class="picker-item-condition">{{ getConditionText(coupon.minSpend) }}</text>
  302. </view>
  303. <view class="picker-item-check" v-if="selectedCoupon && selectedCoupon.id === coupon.id">
  304. <text class="check-icon">✓</text>
  305. </view>
  306. </view>
  307. <!-- 可兑换优惠券(需CF值):仅在 CF 足够兑换其中一张券时才提醒 -->
  308. <view class="picker-section-title" v-if="affordableExchangeCoupons.length > 0">
  309. 可用CF值兑换(当前余额 {{ cfBalance }} CF)
  310. </view>
  311. <view
  312. v-for="coupon in affordableExchangeCoupons"
  313. :key="coupon.id"
  314. class="picker-item picker-item-exchange"
  315. >
  316. <view class="picker-item-left">
  317. <text class="picker-item-value">{{ formatPriceWithSymbol(coupon.value) }}</text>
  318. </view>
  319. <view class="picker-item-right">
  320. <text class="picker-item-name">{{ coupon.name }}</text>
  321. <text class="picker-item-condition">{{ getConditionText(coupon.minSpend) }}</text>
  322. </view>
  323. <button
  324. class="exchange-btn"
  325. :disabled="coupon.exchanging"
  326. @click.stop="doExchangeCoupon(coupon)"
  327. >
  328. {{ coupon.exchanging ? '兑换中...' : '兑换' }}
  329. </button>
  330. </view>
  331. <view class="picker-empty" v-if="ownedCoupons.length === 0 && affordableExchangeCoupons.length === 0">
  332. <text>暂无可用优惠券</text>
  333. </view>
  334. </scroll-view>
  335. <view class="picker-footer" v-if="selectedCoupon">
  336. <button class="picker-btn-remove" @click="removeCoupon">不使用优惠券</button>
  337. </view>
  338. </view>
  339. </view>
  340. <!-- 自取地点选择器 -->
  341. <view class="modal-mask" v-if="showPickupLocationModal" @click="showPickupLocationModal=false">
  342. <view class="picker-modal" @click.stop>
  343. <view class="picker-header">
  344. <text class="picker-title">选择自取地点</text>
  345. <text class="picker-close" @click="showPickupLocationModal=false">关闭</text>
  346. </view>
  347. <scroll-view scroll-y class="picker-list">
  348. <view
  349. v-for="(loc, idx) in pickupLocations"
  350. :key="loc.id"
  351. class="picker-item"
  352. :class="selectedPickupLocation && selectedPickupLocation.id === loc.id ? 'picker-item-active' : ''"
  353. @click="selectPickupLocation(loc)"
  354. >
  355. <view class="picker-item-left">
  356. <text class="picker-item-name">{{ loc.name }}</text>
  357. <text class="picker-item-addr">{{ loc.address }}</text>
  358. </view>
  359. <view class="picker-item-check" v-if="selectedPickupLocation && selectedPickupLocation.id === loc.id">
  360. <text class="check-icon">✓</text>
  361. </view>
  362. </view>
  363. </scroll-view>
  364. </view>
  365. </view>
  366. <!-- 时间段选择器 -->
  367. <view class="modal-mask" v-if="showTimeSlotModal" @click="showTimeSlotModal=false">
  368. <view class="picker-modal" @click.stop>
  369. <view class="picker-header">
  370. <text class="picker-title">选择取货时间</text>
  371. <text class="picker-close" @click="showTimeSlotModal=false">关闭</text>
  372. </view>
  373. <scroll-view scroll-y class="picker-list">
  374. <view
  375. v-for="(slot, idx) in (selectedPickupLocation && selectedPickupLocation.timeSlots) || []"
  376. :key="slot.id"
  377. class="picker-item"
  378. :class="selectedTimeSlot && selectedTimeSlot.id === slot.id ? 'picker-item-active' : ''"
  379. @click="selectTimeSlot(slot)"
  380. >
  381. <view class="picker-item-left">
  382. <text class="picker-item-name">{{ slot.startTime }} - {{ slot.endTime }}</text>
  383. </view>
  384. <view class="picker-item-check" v-if="selectedTimeSlot && selectedTimeSlot.id === slot.id">
  385. <text class="check-icon">✓</text>
  386. </view>
  387. </view>
  388. </scroll-view>
  389. </view>
  390. </view>
  391. <!-- 服务者选择器 -->
  392. <view class="modal-mask" v-if="showServicePersonModal" @click="showServicePersonModal=false">
  393. <view class="picker-modal" @click.stop>
  394. <view class="picker-header">
  395. <text class="picker-title">选择服务者</text>
  396. <text class="picker-close" @click="showServicePersonModal=false">关闭</text>
  397. </view>
  398. <scroll-view scroll-y class="picker-list">
  399. <view
  400. v-for="(person, idx) in servicePersons"
  401. :key="person.id"
  402. class="picker-item"
  403. :class="selectedServicePerson && selectedServicePerson.id === person.id ? 'picker-item-active' : ''"
  404. @click="selectServicePerson(person)"
  405. >
  406. <view class="picker-item-left">
  407. <text class="picker-item-name">{{ person.name }}</text>
  408. <text class="picker-item-desc">{{ person.title || '' }}</text>
  409. <text class="picker-item-price">{{ formatPriceWithSymbol(person.price) }}</text>
  410. </view>
  411. <view class="picker-item-check" v-if="selectedServicePerson && selectedServicePerson.id === person.id">
  412. <text class="check-icon">✓</text>
  413. </view>
  414. </view>
  415. </scroll-view>
  416. </view>
  417. </view>
  418. <!-- 线上时间段选择器 -->
  419. <view class="modal-mask" v-if="showOnlineSlotModal" @click="showOnlineSlotModal=false">
  420. <view class="picker-modal" @click.stop>
  421. <view class="picker-header">
  422. <text class="picker-title">选择服务时间</text>
  423. <text class="picker-close" @click="showOnlineSlotModal=false">关闭</text>
  424. </view>
  425. <scroll-view scroll-y class="picker-list">
  426. <view
  427. v-for="slot in onlineTimeSlots"
  428. :key="slot.id"
  429. class="picker-item"
  430. :class="selectedTimeSlot && selectedTimeSlot.id === slot.id ? 'picker-item-active' : ''"
  431. @click="selectOnlineSlot(slot)"
  432. >
  433. <view class="picker-item-left">
  434. <text class="picker-item-name">{{ formatOnlineTime(slot.startTime) }} - {{ formatOnlineTime(slot.endTime) }}</text>
  435. </view>
  436. <view class="picker-item-check" v-if="selectedTimeSlot && selectedTimeSlot.id === slot.id">
  437. <text class="check-icon">✓</text>
  438. </view>
  439. </view>
  440. </scroll-view>
  441. </view>
  442. </view>
  443. <view class="bottom-bar">
  444. <view class="bottom-left">
  445. <text class="total-label">合计: </text>
  446. <text class="total-amount">{{ formatPriceWithSymbol(finalAmount) }}</text>
  447. <text v-if="selectedCoupon" class="total-original">{{ formatPriceWithSymbol(actualAmount + freight) }}</text>
  448. </view>
  449. <button
  450. :class="['submit-btn', submitting ? 'disabled' : '']"
  451. :disabled="submitting"
  452. @click="onSubmit"
  453. >提交订单</button>
  454. </view>
  455. </view>
  456. </template>
  457. <script>
  458. import { BrandColors } from '@/utils/brand-colors.js'
  459. import config from '@/config.js'
  460. import { getCouponList, getCouponCheckoutList, addressList, getProductRequiredFields, getMyMembership, getGiftMembershipProgress, productDetail, getFamilyPlatformBalance, exchangeCouponByCf, shopDiscountCalculate, getSpecialPriceInfo, applyCoupon } from '../../../utils/api.js'
  461. import { parseDate } from '@/utils/format.js'
  462. import CountdownTag from '@/pages/shop/components/countdown-tag.vue'
  463. import HandSignature from '@/components/hand-signature/hand-signature.vue'
  464. import fontScaleMixin from '@/mixins/font-scale.js'
  465. export default {
  466. mixins: [fontScaleMixin],
  467. components: {
  468. CountdownTag,
  469. HandSignature
  470. },
  471. data() {
  472. return {
  473. placeholderStyle: 'color:' + BrandColors.textGhost + '; font-size: calc(26rpx * var(--font-scale, 1));',
  474. items: [],
  475. selectedAddress: null,
  476. requiredFields: [], // 需要的购买信息字段
  477. purchaseForm: {}, // 用户填写的购买信息
  478. addressList: [],
  479. freight: 0,
  480. remark: '',
  481. loading: false,
  482. submitting: false,
  483. actualAmount: 0,
  484. coupons: [],
  485. exchangeableCoupons: [],
  486. cfBalance: 0,
  487. selectedCoupon: null,
  488. couponDiscount: 0, // 服务端 /api/coupon/apply 返回的抵扣金额(分),前端只展示
  489. couponApplying: false,
  490. showCouponPicker: false,
  491. pointsUsed: 0,
  492. userTotalPoints: 0,
  493. pointsLoading: false,
  494. isMember: false,
  495. // 配送配置
  496. deliveryMethod: 1,
  497. productDeliveryConfig: null,
  498. pickupLocations: [],
  499. selectedPickupLocation: null,
  500. selectedTimeSlot: null,
  501. servicePersons: [],
  502. selectedServicePerson: null,
  503. onlineSlots: [],
  504. // 弹窗控制
  505. showPickupLocationModal: false,
  506. showTimeSlotModal: false,
  507. showServicePersonModal: false,
  508. showOnlineSlotModal: false,
  509. giftItemIds: [],
  510. giftProgress: null, // 赠会员累计进度
  511. discountInfo: null,
  512. giftPromo: null, // 送会员一口价促销信息
  513. taskId: null, // 购买任务打卡:透传至支付页
  514. // 限时特价(扫码闪购):由 product-detail 经 storage 一次性带入,onLoad 消费后即清除
  515. checkoutSpecialDealId: null,
  516. specialDeal: null
  517. }
  518. },
  519. computed: {
  520. // 当前商品是否要求手签名(ProductPurchaseFieldService 预定义字段 hand_signature)
  521. hasHandSignatureField() {
  522. var fields = this.requiredFields || []
  523. for (var i = 0; i < fields.length; i++) {
  524. if (fields[i].fieldKey === 'hand_signature') return true
  525. }
  526. return false
  527. },
  528. giftAccumulatedYuan() {
  529. if (!this.giftProgress || !this.giftProgress.accumulatedAmount) return 0
  530. return this.giftProgress.accumulatedAmount / 100
  531. },
  532. giftThresholdYuan() {
  533. if (!this.giftProgress || !this.giftProgress.threshold) return 0
  534. return this.giftProgress.threshold / 100
  535. },
  536. giftRemainingYuan() {
  537. if (!this.giftProgress || !this.giftProgress.remaining) return 0
  538. return this.giftProgress.remaining / 100
  539. },
  540. giftProgressPercent() {
  541. if (!this.giftProgress || !this.giftProgress.threshold || this.giftProgress.threshold <= 0) return 0
  542. if (!this.giftProgress.accumulatedAmount) return 0
  543. return Math.min(100, Math.round(this.giftProgress.accumulatedAmount / this.giftProgress.threshold * 100))
  544. },
  545. giftIsGranted() {
  546. return this.giftProgress && this.giftProgress.granted === 1
  547. },
  548. giftPromoDiscount() {
  549. if (!this.giftPromo || this.giftPromo.active !== true) return 0
  550. return this.giftPromo.discount || 0
  551. },
  552. // 限时特价(扫码闪购):特价单且活动禁止优惠券时隐藏优惠券选择区。
  553. // 活动信息未返回(加载中/失败)时默认视为不可用券(特价单保守处理)。
  554. isSpecialCouponDisabled() {
  555. if (!this.checkoutSpecialDealId) return false
  556. return !this.specialDeal || this.specialDeal.allowCoupon === 0
  557. },
  558. giftLevelNames() {
  559. var names = []
  560. for (var i = 0; i < this.items.length; i++) {
  561. if (this.items[i].giftLevelName && names.indexOf(this.items[i].giftLevelName) < 0) {
  562. names.push(this.items[i].giftLevelName)
  563. }
  564. }
  565. return names
  566. },
  567. finalAmount() {
  568. var total = (this.actualAmount || 0) + (this.freight || 0)
  569. total = total - (this.couponDiscount || 0)
  570. total = total - (this.pointsUsed || 0)
  571. total = total - this.giftPromoDiscount
  572. if (total < 0) total = 0
  573. return total
  574. },
  575. maxPoints() {
  576. var total = (this.actualAmount || 0) + (this.freight || 0)
  577. total = total - (this.couponDiscount || 0)
  578. if (total < 0) total = 0
  579. if (this.userTotalPoints < total) {
  580. return this.userTotalPoints
  581. }
  582. return total
  583. },
  584. pointsYuanEquivalent() {
  585. return (this.pointsUsed / 100).toFixed(2)
  586. },
  587. ownedCoupons() {
  588. var self = this
  589. var currentProductId = (self.items && self.items.length > 0) ? self.items[0].productId : null
  590. return this.coupons.filter(function(c) {
  591. if (c.status && c.status !== 'AVAILABLE') return false
  592. if (c.minSpend && c.minSpend > self.actualAmount) return false
  593. if (c.applicableTo === 'PRODUCT' && c.productId != null) {
  594. return c.productId === currentProductId
  595. }
  596. if (c.applicableTo && c.applicableTo !== 'ALL' && c.applicableTo !== 'PRODUCT') return false
  597. return true
  598. })
  599. },
  600. affordableExchangeCoupons() {
  601. var self = this
  602. return (this.exchangeableCoupons || []).filter(function(c) {
  603. return c.pointsPrice > 0 && self.cfBalance >= c.pointsPrice
  604. })
  605. },
  606. onlineTimeSlots() {
  607. if (this.deliveryMethod === 4 && this.selectedServicePerson) {
  608. return this.selectedServicePerson.slots || []
  609. }
  610. if (this.deliveryMethod === 5) {
  611. return this.onlineSlots
  612. }
  613. return []
  614. }
  615. },
  616. onLoad(options) {
  617. var that = this
  618. var stored = uni.getStorageSync('checkoutItems')
  619. var giftIds = uni.getStorageSync('checkoutGiftItemIds')
  620. var giftPromo = uni.getStorageSync('checkoutGiftPromo')
  621. this.giftItemIds = (giftIds && giftIds.length > 0) ? giftIds : []
  622. this.giftPromo = giftPromo || null
  623. if (stored && stored.length > 0) {
  624. this.items = stored
  625. this.calcAmount()
  626. } else if (options.productId) {
  627. // Load product directly from detail page
  628. var productData = {
  629. productId: parseInt(options.productId),
  630. productName: options.productName || '商品',
  631. coverImage: options.coverImage || '',
  632. unitPrice: parseInt(options.price) || 0,
  633. quantity: parseInt(options.quantity) || 1
  634. }
  635. if (options.skuId) {
  636. productData.skuId = parseInt(options.skuId)
  637. }
  638. this.items = [productData]
  639. this.calcAmount()
  640. }
  641. this.checkMemberStatus()
  642. this.loadDefaultAddress()
  643. // 购买任务打卡:接受 taskId 并透传至支付页
  644. this.taskId = options && options.taskId ? parseInt(options.taskId) : null
  645. this.loadRequiredFields()
  646. this.loadCoupons()
  647. this.loadExchangeableCoupons()
  648. this.loadCfBalance()
  649. this.loadUserPoints()
  650. this.loadDeliveryConfig()
  651. this.loadDiscount()
  652. this.loadGiftProgress()
  653. // 限时特价(扫码闪购):一次性消费 storage key —— 防止普通购物车入口误挂特价单。
  654. // 仅产品详情扫码进 checkout 场景才会携带此 key;其他入口(购物车、商品直接加购)不写该 key。
  655. this.checkoutSpecialDealId = uni.getStorageSync('checkoutSpecialDealId') || null
  656. uni.removeStorageSync('checkoutSpecialDealId')
  657. if (this.checkoutSpecialDealId) {
  658. this.loadCheckoutSpecialDeal()
  659. }
  660. this._onLoadFired = true
  661. },
  662. onShow() {
  663. // 从地址选择/编辑页返回后重新加载地址列表(首次进入跳过,避免与 onLoad 双发)
  664. if (this._onLoadFired) {
  665. this._onLoadFired = false
  666. } else {
  667. this.loadDefaultAddress()
  668. }
  669. },
  670. methods: {
  671. effectivePrice(item) {
  672. if (!item) return 0
  673. var price = item.unitPrice || 0
  674. // 会员可享会员价
  675. if (this.isMember && item.memberPrice && item.memberPrice > 0 && item.memberPrice < price) {
  676. price = item.memberPrice
  677. }
  678. return price
  679. },
  680. calcAmount() {
  681. var total = 0
  682. for (var i = 0; i < this.items.length; i++) {
  683. total = total + (this.items[i].unitPrice * this.items[i].quantity)
  684. }
  685. this.actualAmount = total
  686. },
  687. async loadCoupons() {
  688. try {
  689. var res = await getCouponList()
  690. this.coupons = res.data || []
  691. } catch (e) {
  692. this.coupons = []
  693. }
  694. },
  695. async loadExchangeableCoupons() {
  696. try {
  697. var productId = null
  698. if (this.items && this.items.length > 0) {
  699. productId = this.items[0].productId
  700. }
  701. var res = await getCouponCheckoutList({ productId: productId })
  702. this.exchangeableCoupons = res.data || []
  703. } catch (e) {
  704. console.error('加载可兑换优惠券失败', e)
  705. this.exchangeableCoupons = []
  706. }
  707. },
  708. async loadCfBalance() {
  709. try {
  710. var res = await getFamilyPlatformBalance()
  711. if (res.code === 200 && res.data) {
  712. this.cfBalance = res.data.available || 0
  713. }
  714. } catch (e) {
  715. console.error('加载CF余额失败', e)
  716. }
  717. },
  718. async doExchangeCoupon(coupon) {
  719. if (coupon.pointsPrice > this.cfBalance) {
  720. uni.showToast({ title: 'CF值不足,当前可用 ' + this.cfBalance + ' CF值', icon: 'none' })
  721. return
  722. }
  723. coupon.exchanging = true
  724. uni.showLoading({ title: '兑换中...' })
  725. try {
  726. // 注意:此处 coupon.id 是「券模板ID」(来自 /coupon/checkout-list)
  727. var res = await exchangeCouponByCf({ couponId: coupon.id })
  728. uni.hideLoading()
  729. coupon.exchanging = false
  730. if (res.code === 200) {
  731. uni.showToast({ title: '兑换成功', icon: 'success' })
  732. // 兑换成功后有两点必须重新拉列表,不能在本地把 template 券挪进已拥有列表:
  733. // 1. /coupon/list 里的 id 是「券实例ID(family_coupon.id)」,而下单 couponId 要传的就是它;
  734. // 本地挪进去的 coupon.id 是券模板ID,直接选中会导致后端 familyCouponMapper.selectById 查不到、
  735. // 优惠沉默不生效。重新拉列表才能拿到正确的券实例ID。
  736. // 2. /coupon/checkout-list 由后端过滤「家庭未拥有」,刷新后才能把刚换的券移出可兑换区。
  737. await Promise.all([this.loadCoupons(), this.loadExchangeableCoupons()])
  738. // 刷新 CF 余额(刚扣掉一笔)
  739. this.loadCfBalance()
  740. // 兑换后已自动选中:后端返回券实例ID(family_coupon.id,
  741. // 与 /coupon/list 里的 id/userCouponId 同值),匹配到即选中并交由服务端算折扣。
  742. // 匹配不到(列表未刷到/券已失效)不报错,维持未选中的现状。
  743. var newCouponId = parseInt(res.data)
  744. if (!isNaN(newCouponId) && newCouponId > 0) {
  745. var matched = null
  746. var myCoupons = this.coupons || []
  747. for (var i = 0; i < myCoupons.length; i++) {
  748. if (myCoupons[i] && parseInt(myCoupons[i].id) === newCouponId) {
  749. matched = myCoupons[i]
  750. break
  751. }
  752. }
  753. if (matched) {
  754. this.selectedCoupon = matched
  755. // 门槛/范围不满足时该方法会自动清空选中并提示,属预期(券已入账我的优惠券)
  756. this.applyCouponDiscount()
  757. }
  758. }
  759. } else {
  760. uni.showToast({ title: res.message || '兑换失败', icon: 'none' })
  761. }
  762. } catch (e) {
  763. uni.hideLoading()
  764. coupon.exchanging = false
  765. uni.showToast({ title: '兑换失败', icon: 'none' })
  766. }
  767. },
  768. openCouponPicker() {
  769. if (this.ownedCoupons.length === 0 && !this.selectedCoupon) {
  770. uni.showToast({ title: '暂无可用优惠券', icon: 'none' })
  771. return
  772. }
  773. this.showCouponPicker = true
  774. },
  775. closeCouponPicker() {
  776. this.showCouponPicker = false
  777. },
  778. selectCoupon(coupon) {
  779. this.selectedCoupon = coupon
  780. this.showCouponPicker = false
  781. this.applyCouponDiscount()
  782. },
  783. removeCoupon() {
  784. this.selectedCoupon = null
  785. this.couponDiscount = 0
  786. this.showCouponPicker = false
  787. },
  788. // 优惠券抵扣统一由服务端计算(券类型/满减门槛/会员范围/折扣千分比),
  789. // 前端不再用 selectedCoupon.value 本地减额,保证展示与下单落库一致。
  790. async applyCouponDiscount() {
  791. if (!this.selectedCoupon) {
  792. this.couponDiscount = 0
  793. return
  794. }
  795. var applyingCouponId = this.selectedCoupon.id
  796. this.couponApplying = true
  797. try {
  798. var res = await applyCoupon({
  799. userCouponId: this.selectedCoupon.id,
  800. orderType: 'PRODUCT',
  801. orderAmount: this.actualAmount || 0
  802. })
  803. // 期间用户可能已改选/取消券,丢弃过期响应
  804. if (!this.selectedCoupon || this.selectedCoupon.id !== applyingCouponId) {
  805. return
  806. }
  807. this.couponDiscount = (res && res.data && res.data.discount) || 0
  808. } catch (e) {
  809. if (this.selectedCoupon && this.selectedCoupon.id === applyingCouponId) {
  810. // 服务端判定不可用(request 已提示 message),本地同步清空避免错误展示
  811. this.selectedCoupon = null
  812. this.couponDiscount = 0
  813. }
  814. } finally {
  815. this.couponApplying = false
  816. }
  817. },
  818. onPointsInput(e) {
  819. var val = parseInt(e.detail.value) || 0
  820. if (val < 0) val = 0
  821. var maxP = this.maxPoints
  822. if (val > maxP) {
  823. val = maxP
  824. uni.showToast({ title: '最多使用 ' + maxP + ' 积分', icon: 'none' })
  825. }
  826. this.pointsUsed = val
  827. },
  828. getConditionText(minSpend) {
  829. if (!minSpend || minSpend <= 0) return '无门槛'
  830. return '满' + (minSpend / 100).toFixed(2) + '元可用'
  831. },
  832. async loadDefaultAddress() {
  833. this.loading = true
  834. try {
  835. var res = await addressList()
  836. if (res.code === 200) {
  837. var list = res.data || []
  838. this.addressList = list
  839. // 如果当前已有选中地址,保持选中状态
  840. if (this.selectedAddress) {
  841. var stillExists = false
  842. for (var k = 0; k < list.length; k++) {
  843. if (list[k].id === this.selectedAddress.id) {
  844. stillExists = true
  845. break
  846. }
  847. }
  848. if (!stillExists) {
  849. this.selectedAddress = null
  850. }
  851. }
  852. if (!this.selectedAddress) {
  853. for (var i = 0; i < list.length; i++) {
  854. if (list[i].isDefault === 1) {
  855. this.selectedAddress = list[i]
  856. break
  857. }
  858. }
  859. if (!this.selectedAddress && list.length > 0) {
  860. this.selectedAddress = list[0]
  861. }
  862. }
  863. }
  864. } catch (e) {
  865. console.error(e)
  866. } finally {
  867. this.loading = false
  868. }
  869. },
  870. async loadRequiredFields() {
  871. if (this.items.length === 0) return
  872. var productId = this.items[0].productId
  873. try {
  874. var res = await getProductRequiredFields(productId)
  875. if (res.code === 200) {
  876. this.requiredFields = res.data || []
  877. this.autoFillPurchaseForm()
  878. }
  879. } catch (e) {
  880. console.error(e)
  881. }
  882. },
  883. autoFillPurchaseForm() {
  884. if (!this.selectedAddress || this.requiredFields.length === 0) return
  885. var form = {}
  886. for (var i = 0; i < this.requiredFields.length; i++) {
  887. var field = this.requiredFields[i]
  888. if (field.prefillValue) {
  889. form[field.fieldKey] = field.prefillValue
  890. } else {
  891. form[field.fieldKey] = ''
  892. }
  893. }
  894. this.purchaseForm = form
  895. },
  896. onHandSignatureConfirm(dataUrl) {
  897. var form = this.purchaseForm
  898. form.hand_signature = dataUrl || ''
  899. this.purchaseForm = form
  900. },
  901. onHandSignatureClear() {
  902. var form = this.purchaseForm
  903. form.hand_signature = ''
  904. this.purchaseForm = form
  905. },
  906. onHandSignatureAgreeChange(agreed) {
  907. // 取消勾选同意 → 作废已确认签名,需重新签署
  908. if (!agreed) this.onHandSignatureClear()
  909. },
  910. openAddressPicker() {
  911. if (this.addressList.length === 0) {
  912. uni.showToast({ title: '暂无地址,请先添加', icon: 'none' })
  913. return
  914. }
  915. uni.navigateTo({ url: '/pages/shop/address/address?selectMode=1' })
  916. },
  917. checkMemberStatus() {
  918. var that = this
  919. getMyMembership().then(function(res) {
  920. if (res.data && res.data.memberLevel) {
  921. that.isMember = res.data.memberLevel !== 'FREE'
  922. }
  923. }).catch(function() {})
  924. },
  925. loadGiftProgress() {
  926. var that = this
  927. getGiftMembershipProgress().then(function(res) {
  928. if (res.data && res.data.code === 200) {
  929. that.giftProgress = res.data.data || null
  930. }
  931. }).catch(function() {})
  932. },
  933. goUpgrade() {
  934. uni.navigateTo({ url: '/pages/membership/upgrade' })
  935. },
  936. goAddAddress() {
  937. uni.navigateTo({ url: '/pages/shop/address-edit/address-edit' })
  938. },
  939. // ========== 配送方式相关 ==========
  940. loadDeliveryConfig() {
  941. if (this.items.length === 0) return
  942. var productId = this.items[0].productId
  943. if (!productId) return
  944. var stored = uni.getStorageSync('checkoutItems')
  945. var storageData = stored && stored.length > 0 ? stored[0] : {}
  946. var deliveryMethod = storageData.deliveryMethod
  947. if (!deliveryMethod || deliveryMethod <= 1) return
  948. this.deliveryMethod = deliveryMethod
  949. this.productDeliveryConfig = storageData.deliveryConfig || null
  950. // 如果来自产品详情,可能已有选中值
  951. if (storageData.pickupLocationId) {
  952. this.selectedPickupLocation = { id: storageData.pickupLocationId }
  953. }
  954. if (storageData.timeSlotId) {
  955. this.selectedTimeSlot = { id: storageData.timeSlotId }
  956. }
  957. if (storageData.servicePersonId) {
  958. this.selectedServicePerson = { id: storageData.servicePersonId }
  959. }
  960. // 加载完整配置
  961. var that = this
  962. productDetail({ id: productId }).then(function(res) {
  963. if (res.code === 200 && res.data && res.data.deliveryConfig) {
  964. that.productDeliveryConfig = res.data.deliveryConfig
  965. that.deliveryMethod = res.data.deliveryMethod || that.deliveryMethod
  966. that.pickupLocations = res.data.deliveryConfig.pickupLocations || []
  967. that.servicePersons = res.data.deliveryConfig.servicePersons || []
  968. that.onlineSlots = res.data.deliveryConfig.onlineSlots || []
  969. }
  970. }).catch(function() {})
  971. },
  972. loadDiscount() {
  973. var that = this
  974. if (this.items.length === 0) return
  975. var productIds = []
  976. for (var i = 0; i < this.items.length; i++) {
  977. if (this.items[i].productId) productIds.push(this.items[i].productId)
  978. }
  979. if (productIds.length === 0) return
  980. shopDiscountCalculate({
  981. productIds: productIds,
  982. orderAmount: this.actualAmount
  983. }).then(function(res) {
  984. if (res.code === 200 && res.data) {
  985. that.discountInfo = res.data
  986. }
  987. }).catch(function() {})
  988. },
  989. // 限时特价(扫码闪购):拉取活动信息并校验一次性消费的 dealId。
  990. // 仅当活动进行中且与订单商品一致才按特价单处理,否则回落普通订单(后端同样拒绝无效特价单)。
  991. loadCheckoutSpecialDeal() {
  992. var that = this
  993. getSpecialPriceInfo(this.checkoutSpecialDealId).then(function(res) {
  994. if (res && res.code === 200 && res.data) {
  995. var deal = res.data
  996. if (deal.runStatus === 'ACTIVE' && that.items && that.items.length === 1
  997. && that.items[0].productId === deal.productId) {
  998. that.specialDeal = deal
  999. } else {
  1000. that.checkoutSpecialDealId = null
  1001. that.specialDeal = null
  1002. }
  1003. } else {
  1004. that.checkoutSpecialDealId = null
  1005. that.specialDeal = null
  1006. }
  1007. }).catch(function() {
  1008. that.checkoutSpecialDealId = null
  1009. that.specialDeal = null
  1010. })
  1011. },
  1012. onDeliveryMethodChange: function(e) {
  1013. this.deliveryMethod = parseInt(e.detail.value)
  1014. this.selectedPickupLocation = null
  1015. this.selectedTimeSlot = null
  1016. this.selectedServicePerson = null
  1017. },
  1018. onPickupLocationChange: function(e) {
  1019. var idx = parseInt(e.detail.value)
  1020. if (this.pickupLocations[idx]) {
  1021. this.selectedPickupLocation = this.pickupLocations[idx]
  1022. this.selectedTimeSlot = null
  1023. }
  1024. },
  1025. onTimeSlotChange: function(e) {
  1026. var idx = parseInt(e.detail.value)
  1027. if (this.selectedPickupLocation && this.selectedPickupLocation.timeSlots && this.selectedPickupLocation.timeSlots[idx]) {
  1028. this.selectedTimeSlot = this.selectedPickupLocation.timeSlots[idx]
  1029. }
  1030. },
  1031. onServicePersonChange: function(e) {
  1032. var idx = parseInt(e.detail.value)
  1033. if (this.servicePersons[idx]) {
  1034. this.selectedServicePerson = this.servicePersons[idx]
  1035. this.selectedTimeSlot = null
  1036. }
  1037. },
  1038. onOnlineSlotChange: function(e) {
  1039. var idx = parseInt(e.detail.value)
  1040. if (this.onlineSlots[idx]) {
  1041. this.selectedTimeSlot = this.onlineSlots[idx]
  1042. }
  1043. },
  1044. deliveryMethodLabel: function(method) {
  1045. var map = { 1: '快递配送', 2: '到店自提', 3: '快递/自提', 4: '线上服务', 5: '线上预约' }
  1046. return map[method] || '快递配送'
  1047. },
  1048. deliveryMethodHint: function(method) {
  1049. var map = { 1: '', 2: '请选择自取地点和时间段', 3: '请选择配送方式', 4: '请选择服务者和时间', 5: '请选择预约时段' }
  1050. return map[method] || ''
  1051. },
  1052. selectPickupLocation(loc) {
  1053. this.selectedPickupLocation = loc
  1054. this.selectedTimeSlot = null
  1055. this.showPickupLocationModal = false
  1056. },
  1057. selectTimeSlot(slot) {
  1058. this.selectedTimeSlot = slot
  1059. this.showTimeSlotModal = false
  1060. },
  1061. selectServicePerson(person) {
  1062. this.selectedServicePerson = person
  1063. this.selectedTimeSlot = null
  1064. this.showServicePersonModal = false
  1065. },
  1066. selectOnlineSlot(slot) {
  1067. this.selectedTimeSlot = slot
  1068. this.showOnlineSlotModal = false
  1069. },
  1070. loadUserPoints() {
  1071. var that = this
  1072. uni.request({
  1073. url: config.api('/api/user/info'),
  1074. method: 'POST',
  1075. data: {},
  1076. header: {
  1077. 'Content-Type': 'application/json',
  1078. 'Authorization': 'Bearer ' + uni.getStorageSync('token')
  1079. },
  1080. success: function(res) {
  1081. if (res.data && res.data.code === 200) {
  1082. that.userTotalPoints = res.data.data.totalPoints || 0
  1083. }
  1084. }
  1085. })
  1086. },
  1087. onSubmit() {
  1088. if (!this.selectedAddress) {
  1089. uni.showToast({ title: '请选择收货地址', icon: 'none' })
  1090. return
  1091. }
  1092. if (this.items.length === 0) {
  1093. uni.showToast({ title: '请选择商品', icon: 'none' })
  1094. return
  1095. }
  1096. // 购买信息要求手签名时,必须先完成手写签名
  1097. if (this.hasHandSignatureField && !this.purchaseForm.hand_signature) {
  1098. uni.showToast({ title: '请先完成手写签名', icon: 'none' })
  1099. return
  1100. }
  1101. this.submitting = true
  1102. var orderItems = []
  1103. for (var i = 0; i < this.items.length; i++) {
  1104. var itemData = {
  1105. productId: this.items[i].productId,
  1106. quantity: this.items[i].quantity
  1107. }
  1108. if (this.items[i].skuId) {
  1109. itemData.skuId = this.items[i].skuId
  1110. }
  1111. orderItems.push(itemData)
  1112. }
  1113. var that = this
  1114. uni.request({
  1115. url: config.api('/api/product/order/create'),
  1116. method: 'POST',
  1117. data: {
  1118. items: orderItems,
  1119. giftItemIds: that.giftItemIds,
  1120. remark: this.remark,
  1121. addressId: that.selectedAddress.id,
  1122. purchaseInfo: that.purchaseForm,
  1123. pointsUsed: that.pointsUsed,
  1124. discountAmount: (that.discountInfo ? that.discountInfo.discountAmount : 0) + that.giftPromoDiscount,
  1125. couponId: that.selectedCoupon ? that.selectedCoupon.id : null,
  1126. // 特价单透传(无则传 null):后端 createSpecialDealOrder 校验活动后按特价结算
  1127. specialDealId: that.checkoutSpecialDealId || null,
  1128. deliveryMethod: that.deliveryMethod,
  1129. pickupLocationId: that.selectedPickupLocation ? that.selectedPickupLocation.id : null,
  1130. timeSlotId: that.selectedTimeSlot ? that.selectedTimeSlot.id : null,
  1131. servicePersonId: that.selectedServicePerson ? that.selectedServicePerson.id : null
  1132. },
  1133. header: {
  1134. 'Content-Type': 'application/json',
  1135. 'Authorization': 'Bearer ' + uni.getStorageSync('token')
  1136. },
  1137. success: function(res) {
  1138. that.submitting = false
  1139. if (res.data && res.data.code === 200) {
  1140. var order = res.data.data
  1141. uni.showToast({ title: '下单成功', icon: 'success' })
  1142. uni.removeStorageSync('checkoutItems')
  1143. uni.removeStorageSync('checkoutGiftItemIds')
  1144. uni.removeStorageSync('checkoutGiftPromo')
  1145. uni.removeStorageSync('checkoutSpecialDealId')
  1146. var moneyAmount = order.moneyAmount != null ? order.moneyAmount : order.totalAmount
  1147. var pointsUsed = order.pointsUsed || 0
  1148. setTimeout(function() {
  1149. uni.navigateTo({
  1150. url: '/pages/shop/payment/payment?orderNo=' + order.orderNo + '&amount=' + moneyAmount + '&pointsUsed=' + pointsUsed + (this.taskId ? '&taskId=' + this.taskId : '')
  1151. })
  1152. }, 1000)
  1153. } else {
  1154. uni.showToast({ title: res.data.message || '下单失败', icon: 'none' })
  1155. }
  1156. },
  1157. fail: function() {
  1158. that.submitting = false
  1159. uni.showToast({ title: '网络请求失败', icon: 'none' })
  1160. }
  1161. })
  1162. },
  1163. formatPrice(price) {
  1164. if (price === null || price === undefined) return '0.00'
  1165. return (Number(price) / 100).toFixed(2)
  1166. },
  1167. formatPhone(phone) {
  1168. if (!phone) return ''
  1169. if (phone.length === 11) {
  1170. return phone.substr(0, 3) + '****' + phone.substr(7)
  1171. }
  1172. return phone
  1173. },
  1174. selectServicePerson(person) {
  1175. this.selectedServicePerson = person
  1176. this.selectedTimeSlot = null
  1177. this.showServicePersonModal = false
  1178. },
  1179. selectOnlineSlot(slot) {
  1180. this.selectedTimeSlot = slot
  1181. this.showOnlineSlotModal = false
  1182. },
  1183. formatOnlineTime: function(timeStr) {
  1184. if (!timeStr) return ''
  1185. try {
  1186. var d = parseDate(timeStr)
  1187. if (!d) return timeStr
  1188. return (d.getMonth() + 1) + '月' + d.getDate() + '日 ' + String(d.getHours()).padStart(2, '0') + ':' + String(d.getMinutes()).padStart(2, '0')
  1189. } catch (e) {
  1190. return timeStr
  1191. }
  1192. },
  1193. showPickupLocationPicker: function() {
  1194. this.showPickupLocationModal = true
  1195. },
  1196. showTimeSlotPicker: function() {
  1197. if (!this.selectedPickupLocation) return
  1198. this.showTimeSlotModal = true
  1199. },
  1200. showServicePersonPicker: function() {
  1201. this.showServicePersonModal = true
  1202. },
  1203. showOnlineSlotPicker: function() {
  1204. this.showOnlineSlotModal = true
  1205. },
  1206. selectPickupLocation: function(loc) {
  1207. this.selectedPickupLocation = loc
  1208. this.selectedTimeSlot = null
  1209. this.showPickupLocationModal = false
  1210. },
  1211. selectTimeSlot: function(slot) {
  1212. this.selectedTimeSlot = slot
  1213. this.showTimeSlotModal = false
  1214. },
  1215. selectServicePerson: function(person) {
  1216. this.selectedServicePerson = person
  1217. this.showServicePersonModal = false
  1218. },getImageUrl: function(path) {
  1219. if (!path || path === 'null' || path === 'undefined' || path === '/null') return ''
  1220. var s = String(path).trim()
  1221. if (!s || s === 'null' || s === '/null') return ''
  1222. if (s.indexOf('http://') === 0 || s.indexOf('https://') === 0) return s
  1223. return config.API_BASE_URL + (s.charAt(0) === '/' ? s : '/' + s)
  1224. }
  1225. }
  1226. }
  1227. </script>
  1228. <style scoped lang="scss">
  1229. .container {
  1230. min-height: 100vh;
  1231. background: $facade-fill-2;
  1232. }
  1233. .loading-wrap {
  1234. display: flex;
  1235. justify-content: center;
  1236. padding-top: 200rpx;
  1237. }
  1238. .loading-text {
  1239. font-size: calc(28rpx * var(--font-scale, 1));
  1240. color: $facade-text-muted;
  1241. }
  1242. .content {
  1243. height: calc(100vh - 120rpx);
  1244. }
  1245. .section {
  1246. background: $app-surface;
  1247. margin: 20rpx;
  1248. border-radius: 16rpx;
  1249. padding: 24rpx;
  1250. }
  1251. .section-title {
  1252. font-size: calc(28rpx * var(--font-scale, 1));
  1253. font-weight: bold;
  1254. color: $facade-text-strong;
  1255. margin-bottom: 20rpx;
  1256. display: block;
  1257. }
  1258. .address-section {
  1259. position: relative;
  1260. }
  1261. .address-content {
  1262. position: relative;
  1263. }
  1264. .address-top {
  1265. display: flex;
  1266. align-items: center;
  1267. margin-bottom: 10rpx;
  1268. }
  1269. .receiver-name {
  1270. font-size: calc(30rpx * var(--font-scale, 1));
  1271. font-weight: bold;
  1272. color: $facade-text-strong;
  1273. margin-right: 20rpx;
  1274. }
  1275. .receiver-phone {
  1276. font-size: calc(26rpx * var(--font-scale, 1));
  1277. color: $facade-text-body;
  1278. }
  1279. .default-badge {
  1280. font-size: calc(20rpx * var(--font-scale, 1));
  1281. color: $brand-primary;
  1282. background: $brand-primary-tint-2;
  1283. padding: 2rpx 12rpx;
  1284. border-radius: 24rpx;
  1285. margin-left: 12rpx;
  1286. }
  1287. .address-detail {
  1288. font-size: calc(26rpx * var(--font-scale, 1));
  1289. color: $facade-text-muted;
  1290. line-height: 1.5;
  1291. }
  1292. .address-arrow {
  1293. position: absolute;
  1294. right: 0;
  1295. top: 50%;
  1296. font-size: calc(40rpx * var(--font-scale, 1));
  1297. color: $facade-text-ghost;
  1298. transform: translateY(-50%);
  1299. }
  1300. .address-empty {
  1301. display: flex;
  1302. align-items: center;
  1303. justify-content: center;
  1304. padding: $uni-space-lg 0;
  1305. position: relative;
  1306. }
  1307. .address-empty-icon {
  1308. font-size: calc(40rpx * var(--font-scale, 1));
  1309. margin-right: 12rpx;
  1310. }
  1311. .address-empty-text {
  1312. font-size: calc(28rpx * var(--font-scale, 1));
  1313. color: $facade-text-muted;
  1314. }
  1315. .order-item {
  1316. display: flex;
  1317. align-items: center;
  1318. padding: 16rpx 0;
  1319. border-bottom: 1rpx solid $facade-fill-2;
  1320. }
  1321. .order-item:last-child {
  1322. border-bottom: none;
  1323. }
  1324. .item-image {
  1325. width: 80rpx;
  1326. height: 80rpx;
  1327. border-radius: 8rpx;
  1328. background: $facade-fill;
  1329. margin-right: 16rpx;
  1330. }
  1331. .item-info {
  1332. flex: 1;
  1333. display: flex;
  1334. flex-direction: column;
  1335. min-width: 0;
  1336. }
  1337. .item-name {
  1338. font-size: calc(26rpx * var(--font-scale, 1));
  1339. color: $facade-text-strong;
  1340. overflow: hidden;
  1341. text-overflow: ellipsis;
  1342. white-space: nowrap;
  1343. margin-bottom: 6rpx;
  1344. }
  1345. .item-spec-desc {
  1346. font-size: calc(22rpx * var(--font-scale, 1));
  1347. color: $facade-text-muted;
  1348. display: block;
  1349. margin-top: 2rpx;
  1350. }
  1351. .item-supplier-name {
  1352. font-size: calc(20rpx * var(--font-scale, 1));
  1353. color: $uni-info;
  1354. display: block;
  1355. margin-top: 2rpx;
  1356. }
  1357. .item-qty {
  1358. font-size: calc(22rpx * var(--font-scale, 1));
  1359. color: $facade-text-muted;
  1360. }
  1361. .item-price {
  1362. font-size: calc(26rpx * var(--font-scale, 1));
  1363. color: $brand-primary;
  1364. font-weight: bold;
  1365. margin-left: 16rpx;
  1366. }
  1367. .info-row {
  1368. display: flex;
  1369. justify-content: space-between;
  1370. align-items: center;
  1371. padding: 8rpx 0;
  1372. }
  1373. .info-label {
  1374. font-size: calc(26rpx * var(--font-scale, 1));
  1375. color: $facade-text-muted;
  1376. }
  1377. .info-value {
  1378. font-size: calc(26rpx * var(--font-scale, 1));
  1379. color: $facade-text-strong;
  1380. }
  1381. .remark-input {
  1382. flex: 1;
  1383. text-align: right;
  1384. font-size: calc(26rpx * var(--font-scale, 1));
  1385. color: $facade-text-strong;
  1386. }
  1387. /* ===== Coupon Section ===== */
  1388. .coupon-section {
  1389. position: relative;
  1390. }
  1391. .coupon-section:active {
  1392. background: $facade-fill-ghost;
  1393. }
  1394. .coupon-selected {
  1395. display: flex;
  1396. align-items: center;
  1397. flex: 1;
  1398. justify-content: flex-end;
  1399. margin-right: $uni-space-lg;
  1400. }
  1401. .coupon-discount {
  1402. font-size: calc(26rpx * var(--font-scale, 1));
  1403. color: $brand-primary;
  1404. font-weight: 600;
  1405. margin-right: 12rpx;
  1406. }
  1407. .coupon-name-tag {
  1408. font-size: calc(22rpx * var(--font-scale, 1));
  1409. color: $app-surface;
  1410. background: $brand-primary;
  1411. padding: 2rpx 12rpx;
  1412. border-radius: 8rpx;
  1413. max-width: 200rpx;
  1414. overflow: hidden;
  1415. text-overflow: ellipsis;
  1416. white-space: nowrap;
  1417. }
  1418. .coupon-placeholder {
  1419. flex: 1;
  1420. text-align: right;
  1421. margin-right: $uni-space-lg;
  1422. }
  1423. .placeholder-text {
  1424. font-size: calc(26rpx * var(--font-scale, 1));
  1425. color: $facade-text-ghost;
  1426. }
  1427. .total-original {
  1428. font-size: calc(22rpx * var(--font-scale, 1));
  1429. color: $facade-text-ghost-light;
  1430. text-decoration: line-through;
  1431. margin-left: 8rpx;
  1432. }
  1433. /* ===== Member Upgrade Hint ===== */
  1434. .member-upgrade-section {
  1435. position: relative;
  1436. }
  1437. .member-upgrade-row {
  1438. display: flex;
  1439. align-items: center;
  1440. }
  1441. .member-upgrade-icon {
  1442. font-size: calc(32rpx * var(--font-scale, 1));
  1443. margin-right: 12rpx;
  1444. }
  1445. .member-upgrade-text {
  1446. flex: 1;
  1447. font-size: calc(26rpx * var(--font-scale, 1));
  1448. color: $brand-primary;
  1449. font-weight: 500;
  1450. }
  1451. .member-upgrade-arrow {
  1452. font-size: calc(32rpx * var(--font-scale, 1));
  1453. color: $brand-primary;
  1454. }
  1455. /* ===== Member Coupon Hint ===== */
  1456. .member-coupon-hint {
  1457. margin-top: -10rpx;
  1458. margin-bottom: 20rpx;
  1459. }
  1460. .member-coupon-hint-content {
  1461. display: flex;
  1462. align-items: center;
  1463. padding: 20rpx 24rpx;
  1464. background: linear-gradient(135deg, $uni-primary-pale 0%, $facade-brand-tint-2 100%);
  1465. border-radius: 16rpx;
  1466. border: 1rpx solid $brand-primary-light-2;
  1467. }
  1468. .hint-icon {
  1469. font-size: calc(32rpx * var(--font-scale, 1));
  1470. margin-right: 12rpx;
  1471. }
  1472. .hint-text {
  1473. font-size: calc(24rpx * var(--font-scale, 1));
  1474. color: $brand-primary-deep;
  1475. font-weight: 500;
  1476. }
  1477. /* ===== Coupon Picker Modal ===== */
  1478. .modal-mask {
  1479. position: fixed;
  1480. top: 0;
  1481. left: 0;
  1482. right: 0;
  1483. bottom: 0;
  1484. background: rgba(0,0,0,0.5);
  1485. z-index: 999;
  1486. display: flex;
  1487. align-items: flex-end;
  1488. }
  1489. .coupon-picker {
  1490. background: $app-surface;
  1491. border-radius: 24rpx 24rpx 0 0;
  1492. width: 100%;
  1493. max-height: 70vh;
  1494. display: flex;
  1495. flex-direction: column;
  1496. }
  1497. .picker-header {
  1498. display: flex;
  1499. justify-content: space-between;
  1500. align-items: center;
  1501. padding: $uni-space-page;
  1502. border-bottom: 1rpx solid $facade-hairline-2;
  1503. }
  1504. .picker-title {
  1505. font-size: calc(30rpx * var(--font-scale, 1));
  1506. font-weight: 600;
  1507. color: $facade-text-strong;
  1508. }
  1509. .picker-close {
  1510. font-size: calc(26rpx * var(--font-scale, 1));
  1511. color: $facade-text-muted;
  1512. }
  1513. .picker-list {
  1514. max-height: 50vh;
  1515. padding: 0 20rpx;
  1516. }
  1517. .picker-item {
  1518. display: flex;
  1519. align-items: center;
  1520. padding: 24rpx 16rpx;
  1521. border-bottom: 1rpx solid $facade-fill-2;
  1522. }
  1523. .picker-item:active {
  1524. background: $facade-fill-ghost;
  1525. }
  1526. .picker-item-active {
  1527. background: $uni-primary-pale;
  1528. }
  1529. .picker-item-left {
  1530. width: 120rpx;
  1531. text-align: center;
  1532. flex-shrink: 0;
  1533. }
  1534. .picker-item-value {
  1535. font-size: calc(32rpx * var(--font-scale, 1));
  1536. font-weight: bold;
  1537. color: $brand-primary;
  1538. }
  1539. .picker-item-right {
  1540. flex: 1;
  1541. margin: 0 16rpx;
  1542. }
  1543. .picker-item-name {
  1544. font-size: calc(26rpx * var(--font-scale, 1));
  1545. color: $facade-text-strong;
  1546. display: block;
  1547. margin-bottom: 4rpx;
  1548. }
  1549. .picker-item-condition {
  1550. font-size: calc(22rpx * var(--font-scale, 1));
  1551. color: $facade-text-muted;
  1552. }
  1553. .picker-item-check {
  1554. width: 40rpx;
  1555. height: 40rpx;
  1556. background: $brand-primary;
  1557. border-radius: 50%;
  1558. display: flex;
  1559. align-items: center;
  1560. justify-content: center;
  1561. flex-shrink: 0;
  1562. }
  1563. .check-icon {
  1564. color: $app-surface;
  1565. font-size: calc(24rpx * var(--font-scale, 1));
  1566. font-weight: bold;
  1567. }
  1568. .picker-empty {
  1569. text-align: center;
  1570. padding: 60rpx 0;
  1571. font-size: calc(26rpx * var(--font-scale, 1));
  1572. color: $facade-text-muted;
  1573. }
  1574. .picker-footer {
  1575. padding: 20rpx;
  1576. border-top: 1rpx solid $facade-hairline-2;
  1577. }
  1578. .picker-btn-remove {
  1579. background: $facade-fill-2;
  1580. color: $facade-text-body;
  1581. font-size: calc(26rpx * var(--font-scale, 1));
  1582. border-radius: 16rpx;
  1583. border: none;
  1584. }
  1585. .picker-btn-remove::after {
  1586. border: none;
  1587. }
  1588. .bottom-spacer {
  1589. height: 140rpx;
  1590. }
  1591. .bottom-bar {
  1592. position: fixed;
  1593. bottom: 0;
  1594. left: 0;
  1595. right: 0;
  1596. height: 100rpx;
  1597. background: $app-surface;
  1598. border-top: 1rpx solid $facade-hairline-2;
  1599. display: flex;
  1600. align-items: center;
  1601. justify-content: space-between;
  1602. padding: 0 $uni-space-page;
  1603. z-index: 100;
  1604. }
  1605. .bottom-left {
  1606. display: flex;
  1607. align-items: baseline;
  1608. }
  1609. .total-label {
  1610. font-size: calc(26rpx * var(--font-scale, 1));
  1611. color: $facade-text-body;
  1612. }
  1613. .total-amount {
  1614. font-size: calc(36rpx * var(--font-scale, 1));
  1615. color: $brand-primary;
  1616. font-weight: bold;
  1617. }
  1618. .submit-btn {
  1619. background: linear-gradient(135deg, $brand-primary, $brand-primary-light);
  1620. color: $app-surface;
  1621. font-size: calc(28rpx * var(--font-scale, 1));
  1622. font-weight: bold;
  1623. padding: 0 60rpx;
  1624. height: 72rpx;
  1625. line-height: 72rpx;
  1626. border-radius: 24rpx;
  1627. border: none;
  1628. }
  1629. .submit-btn::after {
  1630. border: none;
  1631. }
  1632. .submit-btn.disabled {
  1633. background: $facade-border-soft;
  1634. color: $facade-text-muted;
  1635. }
  1636. .points-balance {
  1637. font-size: calc(24rpx * var(--font-scale, 1));
  1638. color: $brand-primary;
  1639. }
  1640. .points-input-row {
  1641. display: flex;
  1642. align-items: center;
  1643. margin-top: 16rpx;
  1644. padding: 12rpx 0;
  1645. border-top: 1rpx solid $facade-fill-2;
  1646. }
  1647. .points-input {
  1648. flex: 1;
  1649. height: 60rpx;
  1650. font-size: calc(28rpx * var(--font-scale, 1));
  1651. color: $facade-text-strong;
  1652. background: $facade-fill-ghost-2;
  1653. border-radius: 8rpx;
  1654. padding: 0 16rpx;
  1655. }
  1656. .points-hint {
  1657. font-size: calc(24rpx * var(--font-scale, 1));
  1658. color: $facade-text-muted;
  1659. margin-left: 12rpx;
  1660. min-width: 100rpx;
  1661. text-align: right;
  1662. }
  1663. .points-tip {
  1664. margin-top: 8rpx;
  1665. }
  1666. .points-tip-text {
  1667. font-size: calc(22rpx * var(--font-scale, 1));
  1668. color: $facade-text-ghost-light;
  1669. }
  1670. .total-original {
  1671. font-size: calc(24rpx * var(--font-scale, 1));
  1672. color: $facade-text-ghost-light;
  1673. text-decoration: line-through;
  1674. margin-left: 8rpx;
  1675. }
  1676. /* ===== Purchase Info Fields ===== */
  1677. .purchase-field-row {
  1678. display: flex;
  1679. align-items: center;
  1680. padding: 16rpx 0;
  1681. border-bottom: 1rpx solid $facade-fill-2;
  1682. }
  1683. .purchase-field-row:last-child {
  1684. border-bottom: none;
  1685. }
  1686. .purchase-field-label {
  1687. font-size: calc(26rpx * var(--font-scale, 1));
  1688. color: $facade-text-strong;
  1689. width: 160rpx;
  1690. flex-shrink: 0;
  1691. }
  1692. .required-mark {
  1693. color: $el-danger;
  1694. }
  1695. .purchase-field-input {
  1696. flex: 1;
  1697. font-size: calc(26rpx * var(--font-scale, 1));
  1698. color: $facade-text-strong;
  1699. text-align: right;
  1700. padding: 8rpx 0;
  1701. }
  1702. .purchase-field-input[disabled] {
  1703. background: transparent;
  1704. color: $facade-text-muted;
  1705. }
  1706. .purchase-field-prefill {
  1707. font-size: calc(22rpx * var(--font-scale, 1));
  1708. color: $el-success;
  1709. margin-left: 8rpx;
  1710. }
  1711. /* ===== 购买信息-手签名 ===== */
  1712. .purchase-signature-block {
  1713. margin-top: 24rpx;
  1714. }
  1715. .purchase-signature-title {
  1716. font-size: calc(26rpx * var(--font-scale, 1));
  1717. color: $facade-text-strong;
  1718. font-weight: bold;
  1719. margin-bottom: 12rpx;
  1720. }
  1721. /* 配送方式选择 */
  1722. .delivery-sub-label {
  1723. font-size: calc(24rpx * var(--font-scale, 1));
  1724. color: $facade-text-muted;
  1725. margin-bottom: 12rpx;
  1726. margin-top: 16rpx;
  1727. }
  1728. .picker-row {
  1729. display: flex;
  1730. align-items: center;
  1731. justify-content: space-between;
  1732. padding: 20rpx 0;
  1733. border-bottom: 1rpx solid $facade-fill-2;
  1734. }
  1735. .picker-row:last-child {
  1736. border-bottom: none;
  1737. }
  1738. .picker-value {
  1739. font-size: calc(28rpx * var(--font-scale, 1));
  1740. color: $facade-text-strong;
  1741. flex: 1;
  1742. }
  1743. .picker-placeholder {
  1744. font-size: calc(28rpx * var(--font-scale, 1));
  1745. color: $facade-text-muted;
  1746. flex: 1;
  1747. }
  1748. .picker-arrow {
  1749. font-size: calc(32rpx * var(--font-scale, 1));
  1750. color: $facade-text-ghost;
  1751. margin-left: 10rpx;
  1752. }
  1753. .modal-mask {
  1754. position: fixed;
  1755. top: 0;
  1756. left: 0;
  1757. right: 0;
  1758. bottom: 0;
  1759. background: rgba(0,0,0,0.5);
  1760. z-index: 999;
  1761. display: flex;
  1762. align-items: flex-end;
  1763. }
  1764. .picker-modal {
  1765. width: 100%;
  1766. background: $app-surface;
  1767. border-radius: 24rpx 24rpx 0 0;
  1768. max-height: 70vh;
  1769. display: flex;
  1770. flex-direction: column;
  1771. }
  1772. .picker-modal .picker-header {
  1773. display: flex;
  1774. justify-content: space-between;
  1775. align-items: center;
  1776. padding: $uni-space-page;
  1777. border-bottom: 1rpx solid $facade-hairline-2;
  1778. }
  1779. .picker-modal .picker-title {
  1780. font-size: calc(32rpx * var(--font-scale, 1));
  1781. font-weight: bold;
  1782. color: $facade-text-strong;
  1783. }
  1784. .picker-modal .picker-close {
  1785. font-size: calc(28rpx * var(--font-scale, 1));
  1786. color: $facade-text-muted;
  1787. }
  1788. .picker-modal .picker-list {
  1789. flex: 1;
  1790. max-height: 50vh;
  1791. padding: 20rpx $uni-space-page;
  1792. }
  1793. .picker-modal .picker-item {
  1794. display: flex;
  1795. align-items: center;
  1796. padding: 24rpx 0;
  1797. border-bottom: 1rpx solid $facade-fill-2;
  1798. }
  1799. .picker-modal .picker-item:last-child {
  1800. border-bottom: none;
  1801. }
  1802. .picker-modal .picker-item-active {
  1803. background: $brand-primary-tint-2;
  1804. border-radius: 16rpx;
  1805. padding: 24rpx 16rpx;
  1806. }
  1807. .picker-modal .picker-item-left {
  1808. flex: 1;
  1809. min-width: 0;
  1810. }
  1811. .picker-modal .picker-item-name {
  1812. font-size: calc(28rpx * var(--font-scale, 1));
  1813. color: $facade-text-strong;
  1814. display: block;
  1815. }
  1816. .picker-modal .picker-item-addr {
  1817. font-size: calc(24rpx * var(--font-scale, 1));
  1818. color: $facade-text-muted;
  1819. margin-top: 6rpx;
  1820. display: block;
  1821. }
  1822. .picker-modal .picker-item-desc {
  1823. font-size: calc(24rpx * var(--font-scale, 1));
  1824. color: $facade-text-muted;
  1825. margin-top: 4rpx;
  1826. display: block;
  1827. }
  1828. .picker-modal .picker-item-price {
  1829. font-size: calc(26rpx * var(--font-scale, 1));
  1830. color: $brand-primary;
  1831. font-weight: bold;
  1832. margin-top: 4rpx;
  1833. display: block;
  1834. }
  1835. .picker-modal .picker-item-check {
  1836. margin-left: 16rpx;
  1837. color: $brand-primary;
  1838. font-size: calc(32rpx * var(--font-scale, 1));
  1839. }
  1840. /* Gift membership progress */
  1841. .gift-progress-section {
  1842. background: $uni-primary-pale;
  1843. border-radius: 16rpx;
  1844. border: 2rpx solid $brand-primary-light-2;
  1845. }
  1846. .gift-progress-header {
  1847. display: flex;
  1848. align-items: center;
  1849. margin-bottom: 16rpx;
  1850. }
  1851. .gift-progress-icon {
  1852. font-size: calc(32rpx * var(--font-scale, 1));
  1853. margin-right: 12rpx;
  1854. }
  1855. .gift-progress-title {
  1856. flex: 1;
  1857. font-size: calc(26rpx * var(--font-scale, 1));
  1858. color: $brand-primary-deep;
  1859. font-weight: 500;
  1860. }
  1861. .gift-progress-percent {
  1862. font-size: calc(28rpx * var(--font-scale, 1));
  1863. color: $brand-primary;
  1864. font-weight: bold;
  1865. }
  1866. .gift-progress-bar-bg {
  1867. height: 20rpx;
  1868. background: $brand-primary-light-2;
  1869. border-radius: 8rpx;
  1870. overflow: hidden;
  1871. margin-bottom: 12rpx;
  1872. }
  1873. .gift-progress-bar-fill {
  1874. height: 100%;
  1875. background: linear-gradient(90deg, $brand-primary, $brand-primary-light);
  1876. border-radius: 8rpx;
  1877. }
  1878. .gift-progress-info {
  1879. display: flex;
  1880. justify-content: space-between;
  1881. }
  1882. .gift-progress-accumulated {
  1883. font-size: calc(22rpx * var(--font-scale, 1));
  1884. color: $mat-orange-deep;
  1885. }
  1886. .gift-progress-remaining {
  1887. font-size: calc(22rpx * var(--font-scale, 1));
  1888. color: $brand-primary-deep;
  1889. font-weight: 500;
  1890. }
  1891. .gift-progress-level {
  1892. margin-top: 12rpx;
  1893. font-size: calc(22rpx * var(--font-scale, 1));
  1894. color: $brand-primary;
  1895. }
  1896. .gift-progress-note {
  1897. display: block;
  1898. margin-top: 8rpx;
  1899. font-size: calc(20rpx * var(--font-scale, 1));
  1900. color: $mat-orange-deep;
  1901. }
  1902. .gift-granted-section {
  1903. background: $status-success-tint-2;
  1904. border-radius: 16rpx;
  1905. border: 2rpx solid $tint-green-line;
  1906. }
  1907. .gift-granted-row {
  1908. display: flex;
  1909. align-items: center;
  1910. }
  1911. .gift-granted-icon {
  1912. font-size: calc(32rpx * var(--font-scale, 1));
  1913. margin-right: 12rpx;
  1914. }
  1915. .gift-granted-text {
  1916. flex: 1;
  1917. font-size: calc(26rpx * var(--font-scale, 1));
  1918. color: #15803D;
  1919. }
  1920. .gift-promo-section {
  1921. background: $uni-primary-pale;
  1922. border-radius: 16rpx;
  1923. border: 2rpx solid $brand-primary-light-2;
  1924. margin: 20rpx;
  1925. padding: 20rpx;
  1926. }
  1927. .gift-promo-row {
  1928. display: flex;
  1929. align-items: center;
  1930. justify-content: space-between;
  1931. }
  1932. .gift-promo-icon {
  1933. font-size: calc(32rpx * var(--font-scale, 1));
  1934. margin-right: 12rpx;
  1935. }
  1936. .gift-promo-content {
  1937. flex: 1;
  1938. }
  1939. .gift-promo-title {
  1940. font-size: calc(26rpx * var(--font-scale, 1));
  1941. color: $brand-primary-deep;
  1942. font-weight: 500;
  1943. }
  1944. .gift-promo-desc {
  1945. font-size: calc(22rpx * var(--font-scale, 1));
  1946. color: $mat-orange-deep;
  1947. margin-top: 4rpx;
  1948. }
  1949. .gift-promo-save {
  1950. font-size: calc(22rpx * var(--font-scale, 1));
  1951. color: $brand-primary;
  1952. }
  1953. /* 保持原有样式向下延伸 */
  1954. </style>