payOrder.vue 47 KB

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