payOrder.vue 47 KB

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