checkout.vue 58 KB

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