create.vue 48 KB

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