confirmOrder.vue 64 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166
  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. this.getvipMoney()
  520. let totalMoney =0
  521. if(this.Vipmoney.canReduceFlag=='1'){
  522. totalMoney = parseFloat(this.totalPrice1 -(this.Vipmoney.reduceAmount?this.Vipmoney.reduceAmount:0)).toFixed(2)
  523. }else{
  524. 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)
  525. }
  526. if (totalMoney <= 0) {
  527. this.totalPrice12 = 0.01
  528. } else {
  529. this.totalPrice12 = totalMoney
  530. }
  531. },
  532. //获取会员立减金额
  533. getvipMoney() {
  534. let data = {
  535. shopId: this.shopId,
  536. userId: uni.getStorageSync('userId'),
  537. originalPrice:this.totalPrice1
  538. }
  539. this.$Request.get('/app/vip/get-can-reduce',data).then((res) => {
  540. console.log(res, '会员立减',data)
  541. if (res.code == 0 && res.data) {
  542. this.Vipmoney=res.data
  543. let totalMoney =0
  544. if(this.Vipmoney.canReduceFlag=='1'){
  545. totalMoney = parseFloat(this.totalPrice1 -(this.Vipmoney.reduceAmount?this.Vipmoney.reduceAmount:0)).toFixed(2)
  546. }else{
  547. 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)
  548. }
  549. if (totalMoney <= 0) {
  550. this.totalPrice12 = 0.01
  551. } else {
  552. this.totalPrice12 = totalMoney
  553. }
  554. }
  555. })
  556. },
  557. getIntegralRules() {
  558. let data = {
  559. money: this.totalPrice12
  560. }
  561. this.$Request.get('/app/userintegral/getIntegralByMoney', data).then((res) => {
  562. console.log(res, '999',data)
  563. if (res.code == 0) {
  564. this.intergral = res.data.intergral
  565. this.maxIntegral = res.data.maxIntegral
  566. this.ruleAmount1 = res.data.ruleAmount1
  567. this.ruleAmount2 = res.data.ruleAmount2
  568. this.ruleMaxAmount = res.data.ruleMaxAmount
  569. this.ruleValue1 = res.data.ruleValue1
  570. this.ruleValue2 = res.data.ruleValue2
  571. if (res.data.flag == 1) {
  572. this.isIntegral = true
  573. } else {
  574. this.isIntegral = false
  575. }
  576. }
  577. })
  578. },
  579. //获取骑手上下班时间
  580. getQishou() {
  581. this.$Request.get('/app/tbindent/work-time').then((res) => {
  582. console.log(res, 'p')
  583. if (res.code == 0 && res.data) {
  584. if (this.orderType == 2) {
  585. if (this.autoSendOrder == 0) {
  586. //0是平台配
  587. this.workStart = parseInt(res.data.workingHoursOfRider.substring(0, 2))
  588. this.workStartMin = parseInt(res.data.workingHoursOfRider.substring(3, 5))
  589. this.workEnd = parseInt(res.data.workingHoursOfRider.substring(6, 8))
  590. } else if (this.autoSendOrder == 1) {
  591. this.workStart = parseInt(this.shopDet.businessHours.substring(0, 2))
  592. this.workStartMin = parseInt(this.shopDet.businessHours.substring(3, 5))
  593. this.workEnd = parseInt(this.shopDet.lockHours.substring(0, 2))
  594. }
  595. } else if (this.orderType == 1) {
  596. this.workStart = parseInt(this.shopDet.businessHours.substring(0, 2))
  597. this.workStartMin = parseInt(this.shopDet.businessHours.substring(3, 5))
  598. this.workEnd = parseInt(this.shopDet.lockHours.substring(0, 2))
  599. }
  600. this.yusongTime = res.data.timeOfRider
  601. var date = new Date()
  602. var currentHours = date.getHours()
  603. var currentMinute = date.getMinutes()
  604. var temp = []
  605. // currentHours = 12;
  606. var temp_time = []
  607. //如果当前时间大于20点
  608. var minite = parseInt(this.yusongTime - parseInt(this.yusongTime / 60) * 60)
  609. if (parseInt(this.yusongTime / 60) == 0) {
  610. var h1 = 0
  611. var h2 = parseInt(this.yusongTime - parseInt(this.yusongTime / 60) * 60)
  612. } else {
  613. var h1 = parseInt(this.yusongTime / 60)
  614. var h2 = parseInt(this.yusongTime - parseInt(this.yusongTime / 60) * 60)
  615. }
  616. var acc = currentHours + h1
  617. var bcc = currentMinute + h2
  618. var teshu = this.workStart + h1
  619. if (bcc >= 60) {
  620. var b = bcc - 60
  621. var a = acc + 1
  622. } else {
  623. var b = bcc
  624. var a = acc
  625. }
  626. var a1 = a + 1
  627. var s1 = a.toString()
  628. var s2 = a1.toString()
  629. var e1 = b.toString()
  630. console.log(this.workEnd, h1, currentHours, 'o')
  631. var cc = (this.workStartMin + h2).toString()
  632. if (currentHours >= this.workEnd - h1) {
  633. var time2 = teshu + 1
  634. // this.data.warning = '当前时间段无骑手配送,现在下单,最早将于明日'+teshu + ':00'+'送达'
  635. uni.showModal({
  636. title: '提示',
  637. content: '当前时间段无骑手配送,现在下单,最早将于明日' + teshu + ':00' + '送达',
  638. success: (res) => {
  639. if (res.confirm) {
  640. } else if (res.cancel) {
  641. }
  642. }
  643. })
  644. // this.data.startDate = '明日 | '+teshu + ':00' + '-' + time2 + ':00'
  645. // this.data.startDate = '明早 | '+a + ':'+b + '-' + a1 + ':'+b
  646. temp[0] = ['明天']
  647. temp[1] = []
  648. // console.log(teshu,'明1',this.workEnd-h1)
  649. for (let i = teshu; i < this.workEnd - h1; ) {
  650. var i1 = i + 1
  651. var ss1 = i.toString()
  652. var ss2 = i1.toString()
  653. // console.log(ss1,'明')
  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. } else if (currentHours < this.workStart) {
  658. var time2 = teshu + 1
  659. uni.showModal({
  660. title: '提示',
  661. content: '当前时间段无骑手配送,现在下单,最早将于今日' + teshu + ':00' + '送达',
  662. success: (res) => {
  663. if (res.confirm) {
  664. } else if (res.cancel) {
  665. }
  666. }
  667. })
  668. temp[0] = ['今天', '明天']
  669. temp[1] = []
  670. for (let i = teshu; i < this.workEnd - h1; ) {
  671. var i1 = i + 1
  672. var ss1 = i.toString()
  673. var ss2 = i1.toString()
  674. temp[1].push(ss1.padStart(2, 0) + ':' + cc.padStart(2, 0) + '-' + ss2.padStart(2, 0) + ':' + cc.padStart(2, 0))
  675. i += 1
  676. }
  677. } else {
  678. temp[0] = ['今天', '明天']
  679. temp[1] = []
  680. for (let i = a; i < this.workEnd - h1; ) {
  681. var i1 = i + 1
  682. var ss1 = i.toString()
  683. var ss2 = i1.toString()
  684. temp[1].push(ss1.padStart(2, 0) + ':' + e1.padStart(2, 0) + '-' + ss2.padStart(2, 0) + ':' + e1.padStart(2, 0))
  685. i += 1
  686. }
  687. }
  688. // this.$queue.setData({
  689. // multiArray:temp,
  690. // })
  691. this.data.multiArray = temp
  692. if (this.data.warning != '') {
  693. wx.showToast({
  694. title: this.data.warning,
  695. icon: 'none',
  696. duration: 3000
  697. })
  698. }
  699. }
  700. })
  701. },
  702. bindMultiPickerColumnChange: function (e) {
  703. console.log(e,'e')
  704. console.log('第几列发生变化', e.detail.column)
  705. console.log('选择第几个', e.detail.value)
  706. let c = e.detail.column
  707. let v = e.detail.value
  708. var time = []
  709. var date = new Date()
  710. var currentHours = date.getHours()
  711. var currentMinute = date.getMinutes()
  712. var minite = parseInt(this.yusongTime - parseInt(this.yusongTime / 60) * 60)
  713. if (parseInt(this.yusongTime / 60) == 0) {
  714. var h1 = 0
  715. var h2 = parseInt(this.yusongTime - parseInt(this.yusongTime / 60) * 60)
  716. } else {
  717. var h1 = parseInt(this.yusongTime / 60)
  718. var h2 = parseInt(this.yusongTime - parseInt(this.yusongTime / 60) * 60)
  719. }
  720. var acc = currentHours + h1
  721. var bcc = currentMinute + h2
  722. var teshu = this.workStart + h1
  723. if (bcc >= 60) {
  724. var b = bcc - 60
  725. var a = acc + 1
  726. } else {
  727. var b = bcc
  728. var a = acc
  729. }
  730. var a1 = a + 1
  731. var s1 = a.toString()
  732. var s2 = a1.toString()
  733. var e1 = b.toString()
  734. var cc = (this.workStartMin + h2).toString()
  735. // console.log(this.workStartMin,h2,'kkk')
  736. var temp = this.data.multiArray
  737. // currentHours = 12;
  738. if (c == 0) {
  739. if (temp[c][v] == '今天') {
  740. temp[1] = []
  741. for (let i = a; i < this.workEnd - h1; ) {
  742. var i1 = i + 1
  743. var ss1 = i.toString()
  744. var ss2 = i1.toString()
  745. temp[1].push(ss1.padStart(2, 0) + ':' + e1.padStart(2, 0) + '-' + ss2.padStart(2, 0) + ':' + e1.padStart(2, 0))
  746. i += 1
  747. }
  748. } else {
  749. temp[1] = []
  750. for (let i = teshu; i < this.workEnd - h1; ) {
  751. var i1 = i + 1
  752. var ss1 = i.toString()
  753. var ss2 = i1.toString()
  754. temp[1].push(ss1.padStart(2, 0) + ':' + cc.padStart(2, 0) + '-' + ss2.padStart(2, 0) + ':' + cc.padStart(2, 0))
  755. i += 1
  756. }
  757. }
  758. // this.$queue.setData({
  759. // multiArray:temp
  760. // })
  761. this.data.multiArray = temp
  762. this.$forceUpdate()
  763. }
  764. },
  765. bindStartMultiPickerChange: function (e) {
  766. let temp = this.data.multiArray
  767. // this.$queue.setData({
  768. // startDate:temp[0][e.detail.value[0]]+' | '+temp[1][e.detail.value[1]]
  769. // })
  770. this.data.startDate = temp[0][e.detail.value[0]] + ' | ' + temp[1][e.detail.value[1]]
  771. console.log(temp[0][e.detail.value[0]], temp[1][e.detail.value[1]].substring(0, 5), getDate(new Date(), 2).fullDate)
  772. if (this.data.startDate) {
  773. this.reservationFlag = 1
  774. if (temp[0][e.detail.value[0]] == '今天') {
  775. var date = getDate(new Date()).fullDate
  776. this.expectDeliveryTime = date + ' ' + temp[1][e.detail.value[1]].substring(0, 5) + ':00'
  777. } else if (temp[0][e.detail.value[0]] == '明天') {
  778. var date = getDate(new Date(), 1).fullDate
  779. this.expectDeliveryTime = date + ' ' + temp[1][e.detail.value[1]].substring(0, 5) + ':00'
  780. } else if (temp[0][e.detail.value[0]] == '后天') {
  781. var date = getDate(new Date(), 2).fullDate
  782. this.expectDeliveryTime = date + ' ' + temp[1][e.detail.value[1]].substring(0, 5) + ':00'
  783. }
  784. }
  785. },
  786. goCash() {
  787. uni.navigateTo({
  788. url: '/my/wallet/index'
  789. })
  790. },
  791. getMsgData() {
  792. this.$Request.get('/app/userintegral/findUserMessage').then((res) => {
  793. if (res.code == 0 && res.data) {
  794. this.userMoney = res.data.userMoney ? res.data.userMoney : 0
  795. }
  796. })
  797. },
  798. //获取店铺详情
  799. getShopDet(shopId) {
  800. let data = {
  801. shopId,
  802. lng: this.lng,
  803. lat: this.lat
  804. }
  805. this.$Request.get('/app/goods/selectGoodsList', data).then((res) => {
  806. console.log(res, 'data')
  807. if (res.code == 0 && res.data) {
  808. this.reservationOpenFlag = res.data.goodsShop.reservationOpenFlag
  809. this.autoSendOrder = res.data.goodsShop.autoSendOrder
  810. this.shopDet = res.data.goodsShop
  811. this.ifPaotui = res.data.goodsShop.enableFullReductionFlag
  812. this.getOrderList()
  813. // this.getQishou()
  814. }
  815. })
  816. },
  817. goBack() {
  818. uni.navigateBack({})
  819. },
  820. isShow() {
  821. this.show = true
  822. },
  823. //选择优惠活动弹框
  824. huodongShow() {
  825. this.youhui = true
  826. },
  827. getDistance() {
  828. if (this.address.lng && this.dataList.shopLng) {
  829. let data = {
  830. ol: this.address.lng,
  831. od: this.address.lat,
  832. dl: this.dataList.shopLng,
  833. dd: this.dataList.shopLat
  834. }
  835. this.$Request.post('/app/tbindent/distance', data).then((res) => {
  836. if (res.code == 0) {
  837. this.distance = res.data
  838. if (this.distance > Number(this.dataList.distributionDistance)) {
  839. this.isTrue = true
  840. } else {
  841. this.isTrue = false
  842. }
  843. }
  844. })
  845. }
  846. },
  847. close() {
  848. this.show = false
  849. },
  850. closeYouhui() {
  851. this.youhui = false
  852. },
  853. switchTab(e) {
  854. this.orderType = e
  855. this.coupon = ''
  856. // this.huodong = ''
  857. if (JSON.stringify(this.address) != '{}') {
  858. this.getDistance()
  859. }
  860. if (this.orderType == 2) {
  861. this.packType=1
  862. this.ispackType =false
  863. this.totalPrice1 = parseFloat(this.totalPrice + this.paotuiMoney + this.dabaoMoney + this.address.insideDeliveryFee).toFixed(2)
  864. this.getvipMoney()
  865. } else {
  866. this.packType=1
  867. this.ispackType =false
  868. if(this.packType==1){
  869. this.totalPrice1 = parseFloat(parseFloat(this.totalPrice) + parseFloat(this.dabaoMoney)).toFixed(2)
  870. }else{
  871. this.totalPrice1 = parseFloat(this.totalPrice).toFixed(2)
  872. }
  873. this.getvipMoney()
  874. }
  875. let totalMoney =0
  876. if(this.Vipmoney.canReduceFlag=='1'){
  877. totalMoney = parseFloat(this.totalPrice1 -(this.Vipmoney.reduceAmount?this.Vipmoney.reduceAmount:0)).toFixed(2)
  878. }else{
  879. 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)
  880. }
  881. if (totalMoney <= 0) {
  882. this.totalPrice12 = 0.01
  883. } else {
  884. this.totalPrice12 = totalMoney
  885. }
  886. console.log(this.totalPrice12,'切换',totalMoney)
  887. if (this.coupon) {
  888. if (this.orderType == 2) {
  889. this.totalPrice1 = parseFloat(
  890. parseFloat(this.totalPrice) + parseFloat(this.paotuiMoney) + parseFloat(this.dabaoMoney) + parseFloat(this.address.insideDeliveryFee)
  891. ).toFixed(2)
  892. } else {
  893. if(this.packType==1){
  894. this.totalPrice1 = parseFloat(parseFloat(this.totalPrice) + parseFloat(this.dabaoMoney)).toFixed(2)
  895. }else{
  896. this.totalPrice1 = parseFloat(this.totalPrice).toFixed(2)
  897. }
  898. }
  899. let totalMoney =0
  900. if(this.Vipmoney.canReduceFlag=='1'){
  901. totalMoney = parseFloat(this.totalPrice1 -(this.Vipmoney.reduceAmount?this.Vipmoney.reduceAmount:0)).toFixed(2)
  902. }else{
  903. 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)
  904. }
  905. if (totalMoney <= 0) {
  906. this.totalPrice12 = 0.01
  907. } else {
  908. this.totalPrice12 = totalMoney
  909. }
  910. }
  911. if (this.huodong) {
  912. if (this.orderType == 2) {
  913. this.totalPrice1 = parseFloat(
  914. parseFloat(this.totalPrice) + parseFloat(this.paotuiMoney) + parseFloat(this.dabaoMoney) + parseFloat(this.address.insideDeliveryFee)
  915. ).toFixed(2)
  916. } else {
  917. if(this.packType==1){
  918. this.totalPrice1 = parseFloat(parseFloat(this.totalPrice) + parseFloat(this.dabaoMoney)).toFixed(2)
  919. }else{
  920. this.totalPrice1 = parseFloat(this.totalPrice).toFixed(2)
  921. }
  922. }
  923. let totalMoney =0
  924. if(this.Vipmoney.canReduceFlag=='1'){
  925. totalMoney = parseFloat(this.totalPrice1 -(this.Vipmoney.reduceAmount?this.Vipmoney.reduceAmount:0)).toFixed(2)
  926. }else{
  927. 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)
  928. }
  929. if (totalMoney <= 0) {
  930. this.totalPrice12 = 0.01
  931. } else {
  932. this.totalPrice12 = totalMoney
  933. }
  934. }if (this.Vipmoney.canReduceFlag=='1') {
  935. if (this.orderType == 2) {
  936. this.totalPrice1 = parseFloat(
  937. parseFloat(this.totalPrice) + parseFloat(this.paotuiMoney) + parseFloat(this.dabaoMoney) + parseFloat(this.address.insideDeliveryFee)
  938. ).toFixed(2)
  939. } else {
  940. if(this.packType==1){
  941. this.totalPrice1 = parseFloat(parseFloat(this.totalPrice) + parseFloat(this.dabaoMoney)).toFixed(2)
  942. }else{
  943. this.totalPrice1 = parseFloat(this.totalPrice).toFixed(2)
  944. }
  945. }
  946. let totalMoney =0
  947. if(this.Vipmoney.canReduceFlag=='1'){
  948. totalMoney = parseFloat(this.totalPrice1 -(this.Vipmoney.reduceAmount?this.Vipmoney.reduceAmount:0)).toFixed(2)
  949. }else{
  950. 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)
  951. }
  952. if (totalMoney <= 0) {
  953. this.totalPrice12 = 0.01
  954. } else {
  955. this.totalPrice12 = totalMoney
  956. }
  957. }
  958. },
  959. // 删除优惠券
  960. detCoupon() {
  961. let data = {
  962. orderId: this.dataList.orderId
  963. }
  964. this.$Request.post('/app/order/deleteCouponByOrderId', data).then((res) => {
  965. if (res.code == 0) {
  966. }
  967. })
  968. },
  969. // 选择优惠券
  970. selCoupon(item) {
  971. this.coupon = item
  972. if (this.orderType == 2) {
  973. this.totalPrice1 = parseFloat(this.totalPrice + this.paotuiMoney + this.dabaoMoney + this.address.insideDeliveryFee).toFixed(2)
  974. } else {
  975. if(this.packType==1){
  976. this.totalPrice1 = parseFloat(parseFloat(this.totalPrice) + parseFloat(this.dabaoMoney)).toFixed(2)
  977. }else{
  978. this.totalPrice1 = parseFloat(this.totalPrice).toFixed(2)
  979. }
  980. }
  981. let totalMoney =0
  982. if(this.Vipmoney.canReduceFlag=='1'){
  983. totalMoney = parseFloat(this.totalPrice1 -(this.Vipmoney.reduceAmount?this.Vipmoney.reduceAmount:0)).toFixed(2)
  984. }else{
  985. 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)
  986. }
  987. if (totalMoney <= 0) {
  988. this.totalPrice12 = 0.01
  989. } else {
  990. this.totalPrice12 = totalMoney
  991. }
  992. let data = {
  993. parentId: this.dataList.parentId,
  994. couponId: this.coupon ? this.coupon.id : ''
  995. }
  996. this.$Request.post('/app/order/employCoupon', data).then((res) => {
  997. if (res.code == 0) {
  998. this.show = false
  999. }
  1000. })
  1001. },
  1002. //选择活动activityId
  1003. selctHuo(item) {
  1004. this.huodong = item
  1005. if (this.orderType == 2) {
  1006. this.totalPrice1 = parseFloat(this.totalPrice + this.paotuiMoney + this.dabaoMoney + this.address.insideDeliveryFee).toFixed(2)
  1007. } else {
  1008. if(this.packType==1){
  1009. this.totalPrice1 = parseFloat(parseFloat(this.totalPrice) + parseFloat(this.dabaoMoney)).toFixed(2)
  1010. }else{
  1011. this.totalPrice1 = parseFloat(this.totalPrice).toFixed(2)
  1012. }
  1013. }
  1014. let totalMoney =0
  1015. if(this.Vipmoney.canReduceFlag=='1'){
  1016. totalMoney = parseFloat(this.totalPrice1 -(this.Vipmoney.reduceAmount?this.Vipmoney.reduceAmount:0)).toFixed(2)
  1017. }else{
  1018. 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)
  1019. }
  1020. if (totalMoney <= 0) {
  1021. this.totalPrice12 = 0.01
  1022. } else {
  1023. this.totalPrice12 = totalMoney
  1024. }
  1025. this.youhui = false
  1026. },
  1027. // 优惠卷列表
  1028. getCouponList() {
  1029. // console.log(this.paotuiMoney)
  1030. // console.log(this.dabaoMoney, '123123')
  1031. let minMoney =
  1032. this.orderType == 2
  1033. ? parseFloat(parseFloat(this.totalPrice) + parseFloat(this.paotuiMoney) + parseFloat(this.dabaoMoney)).toFixed(2)
  1034. : parseFloat(this.totalPrice).toFixed(2)
  1035. let data = {
  1036. shopId: this.dataList.shopId,
  1037. page: 1,
  1038. limit: 10,
  1039. minMoney: minMoney
  1040. }
  1041. this.$Request.get('/app/coupon/selectUserCouponList', data).then((res) => {
  1042. if (res.code == 0) {
  1043. this.couponList = res.data.list
  1044. console.log(this.couponList, 'this.couponList', this.coupon)
  1045. if (this.coupon) {
  1046. let activityExists = this.couponList.some((item) => item.couponId === this.coupon.couponId)
  1047. if (!activityExists) {
  1048. this.coupon = ''
  1049. if (this.orderType == 2) {
  1050. this.totalPrice1 = parseFloat(this.totalPrice + this.paotuiMoney + this.dabaoMoney + this.address.insideDeliveryFee).toFixed(2)
  1051. } else {
  1052. if(this.packType==1){
  1053. this.totalPrice1 = parseFloat(parseFloat(this.totalPrice) + parseFloat(this.dabaoMoney)).toFixed(2)
  1054. }else{
  1055. this.totalPrice1 = parseFloat(this.totalPrice).toFixed(2)
  1056. }
  1057. }
  1058. let totalMoney =0
  1059. if(this.Vipmoney.canReduceFlag=='1'){
  1060. totalMoney = parseFloat(this.totalPrice1 -(this.Vipmoney.reduceAmount?this.Vipmoney.reduceAmount:0)).toFixed(2)
  1061. }else{
  1062. 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)
  1063. }
  1064. if (totalMoney <= 0) {
  1065. this.totalPrice12 = 0.01
  1066. } else {
  1067. this.totalPrice12 = totalMoney
  1068. }
  1069. uni.showModal({
  1070. title: '提示',
  1071. content: '当前选择的优惠券已过期,请重新选择',
  1072. success: (res) => {
  1073. if (res.confirm) {
  1074. this.coupon = ''
  1075. } else if (res.cancel) {
  1076. this.coupon = ''
  1077. }
  1078. }
  1079. })
  1080. }
  1081. }
  1082. }
  1083. })
  1084. },
  1085. // 优惠活动列表
  1086. getHuoList() {
  1087. let data = {
  1088. orderId: this.dataList.orderId
  1089. }
  1090. this.$Request.get(`/app/activity/suit-activity/${this.dataList.orderId}`, data).then((res) => {
  1091. if (res.code == 0) {
  1092. this.huoList = res.data
  1093. // console.log(this.huodong)
  1094. if (this.huodong) {
  1095. // console.log(this.huodong,'有呢')
  1096. let activityExists = this.huoList.some((item) => item.activityId === this.huodong.activityId)
  1097. if (!activityExists) {
  1098. this.huodong = ''
  1099. if (this.orderType == 2) {
  1100. this.totalPrice1 = parseFloat(this.totalPrice + this.paotuiMoney + this.dabaoMoney + this.address.insideDeliveryFee).toFixed(2)
  1101. } else {
  1102. if(this.packType==1){
  1103. this.totalPrice1 = parseFloat(parseFloat(this.totalPrice) + parseFloat(this.dabaoMoney)).toFixed(2)
  1104. }else{
  1105. this.totalPrice1 = parseFloat(this.totalPrice).toFixed(2)
  1106. }
  1107. }
  1108. let totalMoney =0
  1109. if(this.Vipmoney.canReduceFlag=='1'){
  1110. totalMoney = parseFloat(this.totalPrice1 -(this.Vipmoney.reduceAmount?this.Vipmoney.reduceAmount:0)).toFixed(2)
  1111. }else{
  1112. 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)
  1113. }
  1114. if (totalMoney <= 0) {
  1115. this.totalPrice12 = 0.01
  1116. } else {
  1117. this.totalPrice12 = totalMoney
  1118. }
  1119. uni.showModal({
  1120. title: '提示',
  1121. content: '当前选择的优惠活动已过期,请重新选择',
  1122. success: (res) => {
  1123. if (res.confirm) {
  1124. this.huodong = ''
  1125. } else if (res.cancel) {
  1126. this.huodong = ''
  1127. }
  1128. }
  1129. })
  1130. }
  1131. }
  1132. // 匹配出最优惠的活动
  1133. if (this.huoList.length) {
  1134. this.huodong = this.huoList.reduce((prev, current) => (prev.discountAmount > current.discountAmount ? prev : current))
  1135. this.selctHuo(this.huodong)
  1136. }
  1137. // for(var i=0;i<this.huoList.length;i++){
  1138. // if(this.huodong!=''&&this.huodong.activityId!=this.huoList[i].activityId){
  1139. // console.log('优惠活动过期')
  1140. // }
  1141. // }
  1142. // if(this.huoList.length==0){
  1143. // this.huodong=''
  1144. // }
  1145. }
  1146. })
  1147. },
  1148. //拼单支付成功取消订单
  1149. cancelPinDan() {
  1150. // if (this.orderId) {
  1151. // let data = {
  1152. // orderId: this.orderId
  1153. // };
  1154. // this.$Request.post('/app/order/deleteOrder', data).then(res => {
  1155. // if (res.code == 0) {
  1156. // uni.removeStorageSync('orderId');
  1157. // }
  1158. // });
  1159. // }
  1160. },
  1161. // 商品列表
  1162. getOrderList() {
  1163. // 显示加载提示
  1164. uni.showLoading({
  1165. title: '加载中', // 加载提示文本
  1166. mask: true // 是否显示透明蒙层,防止触摸穿透
  1167. })
  1168. this.paotuiMoney = 0
  1169. this.totalPrice1 = 0
  1170. this.totalPrice12=0
  1171. if (this.status == 0) {
  1172. console.log(6666)
  1173. this.payContinue()
  1174. return
  1175. }
  1176. let data = {
  1177. shopId: this.shopId,
  1178. status: 1,
  1179. page: 1,
  1180. limit: 1000
  1181. // orderType: this.orderType
  1182. }
  1183. // console.log(data)
  1184. this.$Request.get('/app/order/selectAllOrderList', data).then((res) => {
  1185. console.log(res,'moneuy')
  1186. uni.hideLoading()
  1187. if (res.code == 0 && res.data.pageUtils.list.length) {
  1188. this.GoodsorderId = res.data.pageUtils.list[0].orderId
  1189. this.dataList = res.data.pageUtils.list[0]
  1190. if (this.dataList && this.dataList.orderGoodsList && this.dataList.orderGoodsList[0]) {
  1191. this.dabaoMoney = 0
  1192. this.dataList.orderGoodsList[0].forEach((res) => {
  1193. res.goodsPicture = res.goodsPicture.split(',')
  1194. this.dabaoMoney += res.goodsPack * res.goodsNum
  1195. this.goodsMoney += res.goodsPrice * res.goodsNum
  1196. this.goodsMoney = parseFloat(this.goodsMoney + this.dabaoMoney)
  1197. })
  1198. this.goodsList = this.dataList.orderGoodsList[0]
  1199. }
  1200. console.log(this.dataList, this.dabaoMoney, 'kkklll')
  1201. if (this.ifPaotui == 1) {
  1202. this.paotuiMoney = this.dataList.errandMoney
  1203. } else if (this.ifPaotui == 0) {
  1204. // 判断商品金额是否大于最低减免配送费金额
  1205. console.log(this.goodsMoney, '商品总金额', res, this.dataList.exemptMinMoney)
  1206. if (Number(this.goodsMoney) >= Number(this.dataList.exemptMinMoney)) {
  1207. this.paotuiMoney = 0
  1208. } else {
  1209. this.paotuiMoney = this.dataList.errandMoney
  1210. }
  1211. }
  1212. this.totalPrice = res.data.money
  1213. console.log(this.totalPrice,'total')
  1214. console.log(this.paotuiMoney,'paotui')
  1215. console.log(this.dabaoMoney,'dabao')
  1216. console.log(this.address.insideDeliveryFee,'free')
  1217. if (this.orderType == 2) {
  1218. this.totalPrice1 = parseFloat(
  1219. parseFloat(this.totalPrice) + parseFloat(this.paotuiMoney) + parseFloat(this.dabaoMoney) + parseFloat(this.address.insideDeliveryFee)
  1220. ).toFixed(2)
  1221. } else {
  1222. if(this.packType==1){
  1223. this.totalPrice1 = parseFloat(parseFloat(this.totalPrice) + parseFloat(this.dabaoMoney)).toFixed(2)
  1224. }else{
  1225. this.totalPrice1 = parseFloat(this.totalPrice).toFixed(2)
  1226. }
  1227. }
  1228. this.getvipMoney()
  1229. // let totalMoney =0
  1230. // if(this.Vipmoney.canReduceFlag=='1'){
  1231. // totalMoney = parseFloat(this.totalPrice1 -(this.Vipmoney.reduceAmount?this.Vipmoney.reduceAmount:0)).toFixed(2)
  1232. // }else{
  1233. // 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)
  1234. // }
  1235. // if (totalMoney <= 0) {
  1236. // this.totalPrice12 = 0.01
  1237. // } else {
  1238. // this.totalPrice12 = totalMoney
  1239. // }
  1240. // console.log(this.dataList)
  1241. this.getCouponList()
  1242. this.getHuoList()
  1243. this.detCoupon()
  1244. this.getDistance()
  1245. }
  1246. // 加载提示关闭
  1247. uni.hideLoading()
  1248. })
  1249. },
  1250. payContinue() {
  1251. let data = {
  1252. orderId: this.orderId,
  1253. page: 1,
  1254. limit: 1000
  1255. }
  1256. console.log(data,'select11')
  1257. this.$Request.get('/app/order/selectOrder', data).then((res) => {
  1258. console.log(res,'select')
  1259. uni.hideLoading()
  1260. if (res.code == 0 && res.data.pageUtils.list.length) {
  1261. this.GoodsorderId = res.data.pageUtils.list[0].orderId
  1262. this.dataList = res.data.pageUtils.list[0]
  1263. if (this.dataList && this.dataList.orderGoodsList && this.dataList.orderGoodsList[0]) {
  1264. this.dataList.orderGoodsList[0].forEach((res) => {
  1265. res.goodsPicture = res.goodsPicture.split(',')
  1266. this.dabaoMoney += res.goodsPack * res.goodsNum
  1267. this.goodsMoney += res.goodsPrice * res.goodsNum
  1268. this.goodsMoney = parseFloat(this.goodsMoney + this.dabaoMoney)
  1269. })
  1270. this.goodsList = this.dataList.orderGoodsList[0]
  1271. }
  1272. console.log(this.dataList, this.dabaoMoney, 'kkklll')
  1273. if (this.ifPaotui == 1) {
  1274. this.paotuiMoney = this.dataList.errandMoney
  1275. } else if (this.ifPaotui == 0) {
  1276. // 判断商品金额是否大于最低减免配送费金额
  1277. console.log(this.goodsMoney, '商品总金额', res, this.dataList.exemptMinMoney)
  1278. if (Number(this.goodsMoney) >= Number(this.dataList.exemptMinMoney)) {
  1279. this.paotuiMoney = 0
  1280. } else {
  1281. this.paotuiMoney = this.dataList.errandMoney
  1282. }
  1283. }
  1284. this.totalPrice = res.data.money
  1285. if (this.orderType == 2) {
  1286. this.totalPrice1 = parseFloat(
  1287. parseFloat(this.totalPrice) + parseFloat(this.paotuiMoney) + parseFloat(this.dabaoMoney) + parseFloat(this.address.insideDeliveryFee)
  1288. ).toFixed(2)
  1289. } else {
  1290. if(this.packType==1){
  1291. this.totalPrice1 = parseFloat(parseFloat(this.totalPrice) + parseFloat(this.dabaoMoney)).toFixed(2)
  1292. }else{
  1293. this.totalPrice1 = parseFloat(this.totalPrice).toFixed(2)
  1294. }
  1295. }
  1296. let totalMoney =0
  1297. if(this.Vipmoney.canReduceFlag=='1'){
  1298. totalMoney = parseFloat(this.totalPrice1 -(this.Vipmoney.reduceAmount?this.Vipmoney.reduceAmount:0)).toFixed(2)
  1299. }else{
  1300. 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)
  1301. }
  1302. if (totalMoney <= 0) {
  1303. this.totalPrice12 = 0.01
  1304. } else {
  1305. this.totalPrice12 = totalMoney
  1306. }
  1307. // console.log(this.dataList)
  1308. this.getCouponList()
  1309. this.getHuoList()
  1310. this.detCoupon()
  1311. this.getDistance()
  1312. }
  1313. // 加载提示关闭
  1314. uni.hideLoading()
  1315. })
  1316. },
  1317. selectWay(item) {
  1318. this.openWay = item.id
  1319. },
  1320. takeReark() {
  1321. let datas = {
  1322. orderId: this.GoodsorderId,
  1323. remark: this.remark
  1324. }
  1325. this.$Request.post('/app/order/updateOrdersRemark', datas).then((res) => {
  1326. if (res.code == 0) {
  1327. } else {
  1328. uni.showToast({
  1329. title: res.msg,
  1330. icon: 'none'
  1331. })
  1332. }
  1333. })
  1334. },
  1335. toSettlement_throttle: throttle(function () {
  1336. this.toSettlement()
  1337. }, 1000),
  1338. // 立即结算
  1339. toSettlement() {
  1340. if (this.isThrottle == false) {
  1341. return
  1342. }
  1343. if (this.isTrue && this.orderType == 2) {
  1344. uni.showToast({
  1345. title: '超出配送范围',
  1346. icon: 'none'
  1347. })
  1348. reutrn
  1349. }
  1350. if (this.orderType == 2 && !this.address.addressId) {
  1351. uni.showToast({
  1352. title: '请选择收货地址',
  1353. icon: 'none'
  1354. })
  1355. return
  1356. }
  1357. if (this.remark) {
  1358. this.takeReark()
  1359. }
  1360. uni.showLoading({
  1361. title: '支付中...',
  1362. mask: true // 是否显示透明蒙层,防止触摸穿透
  1363. })
  1364. this.isThrottle = false
  1365. if (this.openWay == 1) {
  1366. //零钱支付
  1367. let data = {
  1368. userId: uni.getStorageSync('userId'),
  1369. type: 1, //支付方式 1表示微信支付、4或5表示支付宝支付
  1370. activityId: this.huodong ? this.huodong.activityId : '',
  1371. reservationFlag: this.reservationFlag, //是否预约单 1是、0否
  1372. expectDeliveryTime: this.expectDeliveryTime, //期待送达时间 yyyy-MM-dd HH:mm:ss
  1373. parentId: this.dataList.parentId,
  1374. couponId: this.coupon ? this.coupon.id : '',
  1375. addressId: this.address.addressId ? this.address.addressId : '',
  1376. orderType: this.orderType
  1377. }
  1378. console.log(data, 'l')
  1379. this.$Request.post('/app/wxPay/balanceOrder', data).then((res) => {
  1380. console.log(res, '结果')
  1381. if (res.code == 0) {
  1382. uni.hideLoading()
  1383. this.$queue.showToast('支付成功')
  1384. this.cancelPinDan()
  1385. setTimeout(() => {
  1386. this.isThrottle = true
  1387. uni.switchTab({
  1388. url: '/pages/order/index'
  1389. })
  1390. }, 1000)
  1391. } else {
  1392. this.$queue.showToast(res.msg)
  1393. this.isThrottle = true
  1394. }
  1395. })
  1396. } else if (this.openWay == 2) {
  1397. //微信支付
  1398. // #ifdef H5
  1399. let data = {
  1400. userId: uni.getStorageSync('userId'),
  1401. type: 1, //支付方式 1表示微信支付、4或5表示支付宝支付
  1402. activityId: this.huodong ? this.huodong.activityId : '',
  1403. reservationFlag: this.reservationFlag, //是否预约单 1是、0否
  1404. expectDeliveryTime: this.expectDeliveryTime, //期待送达时间 yyyy-MM-dd HH:mm:ss
  1405. parentId: this.dataList.parentId,
  1406. couponId: this.coupon ? this.coupon.id : '',
  1407. addressId: this.address.addressId ? this.address.addressId : '',
  1408. orderType: this.orderType,
  1409. type: 2
  1410. }
  1411. this.$Request.post('/app/wxPay/wxPayJsApiOrder', data).then((res) => {
  1412. uni.hideLoading()
  1413. if (res.code == 0) {
  1414. this.callPay(res.data)
  1415. } else {
  1416. uni.showToast({
  1417. title: res.msg,
  1418. icon: 'none'
  1419. })
  1420. this.isThrottle = true
  1421. }
  1422. })
  1423. // #endif
  1424. // #ifdef MP-WEIXIN
  1425. this.$Request.get('/app/new-pay/enable-new-pay').then((res) => {
  1426. console.log(res, '987')
  1427. if (res.code == 0) {
  1428. let data = {
  1429. userId: uni.getStorageSync('userId'),
  1430. //支付方式 1表示微信支付、4或5表示支付宝支付
  1431. // type: 4,
  1432. activityId: this.huodong ? this.huodong.activityId : '',
  1433. reservationFlag: this.reservationFlag, //是否预约单 1是、0否
  1434. expectDeliveryTime: this.expectDeliveryTime, //期待送达时间 yyyy-MM-dd HH:mm:ss
  1435. parentId: this.dataList.parentId,
  1436. couponId: this.coupon ? this.coupon.id : '',
  1437. addressId: this.address.addressId ? this.address.addressId : '',
  1438. orderType: this.orderType,
  1439. type: res.enable ? 1 : 3,
  1440. idCard: this.idcard1,
  1441. packType:this.packType
  1442. }
  1443. console.log(data,'xinjiu')
  1444. if (res.enable) {
  1445. console.log('xin')
  1446. this.newPay(data)
  1447. } else {
  1448. console.log('jiu')
  1449. this.oldPay(data)
  1450. }
  1451. }
  1452. })
  1453. // #endif
  1454. // #ifdef APP
  1455. let data = {
  1456. type: 1,
  1457. parentId: this.dataList.parentId,
  1458. couponId: this.coupon ? this.coupon.id : '',
  1459. addressId: this.address.addressId ? this.address.addressId : '',
  1460. orderType: this.orderType
  1461. }
  1462. this.$Request.post('/app/wxPay/wxPayJsApiOrder', data).then((res) => {
  1463. console.log(res,'wxaa')
  1464. this.showpay = false
  1465. if (res.code == 0) {
  1466. this.isCheckPay(res.code, 'wxpay', JSON.stringify(res.data))
  1467. } else {
  1468. this.isThrottle = true
  1469. }
  1470. })
  1471. // #endif
  1472. } else if (this.openWay == 3) {
  1473. // #ifdef H5
  1474. let data = {
  1475. type: 5,
  1476. parentId: this.dataList.parentId,
  1477. couponId: this.coupon ? this.coupon.id : '',
  1478. addressId: this.address.addressId ? this.address.addressId : '',
  1479. orderType: this.orderType
  1480. }
  1481. this.$Request.post('/app/wxPay/wxPayJsApiOrder', data).then((res) => {
  1482. this.showpay = false
  1483. this.isThrottle = true
  1484. const div = document.createElement('div')
  1485. div.innerHTML = res.data //此处form就是后台返回接收到的数据
  1486. document.body.appendChild(div)
  1487. document.forms[0].submit()
  1488. })
  1489. // #endif
  1490. // #ifdef APP
  1491. let data = {
  1492. type: 4,
  1493. parentId: this.dataList.parentId,
  1494. couponId: this.coupon ? this.coupon.id : '',
  1495. addressId: this.address.addressId ? this.address.addressId : '',
  1496. orderType: this.orderType
  1497. }
  1498. this.$Request.post('/app/wxPay/wxPayJsApiOrder', data).then((res) => {
  1499. this.showpay = false
  1500. this.setPayment('alipay', res.data)
  1501. })
  1502. // #endif
  1503. }
  1504. },
  1505. newPay(data) {
  1506. this.$Request.get('/app/order/get-pay-param', data).then((res) => {
  1507. console.log(res, '新支付')
  1508. if (res.code == 0) {
  1509. uni.requestPayment({
  1510. provider: 'wxpay',
  1511. timeStamp: res.timeStamp,
  1512. nonceStr: res.nonceStr,
  1513. package: res.packageStr,
  1514. signType: res.signType,
  1515. paySign: res.paySign,
  1516. success: (suc) => {
  1517. this.cancelPinDan()
  1518. uni.hideLoading()
  1519. this.$queue.showToast('支付成功')
  1520. setTimeout(() => {
  1521. this.isThrottle = true
  1522. uni.switchTab({
  1523. url: '/pages/order/index'
  1524. })
  1525. }, 1000)
  1526. },
  1527. fail: (err) => {
  1528. console.log('fail:' + JSON.stringify(err))
  1529. this.isThrottle = true
  1530. uni.setStorageSync('isClear', true)
  1531. uni.showToast({
  1532. title: '支付失败',
  1533. icon: 'none',
  1534. mask: true
  1535. })
  1536. setTimeout(() => {
  1537. uni.reLaunch({
  1538. url: '/pages/order/index'
  1539. })
  1540. }, 1500)
  1541. }
  1542. })
  1543. } else {
  1544. uni.showToast({
  1545. title: res.msg,
  1546. icon: 'none'
  1547. })
  1548. this.isThrottle = true
  1549. }
  1550. })
  1551. },
  1552. oldPay(data) {
  1553. this.$Request.post('/app/wxPay/wxPayJsApiOrder', data).then((res) => {
  1554. console.log(res, '旧支付')
  1555. // uni.hideLoading();
  1556. if (res.code == 0) {
  1557. uni.requestPayment({
  1558. provider: 'wxpay',
  1559. timeStamp: res.data.timestamp,
  1560. nonceStr: res.data.noncestr,
  1561. package: res.data.package,
  1562. signType: res.data.signType,
  1563. paySign: res.data.sign,
  1564. success: (suc) => {
  1565. this.cancelPinDan()
  1566. uni.hideLoading()
  1567. this.$queue.showToast('支付成功')
  1568. setTimeout(() => {
  1569. this.isThrottle = true
  1570. uni.switchTab({
  1571. url: '/pages/order/index'
  1572. })
  1573. }, 1000)
  1574. },
  1575. fail: (err) => {
  1576. console.log('fail:' + JSON.stringify(err))
  1577. this.isThrottle = true
  1578. uni.setStorageSync('isClear', true)
  1579. uni.showToast({
  1580. title: '支付失败',
  1581. icon: 'none',
  1582. mask: true
  1583. })
  1584. setTimeout(() => {
  1585. uni.reLaunch({
  1586. url: '/pages/order/index'
  1587. })
  1588. }, 1500)
  1589. }
  1590. })
  1591. } else {
  1592. uni.showToast({
  1593. title: res.msg,
  1594. icon: 'none'
  1595. })
  1596. this.isThrottle = true
  1597. }
  1598. })
  1599. },
  1600. callPay: function (response) {
  1601. if (typeof WeixinJSBridge === 'undefined') {
  1602. if (document.addEventListener) {
  1603. document.addEventListener('WeixinJSBridgeReady', this.onBridgeReady(response), false)
  1604. } else if (document.attachEvent) {
  1605. document.attachEvent('WeixinJSBridgeReady', this.onBridgeReady(response))
  1606. document.attachEvent('onWeixinJSBridgeReady', this.onBridgeReady(response))
  1607. }
  1608. } else {
  1609. this.onBridgeReady(response)
  1610. }
  1611. },
  1612. onBridgeReady: function (response) {
  1613. let that = this
  1614. if (!response.package) {
  1615. return
  1616. }
  1617. WeixinJSBridge.invoke(
  1618. 'getBrandWCPayRequest',
  1619. {
  1620. appId: response.appid, //公众号名称,由商户传入
  1621. timeStamp: response.timestamp, //时间戳,自1970年以来的秒数
  1622. nonceStr: response.noncestr, //随机串
  1623. package: response.package,
  1624. signType: response.signType, //微信签名方式:
  1625. paySign: response.sign //微信签名
  1626. },
  1627. function (res) {
  1628. if (res.err_msg === 'get_brand_wcpay_request:ok') {
  1629. // 使用以上方式判断前端返回,微信团队郑重提示:
  1630. //res.err_msg将在用户支付成功后返回ok,但并不保证它绝对可靠。
  1631. that.cancelPinDan()
  1632. that.$queue.showToast('支付成功')
  1633. setTimeout(function () {
  1634. uni.switchTab({
  1635. url: '/pages/order/index'
  1636. })
  1637. that.isThrottle = true
  1638. }, 1000)
  1639. } else {
  1640. uni.hideLoading()
  1641. that.isThrottle = true
  1642. }
  1643. WeixinJSBridge.log(response.err_msg)
  1644. }
  1645. )
  1646. },
  1647. isCheckPay(code, name, order) {
  1648. if (code == 0) {
  1649. console.log('999999999999')
  1650. this.setPayment(name, order)
  1651. } else {
  1652. uni.hideLoading()
  1653. uni.showToast({
  1654. title: '支付信息有误'
  1655. })
  1656. this.isThrottle = true
  1657. }
  1658. },
  1659. setPayment(name, order) {
  1660. console.log(777777777, name, order)
  1661. uni.requestPayment({
  1662. provider: name,
  1663. orderInfo: order, //微信、支付宝订单数据
  1664. success: (res) => {
  1665. uni.hideLoading()
  1666. this.cancelPinDan()
  1667. uni.showLoading({
  1668. title: '支付成功',
  1669. icon: 'none'
  1670. })
  1671. setTimeout(() => {
  1672. this.isThrottle = true
  1673. uni.navigateBack()
  1674. }, 1000)
  1675. },
  1676. fail: (err) => {
  1677. uni.hideLoading()
  1678. this.isThrottle = true
  1679. },
  1680. complete: () => {
  1681. this.isThrottle = true
  1682. uni.hideLoading()
  1683. }
  1684. })
  1685. },
  1686. // 获取选择的地址
  1687. getAddressDet(e) {
  1688. let data = {
  1689. addressId: e
  1690. }
  1691. this.$Request.get('/app/address/selectAddressById', data).then((res) => {
  1692. console.log(res, 77777777)
  1693. if (res.code == 0) {
  1694. this.address = res.data
  1695. if (this.address.insideAddressId) {
  1696. this.getInsideDeliveryFee(this.address.insideAddressId)
  1697. } else {
  1698. this.getInsideDeliveryFee(0)
  1699. }
  1700. if (JSON.stringify(this.address) != '{}') {
  1701. this.getDistance()
  1702. }
  1703. uni.removeStorageSync('addressId')
  1704. }
  1705. })
  1706. },
  1707. // 获取地址列表
  1708. getAddressList() {
  1709. let data = {
  1710. page: 1,
  1711. limit: 100
  1712. }
  1713. this.$Request.get('/app/address/selectAddressList', data).then((res) => {
  1714. console.log(res, 741852)
  1715. if (res.code == 0 && res.data.list.length) {
  1716. this.address = res.data.list[0]
  1717. res.data.list.forEach((ret) => {
  1718. if (ret.addressDefault == 1) {
  1719. this.address = ret
  1720. }
  1721. })
  1722. console.log(this.address, '我的地址列表460777')
  1723. if (this.address.insideAddressId) {
  1724. this.getInsideDeliveryFee(this.address.insideAddressId)
  1725. } else {
  1726. this.getInsideDeliveryFee(0)
  1727. }
  1728. if (JSON.stringify(this.address) != '{}') {
  1729. this.getDistance()
  1730. }
  1731. }
  1732. })
  1733. },
  1734. getInsideDeliveryFee(insideAddressId) {
  1735. this.$Request.get(`/app/inside-address/${insideAddressId}`).then((res) => {
  1736. console.log(res, 987456)
  1737. if (res.code == 0) {
  1738. this.address.insideDeliveryFee = res.data.deliveryFee || 0
  1739. }
  1740. })
  1741. },
  1742. goAddress() {
  1743. uni.navigateTo({
  1744. url: '/my/address/index?add=1'
  1745. })
  1746. },
  1747. // 点击调起地图查看位置
  1748. goMap() {
  1749. // let that = this
  1750. // let plugin = requirePlugin('routePlan');
  1751. // let key = 'A3RBZ-23MHW-PTPR5-RLCER-UJTXQ-JIF2G'; //使用在腾讯位置服务申请的key
  1752. // let referer = that.dataList.shopName; //调用插件的app的名称
  1753. // let endPoint = JSON.stringify({ //终点
  1754. // 'name': that.dataList.shopName,
  1755. // 'latitude': that.dataList.shopLat,
  1756. // 'longitude': that.dataList.shopLng,
  1757. // });
  1758. // wx.navigateTo({
  1759. // url: 'plugin://routePlan/index?key=' + key + '&referer=' + referer + '&endPoint=' + endPoint
  1760. // });
  1761. let lati = parseFloat(this.dataList.shopLat)
  1762. let longi = parseFloat(this.dataList.shopLng)
  1763. uni.authorize({
  1764. scope: 'scope.userLocation',
  1765. success: (res) => {
  1766. uni.openLocation({
  1767. name: this.dataList.shopName,
  1768. latitude: lati,
  1769. longitude: longi,
  1770. success: () => {}
  1771. })
  1772. },
  1773. fail: (err) => {}
  1774. })
  1775. },
  1776. // 打电话
  1777. call() {
  1778. uni.makePhoneCall({
  1779. phoneNumber: this.dataList.shopPhone
  1780. })
  1781. }
  1782. }
  1783. }
  1784. </script>
  1785. <style scoped>
  1786. .hintPopul {
  1787. width: 100%;
  1788. height: 100vh;
  1789. position: fixed;
  1790. top: 0;
  1791. background: rgba(0, 0, 0, 0.4);
  1792. z-index: 999;
  1793. }
  1794. .content_ {
  1795. position: absolute;
  1796. left: 0;
  1797. right: 0;
  1798. top: 0;
  1799. bottom: 0;
  1800. margin: auto;
  1801. text-align: center;
  1802. width: 500rpx;
  1803. height: 400rpx;
  1804. border-radius: 20rpx;
  1805. background-color: #fff;
  1806. padding-top: 120rpx;
  1807. }
  1808. .content_ image {
  1809. position: absolute;
  1810. top: -50rpx;
  1811. left: 0;
  1812. right: 0;
  1813. margin: auto;
  1814. }
  1815. .hintText {
  1816. font-size: 30rpx;
  1817. }
  1818. .Btns {
  1819. width: 460rpx;
  1820. height: 60rpx;
  1821. line-height: 60rpx;
  1822. text-align: center;
  1823. background: #fcd202;
  1824. font-size: 28rpx;
  1825. border: 2rpx solid #fcd202;
  1826. color: #333333;
  1827. border-radius: 50rpx;
  1828. font-weight: 700;
  1829. margin: auto;
  1830. }
  1831. .goods_address {
  1832. width: 94%;
  1833. background: #ffffff;
  1834. height: 120rpx;
  1835. margin: 20rpx auto 0;
  1836. border-radius: 18rpx;
  1837. }
  1838. .address_box {
  1839. width: 90%;
  1840. margin: 0 auto;
  1841. height: 120rpx;
  1842. display: flex;
  1843. line-height: 120rpx;
  1844. }
  1845. .address_name {
  1846. flex: 1;
  1847. font-size: 30rpx;
  1848. }
  1849. .address_image {
  1850. /* flex: 1; */
  1851. display: flex;
  1852. justify-content: flex-end;
  1853. align-items: center;
  1854. }
  1855. .address_image image {
  1856. width: 25rpx;
  1857. height: 40rpx;
  1858. }
  1859. .songda_image image {
  1860. width: 20rpx;
  1861. height: 30rpx;
  1862. margin-left: 20rpx;
  1863. }
  1864. /* 地址 */
  1865. .address {
  1866. width: 88%;
  1867. margin: 3% auto;
  1868. padding: 3%;
  1869. display: flex;
  1870. background-color: #ffffff;
  1871. border-radius: 18rpx;
  1872. }
  1873. .adderss_le {
  1874. width: 90%;
  1875. line-height: 1.5;
  1876. }
  1877. .adderss_le_text {
  1878. font-size: 30rpx;
  1879. font-weight: bold;
  1880. color: #333333;
  1881. }
  1882. .adderss_le_text2 {
  1883. font-size: 24rpx;
  1884. font-weight: 500;
  1885. color: #999999;
  1886. display: flex;
  1887. }
  1888. .adderss_le_text2 view {
  1889. margin-left: 2%;
  1890. }
  1891. .adderss_le_text2 view:first-child {
  1892. margin-left: 0;
  1893. }
  1894. .adderss_ri {
  1895. width: 10%;
  1896. text-align: right;
  1897. line-height: 3;
  1898. }
  1899. .adderss_ri image {
  1900. width: 18rpx;
  1901. height: 30rpx;
  1902. }
  1903. /* 商品 */
  1904. .food {
  1905. width: 94%;
  1906. margin: 3% auto;
  1907. padding: 3%;
  1908. background-color: #ffffff;
  1909. border-radius: 18rpx;
  1910. }
  1911. .food_top {
  1912. display: flex;
  1913. justify-content: space-between;
  1914. align-items: center;
  1915. font-size: 32rpx;
  1916. font-weight: bold;
  1917. }
  1918. .food_bottom {
  1919. margin-top: 20rpx;
  1920. color: #666666;
  1921. font-size: 28rpx;
  1922. line-height: 45rpx;
  1923. }
  1924. .bottom_text {
  1925. color: #ea0018;
  1926. }
  1927. .tosend_header_food {
  1928. width: 100%;
  1929. display: flex;
  1930. margin-top: 3%;
  1931. }
  1932. .tosend_header_food_le {
  1933. width: 15%;
  1934. }
  1935. .tosend_header_food_le image {
  1936. width: 110rpx;
  1937. height: 110rpx;
  1938. border-radius: 10rpx;
  1939. }
  1940. .tosend_header_food_ce {
  1941. margin: 0 0 0 4%;
  1942. width: 57%;
  1943. }
  1944. .tosend_header_food_ri {
  1945. text-align: right;
  1946. width: 25%;
  1947. }
  1948. .tosend_header_food_text {
  1949. font-size: 34rpx;
  1950. font-weight: 500;
  1951. color: #333333;
  1952. line-height: 1.8;
  1953. }
  1954. .tosend_header_food_text text {
  1955. font-size: 25rpx;
  1956. }
  1957. .tosend_header_food_text2 {
  1958. font-size: 28rpx;
  1959. font-weight: 500;
  1960. color: #999999;
  1961. }
  1962. .do_top {
  1963. padding-top: 3%;
  1964. }
  1965. .do_bot {
  1966. padding-bottom: 3%;
  1967. border-bottom: 2rpx solid #e6e6e6;
  1968. }
  1969. .tosend_header_do {
  1970. width: 100%;
  1971. color: #333333;
  1972. font-size: 30rpx;
  1973. display: flex;
  1974. margin-top: 20rpx;
  1975. line-height: 1.5;
  1976. }
  1977. .tosend_header_do view {
  1978. /* flex: 1; */
  1979. }
  1980. .tosend_header_do_ri {
  1981. text-align: right;
  1982. }
  1983. .tosend_header_do_le2 {
  1984. font-family: PingFang SC;
  1985. font-weight: 500;
  1986. color: #999999;
  1987. padding-top: 1.5%;
  1988. }
  1989. .tosend_header_do_ri2 {
  1990. text-align: right;
  1991. color: #ea0000;
  1992. font-size: 40rpx;
  1993. }
  1994. .tosend_header_do_ri2 text {
  1995. font-size: 30rpx;
  1996. }
  1997. /* 支付 */
  1998. /* .payment_all{
  1999. width: 88%;margin: 3% auto;padding: 3%;background-color: #FFFFFF;
  2000. border-radius: 18rpx;
  2001. }
  2002. .payment{
  2003. width: 100%;display: flex;margin-top: 3%;
  2004. }
  2005. .payment_le{
  2006. width: 13%;
  2007. }
  2008. .payment_le image{
  2009. width: 60rpx;height: 60rpx;
  2010. }
  2011. .payment_ce{
  2012. width: 52%;
  2013. font-size: 30rpx;
  2014. font-weight: bold;
  2015. color: #333333;line-height: 60rpx;
  2016. }
  2017. .payment_ri{
  2018. width: 35%;text-align: right;line-height: 60rpx;
  2019. } */
  2020. /* 结算 */
  2021. .goorder {
  2022. width: 100%;
  2023. padding: 2% 3%;
  2024. position: fixed;
  2025. bottom: 0;
  2026. background-color: #ffffff;
  2027. z-index: 999;
  2028. }
  2029. .goorder_but {
  2030. width: 100%;
  2031. line-height: 3.5;
  2032. text-align: center;
  2033. background: #fcd202;
  2034. border-radius: 36rpx;
  2035. font-weight: 700;
  2036. }
  2037. .goorder_but_ {
  2038. opacity: 0.5;
  2039. }
  2040. .bg {
  2041. background-color: #ffffff;
  2042. }
  2043. .tabBtn {
  2044. /* background-color: #f6f6fa; */
  2045. height: 60rpx;
  2046. line-height: 60rpx;
  2047. color: #999999;
  2048. font-size: 38rpx;
  2049. }
  2050. .active {
  2051. /* width: 82rpx; */
  2052. height: 6rpx;
  2053. background: #fcd202;
  2054. /* position: relative;
  2055. top: -20rpx; */
  2056. z-index: 9;
  2057. }
  2058. </style>