payOrder.vue 50 KB

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