create.vue 49 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549
  1. <template>
  2. <view class="order-submission">
  3. <navigator url="/pages/address/list?source=1" v-if="shippingType === 1" class="address">
  4. <view class="address-head">服务地址</view>
  5. <view v-if="addressData.phone" class="address-main">
  6. <image src="../../static/order/address.png" class="address-left"></image>
  7. <view class="address-text">{{ addressData.province }} {{ addressData.city }} {{ addressData.county }}
  8. {{ addressData.address }}
  9. </view>
  10. <image src="../../static/order/right.png" class="address-right"></image>
  11. </view>
  12. <view class="padding-tb-sm" v-else>
  13. 请选择配送地址
  14. </view>
  15. </navigator>
  16. <image class="a-bg"
  17. src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAu4AAAAFCAYAAAAaAW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fsdn2+QYpeH7/8CBe+mAsq7nIsevKEjivgv1dQdzYUGH7dMlXe3FmwxZMTRyFgiZkW48mF0/XMYWqm75JfH8IUmPA1tlUMnHv+8T3N3J8d3Hkey6I3re6Djvaam1v/urhswjdsQ2jf/kVJRI1xHdPrh1lltzTWUxXai5H07N74P7KettnPDQyjWtf/ohglyJfl7jz/drP+vDrzgYsLZdtP2PRnz6B/u4t9I+U9cYCH81hddoFuBG4bxNq7v9xSfh+G/H9wKkIwF5JkR38fF3VLb73dDXhpsYS8P0Vxve7MZ14E04EkX2SumDj40Lkjz2LS9x1nZVqcK1rh1L/GaiZDB1GYwGPRi9+sA4r63odGEjAoKTZS0mTwUtoS2sTPioc1jd64KJqNZXRP9EtLFrLT5KQOd6H1JtvQ/SUQ1CUC1Z/tjp5MgXn51bAfc1VpAUVb6pqi+bsqRlrOB0ITSI0kUa1IvF7JcribPbxZnt9BYIeBZm0ap1BO2yHLMOIxjH111chmDocXg9XzZFR4fD74e5cA9GtQEulbLGbfaNMvv4+BfG3hiet9wxlUeDGdDPn68uqXVgVKKezbiBN/HHYoTnrqlORkDx0BHr/ABzVVbknbZysZ3wnRVyda6HU1UIjvpt28p2C+T+GEtYeeEh3jqcdKjl2BcWY65q9UAQb+c6+k3iePnaS+P5Pq8spOJ38fJ09RVI1OFuWo6xtJXSD+J6xh++OHN8PEt8HxtNY4pbAczC+m2Rnh8V3J9Q0Fa4LeG97YQdehj4aoSL9NZiZNMTKStp6g5/x5NsW37vWQaS1WXzPHvjihzYS/lgshbeJ75WySHm7wNXXk8SbK/xutOX4ntHtYRxE0eJn6uARaGf6ie++7GPNxVkf/78AAwCn1+RYqusbZQAAAABJRU5ErkJggg=="></image>
  18. <view class="goods">
  19. <view class="goods-head flex">
  20. <view class="goods-head-text">服务时间</view>
  21. <view @click="selectTime" style="text-align: right;" class="goods-head-time text-cut padding-right-sm">
  22. {{ shippingType === 2 ? orderReqeust.predictTime.replaceAll('送达', '取货') : orderReqeust.predictTime }}
  23. </view>
  24. <image src="../../static/order/time-right.png" class="goods-head-right"></image>
  25. </view>
  26. <view class="goods-one" v-if="orderReqeust.productList.length ==1">
  27. <image class="goods-img"
  28. :src="(orderReqeust.productList[0].productAttrImg?JSON.parse(orderReqeust.productList[0].productAttrImg)[0].url:JSON.parse(orderReqeust.productList[0].productImg)[0].url)"></image>
  29. <view class="goods-text">
  30. <view class="goods-name">{{ orderReqeust.productList[0].productAttrName }}</view>
  31. <view class="goods-tag">
  32. <view class="goods-price"
  33. v-if="!orderReqeust.isIntegral && (orderReqeust.seckillId || orderReqeust.groupShopId)">
  34. ¥{{ orderReqeust.productList[0].price }}
  35. </view>
  36. <view class="goods-price"
  37. v-if="!orderReqeust.isIntegral && !orderReqeust.seckillId && !orderReqeust.groupShopId">
  38. ¥{{ isVip ? orderReqeust.productList[0].vipPrice : orderReqeust.productList[0].price }}
  39. </view>
  40. <view class="goods-price" style="color: red" v-if="orderReqeust.isIntegral">
  41. 积分{{ orderReqeust.productList[0].integral }}
  42. </view>
  43. <view class="goods-yprice">¥{{ orderReqeust.productList[0].otPrice }}</view>
  44. <view class="goods-number">×{{ orderReqeust.productList[0].cartNum }}</view>
  45. </view>
  46. </view>
  47. </view>
  48. <view class="goods-one" v-else>
  49. <view class="scroll_box">
  50. <scroll-view scroll-x="true">
  51. <block v-for="(item, index) in orderReqeust.productList" :key="index">
  52. <image class="goods-more-img"
  53. :src="(item.productAttrImg?JSON.parse(item.productAttrImg)[0].url:JSON.parse(item.productImg)[0].url)"></image>
  54. </block>
  55. </scroll-view>
  56. </view>
  57. <view class="goods-more-number">共{{ orderReqeust.totalNumber }}件</view>
  58. <image src="../../static/order/time-right.png" class="goods-more-right"></image>
  59. </view>
  60. </view>
  61. <view class="distribution">
  62. <view class="distribution-list distribution-list-bottom" v-if="shippingType === 2">
  63. <view class="distribution-text">联系人</view>
  64. <view class="distribution-price"><input type="text" v-model="orderReqeust.name"
  65. placeholder="请输入您的联系姓名"></view>
  66. </view>
  67. <view class="distribution-list distribution-list-bottom" v-if="shippingType === 2">
  68. <view class="distribution-text">联系电话</view>
  69. <view class="distribution-price"><input type="text" v-model="orderReqeust.phone"
  70. placeholder="请输入您的联系电话"></view>
  71. </view>
  72. <view class="distribution-list distribution-list-bottom"
  73. :class="{ 'disabled': !hasCoupons }"
  74. @click="hasCoupons ? toggleMask('show') : null"
  75. v-if="!orderReqeust.isIntegral">
  76. <view class="distribution-text">优惠券
  77. <!-- 新增最佳优惠标识 -->
  78. <view v-if="orderReqeust.coupon && orderReqeust.coupon.id === bestCouponId" class="best-coupon">
  79. 最佳优惠
  80. </view>
  81. </view>
  82. <view class="distribution-price" :style="{ color: hasCoupons ? 'red' : '#999' }">
  83. {{
  84. orderReqeust.coupon ? "-¥" + orderReqeust.coupon.couponPrice : (hasCoupons ? '选择优惠券' : '暂无优惠券')
  85. }}
  86. </view>
  87. </view>
  88. <view class="distribution-list">
  89. <view class="distribution-text">备注</view>
  90. <view class="distribution-price"><input type="text" v-model="orderReqeust.mono" placeholder="请输入备注信息">
  91. </view>
  92. </view>
  93. <view class="distribution-list distribution-list-bottom" v-if="shippingType === 1">
  94. <view class="distribution-text" style="width: 250rpx">加急费用(可选)</view>
  95. <view class="distribution-price" style="display: flex; align-items: center; justify-content: flex-end;flex:1; width: 430upx">
  96. <input type="number" v-model.number="orderReqeust.urgentFee"
  97. placeholder="请输入加急费用"
  98. style="text-align: right; flex: 1; border: none; outline: none;">
  99. <text style="margin-left: 5rpx;">元</text>
  100. </view>
  101. </view>
  102. <!-- 照片上传区域 -->
  103. <view class="distribution-list photo-upload-section distribution-list-bottom">
  104. <view class="distribution-text">订单照片</view>
  105. <view class="photo-upload-container">
  106. <view class="photo-list">
  107. <!-- 已上传的照片预览 -->
  108. <view
  109. v-for="(photo, index) in orderReqeust.photos"
  110. :key="index"
  111. class="photo-item"
  112. >
  113. <image :src="photo" class="photo-preview" mode="aspectFill" @click="previewPhoto(index)"></image>
  114. <view class="photo-delete" @click="deletePhoto(index)">
  115. <text class="photo-delete-icon">×</text>
  116. </view>
  117. </view>
  118. <!-- 添加照片按钮 -->
  119. <view
  120. v-if="orderReqeust.photos.length < 6"
  121. class="photo-add-btn"
  122. @click="choosePhoto"
  123. >
  124. <text class="photo-add-icon">+</text>
  125. <text class="photo-add-text">添加照片</text>
  126. </view>
  127. </view>
  128. <view class="photo-tips">最多可上传6张照片</view>
  129. </view>
  130. </view>
  131. </view>
  132. <view class="distribution">
  133. <view class="distribution-list distribution-list-bottom">
  134. <view class="distribution-text pay-text">支付方式</view>
  135. </view>
  136. <view v-if="!orderReqeust.isIntegral" class="distribution-list distribution-list-bottom"
  137. @click="changePayType('WX')">
  138. <view class="distribution-text">微信</view>
  139. <view class="distribution-price">
  140. <image
  141. :src="payType === 'WX'?'../../static/order/xuanzhong.png':'../../static/order/xuanzhong-no.png'"></image>
  142. </view>
  143. </view>
  144. <view v-if="!orderReqeust.isIntegral" class="distribution-list" @click="changePayType('BALANCE')">
  145. <view class="distribution-text">余额</view>
  146. <view class="distribution-price">
  147. <image
  148. :src="payType === 'BALANCE'?'../../static/order/xuanzhong.png':'../../static/order/xuanzhong-no.png'"></image>
  149. </view>
  150. </view>
  151. <view v-if="orderReqeust.isIntegral" class="distribution-list" @click="changePayType('INTEGRAL')">
  152. <view class="distribution-text">积分</view>
  153. <view class="distribution-price">
  154. <image
  155. :src="payType === 'INTEGRAL'?'../../static/order/xuanzhong.png':'../../static/order/xuanzhong-no.png'"></image>
  156. </view>
  157. </view>
  158. </view>
  159. <!-- 优惠券面板 -->
  160. <view class="mask" :class="maskState===0 ? 'none' : maskState===1 ? 'show' : ''" @click="toggleMask">
  161. <view class="mask-content" @click.stop.prevent="stopPrevent">
  162. <!-- 优惠券页面,仿mt -->
  163. <view v-if="getAvailableCoupons().length === 0" class="no-coupon-tip">
  164. <text>暂无可用优惠券</text>
  165. </view>
  166. <view @click="isCouponAvailable(item) ? selectCoupon(item) : null"
  167. class="coupon-item"
  168. :class="{ 'coupon-disabled': !isCouponAvailable(item) }"
  169. v-for="(item,index) in couponList" :key="index">
  170. <view class="con">
  171. <view class="left">
  172. <text class="title">{{ item.couponTitle }}</text>
  173. <text class="time">有效期至{{ item.endTime || '-' }}</text>
  174. </view>
  175. <view class="right">
  176. <text class="price">{{ item.couponPrice }}</text>
  177. <text>满{{ item.useMinPrice }}可用</text>
  178. </view>
  179. <view class="circle l"></view>
  180. <view class="circle r"></view>
  181. </view>
  182. <text class="tips">{{ item.categoryTitle ? '限' + item.categoryTitle + '可用' : '全品类可用' }}</text>
  183. <text class="info" v-if="item.id === bestCouponId && hasAvailableCoupons">最佳优惠</text>
  184. </view>
  185. </view>
  186. </view>
  187. <!-- 底部 -->
  188. <view class="footer">
  189. <view class="priceClass">
  190. <view class="price-content">
  191. <text>总计</text>
  192. <text class="price-content-money">
  193. ¥{{ orderPriceData.actualPrice || '-' }}
  194. </text>
  195. <text class="price-content-money" style="color: red" v-if="orderReqeust.isIntegral === 1"> +
  196. 积分{{ orderReqeust.integral }}
  197. </text>
  198. </view>
  199. <view class="price-preferential">
  200. <text>已优惠:</text>
  201. <text>{{ orderPriceData.couponPrice || '0' }}元</text>
  202. </view>
  203. </view>
  204. <view class="submit" @click="submit">
  205. 去付款
  206. </view>
  207. </view>
  208. <uni-popup ref="popup" type="bottom" :animation="true" style="z-index: 9999;">
  209. <view class="flex align-center justify-between" style="padding: 34rpx 30rpx;background-color: #F2F2F2;">
  210. <view style="font-size: 32rpx;line-height: 38rpx;color: #1B1C33;">选择到达时间</view>
  211. <view @click="checkTime" style="font-size: 32rpx;line-height: 38rpx;color: #2AAB34;">确定</view>
  212. </view>
  213. <view class="flex justify-between">
  214. <view style="width: 347rpx;height: 500rpx;background-color: #F2F2F2;">
  215. <view v-for="(date,index) in dayList" :key="index" @click="chooseDay(index)"
  216. :class="[index == dayIndex?'bg-white':'']"
  217. style="padding: 25rpx 84rpx 25rpx 59rpx;font-size: 32rpx;line-height: 38rpx;color: #1B1C33;">
  218. {{ date }}
  219. </view>
  220. </view>
  221. <view class="bg-white" style="width: 404rpx;height: 500rpx;padding-left: 52rpx;position: relative;">
  222. <scroll-view scroll-y="true" style="width: 404rpx;height: 500rpx;">
  223. <view v-for="(time,index) in timeList[dayIndex]" :key="index" @click="chooseTime(index)"
  224. :class="[index == timeIndex?'text-green':'']"
  225. class="solid-bottom" style="padding: 25rpx 0;font-size: 32rpx;line-height: 38rpx;">
  226. <text v-if="time.length > 2">{{ time }}</text>
  227. <text v-else>{{ time[0] + '-' + time[1] }}</text>
  228. </view>
  229. </scroll-view>
  230. <view
  231. style="position: absolute;bottom: 0;width: 404rpx;height: 53rpx;background-color: rgba(255,255,255,0.8);">
  232. </view>
  233. </view>
  234. </view>
  235. </uni-popup>
  236. </view>
  237. </template>
  238. <script>
  239. import uniPopup from "@/components/uni-popup/uni-popup.vue"
  240. import {dateFormat} from "../../filters";
  241. export default {
  242. data() {
  243. return {
  244. payType: 'WX',
  245. shippingType: 1,
  246. bestCouponId: null, // 最佳优惠券的 ID
  247. orderReqeust: {
  248. productList: [],
  249. totalotPrice: 0,
  250. totalPrice: 0, //商品折扣(仅算VIP和限时打折)后总价
  251. totalNumber: 0,//商品件数
  252. coupon: undefined,
  253. couponId: 0,
  254. mono: '',
  255. takeWay: '',
  256. freightPrice: 0,
  257. urgentFee: undefined, // 加急费用
  258. addressId: undefined,
  259. predictTime: '',
  260. phone: '',
  261. name: '',
  262. integral: 0,
  263. gainIntegral: 0,
  264. photos: [] // 订单照片数组
  265. },
  266. skuCategoryPriceMap: {},
  267. maskState: 0, //优惠券面板显示状态
  268. couponList: [],
  269. hasAvailableCoupons: false, // 是否有可用优惠券
  270. hasCoupons: false,
  271. urgentFeeTimer: null, // 加急费用防抖定时器
  272. orderPriceData: { // 订单价格数据
  273. productTotalPrice: 0,
  274. productOriginalTotalPrice: 0,
  275. freightPrice: 0,
  276. urgentFee: 0,
  277. couponPrice: 0,
  278. actualPrice: 0
  279. },
  280. isVip: false,
  281. storageData: {
  282. address: ''
  283. },
  284. addressData: {
  285. consignee: '',
  286. phone: '',
  287. province: '',
  288. city: '',
  289. county: '',
  290. address: '',
  291. defaultAddress: false,
  292. },
  293. submiting: false,
  294. dayList: [],//配送时间
  295. dayIndex: 0,//选中配送时间
  296. timeList: [],
  297. timeIndex: 0,
  298. now: 0,//当前小时
  299. nowTime: 0,//当前分钟
  300. dateObj: {
  301. year: 0,
  302. today: 0,
  303. tomorrow: 1,
  304. afterTomo: 2
  305. }
  306. }
  307. },
  308. components: {uniPopup},
  309. computed: {
  310. // 动态计算照片区域高度
  311. photoContainerHeight() {
  312. const totalItems = this.orderReqeust.photos.length + (this.orderReqeust.photos.length < 5 ? 1 : 0) // 照片数量 + 添加按钮
  313. const rows = Math.ceil(totalItems / 2) // 每行2张,计算行数
  314. return rows * 200 + 'rpx' // 每行200rpx高度(包含180rpx照片高度 + 20rpx行间距)
  315. }
  316. },
  317. onShow() {
  318. this.isVip = this.$api.isVip()
  319. },
  320. onLoad(option) {
  321. //商品数据
  322. this.isVip = this.$api.isVip()
  323. const that = this
  324. if (option.takeway) {
  325. that.orderReqeust.takeWay = option.takeway
  326. }
  327. that.orderReqeust.productList = that.$api.globalData.productList;
  328. let totalotPrice = 0
  329. let totalPrice = 0
  330. let totalNumber = 0
  331. let skuCategoryPriceMap = {}
  332. that.orderReqeust.productList.forEach(item => {
  333. totalotPrice += item.otPrice * item.cartNum
  334. totalNumber += item.cartNum
  335. totalPrice += that.isVip ? (item.vipPrice * item.cartNum) : (item.price * item.cartNum)
  336. //构建category价格Map
  337. item.cateIdList.forEach(catItem => {
  338. if (skuCategoryPriceMap[catItem]) {
  339. skuCategoryPriceMap[catItem] += that.isVip ? (item.vipPrice * item.cartNum) : (item.price * item.cartNum)
  340. } else {
  341. skuCategoryPriceMap[catItem] = that.isVip ? (item.vipPrice) : (item.price)
  342. }
  343. })
  344. })
  345. that.skuCategoryPriceMap = skuCategoryPriceMap
  346. that.orderReqeust.totalotPrice = totalotPrice
  347. that.orderReqeust.totalNumber = totalNumber
  348. that.orderReqeust.totalPrice = totalPrice
  349. that.$api.request('get', 'coupon/app/getUserCoupons').then(res => {
  350. that.couponList = res.data
  351. this.findBestCoupon(); // 找出最佳优惠券
  352. if (that.bestCouponId) {
  353. const baseIndex = that.couponList.findIndex(coupon => that.bestCouponId === coupon.id)
  354. that.couponList.unshift(...that.couponList.splice(that.couponList.indexOf(baseIndex), 1));
  355. }
  356. that.hasCoupons = res.data.length > 0
  357. that.hasAvailableCoupons = that.getAvailableCoupons().length > 0
  358. // 初始化价格计算
  359. that.calculateOrderPrice();
  360. })
  361. let addresses = uni.getStorageSync('addresses');
  362. that.$api.request('get', 'storage/position/getStorage', {storageId: that.$store.state.storageId}).then(res => {
  363. that.storageData = res.data
  364. if (addresses) {
  365. that.storageData.distance = addresses.distance
  366. }
  367. })
  368. //设置距离
  369. that.$api.request('get', 'address/app/getDefAddress').then(res => {
  370. if (res.data) {
  371. that.addressData = res.data
  372. }
  373. })
  374. if (that.orderReqeust.productList.length === 1 && that.orderReqeust.productList[0].groupShopId) {
  375. //若是团购商品,则携带上团购信息
  376. that.orderReqeust.groupShopId = that.orderReqeust.productList[0].groupShopId
  377. //总价重置
  378. that.orderReqeust.totalPrice = that.orderReqeust.productList[0].price
  379. }
  380. if (that.orderReqeust.productList.length === 1 && that.orderReqeust.productList[0].seckillId) {
  381. //若是秒杀商品,则携带上秒杀信息
  382. that.orderReqeust.seckillId = that.orderReqeust.productList[0].seckillId
  383. //总价重置
  384. that.orderReqeust.totalPrice = that.orderReqeust.productList[0].price
  385. }
  386. if (that.orderReqeust.productList.length === 1 && that.orderReqeust.productList[0].isIntegral) {
  387. //若是积分商品,则携带上积分信息
  388. that.orderReqeust.isIntegral = that.orderReqeust.productList[0].isIntegral
  389. that.orderReqeust.integral = that.orderReqeust.productList[0].integral
  390. that.orderReqeust.payType = 'INTEGRAL'
  391. that.payType = 'INTEGRAL'
  392. }
  393. // 使用默认参数:8-22点,7天,1小时间隔
  394. // 可以根据需要调整参数:this.calcTime(minStartHour, maxEndHour, dayCount, intervalHour)
  395. this.calcTime()
  396. },
  397. methods: {
  398. dateFormat,
  399. findBestCoupon() {
  400. if (this.couponList.length > 0) {
  401. // 找出优惠力度最大的优惠券
  402. let bestCoupon = this.couponList.reduce((prev, curr) => {
  403. return prev.couponPrice > curr.couponPrice ? prev : curr;
  404. });
  405. this.bestCouponId = bestCoupon.id; // 存储最佳优惠券的 ID
  406. }
  407. },
  408. // 获取可用的优惠券列表
  409. getAvailableCoupons() {
  410. return this.couponList.filter(item => {
  411. return (!item.categoryId && this.orderReqeust.totalPrice >= item.useMinPrice) ||
  412. // 有categoryId 且 category 价格大于实际价格
  413. (item.categoryId && this.skuCategoryPriceMap[item.categoryId] && this.skuCategoryPriceMap[item.categoryId] > item.useMinPrice);
  414. });
  415. },
  416. // 判断单个优惠券是否可用
  417. isCouponAvailable(item) {
  418. return (!item.categoryId && this.orderReqeust.totalPrice >= item.useMinPrice) ||
  419. (item.categoryId && this.skuCategoryPriceMap[item.categoryId] && this.skuCategoryPriceMap[item.categoryId] > item.useMinPrice);
  420. },
  421. // 计算订单价格
  422. calculateOrderPrice() {
  423. const that = this;
  424. const requestData = {
  425. ...that.orderReqeust,
  426. urgentFee: that.orderReqeust.urgentFee || 0
  427. };
  428. that.$api.request('post', 'order/app/calculateOrderPrice', JSON.stringify(requestData))
  429. .then(res => {
  430. that.orderPriceData = res.data;
  431. // 更新可用优惠券状态
  432. that.hasAvailableCoupons = that.getAvailableCoupons().length > 0;
  433. })
  434. .catch(err => {
  435. console.error('计算订单价格失败:', err);
  436. throw err
  437. });
  438. },
  439. showFreightMsg() {
  440. uni.showToast({
  441. title: this.orderReqeust.freightMsg, // 假设接口返回的 msg 存储在 freightMsg 中
  442. icon: 'none',
  443. duration: 2000
  444. });
  445. },
  446. // 选择支付方式
  447. changePayType(type) {
  448. this.payType = type
  449. },
  450. // 选择照片
  451. choosePhoto() {
  452. const remainingCount = 5 - this.orderReqeust.photos.length
  453. uni.chooseImage({
  454. count: remainingCount,
  455. sizeType: ['compressed'],
  456. sourceType: ['album', 'camera'],
  457. success: (res) => {
  458. const tempFilePaths = res.tempFilePaths
  459. // 依次上传选中的照片
  460. tempFilePaths.forEach(filePath => {
  461. this.uploadPhoto(filePath)
  462. })
  463. },
  464. fail: (err) => {
  465. console.error('选择照片失败:', err)
  466. uni.showToast({
  467. title: '选择照片失败',
  468. icon: 'none'
  469. })
  470. }
  471. })
  472. },
  473. // 上传照片
  474. uploadPhoto(filePath) {
  475. this.$api.uploadImgByPath(filePath, (url) => {
  476. this.orderReqeust.photos.push(url)
  477. uni.showToast({
  478. title: '上传成功',
  479. icon: 'success'
  480. })
  481. })
  482. },
  483. // 预览照片
  484. previewPhoto(index) {
  485. uni.previewImage({
  486. urls: this.orderReqeust.photos,
  487. current: index
  488. })
  489. },
  490. // 删除照片
  491. deletePhoto(index) {
  492. uni.showModal({
  493. title: '确认删除',
  494. content: '确定要删除这张照片吗?',
  495. success: (res) => {
  496. if (res.confirm) {
  497. this.orderReqeust.photos.splice(index, 1)
  498. }
  499. }
  500. })
  501. },
  502. addressType: function (index) {
  503. this.shippingType = index
  504. },
  505. //显示优惠券面板
  506. toggleMask(type) {
  507. let timer = type === 'show' ? 10 : 300;
  508. let state = type === 'show' ? 1 : 0;
  509. this.maskState = 2;
  510. setTimeout(() => {
  511. this.maskState = state;
  512. }, timer)
  513. },
  514. jia(arg1, arg2) {
  515. var r1, r2, m;
  516. try {
  517. r1 = arg1.toString().split(".")[1].length
  518. } catch (e) {
  519. r1 = 0
  520. }
  521. try {
  522. r2 = arg2.toString().split(".")[1].length
  523. } catch (e) {
  524. r2 = 0
  525. }
  526. m = Math.pow(10, Math.max(r1, r2));
  527. return (arg1 * m + arg2 * m) / m;
  528. },
  529. jian(arg2, arg1) {
  530. var r1, r2, m, n;
  531. try {
  532. r1 = arg1.toString().split(".")[1].length
  533. } catch (e) {
  534. r1 = 0
  535. }
  536. try {
  537. r2 = arg2.toString().split(".")[1].length
  538. } catch (e) {
  539. r2 = 0
  540. }
  541. m = Math.pow(10, Math.max(r1, r2));
  542. //lastmodifybydeeka
  543. //动态控制精度长度
  544. n = (r1 >= r2) ? r1 : r2;
  545. return ((arg2 * m - arg1 * m) / m).toFixed(n);
  546. },
  547. calcFreightPrice() {
  548. const that = this;
  549. if (that.addressData) {
  550. that.orderReqeust.addressId = that.addressData.id;
  551. }
  552. that.orderReqeust.storageId = that.$store.state.storageId;
  553. // 调用新的价格计算接口
  554. that.calculateOrderPrice();
  555. },
  556. numberChange(data) {
  557. this.number = data.number;
  558. },
  559. submit() {
  560. const that = this
  561. if (that.submiting) {
  562. return
  563. }
  564. if (this.shippingType === 1) {
  565. if (!this.addressData.id) {
  566. this.$api.msg('请选择配送地址')
  567. return
  568. }
  569. } else {
  570. if (!this.storageData) {
  571. this.$api.msg('未有仓库地址信息')
  572. return
  573. }
  574. if (!this.orderReqeust.name) {
  575. this.$api.msg('请填写您的联系姓名')
  576. return
  577. }
  578. if (!this.storageData.phone || this.storageData.phone.length !== 11) {
  579. this.$api.msg('请正确填写您的联系方式')
  580. return
  581. }
  582. }
  583. if (this.orderReqeust.freightPrice < 0 && !that.orderReqeust.isIntegral) {
  584. this.$api.msg('无法配送!最低配送为' + Math.abs(this.orderReqeust.freightPrice) + '元')
  585. return
  586. }
  587. uni.showLoading({})
  588. that.submiting = true
  589. if (that.addressData.id) {
  590. that.orderReqeust.addressId = that.addressData.id
  591. }
  592. that.orderReqeust.storageId = that.$store.state.storageId
  593. that.orderReqeust.shippingType = this.shippingType
  594. that.orderReqeust.channel = uni.getSystemInfoSync().platform
  595. that.orderReqeust.payType = that.payType
  596. that.orderReqeust.urgentFee = that.orderReqeust.urgentFee || 0
  597. if (that.payType === 'BALANCE') {
  598. that.$api.request('post', 'order/app/takeOrder',
  599. JSON.stringify(that.orderReqeust)
  600. , failres => {
  601. that.submiting = false
  602. that.$api.msg(failres.msg)
  603. }).then(res => {
  604. uni.redirectTo({
  605. url: '/pages/pay/success'
  606. })
  607. })
  608. return;
  609. }
  610. if (that.orderReqeust.isIntegral) {
  611. that.$api.request('post', 'order/app/takeOrder',
  612. JSON.stringify(that.orderReqeust)
  613. , failres => {
  614. that.submiting = false
  615. that.$api.msg(failres.msg)
  616. }).then(res => {
  617. uni.redirectTo({
  618. url: '/pages/pay/success'
  619. })
  620. })
  621. return;
  622. }
  623. that.$api.request('post', 'order/app/takeOrder',
  624. JSON.stringify(that.orderReqeust)
  625. , failres => {
  626. that.submiting = false
  627. that.$api.msg(failres.msg)
  628. }).then(res => {
  629. //提交订单成功后,无需再让用户提交订单
  630. // that.submiting = false
  631. // uni.redirectTo({
  632. // url: '/pages/pay/pay?orderno=' + res.data + '&price=' + that.orderReqeust.totalPrice
  633. // })
  634. that.confirm(res.data, that.orderPriceData.actualPrice || 0)
  635. })
  636. },
  637. selectCoupon(couponItem) {
  638. this.orderReqeust.couponId = couponItem.id
  639. this.orderReqeust.coupon = couponItem
  640. this.maskState = 0
  641. this.calculateOrderPrice()
  642. },
  643. stopPrevent() {
  644. },
  645. //打开选择时间的弹窗
  646. selectTime() {
  647. this.$refs.popup.open()
  648. },
  649. /**
  650. * 生成服务时间选项
  651. * @param {number} minStartHour - 最小开始时间(整点,0-23)
  652. * @param {number} maxEndHour - 最大结束时间(整点,0-23)
  653. * @param {number} dayCount - 天数(默认7天,包含今天)
  654. * @param {number} intervalHour - 间隔时间(默认1小时)
  655. */
  656. calcTime(minStartHour = 8, maxEndHour = 22, dayCount = 8, intervalHour = 1) {
  657. const date = new Date()
  658. const year = date.getFullYear()
  659. const month = date.getMonth() + 1
  660. const day = date.getDate()
  661. const currentHour = date.getHours()
  662. if (date.getHours() >= maxEndHour) {
  663. dayCount += 1
  664. }
  665. // 初始化数组
  666. this.dayList = []
  667. this.timeList = []
  668. this.dateObj = {year, month: month < 10 ? '0' + month : month}
  669. // 生成日期列表
  670. for (let i = 0; i < dayCount; i++) {
  671. const targetDate = new Date(year, month - 1, day + i)
  672. const targetMonth = targetDate.getMonth() + 1
  673. const targetDay = targetDate.getDate()
  674. const formatMonth = targetMonth < 10 ? '0' + targetMonth : targetMonth
  675. const formatDay = targetDay < 10 ? '0' + targetDay : targetDay
  676. let dayLabel = ''
  677. if (i === 0) {
  678. dayLabel = `今天${formatMonth}月${formatDay}日`
  679. this.dateObj.today = formatDay
  680. } else if (i === 1) {
  681. dayLabel = `明天${formatMonth}月${formatDay}日`
  682. this.dateObj.tomorrow = formatDay
  683. } else if (i === 2) {
  684. dayLabel = `后天${formatMonth}月${formatDay}日`
  685. this.dateObj.afterTomo = formatDay
  686. } else {
  687. const weekdays = ['周日', '周一', '周二', '周三', '周四', '周五', '周六']
  688. const weekday = weekdays[targetDate.getDay()]
  689. dayLabel = `${weekday}${formatMonth}月${formatDay}日`
  690. }
  691. this.dayList.push(dayLabel)
  692. this.timeList[i] = []
  693. }
  694. // 生成时间段选项
  695. for (let dayIndex = 0; dayIndex < dayCount; dayIndex++) {
  696. let startHour = minStartHour
  697. // 如果是今天,需要特殊处理
  698. if (dayIndex === 0) {
  699. if (currentHour >= maxEndHour) {
  700. // 当前时间已过营业结束时间,今天不提供服务
  701. continue
  702. } else if (currentHour >= minStartHour) {
  703. // 当前时间在营业时间内,从下一个整点开始
  704. startHour = currentHour + 1
  705. // 如果还有可用时间段,添加"尽快到达"选项
  706. if (startHour <= maxEndHour) {
  707. this.timeList[0].push('尽快到达')
  708. }
  709. }
  710. // 如果当前时间在营业开始前,使用原本的minStartHour
  711. }
  712. // 生成时间段
  713. for (let hour = startHour; hour <= maxEndHour; hour += intervalHour) {
  714. const endHour = Math.min(hour + intervalHour, maxEndHour)
  715. if (endHour > hour) {
  716. const startTime = hour < 10 ? '0' + hour + ':00' : hour + ':00'
  717. const endTime = endHour < 10 ? '0' + endHour + ':00' : endHour + ':00'
  718. this.timeList[dayIndex].push([startTime, endTime])
  719. }
  720. }
  721. }
  722. // 移除没有可用时间段的天(从后往前删除,避免索引问题)
  723. for (let i = this.timeList.length - 1; i >= 0; i--) {
  724. if (this.timeList[i].length === 0) {
  725. this.dayList.splice(i, 1)
  726. this.timeList.splice(i, 1)
  727. }
  728. }
  729. // 设置默认选择(第一天的第一个时间段)
  730. if (this.dayList.length > 0) {
  731. // 找到第一个有时间段的天
  732. let firstAvailableDay = 0
  733. for (let i = 0; i < this.timeList.length; i++) {
  734. if (this.timeList[i].length > 0) {
  735. firstAvailableDay = i
  736. break
  737. }
  738. }
  739. if (this.timeList[firstAvailableDay] && this.timeList[firstAvailableDay].length > 0) {
  740. this.dayIndex = firstAvailableDay
  741. this.timeIndex = 0
  742. const firstDay = this.dayList[firstAvailableDay]
  743. const firstTime = this.timeList[firstAvailableDay][0]
  744. if (typeof firstTime === 'string') {
  745. // 尽快到达的情况
  746. const nextHour = currentHour + 1
  747. const estimatedTime = nextHour < 10 ? '0' + nextHour + ':00' : nextHour + ':00'
  748. this.orderReqeust.predictTime = `尽快到达(预计${estimatedTime}到达)`
  749. const targetDate = new Date(year, month - 1, day + firstAvailableDay, nextHour, 0)
  750. this.orderReqeust.predictDate = targetDate.getTime()
  751. } else {
  752. // 普通时间段的情况
  753. this.orderReqeust.predictTime = `${firstDay}${firstTime[0]}-${firstTime[1]}`
  754. const targetDate = new Date(year, month - 1, day + firstAvailableDay)
  755. const endTime = firstTime[1].split(':')
  756. targetDate.setHours(parseInt(endTime[0]), parseInt(endTime[1]))
  757. this.orderReqeust.predictDate = targetDate.getTime()
  758. }
  759. } else {
  760. // 如果没有任何可用时间段,设置明天的第一个时间段
  761. console.warn('No available time slots found, creating fallback option')
  762. this.orderReqeust.predictTime = '明天' + minStartHour + ':00-' + (minStartHour + 1) + ':00'
  763. }
  764. }
  765. // 保存当前时间信息
  766. this.now = currentHour
  767. this.nowTime = date.getMinutes()
  768. // 调试信息
  769. console.log('calcTime debug info:', {
  770. currentHour,
  771. minStartHour,
  772. maxEndHour,
  773. dayCount,
  774. intervalHour,
  775. dayListLength: this.dayList.length,
  776. timeListLength: this.timeList.length,
  777. timeList: this.timeList
  778. })
  779. },
  780. chooseDay(index) {
  781. this.dayIndex = index
  782. },
  783. chooseTime(index) {
  784. this.timeIndex = index
  785. },
  786. checkTime() {
  787. const selectedTime = this.timeList[this.dayIndex][this.timeIndex]
  788. const selectedDay = this.dayList[this.dayIndex]
  789. // 计算目标日期
  790. const today = new Date()
  791. const targetDate = new Date(today.getFullYear(), today.getMonth(), today.getDate() + this.dayIndex)
  792. if (typeof selectedTime === 'string' && selectedTime === '尽快到达') {
  793. // 尽快到达的情况
  794. const nextHour = this.now + 1
  795. const estimatedTime = nextHour < 10 ? '0' + nextHour + ':00' : nextHour + ':00'
  796. this.orderReqeust.predictTime = `尽快到达(预计${estimatedTime}到达)`
  797. targetDate.setHours(nextHour, 0, 0, 0)
  798. this.orderReqeust.predictDate = targetDate.getTime()
  799. } else {
  800. // 普通时间段的情况
  801. this.orderReqeust.predictTime = `${selectedDay}${selectedTime[0]}-${selectedTime[1]}`
  802. const endTime = selectedTime[1].split(':')
  803. targetDate.setHours(parseInt(endTime[0]), parseInt(endTime[1]), 0, 0)
  804. this.orderReqeust.predictDate = targetDate.getTime()
  805. }
  806. this.$refs.popup.close()
  807. console.log('Selected time:', this.orderReqeust)
  808. },
  809. //确认支付
  810. confirm(orderNo, totalPrice) {
  811. // ============微信支付代码 prod 开始============
  812. // #ifdef APP-PLUS
  813. this.$api.msg('演示环境不支持支付')
  814. return
  815. // #endif
  816. const that = this
  817. that.$api.request('get', 'order/app/wxPrepay', {
  818. orderId: orderNo
  819. }, failres => {
  820. that.submiting = false
  821. that.$api.msg(failres.msg)
  822. }).then(prepayRes => {
  823. uni.hideLoading()
  824. that.submiting = false
  825. let payParam = {};
  826. //#ifdef MP-WEIXIN
  827. payParam = {
  828. appId: prepayRes.data.appId,
  829. nonceStr: prepayRes.data.nonceStr,
  830. package: prepayRes.data.packageValue,
  831. timeStamp: prepayRes.data.timeStamp,
  832. signType: prepayRes.data.signType,
  833. paySign: prepayRes.data.paySign,
  834. }
  835. //#endif
  836. //#ifdef APP-PLUS
  837. payParam = {
  838. appid: prepayRes.data.appId,
  839. noncestr: prepayRes.data.nonceStr,
  840. package: prepayRes.data.packageValue,
  841. partnerid: prepayRes.data.partnerId,
  842. prepayid: prepayRes.data.prepayId,
  843. timestamp: parseInt(prepayRes.data.timeStamp),
  844. sign: prepayRes.data.sign,
  845. signType: 'MD5'
  846. }
  847. //#endif
  848. //#ifdef MP-WEIXIN || APP-PLUS
  849. uni.requestPayment({
  850. provider: 'wxpay',
  851. //#ifdef MP-WEIXIN
  852. ...payParam,
  853. //#endif
  854. //#ifdef APP-PLUS
  855. orderInfo: payParam,
  856. //#endif
  857. success: function (res) {
  858. uni.redirectTo({
  859. url: '/pages/pay/success'
  860. })
  861. },
  862. fail: function (res) {
  863. // console.log("支付过程失败");
  864. // that.$api.msg(JSON.stringify(res))
  865. },
  866. complete: function (res) {
  867. console.log("支付过程结束")
  868. }
  869. });
  870. //#endif
  871. //#ifdef H5
  872. that.$jweixin.chooseWXPay({
  873. nonceStr: prepayRes.data.nonceStr,
  874. timestamp: prepayRes.data.timeStamp,
  875. package: prepayRes.data.packageValue,
  876. signType: prepayRes.data.signType,
  877. paySign: prepayRes.data.paySign,
  878. success: (e) => {
  879. //支付成功
  880. uni.redirectTo({
  881. url: '/pages/pay/success'
  882. })
  883. },
  884. fail: function (res) {
  885. console.log("支付过程失败");
  886. that.$api.msg(JSON.stringify(res))
  887. },
  888. complete: function (res) {
  889. console.log("支付过程结束")
  890. }
  891. })
  892. //#endif
  893. })
  894. //============微信支付代码 prod 结束============
  895. //============微信支付代码 dev 开始============
  896. // uni.request({
  897. // url: this.$api.defConfig().baseUrl + '/cb/wxpay',
  898. // data: {
  899. // outTradeNo: orderNo,
  900. // transactionId:'test',
  901. // totalFee: Math.round(totalPrice * 100)
  902. // },
  903. // method: 'POST',
  904. // header: {
  905. // 'Content-Type': 'application/json; charset=UTF-8'
  906. // },
  907. // success: (res) => {
  908. // //代码回调-上线后注释代码-结束
  909. // uni.redirectTo({
  910. // url: '/pages/pay/success'
  911. // })
  912. // }
  913. // });
  914. //============微信支付代码 dev 结束============
  915. }
  916. },
  917. watch: {
  918. // 监听加急费用变化
  919. 'orderReqeust.urgentFee': {
  920. handler(newVal, oldVal) {
  921. if (newVal !== oldVal && this.orderReqeust.productList && this.orderReqeust.productList.length > 0) {
  922. // 防抖处理,避免频繁调用
  923. clearTimeout(this.urgentFeeTimer);
  924. this.urgentFeeTimer = setTimeout(() => {
  925. this.calculateOrderPrice();
  926. }, 500);
  927. }
  928. },
  929. immediate: false
  930. }
  931. }
  932. }
  933. </script>
  934. <style lang="scss">
  935. page {
  936. background: #F4F4F4;
  937. padding-bottom: 100upx;
  938. }
  939. .mask {
  940. display: flex;
  941. align-items: flex-end;
  942. position: fixed;
  943. left: 0;
  944. top: var(--window-top);
  945. bottom: 0;
  946. width: 100%;
  947. background: rgba(0, 0, 0, 0);
  948. z-index: 9995;
  949. transition: .3s;
  950. .mask-content {
  951. width: 100%;
  952. min-height: 30vh;
  953. max-height: 70vh;
  954. background: #f3f3f3;
  955. transform: translateY(100%);
  956. transition: .3s;
  957. overflow-y: scroll;
  958. }
  959. &.none {
  960. display: none;
  961. }
  962. &.show {
  963. background: rgba(0, 0, 0, .4);
  964. .mask-content {
  965. transform: translateY(0);
  966. }
  967. }
  968. }
  969. /* 无优惠券提示 */
  970. .no-coupon-tip {
  971. display: flex;
  972. justify-content: center;
  973. align-items: center;
  974. height: 200upx;
  975. color: #999;
  976. font-size: 28upx;
  977. }
  978. /* 优惠券列表 */
  979. .coupon-item {
  980. display: flex;
  981. flex-direction: column;
  982. margin: 20upx 24upx;
  983. background: #fff;
  984. position: relative;
  985. .con {
  986. display: flex;
  987. align-items: center;
  988. position: relative;
  989. height: 120upx;
  990. padding: 0 30upx;
  991. &:after {
  992. position: absolute;
  993. left: 0;
  994. bottom: 0;
  995. content: '';
  996. width: 100%;
  997. height: 0;
  998. border-bottom: 1px dashed #f3f3f3;
  999. transform: scaleY(50%);
  1000. }
  1001. }
  1002. .info {
  1003. position: absolute;
  1004. right: 20rpx;
  1005. bottom: 20rpx;
  1006. color: red;
  1007. }
  1008. .left {
  1009. display: flex;
  1010. flex-direction: column;
  1011. justify-content: center;
  1012. flex: 1;
  1013. overflow: hidden;
  1014. height: 100upx;
  1015. }
  1016. .title {
  1017. font-size: 32upx;
  1018. color: $font-color-dark;
  1019. margin-bottom: 10upx;
  1020. }
  1021. .time {
  1022. font-size: 24upx;
  1023. color: $font-color-light;
  1024. }
  1025. .right {
  1026. display: flex;
  1027. flex-direction: column;
  1028. justify-content: center;
  1029. align-items: center;
  1030. font-size: 26upx;
  1031. color: $font-color-base;
  1032. height: 100upx;
  1033. }
  1034. .price {
  1035. font-size: 44upx;
  1036. color: $base-color;
  1037. &:before {
  1038. content: '¥';
  1039. font-size: 34upx;
  1040. }
  1041. }
  1042. .tips {
  1043. font-size: 24upx;
  1044. color: $font-color-light;
  1045. line-height: 60upx;
  1046. padding-left: 30upx;
  1047. }
  1048. .circle {
  1049. position: absolute;
  1050. left: -6upx;
  1051. bottom: -10upx;
  1052. z-index: 10;
  1053. width: 20upx;
  1054. height: 20upx;
  1055. background: #f3f3f3;
  1056. border-radius: 100px;
  1057. &.r {
  1058. left: auto;
  1059. right: -6upx;
  1060. }
  1061. }
  1062. }
  1063. /* 不可用优惠券置灰样式 */
  1064. .coupon-disabled {
  1065. opacity: 0.5;
  1066. pointer-events: none;
  1067. .title {
  1068. color: #999 !important;
  1069. }
  1070. .time {
  1071. color: #ccc !important;
  1072. }
  1073. .price {
  1074. color: #999 !important;
  1075. }
  1076. .tips {
  1077. color: #ccc !important;
  1078. }
  1079. }
  1080. .address {
  1081. padding: 36upx 30upx;
  1082. background-color: #FFFFFF;
  1083. overflow: hidden;
  1084. }
  1085. .address-head {
  1086. color: #999999;
  1087. font-size: 28upx;
  1088. font-weight: 400;
  1089. }
  1090. .address-main {
  1091. margin-top: 24upx;
  1092. }
  1093. .address-left {
  1094. margin: 9upx 0;
  1095. width: 24upx;
  1096. height: 32upx;
  1097. float: left;
  1098. }
  1099. .address-text {
  1100. margin-left: 14upx;
  1101. float: left;
  1102. font-size: 36upx;
  1103. color: #333333;
  1104. font-weight: 500;
  1105. }
  1106. .address-right {
  1107. margin: 11upx 20upx 11upx 0;
  1108. width: 28upx;
  1109. height: 28upx;
  1110. float: right;
  1111. }
  1112. .address-distance {
  1113. clear: both;
  1114. margin-top: 10upx;
  1115. color: #333333;
  1116. font-size: 30upx;
  1117. }
  1118. .a-bg {
  1119. display: block;
  1120. width: 100%;
  1121. height: 5upx;
  1122. }
  1123. .goods {
  1124. margin-top: 20upx;
  1125. background-color: #FFFFFF;
  1126. overflow: hidden;
  1127. }
  1128. .goods-head {
  1129. margin: 0 30upx;
  1130. height: 100upx;
  1131. padding: 30upx 0;
  1132. border-bottom: 2upx solid #F1F1F1;
  1133. }
  1134. .goods-head-text {
  1135. width: 294upx;
  1136. float: left;
  1137. color: #333333;
  1138. font-size: 28upx;
  1139. }
  1140. .goods-head-time {
  1141. width: 490upx;
  1142. float: left;
  1143. color: #2AAC34;
  1144. font-size: 28upx;
  1145. }
  1146. .goods-head-right {
  1147. margin-top: 8upx;
  1148. width: 16upx;
  1149. height: 24upx;
  1150. float: left;
  1151. }
  1152. .goods-one {
  1153. padding: 40upx 0 30upx 0;
  1154. margin: 0 30upx;
  1155. height: 190upx;
  1156. }
  1157. .scroll_box {
  1158. width: 544upx;
  1159. height: 110upx;
  1160. float: left;
  1161. overflow: hidden;
  1162. }
  1163. .scroll_box scroll-view {
  1164. height: 110upx;
  1165. width: 544upx;
  1166. white-space: nowrap;
  1167. }
  1168. .goods-img {
  1169. margin-top: 2upx;
  1170. width: 118upx;
  1171. height: 110upx;
  1172. float: left;
  1173. }
  1174. .goods-more-img {
  1175. margin-top: 2upx;
  1176. width: 118upx;
  1177. height: 110upx;
  1178. display: inline-block;
  1179. margin-right: 36upx;
  1180. }
  1181. .goods-more-number {
  1182. width: 126upx;
  1183. height: 110upx;
  1184. line-height: 110upx;
  1185. text-align: center;
  1186. color: #1B1C33;
  1187. font-size: 28upx;
  1188. float: left;
  1189. }
  1190. .goods-more-right {
  1191. margin-top: 43.5upx;
  1192. width: 15upx;
  1193. height: 23upx;
  1194. float: left;
  1195. }
  1196. .goods-text {
  1197. margin-top: 6upx;
  1198. margin-left: 32upx;
  1199. width: 538upx;
  1200. height: 110upx;
  1201. float: left;
  1202. }
  1203. .goods-name {
  1204. width: 500upx;
  1205. line-height: 44upx;
  1206. overflow: hidden;
  1207. color: #333333;
  1208. font-size: 32upx;
  1209. }
  1210. .goods-tag {
  1211. margin-top: 10upx;
  1212. }
  1213. .goods-price {
  1214. float: left;
  1215. color: #333333;
  1216. font-size: 32upx;
  1217. line-height: 44upx;
  1218. }
  1219. .goods-yprice {
  1220. margin-left: 16upx;
  1221. float: left;
  1222. color: #AEAEAE;
  1223. font-size: 24upx;
  1224. line-height: 44upx;
  1225. text-decoration: line-through;
  1226. }
  1227. .goods-number {
  1228. float: right;
  1229. color: #333333;
  1230. font-size: 32upx;
  1231. }
  1232. .distribution {
  1233. padding: 0 30upx;
  1234. margin-top: 20upx;
  1235. background-color: #FFFFFF;
  1236. overflow: hidden;
  1237. }
  1238. .distribution-list {
  1239. height: 100upx;
  1240. line-height: 100upx;
  1241. font-size: 28upx;
  1242. clear: both;
  1243. }
  1244. .distribution-list-bottom {
  1245. border-bottom: 2upx solid #F1F1F1;
  1246. }
  1247. .distribution-list.disabled {
  1248. opacity: 0.5;
  1249. color: #999;
  1250. }
  1251. .info-icon {
  1252. width: 28upx;
  1253. height: 28upx;
  1254. margin-left: 10upx;
  1255. vertical-align: middle;
  1256. }
  1257. .distribution-price {
  1258. width: 490upx;
  1259. float: left;
  1260. text-align: right;
  1261. color: #666666;
  1262. }
  1263. .distribution-price input {
  1264. width: 490upx;
  1265. height: 100upx;
  1266. line-height: 100upx;
  1267. overflow: hidden;
  1268. text-align: right;
  1269. }
  1270. .pay-text {
  1271. color: #333333;
  1272. font-size: 32upx;
  1273. }
  1274. .distribution-price image {
  1275. width: 40upx;
  1276. height: 40upx;
  1277. float: right;
  1278. margin-top: 30upx;
  1279. }
  1280. .footer {
  1281. position: fixed;
  1282. left: 0;
  1283. bottom: 0;
  1284. z-index: 99;
  1285. height: 98upx;
  1286. width: 100%;
  1287. background-color: #FFFFFF;
  1288. }
  1289. .priceClass {
  1290. margin-left: 62upx;
  1291. width: 448upx;
  1292. float: left;
  1293. }
  1294. .price-content {
  1295. height: 50upx;
  1296. line-height: 50upx;
  1297. margin-top: 10upx;
  1298. color: #666666;
  1299. font-size: 26upx;
  1300. }
  1301. .price-content-money {
  1302. color: #2AAC34;
  1303. font-size: 36upx;
  1304. }
  1305. .price-preferential {
  1306. height: 36upx;
  1307. line-height: 36upx;
  1308. color: #AEAEAE;
  1309. font-size: 20upx;
  1310. }
  1311. .submit {
  1312. width: 240upx;
  1313. float: left;
  1314. line-height: 98upx;
  1315. color: #FFFFFF;
  1316. background-color: #2AAC34;
  1317. text-align: center;
  1318. }
  1319. .order-submission .wrapper .shipping select {
  1320. color: #999;
  1321. padding-right: 0.15 * 100rpx;
  1322. }
  1323. .order-submission .wrapper .shipping .iconfont {
  1324. font-size: 0.3 * 100rpx;
  1325. color: #515151;
  1326. }
  1327. .order-submission .wrapper .item .discount input::placeholder {
  1328. color: #ccc;
  1329. }
  1330. .distribution-text {
  1331. width: 200upx;
  1332. float: left;
  1333. color: #333333;
  1334. display: flex; // 使用 flex 布局
  1335. align-items: center; // 垂直居中
  1336. }
  1337. .best-coupon {
  1338. display: inline-block;
  1339. padding: 4upx 8upx;
  1340. background-color: #fff;
  1341. border-radius: 4upx;
  1342. color: red;
  1343. font-size: 24upx;
  1344. }
  1345. /* 照片上传相关样式 */
  1346. .photo-upload-section {
  1347. flex-direction: row !important; /* 改为横向布局 */
  1348. align-items: flex-start !important;
  1349. height: auto !important; /* 覆盖distribution-list的固定高度 */
  1350. line-height: normal !important; /* 覆盖distribution-list的固定行高 */
  1351. padding: 30rpx 0 !important; /* 添加上下内边距 */
  1352. }
  1353. .photo-upload-container {
  1354. flex: 1; /* 占据剩余空间 */
  1355. margin-top: 50rpx;
  1356. margin-left: 20rpx; /* 与文案保持间距 */
  1357. min-height: 200rpx; /* 确保至少有200rpx高度 */
  1358. }
  1359. .photo-list {
  1360. display: flex;
  1361. flex-wrap: wrap;
  1362. gap: 20rpx;
  1363. align-content: flex-start;
  1364. width: 100%;
  1365. }
  1366. .photo-item {
  1367. position: relative;
  1368. width: 200rpx; /* 固定正方形宽度 */
  1369. height: 200rpx; /* 固定正方形高度 */
  1370. margin-bottom: 20rpx; /* 行间距 */
  1371. }
  1372. .photo-preview {
  1373. width: 100%;
  1374. height: 100%;
  1375. border-radius: 8rpx;
  1376. border: 2rpx solid #e5e5e5;
  1377. }
  1378. .photo-delete {
  1379. position: absolute;
  1380. top: -10rpx;
  1381. right: -10rpx;
  1382. width: 40rpx;
  1383. height: 40rpx;
  1384. background-color: #ff4757;
  1385. border-radius: 50%;
  1386. display: flex;
  1387. align-items: center;
  1388. justify-content: center;
  1389. }
  1390. .photo-delete-icon {
  1391. color: #fff;
  1392. font-size: 24rpx;
  1393. font-weight: bold;
  1394. }
  1395. .photo-add-btn {
  1396. width: 200rpx; /* 与photo-item保持一致 */
  1397. height: 200rpx; /* 与photo-item保持一致 */
  1398. margin-bottom: 20rpx; /* 与photo-item保持一致的行间距 */
  1399. border: 2rpx dashed #ccc;
  1400. border-radius: 8rpx;
  1401. display: flex;
  1402. flex-direction: column;
  1403. align-items: center;
  1404. justify-content: center;
  1405. background-color: #fafafa;
  1406. }
  1407. .photo-add-icon {
  1408. font-size: 32rpx; /* 调小图标尺寸 */
  1409. color: #999;
  1410. margin-bottom: 4rpx; /* 减少间距 */
  1411. }
  1412. .photo-add-text {
  1413. font-size: 20rpx; /* 调小文字尺寸 */
  1414. color: #999;
  1415. }
  1416. .photo-tips {
  1417. margin-top: 20rpx;
  1418. font-size: 24rpx;
  1419. color: #999;
  1420. }
  1421. </style>