create.vue 50 KB

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