payOrder.vue 47 KB

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