checkout.vue 49 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656
  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. :key="field.fieldKey"
  106. class="purchase-field-row"
  107. >
  108. <text class="purchase-field-label">
  109. {{ field.fieldName }}
  110. <text v-if="field.isRequired" class="required-mark">*</text>
  111. </text>
  112. <input
  113. v-model="purchaseForm[field.fieldKey]"
  114. class="purchase-field-input"
  115. :placeholder="'请输入' + field.fieldName + (field.isRequired ? '' : '(选填)')"
  116. :disabled="!!field.prefillValue"
  117. placeholder-style="color: #ccc; font-size: 26rpx;"
  118. />
  119. <text v-if="field.prefillValue" class="purchase-field-prefill">已填写</text>
  120. </view>
  121. </view>
  122. <!-- Order Items Section -->
  123. <view class="section">
  124. <text class="section-title">商品信息</text>
  125. <view
  126. v-for="item in items"
  127. :key="item.productId"
  128. class="order-item"
  129. >
  130. <image
  131. class="item-image"
  132. :src="getImageUrl(item.coverImage) || '/static/default-product.png'"
  133. mode="aspectFill"
  134. />
  135. <view class="item-info">
  136. <text class="item-name">{{ item.productName }}</text>
  137. <text v-if="item.specDesc" class="item-spec-desc">{{ item.specDesc }}</text>
  138. <text v-if="item.supplierName" class="item-supplier-name">供应商: {{ item.supplierName }}</text>
  139. <text class="item-qty">x{{ item.quantity }}</text>
  140. </view>
  141. <text class="item-price">{{ formatPriceWithSymbol(item.unitPrice) }}</text>
  142. </view>
  143. </view>
  144. <!-- Freight Section -->
  145. <view class="section">
  146. <view class="info-row">
  147. <text class="info-label">运费</text>
  148. <text class="info-value">{{ formatPriceWithSymbol(freight) }}</text>
  149. </view>
  150. </view>
  151. <!-- Member Upgrade Hint -->
  152. <view v-if="!isMember" class="section member-upgrade-section" @click="goUpgrade">
  153. <view class="member-upgrade-row">
  154. <text class="member-upgrade-icon">👑</text>
  155. <text class="member-upgrade-text">开通会员享全场商品专享价</text>
  156. <text class="member-upgrade-arrow">›</text>
  157. </view>
  158. </view>
  159. <!-- Limited-Time Discount Section -->
  160. <view v-if="discountInfo" class="section discount-section">
  161. <view class="info-row">
  162. <text class="info-label">限时折扣</text>
  163. <text class="discount-amount">-{{ formatPriceWithSymbol(discountInfo.discountAmount) }}</text>
  164. </view>
  165. <view class="discount-rule-name">{{ discountInfo.ruleName || '' }}</view>
  166. <countdown-tag v-if="discountInfo.endTime" :end-time="discountInfo.endTime" />
  167. </view>
  168. <!-- Coupon Section -->
  169. <view class="section coupon-section" @click="openCouponPicker">
  170. <view class="info-row">
  171. <text class="info-label">优惠券</text>
  172. <view class="coupon-selected" v-if="selectedCoupon">
  173. <text class="coupon-discount">-{{ formatPriceWithSymbol(selectedCoupon.value) }}</text>
  174. <text class="coupon-name-tag">{{ selectedCoupon.name }}</text>
  175. </view>
  176. <view class="coupon-placeholder" v-else>
  177. <text class="placeholder-text">选择优惠券</text>
  178. </view>
  179. <text class="address-arrow">›</text>
  180. </view>
  181. </view>
  182. <view v-if="!isMember" class="section member-coupon-hint">
  183. <view class="member-coupon-hint-content">
  184. <text class="hint-icon">👑</text>
  185. <text class="hint-text">加入会员可使用优惠券享更多优惠</text>
  186. </view>
  187. </view>
  188. <!-- Points Deduction Section -->
  189. <view class="section" v-if="userTotalPoints > 0">
  190. <view class="info-row">
  191. <text class="info-label">积分抵扣</text>
  192. <text class="points-balance">可用 {{ userTotalPoints }} 积分</text>
  193. </view>
  194. <view class="points-input-row">
  195. <input
  196. class="points-input"
  197. type="number"
  198. :value="pointsUsed"
  199. @input="onPointsInput"
  200. placeholder="输入使用积分"
  201. placeholder-style="color: #ccc; font-size: 26rpx;"
  202. />
  203. <text class="points-hint">≈ ¥{{ pointsYuanEquivalent }}</text>
  204. </view>
  205. <view class="points-tip">
  206. <text class="points-tip-text">1积分 = ¥0.01,最多使用 {{ maxPoints }} 积分</text>
  207. </view>
  208. </view>
  209. <!-- Remark Section -->
  210. <view class="section">
  211. <view class="info-row">
  212. <text class="info-label">备注</text>
  213. <input
  214. class="remark-input"
  215. v-model="remark"
  216. placeholder="选填,给商家留言"
  217. placeholder-style="color: #ccc; font-size: 26rpx;"
  218. />
  219. </view>
  220. </view>
  221. <view class="bottom-spacer"></view>
  222. </scroll-view>
  223. <!-- 优惠券选择器必须与 scroll-view 平级,否则 iOS 上 position: fixed 在 scroll-view 内不生效(优惠券弹窗不显示) -->
  224. <view class="modal-mask" v-if="showCouponPicker" @click="closeCouponPicker">
  225. <view class="coupon-picker" @click.stop>
  226. <view class="picker-header">
  227. <text class="picker-title">选择优惠券</text>
  228. <text class="picker-close" @click="closeCouponPicker">关闭</text>
  229. </view>
  230. <scroll-view scroll-y class="picker-list">
  231. <!-- 已拥有优惠券 -->
  232. <view class="picker-section-title" v-if="ownedCoupons.length > 0">已拥有优惠券</view>
  233. <view
  234. v-for="coupon in ownedCoupons"
  235. :key="coupon.id"
  236. class="picker-item"
  237. :class="selectedCoupon && selectedCoupon.id === coupon.id ? 'picker-item-active' : ''"
  238. @click="selectCoupon(coupon)"
  239. >
  240. <view class="picker-item-left">
  241. <text class="picker-item-value">{{ formatPriceWithSymbol(coupon.value) }}</text>
  242. </view>
  243. <view class="picker-item-right">
  244. <text class="picker-item-name">{{ coupon.name }}</text>
  245. <text class="picker-item-condition">{{ getConditionText(coupon.minSpend) }}</text>
  246. </view>
  247. <view class="picker-item-check" v-if="selectedCoupon && selectedCoupon.id === coupon.id">
  248. <text class="check-icon">✓</text>
  249. </view>
  250. </view>
  251. <!-- 可兑换优惠券(需CF值):仅在 CF 足够兑换其中一张券时才提醒 -->
  252. <view class="picker-section-title" v-if="affordableExchangeCoupons.length > 0">
  253. 可用CF值兑换(当前余额 {{ cfBalance }} CF)
  254. </view>
  255. <view
  256. v-for="coupon in affordableExchangeCoupons"
  257. :key="coupon.id"
  258. class="picker-item picker-item-exchange"
  259. >
  260. <view class="picker-item-left">
  261. <text class="picker-item-value">{{ formatPriceWithSymbol(coupon.value) }}</text>
  262. </view>
  263. <view class="picker-item-right">
  264. <text class="picker-item-name">{{ coupon.name }}</text>
  265. <text class="picker-item-condition">{{ getConditionText(coupon.minSpend) }}</text>
  266. </view>
  267. <button
  268. class="exchange-btn"
  269. :disabled="coupon.exchanging"
  270. @click.stop="doExchangeCoupon(coupon)"
  271. >
  272. {{ coupon.exchanging ? '兑换中...' : '兑换' }}
  273. </button>
  274. </view>
  275. <view class="picker-empty" v-if="ownedCoupons.length === 0 && affordableExchangeCoupons.length === 0">
  276. <text>暂无可用优惠券</text>
  277. </view>
  278. </scroll-view>
  279. <view class="picker-footer" v-if="selectedCoupon">
  280. <button class="picker-btn-remove" @click="removeCoupon">不使用优惠券</button>
  281. </view>
  282. </view>
  283. </view>
  284. <!-- 自取地点选择器 -->
  285. <view class="modal-mask" v-if="showPickupLocationModal" @click="showPickupLocationModal=false">
  286. <view class="picker-modal" @click.stop>
  287. <view class="picker-header">
  288. <text class="picker-title">选择自取地点</text>
  289. <text class="picker-close" @click="showPickupLocationModal=false">关闭</text>
  290. </view>
  291. <scroll-view scroll-y class="picker-list">
  292. <view
  293. v-for="(loc, idx) in pickupLocations"
  294. :key="loc.id"
  295. class="picker-item"
  296. :class="selectedPickupLocation && selectedPickupLocation.id === loc.id ? 'picker-item-active' : ''"
  297. @click="selectPickupLocation(loc)"
  298. >
  299. <view class="picker-item-left">
  300. <text class="picker-item-name">{{ loc.name }}</text>
  301. <text class="picker-item-addr">{{ loc.address }}</text>
  302. </view>
  303. <view class="picker-item-check" v-if="selectedPickupLocation && selectedPickupLocation.id === loc.id">
  304. <text class="check-icon">✓</text>
  305. </view>
  306. </view>
  307. </scroll-view>
  308. </view>
  309. </view>
  310. <!-- 时间段选择器 -->
  311. <view class="modal-mask" v-if="showTimeSlotModal" @click="showTimeSlotModal=false">
  312. <view class="picker-modal" @click.stop>
  313. <view class="picker-header">
  314. <text class="picker-title">选择取货时间</text>
  315. <text class="picker-close" @click="showTimeSlotModal=false">关闭</text>
  316. </view>
  317. <scroll-view scroll-y class="picker-list">
  318. <view
  319. v-for="(slot, idx) in (selectedPickupLocation && selectedPickupLocation.timeSlots) || []"
  320. :key="slot.id"
  321. class="picker-item"
  322. :class="selectedTimeSlot && selectedTimeSlot.id === slot.id ? 'picker-item-active' : ''"
  323. @click="selectTimeSlot(slot)"
  324. >
  325. <view class="picker-item-left">
  326. <text class="picker-item-name">{{ slot.startTime }} - {{ slot.endTime }}</text>
  327. </view>
  328. <view class="picker-item-check" v-if="selectedTimeSlot && selectedTimeSlot.id === slot.id">
  329. <text class="check-icon">✓</text>
  330. </view>
  331. </view>
  332. </scroll-view>
  333. </view>
  334. </view>
  335. <!-- 服务者选择器 -->
  336. <view class="modal-mask" v-if="showServicePersonModal" @click="showServicePersonModal=false">
  337. <view class="picker-modal" @click.stop>
  338. <view class="picker-header">
  339. <text class="picker-title">选择服务者</text>
  340. <text class="picker-close" @click="showServicePersonModal=false">关闭</text>
  341. </view>
  342. <scroll-view scroll-y class="picker-list">
  343. <view
  344. v-for="(person, idx) in servicePersons"
  345. :key="person.id"
  346. class="picker-item"
  347. :class="selectedServicePerson && selectedServicePerson.id === person.id ? 'picker-item-active' : ''"
  348. @click="selectServicePerson(person)"
  349. >
  350. <view class="picker-item-left">
  351. <text class="picker-item-name">{{ person.name }}</text>
  352. <text class="picker-item-desc">{{ person.title || '' }}</text>
  353. <text class="picker-item-price">{{ formatPriceWithSymbol(person.price) }}</text>
  354. </view>
  355. <view class="picker-item-check" v-if="selectedServicePerson && selectedServicePerson.id === person.id">
  356. <text class="check-icon">✓</text>
  357. </view>
  358. </view>
  359. </scroll-view>
  360. </view>
  361. </view>
  362. <!-- 线上时间段选择器 -->
  363. <view class="modal-mask" v-if="showOnlineSlotModal" @click="showOnlineSlotModal=false">
  364. <view class="picker-modal" @click.stop>
  365. <view class="picker-header">
  366. <text class="picker-title">选择服务时间</text>
  367. <text class="picker-close" @click="showOnlineSlotModal=false">关闭</text>
  368. </view>
  369. <scroll-view scroll-y class="picker-list">
  370. <view
  371. v-for="slot in onlineTimeSlots"
  372. :key="slot.id"
  373. class="picker-item"
  374. :class="selectedTimeSlot && selectedTimeSlot.id === slot.id ? 'picker-item-active' : ''"
  375. @click="selectOnlineSlot(slot)"
  376. >
  377. <view class="picker-item-left">
  378. <text class="picker-item-name">{{ formatOnlineTime(slot.startTime) }} - {{ formatOnlineTime(slot.endTime) }}</text>
  379. </view>
  380. <view class="picker-item-check" v-if="selectedTimeSlot && selectedTimeSlot.id === slot.id">
  381. <text class="check-icon">✓</text>
  382. </view>
  383. </view>
  384. </scroll-view>
  385. </view>
  386. </view>
  387. <view class="bottom-bar">
  388. <view class="bottom-left">
  389. <text class="total-label">合计: </text>
  390. <text class="total-amount">{{ formatPriceWithSymbol(finalAmount) }}</text>
  391. <text v-if="selectedCoupon" class="total-original">{{ formatPriceWithSymbol(actualAmount + freight) }}</text>
  392. </view>
  393. <button
  394. :class="['submit-btn', submitting ? 'disabled' : '']"
  395. :disabled="submitting"
  396. @click="onSubmit"
  397. >提交订单</button>
  398. </view>
  399. </view>
  400. </template>
  401. <script>
  402. import config from '@/config.js'
  403. import { getCouponList, getCouponCheckoutList, addressList, getProductRequiredFields, getMyMembership, productDetail, getFamilyPlatformBalance, exchangeCouponByCf, shopDiscountCalculate } from '../../../utils/api.js'
  404. import { parseDate } from '@/utils/format.js'
  405. import CountdownTag from '@/components/countdown-tag.vue'
  406. export default {
  407. components: {
  408. CountdownTag
  409. },
  410. data() {
  411. return {
  412. items: [],
  413. selectedAddress: null,
  414. requiredFields: [], // 需要的购买信息字段
  415. purchaseForm: {}, // 用户填写的购买信息
  416. addressList: [],
  417. freight: 0,
  418. remark: '',
  419. loading: false,
  420. submitting: false,
  421. actualAmount: 0,
  422. coupons: [],
  423. exchangeableCoupons: [],
  424. cfBalance: 0,
  425. selectedCoupon: null,
  426. showCouponPicker: false,
  427. pointsUsed: 0,
  428. userTotalPoints: 0,
  429. pointsLoading: false,
  430. isMember: false,
  431. // 配送配置
  432. deliveryMethod: 1,
  433. productDeliveryConfig: null,
  434. pickupLocations: [],
  435. selectedPickupLocation: null,
  436. selectedTimeSlot: null,
  437. servicePersons: [],
  438. selectedServicePerson: null,
  439. onlineSlots: [],
  440. // 弹窗控制
  441. showPickupLocationModal: false,
  442. showTimeSlotModal: false,
  443. showServicePersonModal: false,
  444. showOnlineSlotModal: false,
  445. giftItemIds: [],
  446. discountInfo: null
  447. }
  448. },
  449. computed: {
  450. finalAmount() {
  451. var total = (this.actualAmount || 0) + (this.freight || 0)
  452. if (this.selectedCoupon) {
  453. total = total - this.selectedCoupon.value
  454. }
  455. total = total - (this.pointsUsed || 0)
  456. if (total < 0) total = 0
  457. return total
  458. },
  459. maxPoints() {
  460. var total = (this.actualAmount || 0) + (this.freight || 0)
  461. if (this.selectedCoupon) {
  462. total = total - this.selectedCoupon.value
  463. }
  464. if (total < 0) total = 0
  465. if (this.userTotalPoints < total) {
  466. return this.userTotalPoints
  467. }
  468. return total
  469. },
  470. pointsYuanEquivalent() {
  471. return (this.pointsUsed / 100).toFixed(2)
  472. },
  473. ownedCoupons() {
  474. var self = this
  475. var currentProductId = (self.items && self.items.length > 0) ? self.items[0].productId : null
  476. return this.coupons.filter(function(c) {
  477. if (c.status && c.status !== 'AVAILABLE') return false
  478. if (c.minSpend && c.minSpend > self.actualAmount) return false
  479. if (c.applicableTo === 'PRODUCT' && c.productId != null) {
  480. return c.productId === currentProductId
  481. }
  482. if (c.applicableTo && c.applicableTo !== 'ALL' && c.applicableTo !== 'PRODUCT') return false
  483. return true
  484. })
  485. },
  486. availableCoupons() {
  487. var self = this
  488. var currentProductId = (self.items && self.items.length > 0) ? self.items[0].productId : null
  489. return this.coupons.filter(function(c) {
  490. if (c.status && c.status !== 'AVAILABLE') return false
  491. if (c.minSpend && c.minSpend > self.actualAmount) return false
  492. if (c.applicableTo === 'PRODUCT' && c.productId != null) {
  493. return c.productId === currentProductId
  494. }
  495. if (c.applicableTo && c.applicableTo !== 'ALL' && c.applicableTo !== 'PRODUCT') return false
  496. return true
  497. })
  498. },
  499. affordableExchangeCoupons() {
  500. var self = this
  501. return (this.exchangeableCoupons || []).filter(function(c) {
  502. return c.pointsPrice > 0 && self.cfBalance >= c.pointsPrice
  503. })
  504. },
  505. onlineTimeSlots() {
  506. if (this.deliveryMethod === 4 && this.selectedServicePerson) {
  507. return this.selectedServicePerson.slots || []
  508. }
  509. if (this.deliveryMethod === 5) {
  510. return this.onlineSlots
  511. }
  512. return []
  513. }
  514. },
  515. onLoad(options) {
  516. var that = this
  517. var stored = uni.getStorageSync('checkoutItems')
  518. var giftIds = uni.getStorageSync('checkoutGiftItemIds')
  519. this.giftItemIds = (giftIds && giftIds.length > 0) ? giftIds : []
  520. if (stored && stored.length > 0) {
  521. this.items = stored
  522. this.calcAmount()
  523. } else if (options.productId) {
  524. // Load product directly from detail page
  525. var productData = {
  526. productId: parseInt(options.productId),
  527. productName: options.productName || '商品',
  528. coverImage: options.coverImage || '',
  529. unitPrice: parseInt(options.price) || 0,
  530. quantity: parseInt(options.quantity) || 1
  531. }
  532. if (options.skuId) {
  533. productData.skuId = parseInt(options.skuId)
  534. }
  535. this.items = [productData]
  536. this.calcAmount()
  537. }
  538. this.checkMemberStatus()
  539. this.loadDefaultAddress()
  540. this.loadRequiredFields()
  541. this.loadCoupons()
  542. this.loadExchangeableCoupons()
  543. this.loadCfBalance()
  544. this.loadUserPoints()
  545. this.loadDeliveryConfig()
  546. this.loadDiscount()
  547. this._onLoadFired = true
  548. },
  549. onShow() {
  550. // 从地址选择/编辑页返回后重新加载地址列表(首次进入跳过,避免与 onLoad 双发)
  551. if (this._onLoadFired) {
  552. this._onLoadFired = false
  553. } else {
  554. this.loadDefaultAddress()
  555. }
  556. },
  557. methods: {
  558. calcAmount() {
  559. var total = 0
  560. for (var i = 0; i < this.items.length; i++) {
  561. total = total + (this.items[i].unitPrice * this.items[i].quantity)
  562. }
  563. this.actualAmount = total
  564. },
  565. async loadCoupons() {
  566. try {
  567. var res = await getCouponList()
  568. this.coupons = res.data || []
  569. } catch (e) {
  570. this.coupons = []
  571. }
  572. },
  573. async loadExchangeableCoupons() {
  574. try {
  575. var productId = null
  576. if (this.items && this.items.length > 0) {
  577. productId = this.items[0].productId
  578. }
  579. var res = await getCouponCheckoutList({ productId: productId })
  580. this.exchangeableCoupons = res.data || []
  581. } catch (e) {
  582. console.error('加载可兑换优惠券失败', e)
  583. this.exchangeableCoupons = []
  584. }
  585. },
  586. async loadCfBalance() {
  587. try {
  588. var res = await getFamilyPlatformBalance()
  589. if (res.code === 200 && res.data) {
  590. this.cfBalance = res.data.available || 0
  591. }
  592. } catch (e) {
  593. console.error('加载CF余额失败', e)
  594. }
  595. },
  596. async doExchangeCoupon(coupon) {
  597. if (coupon.pointsPrice > this.cfBalance) {
  598. uni.showToast({ title: 'CF值不足,当前可用 ' + this.cfBalance + ' CF值', icon: 'none' })
  599. return
  600. }
  601. coupon.exchanging = true
  602. uni.showLoading({ title: '兑换中...' })
  603. try {
  604. var res = await exchangeCouponByCf({ couponId: coupon.id })
  605. uni.hideLoading()
  606. coupon.exchanging = false
  607. if (res.code === 200) {
  608. uni.showToast({ title: '兑换成功', icon: 'success' })
  609. // 从可兑换列表移除,加入已拥有列表
  610. var idx = this.exchangeableCoupons.findIndex(function(c) { return c.id === coupon.id })
  611. if (idx >= 0) {
  612. this.exchangeableCoupons.splice(idx, 1)
  613. }
  614. coupon.isExchangeable = false
  615. coupon.status = 'AVAILABLE'
  616. this.coupons.push(coupon)
  617. // 刷新余额
  618. this.loadCfBalance()
  619. } else {
  620. uni.showToast({ title: res.message || '兑换失败', icon: 'none' })
  621. }
  622. } catch (e) {
  623. uni.hideLoading()
  624. coupon.exchanging = false
  625. uni.showToast({ title: '兑换失败', icon: 'none' })
  626. }
  627. },
  628. openCouponPicker() {
  629. if (this.availableCoupons.length === 0 && !this.selectedCoupon) {
  630. uni.showToast({ title: '暂无可用优惠券', icon: 'none' })
  631. return
  632. }
  633. this.showCouponPicker = true
  634. },
  635. closeCouponPicker() {
  636. this.showCouponPicker = false
  637. },
  638. selectCoupon(coupon) {
  639. this.selectedCoupon = coupon
  640. this.showCouponPicker = false
  641. },
  642. removeCoupon() {
  643. this.selectedCoupon = null
  644. this.showCouponPicker = false
  645. },
  646. onPointsInput(e) {
  647. var val = parseInt(e.detail.value) || 0
  648. if (val < 0) val = 0
  649. var maxP = this.maxPoints
  650. if (val > maxP) {
  651. val = maxP
  652. uni.showToast({ title: '最多使用 ' + maxP + ' 积分', icon: 'none' })
  653. }
  654. this.pointsUsed = val
  655. },
  656. getConditionText(minSpend) {
  657. if (!minSpend || minSpend <= 0) return '无门槛'
  658. return '满' + (minSpend / 100).toFixed(2) + '元可用'
  659. },
  660. async loadDefaultAddress() {
  661. this.loading = true
  662. try {
  663. var res = await addressList()
  664. if (res.code === 200) {
  665. var list = res.data || []
  666. this.addressList = list
  667. // 如果当前已有选中地址,保持选中状态
  668. if (this.selectedAddress) {
  669. var stillExists = false
  670. for (var k = 0; k < list.length; k++) {
  671. if (list[k].id === this.selectedAddress.id) {
  672. stillExists = true
  673. break
  674. }
  675. }
  676. if (!stillExists) {
  677. this.selectedAddress = null
  678. }
  679. }
  680. if (!this.selectedAddress) {
  681. for (var i = 0; i < list.length; i++) {
  682. if (list[i].isDefault === 1) {
  683. this.selectedAddress = list[i]
  684. break
  685. }
  686. }
  687. if (!this.selectedAddress && list.length > 0) {
  688. this.selectedAddress = list[0]
  689. }
  690. }
  691. }
  692. } catch (e) {
  693. console.error(e)
  694. } finally {
  695. this.loading = false
  696. }
  697. },
  698. async loadRequiredFields() {
  699. if (this.items.length === 0) return
  700. var productId = this.items[0].productId
  701. try {
  702. var res = await getProductRequiredFields(productId)
  703. if (res.code === 200) {
  704. this.requiredFields = res.data || []
  705. this.autoFillPurchaseForm()
  706. }
  707. } catch (e) {
  708. console.error(e)
  709. }
  710. },
  711. autoFillPurchaseForm() {
  712. if (!this.selectedAddress || this.requiredFields.length === 0) return
  713. var form = {}
  714. for (var i = 0; i < this.requiredFields.length; i++) {
  715. var field = this.requiredFields[i]
  716. if (field.prefillValue) {
  717. form[field.fieldKey] = field.prefillValue
  718. } else {
  719. form[field.fieldKey] = ''
  720. }
  721. }
  722. this.purchaseForm = form
  723. },
  724. openAddressPicker() {
  725. if (this.addressList.length === 0) {
  726. uni.showToast({ title: '暂无地址,请先添加', icon: 'none' })
  727. return
  728. }
  729. uni.navigateTo({ url: '/pages/shop/address/address?selectMode=1' })
  730. },
  731. checkMemberStatus() {
  732. var that = this
  733. getMyMembership().then(function(res) {
  734. if (res.data && res.data.memberLevel) {
  735. that.isMember = res.data.memberLevel !== 'FREE'
  736. }
  737. }).catch(function() {})
  738. },
  739. goUpgrade() {
  740. uni.navigateTo({ url: '/pages/membership/upgrade' })
  741. },
  742. goAddAddress() {
  743. uni.navigateTo({ url: '/pages/shop/address-edit/address-edit' })
  744. },
  745. // ========== 配送方式相关 ==========
  746. loadDeliveryConfig() {
  747. if (this.items.length === 0) return
  748. var productId = this.items[0].productId
  749. if (!productId) return
  750. var stored = uni.getStorageSync('checkoutItems')
  751. var storageData = stored && stored.length > 0 ? stored[0] : {}
  752. var deliveryMethod = storageData.deliveryMethod
  753. if (!deliveryMethod || deliveryMethod <= 1) return
  754. this.deliveryMethod = deliveryMethod
  755. this.productDeliveryConfig = storageData.deliveryConfig || null
  756. // 如果来自产品详情,可能已有选中值
  757. if (storageData.pickupLocationId) {
  758. this.selectedPickupLocation = { id: storageData.pickupLocationId }
  759. }
  760. if (storageData.timeSlotId) {
  761. this.selectedTimeSlot = { id: storageData.timeSlotId }
  762. }
  763. if (storageData.servicePersonId) {
  764. this.selectedServicePerson = { id: storageData.servicePersonId }
  765. }
  766. // 加载完整配置
  767. var that = this
  768. productDetail({ id: productId }).then(function(res) {
  769. if (res.code === 200 && res.data && res.data.deliveryConfig) {
  770. that.productDeliveryConfig = res.data.deliveryConfig
  771. that.deliveryMethod = res.data.deliveryMethod || that.deliveryMethod
  772. that.pickupLocations = res.data.deliveryConfig.pickupLocations || []
  773. that.servicePersons = res.data.deliveryConfig.servicePersons || []
  774. that.onlineSlots = res.data.deliveryConfig.onlineSlots || []
  775. }
  776. }).catch(function() {})
  777. },
  778. loadDiscount() {
  779. var that = this
  780. if (this.items.length === 0) return
  781. var productIds = []
  782. for (var i = 0; i < this.items.length; i++) {
  783. if (this.items[i].productId) productIds.push(this.items[i].productId)
  784. }
  785. if (productIds.length === 0) return
  786. shopDiscountCalculate({
  787. productIds: productIds,
  788. orderAmount: this.actualAmount
  789. }).then(function(res) {
  790. if (res.code === 200 && res.data) {
  791. that.discountInfo = res.data
  792. }
  793. }).catch(function() {})
  794. },
  795. onDeliveryMethodChange: function(e) {
  796. this.deliveryMethod = parseInt(e.detail.value)
  797. this.selectedPickupLocation = null
  798. this.selectedTimeSlot = null
  799. this.selectedServicePerson = null
  800. },
  801. onPickupLocationChange: function(e) {
  802. var idx = parseInt(e.detail.value)
  803. if (this.pickupLocations[idx]) {
  804. this.selectedPickupLocation = this.pickupLocations[idx]
  805. this.selectedTimeSlot = null
  806. }
  807. },
  808. onTimeSlotChange: function(e) {
  809. var idx = parseInt(e.detail.value)
  810. if (this.selectedPickupLocation && this.selectedPickupLocation.timeSlots && this.selectedPickupLocation.timeSlots[idx]) {
  811. this.selectedTimeSlot = this.selectedPickupLocation.timeSlots[idx]
  812. }
  813. },
  814. onServicePersonChange: function(e) {
  815. var idx = parseInt(e.detail.value)
  816. if (this.servicePersons[idx]) {
  817. this.selectedServicePerson = this.servicePersons[idx]
  818. this.selectedTimeSlot = null
  819. }
  820. },
  821. onOnlineSlotChange: function(e) {
  822. var idx = parseInt(e.detail.value)
  823. if (this.onlineSlots[idx]) {
  824. this.selectedTimeSlot = this.onlineSlots[idx]
  825. }
  826. },
  827. deliveryMethodLabel: function(method) {
  828. var map = { 1: '快递配送', 2: '到店自提', 3: '快递/自提', 4: '线上服务', 5: '线上预约' }
  829. return map[method] || '快递配送'
  830. },
  831. deliveryMethodHint: function(method) {
  832. var map = { 1: '', 2: '请选择自取地点和时间段', 3: '请选择配送方式', 4: '请选择服务者和时间', 5: '请选择预约时段' }
  833. return map[method] || ''
  834. },
  835. selectPickupLocation(loc) {
  836. this.selectedPickupLocation = loc
  837. this.selectedTimeSlot = null
  838. this.showPickupLocationModal = false
  839. },
  840. selectTimeSlot(slot) {
  841. this.selectedTimeSlot = slot
  842. this.showTimeSlotModal = false
  843. },
  844. selectServicePerson(person) {
  845. this.selectedServicePerson = person
  846. this.selectedTimeSlot = null
  847. this.showServicePersonModal = false
  848. },
  849. selectOnlineSlot(slot) {
  850. this.selectedTimeSlot = slot
  851. this.showOnlineSlotModal = false
  852. },
  853. loadUserPoints() {
  854. var that = this
  855. uni.request({
  856. url: config.api('/api/user/info'),
  857. method: 'POST',
  858. data: {},
  859. header: {
  860. 'Content-Type': 'application/json',
  861. 'Authorization': 'Bearer ' + uni.getStorageSync('token')
  862. },
  863. success: function(res) {
  864. if (res.data && res.data.code === 200) {
  865. that.userTotalPoints = res.data.data.totalPoints || 0
  866. }
  867. }
  868. })
  869. },
  870. onSubmit() {
  871. if (!this.selectedAddress) {
  872. uni.showToast({ title: '请选择收货地址', icon: 'none' })
  873. return
  874. }
  875. if (this.items.length === 0) {
  876. uni.showToast({ title: '请选择商品', icon: 'none' })
  877. return
  878. }
  879. this.submitting = true
  880. var orderItems = []
  881. for (var i = 0; i < this.items.length; i++) {
  882. var itemData = {
  883. productId: this.items[i].productId,
  884. quantity: this.items[i].quantity
  885. }
  886. if (this.items[i].skuId) {
  887. itemData.skuId = this.items[i].skuId
  888. }
  889. orderItems.push(itemData)
  890. }
  891. var that = this
  892. uni.request({
  893. url: config.api('/api/product/order/create'),
  894. method: 'POST',
  895. data: {
  896. items: orderItems,
  897. giftItemIds: that.giftItemIds,
  898. remark: this.remark,
  899. addressId: that.selectedAddress.id,
  900. purchaseInfo: that.purchaseForm,
  901. pointsUsed: that.pointsUsed,
  902. discountAmount: that.discountInfo ? that.discountInfo.discountAmount : 0,
  903. deliveryMethod: that.deliveryMethod,
  904. pickupLocationId: that.selectedPickupLocation ? that.selectedPickupLocation.id : null,
  905. timeSlotId: that.selectedTimeSlot ? that.selectedTimeSlot.id : null,
  906. servicePersonId: that.selectedServicePerson ? that.selectedServicePerson.id : null
  907. },
  908. header: {
  909. 'Content-Type': 'application/json',
  910. 'Authorization': 'Bearer ' + uni.getStorageSync('token')
  911. },
  912. success: function(res) {
  913. that.submitting = false
  914. if (res.data && res.data.code === 200) {
  915. var order = res.data.data
  916. uni.showToast({ title: '下单成功', icon: 'success' })
  917. uni.removeStorageSync('checkoutItems')
  918. uni.removeStorageSync('checkoutGiftItemIds')
  919. var moneyAmount = order.moneyAmount != null ? order.moneyAmount : order.totalAmount
  920. var pointsUsed = order.pointsUsed || 0
  921. setTimeout(function() {
  922. uni.navigateTo({
  923. url: '/pages/shop/payment/payment?orderNo=' + order.orderNo + '&amount=' + moneyAmount + '&pointsUsed=' + pointsUsed
  924. })
  925. }, 1000)
  926. } else {
  927. uni.showToast({ title: res.data.message || '下单失败', icon: 'none' })
  928. }
  929. },
  930. fail: function() {
  931. that.submitting = false
  932. uni.showToast({ title: '网络请求失败', icon: 'none' })
  933. }
  934. })
  935. },
  936. formatPrice(price) {
  937. if (price === null || price === undefined) return '0.00'
  938. return (Number(price) / 100).toFixed(2)
  939. },
  940. formatPhone(phone) {
  941. if (!phone) return ''
  942. if (phone.length === 11) {
  943. return phone.substr(0, 3) + '****' + phone.substr(7)
  944. }
  945. return phone
  946. },
  947. selectServicePerson(person) {
  948. this.selectedServicePerson = person
  949. this.selectedTimeSlot = null
  950. this.showServicePersonModal = false
  951. },
  952. selectOnlineSlot(slot) {
  953. this.selectedTimeSlot = slot
  954. this.showOnlineSlotModal = false
  955. },
  956. formatOnlineTime: function(timeStr) {
  957. if (!timeStr) return ''
  958. try {
  959. var d = parseDate(timeStr)
  960. if (!d) return timeStr
  961. return (d.getMonth() + 1) + '月' + d.getDate() + '日 ' + String(d.getHours()).padStart(2, '0') + ':' + String(d.getMinutes()).padStart(2, '0')
  962. } catch (e) {
  963. return timeStr
  964. }
  965. },
  966. showPickupLocationPicker: function() {
  967. this.showPickupLocationModal = true
  968. },
  969. showTimeSlotPicker: function() {
  970. if (!this.selectedPickupLocation) return
  971. this.showTimeSlotModal = true
  972. },
  973. showServicePersonPicker: function() {
  974. this.showServicePersonModal = true
  975. },
  976. showOnlineSlotPicker: function() {
  977. this.showOnlineSlotModal = true
  978. },
  979. selectPickupLocation: function(loc) {
  980. this.selectedPickupLocation = loc
  981. this.selectedTimeSlot = null
  982. this.showPickupLocationModal = false
  983. },
  984. selectTimeSlot: function(slot) {
  985. this.selectedTimeSlot = slot
  986. this.showTimeSlotModal = false
  987. },
  988. selectServicePerson: function(person) {
  989. this.selectedServicePerson = person
  990. this.showServicePersonModal = false
  991. },
  992. getImageUrl: function(path) {
  993. return config.API_BASE_URL + path
  994. }
  995. }
  996. }
  997. </script>
  998. <style scoped>
  999. .container {
  1000. min-height: 100vh;
  1001. background: #f5f5f5;
  1002. }
  1003. .loading-wrap {
  1004. display: flex;
  1005. justify-content: center;
  1006. padding-top: 200rpx;
  1007. }
  1008. .loading-text {
  1009. font-size: 28rpx;
  1010. color: #999;
  1011. }
  1012. .content {
  1013. height: calc(100vh - 120rpx);
  1014. }
  1015. .section {
  1016. background: #fff;
  1017. margin: 20rpx;
  1018. border-radius: 16rpx;
  1019. padding: 24rpx;
  1020. }
  1021. .section-title {
  1022. font-size: 28rpx;
  1023. font-weight: bold;
  1024. color: #333;
  1025. margin-bottom: 20rpx;
  1026. display: block;
  1027. }
  1028. .address-section {
  1029. position: relative;
  1030. }
  1031. .address-content {
  1032. position: relative;
  1033. }
  1034. .address-top {
  1035. display: flex;
  1036. align-items: center;
  1037. margin-bottom: 10rpx;
  1038. }
  1039. .receiver-name {
  1040. font-size: 30rpx;
  1041. font-weight: bold;
  1042. color: #333;
  1043. margin-right: 20rpx;
  1044. }
  1045. .receiver-phone {
  1046. font-size: 26rpx;
  1047. color: #666;
  1048. }
  1049. .default-badge {
  1050. font-size: 20rpx;
  1051. color: #F97316;
  1052. background: #fff7e6;
  1053. padding: 2rpx 12rpx;
  1054. border-radius: 20rpx;
  1055. margin-left: 12rpx;
  1056. }
  1057. .address-detail {
  1058. font-size: 26rpx;
  1059. color: #999;
  1060. line-height: 1.5;
  1061. }
  1062. .address-arrow {
  1063. position: absolute;
  1064. right: 0;
  1065. top: 50%;
  1066. font-size: 40rpx;
  1067. color: #ccc;
  1068. transform: translateY(-50%);
  1069. }
  1070. .address-empty {
  1071. display: flex;
  1072. align-items: center;
  1073. justify-content: center;
  1074. padding: 30rpx 0;
  1075. position: relative;
  1076. }
  1077. .address-empty-icon {
  1078. font-size: 40rpx;
  1079. margin-right: 12rpx;
  1080. }
  1081. .address-empty-text {
  1082. font-size: 28rpx;
  1083. color: #999;
  1084. }
  1085. .order-item {
  1086. display: flex;
  1087. align-items: center;
  1088. padding: 16rpx 0;
  1089. border-bottom: 1rpx solid #f5f5f5;
  1090. }
  1091. .order-item:last-child {
  1092. border-bottom: none;
  1093. }
  1094. .item-image {
  1095. width: 80rpx;
  1096. height: 80rpx;
  1097. border-radius: 8rpx;
  1098. background: #f0f0f0;
  1099. margin-right: 16rpx;
  1100. }
  1101. .item-info {
  1102. flex: 1;
  1103. display: flex;
  1104. flex-direction: column;
  1105. min-width: 0;
  1106. }
  1107. .item-name {
  1108. font-size: 26rpx;
  1109. color: #333;
  1110. overflow: hidden;
  1111. text-overflow: ellipsis;
  1112. white-space: nowrap;
  1113. margin-bottom: 6rpx;
  1114. }
  1115. .item-spec-desc {
  1116. font-size: 22rpx;
  1117. color: #999;
  1118. display: block;
  1119. margin-top: 2rpx;
  1120. }
  1121. .item-supplier-name {
  1122. font-size: 20rpx;
  1123. color: #0EA5E9;
  1124. display: block;
  1125. margin-top: 2rpx;
  1126. }
  1127. .item-qty {
  1128. font-size: 22rpx;
  1129. color: #999;
  1130. }
  1131. .item-price {
  1132. font-size: 26rpx;
  1133. color: #F97316;
  1134. font-weight: bold;
  1135. margin-left: 16rpx;
  1136. }
  1137. .info-row {
  1138. display: flex;
  1139. justify-content: space-between;
  1140. align-items: center;
  1141. padding: 8rpx 0;
  1142. }
  1143. .info-label {
  1144. font-size: 26rpx;
  1145. color: #999;
  1146. }
  1147. .info-value {
  1148. font-size: 26rpx;
  1149. color: #333;
  1150. }
  1151. .remark-input {
  1152. flex: 1;
  1153. text-align: right;
  1154. font-size: 26rpx;
  1155. color: #333;
  1156. }
  1157. /* ===== Coupon Section ===== */
  1158. .coupon-section {
  1159. position: relative;
  1160. }
  1161. .coupon-section:active {
  1162. background: #fafafa;
  1163. }
  1164. .coupon-selected {
  1165. display: flex;
  1166. align-items: center;
  1167. flex: 1;
  1168. justify-content: flex-end;
  1169. margin-right: 30rpx;
  1170. }
  1171. .coupon-discount {
  1172. font-size: 26rpx;
  1173. color: #F97316;
  1174. font-weight: 600;
  1175. margin-right: 12rpx;
  1176. }
  1177. .coupon-name-tag {
  1178. font-size: 22rpx;
  1179. color: #fff;
  1180. background: #F97316;
  1181. padding: 2rpx 12rpx;
  1182. border-radius: 6rpx;
  1183. max-width: 200rpx;
  1184. overflow: hidden;
  1185. text-overflow: ellipsis;
  1186. white-space: nowrap;
  1187. }
  1188. .coupon-placeholder {
  1189. flex: 1;
  1190. text-align: right;
  1191. margin-right: 30rpx;
  1192. }
  1193. .placeholder-text {
  1194. font-size: 26rpx;
  1195. color: #ccc;
  1196. }
  1197. .total-original {
  1198. font-size: 22rpx;
  1199. color: #bbb;
  1200. text-decoration: line-through;
  1201. margin-left: 8rpx;
  1202. }
  1203. /* ===== Member Upgrade Hint ===== */
  1204. .member-upgrade-section {
  1205. position: relative;
  1206. }
  1207. .member-upgrade-row {
  1208. display: flex;
  1209. align-items: center;
  1210. }
  1211. .member-upgrade-icon {
  1212. font-size: 32rpx;
  1213. margin-right: 12rpx;
  1214. }
  1215. .member-upgrade-text {
  1216. flex: 1;
  1217. font-size: 26rpx;
  1218. color: #F97316;
  1219. font-weight: 500;
  1220. }
  1221. .member-upgrade-arrow {
  1222. font-size: 32rpx;
  1223. color: #F97316;
  1224. }
  1225. /* ===== Member Coupon Hint ===== */
  1226. .member-coupon-hint {
  1227. margin-top: -10rpx;
  1228. margin-bottom: 20rpx;
  1229. }
  1230. .member-coupon-hint-content {
  1231. display: flex;
  1232. align-items: center;
  1233. padding: 20rpx 24rpx;
  1234. background: linear-gradient(135deg, #FFF7ED 0%, #FFEDD5 100%);
  1235. border-radius: 16rpx;
  1236. border: 1rpx solid #FED7AA;
  1237. }
  1238. .hint-icon {
  1239. font-size: 32rpx;
  1240. margin-right: 12rpx;
  1241. }
  1242. .hint-text {
  1243. font-size: 24rpx;
  1244. color: #C2410C;
  1245. font-weight: 500;
  1246. }
  1247. /* ===== Coupon Picker Modal ===== */
  1248. .modal-mask {
  1249. position: fixed;
  1250. top: 0;
  1251. left: 0;
  1252. right: 0;
  1253. bottom: 0;
  1254. background: rgba(0,0,0,0.5);
  1255. z-index: 999;
  1256. display: flex;
  1257. align-items: flex-end;
  1258. }
  1259. .coupon-picker {
  1260. background: #fff;
  1261. border-radius: 24rpx 24rpx 0 0;
  1262. width: 100%;
  1263. max-height: 70vh;
  1264. display: flex;
  1265. flex-direction: column;
  1266. }
  1267. .picker-header {
  1268. display: flex;
  1269. justify-content: space-between;
  1270. align-items: center;
  1271. padding: 30rpx;
  1272. border-bottom: 1rpx solid #eee;
  1273. }
  1274. .picker-title {
  1275. font-size: 30rpx;
  1276. font-weight: 600;
  1277. color: #333;
  1278. }
  1279. .picker-close {
  1280. font-size: 26rpx;
  1281. color: #999;
  1282. }
  1283. .picker-list {
  1284. max-height: 50vh;
  1285. padding: 0 20rpx;
  1286. }
  1287. .picker-item {
  1288. display: flex;
  1289. align-items: center;
  1290. padding: 24rpx 16rpx;
  1291. border-bottom: 1rpx solid #f5f5f5;
  1292. }
  1293. .picker-item:active {
  1294. background: #fafafa;
  1295. }
  1296. .picker-item-active {
  1297. background: #FFF7ED;
  1298. }
  1299. .picker-item-left {
  1300. width: 120rpx;
  1301. text-align: center;
  1302. flex-shrink: 0;
  1303. }
  1304. .picker-item-value {
  1305. font-size: 32rpx;
  1306. font-weight: bold;
  1307. color: #F97316;
  1308. }
  1309. .picker-item-right {
  1310. flex: 1;
  1311. margin: 0 16rpx;
  1312. }
  1313. .picker-item-name {
  1314. font-size: 26rpx;
  1315. color: #333;
  1316. display: block;
  1317. margin-bottom: 4rpx;
  1318. }
  1319. .picker-item-condition {
  1320. font-size: 22rpx;
  1321. color: #999;
  1322. }
  1323. .picker-item-check {
  1324. width: 40rpx;
  1325. height: 40rpx;
  1326. background: #F97316;
  1327. border-radius: 50%;
  1328. display: flex;
  1329. align-items: center;
  1330. justify-content: center;
  1331. flex-shrink: 0;
  1332. }
  1333. .check-icon {
  1334. color: #fff;
  1335. font-size: 24rpx;
  1336. font-weight: bold;
  1337. }
  1338. .picker-empty {
  1339. text-align: center;
  1340. padding: 60rpx 0;
  1341. font-size: 26rpx;
  1342. color: #999;
  1343. }
  1344. .picker-footer {
  1345. padding: 20rpx;
  1346. border-top: 1rpx solid #eee;
  1347. }
  1348. .picker-btn-remove {
  1349. background: #f5f5f5;
  1350. color: #666;
  1351. font-size: 26rpx;
  1352. border-radius: 12rpx;
  1353. border: none;
  1354. }
  1355. .picker-btn-remove::after {
  1356. border: none;
  1357. }
  1358. .bottom-spacer {
  1359. height: 140rpx;
  1360. }
  1361. .bottom-bar {
  1362. position: fixed;
  1363. bottom: 0;
  1364. left: 0;
  1365. right: 0;
  1366. height: 100rpx;
  1367. background: #fff;
  1368. border-top: 1rpx solid #eee;
  1369. display: flex;
  1370. align-items: center;
  1371. justify-content: space-between;
  1372. padding: 0 30rpx;
  1373. z-index: 100;
  1374. }
  1375. .bottom-left {
  1376. display: flex;
  1377. align-items: baseline;
  1378. }
  1379. .total-label {
  1380. font-size: 26rpx;
  1381. color: #666;
  1382. }
  1383. .total-amount {
  1384. font-size: 36rpx;
  1385. color: #F97316;
  1386. font-weight: bold;
  1387. }
  1388. .submit-btn {
  1389. background: linear-gradient(135deg, #F97316, #FB923C);
  1390. color: #fff;
  1391. font-size: 28rpx;
  1392. font-weight: bold;
  1393. padding: 0 60rpx;
  1394. height: 72rpx;
  1395. line-height: 72rpx;
  1396. border-radius: 36rpx;
  1397. border: none;
  1398. }
  1399. .submit-btn::after {
  1400. border: none;
  1401. }
  1402. .submit-btn.disabled {
  1403. background: #ddd;
  1404. color: #999;
  1405. }
  1406. .points-balance {
  1407. font-size: 24rpx;
  1408. color: #F97316;
  1409. }
  1410. .points-input-row {
  1411. display: flex;
  1412. align-items: center;
  1413. margin-top: 16rpx;
  1414. padding: 12rpx 0;
  1415. border-top: 1rpx solid #f5f5f5;
  1416. }
  1417. .points-input {
  1418. flex: 1;
  1419. height: 60rpx;
  1420. font-size: 28rpx;
  1421. color: #333;
  1422. background: #f9f9f9;
  1423. border-radius: 8rpx;
  1424. padding: 0 16rpx;
  1425. }
  1426. .points-hint {
  1427. font-size: 24rpx;
  1428. color: #999;
  1429. margin-left: 12rpx;
  1430. min-width: 100rpx;
  1431. text-align: right;
  1432. }
  1433. .points-tip {
  1434. margin-top: 8rpx;
  1435. }
  1436. .points-tip-text {
  1437. font-size: 22rpx;
  1438. color: #bbb;
  1439. }
  1440. .total-original {
  1441. font-size: 24rpx;
  1442. color: #bbb;
  1443. text-decoration: line-through;
  1444. margin-left: 8rpx;
  1445. }
  1446. /* ===== Purchase Info Fields ===== */
  1447. .purchase-field-row {
  1448. display: flex;
  1449. align-items: center;
  1450. padding: 16rpx 0;
  1451. border-bottom: 1rpx solid #f5f5f5;
  1452. }
  1453. .purchase-field-row:last-child {
  1454. border-bottom: none;
  1455. }
  1456. .purchase-field-label {
  1457. font-size: 26rpx;
  1458. color: #333;
  1459. width: 160rpx;
  1460. flex-shrink: 0;
  1461. }
  1462. .required-mark {
  1463. color: #f56c6c;
  1464. }
  1465. .purchase-field-input {
  1466. flex: 1;
  1467. font-size: 26rpx;
  1468. color: #333;
  1469. text-align: right;
  1470. padding: 8rpx 0;
  1471. }
  1472. .purchase-field-input[disabled] {
  1473. background: transparent;
  1474. color: #999;
  1475. }
  1476. .purchase-field-prefill {
  1477. font-size: 22rpx;
  1478. color: #67c23a;
  1479. margin-left: 8rpx;
  1480. }
  1481. /* 配送方式选择 */
  1482. .delivery-sub-label {
  1483. font-size: 24rpx;
  1484. color: #999;
  1485. margin-bottom: 12rpx;
  1486. margin-top: 16rpx;
  1487. }
  1488. .picker-row {
  1489. display: flex;
  1490. align-items: center;
  1491. justify-content: space-between;
  1492. padding: 20rpx 0;
  1493. border-bottom: 1rpx solid #f5f5f5;
  1494. }
  1495. .picker-row:last-child {
  1496. border-bottom: none;
  1497. }
  1498. .picker-value {
  1499. font-size: 28rpx;
  1500. color: #333;
  1501. flex: 1;
  1502. }
  1503. .picker-placeholder {
  1504. font-size: 28rpx;
  1505. color: #999;
  1506. flex: 1;
  1507. }
  1508. .picker-arrow {
  1509. font-size: 32rpx;
  1510. color: #ccc;
  1511. margin-left: 10rpx;
  1512. }
  1513. .modal-mask {
  1514. position: fixed;
  1515. top: 0;
  1516. left: 0;
  1517. right: 0;
  1518. bottom: 0;
  1519. background: rgba(0,0,0,0.5);
  1520. z-index: 999;
  1521. display: flex;
  1522. align-items: flex-end;
  1523. }
  1524. .picker-modal {
  1525. width: 100%;
  1526. background: #fff;
  1527. border-radius: 24rpx 24rpx 0 0;
  1528. max-height: 70vh;
  1529. display: flex;
  1530. flex-direction: column;
  1531. }
  1532. .picker-modal .picker-header {
  1533. display: flex;
  1534. justify-content: space-between;
  1535. align-items: center;
  1536. padding: 30rpx;
  1537. border-bottom: 1rpx solid #eee;
  1538. }
  1539. .picker-modal .picker-title {
  1540. font-size: 32rpx;
  1541. font-weight: bold;
  1542. color: #333;
  1543. }
  1544. .picker-modal .picker-close {
  1545. font-size: 28rpx;
  1546. color: #999;
  1547. }
  1548. .picker-modal .picker-list {
  1549. flex: 1;
  1550. max-height: 50vh;
  1551. padding: 20rpx 30rpx;
  1552. }
  1553. .picker-modal .picker-item {
  1554. display: flex;
  1555. align-items: center;
  1556. padding: 24rpx 0;
  1557. border-bottom: 1rpx solid #f5f5f5;
  1558. }
  1559. .picker-modal .picker-item:last-child {
  1560. border-bottom: none;
  1561. }
  1562. .picker-modal .picker-item-active {
  1563. background: #fff7e6;
  1564. border-radius: 12rpx;
  1565. padding: 24rpx 16rpx;
  1566. }
  1567. .picker-modal .picker-item-left {
  1568. flex: 1;
  1569. min-width: 0;
  1570. }
  1571. .picker-modal .picker-item-name {
  1572. font-size: 28rpx;
  1573. color: #333;
  1574. display: block;
  1575. }
  1576. .picker-modal .picker-item-addr {
  1577. font-size: 24rpx;
  1578. color: #999;
  1579. margin-top: 6rpx;
  1580. display: block;
  1581. }
  1582. .picker-modal .picker-item-desc {
  1583. font-size: 24rpx;
  1584. color: #999;
  1585. margin-top: 4rpx;
  1586. display: block;
  1587. }
  1588. .picker-modal .picker-item-price {
  1589. font-size: 26rpx;
  1590. color: #F97316;
  1591. font-weight: bold;
  1592. margin-top: 4rpx;
  1593. display: block;
  1594. }
  1595. .picker-modal .picker-item-check {
  1596. margin-left: 16rpx;
  1597. color: #F97316;
  1598. font-size: 32rpx;
  1599. }
  1600. </style>