confirmOrder.vue 47 KB

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