payOrder.vue 49 KB

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