checkout.vue 71 KB

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