create.vue 49 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492
  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+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMy1jMDExIDY2LjE0NTY2MSwgMjAxMi8wMi8wNi0xNDo1NjoyNyAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYm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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. onShow() {
  308. this.isVip = this.$api.isVip()
  309. },
  310. onLoad(option) {
  311. //商品数据
  312. this.isVip = this.$api.isVip()
  313. const that = this
  314. if (option.takeway) {
  315. that.orderReqeust.takeWay = option.takeway
  316. }
  317. that.orderReqeust.productList = that.$api.globalData.productList;
  318. let totalotPrice = 0
  319. let totalPrice = 0
  320. let totalNumber = 0
  321. let skuCategoryPriceMap = {}
  322. that.orderReqeust.productList.forEach(item => {
  323. totalotPrice += item.otPrice * item.cartNum
  324. totalNumber += item.cartNum
  325. totalPrice += that.isVip ? (item.vipPrice * item.cartNum) : (item.price * item.cartNum)
  326. //构建category价格Map
  327. item.cateIdList.forEach(catItem => {
  328. if (skuCategoryPriceMap[catItem]) {
  329. skuCategoryPriceMap[catItem] += that.isVip ? (item.vipPrice * item.cartNum) : (item.price * item.cartNum)
  330. } else {
  331. skuCategoryPriceMap[catItem] = that.isVip ? (item.vipPrice) : (item.price)
  332. }
  333. })
  334. })
  335. that.skuCategoryPriceMap = skuCategoryPriceMap
  336. that.orderReqeust.totalotPrice = totalotPrice
  337. that.orderReqeust.totalNumber = totalNumber
  338. that.orderReqeust.totalPrice = totalPrice
  339. that.$api.request('get', 'coupon/app/getUserCoupons').then(res => {
  340. that.couponList = res.data
  341. this.findBestCoupon(); // 找出最佳优惠券
  342. })
  343. let addresses = uni.getStorageSync('addresses');
  344. that.$api.request('get', 'storage/position/getStorage', {storageId: that.$store.state.storageId}).then(res => {
  345. that.storageData = res.data
  346. if (addresses) {
  347. that.storageData.distance = addresses.distance
  348. }
  349. })
  350. //设置距离
  351. that.$api.request('get', 'address/app/getDefAddress').then(res => {
  352. if (res.data) {
  353. that.addressData = res.data
  354. }
  355. that.calcFreightPrice()
  356. })
  357. if (that.orderReqeust.productList.length === 1 && that.orderReqeust.productList[0].groupShopId) {
  358. //若是团购商品,则携带上团购信息
  359. that.orderReqeust.groupShopId = that.orderReqeust.productList[0].groupShopId
  360. //总价重置
  361. that.orderReqeust.totalPrice = that.orderReqeust.productList[0].price
  362. }
  363. if (that.orderReqeust.productList.length === 1 && that.orderReqeust.productList[0].seckillId) {
  364. //若是秒杀商品,则携带上秒杀信息
  365. that.orderReqeust.seckillId = that.orderReqeust.productList[0].seckillId
  366. //总价重置
  367. that.orderReqeust.totalPrice = that.orderReqeust.productList[0].price
  368. }
  369. if (that.orderReqeust.productList.length === 1 && that.orderReqeust.productList[0].isIntegral) {
  370. //若是积分商品,则携带上积分信息
  371. that.orderReqeust.isIntegral = that.orderReqeust.productList[0].isIntegral
  372. that.orderReqeust.integral = that.orderReqeust.productList[0].integral
  373. that.orderReqeust.payType = 'INTEGRAL'
  374. that.payType = 'INTEGRAL'
  375. }
  376. this.calcTime()
  377. },
  378. methods: {
  379. findBestCoupon() {
  380. if (this.couponList.length > 0) {
  381. // 找出优惠力度最大的优惠券
  382. let bestCoupon = this.couponList.reduce((prev, curr) => {
  383. return prev.couponPrice > curr.couponPrice ? prev : curr;
  384. });
  385. this.bestCouponId = bestCoupon.id; // 存储最佳优惠券的 ID
  386. }
  387. },
  388. showFreightMsg() {
  389. uni.showToast({
  390. title: this.orderReqeust.freightMsg, // 假设接口返回的 msg 存储在 freightMsg 中
  391. icon: 'none',
  392. duration: 2000
  393. });
  394. },
  395. // 选择支付方式
  396. changePayType(type) {
  397. this.payType = type
  398. },
  399. // 选择照片
  400. choosePhoto() {
  401. const remainingCount = 5 - this.orderReqeust.photos.length
  402. uni.chooseImage({
  403. count: remainingCount,
  404. sizeType: ['compressed'],
  405. sourceType: ['album', 'camera'],
  406. success: (res) => {
  407. const tempFilePaths = res.tempFilePaths
  408. // 依次上传选中的照片
  409. tempFilePaths.forEach(filePath => {
  410. this.uploadPhoto(filePath)
  411. })
  412. },
  413. fail: (err) => {
  414. console.error('选择照片失败:', err)
  415. uni.showToast({
  416. title: '选择照片失败',
  417. icon: 'none'
  418. })
  419. }
  420. })
  421. },
  422. // 上传照片
  423. uploadPhoto(filePath) {
  424. this.$api.uploadImg(filePath, (url) => {
  425. this.orderReqeust.photos.push(url)
  426. uni.showToast({
  427. title: '上传成功',
  428. icon: 'success'
  429. })
  430. })
  431. },
  432. // 预览照片
  433. previewPhoto(index) {
  434. uni.previewImage({
  435. urls: this.orderReqeust.photos,
  436. current: index
  437. })
  438. },
  439. // 删除照片
  440. deletePhoto(index) {
  441. uni.showModal({
  442. title: '确认删除',
  443. content: '确定要删除这张照片吗?',
  444. success: (res) => {
  445. if (res.confirm) {
  446. this.orderReqeust.photos.splice(index, 1)
  447. }
  448. }
  449. })
  450. },
  451. addressType: function (index) {
  452. this.shippingType = index
  453. this.calcFreightPrice()
  454. },
  455. //显示优惠券面板
  456. toggleMask(type) {
  457. let timer = type === 'show' ? 10 : 300;
  458. let state = type === 'show' ? 1 : 0;
  459. this.maskState = 2;
  460. setTimeout(() => {
  461. this.maskState = state;
  462. }, timer)
  463. },
  464. jia(arg1, arg2) {
  465. var r1, r2, m;
  466. try {
  467. r1 = arg1.toString().split(".")[1].length
  468. } catch (e) {
  469. r1 = 0
  470. }
  471. try {
  472. r2 = arg2.toString().split(".")[1].length
  473. } catch (e) {
  474. r2 = 0
  475. }
  476. m = Math.pow(10, Math.max(r1, r2));
  477. return (arg1 * m + arg2 * m) / m;
  478. },
  479. jian(arg2, arg1) {
  480. var r1, r2, m, n;
  481. try {
  482. r1 = arg1.toString().split(".")[1].length
  483. } catch (e) {
  484. r1 = 0
  485. }
  486. try {
  487. r2 = arg2.toString().split(".")[1].length
  488. } catch (e) {
  489. r2 = 0
  490. }
  491. m = Math.pow(10, Math.max(r1, r2));
  492. //lastmodifybydeeka
  493. //动态控制精度长度
  494. n = (r1 >= r2) ? r1 : r2;
  495. return ((arg2 * m - arg1 * m) / m).toFixed(n);
  496. },
  497. calcFreightPrice() {
  498. const that = this;
  499. if (that.addressData) {
  500. that.orderReqeust.addressId = that.addressData.id;
  501. }
  502. that.orderReqeust.storageId = that.$store.state.storageId;
  503. if (that.shippingType === 1 && !that.orderReqeust.isIntegral) {
  504. that.$api.request('post', 'order/app/getFreightMoney', JSON.stringify(that.orderReqeust))
  505. .then(res => {
  506. that.orderReqeust.freightPrice = res.data.totalPrice;
  507. that.orderReqeust.freightMsg = res.data.msg; // 存储 msg
  508. });
  509. } else {
  510. that.orderReqeust.freightPrice = 0;
  511. }
  512. },
  513. numberChange(data) {
  514. this.number = data.number;
  515. },
  516. submit() {
  517. const that = this
  518. if (that.submiting) {
  519. return
  520. }
  521. if (this.shippingType === 1) {
  522. if (!this.addressData.id) {
  523. this.$api.msg('请选择配送地址')
  524. return
  525. }
  526. } else {
  527. if (!this.storageData) {
  528. this.$api.msg('未有仓库地址信息')
  529. return
  530. }
  531. if (!this.orderReqeust.name) {
  532. this.$api.msg('请填写您的联系姓名')
  533. return
  534. }
  535. if (!this.storageData.phone || this.storageData.phone.length !== 11) {
  536. this.$api.msg('请正确填写您的联系方式')
  537. return
  538. }
  539. }
  540. if (this.orderReqeust.freightPrice < 0 && !that.orderReqeust.isIntegral) {
  541. this.$api.msg('无法配送!最低配送为' + Math.abs(this.orderReqeust.freightPrice) + '元')
  542. return
  543. }
  544. uni.showLoading({})
  545. that.submiting = true
  546. if (that.addressData.id) {
  547. that.orderReqeust.addressId = that.addressData.id
  548. }
  549. that.orderReqeust.storageId = that.$store.state.storageId
  550. that.orderReqeust.shippingType = this.shippingType
  551. that.orderReqeust.channel = uni.getSystemInfoSync().platform
  552. that.orderReqeust.payType = that.payType
  553. if (that.payType === 'BALANCE') {
  554. that.$api.request('post', 'order/app/takeOrder',
  555. JSON.stringify(that.orderReqeust)
  556. , failres => {
  557. that.submiting = false
  558. that.$api.msg(failres.msg)
  559. }).then(res => {
  560. uni.redirectTo({
  561. url: '/pages/pay/success'
  562. })
  563. })
  564. return;
  565. }
  566. if (that.orderReqeust.isIntegral) {
  567. that.$api.request('post', 'order/app/takeOrder',
  568. JSON.stringify(that.orderReqeust)
  569. , failres => {
  570. that.submiting = false
  571. that.$api.msg(failres.msg)
  572. }).then(res => {
  573. uni.redirectTo({
  574. url: '/pages/pay/success'
  575. })
  576. })
  577. return;
  578. }
  579. that.$api.request('post', 'order/app/takeOrder',
  580. JSON.stringify(that.orderReqeust)
  581. , failres => {
  582. that.submiting = false
  583. that.$api.msg(failres.msg)
  584. }).then(res => {
  585. //提交订单成功后,无需再让用户提交订单
  586. // that.submiting = false
  587. // uni.redirectTo({
  588. // url: '/pages/pay/pay?orderno=' + res.data + '&price=' + that.orderReqeust.totalPrice
  589. // })
  590. that.confirm(res.data, (that.orderReqeust.totalPrice - (that.orderReqeust.coupon ? that.orderReqeust.coupon.couponPrice : 0) + parseFloat(that.orderReqeust.freightPrice)))
  591. })
  592. },
  593. selectCoupon(couponItem) {
  594. this.orderReqeust.couponId = couponItem.id
  595. this.orderReqeust.coupon = couponItem
  596. this.maskState = 0
  597. this.calcFreightPrice()
  598. },
  599. stopPrevent() {
  600. },
  601. //打开选择时间的弹窗
  602. selectTime() {
  603. this.$refs.popup.open()
  604. },
  605. //根据当前仓库营业时段及当前时间计算可供选择的送达时间
  606. calcTime() {
  607. var deliveryStart = this.$store.state.storageObj.deliveryStartTime.split(':')
  608. var deliveryStop = this.$store.state.storageObj.deliveryStopTime.split(':')
  609. var startHour = parseInt(deliveryStart[0])
  610. var startMin = parseInt(deliveryStart[1])
  611. var stopHour = parseInt(deliveryStop[0])
  612. var stopMin = parseInt(deliveryStop[1])
  613. var date = new Date()
  614. var year = date.getFullYear()
  615. var month = date.getMonth() + 1
  616. var day = date.getDate()
  617. // Create dates for today, tomorrow and after tomorrow
  618. var today = new Date(year, month - 1, day)
  619. var tomorrow = new Date(year, month - 1, day + 1)
  620. var afterTomo = new Date(year, month - 1, day + 2)
  621. // Get correct month and day for each date
  622. var todayMonth = today.getMonth() + 1
  623. var todayDay = today.getDate()
  624. var tomorrowMonth = tomorrow.getMonth() + 1
  625. var tomorrowDay = tomorrow.getDate()
  626. var afterTomoMonth = afterTomo.getMonth() + 1
  627. var afterTomoDay = afterTomo.getDate()
  628. // Format dates with leading zeros if needed
  629. var formatTodayMonth = todayMonth > 9 ? todayMonth : '0' + todayMonth
  630. var formatTodayDay = todayDay > 9 ? todayDay : '0' + todayDay
  631. var formatTomorrowMonth = tomorrowMonth > 9 ? tomorrowMonth : '0' + tomorrowMonth
  632. var formatTomorrowDay = tomorrowDay > 9 ? tomorrowDay : '0' + tomorrowDay
  633. var formatAfterTomoMonth = afterTomoMonth > 9 ? afterTomoMonth : '0' + afterTomoMonth
  634. var formatAfterTomoDay = afterTomoDay > 9 ? afterTomoDay : '0' + afterTomoDay
  635. this.dateObj.year = year
  636. this.dateObj.today = formatTodayDay
  637. this.dateObj.tomorrow = formatTomorrowDay
  638. this.dateObj.afterTomo = formatAfterTomoDay
  639. this.dateObj.month = formatTodayMonth // Use today's month as reference
  640. this.dayList = [
  641. '今天' + formatTodayMonth + '月' + formatTodayDay + '日',
  642. '明天' + formatTomorrowMonth + '月' + formatTomorrowDay + '日',
  643. '后天' + formatAfterTomoMonth + '月' + formatAfterTomoDay + '日'
  644. ]
  645. this.timeList[0] = ['尽快送达']
  646. this.timeList[1] = []
  647. for (var i = 0; i < stopHour - startHour; i++) {
  648. var time = startHour + i > 9 ? parseInt(startHour + i) : '0' + parseInt(startHour + i)
  649. this.timeList[1].push([time + ':00', time + ':30'])
  650. this.timeList[1].push([time + ':30', parseInt(parseInt(time) + 1) + ':00'])
  651. }
  652. if (startMin >= 30) {
  653. this.timeList[1].splice(0, 1)
  654. }
  655. //预计送达时间字符
  656. this.orderReqeust.predictTime = this.dayList[1] + this.timeList[1][0][0] + '-' + this.timeList[1][0][1]
  657. this.orderReqeust.predictDate = new Date(year + '-' + formatTomorrowMonth + '-' + formatTomorrowDay + ' ' + this.timeList[1][0][1]).getTime()
  658. this.timeList[2] = []
  659. for (var i = 0; i < stopHour - startHour; i++) {
  660. var time = startHour + i > 9 ? parseInt(startHour + i) : '0' + parseInt(startHour + i)
  661. this.timeList[2].push([time + ':00', time + ':30'])
  662. this.timeList[2].push([time + ':30', parseInt(parseInt(time) + 1) + ':00'])
  663. }
  664. if (startMin >= 30) {
  665. this.timeList[2].splice(0, 1)
  666. }
  667. var now = date.getHours()
  668. if (now < startHour) {
  669. now = startHour
  670. }
  671. var nowTime = date.getMinutes()
  672. this.nowTime = nowTime
  673. this.now = now
  674. if (now >= stopHour) {
  675. this.dayList.splice(0, 1)
  676. this.timeList.splice(0, 1)
  677. } else {
  678. this.timeList[0] = ['尽快送达']
  679. for (var i = 0; i < stopHour - now; i++) {
  680. var time = now + i > 9 ? now + i : '0' + parseInt(now + i)
  681. this.timeList[0].push([time + ':00', time + ':30'])
  682. this.timeList[0].push([time + ':30', parseInt(now + i + 1) + ':00'])
  683. }
  684. if (nowTime > 30) {
  685. this.timeList[0].splice(1, 2)
  686. var timeMine = nowTime - 30 > 9 ? parseInt(nowTime - 30) : '0' + parseInt(nowTime - 30)
  687. this.orderReqeust.predictTime = '尽快送达(预计' + parseInt(now + 1) + ':' + timeMine + '送达)'
  688. this.orderReqeust.predictDate = new Date(year + '-' + formatTodayMonth + '-' + formatTodayDay + ' ' + parseInt(now + 1) + ':' + timeMine).getTime()
  689. } else if (nowTime < 29) {
  690. this.orderReqeust.predictTime = '尽快送达(预计' + now + ':' + parseInt(nowTime + 30) + '送达)'
  691. this.orderReqeust.predictDate = new Date(year + '-' + formatTodayMonth + '-' + formatTodayDay + ' ' + now + ':' + parseInt(nowTime + 30)).getTime()
  692. } else if (nowTime == 30) {
  693. this.timeList[0].splice(1, 1)
  694. this.orderReqeust.predictTime = '尽快送达(预计' + parseInt(now + 1) + ':00送达)'
  695. this.orderReqeust.predictDate = new Date(year + '-' + formatTodayMonth + '-' + formatTodayDay + ' ' + parseInt(now + 1) + ':00').getTime()
  696. }
  697. }
  698. },
  699. chooseDay(index) {
  700. this.dayIndex = index
  701. },
  702. chooseTime(index) {
  703. this.timeIndex = index
  704. },
  705. checkTime() {
  706. //当天尽快送达
  707. if (this.dayIndex == 0 && this.timeIndex == 0 && this.dayList.length >= 3) {
  708. if (this.nowTime > 30) {
  709. var timeMine = this.nowTime - 30 > 9 ? parseInt(this.nowTime - 30) : '0' + parseInt(this.nowTime - 30)
  710. this.orderReqeust.predictTime = '尽快送达(预计' + parseInt(this.now + 1) + ':' + timeMine + '送达)'
  711. this.orderReqeust.predictDate = new Date(this.dateObj.year + '-' + this.dateObj.month + '-' + this.dateObj.today + ' ' + parseInt(this.now + 1) + ':' + timeMine).getTime()
  712. } else if (this.nowTime < 29) {
  713. this.orderReqeust.predictTime = '尽快送达(预计' + this.now + ':' + parseInt(this.nowTime + 30) + '送达)'
  714. this.orderReqeust.predictDate = new Date(this.dateObj.year + '-' + this.dateObj.month + '-' + this.dateObj.today + ' ' + this.now + ':' + parseInt(this.nowTime + 30)).getTime()
  715. } else if (this.nowTime == 30) {
  716. this.orderReqeust.predictTime = '尽快送达(预计' + parseInt(this.now + 1) + ':00送达)'
  717. this.orderReqeust.predictDate = new Date(this.dateObj.year + '-' + this.dateObj.month + '-' + this.dateObj.today + ' ' + parseInt(this.now + 1) + ':00').getTime()
  718. }
  719. this.$refs.popup.close()
  720. console.log(this.orderReqeust)
  721. return
  722. }
  723. //当天送达
  724. if (this.dayIndex == 0 && this.dayList.length >= 3) {
  725. this.orderReqeust.predictTime = this.timeList[0][this.timeIndex][0] + '-' + this.timeList[0][this.timeIndex][1]
  726. console.log(this.dateObj.year + '-' + this.dateObj.month + '-' + this.dateObj.today + ' ' + this.timeList[this.dayIndex][this.timeIndex][1])
  727. this.orderReqeust.predictDate = new Date(this.dateObj.year + '-' + this.dateObj.month + '-' + this.dateObj.today + ' ' + this.timeList[this.dayIndex][this.timeIndex][1]).getTime()
  728. this.$refs.popup.close()
  729. console.log(this.orderReqeust)
  730. return
  731. }
  732. //明、后天送达
  733. this.orderReqeust.predictTime = this.dayList[this.dayIndex] + this.timeList[this.dayIndex][this.timeIndex][0] + '-' + this.timeList[this.dayIndex][this.timeIndex][1]
  734. if (this.dayList.length >= 3) {
  735. if (this.dayIndex == 1) {//明天
  736. this.orderReqeust.predictDate = new Date(this.dateObj.year + '-' + this.dateObj.month + '-' + this.dateObj.tomorrow + ' ' + this.timeList[this.dayIndex][this.timeIndex][1]).getTime()
  737. } else if (this.dayIndex == 2) {//后天
  738. this.orderReqeust.predictDate = new Date(this.dateObj.year + '-' + this.dateObj.month + '-' + this.dateObj.afterTomo + ' ' + this.timeList[this.dayIndex][this.timeIndex][1]).getTime()
  739. }
  740. } else if (this.dayList.length >= 2) {
  741. if (this.dayIndex == 0) {//明天
  742. this.orderReqeust.predictDate = new Date(this.dateObj.year + '-' + this.dateObj.month + '-' + this.dateObj.tomorrow + ' ' + this.timeList[this.dayIndex][this.timeIndex][1]).getTime()
  743. } else if (this.dayIndex == 1) {//后天
  744. this.orderReqeust.predictDate = new Date(this.dateObj.year + '-' + this.dateObj.month + '-' + this.dateObj.afterTomo + ' ' + this.timeList[this.dayIndex][this.timeIndex][1]).getTime()
  745. }
  746. }
  747. this.$refs.popup.close()
  748. console.log(this.orderReqeust)
  749. },
  750. //确认支付
  751. confirm(orderNo, totalPrice) {
  752. // ============微信支付代码 prod 开始============
  753. // #ifdef APP-PLUS
  754. this.$api.msg('演示环境不支持支付')
  755. return
  756. // #endif
  757. const that = this
  758. that.$api.request('get', 'order/app/wxPrepay', {
  759. orderId: orderNo
  760. }, failres => {
  761. that.submiting = false
  762. that.$api.msg(failres.msg)
  763. }).then(prepayRes => {
  764. uni.hideLoading()
  765. that.submiting = false
  766. //#ifdef MP-WEIXIN
  767. const payParam = {
  768. appId: prepayRes.data.appId,
  769. nonceStr: prepayRes.data.nonceStr,
  770. package: prepayRes.data.packageValue,
  771. timeStamp: prepayRes.data.timeStamp,
  772. signType: prepayRes.data.signType,
  773. paySign: prepayRes.data.paySign,
  774. }
  775. //#endif
  776. //#ifdef APP-PLUS
  777. const payParam = {
  778. appid: prepayRes.data.appId,
  779. noncestr: prepayRes.data.nonceStr,
  780. package: prepayRes.data.packageValue,
  781. partnerid: prepayRes.data.partnerId,
  782. prepayid: prepayRes.data.prepayId,
  783. timestamp: parseInt(prepayRes.data.timeStamp),
  784. sign: prepayRes.data.sign,
  785. signType: 'MD5'
  786. }
  787. //#endif
  788. //#ifdef MP-WEIXIN || APP-PLUS
  789. uni.requestPayment({
  790. provider: 'wxpay',
  791. //#ifdef MP-WEIXIN
  792. ...payParam,
  793. //#endif
  794. //#ifdef APP-PLUS
  795. orderInfo: payParam,
  796. //#endif
  797. success: function (res) {
  798. uni.redirectTo({
  799. url: '/pages/pay/success'
  800. })
  801. },
  802. fail: function (res) {
  803. // console.log("支付过程失败");
  804. // that.$api.msg(JSON.stringify(res))
  805. },
  806. complete: function (res) {
  807. console.log("支付过程结束")
  808. }
  809. });
  810. //#endif
  811. //#ifdef H5
  812. that.$jweixin.chooseWXPay({
  813. nonceStr: prepayRes.data.nonceStr,
  814. timestamp: prepayRes.data.timeStamp,
  815. package: prepayRes.data.packageValue,
  816. signType: prepayRes.data.signType,
  817. paySign: prepayRes.data.paySign,
  818. success: (e) => {
  819. //支付成功
  820. uni.redirectTo({
  821. url: '/pages/pay/success'
  822. })
  823. },
  824. fail: function (res) {
  825. console.log("支付过程失败");
  826. that.$api.msg(JSON.stringify(res))
  827. },
  828. complete: function (res) {
  829. console.log("支付过程结束")
  830. }
  831. })
  832. //#endif
  833. })
  834. //============微信支付代码 prod 结束============
  835. //============微信支付代码 dev 开始============
  836. // uni.request({
  837. // url: this.$api.defConfig().baseUrl + '/cb/wxpay',
  838. // data: {
  839. // outTradeNo: orderNo,
  840. // transactionId:'test',
  841. // totalFee: Math.round(totalPrice * 100)
  842. // },
  843. // method: 'POST',
  844. // header: {
  845. // 'Content-Type': 'application/json; charset=UTF-8'
  846. // },
  847. // success: (res) => {
  848. // //代码回调-上线后注释代码-结束
  849. // uni.redirectTo({
  850. // url: '/pages/pay/success'
  851. // })
  852. // }
  853. // });
  854. //============微信支付代码 dev 结束============
  855. }
  856. }
  857. }
  858. </script>
  859. <style lang="scss">
  860. page {
  861. background: #F4F4F4;
  862. padding-bottom: 100upx;
  863. }
  864. .mask {
  865. display: flex;
  866. align-items: flex-end;
  867. position: fixed;
  868. left: 0;
  869. top: var(--window-top);
  870. bottom: 0;
  871. width: 100%;
  872. background: rgba(0, 0, 0, 0);
  873. z-index: 9995;
  874. transition: .3s;
  875. .mask-content {
  876. width: 100%;
  877. min-height: 30vh;
  878. max-height: 70vh;
  879. background: #f3f3f3;
  880. transform: translateY(100%);
  881. transition: .3s;
  882. overflow-y: scroll;
  883. }
  884. &.none {
  885. display: none;
  886. }
  887. &.show {
  888. background: rgba(0, 0, 0, .4);
  889. .mask-content {
  890. transform: translateY(0);
  891. }
  892. }
  893. }
  894. /* 优惠券列表 */
  895. .coupon-item {
  896. display: flex;
  897. flex-direction: column;
  898. margin: 20upx 24upx;
  899. background: #fff;
  900. .con {
  901. display: flex;
  902. align-items: center;
  903. position: relative;
  904. height: 120upx;
  905. padding: 0 30upx;
  906. &:after {
  907. position: absolute;
  908. left: 0;
  909. bottom: 0;
  910. content: '';
  911. width: 100%;
  912. height: 0;
  913. border-bottom: 1px dashed #f3f3f3;
  914. transform: scaleY(50%);
  915. }
  916. }
  917. .left {
  918. display: flex;
  919. flex-direction: column;
  920. justify-content: center;
  921. flex: 1;
  922. overflow: hidden;
  923. height: 100upx;
  924. }
  925. .title {
  926. font-size: 32upx;
  927. color: $font-color-dark;
  928. margin-bottom: 10upx;
  929. }
  930. .time {
  931. font-size: 24upx;
  932. color: $font-color-light;
  933. }
  934. .right {
  935. display: flex;
  936. flex-direction: column;
  937. justify-content: center;
  938. align-items: center;
  939. font-size: 26upx;
  940. color: $font-color-base;
  941. height: 100upx;
  942. }
  943. .price {
  944. font-size: 44upx;
  945. color: $base-color;
  946. &:before {
  947. content: '¥';
  948. font-size: 34upx;
  949. }
  950. }
  951. .tips {
  952. font-size: 24upx;
  953. color: $font-color-light;
  954. line-height: 60upx;
  955. padding-left: 30upx;
  956. }
  957. .circle {
  958. position: absolute;
  959. left: -6upx;
  960. bottom: -10upx;
  961. z-index: 10;
  962. width: 20upx;
  963. height: 20upx;
  964. background: #f3f3f3;
  965. border-radius: 100px;
  966. &.r {
  967. left: auto;
  968. right: -6upx;
  969. }
  970. }
  971. }
  972. .address {
  973. padding: 36upx 30upx;
  974. background-color: #FFFFFF;
  975. overflow: hidden;
  976. }
  977. .address-head {
  978. color: #999999;
  979. font-size: 28upx;
  980. font-weight: 400;
  981. }
  982. .address-main {
  983. margin-top: 24upx;
  984. }
  985. .address-left {
  986. margin: 9upx 0;
  987. width: 24upx;
  988. height: 32upx;
  989. float: left;
  990. }
  991. .address-text {
  992. margin-left: 14upx;
  993. float: left;
  994. font-size: 36upx;
  995. color: #333333;
  996. font-weight: 500;
  997. }
  998. .address-right {
  999. margin: 11upx 20upx 11upx 0;
  1000. width: 28upx;
  1001. height: 28upx;
  1002. float: right;
  1003. }
  1004. .address-distance {
  1005. clear: both;
  1006. margin-top: 10upx;
  1007. color: #333333;
  1008. font-size: 30upx;
  1009. }
  1010. .a-bg {
  1011. display: block;
  1012. width: 100%;
  1013. height: 5upx;
  1014. }
  1015. .goods {
  1016. margin-top: 20upx;
  1017. background-color: #FFFFFF;
  1018. overflow: hidden;
  1019. }
  1020. .goods-head {
  1021. margin: 0 30upx;
  1022. height: 100upx;
  1023. padding: 30upx 0;
  1024. border-bottom: 2upx solid #F1F1F1;
  1025. }
  1026. .goods-head-text {
  1027. width: 294upx;
  1028. float: left;
  1029. color: #333333;
  1030. font-size: 28upx;
  1031. }
  1032. .goods-head-time {
  1033. width: 490upx;
  1034. float: left;
  1035. color: #2AAC34;
  1036. font-size: 28upx;
  1037. }
  1038. .goods-head-right {
  1039. margin-top: 8upx;
  1040. width: 16upx;
  1041. height: 24upx;
  1042. float: left;
  1043. }
  1044. .goods-one {
  1045. padding: 40upx 0 30upx 0;
  1046. margin: 0 30upx;
  1047. height: 190upx;
  1048. }
  1049. .scroll_box {
  1050. width: 544upx;
  1051. height: 110upx;
  1052. float: left;
  1053. overflow: hidden;
  1054. }
  1055. .scroll_box scroll-view {
  1056. height: 110upx;
  1057. width: 544upx;
  1058. white-space: nowrap;
  1059. }
  1060. .goods-img {
  1061. margin-top: 2upx;
  1062. width: 118upx;
  1063. height: 110upx;
  1064. float: left;
  1065. }
  1066. .goods-more-img {
  1067. margin-top: 2upx;
  1068. width: 118upx;
  1069. height: 110upx;
  1070. display: inline-block;
  1071. margin-right: 36upx;
  1072. }
  1073. .goods-more-number {
  1074. width: 126upx;
  1075. height: 110upx;
  1076. line-height: 110upx;
  1077. text-align: center;
  1078. color: #1B1C33;
  1079. font-size: 28upx;
  1080. float: left;
  1081. }
  1082. .goods-more-right {
  1083. margin-top: 43.5upx;
  1084. width: 15upx;
  1085. height: 23upx;
  1086. float: left;
  1087. }
  1088. .goods-text {
  1089. margin-top: 6upx;
  1090. margin-left: 32upx;
  1091. width: 538upx;
  1092. height: 110upx;
  1093. float: left;
  1094. }
  1095. .goods-name {
  1096. width: 500upx;
  1097. line-height: 44upx;
  1098. overflow: hidden;
  1099. color: #333333;
  1100. font-size: 32upx;
  1101. }
  1102. .goods-tag {
  1103. margin-top: 10upx;
  1104. }
  1105. .goods-price {
  1106. float: left;
  1107. color: #333333;
  1108. font-size: 32upx;
  1109. line-height: 44upx;
  1110. }
  1111. .goods-yprice {
  1112. margin-left: 16upx;
  1113. float: left;
  1114. color: #AEAEAE;
  1115. font-size: 24upx;
  1116. line-height: 44upx;
  1117. text-decoration: line-through;
  1118. }
  1119. .goods-number {
  1120. float: right;
  1121. color: #333333;
  1122. font-size: 32upx;
  1123. }
  1124. .distribution {
  1125. padding: 0 30upx;
  1126. margin-top: 20upx;
  1127. background-color: #FFFFFF;
  1128. overflow: hidden;
  1129. }
  1130. .distribution-list {
  1131. height: 100upx;
  1132. line-height: 100upx;
  1133. font-size: 28upx;
  1134. clear: both;
  1135. }
  1136. .distribution-list-bottom {
  1137. border-bottom: 2upx solid #F1F1F1;
  1138. }
  1139. .info-icon {
  1140. width: 28upx;
  1141. height: 28upx;
  1142. margin-left: 10upx;
  1143. vertical-align: middle;
  1144. }
  1145. .distribution-price {
  1146. width: 490upx;
  1147. float: left;
  1148. text-align: right;
  1149. color: #666666;
  1150. }
  1151. .distribution-price input {
  1152. width: 490upx;
  1153. height: 100upx;
  1154. line-height: 100upx;
  1155. overflow: hidden;
  1156. text-align: right;
  1157. }
  1158. .pay-text {
  1159. color: #333333;
  1160. font-size: 32upx;
  1161. }
  1162. .distribution-price image {
  1163. width: 40upx;
  1164. height: 40upx;
  1165. float: right;
  1166. margin-top: 30upx;
  1167. }
  1168. .footer {
  1169. position: fixed;
  1170. left: 0;
  1171. bottom: 0;
  1172. z-index: 99;
  1173. height: 98upx;
  1174. width: 100%;
  1175. background-color: #FFFFFF;
  1176. }
  1177. .priceClass {
  1178. margin-left: 62upx;
  1179. width: 448upx;
  1180. float: left;
  1181. }
  1182. .price-content {
  1183. height: 50upx;
  1184. line-height: 50upx;
  1185. margin-top: 10upx;
  1186. color: #666666;
  1187. font-size: 26upx;
  1188. }
  1189. .price-content-money {
  1190. color: #2AAC34;
  1191. font-size: 36upx;
  1192. }
  1193. .price-preferential {
  1194. height: 36upx;
  1195. line-height: 36upx;
  1196. color: #AEAEAE;
  1197. font-size: 20upx;
  1198. }
  1199. .submit {
  1200. width: 240upx;
  1201. float: left;
  1202. line-height: 98upx;
  1203. color: #FFFFFF;
  1204. background-color: #2AAC34;
  1205. text-align: center;
  1206. }
  1207. .order-submission .wrapper .shipping select {
  1208. color: #999;
  1209. padding-right: 0.15 * 100rpx;
  1210. }
  1211. .order-submission .wrapper .shipping .iconfont {
  1212. font-size: 0.3 * 100rpx;
  1213. color: #515151;
  1214. }
  1215. .order-submission .allAddress {
  1216. width: 100%;
  1217. background-image: linear-gradient(to bottom, #FFFFFF 0%, #FFFFFF 100%);
  1218. background-image: -webkit-linear-gradient(to bottom, #FFFFFF 0%, #FFFFFF 100%);
  1219. background-image: -moz-linear-gradient(to bottom, #FFFFFF 0%, #FFFFFF 100%);
  1220. padding-top: 1 * 100rpx;
  1221. }
  1222. .order-submission .allAddress .nav {
  1223. margin: 0 auto;
  1224. padding: 0 30rpx;
  1225. width: 100%;
  1226. box-sizing: border-box;
  1227. }
  1228. .order-submission .allAddress .nav .item {
  1229. flex: 1;
  1230. position: relative;
  1231. }
  1232. .order-submission .allAddress .nav .item.on {
  1233. position: relative;
  1234. }
  1235. .order-submission .allAddress .nav .item.on:before {
  1236. position: absolute;
  1237. bottom: 0;
  1238. content: '骑手配送';
  1239. font-size: 0.28 * 100rpx;
  1240. display: block;
  1241. height: 0;
  1242. left: 0;
  1243. right: 0;
  1244. border-width: 0.4 * 100rpx;
  1245. border-style: solid;
  1246. border-color: #fff;
  1247. z-index: 9;
  1248. text-align: center;
  1249. line-height: 0.14 * 100rpx;
  1250. }
  1251. .order-submission .allAddress .nav .item:nth-of-type(2).on:before {
  1252. content: '到店自提';
  1253. border-width: 0.4 * 100rpx;
  1254. }
  1255. .order-submission .allAddress .nav .item.on2 {
  1256. position: relative;
  1257. }
  1258. .order-submission .allAddress .nav .item.on2:before {
  1259. position: absolute;
  1260. bottom: 0;
  1261. content: '到店自提';
  1262. font-size: 0.28 * 100rpx;
  1263. display: block;
  1264. height: 0;
  1265. left: 0;
  1266. right: 0;
  1267. border-width: 0.4 * 100rpx;
  1268. border-style: solid;
  1269. border-color: #d5e6e6;
  1270. text-align: center;
  1271. line-height: 0.14 * 100rpx;
  1272. }
  1273. .order-submission .allAddress .nav .item:nth-of-type(1).on2:before {
  1274. content: '骑手配送';
  1275. border-width: 0.4 * 100rpx;
  1276. }
  1277. .order-submission .allAddress .address {
  1278. width: 6.91 * 100rpx;
  1279. height: 1.5 * 100rpx;
  1280. margin: 0 auto;
  1281. box-sizing: border-box;
  1282. }
  1283. .order-submission .allAddress .line {
  1284. width: 7.1 * 100rpx;
  1285. margin: 0 auto;
  1286. }
  1287. .order-submission .wrapper .item .discount input::placeholder {
  1288. color: #ccc;
  1289. }
  1290. .distribution-text {
  1291. width: 200upx;
  1292. float: left;
  1293. color: #333333;
  1294. display: flex; // 使用 flex 布局
  1295. align-items: center; // 垂直居中
  1296. }
  1297. .best-coupon {
  1298. display: inline-block;
  1299. padding: 4upx 8upx;
  1300. background-color: #fff;
  1301. border-radius: 4upx;
  1302. color: red;
  1303. font-size: 24upx;
  1304. }
  1305. /* 照片上传相关样式 */
  1306. .photo-upload-section {
  1307. flex-direction: column !important;
  1308. align-items: flex-start !important;
  1309. }
  1310. .photo-upload-container {
  1311. width: 100%;
  1312. margin-top: 20rpx;
  1313. }
  1314. .photo-list {
  1315. display: flex;
  1316. flex-wrap: wrap;
  1317. gap: 20rpx;
  1318. }
  1319. .photo-item {
  1320. position: relative;
  1321. width: 160rpx;
  1322. height: 160rpx;
  1323. }
  1324. .photo-preview {
  1325. width: 100%;
  1326. height: 100%;
  1327. border-radius: 8rpx;
  1328. border: 2rpx solid #e5e5e5;
  1329. }
  1330. .photo-delete {
  1331. position: absolute;
  1332. top: -10rpx;
  1333. right: -10rpx;
  1334. width: 40rpx;
  1335. height: 40rpx;
  1336. background-color: #ff4757;
  1337. border-radius: 50%;
  1338. display: flex;
  1339. align-items: center;
  1340. justify-content: center;
  1341. }
  1342. .photo-delete-icon {
  1343. color: #fff;
  1344. font-size: 24rpx;
  1345. font-weight: bold;
  1346. }
  1347. .photo-add-btn {
  1348. width: 160rpx;
  1349. height: 160rpx;
  1350. border: 2rpx dashed #ccc;
  1351. border-radius: 8rpx;
  1352. display: flex;
  1353. flex-direction: column;
  1354. align-items: center;
  1355. justify-content: center;
  1356. background-color: #fafafa;
  1357. }
  1358. .photo-add-icon {
  1359. font-size: 48rpx;
  1360. color: #999;
  1361. margin-bottom: 8rpx;
  1362. }
  1363. .photo-add-text {
  1364. font-size: 24rpx;
  1365. color: #999;
  1366. }
  1367. .photo-tips {
  1368. margin-top: 20rpx;
  1369. font-size: 24rpx;
  1370. color: #999;
  1371. }
  1372. </style>