payOrder.vue 45 KB

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