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