payOrder.vue 49 KB

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