payOrder.vue 45 KB

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