payOrder.vue 49 KB

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