confirmOrder.vue 47 KB

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