confirmOrder.vue 49 KB

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