| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042 |
- <template>
- <view class="contentV">
- <customNav :shownav="true" :title="$t('index.xiadanzhifu')" titledetl=""></customNav>
- <view class="ctinrow">
- <view class="topSwichV" :style="{backgroundColor:Bcolor}" @click="peisong">
- <view class="topSwichV">
- <image class="toppz" :src="peisongimg" mode="widthFix"></image>
- <text class="toppztext" :style="{color:Tcolor}">{{$t('order.peisong')}}</text>
- </view>
- </view>
- <view class="topSwichVL" :style="{backgroundColor:Bcolorr}" @click="ziqu">
- <view class="topSwichVL">
- <image class="toppz" :src="ziquimg" mode="widthFix"></image>
- <text class="toppztext" :style="{color:Tcolorr}">{{$t('order.ziqu')}}</text>
- </view>
- </view>
- <!-- <view class="topSwichVL" :style="{backgroundColor:Bcolorrr}" @click="tangshi">
- <view class="topSwichVL">
- <image class="toppz" :src="tangshiimg" mode="widthFix"></image>
- <text class="toppztext" :style="{color:Tcolorrr}">{{$t('shouye.tangshi')}}</text>
- </view>
- </view> -->
- </view>
- <label class="linesp"></label>
- <uni-list v-if="showAdrr==0">
- <uni-list-item :title="dizhiID.address" :note="dizhiID.phone" :rightText="dizhiID.name"
- thumb="/static/images/dizhil@3x.png" thumb-size="sm" @click="changaddr" link></uni-list-item>
- </uni-list>
- <uni-list>
- <uni-list-item :title="delryTime.length>0?$t('order.yuyueshijian'):$t('order.jinkuaisd')"
- :note="delryTime.length>0?delryTime:('10~20 '+$t('order.Xfenzhongsd'))"
- :rightText="$t('order.yuyueshijian')" thumb="/static/images/time@3x.png" thumb-size="sm"
- @click="yuyueshijian" link></uni-list-item>
- </uni-list>
- <label class="linesp"></label>
- <label class="linesp"></label>
- <uni-list>
- <uni-list-item :title="$t('index.goodslist')"></uni-list-item>
- </uni-list>
- <view v-for="(item,findex) in foodlist">
- <view class="spnodetail">
- <view class="">
- <myImage class="spIcon" :mysrc="item.image" mymode="scaleToFill"></myImage>
- </view>
- <view style="width: 82%;">
- <view class="actBTV">
- <view style="font-size: 30rpx;width: 100%;">
- <text class="text2row" style="width: 100%;">{{item.name}}</text>
- </view>
- <view class="contentInRowL">
- <image v-if="item.number>0" class="imageRJ" src="/static/images/jian@3x.png"
- mode="aspectFit" @click="jiajian(findex,-1)"></image>
- <text v-if="item.number>0" class="textR">{{item.number}}</text>
- <image class="imageR" src="/static/images/plus-circle-fill@3x.png" mode="aspectFit"
- @click="jiajian(findex,1)"></image>
- </view>
- </view>
- <view class="actBTV">
- <view style="font-size: 26rpx;color: blueviolet;">{{$t('shangpin.shoujia')}}:
- {{$formPr(item.price+item.otherPrice)}}{{$t('locale.huobidw')}}
- </view>
- <view class="xiaoji" style="font-size: 28rpx;color: brown;">{{$t('shangpin.xiaoji')}}:
- {{$formPr((item.price+item.otherPrice)*item.number)}}{{$t('locale.huobidw')}}
- </view>
- </view>
- <view class="viewinrow">
- <text class="kouweisku">{{arraytoStr(item.ask)}}</text>
- </view>
- <view v-if="item.beizhu" class="">
- <text style="font-size: 30rpx;color:#00A6FF;">{{item.beizhu}}</text>
- </view>
- </view>
- </view>
- </view>
- <label class="linesp"></label>
- <label class="linesp"></label>
- <view style="background-color:white;width: 100%;">
- <view class="contentInRowS shifdf" @click="xuanzcux">
- <view class="contentInRowL" style="width: 86%;">
- <image style="width: 50rpx;height: 50rpx;" src="/static/images/hongbkqh@3x.png" mode="scaleToFill">
- </image>
- <view class="contentColumn" style="width: 100%;">
- <text class="shifdftext"
- :style="youyh?'color:fuchsia;':'color:darkgray;'">{{$t('index.hongbaokq')}}</text>
- <text class="hdts" style="color: black;font-size: 26rpx;">{{yhhd}}</text>
- </view>
- </view>
- <image v-if="hyyh!=0" style="width: 50rpx;height: 50rpx;" src="/static/images/dagoul.png"
- mode="scaleToFill"></image>
- </view>
- </view>
- <!-- <view style="background-color:white;width: 100%;">
- <view class="contentInRowS shifdf" @click="jifenduihuan">
- <view class="contentInRowL" style="width: 86%;">
- <image style="width: 50rpx;height: 50rpx;" src="/static/images/hongbkqh@3x.png" mode="scaleToFill"></image>
- <view class="contentColumn" style="width: 100%;">
- <text class="shifdftext" :style="isjifenduihan?'color:green;':'color:darkgray;'">积分兑换</text>
- <text v-if="points>0" class="hdts" style="color: black;font-size: 26rpx;">{{points}}积分兑换{{pointsReduction}}</text>
- </view>
- </view>
- <image v-if="isjifenduihan" style="width: 50rpx;height: 50rpx;" src="/static/images/dagoul.png" mode="scaleToFill"></image>
- </view>
- </view> -->
- <view class="contentInRowS shifdf" @click="shifodaofu">
- <view class="contentInRowC">
- <image style="width: 50rpx;height: 50rpx;" src="/static/images/payflact@3x.png" mode="scaleToFill">
- </image>
- <text class="shifdftext"
- :style="shifoudf==0?'color:darkgray;':'color:fuchsia;'">{{$t('index.huodaofukan')}}</text>
- </view>
- <image v-if="shifoudf==1" style="width: 50rpx;height: 50rpx;" src="/static/images/dagoul.png"
- mode="scaleToFill"></image>
- </view>
- <label class="linesp"></label>
- <label class="linesp"></label>
- <uni-list>
- <uni-list-item :title="$t('order.beizhu')"></uni-list-item>
- </uni-list>
- <textarea class="pinglun" :placeholder="$t('order.srddbz')" :value="remarks" @input="sumfontnum"></textarea>
- <label class="linesp"></label>
- <label class="linesp"></label>
- <!-- <view v-if="showAdrr==0">
- <uni-list>
- <uni-list-item :title="$t('order.menpaizp')"></uni-list-item>
- </uni-list>
- <view class="contentColumnC" style="margin-top: 30rpx;" @click="selectImage">
- <netImage width="640" height="640" :mysrc="mpImage" mymode="scaleToFill"></netImage>
- </view>
- <view class="linesp" style="margin-top: 20rpx;"></view>
- <label class="linesp"></label>
- </view> -->
- <uni-list>
- <uni-list-item :title="$t('order.shangpinxj')" :rightText="$formPr(spxj)+$t('locale.huobidw')" />
- <uni-list-item :title="$t('order.peisongfei')" :rightText="$formPr(psf)+$t('locale.huobidw')" />
- <uni-list-item :title="$t('order.youhuijine')" :rightText="'-'+$formPr(hyyh)+$t('locale.huobidw')" />
- </uni-list>
- <label class="linesp"></label>
- <label class="linesp"></label>
- <uni-list>
- <uni-list-item :title="$t('order.zhifujine')" :rightText="$formPr(zje)+$t('locale.huobidw')" />
- </uni-list>
- <label class="linesp"></label>
- <label class="linesp"></label>
- <view class="delbtct">
- <view class="delbt" @click="qufukuan">
- <label>{{actTitle}}</label>
- </view>
- </view>
- <label class="linesp"></label>
- <liu-delivery-time @change="changeTime" @close="deliveryclose" ref="chooseTime"
- :title="$t('order.yuyueshijian')"></liu-delivery-time>
- <yhdslCropper ref="yhdslCropper" :quality="1" mode="scale" @uploadImg="uploadImg" :scale="scale"></yhdslCropper>
- <popViewGG :show="showpop" :acttips="$t('order.queding')" :maskClosable="true" :isCancel="false"
- @chooseCancel="chooseCancel">
- <view class="contentColumnC" style="width: 100%;background-color: whitesmoke;">
- <view class="contentColumnC" style="height: 80rpx;width: 100%;background-color: lightgray;">
- <view class="contentInRowS" style="height: 80rpx;width: 90%;">
- <text style="font-size: 30rpx;color: crimson;" @click="querenyhhd"></text>
- <text style="font-size: 28rpx;">{{$t('index.hongbaokq')}}</text>
- <text style="font-size: 30rpx;color: #00A6FF;"
- @click="querenyhhd">{{$t('order.queding')}}</text>
- </view>
- </view>
- <view v-if="cxList.length>0" style="width: 90%;">
- <checkbox-group @change="hdradioChange">
- <label class="contentColumn" style="margin-top: 16rpx;" v-for="(item, index) in cxList"
- :key="index">
- <checkbox :value="item.id" :checked="item.id === hdidpt||item.id === hdidsj">
- <view class="contentColumn" :style="item.type==0?'color: #00A6FF;':'color:green;'">
- <text style="font-size: 28rpx;">{{item.salesName}}</text>
- <text style="font-size: 28rpx;">{{getNote(item,0)}}</text>
- </view>
- </checkbox>
- </label>
- </checkbox-group>
- </view>
- <view v-if="kqList.length>0" style="width: 90%;">
- <checkbox-group @change="kaqradioChange">
- <label class="contentColumn" style="margin-top: 16rpx;" v-for="(item, index) in kqList"
- :key="index">
- <checkbox :value="item.id" :checked="item.id === kqidpt||item.id === kqidsj">
- <view class="contentColumn" :style="item.type==0?'color: #00A6FF;':'color:green;'">
- <text style="font-size: 28rpx;">{{item.name}}</text>
- <text style="font-size: 28rpx;">{{getNote(item,1)}}</text>
- </view>
- </checkbox>
- </label>
- </checkbox-group>
- </view>
- <view class="contentInRowC" style="width: 100%;height: 80rpx;margin-top: 16rpx;">
- <text>{{$t('hongbaokq.leijiyh')}} {{hyyh}}{{$t('locale.huobidw')}}</text>
- </view>
- <view style="height: 80rpx;"></view>
- </view>
- </popViewGG>
- <popViewGG :tips="$t('order.zhifufangshi')" :show="zffsS" :showbotom="false" :maskClosable="true"
- :isCancel="true" @chooseCancel="chooseCancel">
- <view class="contentColumnC" style="width: 100%;background-color: whitesmoke;">
- <view class="zhifbut" style="background-color: deeppink;" @click="huodaofukuan">
- {{$t('index.huodaofukan')}}
- </view>
- <!-- <view class="zhifbut" style="background-color:#00A6FF;" @click="getVNPay">VNPAY</view> -->
- </view>
- </popViewGG>
- </view>
- </template>
- <script>
- import uniList from '@/uni_modules/uni-list/uni-list.vue';
- import uniListItem from '@/uni_modules/uni-list-item/uni-list-item.vue';
- // import uniAd from '@/uni_modules/uni-list-ad/uni-list-ad.vue';
- // import uniChat from '@/uni_modules/uni-list-chat/uni-list-chat.vue';
- import yhdslCropper from '@/components/yhdsl-cropper/yhdsl-cropper.vue';
- import api from "@/pages/api/api.js"
- export default {
- components: {
- uniList,
- uniListItem,
- yhdslCropper
- },
- data() {
- return {
- mendid: 0,
- userid: 0,
- ddId: '',
- rId: '',
- showAdrr: 0,
- foodlist: [],
- Bcolor: 'whitesmoke',
- Bcolorr: 'lightgray',
- Bcolorrr: 'lightgray',
- Tcolor: 'black',
- Tcolorr: 'darkgray',
- Tcolorrr: 'darkgray',
- peisongimg: '/static/images/peisongh@3x.png',
- ziquimg: '/static/images/ziqu@3x.png',
- tangshiimg: '/static/images/tangshih.png',
- actTitle: this.$t('order.querendd'),
- actType: 0,
- remarks: '',
- spxj: 0.00,
- psf: 0.00,
- freight: 0.00,
- hyyh: 0.00,
- zje: 0.00,
- jvli: 0.00,
- zhixianjuli: 0.00,
- zhixianfreight: 0.00,
- dizhiID: '',
- addrList: [],
- peisongdizhiaddress: '',
- peisongdizhiname: '',
- peisongdizhiphone: '',
- zfindex: 0,
- delryTime: '',
- isGetyunfei: false,
- mendianMs: '',
- cid: '',
- orderDetl: '',
- shifouzhifu: false,
- zhifuUrl: '',
- shifoudf: 0,
- scale: 1,
- baseUrl: this.$baseImagurl,
- mpImage: '',
- showpop: false,
- indicatorStyle: 'height: 50px;',
- zffsS: false,
- keyixd: true,
- cxList: [],
- hdidpt: 0, //平台促销活动id
- hdidsj: 0, //门店促销活动id
- kqList: [],
- kqidpt: 0, //平台使用优惠券id
- kqidsj: 0, //门店优惠券id
- yhhd: '',
- youyh: false,
- discountAmount: 0, //平台优惠券优惠金额
- salesReduction: 0, //平台促销減免值
- mdDiscountAmount: 0, //门店优惠券优惠金额
- mdSalesReduction: 0, //门店促销減免值
- isjifenduihan: false,
- sumpoints: 0, //全部积分
- pointsBl: 0, //积分抵扣比例
- points: 0, //抵扣的积分
- pointsReduction: 0 //积分抵扣值
- }
- },
- onLoad(option) {
- this.foodlist = uni.getStorageSync("JSfoodlist");
- uni.setStorageSync('JSfoodlist', '');
- this.mendid = option.mendid;
- this.userid = option.userid;
- this.cid = uni.getStorageSync("cid");
- this.cuxiaoList();
- //this.getPoint();
- },
- onShow() {
- var temp = uni.getStorageSync("peisongdizhi");
- if (undefined == temp || null == temp || '' == temp) {
- this.dizhiID = '';
- //this.getaddressList();
- } else {
- this.dizhiID = temp;
- this.mpImage = this.dizhiID.annexes;
- }
- this.isGetyunfei = false;
- if (this.mendianMs == '') {
- this.getmendianDetail(this.mendid);
- } else {
- if (this.dizhiID == '') {
- this.getaddressList();
- } else {
- console.log('4444')
- this.getyunfei(this.dizhiID.latitude, this.dizhiID.longitude);
- }
- }
- if (this.shifouzhifu) {
- this.shifouzhifu = false;
- this.getorderDetl();
- }
- },
- methods: {
- // 检测是否为安卓设备
- isAndroidDevice() {
- // 在H5环境中检测
- // #ifdef H5
- const ua = navigator.userAgent.toLowerCase();
- return ua.indexOf('android') > -1;
- // #endif
-
- // 在App环境中检测
- // #ifdef APP-PLUS
- return plus.os.name === 'Android';
- // #endif
-
- // 其他环境默认返回false
- return false;
- },
-
- // 安卓设备自动下载并安装APK
- downloadAndInstallAndroid(androidUrl) {
- const that = this;
-
- // 显示下载提示
- uni.showLoading({
- title: '正在下载应用...',
- mask: true
- });
-
- // 在App环境中使用plus.downloader
- // #ifdef APP-PLUS
- const appDownloadTask = plus.downloader.createDownload(androidUrl, {
- filename: '_downloads/CTE.apk'
- }, function(download, status) {
- uni.hideLoading();
-
- if (status === 200) {
- // 下载成功,尝试安装
- that.installAndroidApp(download.filename);
- } else {
- uni.showToast({
- title: '下载失败,请重试',
- icon: 'none',
- duration: 2000
- });
- }
- });
-
- // 监听下载进度
- appDownloadTask.addEventListener('statechanged', function(download, status) {
- if (status === 200) {
- const progress = Math.round((download.downloadedSize / download.totalSize) * 100);
- uni.showLoading({
- title: `下载中 ${progress}%`,
- mask: true
- });
- }
- });
-
- appDownloadTask.start();
- // #endif
-
- // 在H5环境中使用uni.downloadFile
- // #ifdef H5
- const h5DownloadTask = uni.downloadFile({
- url: androidUrl,
- success: function(res) {
- uni.hideLoading();
-
- if (res.statusCode === 200) {
- // 下载成功,尝试安装
- that.installAndroidApp(res.tempFilePath);
- } else {
- uni.showToast({
- title: '下载失败,请重试',
- icon: 'none',
- duration: 2000
- });
- }
- },
- fail: function(err) {
- uni.hideLoading();
- console.log('下载失败:', err);
-
- // 下载失败时,提供手动下载选项
- uni.showModal({
- title: '下载失败',
- content: '自动下载失败,是否手动下载?',
- success: function(res) {
- if (res.confirm) {
- // 使用浏览器打开下载链接
- window.open(androidUrl, '_blank');
- }
- }
- });
- }
- });
-
- // 监听下载进度
- h5DownloadTask.onProgressUpdate(function(res) {
- const progress = Math.round(res.progress);
- uni.showLoading({
- title: `下载中 ${progress}%`,
- mask: true
- });
- });
- // #endif
- },
-
- // 安装安卓应用
- installAndroidApp(filePath) {
- const that = this;
-
- // 在App环境中,直接尝试安装APK
- // #ifdef APP-PLUS
- uni.showModal({
- title: '下载完成',
- content: '应用已下载完成,是否立即安装?',
- success: function(res) {
- if (res.confirm) {
- // 使用plus.runtime.install安装APK
- plus.runtime.install(filePath, {
- force: false
- }, function() {
- uni.showToast({
- title: '安装成功',
- icon: 'success',
- duration: 2000
- });
- }, function(e) {
- console.log('安装失败:', e);
- uni.showModal({
- title: '安装失败',
- content: '自动安装失败,请手动安装。是否打开文件管理器?',
- success: function(res) {
- if (res.confirm) {
- // 打开文件管理器
- plus.runtime.openFile(filePath);
- }
- }
- });
- });
- }
- }
- });
- // #endif
-
- // 在H5环境中,提示用户手动安装
- // #ifdef H5
- uni.showModal({
- title: '下载完成',
- content: '应用已下载完成,请点击下载的文件进行安装',
- showCancel: false,
- success: function(res) {
- if (res.confirm) {
- // 尝试打开下载链接,让用户手动下载
- window.open(filePath, '_blank');
- }
- }
- });
- // #endif
- },
-
- // 下载iOS应用
- downloadIOSApp(iosUrl) {
- // 检测是否为iOS设备
- const isIOS = this.isIOSDevice();
-
- if (!isIOS) {
- // 非iOS设备直接打开浏览器链接
- window.open('https://apps.apple.com/cn/app/cte/id6468907188', '_blank');
- return;
- }
-
- // 在App环境中使用plus.runtime.openURL
- // #ifdef APP-PLUS
- plus.runtime.openURL(
- 'itms-apps://itunes.apple.com/cn/app/cte/id6468907188',
- (res) => {
- console.log('打开 App Store 成功')
- },
- (err) => {
- console.log('打开 App Store 失败,尝试浏览器打开')
- // 如果 itms-apps:// 失败,回退到浏览器打开
- plus.runtime.openURL('https://apps.apple.com/cn/app/cte/id6468907188')
- }
- );
- // #endif
-
- // 在H5环境中,针对iOS设备优化
- // #ifdef H5
- // 先尝试直接打开App Store链接
- const appStoreUrl = 'https://apps.apple.com/cn/app/cte/id6468907188';
-
- // 尝试多种方式打开App Store
- this.tryOpenAppStore(appStoreUrl);
- // #endif
- },
-
- // 检测是否为iOS设备
- isIOSDevice() {
- // #ifdef H5
- const ua = navigator.userAgent.toLowerCase();
- return /iphone|ipad|ipod/.test(ua);
- // #endif
-
- // #ifdef APP-PLUS
- return plus.os.name === 'iOS';
- // #endif
-
- return false;
- },
-
- // 尝试打开App Store的多种方式
- tryOpenAppStore(appStoreUrl) {
- // 方法1: 直接使用window.open
- const newWindow = window.open(appStoreUrl, '_blank');
-
- // 如果新窗口被阻止,尝试其他方法
- if (!newWindow || newWindow.closed || typeof newWindow.closed == 'undefined') {
- // 方法2: 尝试使用itms-apps协议
- this.tryItmsProtocol();
- }
- },
-
- // 尝试使用itms-apps协议
- tryItmsProtocol() {
- const itmsUrl = 'itms-apps://itunes.apple.com/cn/app/cte/id6468907188';
-
- // 创建一个隐藏的iframe来尝试打开itms-apps协议
- const iframe = document.createElement('iframe');
- iframe.style.display = 'none';
- iframe.style.width = '1px';
- iframe.style.height = '1px';
- iframe.src = itmsUrl;
- document.body.appendChild(iframe);
-
- // 设置超时,如果App Store没有打开,则回退到浏览器
- setTimeout(() => {
- if (document.body.contains(iframe)) {
- document.body.removeChild(iframe);
- }
- // 最后回退到浏览器打开
- window.location.href = 'https://apps.apple.com/cn/app/cte/id6468907188';
- }, 1500);
- },
-
- //促销
- cuxiaoList() {
- this.youyh = false;
- this.yhhd = '';
- var price = 0;
- for (var i = 0; i < this.foodlist.length; i++) {
- price = price + (this.foodlist[i].price + this.foodlist[i].otherPrice) * this.foodlist[i].number;
- }
- this.cxList = [];
- api('cuxiaoList', {
- mdId: this.mendid,
- price: price,
- yfPrice: this.psf
- }, r => {
- console.log(r);
- console.log('-----------1', this.mendid, price, this.psf)
- if (r.data.code == 200) {
- this.cxList = r.data.data;
- if (this.cxList.length > 0) {
- this.yhhd = this.$t('order.qingxzyhkq');
- this.youyh = true;
- }
- }
- this.jisuanjiner();
- this.kaquanList();
- }, failc => {
- //console.log('getadvertis----',failc)
- })
- },
- kaquanList() {
- var price = 0;
- for (var i = 0; i < this.foodlist.length; i++) {
- price = price + (this.foodlist[i].price + this.foodlist[i].otherPrice) * this.foodlist[i].number;
- }
- this.kqList = [];
- api('orderyhList', {
- mdId: this.mendid,
- price: price,
- yfPrice: this.psf
- }, r => {
- console.log(r);
- console.log('-----------2', this.mendid, price, this.psf)
- if (r.data.code == 200) {
- this.kqList = r.data.data;
- if (this.kqList.length > 0) {
- this.yhhd = this.$t('order.qingxzyhkq');
- this.youyh = true;
- } else {
- if (!this.youyh) {
- this.yhhd = '';
- this.youyh = false;
- }
- }
- }
- this.jisuanjiner();
- }, failc => {
- //console.log('getadvertis----',failc)
- })
- },
- //积分
- getPoint() {
- api('getPoint', {}, r => {
- console.log("getPoint:", r);
- if (r.data.code == 200) {
- this.sumpoints = r.data.data.points; //积分
- this.pointsBl = r.data.data.bl; //积分抵扣值
- } else if (r.data.code == 500) {
- this.sumpoints = 0; //积分
- this.pointsBl = 0; //积分抵扣值
- }
- }, failc => {
- //console.log('getadvertis----',failc)
- })
- },
- hdradioChange(evt) {
- console.log(evt.detail.value)
- var hdids = evt.detail.value;
- var hdid = 0;
- var hdidpt = 0;
- var hdidsj = 0;
- for (var i = 0; i < hdids.length; i++) {
- var oid = hdids[i];
- if (oid == this.hdidpt) {
- hdidpt = oid;
- } else if (oid == this.hdidsj) {
- hdidsj = oid;
- } else {
- hdid = oid;
- }
- }
- this.hdidpt = hdidpt;
- this.hdidsj = hdidsj;
- var sobj = null;
- for (var i = 0; i < this.cxList.length; i++) {
- var obj = this.cxList[i];
- if (obj.id == hdid) {
- sobj = obj;
- break;
- }
- }
- if (this.cxList.length > 0 && hdid > 0) {
- for (var i = 0; i < this.cxList.length; i++) {
- var obj = this.cxList[i];
- if (obj.id == this.hdidpt) {
- if (sobj.salesType == obj.salesType) {
- this.hdidpt = 0;
- }
- }
- if (obj.id == this.hdidsj) {
- if (sobj.salesType == obj.salesType) {
- this.hdidsj = 0;
- }
- }
- }
- }
- if (this.kqList.length > 0 && hdid > 0) {
- for (var i = 0; i < this.kqList.length; i++) {
- var obj = this.kqList[i];
- if (obj.id == this.kqidpt) {
- if (sobj.salesType == obj.yhfangs) {
- this.kqidpt = 0;
- }
- }
- if (obj.id == this.kqidsj) {
- if (sobj.salesType == obj.yhfangs) {
- this.kqidsj = 0;
- }
- }
- }
- }
- if (hdid > 0) {
- if (sobj && sobj.type == 0) {
- this.hdidpt = hdid;
- } else if (sobj && sobj.type == 1) {
- this.hdidsj = hdid;
- }
- }
- this.jisuanjiner();
- },
- kaqradioChange(evt) {
- console.log(evt)
- var kqids = evt.detail.value;
- var kqid = 0;
- var kqidpt = 0;
- var kqidsj = 0;
- for (var i = 0; i < kqids.length; i++) {
- var oid = kqids[i];
- if (oid == this.kqidpt) {
- kqidpt = oid;
- } else if (oid == this.kqidsj) {
- kqidsj = oid;
- } else {
- kqid = oid;
- }
- }
- this.kqidpt = kqidpt;
- this.kqidsj = kqidsj;
- var sobj = null;
- for (var i = 0; i < this.kqList.length; i++) {
- var obj = this.kqList[i]
- if (obj.id == kqid) {
- sobj = obj;
- break;
- }
- }
- if (this.cxList.length > 0 && kqid > 0) {
- for (var i = 0; i < this.cxList.length; i++) {
- var obj = this.cxList[i];
- if (obj.id == this.hdidpt) {
- if (sobj.yhfangs == obj.salesType) {
- this.hdidpt = 0;
- }
- }
- if (obj.id == this.hdidsj) {
- if (sobj.yhfangs == obj.salesType) {
- this.hdidsj = 0;
- }
- }
- }
- }
- if (this.kqList.length > 0 && kqid > 0) {
- for (var i = 0; i < this.kqList.length; i++) {
- var obj = this.kqList[i];
- if (obj.id == this.kqidpt) {
- if (sobj.yhfangs == obj.yhfangs) {
- this.kqidpt = 0;
- }
- }
- if (obj.id == this.kqidsj) {
- if (sobj.yhfangs == obj.yhfangs) {
- this.kqidsj = 0;
- }
- }
- }
- }
- if (kqid >= 0) {
- if (sobj && sobj.type == 0) {
- this.kqidpt = kqid;
- } else if (sobj && sobj.type == 1) {
- this.kqidsj = kqid;
- }
- }
- this.jisuanjiner();
- },
- getNote(obj, index) {
- var str = '';
- if (index == 0) {
- var str = '';
- if (obj.salesType == 1 && obj.salesReduction > 1) { //优惠方式:1 运费,2 订单 ,3 商品
- str = this.$t('hongbaokq.yunfeiyh');
- }
- if (obj.salesType == 1 && obj.salesReduction < 1 && obj.salesReduction > 0) { //优惠方式:1 运费,2 订单 ,3 商品
- str = this.$t('hongbaokq.yunfeizk');
- }
- if (obj.salesType == 1 && obj.salesReduction == 0) { //优惠方式:1 运费,2 订单 ,3 商品
- str = this.$t('hongbaokq.yunfeiquanm');
- }
- if (obj.salesType == 2 && obj.salesReduction > 1) {
- str = this.$t('hongbaokq.dingdanyh');
- }
- if (obj.salesType == 2 && obj.salesReduction < 1) {
- str = this.$t('hongbaokq.dingdanzk');
- }
- if (obj.salesType == 3 && obj.salesReduction > 1) {
- str = this.$t('hongbaokq.shangpinyh');
- }
- if (obj.salesType == 3 && obj.salesReduction < 1) {
- str = this.$t('hongbaokq.shangpinzk');
- }
- if (obj.salesReduction != 0) {
- str = str + ' ' + obj.salesReduction;
- }
- }
- if (index == 1) {
- if (obj.yhfangs == 1 && obj.yhnum > 1) { //优惠方式:1 运费,2 订单 ,3 商品
- str = this.$t('hongbaokq.yunfeiyh');
- }
- if (obj.yhfangs == 1 && obj.yhnum < 1 && obj.yhnum > 0) { //优惠方式:1 运费,2 订单 ,3 商品
- str = this.$t('hongbaokq.yunfeizk');
- }
- if (obj.yhfangs == 1 && obj.yhnum == 0) { //优惠方式:1 运费,2 订单 ,3 商品
- str = this.$t('hongbaokq.yunfeiquanm');
- }
- if (obj.yhfangs == 2 && obj.yhnum > 1) {
- str = this.$t('hongbaokq.dingdanyh');
- }
- if (obj.yhfangs == 2 && obj.yhnum < 1) {
- str = this.$t('hongbaokq.dingdanzk');
- }
- if (obj.yhfangs == 3 && obj.yhnum > 1) {
- str = this.$t('hongbaokq.shangpinyh');
- }
- if (obj.yhfangs == 3 && obj.yhnum < 1) {
- str = this.$t('hongbaokq.shangpinzk');
- }
- if (obj.yhnum != 0) {
- str = str + ' ' + obj.yhnum;
- }
- }
- return str;
- },
- querenyhhd() {
- this.showpop = false;
- },
- //积分兑换
- jifenduihuan() {
- if (this.sumpoints > 0) {
- this.isjifenduihan = !this.isjifenduihan;
- } else {
- this.isjifenduihan = false;
- }
- },
- jisuandikou(dingdanjiner) {
- var sumkyjine = this.sumpoints * this.pointsBl;
- if (sumkyjine > dingdanjiner) {
- var jifen = dingdanjiner / this.pointsBl;
- jifen = parseInt(jifen);
- this.points = jifen;
- this.pointsReduction = jifen * this.pointsBl;
- } else {
- this.points = this.sumpoints;
- this.pointsReduction = sumkyjine;
- }
- return this.pointsReduction;
- },
- //商品数量加减
- jiajian(index, state) {
- if (this.actType > 0) {
- return;
- }
- var tempList = this.foodlist;
- if (state > 0) {
- var temp = tempList[index];
- temp.number = temp.number + 1;
- tempList[index] = temp;
- this.gengxingouwuche(temp);
- } else {
- var temp = tempList[index];
- if (temp.number > 1) {
- temp.number = temp.number - 1;
- tempList[index] = temp;
- } else {
- temp.number = temp.number - 1;
- tempList.splice(index, 1);
- }
- this.gengxingouwuche(temp);
- }
- this.foodlist = tempList;
- this.cuxiaoList();
- if (this.foodlist.length == 0) {
- uni.showToast({
- title: that.$t('comp.qingxzsp'),
- icon: 'none',
- duration: 2500
- })
- }
- },
- xuanzcux() {
- this.showpop = true;
- },
- chooseCancel() {
- this.showpop = false;
- this.zffsS = false;
- console.log('chooseCancel');
- },
- //--------------------------------------------------------
- arraytoStr(arry) {
- var str = '';
- if (arry.length > 0) {
- for (var i = 0; i < arry.length; i++) {
- str = str + arry[i] + '; ';
- }
- }
- return str;
- },
- jisuanjiner() {
- this.spxj = 0;
- this.hyyh = 0;
- this.zje = 0;
- for (var i = 0; i < this.foodlist.length; i++) {
- this.spxj = this.spxj + (this.foodlist[i].price + this.foodlist[i].otherPrice) * this.foodlist[i]
- .number;
- }
- this.hyyh = this.jisuanyouhuijiner(this.spxj);
- this.hyyh = parseInt(this.hyyh);
- this.zje = (this.spxj + this.psf) - this.hyyh;
- this.zje = parseInt(this.zje);
- //开始积分抵扣
- this.jisuandikou(this.zje)
- this.zje = this.zje - this.pointsReduction;
- this.zje = parseInt(this.zje);
- //
- },
- jisuanyouhuijiner(price) {
- var zongyouhui = 0;
- this.salesReduction = 0;
- this.mdSalesReduction = 0;
- this.discountAmount = 0;
- this.mdDiscountAmount = 0;
- if (this.cxList.length > 0) {
- for (var i = 0; i < this.cxList.length; i++) {
- var obj = this.cxList[i];
- console.log('111111', this.hdidpt, obj)
- if (obj.id == this.hdidpt) {
- console.log('111111', this.hdidpt, obj)
- if (obj.salesType == "1") {
- if (obj.salesReduction < 1) {
- this.salesReduction = this.psf * (100 - obj.salesReduction * 100) / 100;
- } else if (obj.salesReduction > 1) {
- if (obj.salesReduction > this.psf) {
- this.salesReduction = this.psf;
- } else {
- this.salesReduction = obj.salesReduction;
- }
- }
- }
- if (obj.salesType == "2") {
- if (obj.salesReduction < 1) {
- this.salesReduction = this.salesReduction + (price + this.psf) * (100 - obj
- .salesReduction * 100) / 100;
- } else if (obj.salesReduction > 1) {
- if (obj.salesReduction > (price + this.psf)) {
- this.salesReduction = (price + this.psf);
- } else {
- this.salesReduction = obj.salesReduction;
- }
- }
- console.log(price, obj.salesReduction, price * (1 - obj.salesReduction))
- }
- if (obj.salesType == "3") {
- if (obj.salesReduction < 1) {
- this.salesReduction = this.salesReduction + price * (100 - obj.salesReduction * 100) /
- 100;
- } else if (obj.salesReduction > 1) {
- if (obj.salesReduction > price) {
- this.salesReduction = price;
- } else {
- this.salesReduction = obj.salesReduction;
- }
- }
- }
- }
- if (obj.id == this.hdidsj) {
- console.log('1111112', this.hdidsj, obj)
- if (obj.salesType == "1") {
- this.mdSalesReduction = this.mdSalesReduction + this.psf;
- if (obj.salesReduction < 1) {
- this.mdSalesReduction = this.psf * (100 - obj.salesReduction * 100) / 100;
- } else if (obj.salesReduction > 1) {
- if (obj.salesReduction > this.psf) {
- this.mdSalesReduction = this.psf;
- } else {
- this.mdSalesReduction = obj.salesReduction;
- }
- }
- }
- if (obj.salesType == "2") {
- if (obj.salesReduction < 1) {
- this.mdSalesReduction = this.mdSalesReduction + (price + this.psf) * (100 - obj
- .salesReduction * 100) / 100;
- } else if (obj.salesReduction > 1) {
- if (obj.salesReduction > (price + this.psf)) {
- this.mdSalesReduction = (price + this.psf);
- } else {
- this.mdSalesReduction = obj.salesReduction;
- }
- }
- }
- if (obj.salesType == "3") {
- if (obj.salesReduction < 1) {
- this.mdSalesReduction = this.mdSalesReduction + price * (100 - obj.salesReduction *
- 100) / 100;
- } else if (obj.salesReduction > 1) {
- if (obj.salesReduction > price) {
- this.mdSalesReduction = price;
- } else {
- this.mdSalesReduction = obj.salesReduction;
- }
- }
- }
- }
- }
- }
- if (this.kqList.length > 0) {
- for (var i = 0; i < this.kqList.length; i++) {
- var obj = this.kqList[i];
- if (obj.id == this.kqidpt) {
- console.log('1111113', this.kqidpt, obj)
- if (obj.yhfangs == 1) {
- if (obj.yhnum < 1) {
- this.discountAmount = this.psf * (100 - obj.yhnum * 100) / 100;
- } else if (obj.yhnum > 1) {
- if (obj.yhnum > this.psf) {
- this.discountAmount = this.psf;
- } else {
- this.discountAmount = obj.yhnum;
- }
- }
- }
- if (obj.yhfangs == 2) {
- if (obj.yhnum < 1) {
- this.discountAmount = (price + this.psf) * (100 - obj.yhnum * 100) / 100;
- } else if (obj.yhnum > 1) {
- if (obj.yhnum > (price + this.psf)) {
- this.discountAmount = (price + this.psf);
- } else {
- this.discountAmount = obj.yhnum;
- }
- }
- console.log(price, obj.yhnum, price * (1 - obj.yhnum))
- }
- if (obj.yhfangs == 3) {
- if (obj.yhnum < 1) {
- this.discountAmount = price * (100 - obj.yhnum * 100) / 100;
- } else if (obj.yhnum > 1) {
- if (obj.yhnum > price) {
- this.discountAmount = price;
- } else {
- this.discountAmount = obj.yhnum;
- }
- }
- }
- }
- if (obj.id == this.kqidsj) {
- console.log('1111114', this.kqidsj, obj)
- if (obj.yhfangs == 1) {
- if (obj.yhnum < 1) {
- this.mdDiscountAmount = this.psf * (100 - obj.yhnum * 100) / 100;
- } else if (obj.yhnum > 1) {
- if (obj.yhnum > this.psf) {
- this.mdDiscountAmount = this.psf;
- } else {
- this.mdDiscountAmount = obj.yhnum;
- }
- }
- }
- if (obj.yhfangs == 2) { //订单
- if (obj.yhnum > 1) {
- if (obj.yhnum > (price + this.psf)) {
- this.mdDiscountAmount = (price + this.psf);
- } else {
- this.mdDiscountAmount = obj.yhnum;
- }
- } else {
- this.mdDiscountAmount = this.mdDiscountAmount + (price + this.psf) * (100 - obj.yhnum *
- 100) / 100;
- }
- console.log(price, obj.yhnum, price * (1 - obj.yhnum))
- }
- if (obj.yhfangs == 3) { //商品
- if (obj.yhnum > 1) {
- if (obj.yhnum > price) {
- this.mdDiscountAmount = price;
- } else {
- this.mdDiscountAmount = obj.yhnum;
- }
- } else {
- this.mdDiscountAmount = this.mdDiscountAmount + price * (100 - obj.yhnum * 100) / 100;
- }
- console.log(price, obj.yhnum, price * (1 - obj.yhnum))
- }
- }
- }
- }
- console.log(this.hdidpt, this.hdidsj, this.kqidpt, this.kqidsj)
- console.log(this.salesReduction, this.mdSalesReduction, this.discountAmount, this.mdDiscountAmount)
- zongyouhui = this.salesReduction + this.mdSalesReduction + this.discountAmount + this.mdDiscountAmount;
- console.log('zongyouhui:', zongyouhui);
- return zongyouhui;
- },
- sumfontnum(e) {
- this.remarks = e.target.value;
- },
- shifodaofu() {
- if (this.actType > 1) {
- return;
- }
- if (this.shifoudf == 0) {
- this.shifoudf = 1;
- } else {
- this.shifoudf = 0;
- }
- if (this.actType == 1 && this.shifoudf == 1) {
- this.actTitle = this.$t('index.huodaofukan');
- uni.showToast({
- title: this.$t('order.xuanzezhif'),
- icon: 'none',
- duration: 2500
- })
- } else if (this.actType == 1 && this.shifoudf == 0) {
- this.actTitle = this.$t('order.quzhifu');
- }
- console.log(this.shifoudf)
- },
- changaddr() {
- uni.navigateTo({
- url: '/pages/UserCenter/dizhi/dizhilist'
- })
- },
- yuyueshijian() {
- this.$refs.chooseTime.open()
- },
- changeTime(e) {
- //选择的时间
- console.log('选择的时间', e.value);
- this.delryTime = e.value;
- },
- deliveryclose() {
- this.delryTime = '';
- },
- peisong() {
- if (this.actType > 0) {
- return;
- }
- this.showAdrr = 0;
- this.peisongimg = '/static/images/peisongh@3x.png';
- this.ziquimg = '/static/images/ziqu@3x.png';
- this.tangshiimg = '/static/images/tangshih.png';
- this.Bcolor = 'whitesmoke';
- this.Bcolorr = 'lightgray';
- this.Bcolorrr = 'lightgray';
- this.Tcolor = 'black';
- this.Tcolorr = 'darkgray';
- this.Tcolorrr = 'darkgray';
- this.psf = parseFloat(this.freight);
- this.jisuanjiner();
- },
- ziqu() {
- if (this.actType > 0) {
- return;
- }
- this.showAdrr = 1;
- this.peisongimg = '/static/images/peisong@3x.png';
- this.ziquimg = '/static/images/ziquh@3x.png';
- this.tangshiimg = '/static/images/tangshih.png';
- this.Bcolor = 'lightgray';
- this.Bcolorr = 'whitesmoke';
- this.Bcolorrr = 'lightgray';
- this.Tcolor = 'darkgray';
- this.Tcolorr = 'black';
- this.Tcolorrr = 'darkgray';
- this.psf = 0;
- this.jisuanjiner();
- },
- tangshi() {
- this.showAdrr = 2;
- this.peisongimg = '/static/images/peisong@3x.png';
- this.ziquimg = '/static/images/ziqu@3x.png';
- this.tangshiimg = '/static/images/tangshi.png';
- this.Bcolor = 'lightgray';
- this.Bcolorr = 'lightgray';
- this.Bcolorrr = 'whitesmoke';
- this.Tcolor = 'darkgray';
- this.Tcolorr = 'darkgray';
- this.Tcolorrr = 'black';
- this.psf = 0;
- this.jisuanjiner();
- },
- //确认订单,要求下载app
- qufukuan() {
- if (this.foodlist.length == 0) {
- uni.showToast({
- title: this.$t('comp.qingxzsp'),
- icon: 'none',
- duration: 2500
- })
- return;
- }
- api('getAppDownload', {}, r => {
- console.log(r)
- uni.showModal({
- title: this.$t('api.message'),
- content: this.$t('jiesuan.xiazapp'),
- showCancel: true,
- cancelText: this.$t('jiesuan.xzios'),
- confirmText: this.$t('jiesuan.xiazandriod'),
- success: (res) => {
- if (res.confirm) {
- // 点击下载Android版本
- const isAndroid = this.isAndroidDevice();
- if (isAndroid) {
- // 安卓设备自动下载并安装
- this.downloadAndInstallAndroid(r.data.data.androidUrl);
- } else {
- // 非安卓设备直接打开下载链接
- window.open(r.data.data.androidUrl, '_blank');
- }
- } else if (res.cancel) {
- // 点击下载iOS版本
- this.downloadIOSApp(r.data.data.iosUrl);
- }
- }
- });
- return;
- });
- return
- if (this.keyixd == false) {
- uni.showToast({
- title: this.$t('mend.dianjiastatedy'),
- icon: 'none',
- duration: 2500
- })
- return;
- }
- if (this.actType == 2) { //已经支付过了!!
- // uni.showToast({
- // title: '已经支付过了!!',
- // icon: 'none',
- // duration: 2500
- // })
- return;
- }
- if (this.actType == 1) { //未支付,跳转支付
- this.zffsS = true;
- return;
- }
- var data;
- if (this.ddId.length > 0) {
- console.log('已经生成订单,不能重复提交');
- } else {
- this.ddId = '99' + new Date().valueOf();
- }
- var cretim = getApp().globalData.sj();
- // console.log(cretim);
- // return;
- if (this.showAdrr == 0) {
- if (this.dizhiID == '') {
- uni.showToast({
- title: this.$t('order.shdz'),
- icon: 'none',
- duration: 3500
- })
- return;
- }
- if (!this.isGetyunfei) {
- uni.showToast({
- title: this.$t('order.hqyfsb'),
- icon: 'none',
- duration: 3500
- })
- return;
- }
- data = {
- "ddId": this.ddId,
- "shId": this.userid,
- "mdId": this.mendid,
- "shdzId": this.dizhiID.id,
- "amount": this.zje,
- "remarks": this.remarks,
- "type": 0,
- "delryTime": this.delryTime, //new Date().toISOString(),
- "foodlist": this.foodlist,
- "freight": this.psf,
- "jvli": this.jvli,
- "longitude": this.mendianMs.longitude,
- "latitude": this.mendianMs.latitude,
- "collectPayment": this.shifoudf,
- "cretim": cretim,
- "yhId": this.kqidpt, //平台使用优惠券id
- "mdYhId": this.kqidsj, //门店优惠券id
- "activity": this.hdidpt, //平台促销活动id
- "mdActivity": this.hdidsj, //门店促销活动id
- "salesReduction": this.salesReduction, //平台促销減免值
- "mdSalesReduction": this.mdSalesReduction, //门店促销減免值
- "discountAmount": this.discountAmount, //平台优惠券优惠金额
- "mdDiscountAmount": this.mdDiscountAmount, //门店优惠券优惠金额
- "xiadanjiaoyan": 2
- }
- } else {
- data = {
- "ddId": this.ddId,
- "shId": this.userid,
- "mdId": this.mendid,
- "shdzId": '',
- "amount": this.zje,
- "remarks": this.remarks,
- "type": this.showAdrr,
- "delryTime": this.delryTime, // new Date().toISOString(),
- "foodlist": this.foodlist,
- "freight": this.psf,
- "jvli": this.jvli,
- "longitude": this.mendianMs.longitude,
- "latitude": this.mendianMs.latitude,
- "collectPayment": this.shifoudf,
- "cretim": cretim,
- "yhId": this.kqidpt, //平台使用优惠券id
- "mdYhId": this.kqidsj, //门店优惠券id
- "activity": this.hdidpt, //平台促销活动id
- "mdActivity": this.hdidsj, //门店促销活动id
- "salesReduction": this.salesReduction, //平台促销減免值
- "mdSalesReduction": this.mdSalesReduction, //门店促销減免值
- "discountAmount": this.discountAmount, //平台优惠券优惠金额
- "mdDiscountAmount": this.mdDiscountAmount, //门店优惠券优惠金额
- "xiadanjiaoyan": 2
- }
- }
- this.zhifuUrl = '';
- this.addorder(data);
- },
- getaddressList() {
- api('getaddressList', {}, r => {
- this.addrList = r.data.data;
- if (this.dizhiID != '') {
- console.log('3333')
- this.getyunfei(this.dizhiID.latitude, this.dizhiID.longitude);
- } else {
- if (this.addrList.length > 0) {
- console.log('2222')
- this.dizhiID = this.addrList[0];
- this.mpImage = this.dizhiID.annexes;
- this.getyunfei(this.dizhiID.latitude, this.dizhiID.longitude);
- }
- }
- }, failc => {
- //console.log('getadvertis----',failc)
- })
- },
- getmendianDetail(id) {
- api('getmendianDetail', {
- id: id
- }, r => {
- this.mendianMs = r.data.data;
- console.log('getmendianDetail', this.mendianMs);
- if (this.mendianMs) {
- if (this.mendianMs.state == 1) {
- this.keyixd = false;
- }
- }
- if (this.dizhiID == '') {
- this.getaddressList();
- } else {
- console.log('111')
- this.getyunfei(this.dizhiID.latitude, this.dizhiID.longitude);
- }
- }, failc => {
- //console.log('getadvertis----',failc)
- })
- },
- getyunfei(lat, lng) {
- if (this.mendianMs == '') {
- return;
- }
- //this.getjuliForyunfei(lat,lng);//前端请求规划路径
- //this.getjuliForyunfeiHT(lat,lng);//后端请求规划路径
- //先请求直线距离运费,如果规划路径运费小于直线距离则用直线距离的值
- //1--------在这个方法中调用规划计算
- console.log("getyunfei----------")
- this.zhixianyuanfei(lat, lng);
- },
- //通过坐标直线计算运费
- zhixianyuanfei(lat, lng) {
- var that = this;
- api('getyunfei', {
- lat1: lng,
- lng1: lat,
- lat2: this.mendianMs.longitude,
- lng2: this.mendianMs.latitude
- }, r => {
- console.log('直线运费');
- console.log(r);
- if (r.data.code != 200) {
- return;
- }
- that.freight = parseInt(r.data.data.freight);
- if (that.freight > 0) {} else {
- that.freight = 0;
- }
- that.zhixianfreight = that.freight;
- that.zhixianjuli = r.data.data.jvli;
- that.getjuliForyunfeiHT(lat, lng);
- }, failc => {
- //console.log('getadvertis----',failc)
- })
- },
- getjuliForyunfei(lat, lng) { //前端
- var data = {
- "origin": {
- "location": {
- "latLng": {
- "latitude": lat,
- "longitude": lng
- }
- }
- },
- "destination": {
- "location": {
- "latLng": {
- "latitude": this.mendianMs.latitude,
- "longitude": this.mendianMs.longitude
- }
- }
- },
- "travelMode": "DRIVE",
- "units": "METRIC" //米
- };
- console.log(data);
- api('getdistense', data, r => {
- console.log('getadvertis----', r);
- if (r.statusCode == 200) {
- var dist = r.data.routes[0].distanceMeters;
- console.log(dist / 1000);
- this.getyunfeiWithJuli(dist / 1000);
- console.log('路径运费');
- } else {
- this.zhixianyuanfei(lat, lng);
- console.log('路径计算距离失败!');
- uni.showToast({
- title: '计算距离失败!',
- icon: 'none',
- duration: 3500
- })
- }
- }, failc => {
- console.log('getadvertis----', failc)
- })
- },
- getjuliForyunfeiHT(lat, lng) {
- var that = this;
- var latlng1 = '' + lat + ',' + lng;
- var latlng2 = '' + this.mendianMs.latitude + ',' + this.mendianMs.longitude;
- // var latlng1='10.715641,106.73932';//''+lat+','+lng;
- // var latlng2='10.754999,106.735601';//''+this.mendianMs.latitude+','+this.mendianMs.longitude;
- api('getluxianjvli', {
- latlng1: latlng1,
- latlng2: latlng2,
- id: this.userid
- }, r => {
- console.log('getjuliForyunfeiHT', r);
- if (r.data.code == 200) {
- if (r.data.data[0]) {
- var legs = r.data.data[0].legs;
- if (legs[0]) {
- var juli = legs[0].distance.value;
- // uni.showToast({
- // title:'通过轨迹计算运费',
- // icon: 'none',
- // duration: 3500
- // })
- if (juli > that.zhixianjuli) {
- that.getyunfeiWithJuli(juli / 1000);
- } else {
- that.psf = that.freight;
- that.jvli = that.zhixianjuli;
- that.isGetyunfei = true;
- console.log('直线运费');
- if (this.showAdrr == 0) {
- that.jisuanjiner();
- }
- }
- return;
- }
- }
- }
- that.psf = that.freight;
- that.jvli = that.zhixianjuli;
- that.isGetyunfei = true;
- console.log('直线运费');
- if (this.showAdrr == 0) {
- that.jisuanjiner();
- }
- }, failc => {
- //console.log('getadvertis----',failc)
- })
- },
- getyunfeiWithJuli(distence) {
- var that = this;
- api('getZuiyyfei', {
- quli: JSON.stringify(distence)
- }, r => {
- console.log(r);
- if (r.data.code != 200) {
- return;
- }
- that.psf = parseInt(r.data.data.freight);
- if (that.psf > 0) {} else {
- that.psf = 0;
- }
- that.freight = that.psf;
- that.jvli = r.data.data.jvli;
- that.isGetyunfei = true;
- if (this.showAdrr == 0) {
- that.jisuanjiner();
- }
- }, failc => {
- //console.log('getadvertis----',failc)
- })
- },
- addorder(data) {
- var that = this;
- uni.showLoading({
- title: 'Loading...',
- mask: true
- })
- console.log('addorder', data);
- api('addorder', data,
- r => {
- console.log(r);
- uni.hideLoading();
- if (r.data.code == 200) {
- this.qingkonggouwuche();
- this.ddId = data.ddId;
- this.rId = r.data.data.id;
- this.orderDetl = r.data.data;
- if (this.shifoudf == 0) {
- this.actType = 1;
- this.actTitle = that.$t('order.quzhifu');
- uni.showToast({
- title: that.$t('order.xuanzezhif'),
- icon: 'none',
- duration: 2500
- })
- } else {
- this.actType = 1;
- this.actTitle = that.$t('index.huodaofukan');
- //到付订单,直接更新支付状态
- this.huodaofukuan();
- }
- } else {
- uni.showToast({
- title: r.data.msg,
- icon: 'none',
- duration: 3000
- })
- }
- }, failc => {
- uni.hideLoading();
- //console.log('getadvertis----',failc)
- })
- },
- getVNPay() {
- api('setorderuzt', {
- id: this.rId,
- "collectPayment": 0
- }, res => {
- if (res.data.code != 200) {
- return;
- }
- }, failc => {
- return;
- })
- this.zffsS = false;
- var language = uni.getStorageSync('language');
- var lg;
- if (language == 'yuenan') {
- lg = 'vi';
- } else {
- lg = 'en';
- }
- uni.showLoading({
- title: 'Loading...',
- mask: true
- })
- api('VNPay', {
- orderid: this.ddId,
- amount: parseInt(this.zje),
- language: lg
- }, r => {
- uni.hideLoading();
- if (r.data.code != 200) {
- uni.showToast({
- title: r.data.msg,
- icon: 'none',
- duration: 3500
- })
- return;
- }
- this.shifouzhifu = true;
- this.zhifuUrl = '/pages/OrderList/buy/Zhifuyemian?url=' + encodeURIComponent(JSON.stringify(r
- .data.data)) + '&ddid=' + this.ddId;
- uni.navigateTo({
- url: '/pages/OrderList/buy/Zhifuyemian?url=' + encodeURIComponent(JSON.stringify(r
- .data.data)) + '&ddid=' + this.ddId
- })
- }, failc => {
- uni.hideLoading();
- //console.log('getadvertis----',failc)
- })
- },
- huodaofukuan() {
- this.shifoudf = 1;
- this.zffsS = false;
- uni.showLoading({
- title: 'Loading...',
- mask: true
- })
- var that = this;
- api('setorderuzt', {
- id: this.rId,
- "collectPayment": this.shifoudf
- }, res => {
- console.log('setorderuzt:', res)
- uni.hideLoading();
- if (res.data.code == 200) {
- this.actType = 2;
- this.actTitle = that.$t('order.yizhifu');
- uni.showToast({
- title: that.$t('order.xiadancg'),
- icon: 'none',
- duration: 2500,
- mask: true
- })
- setTimeout(function() {
- // 这里写要延时执行的代码
- uni.redirectTo({
- url: '/pages/OrderList/OrderDetail?ddid=' + that.ddId +
- '&isShangjia=0'
- })
- }, 2500);
- } else {
- if (res.data.msg) {
- uni.showToast({
- title: res.data.msg,
- icon: 'none',
- duration: 2000
- })
- }
- }
- }, failc => {
- uni.hideLoading();
- //console.log('getadvertis----',failc)
- })
- },
- setorderuzt() {
- var that = this;
- api('setorderuzt', {
- id: this.rId,
- state: 1
- }, res => {
- this.actType = 2;
- this.actTitle = that.$t('order.yizhifu');
- uni.showToast({
- title: that.$t('order.xiadancg'),
- icon: 'none',
- duration: 2500,
- mask: true
- })
- setTimeout(function() {
- // 这里写要延时执行的代码
- uni.redirectTo({
- url: '/pages/OrderList/OrderDetail?ddid=' + that.ddId + '&isShangjia=0'
- })
- }, 2500);
- }, failc => {
- //console.log('getadvertis----',failc)
- })
- },
- getorderDetl() {
- var that = this;
- api('getorderxq', {
- ddid: this.ddId
- }, r => {
- this.orderDetl = r.data.data;
- if (this.orderDetl.state == 1) {
- that.actType = 2;
- that.actTitle = that.$t('order.yizhifu');
- uni.showToast({
- title: that.$t('order.xiadancg'),
- icon: 'none',
- duration: 2500,
- mask: true
- })
- setTimeout(function() {
- // 这里写要延时执行的代码
- uni.redirectTo({
- url: '/pages/OrderList/OrderDetail?ddid=' + that.ddId +
- '&isShangjia=0'
- })
- }, 2500);
- }
- }, failc => {
- //console.log('getadvertis----',failc)
- })
- },
- qingkonggouwuche() {
- if (this.foodlist.length > 1) {
- uni.setStorageSync('gouwuche', '');
- return;
- }
- var gwc = uni.getStorageSync('gouwuche');
- var gouwuche;
- if ('' == gwc || null == gwc || undefined == gwc) {} else {
- gouwuche = JSON.parse(gwc);
- if (gouwuche.foodlist.length <= 1) {
- uni.setStorageSync('gouwuche', '');
- return;
- }
- for (var i = 0; i < gouwuche.foodlist.length; i++) {
- var sp = gouwuche.foodlist[i];
- if (this.foodlist[0].id == sp.id) {
- gouwuche.foodlist.splice(i, 1);
- let gwcS = JSON.stringify(gouwuche);
- uni.setStorageSync('gouwuche', gwcS);
- }
- }
- }
- },
- gengxingouwuche(item) {
- var gwc = uni.getStorageSync('gouwuche');
- if ('' == gwc || null == gwc || undefined == gwc) {
- return;
- }
- var gouwuche = JSON.parse(gwc);
- for (var i = 0; i < gouwuche.foodlist.length; i++) {
- var sp = gouwuche.foodlist[i];
- if (item.id == sp.id) {
- if (item.number > 0) {
- gouwuche.foodlist[i].number = item.number;
- } else {
- gouwuche.foodlist.splice(i, 1);
- }
- if (gouwuche.foodlist.length < 1) {
- uni.setStorageSync('gouwuche', '');
- } else {
- let gwcS = JSON.stringify(gouwuche);
- uni.setStorageSync('gouwuche', gwcS);
- }
- return;
- }
- }
- },
- pushMsg(cid, orderId) { //消息推送
- api('pushMsgSJ', {
- cid: cid,
- title: '您有新订单了',
- content: orderId,
- payload: ''
- }, res => {
- console.log(res)
- }, failc => {
- //console.log('getadvertis----',failc)
- })
- },
- selectImage() {
- console.log('selectImage');
- this.$refs.yhdslCropper.chooseImage();
- },
- uploadImg(e) {
- console.log('------------uploadImg:', e)
- this.spImage = e;
- var that = this;
- uni.uploadFile({
- url: this.$upImagurl, //上传图片api
- filePath: e,
- name: 'file',
- header: {
- //"Authorization": userinfo.token
- },
- success: (res) => {
- let group = JSON.parse(res.data);
- that.mpImage = group.data;
- console.log(group)
- api('ADDaddress', {
- id: that.dizhiID.id,
- annexes: that.mpImage
- },
- res => {
- if (res.data.code == 200) {
- that.dizhiID.annexes = that.mpImage;
- uni.setStorageSync("peisongdizhi", that.dizhiID);
- }
- console.log('getGoodsDetail:', res);
- }, failc => {
- //console.log('getadvertis----',failc)
- })
- uni.showToast({
- title: that.$t('mend.shangccg'),
- icon: "success"
- })
- }
- });
- },
- }
- }
- </script>
- <style lang="scss">
- page {
- background-color: #F2F3F7;
- }
- .contentV {
- width: 100%;
- position: relative;
- }
- .linesp {
- width: 100%;
- height: 8rpx;
- background-color: aliceblue;
- }
- .pinglun {
- margin: 16rpx;
- padding: 10rpx;
- width: 92%;
- height: 100rpx;
- border-radius: 15rpx;
- border: 2rpx solid lightgray;
- }
- .ctinrow {
- margin-top: 20rpx;
- width: 100%;
- height: 80rpx;
- display: flex;
- flex-direction: row;
- align-items: center;
- justify-content: center;
- }
- .delbtct {
- margin-left: 10%;
- margin-top: 20rpx;
- padding-bottom: 30rpx;
- width: 80%;
- }
- .delbt {
- text-align: center;
- font-size: 36rpx;
- width: 100%;
- height: 80rpx;
- line-height: 80rpx;
- color: white;
- background-color: goldenrod;
- border-radius: 10rpx;
- }
- .topSwichV {
- height: 70rpx;
- width: 280rpx;
- border-radius: 35rpx;
- display: flex;
- flex-direction: row;
- align-items: center;
- justify-content: center;
- }
- .topSwichVL {
- margin-left: -40rpx;
- height: 70rpx;
- width: 200rpx;
- border-radius: 35rpx;
- display: flex;
- flex-direction: row;
- align-items: center;
- justify-content: center;
- }
- .toppz {
- width: 50rpx;
- }
- .toppztext {
- font-size: 30rpx;
- }
- .spnodetail {
- display: flex;
- flex-direction: row;
- align-items: center;
- background-color: white;
- margin-top: 20rpx;
- margin-bottom: 20rpx;
- }
- .spIcon {
- margin: 20rpx;
- width: 90rpx;
- height: 90rpx;
- }
- .xiaoji {
- margin-left: auto;
- margin-right: 30rpx;
- }
- .actBTV {
- width: 100%;
- display: flex;
- flex-direction: row;
- justify-content: space-between;
- align-items: center;
- }
- .viewinrow {
- display: flex;
- flex-direction: row;
- align-items: center;
- width: 100%;
- }
- .kouweisku {
- padding-right: 10rpx;
- color: chocolate;
- font-size: 26rpx;
- }
- .shifdf {
- height: 90rpx;
- width: 90%;
- margin-left: 5%;
- align-items: center;
- }
- .shifdftext {
- margin-left: 30rpx;
- font-size: 30rpx;
- }
- .hdts {
- margin-left: 30rpx;
- font-size: 30rpx;
- overflow: hidden;
- text-overflow: ellipsis;
- display: -webkit-box;
- -webkit-line-clamp: 1;
- -webkit-box-orient: vertical;
- }
- .picker-view {
- width: 750rpx;
- height: 300rpx;
- margin-top: 10rpx;
- }
- .item {
- line-height: 100rpx;
- text-align: center;
- }
- .zhifbut {
- text-align: center;
- margin-top: 12rpx;
- margin-bottom: 12rpx;
- width: 80%;
- border-radius: 10rpx;
- color: white;
- line-height: 70rpx;
- }
- .imageRJ {
- width: 40rpx;
- height: 40rpx;
- margin-right: 8rpx;
- }
- .imageR {
- width: 40rpx;
- height: 40rpx;
- margin-right: 30rpx;
- }
- .textR {
- font-size: 26rpx;
- margin-left: 6rpx;
- margin-right: 6rpx;
- }
- </style>
|