confirmOrder.vue 51 KB

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