create.vue 49 KB

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