confirmOrder.vue 63 KB

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