| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061 |
- <template>
- <view class="pages">
- <!-- 地址 -->
- <view class="text-center text-red" v-if="isTrue && orderType == 2">超出配送距离</view>
- <view class="food">
- <view class="flex bg justify-between padding-lr-xl">
- <view @click="switchTab(2)" :class="orderType == 2 ? 'select' : ''" class="tabBtn" v-if="XCXIsSelect == '是' && showReach != 1 && shopTypeName != '三大运营商'">
- <view class="title">外卖配送</view>
- <view :class="orderType == 2 ? 'active' : ''"></view>
- </view>
- <view @click="switchTab(1)" :class="orderType == 1 ? 'select' : ''" class="tabBtn" v-if="showReach != 2">
- <view class="title">到店自取</view>
- <view :class="orderType == 1 ? 'active' : ''"></view>
- </view>
- </view>
- <view v-if="orderType == 1">
- <view class="flex margin-top">
- <u-icon name="map" size="50"></u-icon>
- <!-- <text>商家信息</text> -->
- <view class="flex-sub padding-tb-sm margin-left-sm">
- <view class="text-lg text-bold text-black">
- <text>{{ dataList.shopName }}</text>
- <text class="margin-left-sm" @click="call"><u-icon name="phone" size="40"></u-icon></text>
- </view>
- <view class="text-df margin-top-xs" style="color: #999999" @click="goMap">
- {{ dataList.detailedAddress }}
- </view>
- </view>
- </view>
- <view class="flex margin-top" style="align-items: center">
- <view style="font-size: 32rpx; color: #333333; font-weight: bold">是否店内就餐?</view>
- <view style="margin-left: 140px; transform: scale(0.8)"><switch :checked="ispackType" @change="handleSwitchChange" color="#4cd964" /></view>
- </view>
- <view style="color: #ea0018">(店内就餐减免打包费)</view>
- <view class="flex margin-top" style="align-items: center" v-if="shopTypeName == '三大运营商'">
- <view>请填写身份证号:</view>
- <input type="idcard" v-model="idcard1" style="border: 1px solid" />
- </view>
- </view>
- <view class="" v-if="orderType == 2">
- <view class="goods_address" v-if="JSON.stringify(address) == '{}'" @click="goAddress">
- <view class="address_box">
- <view class="address_name">请选择收货地址</view>
- <view class="address_image margin-left">
- <image src="../../../static/images/index/right.png"></image>
- </view>
- </view>
- </view>
- <view class="flex margin-top" style="" v-else @click="goAddress">
- <u-icon name="map" size="50"></u-icon>
- <view class="flex-sub padding-tb-sm margin-left-sm">
- <view class="text-lg text-bold text-black">
- <text>{{ address.userName }}</text>
- <text class="margin-left-sm">{{ address.userPhone }}</text>
- </view>
- <view class="text-df margin-top-xs" style="color: #999999">{{ address.province }}{{ address.city }}{{ address.district }}{{ address.addressDetail }}</view>
- </view>
- <view class="address_image margin-left">
- <image src="../../../static/images/index/right.png"></image>
- </view>
- </view>
- <!-- 预约送达时间 -->
- <!-- <view class="goods_address" v-if="reservationOpenFlag==1">
- <view class="address_box">
- <view class="address_name">送达时间</view>
- <picker class='time-picker' mode="multiSelector" @change="bindStartMultiPickerChange"
- @columnchange="bindMultiPickerColumnChange" :range="data.multiArray">
- {{data.startDate}}
- </picker>
- <view class="songda_image">
- <image src="../../../static/images/index/right.png"></image>
- </view>
- </view>
- </view> -->
- </view>
- </view>
- <!-- 商品 -->
- <view class="food">
- <view class="tosend_header_food" v-for="(item, index) in dataList.orderGoodsList" :key="index">
- <view class="tosend_header_food_le">
- <image :src="item.goodsPicture[0]" style="border-radius: 10rpx" mode=""></image>
- </view>
- <view class="flex-sub margin-left-sm">
- <view class="flex justify-between align-center">
- <view class="text-lg text-bold text-black">{{ item.goodsName }}</view>
- <view class="text-lg text-bold text-black">
- <text class="text-sm">¥</text>
- {{ item.goodsPrice }}
- </view>
- </view>
- <view class="flex justify-between align-center text-gray">
- <view v-if="item.skuMessage">{{ item.skuMessage }}</view>
- <view>x{{ item.goodsNum }}</view>
- </view>
- <view class="flex justify-between align-center text-gray margin-tb-sm" v-if="item.goodsPack && packType == 1">
- <view>打包费</view>
- <view class="">¥{{ item.goodsPack }} / 份</view>
- </view>
- </view>
- </view>
- <!-- <view class="tosend_header_do do_top" v-if="item.goodsPack>0" >
- <view>打包费</view>
- <view class="tosend_header_do_ri">¥{{item.goodsPack}}</view>
- </view> -->
- <view class="tosend_header_do justify-between" v-if="paotuiMoney > 0 && orderType == 2">
- <view>跑腿费</view>
- <view class="tosend_header_do_ri">¥{{ paotuiMoney }}</view>
- </view>
- <view class="tosend_header_do justify-between" v-if="address.insideDeliveryFee && orderType == 2">
- <view>特殊地址跑腿费</view>
- <view class="tosend_header_do_ri">¥{{ address.insideDeliveryFee }}</view>
- </view>
- <view class="tosend_header_do justify-between" v-if="Vipmoney.canReduceFlag == '1'">
- <view>会员立减</view>
- <view class="tosend_header_do_ri">- ¥{{ Vipmoney.reduceAmount }}</view>
- </view>
- <view class="tosend_header_do justify-between do_bot" v-if="Vipmoney.canReduceFlag == '1'">
- <view>优惠券</view>
- <!-- <view class="tosend_header_do_ri" v-if="coupon">- ¥{{ coupon.money }}</view>
- <view v-else>
- <image src="../../../static/images/order/right1.png" style="width: 14rpx; height: 24rpx" mode=""></image>
- </view> -->
- </view>
- <view class="tosend_header_do justify-between do_bot" @click="isShow" v-if="Vipmoney.canReduceFlag == '0'">
- <view>优惠券</view>
- <view class="tosend_header_do_ri" v-if="coupon">- ¥{{ coupon.money }}</view>
- <view v-else>
- <image src="../../../static/images/order/right1.png" style="width: 14rpx; height: 24rpx" mode=""></image>
- </view>
- </view>
- <view class="tosend_header_do justify-between do_bot" v-if="Vipmoney.canReduceFlag == '1'">
- <view>优惠活动</view>
- <!-- <view class="tosend_header_do_ri" v-if="huodong">- ¥{{ huodong.discountAmount }}</view>
- <view v-else>
- <image src="../../../static/images/order/right1.png" style="width: 14rpx; height: 24rpx" mode=""></image>
- </view> -->
- </view>
- <view class="tosend_header_do justify-between do_bot" @click="huodongShow" v-if="Vipmoney.canReduceFlag == '0'">
- <view>优惠活动</view>
- <view class="tosend_header_do_ri" v-if="huodong">- ¥{{ huodong.discountAmount }}</view>
- <view v-else>
- <image src="../../../static/images/order/right1.png" style="width: 14rpx; height: 24rpx" mode=""></image>
- </view>
- </view>
- <view class="tosend_header_do justify-between">
- <view class="tosend_header_do_le2">合计</view>
- <view class="tosend_header_do_ri2">
- <text>¥</text>
- {{ totalPrice12 }}
- </view>
- </view>
- </view>
- <!-- 积分介绍 -->
- <view class="food" v-if="isIntegral">
- <view class="food_top">
- <view class="">获取积分</view>
- <view class="">{{ intergral }}</view>
- </view>
- <view class="food_bottom">
- 实付满{{ ruleAmount1 }}元得
- <text class="bottom_text">{{ ruleValue1 }}分</text>
- ,超过{{ ruleMaxAmount }}元部分,每满{{ ruleAmount2 }}元得
- <text class="bottom_text">{{ ruleValue2 }}分</text>
- ;每笔订单上限
- <text class="bottom_text">{{ maxIntegral }}分</text>
- </view>
- </view>
- <!-- 订单备注 -->
- <view class="food">
- <view class="padding-tb-sm text-lg text-bold text-bold text-black">订单备注</view>
- <view class="flex align-center justify-between padding-tb-sm padding-lr" style="background: #f5f5f5; width: 100%">
- <u-input v-model="remark" type="textarea" placeholder="请输入订单备注" height="180" maxlength="200" style="width: 100%"></u-input>
- </view>
- </view>
- <!-- 支付方式 -->
- <view class="margin-top padding-lr radius bg-white" style="width: 94%; margin: 0 auto; border-radius: 18rpx">
- <view class="padding-tb-sm text-lg text-bold text-bold text-black">支付方式</view>
- <view style="height: 100upx" v-for="(item, index) in openLists" :key="index">
- <view class="flex align-center justify-between padding-tb" v-if="item.text != '零钱'">
- <image :src="item.image" style="width: 55rpx; height: 55rpx; border-radius: 50upx"></image>
- <view class="flex-sub text-xl margin-left">{{ item.text }}</view>
- <radio-group name="openWay" style="margin-left: 20upx" @change="selectWay(item)">
- <label class="tui-radio">
- <radio class="red" :checked="openWay === item.id ? true : false" />
- </label>
- </radio-group>
- </view>
- <view class="flex align-center justify-between padding-tb" v-if="item.text === '零钱'">
- <image :src="item.image" style="width: 55rpx; height: 55rpx; border-radius: 50upx"></image>
- <view class="flex-sub text-xl margin-left">
- {{ item.text }}
- <text style="font-size: 30rpx; margin-left: 10rpx" v-if="userMoney && userMoney > 0">(余额:{{ userMoney }})</text>
- <!-- <text v-else style="font-size: 30rpx; margin-left: 10rpx; text-decoration: underline; color: #ea0000" @tap="goCash()">去充值</text> -->
- </view>
- <radio-group name="openWay" style="margin-left: 20upx" @change="selectWay(item)">
- <label class="tui-radio">
- <radio class="red" :checked="openWay === item.id ? true : false" />
- </label>
- </radio-group>
- </view>
- </view>
- </view>
- <view style="height: 120rpx"></view>
- <!-- 结算 -->
- <view class="goorder">
- <view class="goorder_but" :class="isTrue && orderType == 2 ? 'goorder_but_' : ''" @click="toSettlement">立即结算</view>
- </view>
- <u-popup
- v-model="show"
- mode="center"
- :closeable="true"
- close-icon-pos="top-right"
- close-icon="close-circle"
- close-icon-size="50"
- border-radius="20"
- width="80%"
- @close="close"
- >
- <view class="padding bg-gray">
- <view class="text-center text-lg text-bold margin-bottom-sm">可用优惠券</view>
- <scroll-view scroll-y="true" style="height: 600rpx" v-if="couponList.length > 0">
- <view
- class="flex justify-between align-center radius margin-tb-sm padding-sm bg-white"
- v-for="(item, index) in couponList"
- :key="index"
- @click="selCoupon(item)"
- >
- <view>
- <view>{{ item.couponName }}</view>
- <view>有效期至{{ item.expirationTime }}</view>
- </view>
- <view class="text-sm text-bold">
- ¥
- <text class="text-lg">{{ item.money }}</text>
- </view>
- </view>
- </scroll-view>
- <view v-if="couponList.length == 0" style="height: 100rpx; line-height: 100rpx; text-align: center; font-weight: 700">暂无可用优惠券</view>
- </view>
- </u-popup>
- <!-- 选择优惠活动 -->
- <u-popup
- v-model="youhui"
- mode="center"
- :closeable="true"
- close-icon-pos="top-right"
- close-icon="close-circle"
- close-icon-size="50"
- border-radius="20"
- width="80%"
- @close="closeYouhui()"
- >
- <view class="padding bg-gray">
- <view class="text-center text-lg text-bold margin-bottom-sm">可用优惠活动</view>
- <scroll-view scroll-y="true" style="height: 600rpx" v-if="huoList.length > 0">
- <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)">
- <view>
- <view>{{ item.activityTitle }}</view>
- <view>有效期至{{ item.activityEndTime }}</view>
- </view>
- <!-- <view class="text-sm text-bold">
- ¥
- <text class="text-lg" v-if="item.activityType=='2'">{{ item.money }}</text>
- <text class="text-lg" v-if="item.activityType=='2'">{{ item.money }}</text>
- <text class="text-lg" v-if="item.activityType=='4'">全场打{{ item.discountAmount }}折</text>
- </view> -->
- </view>
- </scroll-view>
- <view v-if="huoList.length == 0" style="height: 100rpx; line-height: 100rpx; text-align: center; font-weight: 700">暂无可用优惠活动</view>
- </view>
- </u-popup>
- <view class="hintPopul" v-if="shopDet && shopDet.putawayFlag == 1">
- <view class="content_">
- <image src="../../../static/images/index/shop.png" style="width: 200rpx; height: 180rpx"></image>
- <view class="text-xl text-bold">店铺打烊啦</view>
- <view class="hintText margin-top-sm text-gray">现在店铺已经打烊了,营业时间</view>
- <view class="margin-top-xs text-gray margin-bottom">{{ shopDet.businessHours }}-{{ shopDet.lockHours }}</view>
- <view class="Btns" @click="goBack()">知道了</view>
- </view>
- </view>
- </view>
- </template>
- <script>
- /**
- * 获取任意时间
- */
- function getDate(date, AddDayCount = 0) {
- if (!date) {
- date = new Date()
- }
- if (typeof date !== 'object') {
- date = date.replace(/-/g, '/')
- }
- const dd = new Date(date)
- dd.setDate(dd.getDate() + AddDayCount) // 获取AddDayCount天后的日期
- var a = new Array('日', '一', '二', '三', '四', '五', '六')
- var week = new Date().getDay()
- var week2 = new Date().getDay() + 1
- const y = dd.getFullYear()
- const m = dd.getMonth() + 1 < 10 ? '0' + (dd.getMonth() + 1) : dd.getMonth() + 1 // 获取当前月份的日期,不足10补0
- const d = dd.getDate() < 10 ? '0' + dd.getDate() : dd.getDate() // 获取当前几号,不足10补0
- const h = dd.getHours() < 10 ? '0' + dd.getHours() : dd.getHours()
- const f = dd.getMinutes() < 10 ? '0' + dd.getMinutes() : dd.getMinutes()
- const s = dd.getSeconds() < 10 ? '0' + dd.getSeconds() : dd.getSeconds()
- return {
- fullDate: y + '-' + m + '-' + d,
- fullDate2: y + '-' + m + '-' + d + ' ' + h + ':' + f + ':' + s,
- fullTime: m + '月' + d + '日',
- year: y,
- month: m,
- date: d,
- day: dd.getDay(),
- sWeek: '周' + a[week],
- eWeek: '周' + a[week2]
- }
- }
- export default {
- data() {
- return {
- userMoney: 0,
- storeCommodityId: 0,
- openLists: [
- {
- image: '../../../static/images/my/weixin.png',
- text: '微信',
- id: 2
- }
- // {
- // image: '../../../static/images/my/zhifubao.png',
- // text: '支付宝',
- // id: 3
- // },
- // {
- // image: '../../../static/images/my/jinbi.png',
- // text: '零钱',
- // id: 1
- // }
- ],
- openWay: 2,
- hintShow: true,
- page: 1,
- limit: 100,
- dataList: {},
- packMoney: 0, //打包费
- totalPrice: 0,
- totalPrice1: 0,
- totalPrice12: 0,
- address: {
- insideDeliveryFee: 0
- }, //地址
- addressId: '',
- parentId: '',
- orderId: '',
- show: false,
- youhui: false, //优惠活动
- coupon: '',
- shopDet: '',
- huodong: '', //选择的活动信息
- Vipmoney: {
- canReduceFlag: '0',
- reduceAmount: 0,
- vipReduceDesc: ''
- }, //会员立减金额
- couponList: [],
- huoList: [], //可用活动
- orderType: 2, //1表示到店自取 2表示外卖配送
- paotuiMoney: 0,
- dabaoMoney: 0,
- goodsMoney: 0,
- distance: 0,
- isTrue: false,
- XCXIsSelect: '是',
- remark: '',
- GoodsorderId: '',
- isThrottle: true,
- lng: '',
- lat: '',
- data: {
- multiArray: [],
- warning: '',
- startDate: '请选择'
- },
- workStart: '', //骑手上班时间
- workEnd: '', //骑手下班时间
- yusongTime: '', //骑手预计送达时长
- reservationFlag: 0, //是否预约单 1是、0否
- expectDeliveryTime: '', //预约送达时间
- timer: '', //定时器
- autoSendOrder: 0, //autoSendOrder为1商家自配,0平台配送
- ifPaotui: 0, //是否满减
- reservationOpenFlag: 0, //1预约,0不预约
- shopId: '',
- showReach: null,
- // 基础实付满多少
- ruleAmount1: 0,
- // 基础实付满多少送的积分
- ruleValue1: 0,
- // 超过多少
- ruleMaxAmount: 0,
- // 第二阶段实付满多少
- ruleAmount2: 0,
- // 第二阶段实付满多少送的积分
- ruleValue2: 0,
- // 每笔订单获取的积分上限
- maxIntegral: 0,
- // 可获得积分
- intergral: 0,
- // 是否显示积分模块
- isIntegral: false,
- shopTypeName: '', //店铺类型
- idcard1: '', //身份证号
- packType: 1, //堂食0,到店外卖打包1
- ispackType: false
- }
- },
- onLoad(option) {
- this.shopTypeName = option.shopTypeName
- if (option.showReach) {
- this.showReach = option.showReach
- }
- // #ifdef MP-WEIXIN
- this.XCXIsSelect = this.$queue.getData('XCXIsSelect') ? this.$queue.getData('XCXIsSelect') : '是'
- // #endif
- this.shopId = option.shopId
- if (option.shopTypeName == '三大运营商') {
- this.orderType = 1
- } else {
- this.orderType = option.orderType
- }
- if (option.orderId) {
- this.orderId = option.orderId
- }
- uni.showLoading({
- title: '加载中...',
- mask: true // 是否显示透明蒙层,防止触摸穿透
- })
- //获取店铺信息
- uni.getLocation({
- type: 'gcj02', //返回可以用于uni.openLocation的经纬度
- success: (res) => {
- // console.log(res, '经纬度')
- this.lat = res.latitude
- this.lng = res.longitude
- }
- })
- this.getAddressList()
- // this.getQishou()
- },
- onUnload() {
- // 页面销毁时清除定时器
- if (this.timer) {
- clearInterval(this.timer)
- }
- },
- onShow() {
- this.getMsgData()
- this.addressId = this.addressId ? this.addressId : uni.getStorageSync('addressId')
- if (this.addressId) {
- this.getAddressDet(this.addressId)
- }
- this.getShopDet(this.shopId)
- // 设置定时器
- this.timer = setInterval(() => {
- // 定时器执行的操作
- // this.getQishou()
- // console.log('每分钟执行一次');
- // 这里可以放置你需要每分钟执行的代码
- this.getCouponList()
- this.getHuoList()
- }, 60 * 1000) // 60 * 1000 毫秒代表一分钟
- },
- watch: {
- totalPrice1() {
- this.getIntegralRules()
- }
- },
- methods: {
- // 开关状态变化时触发
- handleSwitchChange(e) {
- this.ispackType = e.detail.value // 更新状态
- console.log('开关状态:', this.ispackType)
- // 可在此处添加业务逻辑(如保存状态到缓存、调用接口等)
- if (this.ispackType) {
- this.packType = 0
- } else {
- this.packType = 1
- }
- console.log('堂食或:packType', this.packType)
- if (this.orderType == 2) {
- this.totalPrice1 = parseFloat(this.totalPrice + this.paotuiMoney + this.dabaoMoney + this.address.insideDeliveryFee).toFixed(2)
- } else {
- if (this.packType == 1) {
- this.totalPrice1 = parseFloat(parseFloat(this.totalPrice) + parseFloat(this.dabaoMoney)).toFixed(2)
- } else {
- this.totalPrice1 = parseFloat(this.totalPrice).toFixed(2)
- }
- }
- this.getvipMoney()
- let totalMoney = 0
- if (this.Vipmoney.canReduceFlag == '1') {
- totalMoney = parseFloat(this.totalPrice1 - (this.Vipmoney.reduceAmount ? this.Vipmoney.reduceAmount : 0)).toFixed(2)
- } else {
- 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)
- }
- if (totalMoney <= 0) {
- this.totalPrice12 = 0.01
- } else {
- this.totalPrice12 = totalMoney
- }
- },
- //获取会员立减金额
- getvipMoney() {
- let data = {
- // shopId: this.shopId,
- userId: uni.getStorageSync('userId')
- // originalPrice:this.totalPrice1
- }
- this.$Request.get(`/app/vip/get-can-reduce/${this.dataList.orderId}`, data).then((res) => {
- console.log(res, '会员立减')
- if (res.code == 0 && res.data) {
- this.Vipmoney = res.data
- let totalMoney = 0
- if (this.Vipmoney.canReduceFlag == '1') {
- totalMoney = parseFloat(this.totalPrice1 - (this.Vipmoney.reduceAmount ? this.Vipmoney.reduceAmount : 0)).toFixed(2)
- } else {
- 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)
- }
- if (totalMoney <= 0) {
- this.totalPrice12 = 0.01
- } else {
- this.totalPrice12 = totalMoney
- }
- this.getCouponList()
- }
- })
- },
- getIntegralRules() {
- let data = {
- money: this.totalPrice12
- }
- this.$Request.get('/app/userintegral/getIntegralByMoney', data).then((res) => {
- console.log(res, '999')
- if (res.code == 0) {
- this.intergral = res.data.intergral
- this.maxIntegral = res.data.maxIntegral
- this.ruleAmount1 = res.data.ruleAmount1
- this.ruleAmount2 = res.data.ruleAmount2
- this.ruleMaxAmount = res.data.ruleMaxAmount
- this.ruleValue1 = res.data.ruleValue1
- this.ruleValue2 = res.data.ruleValue2
- if (res.data.flag == 1) {
- this.isIntegral = true
- } else {
- this.isIntegral = false
- }
- }
- })
- },
- //获取骑手上下班时间
- getQishou() {
- this.$Request.get('/app/tbindent/work-time').then((res) => {
- if (res.code == 0 && res.data) {
- if (this.orderType == 2) {
- if (this.autoSendOrder == 0) {
- //0是平台配
- this.workStart = parseInt(res.data.workingHoursOfRider.substring(0, 2))
- this.workStartMin = parseInt(res.data.workingHoursOfRider.substring(3, 5))
- this.workEnd = parseInt(res.data.workingHoursOfRider.substring(6, 8))
- } else if (this.autoSendOrder == 1) {
- this.workStart = parseInt(this.shopDet.businessHours.substring(0, 2))
- this.workStartMin = parseInt(this.shopDet.businessHours.substring(3, 5))
- this.workEnd = parseInt(this.shopDet.lockHours.substring(0, 2))
- }
- } else if (this.orderType == 1) {
- this.workStart = parseInt(this.shopDet.businessHours.substring(0, 2))
- this.workStartMin = parseInt(this.shopDet.businessHours.substring(3, 5))
- this.workEnd = parseInt(this.shopDet.lockHours.substring(0, 2))
- }
- this.yusongTime = res.data.timeOfRider
- var date = new Date()
- var currentHours = date.getHours()
- var currentMinute = date.getMinutes()
- var temp = []
- // currentHours = 12;
- var temp_time = []
- //如果当前时间大于20点
- var minite = parseInt(this.yusongTime - parseInt(this.yusongTime / 60) * 60)
- if (parseInt(this.yusongTime / 60) == 0) {
- var h1 = 0
- var h2 = parseInt(this.yusongTime - parseInt(this.yusongTime / 60) * 60)
- } else {
- var h1 = parseInt(this.yusongTime / 60)
- var h2 = parseInt(this.yusongTime - parseInt(this.yusongTime / 60) * 60)
- }
- var acc = currentHours + h1
- var bcc = currentMinute + h2
- var teshu = this.workStart + h1
- if (bcc >= 60) {
- var b = bcc - 60
- var a = acc + 1
- } else {
- var b = bcc
- var a = acc
- }
- var a1 = a + 1
- var s1 = a.toString()
- var s2 = a1.toString()
- var e1 = b.toString()
- var cc = (this.workStartMin + h2).toString()
- if (currentHours >= this.workEnd - h1) {
- // this.$queue.setData({
- // warning:'当前时间段不在服务范围,现在下单,最早将于明早8点上门安装',
- // startDate:'明早 | 8:00-10:00'
- // })
- var time2 = teshu + 1
- uni.showModal({
- title: '提示',
- content: '当前时间段无骑手配送,现在下单,最早将于明日' + teshu + ':00' + '送达',
- success: function (res) {
- if (res.confirm) {
- } else if (res.cancel) {
- }
- }
- })
- // this.data.startDate = '明早 | '+a + ':'+b + '-' + a1 + ':'+b
- temp[0] = ['明天']
- temp[1] = []
- for (let i = teshu; i < this.workEnd - h1; ) {
- var i1 = i + 1
- var ss1 = i.toString()
- var ss2 = i1.toString()
- temp[1].push(ss1.padStart(2, 0) + ':' + cc.padStart(2, 0) + '-' + ss2.padStart(2, 0) + ':' + cc.padStart(2, 0))
- i += 1
- }
- } else if (currentHours < this.workStart) {
- // this.$queue.setData({
- // warning:'当前时间段不在服务范围,现在下单,最早将于今早8点上门安装',
- // startDate:'明早 | 8:00-10:00'
- // })
- var time2 = teshu + 1
- uni.showModal({
- title: '提示',
- content: '当前时间段无骑手配送,现在下单,最早将于今日' + teshu + ':00' + '送达',
- success: function (res) {
- if (res.confirm) {
- } else if (res.cancel) {
- }
- }
- })
- temp[0] = ['今天', '明天']
- temp[1] = []
- for (let i = teshu; i < this.workEnd - h1; ) {
- var i1 = i + 1
- var ss1 = i.toString()
- var ss2 = i1.toString()
- temp[1].push(ss1.padStart(2, 0) + ':' + cc.padStart(2, 0) + '-' + ss2.padStart(2, 0) + ':' + cc.padStart(2, 0))
- i += 1
- }
- } else {
- // this.$queue.setData({
- // startDate:'尽快送达 | 两小时内'
- // })
- // this.data.startDate = '尽快送达 | 两小时内'
- // this.data.startDate = s1.padStart(2,0) + ':'+e1.padStart(2,0) + '-' + s2.padStart(2,0) + ':'+e1.padStart(2,0)
- temp[0] = ['今天', '明天']
- temp[1] = []
- for (let i = a; i < this.workEnd - h1; ) {
- var i1 = i + 1
- var ss1 = i.toString()
- var ss2 = i1.toString()
- temp[1].push(ss1.padStart(2, 0) + ':' + e1.padStart(2, 0) + '-' + ss2.padStart(2, 0) + ':' + e1.padStart(2, 0))
- i += 1
- }
- }
- // this.$queue.setData({
- // multiArray:temp,
- // })
- this.data.multiArray = temp
- if (this.data.warning != '') {
- wx.showToast({
- title: this.data.warning,
- icon: 'none',
- duration: 3000
- })
- }
- }
- })
- },
- bindMultiPickerColumnChange: function (e) {
- let c = e.detail.column
- let v = e.detail.value
- var time = []
- var date = new Date()
- console.log(date)
- var date = new Date()
- var currentHours = date.getHours()
- var currentMinute = date.getMinutes()
- var minite = parseInt(this.yusongTime - parseInt(this.yusongTime / 60) * 60)
- if (parseInt(this.yusongTime / 60) == 0) {
- var h2 = parseInt(this.yusongTime - parseInt(this.yusongTime / 60) * 60)
- } else {
- var h1 = parseInt(this.yusongTime / 60)
- var h2 = parseInt(this.yusongTime - parseInt(this.yusongTime / 60) * 60)
- }
- var acc = currentHours + h1
- var bcc = currentMinute + h2
- var teshu = this.workStart + h1
- if (bcc >= 60) {
- var b = bcc - 60
- var a = acc + 1
- } else {
- var b = bcc
- var a = acc
- }
- var a1 = a + 1
- var s1 = a.toString()
- var s2 = a1.toString()
- var e1 = b.toString()
- var cc = (this.workStartMin + h2).toString()
- // console.log(this.workStartMin,h2,'kkk')
- var temp = this.data.multiArray
- // currentHours = 12;
- if (c == 0) {
- if (temp[c][v] == '今天') {
- temp[1] = []
- for (let i = a; i < this.workEnd - h1; ) {
- var i1 = i + 1
- var ss1 = i.toString()
- var ss2 = i1.toString()
- temp[1].push(ss1.padStart(2, 0) + ':' + e1.padStart(2, 0) + '-' + ss2.padStart(2, 0) + ':' + e1.padStart(2, 0))
- i += 1
- }
- } else {
- temp[1] = []
- for (let i = teshu; i < this.workEnd - h1; ) {
- var i1 = i + 1
- var ss1 = i.toString()
- var ss2 = i1.toString()
- temp[1].push(ss1.padStart(2, 0) + ':' + cc.padStart(2, 0) + '-' + ss2.padStart(2, 0) + ':' + cc.padStart(2, 0))
- i += 1
- }
- }
- // this.$queue.setData({
- // multiArray:temp
- // })
- this.data.multiArray = temp
- this.$forceUpdate()
- }
- },
- bindStartMultiPickerChange: function (e) {
- let temp = this.data.multiArray
- // this.$queue.setData({
- // startDate:temp[0][e.detail.value[0]]+' | '+temp[1][e.detail.value[1]]
- // })
- this.data.startDate = temp[0][e.detail.value[0]] + ' | ' + temp[1][e.detail.value[1]]
- if (this.data.startDate) {
- this.reservationFlag = 1
- if (temp[0][e.detail.value[0]] == '今天') {
- var date = getDate(new Date()).fullDate
- this.expectDeliveryTime = date + ' ' + temp[1][e.detail.value[1]].substring(0, 5) + ':00'
- } else if (temp[0][e.detail.value[0]] == '明天') {
- var date = getDate(new Date(), 1).fullDate
- this.expectDeliveryTime = date + ' ' + temp[1][e.detail.value[1]].substring(0, 5) + ':00'
- } else if (temp[0][e.detail.value[0]] == '后天') {
- var date = getDate(new Date(), 2).fullDate
- this.expectDeliveryTime = date + ' ' + temp[1][e.detail.value[1]].substring(0, 5) + ':00'
- }
- }
- },
- goCash() {
- uni.navigateTo({
- url: '/my/wallet/index'
- })
- },
- getMsgData() {
- this.$Request.get('/app/userintegral/findUserMessage').then((res) => {
- if (res.code == 0 && res.data) {
- this.userMoney = res.data.userMoney ? res.data.userMoney : 0
- }
- })
- },
- //获取店铺详情
- getShopDet(shopId) {
- let data = {
- shopId,
- lng: this.lng,
- lat: this.lat
- }
- this.$Request.get('/app/goods/selectGoodsList', data).then((res) => {
- console.log(res, 'data')
- if (res.code == 0 && res.data) {
- this.reservationOpenFlag = res.data.goodsShop.reservationOpenFlag
- this.autoSendOrder = res.data.goodsShop.autoSendOrder
- this.shopDet = res.data.goodsShop
- this.ifPaotui = res.data.goodsShop.enableFullReductionFlag
- this.getOrderList()
- // this.getQishou()
- }
- })
- },
- goBack() {
- uni.navigateBack({})
- },
- isShow() {
- this.show = true
- },
- //选择优惠活动弹框
- huodongShow() {
- this.youhui = true
- },
- getDistance() {
- if (this.address.lng && this.dataList.shopLng) {
- let data = {
- ol: this.address.lng,
- od: this.address.lat,
- dl: this.dataList.shopLng,
- dd: this.dataList.shopLat
- }
- this.$Request.post('/app/tbindent/distance', data).then((res) => {
- // console.log(res, '963')
- if (res.code == 0) {
- this.distance = res.data
- if (this.distance > Number(this.dataList.distributionDistance)) {
- this.isTrue = true
- } else {
- this.isTrue = false
- }
- }
- })
- }
- },
- close() {
- this.show = false
- },
- closeYouhui() {
- this.youhui = false
- },
- switchTab(e) {
- // this.page = 1
- // this.status = ''
- this.coupon = ''
- this.huodong = ''
- this.orderType = e
- // this.current = 0;
- console.log(e)
- if (JSON.stringify(this.address) != '{}') {
- this.getDistance()
- }
- if (this.orderType == 2) {
- this.packType = 1
- this.ispackType = false
- this.totalPrice1 = parseFloat(this.totalPrice + this.paotuiMoney + this.dabaoMoney + this.address.insideDeliveryFee).toFixed(2)
- this.getvipMoney()
- } else {
- this.packType = 1
- this.ispackType = false
- if (this.packType == 1) {
- this.totalPrice1 = parseFloat(parseFloat(this.totalPrice) + parseFloat(this.dabaoMoney)).toFixed(2)
- } else {
- this.totalPrice1 = parseFloat(this.totalPrice).toFixed(2)
- }
- this.getvipMoney()
- }
- let totalMoney = 0
- if (this.Vipmoney.canReduceFlag == '1') {
- totalMoney = parseFloat(this.totalPrice1 - (this.Vipmoney.reduceAmount ? this.Vipmoney.reduceAmount : 0)).toFixed(2)
- } else {
- 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)
- }
- if (totalMoney <= 0) {
- this.totalPrice12 = 0.01
- } else {
- this.totalPrice12 = totalMoney
- }
- if (this.coupon) {
- if (this.orderType == 2) {
- this.totalPrice1 = parseFloat(this.totalPrice + this.paotuiMoney + this.dabaoMoney + this.address.insideDeliveryFee).toFixed(2)
- } else {
- if (this.packType == 1) {
- this.totalPrice1 = parseFloat(parseFloat(this.totalPrice) + parseFloat(this.dabaoMoney)).toFixed(2)
- } else {
- this.totalPrice1 = parseFloat(this.totalPrice).toFixed(2)
- }
- }
- let totalMoney = 0
- if (this.Vipmoney.canReduceFlag == '1') {
- totalMoney = parseFloat(this.totalPrice1 - (this.Vipmoney.reduceAmount ? this.Vipmoney.reduceAmount : 0)).toFixed(2)
- } else {
- 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)
- }
- if (totalMoney <= 0) {
- this.totalPrice12 = 0.01
- } else {
- this.totalPrice12 = totalMoney
- }
- }
- if (this.huodong) {
- if (this.orderType == 2) {
- this.totalPrice1 = parseFloat(this.totalPrice + this.paotuiMoney + this.dabaoMoney + this.address.insideDeliveryFee).toFixed(2)
- } else {
- if (this.packType == 1) {
- this.totalPrice1 = parseFloat(parseFloat(this.totalPrice) + parseFloat(this.dabaoMoney)).toFixed(2)
- } else {
- this.totalPrice1 = parseFloat(this.totalPrice).toFixed(2)
- }
- }
- let totalMoney = 0
- if (this.Vipmoney.canReduceFlag == '1') {
- totalMoney = parseFloat(this.totalPrice1 - (this.Vipmoney.reduceAmount ? this.Vipmoney.reduceAmount : 0)).toFixed(2)
- } else {
- 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)
- }
- if (totalMoney <= 0) {
- this.totalPrice12 = 0.01
- } else {
- this.totalPrice12 = totalMoney
- }
- }
- if (this.Vipmoney.canReduceFlag == '1') {
- if (this.orderType == 2) {
- this.totalPrice1 = parseFloat(this.totalPrice + this.paotuiMoney + this.dabaoMoney + this.address.insideDeliveryFee).toFixed(2)
- } else {
- if (this.packType == 1) {
- this.totalPrice1 = parseFloat(parseFloat(this.totalPrice) + parseFloat(this.dabaoMoney)).toFixed(2)
- } else {
- this.totalPrice1 = parseFloat(this.totalPrice).toFixed(2)
- }
- }
- let totalMoney = 0
- if (this.Vipmoney.canReduceFlag == '1') {
- totalMoney = parseFloat(this.totalPrice1 - (this.Vipmoney.reduceAmount ? this.Vipmoney.reduceAmount : 0)).toFixed(2)
- } else {
- 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)
- }
- if (totalMoney <= 0) {
- this.totalPrice12 = 0.01
- } else {
- this.totalPrice12 = totalMoney
- }
- }
- },
- // 删除优惠券
- detCoupon() {
- let data = {
- orderId: this.dataList.orderId
- }
- this.$Request.post('/app/order/deleteCouponByOrderId', data).then((res) => {
- if (res.code == 0) {
- }
- })
- },
- // 选择优惠券
- selCoupon(item) {
- this.coupon = item
- if (this.orderType == 2) {
- this.totalPrice1 = parseFloat(this.totalPrice + this.paotuiMoney + this.dabaoMoney + this.address.insideDeliveryFee).toFixed(2)
- } else {
- if (this.packType == 1) {
- this.totalPrice1 = parseFloat(parseFloat(this.totalPrice) + parseFloat(this.dabaoMoney)).toFixed(2)
- } else {
- this.totalPrice1 = parseFloat(this.totalPrice).toFixed(2)
- }
- }
- let totalMoney = 0
- if (this.Vipmoney.canReduceFlag == '1') {
- totalMoney = parseFloat(this.totalPrice1 - (this.Vipmoney.reduceAmount ? this.Vipmoney.reduceAmount : 0)).toFixed(2)
- } else {
- 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)
- }
- if (totalMoney <= 0) {
- this.totalPrice12 = 0.01
- } else {
- this.totalPrice12 = totalMoney
- }
- let data = {
- parentId: this.dataList.parentId,
- couponId: this.coupon ? this.coupon.id : ''
- }
- this.$Request.post('/app/order/employCoupon', data).then((res) => {
- if (res.code == 0) {
- this.show = false
- } else {
- this.$queue.showToast(res.msg)
- }
- })
- },
- //选择活动activityId
- selctHuo(item) {
- this.huodong = item
- if (this.orderType == 2) {
- this.totalPrice1 = parseFloat(this.totalPrice + this.paotuiMoney + this.dabaoMoney + this.address.insideDeliveryFee).toFixed(2)
- } else {
- if (this.packType == 1) {
- this.totalPrice1 = parseFloat(parseFloat(this.totalPrice) + parseFloat(this.dabaoMoney)).toFixed(2)
- } else {
- this.totalPrice1 = parseFloat(this.totalPrice).toFixed(2)
- }
- }
- let totalMoney = 0
- if (this.Vipmoney.canReduceFlag == '1') {
- totalMoney = parseFloat(this.totalPrice1 - (this.Vipmoney.reduceAmount ? this.Vipmoney.reduceAmount : 0)).toFixed(2)
- } else {
- 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)
- }
- if (totalMoney <= 0) {
- this.totalPrice12 = 0.01
- } else {
- this.totalPrice12 = totalMoney
- }
- this.youhui = false
- },
- // 获取优惠券列表
- getCouponList() {
- console.log(this.totalPrice)
- console.log(this.dataList.shopId)
- let minMoney =
- this.orderType == 2
- ? parseFloat(parseFloat(this.totalPrice) + parseFloat(this.paotuiMoney) + parseFloat(this.dabaoMoney)).toFixed(2)
- : parseFloat(this.totalPrice).toFixed(2)
- let data = {
- shopId: this.dataList.shopId,
- page: 1,
- limit: 20,
- minMoney: minMoney
- }
- this.$Request.get('/app/coupon/selectUserCouponList', data).then((res) => {
- console.log(res, '优惠券')
- if (res.code == 0) {
- this.couponList = res.data.list
- if (this.coupon) {
- let activityExists = this.couponList.some((item) => item.couponId === this.coupon.couponId)
- if (!activityExists) {
- this.coupon = ''
- if (this.orderType == 2) {
- this.totalPrice1 = parseFloat(this.totalPrice + this.paotuiMoney + this.dabaoMoney + this.address.insideDeliveryFee).toFixed(2)
- } else {
- if (this.packType == 1) {
- this.totalPrice1 = parseFloat(parseFloat(this.totalPrice) + parseFloat(this.dabaoMoney)).toFixed(2)
- } else {
- this.totalPrice1 = parseFloat(this.totalPrice).toFixed(2)
- }
- }
- let totalMoney = 0
- if (this.Vipmoney.canReduceFlag == '1') {
- totalMoney = parseFloat(this.totalPrice1 - (this.Vipmoney.reduceAmount ? this.Vipmoney.reduceAmount : 0)).toFixed(2)
- } else {
- 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)
- }
- if (totalMoney <= 0) {
- this.totalPrice12 = 0.01
- } else {
- this.totalPrice12 = totalMoney
- }
- uni.showModal({
- title: '提示',
- content: '当前选择的优惠券已过期,请重新选择',
- success: function (res) {
- if (res.confirm) {
- this.coupon = ''
- } else if (res.cancel) {
- this.coupon = ''
- }
- }
- })
- }
- }
- }
- })
- },
- // 优惠活动列表
- getHuoList() {
- let data = {
- orderId: this.dataList.orderId
- }
- this.$Request.get(`/app/activity/suit-activity/${this.dataList.orderId}`, data).then((res) => {
- if (res.code == 0) {
- this.huoList = res.data
- if (this.huodong) {
- // console.log(this.huodong,'有呢')
- let activityExists = this.huoList.some((item) => item.activityId === this.huodong.activityId)
- if (!activityExists) {
- this.huodong = ''
- if (this.orderType == 2) {
- this.totalPrice1 = parseFloat(this.totalPrice + this.paotuiMoney + this.dabaoMoney + this.address.insideDeliveryFee).toFixed(2)
- } else {
- if (this.packType == 1) {
- this.totalPrice1 = parseFloat(parseFloat(this.totalPrice) + parseFloat(this.dabaoMoney)).toFixed(2)
- } else {
- this.totalPrice1 = parseFloat(this.totalPrice).toFixed(2)
- }
- }
- let totalMoney = 0
- if (this.Vipmoney.canReduceFlag == '1') {
- totalMoney = parseFloat(this.totalPrice1 - (this.Vipmoney.reduceAmount ? this.Vipmoney.reduceAmount : 0)).toFixed(2)
- } else {
- 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)
- }
- if (totalMoney <= 0) {
- this.totalPrice12 = 0.01
- } else {
- this.totalPrice12 = totalMoney
- }
- uni.showModal({
- title: '提示',
- content: '当前选择的优惠活动已过期,请重新选择',
- success: function (res) {
- if (res.confirm) {
- this.huodong = ''
- } else if (res.cancel) {
- this.huodong = ''
- }
- }
- })
- }
- }
- // 匹配出最优惠的活动
- if (this.huoList.length) {
- this.huodong = this.huoList.reduce((prev, current) => (prev.discountAmount > current.discountAmount ? prev : current))
- this.selctHuo(this.huodong)
- }
- }
- })
- },
- // 获取订单信息
- getOrderList() {
- this.paotuiMoney = 0
- this.totalPrice1 = 0
- this.totalPrice12 = 0
- let data = {
- orderId: this.orderId
- }
- this.$Request.get('/app/order/selectBuyGoods', data).then((res) => {
- console.log(res, '6661')
- uni.hideLoading()
- if (res.code == 0) {
- this.dataList = res.data
- this.GoodsorderId = res.data.orderId
- // this.getShopDet(res.data.shopId)
- // this.dataList.orderGoodsList[0].goodsPicture = this.dataList.orderGoodsList[0].goodsPicture.split(',')
- // console.log(this.dataList.orderGoodsList)
- if (this.dataList) {
- this.dabaoMoney = 0
- this.dataList.orderGoodsList.forEach((res) => {
- res.goodsPicture = res.goodsPicture.split(',')
- this.dabaoMoney += res.goodsPack * res.goodsNum
- this.goodsMoney += res.goodsPrice * res.goodsNum
- this.goodsMoney = parseFloat(this.goodsMoney + this.dabaoMoney)
- })
- }
- console.log(this.ifPaotui, 'this.ifPaotui')
- if (this.ifPaotui == 1) {
- this.paotuiMoney = this.dataList.errandMoney
- } else if (this.ifPaotui == 0) {
- // 判断商品金额是否大于最低减免配送费金额
- if (Number(this.goodsMoney) >= Number(this.dataList.exemptMinMoney)) {
- console.log('跑腿费')
- this.paotuiMoney = 0
- } else {
- this.paotuiMoney = this.dataList.errandMoney
- }
- }
- this.totalPrice = res.data.payMoney * 1
- console.log(this.dabaoMoney, '打包')
- console.log(this.paotuiMoney, '跑腿')
- if (this.orderType == 2) {
- this.totalPrice1 = parseFloat(this.totalPrice + this.paotuiMoney + this.dabaoMoney + this.address.insideDeliveryFee).toFixed(2)
- } else {
- if (this.packType == 1) {
- this.totalPrice1 = parseFloat(parseFloat(this.totalPrice) + parseFloat(this.dabaoMoney)).toFixed(2)
- } else {
- this.totalPrice1 = parseFloat(this.totalPrice).toFixed(2)
- }
- }
- this.getvipMoney()
- // let totalMoney =0
- // if(this.Vipmoney.canReduceFlag=='1'){
- // totalMoney = parseFloat(this.totalPrice1 -(this.Vipmoney.reduceAmount?this.Vipmoney.reduceAmount:0)).toFixed(2)
- // }else{
- // 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)
- // }
- // if (totalMoney <= 0) {
- // this.totalPrice12 = 0.01
- // } else {
- // this.totalPrice12 = totalMoney
- // }
- console.log(this.dataList)
- // this.getvipMoney()
- this.getCouponList()
- this.getHuoList()
- this.detCoupon()
- this.getDistance()
- }
- })
- },
- selectWay: function (item) {
- this.openWay = item.id
- },
- takeReark() {
- let datas = {
- orderId: this.GoodsorderId,
- remark: this.remark
- }
- this.$Request.post('/app/order/updateOrdersRemark', datas).then((res) => {
- // uni.hideLoading();
- if (res.code == 0) {
- } else {
- uni.showToast({
- title: res.msg,
- icon: 'none'
- })
- }
- })
- },
- // 立即结算
- toSettlement() {
- if (this.isThrottle == false) {
- return
- }
- if (this.isTrue && this.orderType == 2) {
- uni.showToast({
- title: '超出配送范围',
- icon: 'none'
- })
- reutrn
- }
- if (this.orderType == 2 && !this.address.addressId) {
- uni.showToast({
- title: '请选择收货地址',
- icon: 'none'
- })
- return
- }
- if (this.remark) {
- this.takeReark()
- }
- uni.showLoading({
- title: '支付中...',
- mask: true // 是否显示透明蒙层,防止触摸穿透
- })
- this.isThrottle = false
- if (this.openWay == 1) {
- let data = {
- userId: uni.getStorageSync('userId'),
- type: 1, //支付方式 1表示微信支付、4或5表示支付宝支付
- activityId: this.huodong ? this.huodong.activityId : '',
- reservationFlag: this.reservationFlag, //是否预约单 1是、0否
- expectDeliveryTime: this.expectDeliveryTime, //期待送达时间 yyyy-MM-dd HH:mm:ss
- parentId: this.dataList.parentId,
- couponId: this.coupon ? this.coupon.id : '',
- addressId: this.address.addressId ? this.address.addressId : '',
- orderType: this.orderType
- }
- this.$Request.post('/app/wxPay/balanceOrder', data).then((res) => {
- if (res.code == 0) {
- uni.hideLoading()
- this.$queue.showToast('支付成功')
- setTimeout(() => {
- this.isThrottle = true
- uni.switchTab({
- url: '/pages/order/index'
- })
- }, 1000)
- } else {
- this.isThrottle = true
- this.$queue.showToast(res.msg)
- }
- })
- } else if (this.openWay == 2) {
- // #ifdef H5
- let data = {
- userId: uni.getStorageSync('userId'),
- type: 1, //支付方式 1表示微信支付、4或5表示支付宝支付
- activityId: this.huodong ? this.huodong.activityId : '',
- reservationFlag: this.reservationFlag, //是否预约单 1是、0否
- expectDeliveryTime: this.expectDeliveryTime, //期待送达时间 yyyy-MM-dd HH:mm:ss
- parentId: this.dataList.parentId,
- couponId: this.coupon ? this.coupon.id : '',
- addressId: this.address.addressId ? this.address.addressId : '',
- orderType: this.orderType,
- type: 2
- }
- this.$Request.post('/app/wxPay/wxPayJsApiOrder', data).then((res) => {
- if (res.code == 0) {
- this.callPay(res.data)
- } else {
- this.isThrottle = true
- uni.showToast({
- title: res.msg,
- icon: 'none'
- })
- }
- })
- // #endif
- // #ifdef MP-WEIXIN
- this.$Request.get('/app/new-pay/enable-new-pay').then((res) => {
- console.log(res, '666')
- if (res.code == 0) {
- let data = {
- userId: uni.getStorageSync('userId'),
- // type: 4, //支付方式 1表示微信支付、4或5表示支付宝支付
- activityId: this.huodong ? this.huodong.activityId : '',
- reservationFlag: this.reservationFlag, //是否预约单 1是、0否
- expectDeliveryTime: this.expectDeliveryTime, //期待送达时间 yyyy-MM-dd HH:mm:ss
- parentId: this.dataList.parentId,
- couponId: this.coupon ? this.coupon.id : '',
- addressId: this.address.addressId ? this.address.addressId : '',
- orderType: this.orderType,
- type: res.enable ? 1 : 3,
- idCard: this.idcard1,
- packType: this.packType
- }
- console.log(data)
- if (res.enable) {
- console.log('xin')
- this.newPay(data)
- } else {
- console.log('jiu')
- this.oldPay(data)
- }
- }
- })
- // #endif
- // #ifdef APP
- let data = {
- type: 1,
- parentId: this.dataList.parentId,
- couponId: this.coupon ? this.coupon.id : '',
- addressId: this.address.addressId ? this.address.addressId : '',
- orderType: this.orderType
- }
- this.$Request.post('/app/wxPay/wxPayJsApiOrder', data).then((res) => {
- console.log(res)
- this.showpay = false
- if (res.code == 0) {
- this.isCheckPay(res.code, 'wxpay', JSON.stringify(res.data))
- } else {
- this.isThrottle = true
- }
- })
- // #endif
- } else if (this.openWay == 3) {
- // #ifdef H5
- let data = {
- type: 5,
- parentId: this.dataList.parentId,
- couponId: this.coupon ? this.coupon.id : '',
- addressId: this.address.addressId ? this.address.addressId : '',
- orderType: this.orderType
- }
- this.$Request.post('/app/wxPay/wxPayJsApiOrder', data).then((res) => {
- this.showpay = false
- this.isThrottle = true
- const div = document.createElement('div')
- div.innerHTML = res.data //此处form就是后台返回接收到的数据
- document.body.appendChild(div)
- document.forms[0].submit()
- })
- // #endif
- // #ifdef APP-PLUS
- let data = {
- type: 4,
- parentId: this.dataList.parentId,
- couponId: this.coupon ? this.coupon.id : '',
- addressId: this.address.addressId ? this.address.addressId : '',
- orderType: this.orderType
- }
- this.$Request.post('/app/wxPay/wxPayJsApiOrder', data).then((res) => {
- this.showpay = false
- this.setPayment('alipay', res.data)
- })
- // #endif
- }
- },
- newPay(data) {
- this.$Request.get('/app/order/get-pay-param', data).then((res) => {
- console.log(res, '新支付')
- if (res.code == 0) {
- uni.requestPayment({
- provider: 'wxpay',
- timeStamp: res.timeStamp,
- nonceStr: res.nonceStr,
- package: res.packageStr,
- signType: res.signType,
- paySign: res.paySign,
- success: (suc) => {
- uni.hideLoading()
- this.$queue.showToast('支付成功')
- setTimeout(() => {
- this.isThrottle = true
- uni.switchTab({
- url: '/pages/order/index'
- })
- }, 1000)
- },
- fail: (err) => {
- console.log('fail:' + JSON.stringify(err))
- this.isThrottle = true
- uni.setStorageSync('isClear', true)
- uni.showToast({
- title: '支付失败',
- icon: 'none',
- mask: true
- })
- setTimeout(() => {
- uni.reLaunch({
- url: '/pages/order/index'
- })
- }, 1500)
- }
- })
- } else {
- uni.showToast({
- title: res.msg,
- icon: 'none'
- })
- this.isThrottle = true
- }
- })
- },
- oldPay(data) {
- this.$Request.post('/app/wxPay/wxPayJsApiOrder', data).then((res) => {
- console.log(res, '旧支付')
- // uni.hideLoading();
- if (res.code == 0) {
- uni.requestPayment({
- provider: 'wxpay',
- timeStamp: res.data.timestamp,
- nonceStr: res.data.noncestr,
- package: res.data.package,
- signType: res.data.signType,
- paySign: res.data.sign,
- success: (suc) => {
- uni.hideLoading()
- this.$queue.showToast('支付成功')
- setTimeout(() => {
- this.isThrottle = true
- uni.switchTab({
- url: '/pages/order/index'
- })
- }, 1000)
- },
- fail: (err) => {
- console.log('fail:' + JSON.stringify(err))
- this.isThrottle = true
- uni.setStorageSync('isClear', true)
- uni.showToast({
- title: '支付失败',
- icon: 'none',
- mask: true
- })
- setTimeout(() => {
- uni.reLaunch({
- url: '/pages/order/index'
- })
- }, 1500)
- }
- })
- } else {
- uni.showToast({
- title: res.msg,
- icon: 'none'
- })
- this.isThrottle = true
- }
- })
- },
- callPay: function (response) {
- if (typeof WeixinJSBridge === 'undefined') {
- if (document.addEventListener) {
- document.addEventListener('WeixinJSBridgeReady', this.onBridgeReady(response), false)
- } else if (document.attachEvent) {
- document.attachEvent('WeixinJSBridgeReady', this.onBridgeReady(response))
- document.attachEvent('onWeixinJSBridgeReady', this.onBridgeReady(response))
- }
- } else {
- this.onBridgeReady(response)
- }
- },
- onBridgeReady: function (response) {
- let that = this
- if (!response.package) {
- return
- }
- WeixinJSBridge.invoke(
- 'getBrandWCPayRequest',
- {
- appId: response.appid, //公众号名称,由商户传入
- timeStamp: response.timestamp, //时间戳,自1970年以来的秒数
- nonceStr: response.noncestr, //随机串
- package: response.package,
- signType: response.signType, //微信签名方式:
- paySign: response.sign //微信签名
- },
- function (res) {
- if (res.err_msg === 'get_brand_wcpay_request:ok') {
- // 使用以上方式判断前端返回,微信团队郑重提示:
- //res.err_msg将在用户支付成功后返回ok,但并不保证它绝对可靠。
- uni.hideLoading()
- uni.showToast({
- title: '支付成功',
- icon: 'success'
- })
- setTimeout(function () {
- that.isThrottle = true
- uni.switchTab({
- url: '/pages/order/index'
- })
- }, 1000)
- } else {
- that.isThrottle = true
- uni.hideLoading()
- }
- WeixinJSBridge.log(response.err_msg)
- }
- )
- },
- isCheckPay(code, name, order) {
- if (code == 0) {
- console.log('999999999999')
- this.setPayment(name, order)
- } else {
- uni.hideLoading()
- uni.showToast({
- title: '支付信息有误'
- })
- this.isThrottle = true
- }
- },
- setPayment(name, order) {
- console.log(777777777, name, order)
- uni.requestPayment({
- provider: name,
- orderInfo: order, //微信、支付宝订单数据
- success: (res) => {
- uni.hideLoading()
- uni.showLoading({
- title: '支付成功',
- icon: 'none'
- })
- setTimeout(() => {
- this.isThrottle = true
- uni.navigateBack()
- }, 1000)
- },
- fail: (err) => {
- this.isThrottle = true
- uni.hideLoading()
- },
- complete: () => {
- this.isThrottle = true
- uni.hideLoading()
- }
- })
- },
- // 获取选择的地址
- getAddressDet(e) {
- let data = {
- addressId: e
- }
- this.$Request.get('/app/address/selectAddressById', data).then((res) => {
- console.log(res, 741258)
- if (res.code == 0) {
- this.address = res.data
- if (this.address.insideAddressId) {
- this.getInsideDeliveryFee(this.address.insideAddressId)
- } else {
- this.getInsideDeliveryFee(0)
- }
- if (JSON.stringify(this.address) != '{}') {
- this.getDistance()
- }
- uni.removeStorageSync('addressId')
- }
- })
- },
- // 获取地址列表
- getAddressList() {
- let data = {
- page: 1,
- limit: 100
- }
- this.$Request.get('/app/address/selectAddressList', data).then((res) => {
- if (res.code == 0 && res.data.list.length) {
- this.address = res.data.list[0]
- res.data.list.forEach((ret) => {
- if (ret.addressDefault == 1) {
- this.address = ret
- }
- })
- if (this.address.insideAddressId) {
- this.getInsideDeliveryFee(this.address.insideAddressId)
- } else {
- this.getInsideDeliveryFee(0)
- }
- // console.log(this.address, '我的地址列表460777')
- if (JSON.stringify(this.address) != '{}') {
- this.getDistance()
- }
- }
- })
- },
- getInsideDeliveryFee(insideAddressId) {
- this.$Request.get(`/app/inside-address/${insideAddressId}`).then((res) => {
- // console.log(res, 987456)
- if (res.code == 0) {
- this.address.insideDeliveryFee = res.data.deliveryFee || 0
- }
- })
- },
- goAddress() {
- uni.navigateTo({
- url: '/my/address/index?add=1'
- })
- },
- // 点击调起地图查看位置
- goMap() {
- let lati = parseFloat(this.dataList.shopLat)
- let longi = parseFloat(this.dataList.shopLng)
- uni.authorize({
- scope: 'scope.userLocation',
- success: (res) => {
- uni.openLocation({
- name: this.dataList.shopName,
- latitude: lati,
- longitude: longi,
- success: () => {}
- })
- },
- fail(err) {}
- })
- },
- // 打电话
- call() {
- uni.makePhoneCall({
- phoneNumber: this.dataList.shopPhone
- })
- }
- }
- }
- </script>
- <style scoped>
- .hintPopul {
- width: 100%;
- height: 100vh;
- position: fixed;
- top: 0;
- background: rgba(0, 0, 0, 0.4);
- z-index: 999;
- }
- .content_ {
- position: absolute;
- left: 0;
- right: 0;
- top: 0;
- bottom: 0;
- margin: auto;
- text-align: center;
- width: 500rpx;
- height: 400rpx;
- border-radius: 20rpx;
- background-color: #fff;
- padding-top: 120rpx;
- }
- .content_ image {
- position: absolute;
- top: -50rpx;
- left: 0;
- right: 0;
- margin: auto;
- }
- .hintText {
- font-size: 30rpx;
- }
- .Btns {
- width: 460rpx;
- height: 60rpx;
- line-height: 60rpx;
- text-align: center;
- background: #fcd202;
- font-size: 28rpx;
- border: 2rpx solid #fcd202;
- color: #333333;
- border-radius: 50rpx;
- font-weight: 700;
- margin: auto;
- }
- .goods_address {
- width: 94%;
- background: #ffffff;
- height: 120rpx;
- margin: 20rpx auto 0;
- border-radius: 18rpx;
- }
- .address_box {
- width: 90%;
- margin: 0 auto;
- height: 120rpx;
- display: flex;
- line-height: 120rpx;
- }
- .address_name {
- flex: 1;
- font-size: 30rpx;
- }
- .address_image {
- /* flex: 1; */
- display: flex;
- justify-content: flex-end;
- align-items: center;
- }
- .address_image image {
- width: 15rpx;
- height: 30rpx;
- }
- .songda_image image {
- width: 20rpx;
- height: 30rpx;
- margin-left: 20rpx;
- }
- /* 地址 */
- .address {
- width: 88%;
- margin: 3% auto;
- padding: 3%;
- display: flex;
- background-color: #ffffff;
- border-radius: 18rpx;
- }
- .adderss_le {
- width: 90%;
- line-height: 1.5;
- }
- .adderss_le_text {
- font-size: 30rpx;
- font-weight: bold;
- color: #333333;
- }
- .adderss_le_text2 {
- font-size: 24rpx;
- font-weight: 500;
- color: #999999;
- display: flex;
- }
- .adderss_le_text2 view {
- margin-left: 2%;
- }
- .adderss_le_text2 view:first-child {
- margin-left: 0;
- }
- .adderss_ri {
- width: 10%;
- text-align: right;
- line-height: 3;
- }
- .adderss_ri image {
- width: 18rpx;
- height: 30rpx;
- }
- /* 商品 */
- .food {
- width: 94%;
- margin: 3% auto;
- padding: 3%;
- background-color: #ffffff;
- border-radius: 18rpx;
- }
- .food_top {
- display: flex;
- justify-content: space-between;
- align-items: center;
- font-size: 32rpx;
- font-weight: bold;
- }
- .food_bottom {
- margin-top: 20rpx;
- color: #666666;
- font-size: 28rpx;
- line-height: 45rpx;
- }
- .bottom_text {
- color: #ea0018;
- }
- .tosend_header_food {
- width: 100%;
- display: flex;
- margin-top: 3%;
- }
- .tosend_header_food_le {
- width: 15%;
- }
- .tosend_header_food_le image {
- width: 110rpx;
- height: 110rpx;
- }
- .tosend_header_food_ce {
- margin: 0 0 0 4%;
- width: 57%;
- }
- .tosend_header_food_ri {
- text-align: right;
- width: 25%;
- }
- .tosend_header_food_text {
- font-size: 34rpx;
- font-weight: 500;
- color: #333333;
- line-height: 1.8;
- }
- .tosend_header_food_text text {
- font-size: 25rpx;
- }
- .tosend_header_food_text2 {
- font-size: 30rpx;
- font-weight: 500;
- color: #999999;
- }
- .do_top {
- padding-top: 3%;
- }
- .do_bot {
- padding-bottom: 3%;
- border-bottom: 2rpx solid #e6e6e6;
- }
- .tosend_header_do {
- width: 100%;
- color: #333333;
- font-size: 30rpx;
- display: flex;
- margin-top: 20rpx;
- line-height: 1.5;
- }
- .tosend_header_do view {
- /* flex: 1; */
- }
- .tosend_header_do_ri {
- text-align: right;
- }
- .tosend_header_do_le2 {
- font-family: PingFang SC;
- font-weight: 500;
- color: #999999;
- padding-top: 1.5%;
- }
- .tosend_header_do_ri2 {
- text-align: right;
- color: #ea0000;
- font-size: 40rpx;
- }
- .tosend_header_do_ri2 text {
- font-size: 30rpx;
- }
- /* 支付 */
- /* .payment_all{
- width: 88%;margin: 3% auto;padding: 3%;background-color: #FFFFFF;
- border-radius: 18rpx;
- }
- .payment{
- width: 100%;display: flex;margin-top: 3%;
- }
- .payment_le{
- width: 13%;
- }
- .payment_le image{
- width: 60rpx;height: 60rpx;
- }
- .payment_ce{
- width: 52%;
- font-size: 30rpx;
- font-weight: bold;
- color: #333333;line-height: 60rpx;
- }
- .payment_ri{
- width: 35%;text-align: right;line-height: 60rpx;
- } */
- /* 结算 */
- .goorder {
- width: 100%;
- padding: 2% 3%;
- position: fixed;
- bottom: 0;
- background-color: #ffffff;
- }
- .goorder_but {
- width: 100%;
- line-height: 3.5;
- text-align: center;
- background: #fcd202;
- border-radius: 36rpx;
- font-weight: 700;
- }
- .goorder_but_ {
- opacity: 0.5;
- }
- .bg {
- background-color: #ffffff;
- }
- .tabBtn {
- /* background-color: #f6f6fa; */
- height: 60rpx;
- line-height: 60rpx;
- color: #999999;
- font-size: 38rpx;
- }
- .active {
- /* width: 82rpx; */
- height: 6rpx;
- background: #fcd202;
- /* position: relative;
- top: -20rpx; */
- z-index: 9;
- }
- </style>
|