payOrder.vue 51 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835
  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. if (this.orderType == 2) {
  771. this.totalPrice1 = parseFloat(this.totalPrice + this.paotuiMoney + this.dabaoMoney + this.address.insideDeliveryFee).toFixed(2)
  772. } else {
  773. this.totalPrice1 = parseFloat(this.totalPrice + this.dabaoMoney).toFixed(2)
  774. }
  775. let totalMoney = parseFloat(
  776. 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)
  777. )
  778. if (totalMoney <= 0) {
  779. this.totalPrice1 = 0.01
  780. } else {
  781. this.totalPrice1 = totalMoney
  782. }
  783. }
  784. if (this.huodong) {
  785. if (this.orderType == 2) {
  786. this.totalPrice1 = parseFloat(this.totalPrice + this.paotuiMoney + this.dabaoMoney + this.address.insideDeliveryFee).toFixed(2)
  787. } else {
  788. this.totalPrice1 = parseFloat(this.totalPrice + this.dabaoMoney).toFixed(2)
  789. }
  790. let totalMoney = parseFloat(
  791. 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)
  792. )
  793. if (totalMoney <= 0) {
  794. this.totalPrice1 = 0.01
  795. } else {
  796. this.totalPrice1 = totalMoney
  797. }
  798. }if (this.Vipmoney.canReduceFlag=='1') {
  799. if (this.orderType == 2) {
  800. this.totalPrice1 = parseFloat(this.totalPrice + this.paotuiMoney + this.dabaoMoney + this.address.insideDeliveryFee).toFixed(2)
  801. } else {
  802. this.totalPrice1 = parseFloat(this.totalPrice + this.dabaoMoney).toFixed(2)
  803. }
  804. let totalMoney = parseFloat(
  805. 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)
  806. )
  807. if (totalMoney <= 0) {
  808. this.totalPrice1 = 0.01
  809. } else {
  810. this.totalPrice1 = totalMoney
  811. }
  812. }
  813. },
  814. // 删除优惠券
  815. detCoupon() {
  816. let data = {
  817. orderId: this.dataList.orderId
  818. }
  819. this.$Request.post('/app/order/deleteCouponByOrderId', data).then((res) => {
  820. if (res.code == 0) {
  821. }
  822. })
  823. },
  824. // 选择优惠券
  825. selCoupon(item) {
  826. this.coupon = item
  827. if (this.orderType == 2) {
  828. this.totalPrice1 = parseFloat(this.totalPrice + this.paotuiMoney + this.dabaoMoney + this.address.insideDeliveryFee).toFixed(2)
  829. } else {
  830. this.totalPrice1 = parseFloat(this.totalPrice + this.dabaoMoney).toFixed(2)
  831. }
  832. 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)
  833. if (totalMoney <= 0) {
  834. this.totalPrice1 = 0.01
  835. } else {
  836. this.totalPrice1 = totalMoney
  837. }
  838. let data = {
  839. parentId: this.dataList.parentId,
  840. couponId: this.coupon ? this.coupon.id : ''
  841. }
  842. this.$Request.post('/app/order/employCoupon', data).then((res) => {
  843. if (res.code == 0) {
  844. this.show = false
  845. } else {
  846. this.$queue.showToast(res.msg)
  847. }
  848. })
  849. },
  850. //选择活动activityId
  851. selctHuo(item) {
  852. this.huodong = item
  853. if (this.orderType == 2) {
  854. this.totalPrice1 = parseFloat(this.totalPrice + this.paotuiMoney + this.dabaoMoney + this.address.insideDeliveryFee).toFixed(2)
  855. } else {
  856. this.totalPrice1 = parseFloat(this.totalPrice + this.dabaoMoney).toFixed(2)
  857. }
  858. let totalMoney = parseFloat(this.totalPrice1 - (this.huodong.discountAmount ? this.huodong.discountAmount : 0)-(this.Vipmoney.reduceAmount?this.Vipmoney.reduceAmount:0)).toFixed(2)
  859. if (totalMoney <= 0) {
  860. this.totalPrice1 = 0.01
  861. } else {
  862. this.totalPrice1 = totalMoney
  863. }
  864. this.youhui = false
  865. },
  866. // 获取优惠券列表
  867. getCouponList() {
  868. console.log(this.totalPrice)
  869. console.log(this.dataList.packMoney)
  870. let data = {
  871. shopId: this.dataList.shopId,
  872. page: 1,
  873. limit: 20,
  874. minMoney:
  875. this.orderType == 2 ? parseFloat(this.totalPrice * 1).toFixed(2) * 1 + this.paotuiMoney * 1 + this.dabaoMoney * 1 : parseFloat(this.totalPrice * 1).toFixed(2)
  876. }
  877. this.$Request.get('/app/coupon/selectUserCouponList', data).then((res) => {
  878. if (res.code == 0) {
  879. this.couponList = res.data.list
  880. if (this.coupon) {
  881. let activityExists = this.couponList.some((item) => item.couponId === this.coupon.couponId)
  882. if (!activityExists) {
  883. this.coupon = ''
  884. if (this.orderType == 2) {
  885. this.totalPrice1 = parseFloat(this.totalPrice + this.paotuiMoney + this.dabaoMoney + this.address.insideDeliveryFee).toFixed(2)
  886. } else {
  887. this.totalPrice1 = parseFloat(this.totalPrice + this.dabaoMoney).toFixed(2)
  888. }
  889. let totalMoney = parseFloat(
  890. this.totalPrice1 - (this.huodong.discountAmount ? this.huodong.discountAmount : 0) - (this.coupon.money ? this.coupon.money : 0)-(this.Vipmoney.reduceAmount?this.Vipmoney.reduceAmount:0)
  891. ).toFixed(2)
  892. if (totalMoney <= 0) {
  893. this.totalPrice1 = 0.01
  894. } else {
  895. this.totalPrice1 = totalMoney
  896. }
  897. uni.showModal({
  898. title: '提示',
  899. content: '当前选择的优惠券已过期,请重新选择',
  900. success: function (res) {
  901. if (res.confirm) {
  902. this.coupon = ''
  903. } else if (res.cancel) {
  904. this.coupon = ''
  905. }
  906. }
  907. })
  908. }
  909. }
  910. }
  911. })
  912. },
  913. // 优惠活动列表
  914. getHuoList() {
  915. let data = {
  916. orderId: this.dataList.orderId
  917. }
  918. this.$Request.get(`/app/activity/suit-activity/${this.dataList.orderId}`, data).then((res) => {
  919. if (res.code == 0) {
  920. this.huoList = res.data
  921. if (this.huodong) {
  922. // console.log(this.huodong,'有呢')
  923. let activityExists = this.huoList.some((item) => item.activityId === this.huodong.activityId)
  924. if (!activityExists) {
  925. this.huodong = ''
  926. if (this.orderType == 2) {
  927. this.totalPrice1 = parseFloat(this.totalPrice + this.paotuiMoney + this.dabaoMoney + this.address.insideDeliveryFee).toFixed(2)
  928. } else {
  929. this.totalPrice1 = parseFloat(this.totalPrice + this.dabaoMoney).toFixed(2)
  930. }
  931. let totalMoney = parseFloat(
  932. this.totalPrice1 - (this.huodong.discountAmount ? this.huodong.discountAmount : 0) - (this.coupon.money ? this.coupon.money : 0)-(this.Vipmoney.reduceAmount?this.Vipmoney.reduceAmount:0)
  933. ).toFixed(2)
  934. if (totalMoney <= 0) {
  935. this.totalPrice1 = 0.01
  936. } else {
  937. this.totalPrice1 = totalMoney
  938. }
  939. uni.showModal({
  940. title: '提示',
  941. content: '当前选择的优惠活动已过期,请重新选择',
  942. success: function (res) {
  943. if (res.confirm) {
  944. this.huodong = ''
  945. } else if (res.cancel) {
  946. this.huodong = ''
  947. }
  948. }
  949. })
  950. }
  951. }
  952. // 匹配出最优惠的活动
  953. if (this.huoList.length) {
  954. this.huodong = this.huoList.reduce((prev, current) => (prev.discountAmount > current.discountAmount ? prev : current))
  955. this.selctHuo(this.huodong)
  956. }
  957. }
  958. })
  959. },
  960. // 获取订单信息
  961. getOrderList() {
  962. this.paotuiMoney = 0
  963. this.totalPrice1 = 0
  964. let data = {
  965. orderId: this.orderId
  966. }
  967. this.$Request.get('/app/order/selectBuyGoods', data).then((res) => {
  968. console.log(res, '666')
  969. uni.hideLoading()
  970. if (res.code == 0) {
  971. this.dataList = res.data
  972. this.GoodsorderId = res.data.orderId
  973. // this.getShopDet(res.data.shopId)
  974. // this.dataList.orderGoodsList[0].goodsPicture = this.dataList.orderGoodsList[0].goodsPicture.split(',')
  975. // console.log(this.dataList.orderGoodsList)
  976. if (this.dataList) {
  977. this.dabaoMoney = 0
  978. this.dataList.orderGoodsList.forEach((res) => {
  979. res.goodsPicture = res.goodsPicture.split(',')
  980. this.dabaoMoney += res.goodsPack * res.goodsNum
  981. this.goodsMoney += res.goodsPrice * res.goodsNum
  982. this.goodsMoney = parseFloat(this.goodsMoney + this.dabaoMoney)
  983. })
  984. }
  985. console.log(this.ifPaotui, 'this.ifPaotui')
  986. if (this.ifPaotui == 1) {
  987. this.paotuiMoney = this.dataList.errandMoney
  988. } else if (this.ifPaotui == 0) {
  989. // 判断商品金额是否大于最低减免配送费金额
  990. if (Number(this.goodsMoney) >= Number(this.dataList.exemptMinMoney)) {
  991. console.log('跑腿费')
  992. this.paotuiMoney = 0
  993. } else {
  994. this.paotuiMoney = this.dataList.errandMoney
  995. }
  996. }
  997. this.totalPrice = res.data.payMoney * 1
  998. console.log(this.dabaoMoney, '打包')
  999. console.log(this.paotuiMoney, '跑腿')
  1000. if (this.orderType == 2) {
  1001. this.totalPrice1 = parseFloat(this.totalPrice + this.paotuiMoney + this.dabaoMoney + this.address.insideDeliveryFee).toFixed(2)
  1002. } else {
  1003. this.totalPrice1 = this.totalPrice + this.dabaoMoney
  1004. }
  1005. let totalMoney = parseFloat(
  1006. this.totalPrice1 - (this.huodong.discountAmount ? this.huodong.discountAmount : 0) - (this.coupon.money ? this.coupon.money : 0)-(this.Vipmoney.reduceAmount?this.Vipmoney.reduceAmount:0)
  1007. ).toFixed(2)
  1008. if (totalMoney <= 0) {
  1009. this.totalPrice1 = 0.01
  1010. } else {
  1011. this.totalPrice1 = totalMoney
  1012. }
  1013. console.log(this.dataList)
  1014. this.getCouponList()
  1015. this.getHuoList()
  1016. this.detCoupon()
  1017. this.getDistance()
  1018. }
  1019. })
  1020. },
  1021. selectWay: function (item) {
  1022. this.openWay = item.id
  1023. },
  1024. takeReark() {
  1025. let datas = {
  1026. orderId: this.GoodsorderId,
  1027. remark: this.remark
  1028. }
  1029. this.$Request.post('/app/order/updateOrdersRemark', datas).then((res) => {
  1030. // uni.hideLoading();
  1031. if (res.code == 0) {
  1032. } else {
  1033. uni.showToast({
  1034. title: res.msg,
  1035. icon: 'none'
  1036. })
  1037. }
  1038. })
  1039. },
  1040. // 立即结算
  1041. toSettlement() {
  1042. if (this.isThrottle == false) {
  1043. return
  1044. }
  1045. if (this.isTrue && this.orderType == 2) {
  1046. uni.showToast({
  1047. title: '超出配送范围',
  1048. icon: 'none'
  1049. })
  1050. reutrn
  1051. }
  1052. if (this.orderType == 2 && !this.address.addressId) {
  1053. uni.showToast({
  1054. title: '请选择收货地址',
  1055. icon: 'none'
  1056. })
  1057. return
  1058. }
  1059. if (this.remark) {
  1060. this.takeReark()
  1061. }
  1062. uni.showLoading({
  1063. title: '支付中...',
  1064. mask: true // 是否显示透明蒙层,防止触摸穿透
  1065. })
  1066. this.isThrottle = false
  1067. if (this.openWay == 1) {
  1068. let data = {
  1069. userId: uni.getStorageSync('userId'),
  1070. type: 1, //支付方式 1表示微信支付、4或5表示支付宝支付
  1071. activityId: this.huodong ? this.huodong.activityId : '',
  1072. reservationFlag: this.reservationFlag, //是否预约单 1是、0否
  1073. expectDeliveryTime: this.expectDeliveryTime, //期待送达时间 yyyy-MM-dd HH:mm:ss
  1074. parentId: this.dataList.parentId,
  1075. couponId: this.coupon ? this.coupon.id : '',
  1076. addressId: this.address.addressId ? this.address.addressId : '',
  1077. orderType: this.orderType
  1078. }
  1079. this.$Request.post('/app/wxPay/balanceOrder', data).then((res) => {
  1080. if (res.code == 0) {
  1081. uni.hideLoading()
  1082. this.$queue.showToast('支付成功')
  1083. setTimeout(() => {
  1084. this.isThrottle = true
  1085. uni.switchTab({
  1086. url: '/pages/order/index'
  1087. })
  1088. }, 1000)
  1089. } else {
  1090. this.isThrottle = true
  1091. this.$queue.showToast(res.msg)
  1092. }
  1093. })
  1094. } else if (this.openWay == 2) {
  1095. // #ifdef H5
  1096. let data = {
  1097. userId: uni.getStorageSync('userId'),
  1098. type: 1, //支付方式 1表示微信支付、4或5表示支付宝支付
  1099. activityId: this.huodong ? this.huodong.activityId : '',
  1100. reservationFlag: this.reservationFlag, //是否预约单 1是、0否
  1101. expectDeliveryTime: this.expectDeliveryTime, //期待送达时间 yyyy-MM-dd HH:mm:ss
  1102. parentId: this.dataList.parentId,
  1103. couponId: this.coupon ? this.coupon.id : '',
  1104. addressId: this.address.addressId ? this.address.addressId : '',
  1105. orderType: this.orderType,
  1106. type: 2
  1107. }
  1108. this.$Request.post('/app/wxPay/wxPayJsApiOrder', data).then((res) => {
  1109. if (res.code == 0) {
  1110. this.callPay(res.data)
  1111. } else {
  1112. this.isThrottle = true
  1113. uni.showToast({
  1114. title: res.msg,
  1115. icon: 'none'
  1116. })
  1117. }
  1118. })
  1119. // #endif
  1120. // #ifdef MP-WEIXIN
  1121. this.$Request.get('/app/new-pay/enable-new-pay').then((res) => {
  1122. console.log(res, '666')
  1123. if (res.code == 0) {
  1124. let data = {
  1125. userId: uni.getStorageSync('userId'),
  1126. // type: 4, //支付方式 1表示微信支付、4或5表示支付宝支付
  1127. activityId: this.huodong ? this.huodong.activityId : '',
  1128. reservationFlag: this.reservationFlag, //是否预约单 1是、0否
  1129. expectDeliveryTime: this.expectDeliveryTime, //期待送达时间 yyyy-MM-dd HH:mm:ss
  1130. parentId: this.dataList.parentId,
  1131. couponId: this.coupon ? this.coupon.id : '',
  1132. addressId: this.address.addressId ? this.address.addressId : '',
  1133. orderType: this.orderType,
  1134. type: res.enable ? 1 : 3
  1135. }
  1136. console.log(data)
  1137. if (res.enable) {
  1138. console.log('xin')
  1139. this.newPay(data)
  1140. } else {
  1141. console.log('jiu')
  1142. this.oldPay(data)
  1143. }
  1144. }
  1145. })
  1146. // #endif
  1147. // #ifdef APP
  1148. let data = {
  1149. type: 1,
  1150. parentId: this.dataList.parentId,
  1151. couponId: this.coupon ? this.coupon.id : '',
  1152. addressId: this.address.addressId ? this.address.addressId : '',
  1153. orderType: this.orderType
  1154. }
  1155. this.$Request.post('/app/wxPay/wxPayJsApiOrder', data).then((res) => {
  1156. console.log(res)
  1157. this.showpay = false
  1158. if (res.code == 0) {
  1159. this.isCheckPay(res.code, 'wxpay', JSON.stringify(res.data))
  1160. } else {
  1161. this.isThrottle = true
  1162. }
  1163. })
  1164. // #endif
  1165. } else if (this.openWay == 3) {
  1166. // #ifdef H5
  1167. let data = {
  1168. type: 5,
  1169. parentId: this.dataList.parentId,
  1170. couponId: this.coupon ? this.coupon.id : '',
  1171. addressId: this.address.addressId ? this.address.addressId : '',
  1172. orderType: this.orderType
  1173. }
  1174. this.$Request.post('/app/wxPay/wxPayJsApiOrder', data).then((res) => {
  1175. this.showpay = false
  1176. this.isThrottle = true
  1177. const div = document.createElement('div')
  1178. div.innerHTML = res.data //此处form就是后台返回接收到的数据
  1179. document.body.appendChild(div)
  1180. document.forms[0].submit()
  1181. })
  1182. // #endif
  1183. // #ifdef APP-PLUS
  1184. let data = {
  1185. type: 4,
  1186. parentId: this.dataList.parentId,
  1187. couponId: this.coupon ? this.coupon.id : '',
  1188. addressId: this.address.addressId ? this.address.addressId : '',
  1189. orderType: this.orderType
  1190. }
  1191. this.$Request.post('/app/wxPay/wxPayJsApiOrder', data).then((res) => {
  1192. this.showpay = false
  1193. this.setPayment('alipay', res.data)
  1194. })
  1195. // #endif
  1196. }
  1197. },
  1198. newPay(data) {
  1199. this.$Request.get('/app/order/get-pay-param', data).then((res) => {
  1200. console.log(res, '新支付')
  1201. if (res.code == 0) {
  1202. uni.requestPayment({
  1203. provider: 'wxpay',
  1204. timeStamp: res.timeStamp,
  1205. nonceStr: res.nonceStr,
  1206. package: res.packageStr,
  1207. signType: res.signType,
  1208. paySign: res.paySign,
  1209. success: (suc) => {
  1210. uni.hideLoading()
  1211. this.$queue.showToast('支付成功')
  1212. setTimeout(() => {
  1213. this.isThrottle = true
  1214. uni.switchTab({
  1215. url: '/pages/order/index'
  1216. })
  1217. }, 1000)
  1218. },
  1219. fail: (err) => {
  1220. console.log('fail:' + JSON.stringify(err))
  1221. this.isThrottle = true
  1222. uni.setStorageSync('isClear', true)
  1223. uni.showToast({
  1224. title: '支付失败',
  1225. icon: 'none',
  1226. mask: true
  1227. })
  1228. setTimeout(() => {
  1229. uni.reLaunch({
  1230. url: '/pages/order/index'
  1231. })
  1232. }, 1500)
  1233. }
  1234. })
  1235. } else {
  1236. uni.showToast({
  1237. title: res.msg,
  1238. icon: 'none'
  1239. })
  1240. this.isThrottle = true
  1241. }
  1242. })
  1243. },
  1244. oldPay(data) {
  1245. this.$Request.post('/app/wxPay/wxPayJsApiOrder', data).then((res) => {
  1246. console.log(res, '旧支付')
  1247. // uni.hideLoading();
  1248. if (res.code == 0) {
  1249. uni.requestPayment({
  1250. provider: 'wxpay',
  1251. timeStamp: res.data.timestamp,
  1252. nonceStr: res.data.noncestr,
  1253. package: res.data.package,
  1254. signType: res.data.signType,
  1255. paySign: res.data.sign,
  1256. success: (suc) => {
  1257. uni.hideLoading()
  1258. this.$queue.showToast('支付成功')
  1259. setTimeout(() => {
  1260. this.isThrottle = true
  1261. uni.switchTab({
  1262. url: '/pages/order/index'
  1263. })
  1264. }, 1000)
  1265. },
  1266. fail: (err) => {
  1267. console.log('fail:' + JSON.stringify(err))
  1268. this.isThrottle = true
  1269. uni.setStorageSync('isClear', true)
  1270. uni.showToast({
  1271. title: '支付失败',
  1272. icon: 'none',
  1273. mask: true
  1274. })
  1275. setTimeout(() => {
  1276. uni.reLaunch({
  1277. url: '/pages/order/index'
  1278. })
  1279. }, 1500)
  1280. }
  1281. })
  1282. } else {
  1283. uni.showToast({
  1284. title: res.msg,
  1285. icon: 'none'
  1286. })
  1287. this.isThrottle = true
  1288. }
  1289. })
  1290. },
  1291. callPay: function (response) {
  1292. if (typeof WeixinJSBridge === 'undefined') {
  1293. if (document.addEventListener) {
  1294. document.addEventListener('WeixinJSBridgeReady', this.onBridgeReady(response), false)
  1295. } else if (document.attachEvent) {
  1296. document.attachEvent('WeixinJSBridgeReady', this.onBridgeReady(response))
  1297. document.attachEvent('onWeixinJSBridgeReady', this.onBridgeReady(response))
  1298. }
  1299. } else {
  1300. this.onBridgeReady(response)
  1301. }
  1302. },
  1303. onBridgeReady: function (response) {
  1304. let that = this
  1305. if (!response.package) {
  1306. return
  1307. }
  1308. WeixinJSBridge.invoke(
  1309. 'getBrandWCPayRequest',
  1310. {
  1311. appId: response.appid, //公众号名称,由商户传入
  1312. timeStamp: response.timestamp, //时间戳,自1970年以来的秒数
  1313. nonceStr: response.noncestr, //随机串
  1314. package: response.package,
  1315. signType: response.signType, //微信签名方式:
  1316. paySign: response.sign //微信签名
  1317. },
  1318. function (res) {
  1319. if (res.err_msg === 'get_brand_wcpay_request:ok') {
  1320. // 使用以上方式判断前端返回,微信团队郑重提示:
  1321. //res.err_msg将在用户支付成功后返回ok,但并不保证它绝对可靠。
  1322. uni.hideLoading()
  1323. uni.showToast({
  1324. title: '支付成功',
  1325. icon: 'success'
  1326. })
  1327. setTimeout(function () {
  1328. that.isThrottle = true
  1329. uni.switchTab({
  1330. url: '/pages/order/index'
  1331. })
  1332. }, 1000)
  1333. } else {
  1334. that.isThrottle = true
  1335. uni.hideLoading()
  1336. }
  1337. WeixinJSBridge.log(response.err_msg)
  1338. }
  1339. )
  1340. },
  1341. isCheckPay(code, name, order) {
  1342. if (code == 0) {
  1343. console.log('999999999999')
  1344. this.setPayment(name, order)
  1345. } else {
  1346. uni.hideLoading()
  1347. uni.showToast({
  1348. title: '支付信息有误'
  1349. })
  1350. this.isThrottle = true
  1351. }
  1352. },
  1353. setPayment(name, order) {
  1354. console.log(777777777, name, order)
  1355. uni.requestPayment({
  1356. provider: name,
  1357. orderInfo: order, //微信、支付宝订单数据
  1358. success: (res) => {
  1359. uni.hideLoading()
  1360. uni.showLoading({
  1361. title: '支付成功',
  1362. icon: 'none'
  1363. })
  1364. setTimeout(() => {
  1365. this.isThrottle = true
  1366. uni.navigateBack()
  1367. }, 1000)
  1368. },
  1369. fail: (err) => {
  1370. this.isThrottle = true
  1371. uni.hideLoading()
  1372. },
  1373. complete: () => {
  1374. this.isThrottle = true
  1375. uni.hideLoading()
  1376. }
  1377. })
  1378. },
  1379. // 获取选择的地址
  1380. getAddressDet(e) {
  1381. let data = {
  1382. addressId: e
  1383. }
  1384. this.$Request.get('/app/address/selectAddressById', data).then((res) => {
  1385. console.log(res, 741258)
  1386. if (res.code == 0) {
  1387. this.address = res.data
  1388. if (this.address.insideAddressId) {
  1389. this.getInsideDeliveryFee(this.address.insideAddressId)
  1390. } else {
  1391. this.getInsideDeliveryFee(0)
  1392. }
  1393. if (JSON.stringify(this.address) != '{}') {
  1394. this.getDistance()
  1395. }
  1396. uni.removeStorageSync('addressId')
  1397. }
  1398. })
  1399. },
  1400. // 获取地址列表
  1401. getAddressList() {
  1402. let data = {
  1403. page: 1,
  1404. limit: 100
  1405. }
  1406. this.$Request.get('/app/address/selectAddressList', data).then((res) => {
  1407. if (res.code == 0 && res.data.list.length) {
  1408. this.address = res.data.list[0]
  1409. res.data.list.forEach((ret) => {
  1410. if (ret.addressDefault == 1) {
  1411. this.address = ret
  1412. }
  1413. })
  1414. if (this.address.insideAddressId) {
  1415. this.getInsideDeliveryFee(this.address.insideAddressId)
  1416. } else {
  1417. this.getInsideDeliveryFee(0)
  1418. }
  1419. // console.log(this.address, '我的地址列表460777')
  1420. if (JSON.stringify(this.address) != '{}') {
  1421. this.getDistance()
  1422. }
  1423. }
  1424. })
  1425. },
  1426. getInsideDeliveryFee(insideAddressId) {
  1427. this.$Request.get(`/app/inside-address/${insideAddressId}`).then((res) => {
  1428. // console.log(res, 987456)
  1429. if (res.code == 0) {
  1430. this.address.insideDeliveryFee = res.data.deliveryFee || 0
  1431. }
  1432. })
  1433. },
  1434. goAddress() {
  1435. uni.navigateTo({
  1436. url: '/my/address/index?add=1'
  1437. })
  1438. },
  1439. // 点击调起地图查看位置
  1440. goMap() {
  1441. let lati = parseFloat(this.dataList.shopLat)
  1442. let longi = parseFloat(this.dataList.shopLng)
  1443. uni.authorize({
  1444. scope: 'scope.userLocation',
  1445. success: (res) => {
  1446. uni.openLocation({
  1447. name: this.dataList.shopName,
  1448. latitude: lati,
  1449. longitude: longi,
  1450. success: () => {}
  1451. })
  1452. },
  1453. fail(err) {}
  1454. })
  1455. },
  1456. // 打电话
  1457. call() {
  1458. uni.makePhoneCall({
  1459. phoneNumber: this.dataList.shopPhone
  1460. })
  1461. }
  1462. }
  1463. }
  1464. </script>
  1465. <style scoped>
  1466. .hintPopul {
  1467. width: 100%;
  1468. height: 100vh;
  1469. position: fixed;
  1470. top: 0;
  1471. background: rgba(0, 0, 0, 0.4);
  1472. z-index: 999;
  1473. }
  1474. .content_ {
  1475. position: absolute;
  1476. left: 0;
  1477. right: 0;
  1478. top: 0;
  1479. bottom: 0;
  1480. margin: auto;
  1481. text-align: center;
  1482. width: 500rpx;
  1483. height: 400rpx;
  1484. border-radius: 20rpx;
  1485. background-color: #fff;
  1486. padding-top: 120rpx;
  1487. }
  1488. .content_ image {
  1489. position: absolute;
  1490. top: -50rpx;
  1491. left: 0;
  1492. right: 0;
  1493. margin: auto;
  1494. }
  1495. .hintText {
  1496. font-size: 30rpx;
  1497. }
  1498. .Btns {
  1499. width: 460rpx;
  1500. height: 60rpx;
  1501. line-height: 60rpx;
  1502. text-align: center;
  1503. background: #fcd202;
  1504. font-size: 28rpx;
  1505. border: 2rpx solid #fcd202;
  1506. color: #333333;
  1507. border-radius: 50rpx;
  1508. font-weight: 700;
  1509. margin: auto;
  1510. }
  1511. .goods_address {
  1512. width: 94%;
  1513. background: #ffffff;
  1514. height: 120rpx;
  1515. margin: 20rpx auto 0;
  1516. border-radius: 18rpx;
  1517. }
  1518. .address_box {
  1519. width: 90%;
  1520. margin: 0 auto;
  1521. height: 120rpx;
  1522. display: flex;
  1523. line-height: 120rpx;
  1524. }
  1525. .address_name {
  1526. flex: 1;
  1527. font-size: 30rpx;
  1528. }
  1529. .address_image {
  1530. /* flex: 1; */
  1531. display: flex;
  1532. justify-content: flex-end;
  1533. align-items: center;
  1534. }
  1535. .address_image image {
  1536. width: 15rpx;
  1537. height: 30rpx;
  1538. }
  1539. .songda_image image {
  1540. width: 20rpx;
  1541. height: 30rpx;
  1542. margin-left: 20rpx;
  1543. }
  1544. /* 地址 */
  1545. .address {
  1546. width: 88%;
  1547. margin: 3% auto;
  1548. padding: 3%;
  1549. display: flex;
  1550. background-color: #ffffff;
  1551. border-radius: 18rpx;
  1552. }
  1553. .adderss_le {
  1554. width: 90%;
  1555. line-height: 1.5;
  1556. }
  1557. .adderss_le_text {
  1558. font-size: 30rpx;
  1559. font-weight: bold;
  1560. color: #333333;
  1561. }
  1562. .adderss_le_text2 {
  1563. font-size: 24rpx;
  1564. font-weight: 500;
  1565. color: #999999;
  1566. display: flex;
  1567. }
  1568. .adderss_le_text2 view {
  1569. margin-left: 2%;
  1570. }
  1571. .adderss_le_text2 view:first-child {
  1572. margin-left: 0;
  1573. }
  1574. .adderss_ri {
  1575. width: 10%;
  1576. text-align: right;
  1577. line-height: 3;
  1578. }
  1579. .adderss_ri image {
  1580. width: 18rpx;
  1581. height: 30rpx;
  1582. }
  1583. /* 商品 */
  1584. .food {
  1585. width: 94%;
  1586. margin: 3% auto;
  1587. padding: 3%;
  1588. background-color: #ffffff;
  1589. border-radius: 18rpx;
  1590. }
  1591. .food_top {
  1592. display: flex;
  1593. justify-content: space-between;
  1594. align-items: center;
  1595. font-size: 32rpx;
  1596. font-weight: bold;
  1597. }
  1598. .food_bottom {
  1599. margin-top: 20rpx;
  1600. color: #666666;
  1601. font-size: 28rpx;
  1602. line-height: 45rpx;
  1603. }
  1604. .bottom_text {
  1605. color: #ea0018;
  1606. }
  1607. .tosend_header_food {
  1608. width: 100%;
  1609. display: flex;
  1610. margin-top: 3%;
  1611. }
  1612. .tosend_header_food_le {
  1613. width: 15%;
  1614. }
  1615. .tosend_header_food_le image {
  1616. width: 110rpx;
  1617. height: 110rpx;
  1618. }
  1619. .tosend_header_food_ce {
  1620. margin: 0 0 0 4%;
  1621. width: 57%;
  1622. }
  1623. .tosend_header_food_ri {
  1624. text-align: right;
  1625. width: 25%;
  1626. }
  1627. .tosend_header_food_text {
  1628. font-size: 34rpx;
  1629. font-weight: 500;
  1630. color: #333333;
  1631. line-height: 1.8;
  1632. }
  1633. .tosend_header_food_text text {
  1634. font-size: 25rpx;
  1635. }
  1636. .tosend_header_food_text2 {
  1637. font-size: 30rpx;
  1638. font-weight: 500;
  1639. color: #999999;
  1640. }
  1641. .do_top {
  1642. padding-top: 3%;
  1643. }
  1644. .do_bot {
  1645. padding-bottom: 3%;
  1646. border-bottom: 2rpx solid #e6e6e6;
  1647. }
  1648. .tosend_header_do {
  1649. width: 100%;
  1650. color: #333333;
  1651. font-size: 30rpx;
  1652. display: flex;
  1653. margin-top: 20rpx;
  1654. line-height: 1.5;
  1655. }
  1656. .tosend_header_do view {
  1657. /* flex: 1; */
  1658. }
  1659. .tosend_header_do_ri {
  1660. text-align: right;
  1661. }
  1662. .tosend_header_do_le2 {
  1663. font-family: PingFang SC;
  1664. font-weight: 500;
  1665. color: #999999;
  1666. padding-top: 1.5%;
  1667. }
  1668. .tosend_header_do_ri2 {
  1669. text-align: right;
  1670. color: #ea0000;
  1671. font-size: 40rpx;
  1672. }
  1673. .tosend_header_do_ri2 text {
  1674. font-size: 30rpx;
  1675. }
  1676. /* 支付 */
  1677. /* .payment_all{
  1678. width: 88%;margin: 3% auto;padding: 3%;background-color: #FFFFFF;
  1679. border-radius: 18rpx;
  1680. }
  1681. .payment{
  1682. width: 100%;display: flex;margin-top: 3%;
  1683. }
  1684. .payment_le{
  1685. width: 13%;
  1686. }
  1687. .payment_le image{
  1688. width: 60rpx;height: 60rpx;
  1689. }
  1690. .payment_ce{
  1691. width: 52%;
  1692. font-size: 30rpx;
  1693. font-weight: bold;
  1694. color: #333333;line-height: 60rpx;
  1695. }
  1696. .payment_ri{
  1697. width: 35%;text-align: right;line-height: 60rpx;
  1698. } */
  1699. /* 结算 */
  1700. .goorder {
  1701. width: 100%;
  1702. padding: 2% 3%;
  1703. position: fixed;
  1704. bottom: 0;
  1705. background-color: #ffffff;
  1706. }
  1707. .goorder_but {
  1708. width: 100%;
  1709. line-height: 3.5;
  1710. text-align: center;
  1711. background: #fcd202;
  1712. border-radius: 36rpx;
  1713. font-weight: 700;
  1714. }
  1715. .goorder_but_ {
  1716. opacity: 0.5;
  1717. }
  1718. .bg {
  1719. background-color: #ffffff;
  1720. }
  1721. .tabBtn {
  1722. /* background-color: #f6f6fa; */
  1723. height: 60rpx;
  1724. line-height: 60rpx;
  1725. color: #999999;
  1726. font-size: 38rpx;
  1727. }
  1728. .active {
  1729. /* width: 82rpx; */
  1730. height: 6rpx;
  1731. background: #fcd202;
  1732. /* position: relative;
  1733. top: -20rpx; */
  1734. z-index: 9;
  1735. }
  1736. </style>