confirmOrder.vue 50 KB

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