confirmOrder.vue 47 KB

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