checkout.vue 54 KB

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