checkout.vue 67 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035
  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.effectivePrice(this.items[i]) * 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. // 与下单提交(checkout.vue submitProductOrder)一致:透传订单商品 ID 集合,
  799. // 商品绑定券(如菌群测评券 product_id=3)才能通过服务端商品维度校验
  800. var couponProductIds = []
  801. for (var ci = 0; ci < this.items.length; ci++) {
  802. if (this.items[ci].productId) couponProductIds.push(this.items[ci].productId)
  803. }
  804. var res = await applyCoupon({
  805. userCouponId: this.selectedCoupon.id,
  806. orderType: 'PRODUCT',
  807. orderAmount: this.actualAmount || 0,
  808. productIds: couponProductIds
  809. })
  810. // 期间用户可能已改选/取消券,丢弃过期响应
  811. if (!this.selectedCoupon || this.selectedCoupon.id !== applyingCouponId) {
  812. return
  813. }
  814. this.couponDiscount = (res && res.data && res.data.discount) || 0
  815. } catch (e) {
  816. if (this.selectedCoupon && this.selectedCoupon.id === applyingCouponId) {
  817. // 服务端判定不可用(request 已提示 message),本地同步清空避免错误展示
  818. this.selectedCoupon = null
  819. this.couponDiscount = 0
  820. }
  821. } finally {
  822. this.couponApplying = false
  823. }
  824. },
  825. onPointsInput(e) {
  826. var val = parseInt(e.detail.value) || 0
  827. if (val < 0) val = 0
  828. var maxP = this.maxPoints
  829. if (val > maxP) {
  830. val = maxP
  831. uni.showToast({ title: '最多使用 ' + maxP + ' 积分', icon: 'none' })
  832. }
  833. this.pointsUsed = val
  834. },
  835. getConditionText(minSpend) {
  836. if (!minSpend || minSpend <= 0) return '无门槛'
  837. return '满' + (minSpend / 100).toFixed(2) + '元可用'
  838. },
  839. async loadDefaultAddress() {
  840. this.loading = true
  841. try {
  842. var res = await addressList()
  843. if (res.code === 200) {
  844. var list = res.data || []
  845. this.addressList = list
  846. // 如果当前已有选中地址,保持选中状态
  847. if (this.selectedAddress) {
  848. var stillExists = false
  849. for (var k = 0; k < list.length; k++) {
  850. if (list[k].id === this.selectedAddress.id) {
  851. stillExists = true
  852. break
  853. }
  854. }
  855. if (!stillExists) {
  856. this.selectedAddress = null
  857. }
  858. }
  859. if (!this.selectedAddress) {
  860. for (var i = 0; i < list.length; i++) {
  861. if (list[i].isDefault === 1) {
  862. this.selectedAddress = list[i]
  863. break
  864. }
  865. }
  866. if (!this.selectedAddress && list.length > 0) {
  867. this.selectedAddress = list[0]
  868. }
  869. }
  870. }
  871. } catch (e) {
  872. console.error(e)
  873. } finally {
  874. this.loading = false
  875. }
  876. },
  877. async loadRequiredFields() {
  878. if (this.items.length === 0) return
  879. var productId = this.items[0].productId
  880. try {
  881. var res = await getProductRequiredFields(productId)
  882. if (res.code === 200) {
  883. this.requiredFields = res.data || []
  884. this.autoFillPurchaseForm()
  885. }
  886. } catch (e) {
  887. console.error(e)
  888. }
  889. },
  890. autoFillPurchaseForm() {
  891. if (!this.selectedAddress || this.requiredFields.length === 0) return
  892. var form = {}
  893. for (var i = 0; i < this.requiredFields.length; i++) {
  894. var field = this.requiredFields[i]
  895. if (field.prefillValue) {
  896. form[field.fieldKey] = field.prefillValue
  897. } else {
  898. form[field.fieldKey] = ''
  899. }
  900. }
  901. this.purchaseForm = form
  902. },
  903. onHandSignatureConfirm(dataUrl) {
  904. var form = this.purchaseForm
  905. form.hand_signature = dataUrl || ''
  906. this.purchaseForm = form
  907. },
  908. onHandSignatureClear() {
  909. var form = this.purchaseForm
  910. form.hand_signature = ''
  911. this.purchaseForm = form
  912. },
  913. onHandSignatureAgreeChange(agreed) {
  914. // 取消勾选同意 → 作废已确认签名,需重新签署
  915. if (!agreed) this.onHandSignatureClear()
  916. },
  917. openAddressPicker() {
  918. if (this.addressList.length === 0) {
  919. uni.showToast({ title: '暂无地址,请先添加', icon: 'none' })
  920. return
  921. }
  922. uni.navigateTo({ url: '/pages/shop/address/address?selectMode=1' })
  923. },
  924. checkMemberStatus() {
  925. var that = this
  926. getMyMembership().then(function(res) {
  927. if (res.data && res.data.memberLevel) {
  928. that.isMember = res.data.memberLevel !== 'FREE'
  929. // 会员身份异步确认后重算价格:首次 calcAmount 时 isMember 还是 false,会员价未生效
  930. that.calcAmount()
  931. }
  932. }).catch(function() {})
  933. },
  934. loadGiftProgress() {
  935. var that = this
  936. getGiftMembershipProgress().then(function(res) {
  937. if (res.data && res.data.code === 200) {
  938. that.giftProgress = res.data.data || null
  939. }
  940. }).catch(function() {})
  941. },
  942. goUpgrade() {
  943. uni.navigateTo({ url: '/pages/membership/upgrade' })
  944. },
  945. goAddAddress() {
  946. uni.navigateTo({ url: '/pages/shop/address-edit/address-edit' })
  947. },
  948. // ========== 配送方式相关 ==========
  949. loadDeliveryConfig() {
  950. if (this.items.length === 0) return
  951. var productId = this.items[0].productId
  952. if (!productId) return
  953. var stored = uni.getStorageSync('checkoutItems')
  954. var storageData = stored && stored.length > 0 ? stored[0] : {}
  955. var deliveryMethod = storageData.deliveryMethod
  956. if (!deliveryMethod || deliveryMethod <= 1) return
  957. this.deliveryMethod = deliveryMethod
  958. this.productDeliveryConfig = storageData.deliveryConfig || null
  959. // 如果来自产品详情,可能已有选中值
  960. if (storageData.pickupLocationId) {
  961. this.selectedPickupLocation = { id: storageData.pickupLocationId }
  962. }
  963. if (storageData.timeSlotId) {
  964. this.selectedTimeSlot = { id: storageData.timeSlotId }
  965. }
  966. if (storageData.servicePersonId) {
  967. this.selectedServicePerson = { id: storageData.servicePersonId }
  968. }
  969. // 加载完整配置
  970. var that = this
  971. productDetail({ id: productId }).then(function(res) {
  972. if (res.code === 200 && res.data && res.data.deliveryConfig) {
  973. that.productDeliveryConfig = res.data.deliveryConfig
  974. that.deliveryMethod = res.data.deliveryMethod || that.deliveryMethod
  975. that.pickupLocations = res.data.deliveryConfig.pickupLocations || []
  976. that.servicePersons = res.data.deliveryConfig.servicePersons || []
  977. that.onlineSlots = res.data.deliveryConfig.onlineSlots || []
  978. }
  979. }).catch(function() {})
  980. },
  981. loadDiscount() {
  982. var that = this
  983. if (this.items.length === 0) return
  984. var productIds = []
  985. for (var i = 0; i < this.items.length; i++) {
  986. if (this.items[i].productId) productIds.push(this.items[i].productId)
  987. }
  988. if (productIds.length === 0) return
  989. shopDiscountCalculate({
  990. productIds: productIds,
  991. orderAmount: this.actualAmount
  992. }).then(function(res) {
  993. if (res.code === 200 && res.data) {
  994. that.discountInfo = res.data
  995. }
  996. }).catch(function() {})
  997. },
  998. // 限时特价(扫码闪购):拉取活动信息并校验一次性消费的 dealId。
  999. // 仅当活动进行中且与订单商品一致才按特价单处理,否则回落普通订单(后端同样拒绝无效特价单)。
  1000. loadCheckoutSpecialDeal() {
  1001. var that = this
  1002. getSpecialPriceInfo(this.checkoutSpecialDealId).then(function(res) {
  1003. if (res && res.code === 200 && res.data) {
  1004. var deal = res.data
  1005. if (deal.runStatus === 'ACTIVE' && that.items && that.items.length === 1
  1006. && that.items[0].productId === deal.productId) {
  1007. that.specialDeal = deal
  1008. } else {
  1009. that.checkoutSpecialDealId = null
  1010. that.specialDeal = null
  1011. }
  1012. } else {
  1013. that.checkoutSpecialDealId = null
  1014. that.specialDeal = null
  1015. }
  1016. }).catch(function() {
  1017. that.checkoutSpecialDealId = null
  1018. that.specialDeal = null
  1019. })
  1020. },
  1021. onDeliveryMethodChange: function(e) {
  1022. this.deliveryMethod = parseInt(e.detail.value)
  1023. this.selectedPickupLocation = null
  1024. this.selectedTimeSlot = null
  1025. this.selectedServicePerson = null
  1026. },
  1027. onPickupLocationChange: function(e) {
  1028. var idx = parseInt(e.detail.value)
  1029. if (this.pickupLocations[idx]) {
  1030. this.selectedPickupLocation = this.pickupLocations[idx]
  1031. this.selectedTimeSlot = null
  1032. }
  1033. },
  1034. onTimeSlotChange: function(e) {
  1035. var idx = parseInt(e.detail.value)
  1036. if (this.selectedPickupLocation && this.selectedPickupLocation.timeSlots && this.selectedPickupLocation.timeSlots[idx]) {
  1037. this.selectedTimeSlot = this.selectedPickupLocation.timeSlots[idx]
  1038. }
  1039. },
  1040. onServicePersonChange: function(e) {
  1041. var idx = parseInt(e.detail.value)
  1042. if (this.servicePersons[idx]) {
  1043. this.selectedServicePerson = this.servicePersons[idx]
  1044. this.selectedTimeSlot = null
  1045. }
  1046. },
  1047. onOnlineSlotChange: function(e) {
  1048. var idx = parseInt(e.detail.value)
  1049. if (this.onlineSlots[idx]) {
  1050. this.selectedTimeSlot = this.onlineSlots[idx]
  1051. }
  1052. },
  1053. deliveryMethodLabel: function(method) {
  1054. var map = { 1: '快递配送', 2: '到店自提', 3: '快递/自提', 4: '线上服务', 5: '线上预约' }
  1055. return map[method] || '快递配送'
  1056. },
  1057. deliveryMethodHint: function(method) {
  1058. var map = { 1: '', 2: '请选择自取地点和时间段', 3: '请选择配送方式', 4: '请选择服务者和时间', 5: '请选择预约时段' }
  1059. return map[method] || ''
  1060. },
  1061. selectPickupLocation(loc) {
  1062. this.selectedPickupLocation = loc
  1063. this.selectedTimeSlot = null
  1064. this.showPickupLocationModal = false
  1065. },
  1066. selectTimeSlot(slot) {
  1067. this.selectedTimeSlot = slot
  1068. this.showTimeSlotModal = false
  1069. },
  1070. selectServicePerson(person) {
  1071. this.selectedServicePerson = person
  1072. this.selectedTimeSlot = null
  1073. this.showServicePersonModal = false
  1074. },
  1075. selectOnlineSlot(slot) {
  1076. this.selectedTimeSlot = slot
  1077. this.showOnlineSlotModal = false
  1078. },
  1079. loadUserPoints() {
  1080. var that = this
  1081. uni.request({
  1082. url: config.api('/api/user/info'),
  1083. method: 'POST',
  1084. data: {},
  1085. header: {
  1086. 'Content-Type': 'application/json',
  1087. 'Authorization': 'Bearer ' + uni.getStorageSync('token')
  1088. },
  1089. success: function(res) {
  1090. if (res.data && res.data.code === 200) {
  1091. that.userTotalPoints = res.data.data.totalPoints || 0
  1092. }
  1093. }
  1094. })
  1095. },
  1096. onSubmit() {
  1097. if (!this.selectedAddress) {
  1098. uni.showToast({ title: '请选择收货地址', icon: 'none' })
  1099. return
  1100. }
  1101. if (this.items.length === 0) {
  1102. uni.showToast({ title: '请选择商品', icon: 'none' })
  1103. return
  1104. }
  1105. // 购买信息要求手签名时,必须先完成手写签名
  1106. if (this.hasHandSignatureField && !this.purchaseForm.hand_signature) {
  1107. uni.showToast({ title: '请先完成手写签名', icon: 'none' })
  1108. return
  1109. }
  1110. this.submitting = true
  1111. var orderItems = []
  1112. for (var i = 0; i < this.items.length; i++) {
  1113. var itemData = {
  1114. productId: this.items[i].productId,
  1115. quantity: this.items[i].quantity
  1116. }
  1117. if (this.items[i].skuId) {
  1118. itemData.skuId = this.items[i].skuId
  1119. }
  1120. orderItems.push(itemData)
  1121. }
  1122. var that = this
  1123. uni.request({
  1124. url: config.api('/api/product/order/create'),
  1125. method: 'POST',
  1126. data: {
  1127. items: orderItems,
  1128. giftItemIds: that.giftItemIds,
  1129. remark: this.remark,
  1130. addressId: that.selectedAddress.id,
  1131. purchaseInfo: that.purchaseForm,
  1132. pointsUsed: that.pointsUsed,
  1133. // discountAmount 仅含规则优惠(不含套餐/一口价):套餐优惠由服务端权威重算计入
  1134. discountAmount: (that.discountInfo ? that.discountInfo.discountAmount : 0),
  1135. couponId: that.selectedCoupon ? that.selectedCoupon.id : null,
  1136. // 特价单透传(无则传 null):后端 createSpecialDealOrder 校验活动后按特价结算
  1137. specialDealId: that.checkoutSpecialDealId || null,
  1138. deliveryMethod: that.deliveryMethod,
  1139. pickupLocationId: that.selectedPickupLocation ? that.selectedPickupLocation.id : null,
  1140. timeSlotId: that.selectedTimeSlot ? that.selectedTimeSlot.id : null,
  1141. servicePersonId: that.selectedServicePerson ? that.selectedServicePerson.id : null
  1142. },
  1143. header: {
  1144. 'Content-Type': 'application/json',
  1145. 'Authorization': 'Bearer ' + uni.getStorageSync('token')
  1146. },
  1147. success: function(res) {
  1148. that.submitting = false
  1149. if (res.data && res.data.code === 200) {
  1150. var order = res.data.data
  1151. uni.showToast({ title: '下单成功', icon: 'success' })
  1152. uni.removeStorageSync('checkoutItems')
  1153. uni.removeStorageSync('checkoutGiftItemIds')
  1154. uni.removeStorageSync('checkoutGiftPromo')
  1155. uni.removeStorageSync('checkoutSpecialDealId')
  1156. var moneyAmount = order.moneyAmount != null ? order.moneyAmount : order.totalAmount
  1157. var pointsUsed = order.pointsUsed || 0
  1158. setTimeout(function() {
  1159. uni.navigateTo({
  1160. url: '/pages/shop/payment/payment?orderNo=' + order.orderNo + '&amount=' + moneyAmount + '&pointsUsed=' + pointsUsed + (this.taskId ? '&taskId=' + this.taskId : '')
  1161. })
  1162. }, 1000)
  1163. } else {
  1164. uni.showToast({ title: res.data.message || '下单失败', icon: 'none' })
  1165. }
  1166. },
  1167. fail: function() {
  1168. that.submitting = false
  1169. uni.showToast({ title: '网络请求失败', icon: 'none' })
  1170. }
  1171. })
  1172. },
  1173. formatPrice(price) {
  1174. if (price === null || price === undefined) return '0.00'
  1175. return (Number(price) / 100).toFixed(2)
  1176. },
  1177. formatPhone(phone) {
  1178. if (!phone) return ''
  1179. if (phone.length === 11) {
  1180. return phone.substr(0, 3) + '****' + phone.substr(7)
  1181. }
  1182. return phone
  1183. },
  1184. selectServicePerson(person) {
  1185. this.selectedServicePerson = person
  1186. this.selectedTimeSlot = null
  1187. this.showServicePersonModal = false
  1188. },
  1189. selectOnlineSlot(slot) {
  1190. this.selectedTimeSlot = slot
  1191. this.showOnlineSlotModal = false
  1192. },
  1193. formatOnlineTime: function(timeStr) {
  1194. if (!timeStr) return ''
  1195. try {
  1196. var d = parseDate(timeStr)
  1197. if (!d) return timeStr
  1198. return (d.getMonth() + 1) + '月' + d.getDate() + '日 ' + String(d.getHours()).padStart(2, '0') + ':' + String(d.getMinutes()).padStart(2, '0')
  1199. } catch (e) {
  1200. return timeStr
  1201. }
  1202. },
  1203. showPickupLocationPicker: function() {
  1204. this.showPickupLocationModal = true
  1205. },
  1206. showTimeSlotPicker: function() {
  1207. if (!this.selectedPickupLocation) return
  1208. this.showTimeSlotModal = true
  1209. },
  1210. showServicePersonPicker: function() {
  1211. this.showServicePersonModal = true
  1212. },
  1213. showOnlineSlotPicker: function() {
  1214. this.showOnlineSlotModal = true
  1215. },
  1216. selectPickupLocation: function(loc) {
  1217. this.selectedPickupLocation = loc
  1218. this.selectedTimeSlot = null
  1219. this.showPickupLocationModal = false
  1220. },
  1221. selectTimeSlot: function(slot) {
  1222. this.selectedTimeSlot = slot
  1223. this.showTimeSlotModal = false
  1224. },
  1225. selectServicePerson: function(person) {
  1226. this.selectedServicePerson = person
  1227. this.showServicePersonModal = false
  1228. },getImageUrl: function(path) {
  1229. if (!path || path === 'null' || path === 'undefined' || path === '/null') return ''
  1230. var s = String(path).trim()
  1231. if (!s || s === 'null' || s === '/null') return ''
  1232. if (s.indexOf('http://') === 0 || s.indexOf('https://') === 0) return s
  1233. return config.API_BASE_URL + (s.charAt(0) === '/' ? s : '/' + s)
  1234. }
  1235. }
  1236. }
  1237. </script>
  1238. <style scoped lang="scss">
  1239. .container {
  1240. min-height: 100vh;
  1241. background: $facade-fill-2;
  1242. }
  1243. .loading-wrap {
  1244. display: flex;
  1245. justify-content: center;
  1246. padding-top: 200rpx;
  1247. }
  1248. .loading-text {
  1249. font-size: calc(28rpx * var(--font-scale, 1));
  1250. color: $facade-text-muted;
  1251. }
  1252. .content {
  1253. height: calc(100vh - 120rpx);
  1254. padding-bottom: 160rpx;
  1255. }
  1256. .section {
  1257. background: $app-surface;
  1258. margin: 20rpx;
  1259. border-radius: 16rpx;
  1260. padding: 24rpx;
  1261. }
  1262. .section-title {
  1263. font-size: calc(28rpx * var(--font-scale, 1));
  1264. font-weight: bold;
  1265. color: $facade-text-strong;
  1266. margin-bottom: 20rpx;
  1267. display: block;
  1268. }
  1269. .address-section {
  1270. position: relative;
  1271. }
  1272. .address-content {
  1273. position: relative;
  1274. }
  1275. .address-top {
  1276. display: flex;
  1277. align-items: center;
  1278. margin-bottom: 10rpx;
  1279. }
  1280. .receiver-name {
  1281. font-size: calc(30rpx * var(--font-scale, 1));
  1282. font-weight: bold;
  1283. color: $facade-text-strong;
  1284. margin-right: 20rpx;
  1285. }
  1286. .receiver-phone {
  1287. font-size: calc(26rpx * var(--font-scale, 1));
  1288. color: $facade-text-body;
  1289. }
  1290. .default-badge {
  1291. font-size: calc(20rpx * var(--font-scale, 1));
  1292. color: $brand-primary;
  1293. background: $brand-primary-tint-2;
  1294. padding: 2rpx 12rpx;
  1295. border-radius: 24rpx;
  1296. margin-left: 12rpx;
  1297. }
  1298. .address-detail {
  1299. font-size: calc(26rpx * var(--font-scale, 1));
  1300. color: $facade-text-muted;
  1301. line-height: 1.5;
  1302. }
  1303. .address-arrow {
  1304. position: absolute;
  1305. right: 0;
  1306. top: 50%;
  1307. font-size: calc(40rpx * var(--font-scale, 1));
  1308. color: $facade-text-ghost;
  1309. transform: translateY(-50%);
  1310. }
  1311. .address-empty {
  1312. display: flex;
  1313. align-items: center;
  1314. justify-content: center;
  1315. padding: $uni-space-lg 0;
  1316. position: relative;
  1317. }
  1318. .address-empty-icon {
  1319. font-size: calc(40rpx * var(--font-scale, 1));
  1320. margin-right: 12rpx;
  1321. }
  1322. .address-empty-text {
  1323. font-size: calc(28rpx * var(--font-scale, 1));
  1324. color: $facade-text-muted;
  1325. }
  1326. .order-item {
  1327. display: flex;
  1328. align-items: center;
  1329. padding: 16rpx 0;
  1330. border-bottom: 1rpx solid $facade-fill-2;
  1331. }
  1332. .order-item:last-child {
  1333. border-bottom: none;
  1334. }
  1335. .item-image {
  1336. width: 80rpx;
  1337. height: 80rpx;
  1338. border-radius: 8rpx;
  1339. background: $facade-fill;
  1340. margin-right: 16rpx;
  1341. }
  1342. .item-info {
  1343. flex: 1;
  1344. display: flex;
  1345. flex-direction: column;
  1346. min-width: 0;
  1347. }
  1348. .item-name {
  1349. font-size: calc(26rpx * var(--font-scale, 1));
  1350. color: $facade-text-strong;
  1351. overflow: hidden;
  1352. text-overflow: ellipsis;
  1353. white-space: nowrap;
  1354. margin-bottom: 6rpx;
  1355. }
  1356. .item-spec-desc {
  1357. font-size: calc(22rpx * var(--font-scale, 1));
  1358. color: $facade-text-muted;
  1359. display: block;
  1360. margin-top: 2rpx;
  1361. }
  1362. .item-supplier-name {
  1363. font-size: calc(20rpx * var(--font-scale, 1));
  1364. color: $uni-info;
  1365. display: block;
  1366. margin-top: 2rpx;
  1367. }
  1368. .item-qty {
  1369. font-size: calc(22rpx * var(--font-scale, 1));
  1370. color: $facade-text-muted;
  1371. }
  1372. .item-price {
  1373. font-size: calc(26rpx * var(--font-scale, 1));
  1374. color: $brand-primary;
  1375. font-weight: bold;
  1376. margin-left: 16rpx;
  1377. }
  1378. .info-row {
  1379. display: flex;
  1380. justify-content: space-between;
  1381. align-items: center;
  1382. padding: 8rpx 0;
  1383. }
  1384. .info-label {
  1385. font-size: calc(26rpx * var(--font-scale, 1));
  1386. color: $facade-text-muted;
  1387. }
  1388. .info-value {
  1389. font-size: calc(26rpx * var(--font-scale, 1));
  1390. color: $facade-text-strong;
  1391. }
  1392. .remark-input {
  1393. flex: 1;
  1394. text-align: right;
  1395. font-size: calc(26rpx * var(--font-scale, 1));
  1396. color: $facade-text-strong;
  1397. }
  1398. /* ===== Coupon Section ===== */
  1399. .coupon-section {
  1400. position: relative;
  1401. }
  1402. .coupon-section:active {
  1403. background: $facade-fill-ghost;
  1404. }
  1405. .coupon-selected {
  1406. display: flex;
  1407. align-items: center;
  1408. flex: 1;
  1409. justify-content: flex-end;
  1410. margin-right: $uni-space-lg;
  1411. }
  1412. .coupon-discount {
  1413. font-size: calc(26rpx * var(--font-scale, 1));
  1414. color: $brand-primary;
  1415. font-weight: 600;
  1416. margin-right: 12rpx;
  1417. }
  1418. .coupon-name-tag {
  1419. font-size: calc(22rpx * var(--font-scale, 1));
  1420. color: $app-surface;
  1421. background: $brand-primary;
  1422. padding: 2rpx 12rpx;
  1423. border-radius: 8rpx;
  1424. max-width: 200rpx;
  1425. overflow: hidden;
  1426. text-overflow: ellipsis;
  1427. white-space: nowrap;
  1428. }
  1429. .coupon-placeholder {
  1430. flex: 1;
  1431. text-align: right;
  1432. margin-right: $uni-space-lg;
  1433. }
  1434. .placeholder-text {
  1435. font-size: calc(26rpx * var(--font-scale, 1));
  1436. color: $facade-text-ghost;
  1437. }
  1438. .total-original {
  1439. font-size: calc(22rpx * var(--font-scale, 1));
  1440. color: $facade-text-ghost-light;
  1441. text-decoration: line-through;
  1442. margin-left: 8rpx;
  1443. }
  1444. /* ===== Member Upgrade Hint ===== */
  1445. .member-upgrade-section {
  1446. position: relative;
  1447. }
  1448. .member-upgrade-row {
  1449. display: flex;
  1450. align-items: center;
  1451. }
  1452. .member-upgrade-icon {
  1453. font-size: calc(32rpx * var(--font-scale, 1));
  1454. margin-right: 12rpx;
  1455. }
  1456. .member-upgrade-text {
  1457. flex: 1;
  1458. font-size: calc(26rpx * var(--font-scale, 1));
  1459. color: $brand-primary;
  1460. font-weight: 500;
  1461. }
  1462. .member-upgrade-arrow {
  1463. font-size: calc(32rpx * var(--font-scale, 1));
  1464. color: $brand-primary;
  1465. }
  1466. /* ===== Member Coupon Hint ===== */
  1467. .member-coupon-hint {
  1468. margin-top: -10rpx;
  1469. margin-bottom: 20rpx;
  1470. }
  1471. .member-coupon-hint-content {
  1472. display: flex;
  1473. align-items: center;
  1474. padding: 20rpx 24rpx;
  1475. background: linear-gradient(135deg, $uni-primary-pale 0%, $facade-brand-tint-2 100%);
  1476. border-radius: 16rpx;
  1477. border: 1rpx solid $brand-primary-light-2;
  1478. }
  1479. .hint-icon {
  1480. font-size: calc(32rpx * var(--font-scale, 1));
  1481. margin-right: 12rpx;
  1482. }
  1483. .hint-text {
  1484. font-size: calc(24rpx * var(--font-scale, 1));
  1485. color: $brand-primary-deep;
  1486. font-weight: 500;
  1487. }
  1488. /* ===== Coupon Picker Modal ===== */
  1489. .modal-mask {
  1490. position: fixed;
  1491. top: 0;
  1492. left: 0;
  1493. right: 0;
  1494. bottom: 0;
  1495. background: rgba(0,0,0,0.5);
  1496. z-index: 999;
  1497. display: flex;
  1498. align-items: flex-end;
  1499. }
  1500. .coupon-picker {
  1501. background: $app-surface;
  1502. border-radius: 24rpx 24rpx 0 0;
  1503. width: 100%;
  1504. max-height: 70vh;
  1505. display: flex;
  1506. flex-direction: column;
  1507. }
  1508. .picker-header {
  1509. display: flex;
  1510. justify-content: space-between;
  1511. align-items: center;
  1512. padding: $uni-space-page;
  1513. border-bottom: 1rpx solid $facade-hairline-2;
  1514. }
  1515. .picker-title {
  1516. font-size: calc(30rpx * var(--font-scale, 1));
  1517. font-weight: 600;
  1518. color: $facade-text-strong;
  1519. }
  1520. .picker-close {
  1521. font-size: calc(26rpx * var(--font-scale, 1));
  1522. color: $facade-text-muted;
  1523. }
  1524. .picker-list {
  1525. max-height: 50vh;
  1526. padding: 0 20rpx;
  1527. }
  1528. .picker-item {
  1529. display: flex;
  1530. align-items: center;
  1531. padding: 24rpx 16rpx;
  1532. border-bottom: 1rpx solid $facade-fill-2;
  1533. }
  1534. .picker-item:active {
  1535. background: $facade-fill-ghost;
  1536. }
  1537. .picker-item-active {
  1538. background: $uni-primary-pale;
  1539. }
  1540. .picker-item-left {
  1541. width: 120rpx;
  1542. text-align: center;
  1543. flex-shrink: 0;
  1544. }
  1545. .picker-item-value {
  1546. font-size: calc(32rpx * var(--font-scale, 1));
  1547. font-weight: bold;
  1548. color: $brand-primary;
  1549. }
  1550. .picker-item-right {
  1551. flex: 1;
  1552. margin: 0 16rpx;
  1553. }
  1554. .picker-item-name {
  1555. font-size: calc(26rpx * var(--font-scale, 1));
  1556. color: $facade-text-strong;
  1557. display: block;
  1558. margin-bottom: 4rpx;
  1559. }
  1560. .picker-item-condition {
  1561. font-size: calc(22rpx * var(--font-scale, 1));
  1562. color: $facade-text-muted;
  1563. }
  1564. .picker-item-check {
  1565. width: 40rpx;
  1566. height: 40rpx;
  1567. background: $brand-primary;
  1568. border-radius: 50%;
  1569. display: flex;
  1570. align-items: center;
  1571. justify-content: center;
  1572. flex-shrink: 0;
  1573. }
  1574. .check-icon {
  1575. color: $app-surface;
  1576. font-size: calc(24rpx * var(--font-scale, 1));
  1577. font-weight: bold;
  1578. }
  1579. .picker-empty {
  1580. text-align: center;
  1581. padding: 60rpx 0;
  1582. font-size: calc(26rpx * var(--font-scale, 1));
  1583. color: $facade-text-muted;
  1584. }
  1585. .picker-footer {
  1586. padding: 20rpx;
  1587. border-top: 1rpx solid $facade-hairline-2;
  1588. }
  1589. .picker-btn-remove {
  1590. background: $facade-fill-2;
  1591. color: $facade-text-body;
  1592. font-size: calc(26rpx * var(--font-scale, 1));
  1593. border-radius: 16rpx;
  1594. border: none;
  1595. }
  1596. .picker-btn-remove::after {
  1597. border: none;
  1598. }
  1599. .bottom-spacer {
  1600. height: 160rpx;
  1601. }
  1602. .bottom-bar {
  1603. position: fixed;
  1604. bottom: 0;
  1605. left: 0;
  1606. right: 0;
  1607. height: 120rpx;
  1608. background: $app-surface;
  1609. border-top: 1rpx solid $facade-hairline-2;
  1610. display: flex;
  1611. align-items: center;
  1612. justify-content: space-between;
  1613. padding: 0 $uni-space-page;
  1614. z-index: 100;
  1615. }
  1616. .bottom-left {
  1617. display: flex;
  1618. align-items: baseline;
  1619. }
  1620. .total-label {
  1621. font-size: calc(28rpx * var(--font-scale, 1));
  1622. color: $facade-text-body;
  1623. }
  1624. .total-amount {
  1625. font-size: calc(42rpx * var(--font-scale, 1));
  1626. color: $brand-primary;
  1627. font-weight: bold;
  1628. }
  1629. .submit-btn {
  1630. background: linear-gradient(135deg, $brand-primary, $brand-primary-light);
  1631. color: $app-surface;
  1632. font-size: calc(30rpx * var(--font-scale, 1));
  1633. font-weight: bold;
  1634. padding: 0 56rpx;
  1635. height: 88rpx;
  1636. line-height: 88rpx;
  1637. border-radius: 24rpx;
  1638. border: none;
  1639. margin-left: auto; /* 右下居右:无论容器是否 space-between,都贴右对齐 */
  1640. margin-right: 0; /* 覆盖微信原生 button 默认的 margin-right:auto,防止被居中 */
  1641. flex-shrink: 0; /* 不被左侧合计区挤压 */
  1642. }
  1643. .submit-btn::after {
  1644. border: none;
  1645. }
  1646. .submit-btn.disabled {
  1647. background: $facade-border-soft;
  1648. color: $facade-text-muted;
  1649. }
  1650. .points-balance {
  1651. font-size: calc(24rpx * var(--font-scale, 1));
  1652. color: $brand-primary;
  1653. }
  1654. .points-input-row {
  1655. display: flex;
  1656. align-items: center;
  1657. margin-top: 16rpx;
  1658. padding: 12rpx 0;
  1659. border-top: 1rpx solid $facade-fill-2;
  1660. }
  1661. .points-input {
  1662. flex: 1;
  1663. height: 60rpx;
  1664. font-size: calc(28rpx * var(--font-scale, 1));
  1665. color: $facade-text-strong;
  1666. background: $facade-fill-ghost-2;
  1667. border-radius: 8rpx;
  1668. padding: 0 16rpx;
  1669. }
  1670. .points-hint {
  1671. font-size: calc(24rpx * var(--font-scale, 1));
  1672. color: $facade-text-muted;
  1673. margin-left: 12rpx;
  1674. min-width: 100rpx;
  1675. text-align: right;
  1676. }
  1677. .points-tip {
  1678. margin-top: 8rpx;
  1679. }
  1680. .points-tip-text {
  1681. font-size: calc(22rpx * var(--font-scale, 1));
  1682. color: $facade-text-ghost-light;
  1683. }
  1684. .total-original {
  1685. font-size: calc(24rpx * var(--font-scale, 1));
  1686. color: $facade-text-ghost-light;
  1687. text-decoration: line-through;
  1688. margin-left: 8rpx;
  1689. }
  1690. /* ===== Purchase Info Fields ===== */
  1691. .purchase-field-row {
  1692. display: flex;
  1693. align-items: center;
  1694. padding: 16rpx 0;
  1695. border-bottom: 1rpx solid $facade-fill-2;
  1696. }
  1697. .purchase-field-row:last-child {
  1698. border-bottom: none;
  1699. }
  1700. .purchase-field-label {
  1701. font-size: calc(26rpx * var(--font-scale, 1));
  1702. color: $facade-text-strong;
  1703. width: 160rpx;
  1704. flex-shrink: 0;
  1705. }
  1706. .required-mark {
  1707. color: $el-danger;
  1708. }
  1709. .purchase-field-input {
  1710. flex: 1;
  1711. font-size: calc(26rpx * var(--font-scale, 1));
  1712. color: $facade-text-strong;
  1713. text-align: right;
  1714. padding: 8rpx 0;
  1715. }
  1716. .purchase-field-input[disabled] {
  1717. background: transparent;
  1718. color: $facade-text-muted;
  1719. }
  1720. .purchase-field-prefill {
  1721. font-size: calc(22rpx * var(--font-scale, 1));
  1722. color: $el-success;
  1723. margin-left: 8rpx;
  1724. }
  1725. /* ===== 购买信息-手签名 ===== */
  1726. .purchase-signature-block {
  1727. margin-top: 24rpx;
  1728. }
  1729. .purchase-signature-title {
  1730. font-size: calc(26rpx * var(--font-scale, 1));
  1731. color: $facade-text-strong;
  1732. font-weight: bold;
  1733. margin-bottom: 12rpx;
  1734. }
  1735. /* 配送方式选择 */
  1736. .delivery-sub-label {
  1737. font-size: calc(24rpx * var(--font-scale, 1));
  1738. color: $facade-text-muted;
  1739. margin-bottom: 12rpx;
  1740. margin-top: 16rpx;
  1741. }
  1742. .picker-row {
  1743. display: flex;
  1744. align-items: center;
  1745. justify-content: space-between;
  1746. padding: 20rpx 0;
  1747. border-bottom: 1rpx solid $facade-fill-2;
  1748. }
  1749. .picker-row:last-child {
  1750. border-bottom: none;
  1751. }
  1752. .picker-value {
  1753. font-size: calc(28rpx * var(--font-scale, 1));
  1754. color: $facade-text-strong;
  1755. flex: 1;
  1756. }
  1757. .picker-placeholder {
  1758. font-size: calc(28rpx * var(--font-scale, 1));
  1759. color: $facade-text-muted;
  1760. flex: 1;
  1761. }
  1762. .picker-arrow {
  1763. font-size: calc(32rpx * var(--font-scale, 1));
  1764. color: $facade-text-ghost;
  1765. margin-left: 10rpx;
  1766. }
  1767. .modal-mask {
  1768. position: fixed;
  1769. top: 0;
  1770. left: 0;
  1771. right: 0;
  1772. bottom: 0;
  1773. background: rgba(0,0,0,0.5);
  1774. z-index: 999;
  1775. display: flex;
  1776. align-items: flex-end;
  1777. }
  1778. .picker-modal {
  1779. width: 100%;
  1780. background: $app-surface;
  1781. border-radius: 24rpx 24rpx 0 0;
  1782. max-height: 70vh;
  1783. display: flex;
  1784. flex-direction: column;
  1785. }
  1786. .picker-modal .picker-header {
  1787. display: flex;
  1788. justify-content: space-between;
  1789. align-items: center;
  1790. padding: $uni-space-page;
  1791. border-bottom: 1rpx solid $facade-hairline-2;
  1792. }
  1793. .picker-modal .picker-title {
  1794. font-size: calc(32rpx * var(--font-scale, 1));
  1795. font-weight: bold;
  1796. color: $facade-text-strong;
  1797. }
  1798. .picker-modal .picker-close {
  1799. font-size: calc(28rpx * var(--font-scale, 1));
  1800. color: $facade-text-muted;
  1801. }
  1802. .picker-modal .picker-list {
  1803. flex: 1;
  1804. max-height: 50vh;
  1805. padding: 20rpx $uni-space-page;
  1806. }
  1807. .picker-modal .picker-item {
  1808. display: flex;
  1809. align-items: center;
  1810. padding: 24rpx 0;
  1811. border-bottom: 1rpx solid $facade-fill-2;
  1812. }
  1813. .picker-modal .picker-item:last-child {
  1814. border-bottom: none;
  1815. }
  1816. .picker-modal .picker-item-active {
  1817. background: $brand-primary-tint-2;
  1818. border-radius: 16rpx;
  1819. padding: 24rpx 16rpx;
  1820. }
  1821. .picker-modal .picker-item-left {
  1822. flex: 1;
  1823. min-width: 0;
  1824. }
  1825. .picker-modal .picker-item-name {
  1826. font-size: calc(28rpx * var(--font-scale, 1));
  1827. color: $facade-text-strong;
  1828. display: block;
  1829. }
  1830. .picker-modal .picker-item-addr {
  1831. font-size: calc(24rpx * var(--font-scale, 1));
  1832. color: $facade-text-muted;
  1833. margin-top: 6rpx;
  1834. display: block;
  1835. }
  1836. .picker-modal .picker-item-desc {
  1837. font-size: calc(24rpx * var(--font-scale, 1));
  1838. color: $facade-text-muted;
  1839. margin-top: 4rpx;
  1840. display: block;
  1841. }
  1842. .picker-modal .picker-item-price {
  1843. font-size: calc(26rpx * var(--font-scale, 1));
  1844. color: $brand-primary;
  1845. font-weight: bold;
  1846. margin-top: 4rpx;
  1847. display: block;
  1848. }
  1849. .picker-modal .picker-item-check {
  1850. margin-left: 16rpx;
  1851. color: $brand-primary;
  1852. font-size: calc(32rpx * var(--font-scale, 1));
  1853. }
  1854. /* Gift membership progress */
  1855. .gift-progress-section {
  1856. background: $uni-primary-pale;
  1857. border-radius: 16rpx;
  1858. border: 2rpx solid $brand-primary-light-2;
  1859. }
  1860. .gift-progress-header {
  1861. display: flex;
  1862. align-items: center;
  1863. margin-bottom: 16rpx;
  1864. }
  1865. .gift-progress-icon {
  1866. font-size: calc(32rpx * var(--font-scale, 1));
  1867. margin-right: 12rpx;
  1868. }
  1869. .gift-progress-title {
  1870. flex: 1;
  1871. font-size: calc(26rpx * var(--font-scale, 1));
  1872. color: $brand-primary-deep;
  1873. font-weight: 500;
  1874. }
  1875. .gift-progress-percent {
  1876. font-size: calc(28rpx * var(--font-scale, 1));
  1877. color: $brand-primary;
  1878. font-weight: bold;
  1879. }
  1880. .gift-progress-bar-bg {
  1881. height: 20rpx;
  1882. background: $brand-primary-light-2;
  1883. border-radius: 8rpx;
  1884. overflow: hidden;
  1885. margin-bottom: 12rpx;
  1886. }
  1887. .gift-progress-bar-fill {
  1888. height: 100%;
  1889. background: linear-gradient(90deg, $brand-primary, $brand-primary-light);
  1890. border-radius: 8rpx;
  1891. }
  1892. .gift-progress-info {
  1893. display: flex;
  1894. justify-content: space-between;
  1895. }
  1896. .gift-progress-accumulated {
  1897. font-size: calc(22rpx * var(--font-scale, 1));
  1898. color: $mat-orange-deep;
  1899. }
  1900. .gift-progress-remaining {
  1901. font-size: calc(22rpx * var(--font-scale, 1));
  1902. color: $brand-primary-deep;
  1903. font-weight: 500;
  1904. }
  1905. .gift-progress-level {
  1906. margin-top: 12rpx;
  1907. font-size: calc(22rpx * var(--font-scale, 1));
  1908. color: $brand-primary;
  1909. }
  1910. .gift-progress-note {
  1911. display: block;
  1912. margin-top: 8rpx;
  1913. font-size: calc(20rpx * var(--font-scale, 1));
  1914. color: $mat-orange-deep;
  1915. }
  1916. .gift-granted-section {
  1917. background: $status-success-tint-2;
  1918. border-radius: 16rpx;
  1919. border: 2rpx solid $tint-green-line;
  1920. }
  1921. .gift-granted-row {
  1922. display: flex;
  1923. align-items: center;
  1924. }
  1925. .gift-granted-icon {
  1926. font-size: calc(32rpx * var(--font-scale, 1));
  1927. margin-right: 12rpx;
  1928. }
  1929. .gift-granted-text {
  1930. flex: 1;
  1931. font-size: calc(26rpx * var(--font-scale, 1));
  1932. color: #15803D;
  1933. }
  1934. .gift-promo-section {
  1935. background: $uni-primary-pale;
  1936. border-radius: 16rpx;
  1937. border: 2rpx solid $brand-primary-light-2;
  1938. margin: 20rpx;
  1939. padding: 20rpx;
  1940. }
  1941. .gift-promo-row {
  1942. display: flex;
  1943. align-items: center;
  1944. justify-content: space-between;
  1945. }
  1946. .gift-promo-icon {
  1947. font-size: calc(32rpx * var(--font-scale, 1));
  1948. margin-right: 12rpx;
  1949. }
  1950. .gift-promo-content {
  1951. flex: 1;
  1952. }
  1953. .gift-promo-title {
  1954. font-size: calc(26rpx * var(--font-scale, 1));
  1955. color: $brand-primary-deep;
  1956. font-weight: 500;
  1957. }
  1958. .gift-promo-desc {
  1959. font-size: calc(22rpx * var(--font-scale, 1));
  1960. color: $mat-orange-deep;
  1961. margin-top: 4rpx;
  1962. }
  1963. .gift-promo-save {
  1964. font-size: calc(22rpx * var(--font-scale, 1));
  1965. color: $brand-primary;
  1966. }
  1967. /* 保持原有样式向下延伸 */
  1968. </style>