checkout.vue 69 KB

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