confirmOrder.vue 50 KB

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