create.vue 49 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552
  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,iVBORw0KGgoAAAANSUhEUgAAAu4AAAAFCAYAAA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m+Dfsdn2+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: 0, // 加急费用
  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. const currentMinute = date.getMinutes()
  663. if (date.getHours() >= maxEndHour) {
  664. dayCount += 1
  665. }
  666. // 初始化数组
  667. this.dayList = []
  668. this.timeList = []
  669. this.dateObj = {year, month: month < 10 ? '0' + month : month}
  670. // 生成日期列表
  671. for (let i = 0; i < dayCount; i++) {
  672. const targetDate = new Date(year, month - 1, day + i)
  673. const targetMonth = targetDate.getMonth() + 1
  674. const targetDay = targetDate.getDate()
  675. const formatMonth = targetMonth < 10 ? '0' + targetMonth : targetMonth
  676. const formatDay = targetDay < 10 ? '0' + targetDay : targetDay
  677. let dayLabel = ''
  678. if (i === 0) {
  679. dayLabel = `今天${formatMonth}月${formatDay}日`
  680. this.dateObj.today = formatDay
  681. } else if (i === 1) {
  682. dayLabel = `明天${formatMonth}月${formatDay}日`
  683. this.dateObj.tomorrow = formatDay
  684. } else if (i === 2) {
  685. dayLabel = `后天${formatMonth}月${formatDay}日`
  686. this.dateObj.afterTomo = formatDay
  687. } else {
  688. const weekdays = ['周日', '周一', '周二', '周三', '周四', '周五', '周六']
  689. const weekday = weekdays[targetDate.getDay()]
  690. dayLabel = `${weekday}${formatMonth}月${formatDay}日`
  691. }
  692. this.dayList.push(dayLabel)
  693. this.timeList[i] = []
  694. }
  695. // 生成时间段选项
  696. for (let dayIndex = 0; dayIndex < dayCount; dayIndex++) {
  697. let startHour = minStartHour
  698. // 如果是今天,需要特殊处理
  699. if (dayIndex === 0) {
  700. if (currentHour >= maxEndHour) {
  701. // 当前时间已过营业结束时间,今天不提供服务
  702. continue
  703. } else if (currentHour >= minStartHour) {
  704. // 当前时间在营业时间内,从下一个整点开始
  705. startHour = currentHour + 1
  706. // 如果还有可用时间段,添加"尽快到达"选项
  707. if (startHour <= maxEndHour) {
  708. this.timeList[0].push('尽快到达')
  709. }
  710. }
  711. // 如果当前时间在营业开始前,使用原本的minStartHour
  712. }
  713. // 生成时间段
  714. for (let hour = startHour; hour <= maxEndHour; hour += intervalHour) {
  715. const endHour = Math.min(hour + intervalHour, maxEndHour)
  716. if (endHour > hour) {
  717. const startTime = hour < 10 ? '0' + hour + ':00' : hour + ':00'
  718. const endTime = endHour < 10 ? '0' + endHour + ':00' : endHour + ':00'
  719. this.timeList[dayIndex].push([startTime, endTime])
  720. }
  721. }
  722. }
  723. // 移除没有可用时间段的天(从后往前删除,避免索引问题)
  724. for (let i = this.timeList.length - 1; i >= 0; i--) {
  725. if (this.timeList[i].length === 0) {
  726. this.dayList.splice(i, 1)
  727. this.timeList.splice(i, 1)
  728. }
  729. }
  730. // 设置默认选择(第一天的第一个时间段)
  731. if (this.dayList.length > 0) {
  732. // 找到第一个有时间段的天
  733. let firstAvailableDay = 0
  734. for (let i = 0; i < this.timeList.length; i++) {
  735. if (this.timeList[i].length > 0) {
  736. firstAvailableDay = i
  737. break
  738. }
  739. }
  740. if (this.timeList[firstAvailableDay] && this.timeList[firstAvailableDay].length > 0) {
  741. this.dayIndex = firstAvailableDay
  742. this.timeIndex = 0
  743. const firstDay = this.dayList[firstAvailableDay]
  744. const firstTime = this.timeList[firstAvailableDay][0]
  745. if (typeof firstTime === 'string') {
  746. // 尽快到达的情况
  747. const nextHour = currentHour + 1
  748. const h = nextHour < 10 ? '0' + nextHour : nextHour
  749. const m = currentMinute < 10 ? '0' + currentMinute : currentMinute
  750. this.orderReqeust.predictTime = `尽快到达(预计${h}:${m}到达)`
  751. const targetDate = new Date(year, month - 1, day + firstAvailableDay, nextHour, 0)
  752. this.orderReqeust.predictDate = targetDate.getTime()
  753. } else {
  754. // 普通时间段的情况
  755. this.orderReqeust.predictTime = `${firstDay}${firstTime[0]}-${firstTime[1]}`
  756. const targetDate = new Date(year, month - 1, day + firstAvailableDay)
  757. const endTime = firstTime[1].split(':')
  758. targetDate.setHours(parseInt(endTime[0]), parseInt(endTime[1]))
  759. this.orderReqeust.predictDate = targetDate.getTime()
  760. }
  761. } else {
  762. // 如果没有任何可用时间段,设置明天的第一个时间段
  763. console.warn('No available time slots found, creating fallback option')
  764. this.orderReqeust.predictTime = '明天' + minStartHour + ':00-' + (minStartHour + 1) + ':00'
  765. }
  766. }
  767. // 保存当前时间信息
  768. this.now = currentHour
  769. this.nowTime = date.getMinutes()
  770. // 调试信息
  771. console.log('calcTime debug info:', {
  772. currentHour,
  773. minStartHour,
  774. maxEndHour,
  775. dayCount,
  776. intervalHour,
  777. dayListLength: this.dayList.length,
  778. timeListLength: this.timeList.length,
  779. timeList: this.timeList
  780. })
  781. },
  782. chooseDay(index) {
  783. this.dayIndex = index
  784. },
  785. chooseTime(index) {
  786. this.timeIndex = index
  787. },
  788. checkTime() {
  789. const selectedTime = this.timeList[this.dayIndex][this.timeIndex]
  790. const selectedDay = this.dayList[this.dayIndex]
  791. // 计算目标日期
  792. const today = new Date()
  793. const targetDate = new Date(today.getFullYear(), today.getMonth(), today.getDate() + this.dayIndex)
  794. if (typeof selectedTime === 'string' && selectedTime === '尽快到达') {
  795. // 尽快到达的情况
  796. const nextHour = this.now + 1
  797. const estimatedTime = nextHour < 10 ? '0' + nextHour + ':00' : nextHour + ':00'
  798. this.orderReqeust.predictTime = `尽快到达(预计${estimatedTime}到达)`
  799. targetDate.setHours(nextHour, 0, 0, 0)
  800. this.orderReqeust.predictDate = targetDate.getTime()
  801. } else {
  802. // 普通时间段的情况
  803. this.orderReqeust.predictTime = `${selectedDay}${selectedTime[0]}-${selectedTime[1]}`
  804. const endTime = selectedTime[1].split(':')
  805. targetDate.setHours(parseInt(endTime[0]), parseInt(endTime[1]), 0, 0)
  806. this.orderReqeust.predictDate = targetDate.getTime()
  807. }
  808. this.$refs.popup.close()
  809. console.log('Selected time:', this.orderReqeust)
  810. },
  811. //确认支付
  812. confirm(orderNo, totalPrice) {
  813. // ============微信支付代码 prod 开始============
  814. // #ifdef APP-PLUS
  815. this.$api.msg('演示环境不支持支付')
  816. return
  817. // #endif
  818. const that = this
  819. that.$api.request('get', 'order/app/wxPrepay', {
  820. orderId: orderNo
  821. }, failres => {
  822. that.submiting = false
  823. that.$api.msg(failres.msg)
  824. }).then(prepayRes => {
  825. uni.hideLoading()
  826. that.submiting = false
  827. let payParam = {};
  828. //#ifdef MP-WEIXIN
  829. payParam = {
  830. appId: prepayRes.data.appId,
  831. nonceStr: prepayRes.data.nonceStr,
  832. package: prepayRes.data.packageValue,
  833. timeStamp: prepayRes.data.timeStamp,
  834. signType: prepayRes.data.signType,
  835. paySign: prepayRes.data.paySign,
  836. }
  837. //#endif
  838. //#ifdef APP-PLUS
  839. payParam = {
  840. appid: prepayRes.data.appId,
  841. noncestr: prepayRes.data.nonceStr,
  842. package: prepayRes.data.packageValue,
  843. partnerid: prepayRes.data.partnerId,
  844. prepayid: prepayRes.data.prepayId,
  845. timestamp: parseInt(prepayRes.data.timeStamp),
  846. sign: prepayRes.data.sign,
  847. signType: 'MD5'
  848. }
  849. //#endif
  850. //#ifdef MP-WEIXIN || APP-PLUS
  851. uni.requestPayment({
  852. provider: 'wxpay',
  853. //#ifdef MP-WEIXIN
  854. ...payParam,
  855. //#endif
  856. //#ifdef APP-PLUS
  857. orderInfo: payParam,
  858. //#endif
  859. success: function (res) {
  860. uni.redirectTo({
  861. url: '/pages/pay/success'
  862. })
  863. },
  864. fail: function (res) {
  865. // console.log("支付过程失败");
  866. // that.$api.msg(JSON.stringify(res))
  867. },
  868. complete: function (res) {
  869. console.log("支付过程结束")
  870. }
  871. });
  872. //#endif
  873. //#ifdef H5
  874. that.$jweixin.chooseWXPay({
  875. nonceStr: prepayRes.data.nonceStr,
  876. timestamp: prepayRes.data.timeStamp,
  877. package: prepayRes.data.packageValue,
  878. signType: prepayRes.data.signType,
  879. paySign: prepayRes.data.paySign,
  880. success: (e) => {
  881. //支付成功
  882. uni.redirectTo({
  883. url: '/pages/pay/success'
  884. })
  885. },
  886. fail: function (res) {
  887. console.log("支付过程失败");
  888. that.$api.msg(JSON.stringify(res))
  889. },
  890. complete: function (res) {
  891. console.log("支付过程结束")
  892. }
  893. })
  894. //#endif
  895. })
  896. //============微信支付代码 prod 结束============
  897. //============微信支付代码 dev 开始============
  898. // uni.request({
  899. // url: this.$api.defConfig().baseUrl + '/cb/wxpay',
  900. // data: {
  901. // outTradeNo: orderNo,
  902. // transactionId:'test',
  903. // totalFee: Math.round(totalPrice * 100)
  904. // },
  905. // method: 'POST',
  906. // header: {
  907. // 'Content-Type': 'application/json; charset=UTF-8'
  908. // },
  909. // success: (res) => {
  910. // //代码回调-上线后注释代码-结束
  911. // uni.redirectTo({
  912. // url: '/pages/pay/success'
  913. // })
  914. // }
  915. // });
  916. //============微信支付代码 dev 结束============
  917. }
  918. },
  919. watch: {
  920. // 监听加急费用变化
  921. 'orderReqeust.urgentFee': {
  922. handler(newVal, oldVal) {
  923. if (newVal !== oldVal && this.orderReqeust.productList && this.orderReqeust.productList.length > 0) {
  924. // 防抖处理,避免频繁调用
  925. clearTimeout(this.urgentFeeTimer);
  926. this.urgentFeeTimer = setTimeout(() => {
  927. this.calculateOrderPrice();
  928. }, 500);
  929. }
  930. },
  931. immediate: false
  932. }
  933. }
  934. }
  935. </script>
  936. <style lang="scss">
  937. page {
  938. background: #F4F4F4;
  939. padding-bottom: 100upx;
  940. }
  941. .mask {
  942. display: flex;
  943. align-items: flex-end;
  944. position: fixed;
  945. left: 0;
  946. top: var(--window-top);
  947. bottom: 0;
  948. width: 100%;
  949. background: rgba(0, 0, 0, 0);
  950. z-index: 9995;
  951. transition: .3s;
  952. .mask-content {
  953. width: 100%;
  954. min-height: 30vh;
  955. max-height: 70vh;
  956. background: #f3f3f3;
  957. transform: translateY(100%);
  958. transition: .3s;
  959. overflow-y: scroll;
  960. }
  961. &.none {
  962. display: none;
  963. }
  964. &.show {
  965. background: rgba(0, 0, 0, .4);
  966. .mask-content {
  967. transform: translateY(0);
  968. }
  969. }
  970. }
  971. /* 无优惠券提示 */
  972. .no-coupon-tip {
  973. display: flex;
  974. justify-content: center;
  975. align-items: center;
  976. height: 200upx;
  977. color: #999;
  978. font-size: 28upx;
  979. }
  980. /* 优惠券列表 */
  981. .coupon-item {
  982. display: flex;
  983. flex-direction: column;
  984. margin: 20upx 24upx;
  985. background: #fff;
  986. position: relative;
  987. .con {
  988. display: flex;
  989. align-items: center;
  990. position: relative;
  991. height: 120upx;
  992. padding: 0 30upx;
  993. &:after {
  994. position: absolute;
  995. left: 0;
  996. bottom: 0;
  997. content: '';
  998. width: 100%;
  999. height: 0;
  1000. border-bottom: 1px dashed #f3f3f3;
  1001. transform: scaleY(50%);
  1002. }
  1003. }
  1004. .info {
  1005. position: absolute;
  1006. right: 20rpx;
  1007. bottom: 20rpx;
  1008. color: red;
  1009. }
  1010. .left {
  1011. display: flex;
  1012. flex-direction: column;
  1013. justify-content: center;
  1014. flex: 1;
  1015. overflow: hidden;
  1016. height: 100upx;
  1017. }
  1018. .title {
  1019. font-size: 32upx;
  1020. color: $font-color-dark;
  1021. margin-bottom: 10upx;
  1022. }
  1023. .time {
  1024. font-size: 24upx;
  1025. color: $font-color-light;
  1026. }
  1027. .right {
  1028. display: flex;
  1029. flex-direction: column;
  1030. justify-content: center;
  1031. align-items: center;
  1032. font-size: 26upx;
  1033. color: $font-color-base;
  1034. height: 100upx;
  1035. }
  1036. .price {
  1037. font-size: 44upx;
  1038. color: $base-color;
  1039. &:before {
  1040. content: '¥';
  1041. font-size: 34upx;
  1042. }
  1043. }
  1044. .tips {
  1045. font-size: 24upx;
  1046. color: $font-color-light;
  1047. line-height: 60upx;
  1048. padding-left: 30upx;
  1049. }
  1050. .circle {
  1051. position: absolute;
  1052. left: -6upx;
  1053. bottom: -10upx;
  1054. z-index: 10;
  1055. width: 20upx;
  1056. height: 20upx;
  1057. background: #f3f3f3;
  1058. border-radius: 100px;
  1059. &.r {
  1060. left: auto;
  1061. right: -6upx;
  1062. }
  1063. }
  1064. }
  1065. /* 不可用优惠券置灰样式 */
  1066. .coupon-disabled {
  1067. opacity: 0.5;
  1068. pointer-events: none;
  1069. .title {
  1070. color: #999 !important;
  1071. }
  1072. .time {
  1073. color: #ccc !important;
  1074. }
  1075. .price {
  1076. color: #999 !important;
  1077. }
  1078. .tips {
  1079. color: #ccc !important;
  1080. }
  1081. }
  1082. .address {
  1083. padding: 36upx 30upx;
  1084. background-color: #FFFFFF;
  1085. overflow: hidden;
  1086. }
  1087. .address-head {
  1088. color: #999999;
  1089. font-size: 28upx;
  1090. font-weight: 400;
  1091. }
  1092. .address-main {
  1093. margin-top: 24upx;
  1094. }
  1095. .address-left {
  1096. margin: 9upx 0;
  1097. width: 24upx;
  1098. height: 32upx;
  1099. float: left;
  1100. }
  1101. .address-text {
  1102. margin-left: 14upx;
  1103. float: left;
  1104. font-size: 36upx;
  1105. color: #333333;
  1106. font-weight: 500;
  1107. }
  1108. .address-right {
  1109. margin: 11upx 20upx 11upx 0;
  1110. width: 28upx;
  1111. height: 28upx;
  1112. float: right;
  1113. }
  1114. .address-distance {
  1115. clear: both;
  1116. margin-top: 10upx;
  1117. color: #333333;
  1118. font-size: 30upx;
  1119. }
  1120. .a-bg {
  1121. display: block;
  1122. width: 100%;
  1123. height: 5upx;
  1124. }
  1125. .goods {
  1126. margin-top: 20upx;
  1127. background-color: #FFFFFF;
  1128. overflow: hidden;
  1129. }
  1130. .goods-head {
  1131. margin: 0 30upx;
  1132. height: 100upx;
  1133. padding: 30upx 0;
  1134. border-bottom: 2upx solid #F1F1F1;
  1135. }
  1136. .goods-head-text {
  1137. width: 294upx;
  1138. float: left;
  1139. color: #333333;
  1140. font-size: 28upx;
  1141. }
  1142. .goods-head-time {
  1143. width: 490upx;
  1144. float: left;
  1145. color: #2AAC34;
  1146. font-size: 28upx;
  1147. }
  1148. .goods-head-right {
  1149. margin-top: 8upx;
  1150. width: 16upx;
  1151. height: 24upx;
  1152. float: left;
  1153. }
  1154. .goods-one {
  1155. padding: 40upx 0 30upx 0;
  1156. margin: 0 30upx;
  1157. height: 190upx;
  1158. }
  1159. .scroll_box {
  1160. width: 544upx;
  1161. height: 110upx;
  1162. float: left;
  1163. overflow: hidden;
  1164. }
  1165. .scroll_box scroll-view {
  1166. height: 110upx;
  1167. width: 544upx;
  1168. white-space: nowrap;
  1169. }
  1170. .goods-img {
  1171. margin-top: 2upx;
  1172. width: 118upx;
  1173. height: 110upx;
  1174. float: left;
  1175. }
  1176. .goods-more-img {
  1177. margin-top: 2upx;
  1178. width: 118upx;
  1179. height: 110upx;
  1180. display: inline-block;
  1181. margin-right: 36upx;
  1182. }
  1183. .goods-more-number {
  1184. width: 126upx;
  1185. height: 110upx;
  1186. line-height: 110upx;
  1187. text-align: center;
  1188. color: #1B1C33;
  1189. font-size: 28upx;
  1190. float: left;
  1191. }
  1192. .goods-more-right {
  1193. margin-top: 43.5upx;
  1194. width: 15upx;
  1195. height: 23upx;
  1196. float: left;
  1197. }
  1198. .goods-text {
  1199. margin-top: 6upx;
  1200. margin-left: 32upx;
  1201. width: 538upx;
  1202. height: 110upx;
  1203. float: left;
  1204. }
  1205. .goods-name {
  1206. width: 500upx;
  1207. line-height: 44upx;
  1208. overflow: hidden;
  1209. color: #333333;
  1210. font-size: 32upx;
  1211. }
  1212. .goods-tag {
  1213. margin-top: 10upx;
  1214. }
  1215. .goods-price {
  1216. float: left;
  1217. color: #333333;
  1218. font-size: 32upx;
  1219. line-height: 44upx;
  1220. }
  1221. .goods-yprice {
  1222. margin-left: 16upx;
  1223. float: left;
  1224. color: #AEAEAE;
  1225. font-size: 24upx;
  1226. line-height: 44upx;
  1227. text-decoration: line-through;
  1228. }
  1229. .goods-number {
  1230. float: right;
  1231. color: #333333;
  1232. font-size: 32upx;
  1233. }
  1234. .distribution {
  1235. padding: 0 30upx;
  1236. margin-top: 20upx;
  1237. background-color: #FFFFFF;
  1238. overflow: hidden;
  1239. }
  1240. .distribution-list {
  1241. height: 100upx;
  1242. line-height: 100upx;
  1243. font-size: 28upx;
  1244. clear: both;
  1245. }
  1246. .distribution-list-bottom {
  1247. border-bottom: 2upx solid #F1F1F1;
  1248. }
  1249. .distribution-list.disabled {
  1250. opacity: 0.5;
  1251. color: #999;
  1252. }
  1253. .info-icon {
  1254. width: 28upx;
  1255. height: 28upx;
  1256. margin-left: 10upx;
  1257. vertical-align: middle;
  1258. }
  1259. .distribution-price {
  1260. width: 490upx;
  1261. float: left;
  1262. text-align: right;
  1263. color: #666666;
  1264. }
  1265. .distribution-price input {
  1266. width: 490upx;
  1267. height: 100upx;
  1268. line-height: 100upx;
  1269. overflow: hidden;
  1270. text-align: right;
  1271. }
  1272. .pay-text {
  1273. color: #333333;
  1274. font-size: 32upx;
  1275. }
  1276. .distribution-price image {
  1277. width: 40upx;
  1278. height: 40upx;
  1279. float: right;
  1280. margin-top: 30upx;
  1281. }
  1282. .footer {
  1283. position: fixed;
  1284. left: 0;
  1285. bottom: 0;
  1286. z-index: 99;
  1287. height: 98upx;
  1288. width: 100%;
  1289. background-color: #FFFFFF;
  1290. }
  1291. .priceClass {
  1292. margin-left: 62upx;
  1293. width: 448upx;
  1294. float: left;
  1295. }
  1296. .price-content {
  1297. height: 50upx;
  1298. line-height: 50upx;
  1299. margin-top: 10upx;
  1300. color: #666666;
  1301. font-size: 26upx;
  1302. }
  1303. .price-content-money {
  1304. color: #2AAC34;
  1305. font-size: 36upx;
  1306. }
  1307. .price-preferential {
  1308. height: 36upx;
  1309. line-height: 36upx;
  1310. color: #AEAEAE;
  1311. font-size: 20upx;
  1312. }
  1313. .submit {
  1314. width: 240upx;
  1315. float: left;
  1316. line-height: 98upx;
  1317. color: #FFFFFF;
  1318. background-color: #2AAC34;
  1319. text-align: center;
  1320. }
  1321. .order-submission .wrapper .shipping select {
  1322. color: #999;
  1323. padding-right: 0.15 * 100rpx;
  1324. }
  1325. .order-submission .wrapper .shipping .iconfont {
  1326. font-size: 0.3 * 100rpx;
  1327. color: #515151;
  1328. }
  1329. .order-submission .wrapper .item .discount input::placeholder {
  1330. color: #ccc;
  1331. }
  1332. .distribution-text {
  1333. width: 200upx;
  1334. float: left;
  1335. color: #333333;
  1336. display: flex; // 使用 flex 布局
  1337. align-items: center; // 垂直居中
  1338. }
  1339. .best-coupon {
  1340. display: inline-block;
  1341. padding: 4upx 8upx;
  1342. background-color: #fff;
  1343. border-radius: 4upx;
  1344. color: red;
  1345. font-size: 24upx;
  1346. }
  1347. /* 照片上传相关样式 */
  1348. .photo-upload-section {
  1349. flex-direction: row !important; /* 改为横向布局 */
  1350. align-items: flex-start !important;
  1351. height: auto !important; /* 覆盖distribution-list的固定高度 */
  1352. line-height: normal !important; /* 覆盖distribution-list的固定行高 */
  1353. padding: 30rpx 0 !important; /* 添加上下内边距 */
  1354. }
  1355. .photo-upload-container {
  1356. flex: 1; /* 占据剩余空间 */
  1357. margin-top: 50rpx;
  1358. margin-left: 20rpx; /* 与文案保持间距 */
  1359. min-height: 200rpx; /* 确保至少有200rpx高度 */
  1360. }
  1361. .photo-list {
  1362. display: flex;
  1363. flex-wrap: wrap;
  1364. gap: 20rpx;
  1365. align-content: flex-start;
  1366. width: 100%;
  1367. }
  1368. .photo-item {
  1369. position: relative;
  1370. width: 200rpx; /* 固定正方形宽度 */
  1371. height: 200rpx; /* 固定正方形高度 */
  1372. margin-bottom: 20rpx; /* 行间距 */
  1373. }
  1374. .photo-preview {
  1375. width: 100%;
  1376. height: 100%;
  1377. border-radius: 8rpx;
  1378. border: 2rpx solid #e5e5e5;
  1379. }
  1380. .photo-delete {
  1381. position: absolute;
  1382. top: -10rpx;
  1383. right: -10rpx;
  1384. width: 40rpx;
  1385. height: 40rpx;
  1386. background-color: #ff4757;
  1387. border-radius: 50%;
  1388. display: flex;
  1389. align-items: center;
  1390. justify-content: center;
  1391. }
  1392. .photo-delete-icon {
  1393. color: #fff;
  1394. font-size: 24rpx;
  1395. font-weight: bold;
  1396. }
  1397. .photo-add-btn {
  1398. width: 200rpx; /* 与photo-item保持一致 */
  1399. height: 200rpx; /* 与photo-item保持一致 */
  1400. margin-bottom: 20rpx; /* 与photo-item保持一致的行间距 */
  1401. border: 2rpx dashed #ccc;
  1402. border-radius: 8rpx;
  1403. display: flex;
  1404. flex-direction: column;
  1405. align-items: center;
  1406. justify-content: center;
  1407. background-color: #fafafa;
  1408. }
  1409. .photo-add-icon {
  1410. font-size: 32rpx; /* 调小图标尺寸 */
  1411. color: #999;
  1412. margin-bottom: 4rpx; /* 减少间距 */
  1413. }
  1414. .photo-add-text {
  1415. font-size: 20rpx; /* 调小文字尺寸 */
  1416. color: #999;
  1417. }
  1418. .photo-tips {
  1419. margin-top: 20rpx;
  1420. font-size: 24rpx;
  1421. color: #999;
  1422. }
  1423. </style>