confirmOrder.vue 50 KB

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