confirmOrder.vue 50 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787
  1. <template>
  2. <view class="pages">
  3. <!-- 地址 -->
  4. <view class="text-center text-red" v-if="isTrue && orderType == 2">超出配送距离</view>
  5. <view class="food">
  6. <view class="flex bg justify-between padding-lr-xl">
  7. <view @click="switchTab(2)" :class="orderType == 2 ? 'select' : ''" class="tabBtn" v-if="XCXIsSelect == '是'">
  8. <view class="title">外卖配送</view>
  9. <view :class="orderType == 2 ? 'active' : ''"></view>
  10. </view>
  11. <view @click="switchTab(1)" :class="orderType == 1 ? 'select' : ''" class="tabBtn">
  12. <view class="title">到店自取</view>
  13. <view :class="orderType == 1 ? 'active' : ''"></view>
  14. </view>
  15. </view>
  16. <view v-if="orderType == 1">
  17. <!-- <view class="text-black text-lg margin-top">商家地址</view> -->
  18. <view class="flex margin-top" style="">
  19. <u-icon name="map" size="50"></u-icon>
  20. <view class="flex-sub padding-tb-sm margin-left-sm">
  21. <view class="text-lg text-bold text-black">
  22. <text>{{ dataList.shopName }}</text>
  23. <text class="margin-left-sm" @click="call">{{ dataList.shopPhone }}</text>
  24. </view>
  25. <view class="text-df margin-top-xs" style="color: #999999" @click="goMap">
  26. {{ dataList.detailedAddress }}
  27. </view>
  28. </view>
  29. </view>
  30. <!-- 预约送达时间 -->
  31. <!-- <view class="goods_address" v-if="reservationOpenFlag==1">
  32. <view class="address_box">
  33. <view class="address_name">送达时间</view>
  34. <picker class='time-picker' mode="multiSelector" @change="bindStartMultiPickerChange"
  35. @columnchange="bindMultiPickerColumnChange" :range="data.multiArray">
  36. {{data.startDate}}
  37. </picker>
  38. <view class="songda_image">
  39. <image src="../../../static/images/index/right.png"></image>
  40. </view>
  41. </view>
  42. </view> -->
  43. </view>
  44. <view class="" v-if="orderType == 2">
  45. <view class="goods_address" v-if="JSON.stringify(address) == '{}'" @click="goAddress">
  46. <view class="address_box">
  47. <view class="address_name">请选择收货地址</view>
  48. <view class="address_image margin-left">
  49. <image src="../../../static/images/index/right.png"></image>
  50. </view>
  51. </view>
  52. </view>
  53. <view class="flex margin-top" style="" v-else @click="goAddress">
  54. <u-icon name="map" size="50"></u-icon>
  55. <view class="flex-sub padding-tb-sm margin-left-sm">
  56. <view class="text-lg text-bold text-black">
  57. <text>{{ address.userName }}</text>
  58. <text class="margin-left-sm">{{ address.userPhone }}</text>
  59. </view>
  60. <view class="text-df margin-top-xs" style="color: #999999">{{ address.province }}{{ address.city }}{{ address.district }}{{ address.addressDetail }}</view>
  61. </view>
  62. <view class="address_image margin-left">
  63. <image src="../../../static/images/index/right.png"></image>
  64. </view>
  65. </view>
  66. <!-- 预约送达时间 -->
  67. <!-- <view class="goods_address" v-if="reservationOpenFlag==1">
  68. <view class="address_box">
  69. <view class="address_name">送达时间</view>
  70. <picker class='time-picker' mode="multiSelector" @change="bindStartMultiPickerChange"
  71. @columnchange="bindMultiPickerColumnChange" :range="data.multiArray">
  72. {{data.startDate}}
  73. </picker>
  74. <view class="songda_image">
  75. <image src="../../../static/images/index/right.png"></image>
  76. </view>
  77. </view>
  78. </view> -->
  79. </view>
  80. </view>
  81. <!-- 商品 -->
  82. <view class="food">
  83. <view class="tosend_header_food" v-for="(item, index) in goodsList" :key="index">
  84. <view class="tosend_header_food_le">
  85. <image :src="item.goodsPicture[0]" style="border-radius: 10rpx" mode=""></image>
  86. </view>
  87. <view class="flex-sub margin-left-sm">
  88. <view class="flex justify-between align-center">
  89. <view class="text-lg text-bold text-black">{{ item.goodsName }}</view>
  90. <view class="text-lg text-bold text-black">
  91. <text class="text-sm">¥</text>
  92. {{ item.goodsPrice }}
  93. </view>
  94. </view>
  95. <view class="flex justify-between align-center text-gray">
  96. <view v-if="item.skuMessage">{{ item.skuMessage }}</view>
  97. <view>x{{ item.goodsNum }}</view>
  98. </view>
  99. <view class="flex justify-between text-bold align-center margin-tb-sm">
  100. <view>打包费</view>
  101. <view class="">¥{{ item.goodsPack }} / 份</view>
  102. </view>
  103. </view>
  104. </view>
  105. <view class="tosend_header_do justify-between" v-if="paotuiMoney > 0 && orderType == 2">
  106. <view>跑腿费</view>
  107. <view class="tosend_header_do_ri">¥{{ paotuiMoney }}</view>
  108. </view>
  109. <view class="tosend_header_do justify-between do_bot" @click="isShow">
  110. <view>优惠券</view>
  111. <view class="tosend_header_do_ri" v-if="coupon">- ¥{{ coupon.money }}</view>
  112. <view v-else>
  113. <image src="../../../static/images/order/right1.png" style="width: 14rpx; height: 24rpx" mode=""></image>
  114. </view>
  115. </view>
  116. <view class="tosend_header_do justify-between do_bot" @click="huodongShow">
  117. <view>优惠活动</view>
  118. <view class="tosend_header_do_ri" v-if="huodong">- ¥{{ huodong.discountAmount }}</view>
  119. <view v-else>
  120. <image src="../../../static/images/order/right1.png" style="width: 14rpx; height: 24rpx" mode=""></image>
  121. </view>
  122. </view>
  123. <view class="tosend_header_do justify-between">
  124. <view class="tosend_header_do_le2">合计</view>
  125. <view class="tosend_header_do_ri2">
  126. <text>¥</text>
  127. {{ totalPrice1 }}
  128. </view>
  129. </view>
  130. </view>
  131. <!-- 订单备注 -->
  132. <view class="food">
  133. <view class="padding-tb-sm text-lg text-bold text-bold text-black">订单备注</view>
  134. <view class="flex align-center justify-between padding-tb-sm padding-lr" style="background: #f5f5f5; width: 100%">
  135. <u-input v-model="remark" type="textarea" placeholder="请输入订单备注" height="180" maxlength="200" style="width: 100%"></u-input>
  136. </view>
  137. </view>
  138. <!-- 支付方式 -->
  139. <view class="food">
  140. <view class="padding-tb-sm text-lg text-bold text-bold text-black">支付方式</view>
  141. <view style="height: 100upx" v-for="(item, index) in openLists" :key="index">
  142. <view class="flex align-center justify-between padding-tb" v-if="item.text != '零钱'">
  143. <image :src="item.image" style="width: 55rpx; height: 55rpx; border-radius: 50upx"></image>
  144. <view class="flex-sub text-xl margin-left">{{ item.text }}</view>
  145. <radio-group name="openWay" style="margin-left: 20upx" @change="selectWay(item)">
  146. <label class="tui-radio">
  147. <radio class="red" :checked="openWay === item.id ? true : false" />
  148. </label>
  149. </radio-group>
  150. </view>
  151. <view class="flex align-center justify-between padding-tb" v-if="item.text === '零钱'">
  152. <image :src="item.image" style="width: 55rpx; height: 55rpx; border-radius: 50upx"></image>
  153. <view class="flex-sub text-xl margin-left">
  154. {{ item.text }}
  155. <text style="font-size: 30rpx; margin-left: 10rpx" v-if="userMoney && userMoney > 0">(余额:{{ userMoney }})</text>
  156. <!-- <text v-else
  157. style="font-size: 30rpx;margin-left: 10rpx;text-decoration:underline;color: #ea0000;"
  158. @tap="goCash()">去充值</text> -->
  159. </view>
  160. <radio-group name="openWay" style="margin-left: 20upx" @change="selectWay(item)">
  161. <label class="tui-radio">
  162. <radio class="red" :checked="openWay === item.id ? true : false" />
  163. </label>
  164. </radio-group>
  165. </view>
  166. </view>
  167. </view>
  168. <view style="height: 120rpx"></view>
  169. <!-- 结算 -->
  170. <view class="goorder">
  171. <view class="goorder_but" :class="isTrue && orderType == 2 ? 'goorder_but_' : ''" @click="toSettlement_throttle">立即结算</view>
  172. </view>
  173. <view class="hintPopul" v-if="shopDet && shopDet.putawayFlag == 1">
  174. <view class="content_">
  175. <image src="../../../static/images/index/shop.png" style="width: 200rpx; height: 180rpx"></image>
  176. <view class="text-xl text-bold">店铺打烊啦</view>
  177. <view class="hintText margin-top-sm text-gray">现在店铺已经打烊了,营业时间</view>
  178. <view class="margin-top-xs text-gray margin-bottom">{{ shopDet.businessHours }}-{{ shopDet.lockHours }}</view>
  179. <view class="Btns" @click="goBack()">知道了</view>
  180. </view>
  181. </view>
  182. <u-popup
  183. v-model="show"
  184. mode="center"
  185. :closeable="true"
  186. close-icon-pos="top-right"
  187. close-icon="close-circle"
  188. close-icon-size="50"
  189. border-radius="20"
  190. width="80%"
  191. @close="close"
  192. >
  193. <view class="padding bg-gray">
  194. <view class="text-center text-lg text-bold margin-bottom-sm">可用优惠券</view>
  195. <scroll-view scroll-y="true" style="height: 600rpx" v-if="couponList.length > 0">
  196. <view
  197. class="flex justify-between align-center radius margin-tb-sm padding-sm bg-white"
  198. v-for="(item, index) in couponList"
  199. :key="index"
  200. @click="selCoupon(item)"
  201. >
  202. <view>
  203. <view>{{ item.couponName }}</view>
  204. <view>
  205. {{ item.shopId == 0 ? '平台优惠券' : '商家优惠券' }}
  206. </view>
  207. <view>有效期至{{ item.expirationTime }}</view>
  208. </view>
  209. <view class="text-sm text-bold">
  210. ¥
  211. <text class="text-lg">{{ item.money }}</text>
  212. </view>
  213. </view>
  214. </scroll-view>
  215. <view v-if="couponList.length == 0" style="height: 100rpx; line-height: 100rpx; text-align: center; font-weight: 700">暂无可用优惠券</view>
  216. </view>
  217. </u-popup>
  218. <!-- 选择优惠活动 -->
  219. <u-popup
  220. v-model="youhui"
  221. mode="center"
  222. :closeable="true"
  223. close-icon-pos="top-right"
  224. close-icon="close-circle"
  225. close-icon-size="50"
  226. border-radius="20"
  227. width="80%"
  228. @close="closeYouhui()"
  229. >
  230. <view class="padding bg-gray">
  231. <view class="text-center text-lg text-bold margin-bottom-sm">可用优惠活动</view>
  232. <scroll-view scroll-y="true" style="height: 600rpx" v-if="huoList.length > 0">
  233. <view class="flex justify-between align-center radius margin-tb-sm padding-sm bg-white" v-for="(item, index) in huoList" :key="index" @click="selctHuo(item)">
  234. <view>
  235. <view>{{ item.activityTitle }}</view>
  236. <view>有效期至{{ item.activityEndTime }}</view>
  237. </view>
  238. <!-- <view class="text-sm text-bold">
  239. ¥
  240. <text class="text-lg" v-if="item.activityType=='2'">{{ item.money }}</text>
  241. <text class="text-lg" v-if="item.activityType=='2'">{{ item.money }}</text>
  242. <text class="text-lg" v-if="item.activityType=='4'">全场打{{ item.discountAmount }}折</text>
  243. </view> -->
  244. </view>
  245. </scroll-view>
  246. <view v-if="huoList.length == 0" style="height: 100rpx; line-height: 100rpx; text-align: center; font-weight: 700">暂无可用优惠活动</view>
  247. </view>
  248. </u-popup>
  249. </view>
  250. </template>
  251. <script>
  252. /**
  253. * 获取任意时间
  254. */
  255. function getDate(date, AddDayCount = 0) {
  256. if (!date) {
  257. date = new Date()
  258. }
  259. if (typeof date !== 'object') {
  260. date = date.replace(/-/g, '/')
  261. }
  262. const dd = new Date(date)
  263. dd.setDate(dd.getDate() + AddDayCount) // 获取AddDayCount天后的日期
  264. var a = new Array('日', '一', '二', '三', '四', '五', '六')
  265. var week = new Date().getDay()
  266. var week2 = new Date().getDay() + 1
  267. const y = dd.getFullYear()
  268. const m = dd.getMonth() + 1 < 10 ? '0' + (dd.getMonth() + 1) : dd.getMonth() + 1 // 获取当前月份的日期,不足10补0
  269. const d = dd.getDate() < 10 ? '0' + dd.getDate() : dd.getDate() // 获取当前几号,不足10补0
  270. const h = dd.getHours() < 10 ? '0' + dd.getHours() : dd.getHours()
  271. const f = dd.getMinutes() < 10 ? '0' + dd.getMinutes() : dd.getMinutes()
  272. const s = dd.getSeconds() < 10 ? '0' + dd.getSeconds() : dd.getSeconds()
  273. return {
  274. fullDate: y + '-' + m + '-' + d,
  275. fullDate2: y + '-' + m + '-' + d + ' ' + h + ':' + f + ':' + s,
  276. fullTime: m + '月' + d + '日',
  277. year: y,
  278. month: m,
  279. date: d,
  280. day: dd.getDay(),
  281. sWeek: '周' + a[week],
  282. eWeek: '周' + a[week2]
  283. }
  284. }
  285. import { throttle } from '@/utils/throttle.js'
  286. export default {
  287. data() {
  288. return {
  289. userMoney: 0,
  290. shopDet: '',
  291. isThrottle: true, //防抖,待支付结果返回后继续
  292. storeCommodityId: 0,
  293. openLists: [],
  294. openWay: 2,
  295. orderId: '',
  296. page: 1,
  297. limit: 100,
  298. dataList: [],
  299. packMoney: 0, //打包费
  300. totalPrice: 0,
  301. totalPrice1: 0,
  302. address: {}, //地址
  303. addressId: '',
  304. parentId: '',
  305. shopId: '',
  306. show: false,
  307. youhui: false, //优惠活动
  308. coupon: '', //选择的优惠券信息
  309. huodong: '', //选择的活动信息
  310. couponList: [],
  311. huoList: [], //可用活动
  312. orderType: 2,
  313. paotuiMoney: 0,
  314. dabaoMoney: 0,
  315. goodsMoney: null,
  316. distance: 0,
  317. isTrue: false,
  318. goodsList: [],
  319. XCXIsSelect: '是',
  320. remark: '',
  321. GoodsorderId: '',
  322. ifPaotui: 0, //是否满减
  323. lng: '',
  324. lat: '',
  325. data: {
  326. multiArray: [],
  327. warning: '',
  328. startDate: '请选择'
  329. },
  330. workStart: '', //骑手上班时间
  331. workStartMin: '', //上班分钟
  332. workEnd: '', //骑手下班时间
  333. yusongTime: '', //骑手预计送达时长
  334. reservationFlag: 0, //是否预约单 1是、0否
  335. expectDeliveryTime: '', //预约送达时间
  336. timer: '', //定时器
  337. autoSendOrder: 0, //autoSendOrder为1商家自配,0平台配送
  338. reservationOpenFlag: 0, //1预约,0不预约
  339. status: null
  340. }
  341. },
  342. onLoad(option) {
  343. console.log(option, '256')
  344. // #ifdef APP
  345. this.openLists = [
  346. {
  347. image: '../../../static/images/my/weixin.png',
  348. text: '微信',
  349. id: 2
  350. }
  351. // {
  352. // image: '../../../static/images/my/zhifubao.png',
  353. // text: '支付宝',
  354. // id: 3
  355. // },
  356. // {
  357. // image: '../../../static/images/my/jinbi.png',
  358. // text: '零钱',
  359. // id: 1
  360. // }
  361. ]
  362. // #endif
  363. // #ifdef MP-WEIXIN
  364. this.XCXIsSelect = this.$queue.getData('XCXIsSelect') ? this.$queue.getData('XCXIsSelect') : '是'
  365. this.openLists = [
  366. {
  367. image: '../../../static/images/my/weixin.png',
  368. text: '微信',
  369. id: 2
  370. }
  371. // {
  372. // image: '../../../static/images/my/jinbi.png',
  373. // text: '零钱',
  374. // id: 1
  375. // }
  376. ]
  377. // #endif
  378. // #ifdef H5
  379. this.openLists = [
  380. {
  381. image: '../../../static/images/my/weixin.png',
  382. text: '微信',
  383. id: 2
  384. }
  385. // {
  386. // image: '../../../static/images/my/zhifubao.png',
  387. // text: '支付宝',
  388. // id: 3
  389. // },
  390. // {
  391. // image: '../../../static/images/my/jinbi.png',
  392. // text: '零钱',
  393. // id: 1
  394. // }
  395. ]
  396. // #endif
  397. this.shopId = option.shopId
  398. this.orderType = option.orderType
  399. if (option.orderId) {
  400. this.orderId = option.orderId
  401. }
  402. if (option.status) {
  403. this.status = option.status
  404. }
  405. // #ifndef H5
  406. uni.getLocation({
  407. type: 'gcj02', //返回可以用于uni.openLocation的经纬度
  408. success: function (res) {
  409. this.lat = res.latitude
  410. this.lng = res.longitude
  411. }
  412. })
  413. this.getShopDet(this.shopId)
  414. // #endif
  415. // #ifdef H5
  416. uni.getLocation({
  417. type: 'gcj02', //返回可以用于uni.openLocation的经纬度
  418. success: function (res) {
  419. this.lat = res.latitude
  420. this.lng = res.longitude
  421. }
  422. })
  423. this.getShopDet(this.shopId)
  424. // #endif
  425. uni.showLoading({
  426. title: '加载中...',
  427. mask: true // 是否显示透明蒙层,防止触摸穿透
  428. })
  429. // this.getOrderList();
  430. this.getAddressList()
  431. },
  432. onUnload() {
  433. // 页面销毁时清除定时器
  434. if (this.timer) {
  435. clearInterval(this.timer)
  436. }
  437. },
  438. onShow() {
  439. this.getMsgData()
  440. console.log(uni.getStorageSync('addressId'), '地址id')
  441. this.addressId = this.addressId ? this.addressId : uni.getStorageSync('addressId')
  442. if (this.addressId) {
  443. console.log(this.addressId, '地址id')
  444. this.address = {}
  445. this.getAddressDet(this.addressId)
  446. }
  447. // 设置定时器
  448. this.timer = setInterval(() => {
  449. // 定时器执行的操作
  450. // this.getQishou()
  451. console.log('每分钟执行一次')
  452. // 这里可以放置你需要每分钟执行的代码
  453. this.getCouponList()
  454. this.getHuoList()
  455. }, 60 * 1000) // 60 * 1000 毫秒代表一分钟
  456. },
  457. methods: {
  458. //获取骑手上下班时间
  459. getQishou() {
  460. this.$Request.get('/app/tbindent/work-time').then((res) => {
  461. console.log(res, 'p')
  462. if (res.code == 0 && res.data) {
  463. if (this.orderType == 2) {
  464. if (this.autoSendOrder == 0) {
  465. //0是平台配
  466. this.workStart = parseInt(res.data.workingHoursOfRider.substring(0, 2))
  467. this.workStartMin = parseInt(res.data.workingHoursOfRider.substring(3, 5))
  468. this.workEnd = parseInt(res.data.workingHoursOfRider.substring(6, 8))
  469. } else if (this.autoSendOrder == 1) {
  470. this.workStart = parseInt(this.shopDet.businessHours.substring(0, 2))
  471. this.workStartMin = parseInt(this.shopDet.businessHours.substring(3, 5))
  472. this.workEnd = parseInt(this.shopDet.lockHours.substring(0, 2))
  473. }
  474. } else if (this.orderType == 1) {
  475. this.workStart = parseInt(this.shopDet.businessHours.substring(0, 2))
  476. this.workStartMin = parseInt(this.shopDet.businessHours.substring(3, 5))
  477. this.workEnd = parseInt(this.shopDet.lockHours.substring(0, 2))
  478. }
  479. this.yusongTime = res.data.timeOfRider
  480. var date = new Date()
  481. var currentHours = date.getHours()
  482. var currentMinute = date.getMinutes()
  483. var temp = []
  484. // currentHours = 12;
  485. var temp_time = []
  486. //如果当前时间大于20点
  487. var minite = parseInt(this.yusongTime - parseInt(this.yusongTime / 60) * 60)
  488. if (parseInt(this.yusongTime / 60) == 0) {
  489. var h1 = 0
  490. var h2 = parseInt(this.yusongTime - parseInt(this.yusongTime / 60) * 60)
  491. } else {
  492. var h1 = parseInt(this.yusongTime / 60)
  493. var h2 = parseInt(this.yusongTime - parseInt(this.yusongTime / 60) * 60)
  494. }
  495. var acc = currentHours + h1
  496. var bcc = currentMinute + h2
  497. var teshu = this.workStart + h1
  498. if (bcc >= 60) {
  499. var b = bcc - 60
  500. var a = acc + 1
  501. } else {
  502. var b = bcc
  503. var a = acc
  504. }
  505. var a1 = a + 1
  506. var s1 = a.toString()
  507. var s2 = a1.toString()
  508. var e1 = b.toString()
  509. console.log(this.workEnd, h1, currentHours, 'o')
  510. var cc = (this.workStartMin + h2).toString()
  511. if (currentHours >= this.workEnd - h1) {
  512. var time2 = teshu + 1
  513. // this.data.warning = '当前时间段无骑手配送,现在下单,最早将于明日'+teshu + ':00'+'送达'
  514. uni.showModal({
  515. title: '提示',
  516. content: '当前时间段无骑手配送,现在下单,最早将于明日' + teshu + ':00' + '送达',
  517. success: function (res) {
  518. if (res.confirm) {
  519. } else if (res.cancel) {
  520. }
  521. }
  522. })
  523. // this.data.startDate = '明日 | '+teshu + ':00' + '-' + time2 + ':00'
  524. // this.data.startDate = '明早 | '+a + ':'+b + '-' + a1 + ':'+b
  525. temp[0] = ['明天']
  526. temp[1] = []
  527. // console.log(teshu,'明1',this.workEnd-h1)
  528. for (let i = teshu; i < this.workEnd - h1; ) {
  529. var i1 = i + 1
  530. var ss1 = i.toString()
  531. var ss2 = i1.toString()
  532. // console.log(ss1,'明')
  533. temp[1].push(ss1.padStart(2, 0) + ':' + cc.padStart(2, 0) + '-' + ss2.padStart(2, 0) + ':' + cc.padStart(2, 0))
  534. i += 1
  535. }
  536. } else if (currentHours < this.workStart) {
  537. var time2 = teshu + 1
  538. uni.showModal({
  539. title: '提示',
  540. content: '当前时间段无骑手配送,现在下单,最早将于今日' + teshu + ':00' + '送达',
  541. success: function (res) {
  542. if (res.confirm) {
  543. } else if (res.cancel) {
  544. }
  545. }
  546. })
  547. temp[0] = ['今天', '明天']
  548. temp[1] = []
  549. for (let i = teshu; i < this.workEnd - h1; ) {
  550. var i1 = i + 1
  551. var ss1 = i.toString()
  552. var ss2 = i1.toString()
  553. temp[1].push(ss1.padStart(2, 0) + ':' + cc.padStart(2, 0) + '-' + ss2.padStart(2, 0) + ':' + cc.padStart(2, 0))
  554. i += 1
  555. }
  556. } else {
  557. temp[0] = ['今天', '明天']
  558. temp[1] = []
  559. for (let i = a; i < this.workEnd - h1; ) {
  560. var i1 = i + 1
  561. var ss1 = i.toString()
  562. var ss2 = i1.toString()
  563. temp[1].push(ss1.padStart(2, 0) + ':' + e1.padStart(2, 0) + '-' + ss2.padStart(2, 0) + ':' + e1.padStart(2, 0))
  564. i += 1
  565. }
  566. }
  567. // this.$queue.setData({
  568. // multiArray:temp,
  569. // })
  570. this.data.multiArray = temp
  571. if (this.data.warning != '') {
  572. wx.showToast({
  573. title: this.data.warning,
  574. icon: 'none',
  575. duration: 3000
  576. })
  577. }
  578. }
  579. })
  580. },
  581. bindMultiPickerColumnChange: function (e) {
  582. console.log(e)
  583. console.log('第几列发生变化', e.detail.column)
  584. console.log('选择第几个', e.detail.value)
  585. let c = e.detail.column
  586. let v = e.detail.value
  587. var time = []
  588. var date = new Date()
  589. var currentHours = date.getHours()
  590. var currentMinute = date.getMinutes()
  591. var minite = parseInt(this.yusongTime - parseInt(this.yusongTime / 60) * 60)
  592. if (parseInt(this.yusongTime / 60) == 0) {
  593. var h1 = 0
  594. var h2 = parseInt(this.yusongTime - parseInt(this.yusongTime / 60) * 60)
  595. } else {
  596. var h1 = parseInt(this.yusongTime / 60)
  597. var h2 = parseInt(this.yusongTime - parseInt(this.yusongTime / 60) * 60)
  598. }
  599. var acc = currentHours + h1
  600. var bcc = currentMinute + h2
  601. var teshu = this.workStart + h1
  602. if (bcc >= 60) {
  603. var b = bcc - 60
  604. var a = acc + 1
  605. } else {
  606. var b = bcc
  607. var a = acc
  608. }
  609. var a1 = a + 1
  610. var s1 = a.toString()
  611. var s2 = a1.toString()
  612. var e1 = b.toString()
  613. var cc = (this.workStartMin + h2).toString()
  614. // console.log(this.workStartMin,h2,'kkk')
  615. var temp = this.data.multiArray
  616. // currentHours = 12;
  617. if (c == 0) {
  618. if (temp[c][v] == '今天') {
  619. temp[1] = []
  620. for (let i = a; i < this.workEnd - h1; ) {
  621. var i1 = i + 1
  622. var ss1 = i.toString()
  623. var ss2 = i1.toString()
  624. temp[1].push(ss1.padStart(2, 0) + ':' + e1.padStart(2, 0) + '-' + ss2.padStart(2, 0) + ':' + e1.padStart(2, 0))
  625. i += 1
  626. }
  627. } else {
  628. temp[1] = []
  629. for (let i = teshu; i < this.workEnd - h1; ) {
  630. var i1 = i + 1
  631. var ss1 = i.toString()
  632. var ss2 = i1.toString()
  633. temp[1].push(ss1.padStart(2, 0) + ':' + cc.padStart(2, 0) + '-' + ss2.padStart(2, 0) + ':' + cc.padStart(2, 0))
  634. i += 1
  635. }
  636. }
  637. // this.$queue.setData({
  638. // multiArray:temp
  639. // })
  640. this.data.multiArray = temp
  641. this.$forceUpdate()
  642. }
  643. },
  644. bindStartMultiPickerChange: function (e) {
  645. let temp = this.data.multiArray
  646. // this.$queue.setData({
  647. // startDate:temp[0][e.detail.value[0]]+' | '+temp[1][e.detail.value[1]]
  648. // })
  649. this.data.startDate = temp[0][e.detail.value[0]] + ' | ' + temp[1][e.detail.value[1]]
  650. console.log(temp[0][e.detail.value[0]], temp[1][e.detail.value[1]].substring(0, 5), getDate(new Date(), 2).fullDate)
  651. if (this.data.startDate) {
  652. this.reservationFlag = 1
  653. if (temp[0][e.detail.value[0]] == '今天') {
  654. var date = getDate(new Date()).fullDate
  655. this.expectDeliveryTime = date + ' ' + temp[1][e.detail.value[1]].substring(0, 5) + ':00'
  656. } else if (temp[0][e.detail.value[0]] == '明天') {
  657. var date = getDate(new Date(), 1).fullDate
  658. this.expectDeliveryTime = date + ' ' + temp[1][e.detail.value[1]].substring(0, 5) + ':00'
  659. } else if (temp[0][e.detail.value[0]] == '后天') {
  660. var date = getDate(new Date(), 2).fullDate
  661. this.expectDeliveryTime = date + ' ' + temp[1][e.detail.value[1]].substring(0, 5) + ':00'
  662. }
  663. }
  664. },
  665. goCash() {
  666. uni.navigateTo({
  667. url: '/my/wallet/index'
  668. })
  669. },
  670. getMsgData() {
  671. this.$Request.get('/app/userintegral/findUserMessage').then((res) => {
  672. if (res.code == 0 && res.data) {
  673. this.userMoney = res.data.userMoney ? res.data.userMoney : 0
  674. }
  675. })
  676. },
  677. //获取店铺详情
  678. getShopDet(shopId) {
  679. let data = {
  680. shopId,
  681. lng: this.lng,
  682. lat: this.lat
  683. }
  684. this.$Request.get('/app/goods/selectGoodsList', data).then((res) => {
  685. console.log(res, 'data')
  686. if (res.code == 0 && res.data) {
  687. this.reservationOpenFlag = res.data.goodsShop.reservationOpenFlag
  688. this.autoSendOrder = res.data.goodsShop.autoSendOrder
  689. this.shopDet = res.data.goodsShop
  690. this.ifPaotui = res.data.goodsShop.enableFullReductionFlag
  691. this.getOrderList()
  692. // this.getQishou()
  693. }
  694. })
  695. },
  696. goBack() {
  697. uni.navigateBack({})
  698. },
  699. isShow() {
  700. this.show = true
  701. },
  702. //选择优惠活动弹框
  703. huodongShow() {
  704. this.youhui = true
  705. },
  706. getDistance() {
  707. if (this.address.lng && this.dataList.shopLng) {
  708. let data = {
  709. ol: this.address.lng,
  710. od: this.address.lat,
  711. dl: this.dataList.shopLng,
  712. dd: this.dataList.shopLat
  713. }
  714. this.$Request.post('/app/tbindent/distance', data).then((res) => {
  715. if (res.code == 0) {
  716. this.distance = res.data
  717. if (this.distance > Number(this.dataList.distributionDistance)) {
  718. this.isTrue = true
  719. } else {
  720. this.isTrue = false
  721. }
  722. }
  723. })
  724. }
  725. },
  726. close() {
  727. this.show = false
  728. },
  729. closeYouhui() {
  730. this.youhui = false
  731. },
  732. switchTab(e) {
  733. this.orderType = e
  734. this.coupon = ''
  735. // this.huodong = ''
  736. if (JSON.stringify(this.address) != '{}') {
  737. this.getDistance()
  738. }
  739. if (this.orderType == 2) {
  740. this.totalPrice1 = parseFloat(parseFloat(this.totalPrice) + parseFloat(this.paotuiMoney) + parseFloat(this.dabaoMoney)).toFixed(2)
  741. } else {
  742. this.totalPrice1 = parseFloat(parseFloat(this.totalPrice) + parseFloat(this.dabaoMoney)).toFixed(2)
  743. }
  744. if (this.coupon) {
  745. let totalMoney = parseFloat(
  746. this.totalPrice1 - (this.coupon.money ? this.coupon.money : 0) - (this.huodong.discountAmount ? this.huodong.discountAmount : 0).toFixed(2)
  747. )
  748. if (totalMoney <= 0) {
  749. this.totalPrice1 = 0.01
  750. } else {
  751. this.totalPrice1 = totalMoney
  752. }
  753. }
  754. if (this.huodong) {
  755. let totalMoney = parseFloat(
  756. this.totalPrice1 - (this.coupon.money ? this.coupon.money : 0) - (this.huodong.discountAmount ? this.huodong.discountAmount : 0).toFixed(2)
  757. )
  758. if (totalMoney <= 0) {
  759. this.totalPrice1 = 0.01
  760. } else {
  761. this.totalPrice1 = totalMoney
  762. }
  763. }
  764. },
  765. // 删除优惠券
  766. detCoupon() {
  767. let data = {
  768. orderId: this.dataList.orderId
  769. }
  770. this.$Request.post('/app/order/deleteCouponByOrderId', data).then((res) => {
  771. if (res.code == 0) {
  772. }
  773. })
  774. },
  775. // 选择优惠券
  776. selCoupon(item) {
  777. this.coupon = item
  778. if (this.orderType == 2) {
  779. this.totalPrice1 = parseFloat(this.totalPrice + this.paotuiMoney + this.dabaoMoney).toFixed(2)
  780. } else {
  781. this.totalPrice1 = parseFloat(this.totalPrice + this.dabaoMoney).toFixed(2)
  782. }
  783. let totalMoney = parseFloat(this.totalPrice1 - (this.coupon.money ? this.coupon.money : 0) - (this.huodong.discountAmount ? this.huodong.discountAmount : 0)).toFixed(2)
  784. if (totalMoney <= 0) {
  785. this.totalPrice1 = 0.01
  786. } else {
  787. this.totalPrice1 = totalMoney
  788. }
  789. let data = {
  790. parentId: this.dataList.parentId,
  791. couponId: this.coupon ? this.coupon.id : ''
  792. }
  793. this.$Request.post('/app/order/employCoupon', data).then((res) => {
  794. if (res.code == 0) {
  795. this.show = false
  796. }
  797. })
  798. },
  799. //选择活动activityId
  800. selctHuo(item) {
  801. this.huodong = item
  802. if (this.orderType == 2) {
  803. this.totalPrice1 = parseFloat(this.totalPrice + this.paotuiMoney + this.dabaoMoney).toFixed(2)
  804. } else {
  805. this.totalPrice1 = parseFloat(this.totalPrice + this.dabaoMoney).toFixed(2)
  806. }
  807. let totalMoney = parseFloat(this.totalPrice1 - (this.huodong.discountAmount ? this.huodong.discountAmount : 0) - (this.coupon.money ? this.coupon.money : 0)).toFixed(2)
  808. if (totalMoney <= 0) {
  809. this.totalPrice1 = 0.01
  810. } else {
  811. this.totalPrice1 = totalMoney
  812. }
  813. this.youhui = false
  814. },
  815. // 优惠卷列表
  816. getCouponList() {
  817. // console.log(this.paotuiMoney)
  818. // console.log(this.dabaoMoney, '123123')
  819. let minMoney =
  820. this.orderType == 2
  821. ? parseFloat(parseFloat(this.totalPrice) + parseFloat(this.paotuiMoney) + parseFloat(this.dabaoMoney)).toFixed(2)
  822. : parseFloat(this.totalPrice).toFixed(2)
  823. let data = {
  824. shopId: this.dataList.shopId,
  825. page: 1,
  826. limit: 10,
  827. minMoney: minMoney
  828. }
  829. this.$Request.get('/app/coupon/selectUserCouponList', data).then((res) => {
  830. if (res.code == 0) {
  831. this.couponList = res.data.list
  832. console.log(this.couponList, 'this.couponList', this.coupon)
  833. if (this.coupon) {
  834. let activityExists = this.couponList.some((item) => item.couponId === this.coupon.couponId)
  835. if (!activityExists) {
  836. this.coupon = ''
  837. if (this.orderType == 2) {
  838. this.totalPrice1 = parseFloat(this.totalPrice + this.paotuiMoney + this.dabaoMoney).toFixed(2)
  839. } else {
  840. this.totalPrice1 = parseFloat(this.totalPrice + this.dabaoMoney).toFixed(2)
  841. }
  842. let totalMoney = parseFloat(
  843. this.totalPrice1 - (this.huodong.discountAmount ? this.huodong.discountAmount : 0) - (this.coupon.money ? this.coupon.money : 0)
  844. ).toFixed(2)
  845. if (totalMoney <= 0) {
  846. this.totalPrice1 = 0.01
  847. } else {
  848. this.totalPrice1 = totalMoney
  849. }
  850. uni.showModal({
  851. title: '提示',
  852. content: '当前选择的优惠券已过期,请重新选择',
  853. success: function (res) {
  854. if (res.confirm) {
  855. this.coupon = ''
  856. } else if (res.cancel) {
  857. this.coupon = ''
  858. }
  859. }
  860. })
  861. }
  862. }
  863. }
  864. })
  865. },
  866. // 优惠活动列表
  867. getHuoList() {
  868. let data = {
  869. orderId: this.dataList.orderId
  870. }
  871. this.$Request.get(`/app/activity/suit-activity/${this.dataList.orderId}`, data).then((res) => {
  872. if (res.code == 0) {
  873. this.huoList = res.data
  874. // console.log(this.huodong)
  875. if (this.huodong) {
  876. // console.log(this.huodong,'有呢')
  877. let activityExists = this.huoList.some((item) => item.activityId === this.huodong.activityId)
  878. if (!activityExists) {
  879. this.huodong = ''
  880. if (this.orderType == 2) {
  881. this.totalPrice1 = parseFloat(this.totalPrice + this.paotuiMoney + this.dabaoMoney).toFixed(2)
  882. } else {
  883. this.totalPrice1 = parseFloat(this.totalPrice + this.dabaoMoney).toFixed(2)
  884. }
  885. let totalMoney = parseFloat(
  886. this.totalPrice1 - (this.huodong.discountAmount ? this.huodong.discountAmount : 0) - (this.coupon.money ? this.coupon.money : 0)
  887. ).toFixed(2)
  888. if (totalMoney <= 0) {
  889. this.totalPrice1 = 0.01
  890. } else {
  891. this.totalPrice1 = totalMoney
  892. }
  893. uni.showModal({
  894. title: '提示',
  895. content: '当前选择的优惠活动已过期,请重新选择',
  896. success: function (res) {
  897. if (res.confirm) {
  898. this.huodong = ''
  899. } else if (res.cancel) {
  900. this.huodong = ''
  901. }
  902. }
  903. })
  904. }
  905. }
  906. // 匹配出最优惠的活动
  907. if (this.huoList.length) {
  908. this.huodong = this.huoList.reduce((prev, current) => (prev.discountAmount > current.discountAmount ? prev : current))
  909. this.selctHuo(this.huodong)
  910. }
  911. // for(var i=0;i<this.huoList.length;i++){
  912. // if(this.huodong!=''&&this.huodong.activityId!=this.huoList[i].activityId){
  913. // console.log('优惠活动过期')
  914. // }
  915. // }
  916. // if(this.huoList.length==0){
  917. // this.huodong=''
  918. // }
  919. }
  920. })
  921. },
  922. //拼单支付成功取消订单
  923. cancelPinDan() {
  924. let that = this
  925. // if (that.orderId) {
  926. // let data = {
  927. // orderId: that.orderId
  928. // };
  929. // that.$Request.post('/app/order/deleteOrder', data).then(res => {
  930. // if (res.code == 0) {
  931. // uni.removeStorageSync('orderId');
  932. // }
  933. // });
  934. // }
  935. },
  936. // 商品列表
  937. getOrderList() {
  938. // 显示加载提示
  939. uni.showLoading({
  940. title: '加载中', // 加载提示文本
  941. mask: true // 是否显示透明蒙层,防止触摸穿透
  942. })
  943. this.paotuiMoney = 0
  944. this.totalPrice1 = 0
  945. if (this.status == 0) {
  946. console.log(6666)
  947. this.payContinue()
  948. return
  949. }
  950. let data = {
  951. shopId: this.shopId,
  952. status: 1,
  953. page: 1,
  954. limit: 1000
  955. // orderType: this.orderType
  956. }
  957. console.log(data)
  958. this.$Request.get('/app/order/selectAllOrderList', data).then((res) => {
  959. console.log(res)
  960. uni.hideLoading()
  961. if (res.code == 0 && res.data.pageUtils.list.length) {
  962. this.GoodsorderId = res.data.pageUtils.list[0].orderId
  963. this.dataList = res.data.pageUtils.list[0]
  964. if (this.dataList && this.dataList.orderGoodsList && this.dataList.orderGoodsList[0]) {
  965. this.dataList.orderGoodsList[0].forEach((res) => {
  966. res.goodsPicture = res.goodsPicture.split(',')
  967. this.dabaoMoney += res.goodsPack * res.goodsNum
  968. this.goodsMoney += res.goodsPrice * res.goodsNum
  969. this.goodsMoney = parseFloat(this.goodsMoney + this.dabaoMoney)
  970. })
  971. this.goodsList = this.dataList.orderGoodsList[0]
  972. }
  973. console.log(this.dataList, this.dabaoMoney, 'kkklll')
  974. if (this.ifPaotui == 1) {
  975. this.paotuiMoney = this.dataList.errandMoney
  976. } else if (this.ifPaotui == 0) {
  977. // 判断商品金额是否大于最低减免配送费金额
  978. console.log(this.goodsMoney, '商品总金额', res, this.dataList.exemptMinMoney)
  979. if (Number(this.goodsMoney) >= Number(this.dataList.exemptMinMoney)) {
  980. this.paotuiMoney = 0
  981. } else {
  982. this.paotuiMoney = this.dataList.errandMoney
  983. }
  984. }
  985. this.totalPrice = res.data.money
  986. if (this.orderType == 2) {
  987. this.totalPrice1 = parseFloat(parseFloat(this.totalPrice) + parseFloat(this.paotuiMoney) + parseFloat(this.dabaoMoney)).toFixed(2)
  988. } else {
  989. this.totalPrice1 = parseFloat(parseFloat(this.totalPrice) + parseFloat(this.dabaoMoney)).toFixed(2)
  990. }
  991. // console.log(this.dataList)
  992. this.getCouponList()
  993. this.getHuoList()
  994. this.detCoupon()
  995. this.getDistance()
  996. }
  997. // 加载提示关闭
  998. uni.hideLoading()
  999. })
  1000. },
  1001. payContinue() {
  1002. let data = {
  1003. orderId: this.orderId,
  1004. page: 1,
  1005. limit: 1000
  1006. }
  1007. console.log(data)
  1008. this.$Request.get('/app/order/selectOrder', data).then((res) => {
  1009. console.log(res)
  1010. uni.hideLoading()
  1011. if (res.code == 0 && res.data.pageUtils.list.length) {
  1012. this.GoodsorderId = res.data.pageUtils.list[0].orderId
  1013. this.dataList = res.data.pageUtils.list[0]
  1014. if (this.dataList && this.dataList.orderGoodsList && this.dataList.orderGoodsList[0]) {
  1015. this.dataList.orderGoodsList[0].forEach((res) => {
  1016. res.goodsPicture = res.goodsPicture.split(',')
  1017. this.dabaoMoney += res.goodsPack * res.goodsNum
  1018. this.goodsMoney += res.goodsPrice * res.goodsNum
  1019. this.goodsMoney = parseFloat(this.goodsMoney + this.dabaoMoney)
  1020. })
  1021. this.goodsList = this.dataList.orderGoodsList[0]
  1022. }
  1023. console.log(this.dataList, this.dabaoMoney, 'kkklll')
  1024. if (this.ifPaotui == 1) {
  1025. this.paotuiMoney = this.dataList.errandMoney
  1026. } else if (this.ifPaotui == 0) {
  1027. // 判断商品金额是否大于最低减免配送费金额
  1028. console.log(this.goodsMoney, '商品总金额', res, this.dataList.exemptMinMoney)
  1029. if (Number(this.goodsMoney) >= Number(this.dataList.exemptMinMoney)) {
  1030. this.paotuiMoney = 0
  1031. } else {
  1032. this.paotuiMoney = this.dataList.errandMoney
  1033. }
  1034. }
  1035. this.totalPrice = res.data.money
  1036. if (this.orderType == 2) {
  1037. this.totalPrice1 = parseFloat(parseFloat(this.totalPrice) + parseFloat(this.paotuiMoney) + parseFloat(this.dabaoMoney)).toFixed(2)
  1038. } else {
  1039. this.totalPrice1 = parseFloat(parseFloat(this.totalPrice) + parseFloat(this.dabaoMoney)).toFixed(2)
  1040. }
  1041. // console.log(this.dataList)
  1042. this.getCouponList()
  1043. this.getHuoList()
  1044. this.detCoupon()
  1045. this.getDistance()
  1046. }
  1047. // 加载提示关闭
  1048. uni.hideLoading()
  1049. })
  1050. },
  1051. selectWay(item) {
  1052. this.openWay = item.id
  1053. },
  1054. takeReark() {
  1055. let datas = {
  1056. orderId: this.GoodsorderId,
  1057. remark: this.remark
  1058. }
  1059. this.$Request.post('/app/order/updateOrdersRemark', datas).then((res) => {
  1060. if (res.code == 0) {
  1061. } else {
  1062. uni.showToast({
  1063. title: res.msg,
  1064. icon: 'none'
  1065. })
  1066. }
  1067. })
  1068. },
  1069. toSettlement_throttle: throttle(function () {
  1070. this.toSettlement()
  1071. }, 1000),
  1072. // 立即结算
  1073. toSettlement() {
  1074. if (this.isThrottle == false) {
  1075. return
  1076. }
  1077. let that = this
  1078. if (this.isTrue && this.orderType == 2) {
  1079. uni.showToast({
  1080. title: '超出配送范围',
  1081. icon: 'none'
  1082. })
  1083. reutrn
  1084. }
  1085. if (this.orderType == 2 && !this.address.addressId) {
  1086. uni.showToast({
  1087. title: '请选择收货地址',
  1088. icon: 'none'
  1089. })
  1090. return
  1091. }
  1092. if (this.remark) {
  1093. this.takeReark()
  1094. }
  1095. uni.showLoading({
  1096. title: '支付中...',
  1097. mask: true // 是否显示透明蒙层,防止触摸穿透
  1098. })
  1099. this.isThrottle = false
  1100. if (this.openWay == 1) {
  1101. //零钱支付
  1102. let data = {
  1103. userId: uni.getStorageSync('userId'),
  1104. type: 1, //支付方式 1表示微信支付、4或5表示支付宝支付
  1105. activityId: this.huodong ? this.huodong.activityId : '',
  1106. reservationFlag: this.reservationFlag, //是否预约单 1是、0否
  1107. expectDeliveryTime: this.expectDeliveryTime, //期待送达时间 yyyy-MM-dd HH:mm:ss
  1108. parentId: this.dataList.parentId,
  1109. couponId: this.coupon ? this.coupon.id : '',
  1110. addressId: this.address.addressId ? this.address.addressId : '',
  1111. orderType: this.orderType
  1112. }
  1113. console.log(data, 'l')
  1114. this.$Request.post('/app/wxPay/balanceOrder', data).then((res) => {
  1115. console.log(res, '结果')
  1116. if (res.code == 0) {
  1117. uni.hideLoading()
  1118. that.$queue.showToast('支付成功')
  1119. that.cancelPinDan()
  1120. setTimeout(function () {
  1121. that.isThrottle = true
  1122. uni.switchTab({
  1123. url: '/pages/order/index'
  1124. })
  1125. }, 1000)
  1126. } else {
  1127. that.$queue.showToast(res.msg)
  1128. that.isThrottle = true
  1129. }
  1130. })
  1131. } else if (this.openWay == 2) {
  1132. //微信支付
  1133. // #ifdef H5
  1134. let data = {
  1135. userId: uni.getStorageSync('userId'),
  1136. type: 1, //支付方式 1表示微信支付、4或5表示支付宝支付
  1137. activityId: this.huodong ? this.huodong.activityId : '',
  1138. reservationFlag: this.reservationFlag, //是否预约单 1是、0否
  1139. expectDeliveryTime: this.expectDeliveryTime, //期待送达时间 yyyy-MM-dd HH:mm:ss
  1140. parentId: this.dataList.parentId,
  1141. couponId: this.coupon ? this.coupon.id : '',
  1142. addressId: this.address.addressId ? this.address.addressId : '',
  1143. orderType: this.orderType,
  1144. type: 2
  1145. }
  1146. this.$Request.post('/app/wxPay/wxPayJsApiOrder', data).then((res) => {
  1147. uni.hideLoading()
  1148. if (res.code == 0) {
  1149. this.callPay(res.data)
  1150. } else {
  1151. uni.showToast({
  1152. title: res.msg,
  1153. icon: 'none'
  1154. })
  1155. this.isThrottle = true
  1156. }
  1157. })
  1158. // #endif
  1159. // #ifdef MP-WEIXIN
  1160. let data = {
  1161. userId: uni.getStorageSync('userId'),
  1162. type: 4, //支付方式 1表示微信支付、4或5表示支付宝支付
  1163. activityId: this.huodong ? this.huodong.activityId : '',
  1164. reservationFlag: this.reservationFlag, //是否预约单 1是、0否
  1165. expectDeliveryTime: this.expectDeliveryTime, //期待送达时间 yyyy-MM-dd HH:mm:ss
  1166. parentId: this.dataList.parentId,
  1167. couponId: this.coupon ? this.coupon.id : '',
  1168. addressId: this.address.addressId ? this.address.addressId : '',
  1169. orderType: this.orderType,
  1170. type: 3
  1171. }
  1172. this.$Request.post('/app/wxPay/wxPayJsApiOrder', data).then((res) => {
  1173. // uni.hideLoading();
  1174. if (res.code == 0) {
  1175. uni.requestPayment({
  1176. provider: 'wxpay',
  1177. timeStamp: res.data.timestamp,
  1178. nonceStr: res.data.noncestr,
  1179. package: res.data.package,
  1180. signType: res.data.signType,
  1181. paySign: res.data.sign,
  1182. success: function (suc) {
  1183. that.cancelPinDan()
  1184. uni.hideLoading()
  1185. that.$queue.showToast('支付成功')
  1186. setTimeout(function () {
  1187. that.isThrottle = true
  1188. uni.switchTab({
  1189. url: '/pages/order/index'
  1190. })
  1191. }, 1000)
  1192. },
  1193. fail: function (err) {
  1194. console.log('fail:' + JSON.stringify(err))
  1195. that.isThrottle = true
  1196. uni.setStorageSync('isClear', true)
  1197. uni.showToast({
  1198. title: '支付失败',
  1199. icon: 'none',
  1200. mask: true
  1201. })
  1202. setTimeout(() => {
  1203. uni.reLaunch({
  1204. url: '/pages/order/index'
  1205. })
  1206. }, 1500)
  1207. }
  1208. })
  1209. } else {
  1210. uni.showToast({
  1211. title: res.msg,
  1212. icon: 'none'
  1213. })
  1214. that.isThrottle = true
  1215. }
  1216. })
  1217. // #endif
  1218. // #ifdef APP
  1219. let data = {
  1220. type: 1,
  1221. parentId: this.dataList.parentId,
  1222. couponId: this.coupon ? this.coupon.id : '',
  1223. addressId: this.address.addressId ? this.address.addressId : '',
  1224. orderType: this.orderType
  1225. }
  1226. this.$Request.post('/app/wxPay/wxPayJsApiOrder', data).then((res) => {
  1227. console.log(res)
  1228. this.showpay = false
  1229. if (res.code == 0) {
  1230. this.isCheckPay(res.code, 'wxpay', JSON.stringify(res.data))
  1231. } else {
  1232. that.isThrottle = true
  1233. }
  1234. })
  1235. // #endif
  1236. } else if (this.openWay == 3) {
  1237. // #ifdef H5
  1238. let data = {
  1239. type: 5,
  1240. parentId: this.dataList.parentId,
  1241. couponId: this.coupon ? this.coupon.id : '',
  1242. addressId: this.address.addressId ? this.address.addressId : '',
  1243. orderType: this.orderType
  1244. }
  1245. this.$Request.post('/app/wxPay/wxPayJsApiOrder', data).then((res) => {
  1246. this.showpay = false
  1247. this.isThrottle = true
  1248. const div = document.createElement('div')
  1249. div.innerHTML = res.data //此处form就是后台返回接收到的数据
  1250. document.body.appendChild(div)
  1251. document.forms[0].submit()
  1252. })
  1253. // #endif
  1254. // #ifdef APP
  1255. let data = {
  1256. type: 4,
  1257. parentId: this.dataList.parentId,
  1258. couponId: this.coupon ? this.coupon.id : '',
  1259. addressId: this.address.addressId ? this.address.addressId : '',
  1260. orderType: this.orderType
  1261. }
  1262. this.$Request.post('/app/wxPay/wxPayJsApiOrder', data).then((res) => {
  1263. this.showpay = false
  1264. this.setPayment('alipay', res.data)
  1265. })
  1266. // #endif
  1267. }
  1268. },
  1269. callPay: function (response) {
  1270. if (typeof WeixinJSBridge === 'undefined') {
  1271. if (document.addEventListener) {
  1272. document.addEventListener('WeixinJSBridgeReady', this.onBridgeReady(response), false)
  1273. } else if (document.attachEvent) {
  1274. document.attachEvent('WeixinJSBridgeReady', this.onBridgeReady(response))
  1275. document.attachEvent('onWeixinJSBridgeReady', this.onBridgeReady(response))
  1276. }
  1277. } else {
  1278. this.onBridgeReady(response)
  1279. }
  1280. },
  1281. onBridgeReady: function (response) {
  1282. let that = this
  1283. if (!response.package) {
  1284. return
  1285. }
  1286. WeixinJSBridge.invoke(
  1287. 'getBrandWCPayRequest',
  1288. {
  1289. appId: response.appid, //公众号名称,由商户传入
  1290. timeStamp: response.timestamp, //时间戳,自1970年以来的秒数
  1291. nonceStr: response.noncestr, //随机串
  1292. package: response.package,
  1293. signType: response.signType, //微信签名方式:
  1294. paySign: response.sign //微信签名
  1295. },
  1296. function (res) {
  1297. if (res.err_msg === 'get_brand_wcpay_request:ok') {
  1298. // 使用以上方式判断前端返回,微信团队郑重提示:
  1299. //res.err_msg将在用户支付成功后返回ok,但并不保证它绝对可靠。
  1300. that.cancelPinDan()
  1301. that.$queue.showToast('支付成功')
  1302. setTimeout(function () {
  1303. uni.switchTab({
  1304. url: '/pages/order/index'
  1305. })
  1306. that.isThrottle = true
  1307. }, 1000)
  1308. } else {
  1309. uni.hideLoading()
  1310. that.isThrottle = true
  1311. }
  1312. WeixinJSBridge.log(response.err_msg)
  1313. }
  1314. )
  1315. },
  1316. isCheckPay(code, name, order) {
  1317. if (code == 0) {
  1318. console.log('999999999999')
  1319. this.setPayment(name, order)
  1320. } else {
  1321. uni.hideLoading()
  1322. uni.showToast({
  1323. title: '支付信息有误'
  1324. })
  1325. this.isThrottle = true
  1326. }
  1327. },
  1328. setPayment(name, order) {
  1329. let that = this
  1330. console.log(777777777, name, order)
  1331. uni.requestPayment({
  1332. provider: name,
  1333. orderInfo: order, //微信、支付宝订单数据
  1334. success: function (res) {
  1335. uni.hideLoading()
  1336. that.cancelPinDan()
  1337. uni.showLoading({
  1338. title: '支付成功',
  1339. icon: 'none'
  1340. })
  1341. setTimeout(function () {
  1342. that.isThrottle = true
  1343. uni.navigateBack()
  1344. }, 1000)
  1345. },
  1346. fail: function (err) {
  1347. uni.hideLoading()
  1348. that.isThrottle = true
  1349. },
  1350. complete() {
  1351. that.isThrottle = true
  1352. uni.hideLoading()
  1353. }
  1354. })
  1355. },
  1356. // 获取选择的地址
  1357. getAddressDet(e) {
  1358. let data = {
  1359. addressId: e
  1360. }
  1361. this.$Request.get('/app/address/selectAddressById', data).then((res) => {
  1362. if (res.code == 0) {
  1363. this.address = res.data
  1364. if (JSON.stringify(this.address) != '{}') {
  1365. this.getDistance()
  1366. }
  1367. uni.removeStorageSync('addressId')
  1368. }
  1369. })
  1370. },
  1371. // 获取地址列表
  1372. getAddressList() {
  1373. let that = this
  1374. let data = {
  1375. page: 1,
  1376. limit: 100
  1377. }
  1378. that.$Request.get('/app/address/selectAddressList', data).then((res) => {
  1379. if (res.code == 0) {
  1380. that.address = res.data.list[0] ? res.data.list[0] : {}
  1381. res.data.list.forEach((ret) => {
  1382. if (ret.addressDefault == 1) {
  1383. that.address = ret
  1384. }
  1385. })
  1386. if (JSON.stringify(this.address) != '{}') {
  1387. this.getDistance()
  1388. }
  1389. }
  1390. })
  1391. },
  1392. goAddress() {
  1393. uni.navigateTo({
  1394. url: '/my/address/index?add=1'
  1395. })
  1396. },
  1397. // 点击调起地图查看位置
  1398. goMap() {
  1399. // let that = this
  1400. // let plugin = requirePlugin('routePlan');
  1401. // let key = 'A3RBZ-23MHW-PTPR5-RLCER-UJTXQ-JIF2G'; //使用在腾讯位置服务申请的key
  1402. // let referer = that.dataList.shopName; //调用插件的app的名称
  1403. // let endPoint = JSON.stringify({ //终点
  1404. // 'name': that.dataList.shopName,
  1405. // 'latitude': that.dataList.shopLat,
  1406. // 'longitude': that.dataList.shopLng,
  1407. // });
  1408. // wx.navigateTo({
  1409. // url: 'plugin://routePlan/index?key=' + key + '&referer=' + referer + '&endPoint=' + endPoint
  1410. // });
  1411. let that = this
  1412. let lati = parseFloat(that.dataList.shopLat)
  1413. let longi = parseFloat(that.dataList.shopLng)
  1414. uni.authorize({
  1415. scope: 'scope.userLocation',
  1416. success(res) {
  1417. uni.openLocation({
  1418. name: that.dataList.shopName,
  1419. latitude: lati,
  1420. longitude: longi,
  1421. success: function () {}
  1422. })
  1423. },
  1424. fail(err) {}
  1425. })
  1426. },
  1427. // 打电话
  1428. call() {
  1429. uni.makePhoneCall({
  1430. phoneNumber: this.dataList.shopPhone
  1431. })
  1432. }
  1433. }
  1434. }
  1435. </script>
  1436. <style scoped>
  1437. .hintPopul {
  1438. width: 100%;
  1439. height: 100vh;
  1440. position: fixed;
  1441. top: 0;
  1442. background: rgba(0, 0, 0, 0.4);
  1443. z-index: 999;
  1444. }
  1445. .content_ {
  1446. position: absolute;
  1447. left: 0;
  1448. right: 0;
  1449. top: 0;
  1450. bottom: 0;
  1451. margin: auto;
  1452. text-align: center;
  1453. width: 500rpx;
  1454. height: 400rpx;
  1455. border-radius: 20rpx;
  1456. background-color: #fff;
  1457. padding-top: 120rpx;
  1458. }
  1459. .content_ image {
  1460. position: absolute;
  1461. top: -50rpx;
  1462. left: 0;
  1463. right: 0;
  1464. margin: auto;
  1465. }
  1466. .hintText {
  1467. font-size: 30rpx;
  1468. }
  1469. .Btns {
  1470. width: 460rpx;
  1471. height: 60rpx;
  1472. line-height: 60rpx;
  1473. text-align: center;
  1474. background: #fcd202;
  1475. font-size: 28rpx;
  1476. border: 2rpx solid #fcd202;
  1477. color: #333333;
  1478. border-radius: 50rpx;
  1479. font-weight: 700;
  1480. margin: auto;
  1481. }
  1482. .goods_address {
  1483. width: 94%;
  1484. background: #ffffff;
  1485. height: 120rpx;
  1486. margin: 20rpx auto 0;
  1487. border-radius: 18rpx;
  1488. }
  1489. .address_box {
  1490. width: 90%;
  1491. margin: 0 auto;
  1492. height: 120rpx;
  1493. display: flex;
  1494. line-height: 120rpx;
  1495. }
  1496. .address_name {
  1497. flex: 1;
  1498. font-size: 30rpx;
  1499. }
  1500. .address_image {
  1501. /* flex: 1; */
  1502. display: flex;
  1503. justify-content: flex-end;
  1504. align-items: center;
  1505. }
  1506. .address_image image {
  1507. width: 25rpx;
  1508. height: 40rpx;
  1509. }
  1510. .songda_image image {
  1511. width: 20rpx;
  1512. height: 30rpx;
  1513. margin-left: 20rpx;
  1514. }
  1515. /* 地址 */
  1516. .address {
  1517. width: 88%;
  1518. margin: 3% auto;
  1519. padding: 3%;
  1520. display: flex;
  1521. background-color: #ffffff;
  1522. border-radius: 18rpx;
  1523. }
  1524. .adderss_le {
  1525. width: 90%;
  1526. line-height: 1.5;
  1527. }
  1528. .adderss_le_text {
  1529. font-size: 30rpx;
  1530. font-weight: bold;
  1531. color: #333333;
  1532. }
  1533. .adderss_le_text2 {
  1534. font-size: 24rpx;
  1535. font-weight: 500;
  1536. color: #999999;
  1537. display: flex;
  1538. }
  1539. .adderss_le_text2 view {
  1540. margin-left: 2%;
  1541. }
  1542. .adderss_le_text2 view:first-child {
  1543. margin-left: 0;
  1544. }
  1545. .adderss_ri {
  1546. width: 10%;
  1547. text-align: right;
  1548. line-height: 3;
  1549. }
  1550. .adderss_ri image {
  1551. width: 18rpx;
  1552. height: 30rpx;
  1553. }
  1554. /* 商品 */
  1555. .food {
  1556. width: 94%;
  1557. margin: 3% auto;
  1558. padding: 3%;
  1559. background-color: #ffffff;
  1560. border-radius: 18rpx;
  1561. }
  1562. .tosend_header_food {
  1563. width: 100%;
  1564. display: flex;
  1565. margin-top: 3%;
  1566. }
  1567. .tosend_header_food_le {
  1568. width: 15%;
  1569. }
  1570. .tosend_header_food_le image {
  1571. width: 110rpx;
  1572. height: 110rpx;
  1573. border-radius: 10rpx;
  1574. }
  1575. .tosend_header_food_ce {
  1576. margin: 0 0 0 4%;
  1577. width: 57%;
  1578. }
  1579. .tosend_header_food_ri {
  1580. text-align: right;
  1581. width: 25%;
  1582. }
  1583. .tosend_header_food_text {
  1584. font-size: 34rpx;
  1585. font-weight: 500;
  1586. color: #333333;
  1587. line-height: 1.8;
  1588. }
  1589. .tosend_header_food_text text {
  1590. font-size: 25rpx;
  1591. }
  1592. .tosend_header_food_text2 {
  1593. font-size: 28rpx;
  1594. font-weight: 500;
  1595. color: #999999;
  1596. }
  1597. .do_top {
  1598. padding-top: 3%;
  1599. }
  1600. .do_bot {
  1601. padding-bottom: 3%;
  1602. border-bottom: 2rpx solid #e6e6e6;
  1603. }
  1604. .tosend_header_do {
  1605. width: 100%;
  1606. color: #333333;
  1607. font-size: 30rpx;
  1608. display: flex;
  1609. margin-top: 20rpx;
  1610. line-height: 1.5;
  1611. }
  1612. .tosend_header_do view {
  1613. /* flex: 1; */
  1614. }
  1615. .tosend_header_do_ri {
  1616. text-align: right;
  1617. }
  1618. .tosend_header_do_le2 {
  1619. font-family: PingFang SC;
  1620. font-weight: 500;
  1621. color: #999999;
  1622. padding-top: 1.5%;
  1623. }
  1624. .tosend_header_do_ri2 {
  1625. text-align: right;
  1626. color: #ea0000;
  1627. font-size: 40rpx;
  1628. }
  1629. .tosend_header_do_ri2 text {
  1630. font-size: 30rpx;
  1631. }
  1632. /* 支付 */
  1633. /* .payment_all{
  1634. width: 88%;margin: 3% auto;padding: 3%;background-color: #FFFFFF;
  1635. border-radius: 18rpx;
  1636. }
  1637. .payment{
  1638. width: 100%;display: flex;margin-top: 3%;
  1639. }
  1640. .payment_le{
  1641. width: 13%;
  1642. }
  1643. .payment_le image{
  1644. width: 60rpx;height: 60rpx;
  1645. }
  1646. .payment_ce{
  1647. width: 52%;
  1648. font-size: 30rpx;
  1649. font-weight: bold;
  1650. color: #333333;line-height: 60rpx;
  1651. }
  1652. .payment_ri{
  1653. width: 35%;text-align: right;line-height: 60rpx;
  1654. } */
  1655. /* 结算 */
  1656. .goorder {
  1657. width: 100%;
  1658. padding: 2% 3%;
  1659. position: fixed;
  1660. bottom: 0;
  1661. background-color: #ffffff;
  1662. z-index: 999;
  1663. }
  1664. .goorder_but {
  1665. width: 100%;
  1666. line-height: 3.5;
  1667. text-align: center;
  1668. background: #fcd202;
  1669. border-radius: 36rpx;
  1670. font-weight: 700;
  1671. }
  1672. .goorder_but_ {
  1673. opacity: 0.5;
  1674. }
  1675. .bg {
  1676. background-color: #ffffff;
  1677. }
  1678. .tabBtn {
  1679. /* background-color: #f6f6fa; */
  1680. height: 60rpx;
  1681. line-height: 60rpx;
  1682. color: #999999;
  1683. font-size: 38rpx;
  1684. }
  1685. .active {
  1686. /* width: 82rpx; */
  1687. height: 6rpx;
  1688. background: #fcd202;
  1689. /* position: relative;
  1690. top: -20rpx; */
  1691. z-index: 9;
  1692. }
  1693. </style>