jiesuanYe.vue 62 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280
  1. <template>
  2. <view class="contentV">
  3. <customNav :shownav="true" :title="$t('index.xiadanzhifu')" titledetl=""></customNav>
  4. <view class="ctinrow">
  5. <view class="topSwichV" :style="{backgroundColor:Bcolor}" @click="peisong">
  6. <view class="topSwichV">
  7. <image class="toppz" :src="peisongimg" mode="widthFix"></image>
  8. <text class="toppztext" :style="{color:Tcolor}">{{$t('order.peisong')}}</text>
  9. </view>
  10. </view>
  11. <view class="topSwichVL" :style="{backgroundColor:Bcolorr}" @click="ziqu">
  12. <view class="topSwichVL">
  13. <image class="toppz" :src="ziquimg" mode="widthFix"></image>
  14. <text class="toppztext" :style="{color:Tcolorr}">{{$t('order.ziqu')}}</text>
  15. </view>
  16. </view>
  17. <!-- <view class="topSwichVL" :style="{backgroundColor:Bcolorrr}" @click="tangshi">
  18. <view class="topSwichVL">
  19. <image class="toppz" :src="tangshiimg" mode="widthFix"></image>
  20. <text class="toppztext" :style="{color:Tcolorrr}">{{$t('shouye.tangshi')}}</text>
  21. </view>
  22. </view> -->
  23. </view>
  24. <label class="linesp"></label>
  25. <uni-list v-if="showAdrr==0">
  26. <uni-list-item :title="dizhiID.address" :note="dizhiID.phone" :rightText="dizhiID.name"
  27. thumb="/static/images/dizhil@3x.png" thumb-size="sm" @click="changaddr" link></uni-list-item>
  28. </uni-list>
  29. <uni-list>
  30. <uni-list-item :title="delryTime.length>0?$t('order.yuyueshijian'):$t('order.jinkuaisd')"
  31. :note="delryTime.length>0?delryTime:('10~20 '+$t('order.Xfenzhongsd'))"
  32. :rightText="$t('order.yuyueshijian')" thumb="/static/images/time@3x.png" thumb-size="sm"
  33. @click="yuyueshijian" link></uni-list-item>
  34. </uni-list>
  35. <label class="linesp"></label>
  36. <label class="linesp"></label>
  37. <uni-list>
  38. <uni-list-item :title="$t('index.goodslist')"></uni-list-item>
  39. </uni-list>
  40. <view v-for="(item,findex) in foodlist">
  41. <view class="spnodetail">
  42. <view class="">
  43. <myImage class="spIcon" :mysrc="item.image" mymode="scaleToFill"></myImage>
  44. </view>
  45. <view style="width: 82%;">
  46. <view class="actBTV">
  47. <view style="font-size: 30rpx;width: 100%;">
  48. <text class="text2row" style="width: 100%;">{{item.name}}</text>
  49. </view>
  50. <view class="contentInRowL">
  51. <image v-if="item.number>0" class="imageRJ" src="/static/images/jian@3x.png"
  52. mode="aspectFit" @click="jiajian(findex,-1)"></image>
  53. <text v-if="item.number>0" class="textR">{{item.number}}</text>
  54. <image class="imageR" src="/static/images/plus-circle-fill@3x.png" mode="aspectFit"
  55. @click="jiajian(findex,1)"></image>
  56. </view>
  57. </view>
  58. <view class="actBTV">
  59. <view style="font-size: 26rpx;color: blueviolet;">{{$t('shangpin.shoujia')}}:
  60. {{$formPr(item.price+item.otherPrice)}}{{$t('locale.huobidw')}}
  61. </view>
  62. <view class="xiaoji" style="font-size: 28rpx;color: brown;">{{$t('shangpin.xiaoji')}}:
  63. {{$formPr((item.price+item.otherPrice)*item.number)}}{{$t('locale.huobidw')}}
  64. </view>
  65. </view>
  66. <view class="viewinrow">
  67. <text class="kouweisku">{{arraytoStr(item.ask)}}</text>
  68. </view>
  69. <view v-if="item.beizhu" class="">
  70. <text style="font-size: 30rpx;color:#00A6FF;">{{item.beizhu}}</text>
  71. </view>
  72. </view>
  73. </view>
  74. </view>
  75. <label class="linesp"></label>
  76. <label class="linesp"></label>
  77. <view style="background-color:white;width: 100%;">
  78. <view class="contentInRowS shifdf" @click="xuanzcux">
  79. <view class="contentInRowL" style="width: 86%;">
  80. <image style="width: 50rpx;height: 50rpx;" src="/static/images/hongbkqh@3x.png" mode="scaleToFill">
  81. </image>
  82. <view class="contentColumn" style="width: 100%;">
  83. <text class="shifdftext"
  84. :style="youyh?'color:fuchsia;':'color:darkgray;'">{{$t('index.hongbaokq')}}</text>
  85. <text class="hdts" style="color: black;font-size: 26rpx;">{{yhhd}}</text>
  86. </view>
  87. </view>
  88. <image v-if="hyyh!=0" style="width: 50rpx;height: 50rpx;" src="/static/images/dagoul.png"
  89. mode="scaleToFill"></image>
  90. </view>
  91. </view>
  92. <!-- <view style="background-color:white;width: 100%;">
  93. <view class="contentInRowS shifdf" @click="jifenduihuan">
  94. <view class="contentInRowL" style="width: 86%;">
  95. <image style="width: 50rpx;height: 50rpx;" src="/static/images/hongbkqh@3x.png" mode="scaleToFill"></image>
  96. <view class="contentColumn" style="width: 100%;">
  97. <text class="shifdftext" :style="isjifenduihan?'color:green;':'color:darkgray;'">积分兑换</text>
  98. <text v-if="points>0" class="hdts" style="color: black;font-size: 26rpx;">{{points}}积分兑换{{pointsReduction}}</text>
  99. </view>
  100. </view>
  101. <image v-if="isjifenduihan" style="width: 50rpx;height: 50rpx;" src="/static/images/dagoul.png" mode="scaleToFill"></image>
  102. </view>
  103. </view> -->
  104. <view class="contentInRowS shifdf" @click="shifodaofu">
  105. <view class="contentInRowC">
  106. <image style="width: 50rpx;height: 50rpx;" src="/static/images/payflact@3x.png" mode="scaleToFill">
  107. </image>
  108. <text class="shifdftext"
  109. :style="shifoudf==0?'color:darkgray;':'color:fuchsia;'">{{$t('index.huodaofukan')}}</text>
  110. </view>
  111. <image v-if="shifoudf==1" style="width: 50rpx;height: 50rpx;" src="/static/images/dagoul.png"
  112. mode="scaleToFill"></image>
  113. </view>
  114. <label class="linesp"></label>
  115. <label class="linesp"></label>
  116. <uni-list>
  117. <uni-list-item :title="$t('order.beizhu')"></uni-list-item>
  118. </uni-list>
  119. <textarea class="pinglun" :placeholder="$t('order.srddbz')" :value="remarks" @input="sumfontnum"></textarea>
  120. <label class="linesp"></label>
  121. <label class="linesp"></label>
  122. <!-- <view v-if="showAdrr==0">
  123. <uni-list>
  124. <uni-list-item :title="$t('order.menpaizp')"></uni-list-item>
  125. </uni-list>
  126. <view class="contentColumnC" style="margin-top: 30rpx;" @click="selectImage">
  127. <netImage width="640" height="640" :mysrc="mpImage" mymode="scaleToFill"></netImage>
  128. </view>
  129. <view class="linesp" style="margin-top: 20rpx;"></view>
  130. <label class="linesp"></label>
  131. </view> -->
  132. <uni-list>
  133. <uni-list-item :title="$t('order.shangpinxj')" :rightText="$formPr(spxj)+$t('locale.huobidw')" />
  134. <uni-list-item :title="$t('order.peisongfei')" :rightText="$formPr(psf)+$t('locale.huobidw')" />
  135. <uni-list-item :title="$t('order.youhuijine')" :rightText="'-'+$formPr(hyyh)+$t('locale.huobidw')" />
  136. </uni-list>
  137. <label class="linesp"></label>
  138. <label class="linesp"></label>
  139. <uni-list>
  140. <uni-list-item :title="$t('order.zhifujine')" :rightText="$formPr(zje)+$t('locale.huobidw')" />
  141. </uni-list>
  142. <label class="linesp"></label>
  143. <label class="linesp"></label>
  144. <view class="delbtct">
  145. <view class="delbt" @click="qufukuan">
  146. <label>{{actTitle}}</label>
  147. </view>
  148. </view>
  149. <label class="linesp"></label>
  150. <liu-delivery-time @change="changeTime" @close="deliveryclose" ref="chooseTime"
  151. :title="$t('order.yuyueshijian')"></liu-delivery-time>
  152. <yhdslCropper ref="yhdslCropper" :quality="1" mode="scale" @uploadImg="uploadImg" :scale="scale"></yhdslCropper>
  153. <popViewGG :show="showpop" :acttips="$t('order.queding')" :maskClosable="true" :isCancel="false"
  154. @chooseCancel="chooseCancel">
  155. <view class="contentColumnC" style="width: 100%;background-color: whitesmoke;">
  156. <view class="contentColumnC" style="height: 80rpx;width: 100%;background-color: lightgray;">
  157. <view class="contentInRowS" style="height: 80rpx;width: 90%;">
  158. <text style="font-size: 30rpx;color: crimson;" @click="querenyhhd"></text>
  159. <text style="font-size: 28rpx;">{{$t('index.hongbaokq')}}</text>
  160. <text style="font-size: 30rpx;color: #00A6FF;"
  161. @click="querenyhhd">{{$t('order.queding')}}</text>
  162. </view>
  163. </view>
  164. <view v-if="cxList.length>0" style="width: 90%;">
  165. <checkbox-group @change="hdradioChange">
  166. <label class="contentColumn" style="margin-top: 16rpx;" v-for="(item, index) in cxList"
  167. :key="index">
  168. <checkbox :value="item.id" :checked="item.id === hdidpt||item.id === hdidsj">
  169. <view class="contentColumn" :style="item.type==0?'color: #00A6FF;':'color:green;'">
  170. <text style="font-size: 28rpx;">{{item.salesName}}</text>
  171. <text style="font-size: 28rpx;">{{getNote(item,0)}}</text>
  172. </view>
  173. </checkbox>
  174. </label>
  175. </checkbox-group>
  176. </view>
  177. <view v-if="kqList.length>0" style="width: 90%;">
  178. <checkbox-group @change="kaqradioChange">
  179. <label class="contentColumn" style="margin-top: 16rpx;" v-for="(item, index) in kqList"
  180. :key="index">
  181. <checkbox :value="item.id" :checked="item.id === kqidpt||item.id === kqidsj">
  182. <view class="contentColumn" :style="item.type==0?'color: #00A6FF;':'color:green;'">
  183. <text style="font-size: 28rpx;">{{item.name}}</text>
  184. <text style="font-size: 28rpx;">{{getNote(item,1)}}</text>
  185. </view>
  186. </checkbox>
  187. </label>
  188. </checkbox-group>
  189. </view>
  190. <view class="contentInRowC" style="width: 100%;height: 80rpx;margin-top: 16rpx;">
  191. <text>{{$t('hongbaokq.leijiyh')}} {{hyyh}}{{$t('locale.huobidw')}}</text>
  192. </view>
  193. <view style="height: 80rpx;"></view>
  194. </view>
  195. </popViewGG>
  196. <popViewGG :tips="$t('order.zhifufangshi')" :show="zffsS" :showbotom="false" :maskClosable="true"
  197. :isCancel="true" @chooseCancel="chooseCancel">
  198. <view class="contentColumnC" style="width: 100%;background-color: whitesmoke;">
  199. <view class="zhifbut" style="background-color: deeppink;" @click="huodaofukuan">
  200. {{$t('index.huodaofukan')}}
  201. </view>
  202. <!-- <view class="zhifbut" style="background-color:#00A6FF;" @click="getVNPay">VNPAY</view> -->
  203. </view>
  204. </popViewGG>
  205. </view>
  206. </template>
  207. <script>
  208. import uniList from '@/uni_modules/uni-list/uni-list.vue';
  209. import uniListItem from '@/uni_modules/uni-list-item/uni-list-item.vue';
  210. // import uniAd from '@/uni_modules/uni-list-ad/uni-list-ad.vue';
  211. // import uniChat from '@/uni_modules/uni-list-chat/uni-list-chat.vue';
  212. import yhdslCropper from '@/components/yhdsl-cropper/yhdsl-cropper.vue';
  213. import api from "@/pages/api/api.js"
  214. export default {
  215. components: {
  216. uniList,
  217. uniListItem,
  218. yhdslCropper
  219. },
  220. data() {
  221. return {
  222. mendid: 0,
  223. userid: 0,
  224. ddId: '',
  225. rId: '',
  226. showAdrr: 0,
  227. foodlist: [],
  228. Bcolor: 'whitesmoke',
  229. Bcolorr: 'lightgray',
  230. Bcolorrr: 'lightgray',
  231. Tcolor: 'black',
  232. Tcolorr: 'darkgray',
  233. Tcolorrr: 'darkgray',
  234. peisongimg: '/static/images/peisongh@3x.png',
  235. ziquimg: '/static/images/ziqu@3x.png',
  236. tangshiimg: '/static/images/tangshih.png',
  237. actTitle: this.$t('order.querendd'),
  238. actType: 0,
  239. remarks: '',
  240. spxj: 0.00,
  241. psf: 0.00,
  242. freight: 0.00,
  243. hyyh: 0.00,
  244. zje: 0.00,
  245. jvli: 0.00,
  246. zhixianjuli: 0.00,
  247. zhixianfreight: 0.00,
  248. dizhiID: '',
  249. addrList: [],
  250. peisongdizhiaddress: '',
  251. peisongdizhiname: '',
  252. peisongdizhiphone: '',
  253. zfindex: 0,
  254. delryTime: '',
  255. isGetyunfei: false,
  256. mendianMs: '',
  257. cid: '',
  258. orderDetl: '',
  259. shifouzhifu: false,
  260. zhifuUrl: '',
  261. shifoudf: 0,
  262. scale: 1,
  263. baseUrl: this.$baseImagurl,
  264. mpImage: '',
  265. showpop: false,
  266. indicatorStyle: 'height: 50px;',
  267. zffsS: false,
  268. keyixd: true,
  269. cxList: [],
  270. hdidpt: 0, //平台促销活动id
  271. hdidsj: 0, //门店促销活动id
  272. kqList: [],
  273. kqidpt: 0, //平台使用优惠券id
  274. kqidsj: 0, //门店优惠券id
  275. yhhd: '',
  276. youyh: false,
  277. discountAmount: 0, //平台优惠券优惠金额
  278. salesReduction: 0, //平台促销減免值
  279. mdDiscountAmount: 0, //门店优惠券优惠金额
  280. mdSalesReduction: 0, //门店促销減免值
  281. isjifenduihan: false,
  282. sumpoints: 0, //全部积分
  283. pointsBl: 0, //积分抵扣比例
  284. points: 0, //抵扣的积分
  285. pointsReduction: 0 //积分抵扣值
  286. }
  287. },
  288. onLoad(option) {
  289. console.log(option)
  290. this.foodlist = uni.getStorageSync("JSfoodlist");
  291. uni.setStorageSync('JSfoodlist', '');
  292. this.mendid = option.mendid;
  293. this.userid = option.userid;
  294. this.cid = uni.getStorageSync("cid");
  295. this.cuxiaoList();
  296. //this.getPoint();
  297. },
  298. onShow() {
  299. var temp = uni.getStorageSync("peisongdizhi");
  300. if (undefined == temp || null == temp || '' == temp) {
  301. this.dizhiID = '';
  302. //this.getaddressList();
  303. } else {
  304. this.dizhiID = temp;
  305. this.mpImage = this.dizhiID.annexes;
  306. }
  307. this.isGetyunfei = false;
  308. if (this.mendianMs == '') {
  309. this.getmendianDetail(this.mendid);
  310. } else {
  311. if (this.dizhiID == '') {
  312. this.getaddressList();
  313. } else {
  314. console.log('4444')
  315. this.getyunfei(this.dizhiID.latitude, this.dizhiID.longitude);
  316. }
  317. }
  318. if (this.shifouzhifu) {
  319. this.shifouzhifu = false;
  320. this.getorderDetl();
  321. }
  322. },
  323. methods: {
  324. // 检测是否为安卓设备
  325. isAndroidDevice() {
  326. // 在H5环境中检测
  327. // #ifdef H5
  328. const ua = navigator.userAgent.toLowerCase();
  329. return ua.indexOf('android') > -1;
  330. // #endif
  331. // 在App环境中检测
  332. // #ifdef APP-PLUS
  333. return plus.os.name === 'Android';
  334. // #endif
  335. // 其他环境默认返回false
  336. return false;
  337. },
  338. // 安卓设备自动下载并安装APK
  339. downloadAndInstallAndroid(androidUrl) {
  340. const that = this;
  341. // 先尝试打开已安装的应用
  342. this.tryOpenInstalledApp();
  343. },
  344. // 尝试打开已安装的应用
  345. tryOpenInstalledApp() {
  346. const that = this;
  347. const appSchema = 'cityexpressuser://';
  348. // 在App环境中使用plus.runtime.openURL
  349. // #ifdef APP-PLUS
  350. plus.runtime.openURL(appSchema, function() {
  351. console.log(that.$t('download.app_opened_success'));
  352. }, function(e) {
  353. console.log(that.$t('download.app_not_installed'));
  354. // 应用未安装,继续下载流程
  355. that.startDownloadProcess();
  356. });
  357. // #endif
  358. // 在H5环境中尝试打开应用
  359. // #ifdef H5
  360. this.tryOpenAppInH5(appSchema);
  361. // #endif
  362. },
  363. // 在H5环境中尝试打开应用
  364. tryOpenAppInH5(appSchema) {
  365. const that = this;
  366. // 检测是否为iOS设备
  367. const isIOS = this.isIOSDevice();
  368. if (isIOS) {
  369. // iOS设备使用特殊处理
  370. this.tryOpenIOSApp(appSchema);
  371. } else {
  372. // 安卓设备使用iframe方式
  373. this.tryOpenAndroidApp(appSchema);
  374. }
  375. },
  376. // 尝试打开iOS应用
  377. tryOpenIOSApp(appSchema) {
  378. const that = this;
  379. // 记录开始时间
  380. const startTime = Date.now();
  381. let hasApp = false;
  382. // 监听页面可见性变化
  383. const handleVisibilityChange = () => {
  384. if (document.hidden) {
  385. hasApp = true;
  386. clearTimeout(timeout);
  387. document.removeEventListener('visibilitychange', handleVisibilityChange);
  388. document.removeEventListener('pagehide', handlePageHide);
  389. document.removeEventListener('blur', handleBlur);
  390. }
  391. };
  392. // 监听页面隐藏事件
  393. const handlePageHide = () => {
  394. hasApp = true;
  395. clearTimeout(timeout);
  396. document.removeEventListener('visibilitychange', handleVisibilityChange);
  397. document.removeEventListener('pagehide', handlePageHide);
  398. document.removeEventListener('blur', handleBlur);
  399. };
  400. // 监听窗口失焦事件
  401. const handleBlur = () => {
  402. hasApp = true;
  403. clearTimeout(timeout);
  404. document.removeEventListener('visibilitychange', handleVisibilityChange);
  405. document.removeEventListener('pagehide', handlePageHide);
  406. document.removeEventListener('blur', handleBlur);
  407. };
  408. // 设置超时检测
  409. const timeout = setTimeout(() => {
  410. if (!hasApp) {
  411. // 应用未安装,继续下载流程
  412. that.startDownloadProcess();
  413. }
  414. document.removeEventListener('visibilitychange', handleVisibilityChange);
  415. document.removeEventListener('pagehide', handlePageHide);
  416. document.removeEventListener('blur', handleBlur);
  417. }, 1500); // 缩短超时时间
  418. // 添加事件监听器
  419. document.addEventListener('visibilitychange', handleVisibilityChange);
  420. document.addEventListener('pagehide', handlePageHide);
  421. window.addEventListener('blur', handleBlur);
  422. // 尝试打开应用
  423. try {
  424. // 方法1: 直接使用window.location
  425. window.location.href = appSchema;
  426. } catch (e) {
  427. // 方法2: 使用iframe
  428. const iframe = document.createElement('iframe');
  429. iframe.style.display = 'none';
  430. iframe.style.width = '1px';
  431. iframe.style.height = '1px';
  432. iframe.src = appSchema;
  433. document.body.appendChild(iframe);
  434. // 清理iframe
  435. setTimeout(() => {
  436. if (document.body.contains(iframe)) {
  437. document.body.removeChild(iframe);
  438. }
  439. }, 1000);
  440. }
  441. },
  442. // 尝试打开安卓应用
  443. tryOpenAndroidApp(appSchema) {
  444. const that = this;
  445. let hasApp = false;
  446. // 监听页面可见性变化
  447. const handleVisibilityChange = () => {
  448. if (document.hidden) {
  449. hasApp = true;
  450. clearTimeout(timeout);
  451. document.removeEventListener('visibilitychange', handleVisibilityChange);
  452. document.removeEventListener('pagehide', handlePageHide);
  453. document.removeEventListener('blur', handleBlur);
  454. }
  455. };
  456. // 监听页面隐藏事件
  457. const handlePageHide = () => {
  458. hasApp = true;
  459. clearTimeout(timeout);
  460. document.removeEventListener('visibilitychange', handleVisibilityChange);
  461. document.removeEventListener('pagehide', handlePageHide);
  462. document.removeEventListener('blur', handleBlur);
  463. };
  464. // 监听窗口失焦事件
  465. const handleBlur = () => {
  466. hasApp = true;
  467. clearTimeout(timeout);
  468. document.removeEventListener('visibilitychange', handleVisibilityChange);
  469. document.removeEventListener('pagehide', handlePageHide);
  470. document.removeEventListener('blur', handleBlur);
  471. };
  472. // 设置超时检测
  473. const timeout = setTimeout(() => {
  474. if (!hasApp) {
  475. // 应用未安装,继续下载流程
  476. that.startDownloadProcess();
  477. }
  478. document.removeEventListener('visibilitychange', handleVisibilityChange);
  479. document.removeEventListener('pagehide', handlePageHide);
  480. document.removeEventListener('blur', handleBlur);
  481. }, 1500); // 缩短超时时间
  482. // 添加事件监听器
  483. document.addEventListener('visibilitychange', handleVisibilityChange);
  484. document.addEventListener('pagehide', handlePageHide);
  485. window.addEventListener('blur', handleBlur);
  486. // 尝试打开应用
  487. try {
  488. // 方法1: 直接使用window.location
  489. window.location.href = appSchema;
  490. } catch (e) {
  491. // 方法2: 使用iframe
  492. const iframe = document.createElement('iframe');
  493. iframe.style.display = 'none';
  494. iframe.style.width = '1px';
  495. iframe.style.height = '1px';
  496. iframe.src = appSchema;
  497. document.body.appendChild(iframe);
  498. // 清理iframe
  499. setTimeout(() => {
  500. if (document.body.contains(iframe)) {
  501. document.body.removeChild(iframe);
  502. }
  503. }, 1000);
  504. }
  505. },
  506. // 开始下载流程
  507. startDownloadProcess() {
  508. const that = this;
  509. // 显示下载提示
  510. uni.showLoading({
  511. title: this.$t('download.downloading'),
  512. mask: true
  513. });
  514. // 获取下载链接
  515. api('getAppDownload', {}, r => {
  516. console.log(r);
  517. // 检测是否为安卓设备
  518. const isAndroid = this.isAndroidDevice();
  519. if (isAndroid) {
  520. // 安卓设备下载APK
  521. that.downloadAndroidAPK(r.data.data.androidUrl);
  522. } else {
  523. // iOS设备打开App Store
  524. that.openAppStore(r.data.data.iosUrl);
  525. }
  526. });
  527. },
  528. // 下载安卓APK
  529. downloadAndroidAPK(androidUrl) {
  530. const that = this;
  531. // 在App环境中使用plus.downloader
  532. // #ifdef APP-PLUS
  533. const appDownloadTask = plus.downloader.createDownload(androidUrl, {
  534. filename: '_downloads/CTE.apk'
  535. }, function(download, status) {
  536. uni.hideLoading();
  537. if (status === 200) {
  538. // 下载成功,尝试安装
  539. that.installAndroidApp(download.filename);
  540. } else {
  541. uni.showToast({
  542. title: that.$t('download.download_failed'),
  543. icon: 'none',
  544. duration: 2000
  545. });
  546. }
  547. });
  548. // 监听下载进度
  549. appDownloadTask.addEventListener('statechanged', function(download, status) {
  550. if (status === 200) {
  551. const progress = Math.round((download.downloadedSize / download.totalSize) * 100);
  552. uni.showLoading({
  553. title: that.$t('download.downloading_progress', {
  554. progress: progress
  555. }),
  556. mask: true
  557. });
  558. }
  559. });
  560. appDownloadTask.start();
  561. // #endif
  562. // 在H5环境中使用uni.downloadFile
  563. // #ifdef H5
  564. const h5DownloadTask = uni.downloadFile({
  565. url: androidUrl,
  566. success: function(res) {
  567. uni.hideLoading();
  568. if (res.statusCode === 200) {
  569. // 下载成功,尝试安装
  570. that.installAndroidApp(res.tempFilePath);
  571. } else {
  572. uni.showToast({
  573. title: that.$t('download.download_failed'),
  574. icon: 'none',
  575. duration: 2000
  576. });
  577. }
  578. },
  579. fail: function(err) {
  580. uni.hideLoading();
  581. console.log('下载失败:', err);
  582. // 下载失败时,提供手动下载选项
  583. uni.showModal({
  584. title: that.$t('download.download_failed'),
  585. content: that.$t('download.download_failed_manual'),
  586. showCancel: true,
  587. cancelText: that.$t('comp.quxiao'),
  588. confirmText: that.$t('comp.queren'),
  589. success: function(res) {
  590. if (res.confirm) {
  591. // 使用浏览器打开下载链接
  592. window.open(androidUrl, '_blank');
  593. }
  594. }
  595. });
  596. }
  597. });
  598. // 监听下载进度
  599. h5DownloadTask.onProgressUpdate(function(res) {
  600. const progress = Math.round(res.progress);
  601. uni.showLoading({
  602. title: that.$t('download.downloading_progress', {
  603. progress: progress
  604. }),
  605. mask: true
  606. });
  607. });
  608. // #endif
  609. },
  610. // 打开App Store
  611. openAppStore(iosUrl) {
  612. const that = this;
  613. // 在App环境中使用plus.runtime.openURL
  614. // #ifdef APP-PLUS
  615. plus.runtime.openURL(
  616. 'itms-apps://itunes.apple.com/cn/app/cte/id6468907188',
  617. (res) => {
  618. console.log(that.$t('download.app_store_success'))
  619. },
  620. (err) => {
  621. console.log(that.$t('download.app_store_failed'))
  622. // 如果 itms-apps:// 失败,回退到浏览器打开
  623. plus.runtime.openURL('https://apps.apple.com/cn/app/cte/id6468907188')
  624. }
  625. );
  626. // #endif
  627. // 在H5环境中,针对iOS设备优化
  628. // #ifdef H5
  629. // 先尝试直接打开App Store链接
  630. const appStoreUrl = 'https://apps.apple.com/cn/app/cte/id6468907188';
  631. // 尝试多种方式打开App Store
  632. that.tryOpenAppStore(appStoreUrl);
  633. // #endif
  634. },
  635. // 安装安卓应用
  636. installAndroidApp(filePath) {
  637. const that = this;
  638. // 在App环境中,直接尝试安装APK
  639. // #ifdef APP-PLUS
  640. uni.showModal({
  641. title: that.$t('download.download_complete'),
  642. content: that.$t('download.install_confirm'),
  643. showCancel: true,
  644. cancelText: that.$t('comp.quxiao'),
  645. confirmText: that.$t('comp.queren'),
  646. success: function(res) {
  647. if (res.confirm) {
  648. // 使用plus.runtime.install安装APK
  649. plus.runtime.install(filePath, {
  650. force: false
  651. }, function() {
  652. uni.showToast({
  653. title: that.$t('download.install_success'),
  654. icon: 'success',
  655. duration: 2000
  656. });
  657. }, function(e) {
  658. console.log('安装失败:', e);
  659. uni.showModal({
  660. title: that.$t('download.install_failed'),
  661. content: that.$t('download.install_failed_manual'),
  662. showCancel: true,
  663. cancelText: that.$t('comp.quxiao'),
  664. confirmText: that.$t('comp.queren'),
  665. success: function(res) {
  666. if (res.confirm) {
  667. // 打开文件管理器
  668. plus.runtime.openFile(filePath);
  669. }
  670. }
  671. });
  672. });
  673. }
  674. }
  675. });
  676. // #endif
  677. // 在H5环境中,提示用户手动安装
  678. // #ifdef H5
  679. uni.showModal({
  680. title: that.$t('download.download_complete'),
  681. content: that.$t('download.manual_install_hint'),
  682. showCancel: false,
  683. confirmText: that.$t('comp.queren'),
  684. success: function(res) {
  685. if (res.confirm) {
  686. // 尝试打开下载链接,让用户手动下载
  687. window.open(filePath, '_blank');
  688. }
  689. }
  690. });
  691. // #endif
  692. },
  693. // 下载iOS应用
  694. downloadIOSApp(iosUrl) {
  695. // 检测是否为iOS设备
  696. const isIOS = this.isIOSDevice();
  697. if (!isIOS) {
  698. // 非iOS设备直接打开浏览器链接
  699. window.open('https://apps.apple.com/cn/app/cte/id6468907188', '_blank');
  700. return;
  701. }
  702. // 先尝试打开已安装的应用
  703. this.tryOpenInstalledApp();
  704. },
  705. // 检测是否为iOS设备
  706. isIOSDevice() {
  707. // #ifdef H5
  708. const ua = navigator.userAgent.toLowerCase();
  709. return /iphone|ipad|ipod/.test(ua);
  710. // #endif
  711. // #ifdef APP-PLUS
  712. return plus.os.name === 'iOS';
  713. // #endif
  714. return false;
  715. },
  716. // 尝试打开App Store的多种方式
  717. tryOpenAppStore(appStoreUrl) {
  718. // 方法1: 直接使用window.open
  719. const newWindow = window.open(appStoreUrl, '_blank');
  720. // 如果新窗口被阻止,尝试其他方法
  721. if (!newWindow || newWindow.closed || typeof newWindow.closed == 'undefined') {
  722. // 方法2: 尝试使用itms-apps协议
  723. this.tryItmsProtocol();
  724. }
  725. },
  726. // 尝试使用itms-apps协议
  727. tryItmsProtocol() {
  728. const itmsUrl = 'itms-apps://itunes.apple.com/cn/app/cte/id6468907188';
  729. // 创建一个隐藏的iframe来尝试打开itms-apps协议
  730. const iframe = document.createElement('iframe');
  731. iframe.style.display = 'none';
  732. iframe.style.width = '1px';
  733. iframe.style.height = '1px';
  734. iframe.src = itmsUrl;
  735. document.body.appendChild(iframe);
  736. // 设置超时,如果App Store没有打开,则回退到浏览器
  737. setTimeout(() => {
  738. if (document.body.contains(iframe)) {
  739. document.body.removeChild(iframe);
  740. }
  741. // 最后回退到浏览器打开
  742. window.location.href = 'https://apps.apple.com/cn/app/cte/id6468907188';
  743. }, 1500);
  744. },
  745. //促销
  746. cuxiaoList() {
  747. this.youyh = false;
  748. this.yhhd = '';
  749. var price = 0;
  750. for (var i = 0; i < this.foodlist.length; i++) {
  751. price = price + (this.foodlist[i].price + this.foodlist[i].otherPrice) * this.foodlist[i].number;
  752. }
  753. this.cxList = [];
  754. api('cuxiaoList', {
  755. mdId: this.mendid,
  756. price: price,
  757. yfPrice: this.psf
  758. }, r => {
  759. console.log(r);
  760. console.log('-----------1', this.mendid, price, this.psf)
  761. if (r.data.code == 200) {
  762. this.cxList = r.data.data;
  763. if (this.cxList.length > 0) {
  764. this.yhhd = this.$t('order.qingxzyhkq');
  765. this.youyh = true;
  766. }
  767. }
  768. this.jisuanjiner();
  769. this.kaquanList();
  770. }, failc => {
  771. //console.log('getadvertis----',failc)
  772. })
  773. },
  774. kaquanList() {
  775. var price = 0;
  776. for (var i = 0; i < this.foodlist.length; i++) {
  777. price = price + (this.foodlist[i].price + this.foodlist[i].otherPrice) * this.foodlist[i].number;
  778. }
  779. this.kqList = [];
  780. api('orderyhList', {
  781. mdId: this.mendid,
  782. price: price,
  783. yfPrice: this.psf
  784. }, r => {
  785. console.log(r);
  786. console.log('-----------2', this.mendid, price, this.psf)
  787. if (r.data.code == 200) {
  788. this.kqList = r.data.data;
  789. if (this.kqList.length > 0) {
  790. this.yhhd = this.$t('order.qingxzyhkq');
  791. this.youyh = true;
  792. } else {
  793. if (!this.youyh) {
  794. this.yhhd = '';
  795. this.youyh = false;
  796. }
  797. }
  798. }
  799. this.jisuanjiner();
  800. }, failc => {
  801. //console.log('getadvertis----',failc)
  802. })
  803. },
  804. //积分
  805. getPoint() {
  806. api('getPoint', {}, r => {
  807. console.log("getPoint:", r);
  808. if (r.data.code == 200) {
  809. this.sumpoints = r.data.data.points; //积分
  810. this.pointsBl = r.data.data.bl; //积分抵扣值
  811. } else if (r.data.code == 500) {
  812. this.sumpoints = 0; //积分
  813. this.pointsBl = 0; //积分抵扣值
  814. }
  815. }, failc => {
  816. //console.log('getadvertis----',failc)
  817. })
  818. },
  819. hdradioChange(evt) {
  820. console.log(evt.detail.value)
  821. var hdids = evt.detail.value;
  822. var hdid = 0;
  823. var hdidpt = 0;
  824. var hdidsj = 0;
  825. for (var i = 0; i < hdids.length; i++) {
  826. var oid = hdids[i];
  827. if (oid == this.hdidpt) {
  828. hdidpt = oid;
  829. } else if (oid == this.hdidsj) {
  830. hdidsj = oid;
  831. } else {
  832. hdid = oid;
  833. }
  834. }
  835. this.hdidpt = hdidpt;
  836. this.hdidsj = hdidsj;
  837. var sobj = null;
  838. for (var i = 0; i < this.cxList.length; i++) {
  839. var obj = this.cxList[i];
  840. if (obj.id == hdid) {
  841. sobj = obj;
  842. break;
  843. }
  844. }
  845. if (this.cxList.length > 0 && hdid > 0) {
  846. for (var i = 0; i < this.cxList.length; i++) {
  847. var obj = this.cxList[i];
  848. if (obj.id == this.hdidpt) {
  849. if (sobj.salesType == obj.salesType) {
  850. this.hdidpt = 0;
  851. }
  852. }
  853. if (obj.id == this.hdidsj) {
  854. if (sobj.salesType == obj.salesType) {
  855. this.hdidsj = 0;
  856. }
  857. }
  858. }
  859. }
  860. if (this.kqList.length > 0 && hdid > 0) {
  861. for (var i = 0; i < this.kqList.length; i++) {
  862. var obj = this.kqList[i];
  863. if (obj.id == this.kqidpt) {
  864. if (sobj.salesType == obj.yhfangs) {
  865. this.kqidpt = 0;
  866. }
  867. }
  868. if (obj.id == this.kqidsj) {
  869. if (sobj.salesType == obj.yhfangs) {
  870. this.kqidsj = 0;
  871. }
  872. }
  873. }
  874. }
  875. if (hdid > 0) {
  876. if (sobj && sobj.type == 0) {
  877. this.hdidpt = hdid;
  878. } else if (sobj && sobj.type == 1) {
  879. this.hdidsj = hdid;
  880. }
  881. }
  882. this.jisuanjiner();
  883. },
  884. kaqradioChange(evt) {
  885. console.log(evt)
  886. var kqids = evt.detail.value;
  887. var kqid = 0;
  888. var kqidpt = 0;
  889. var kqidsj = 0;
  890. for (var i = 0; i < kqids.length; i++) {
  891. var oid = kqids[i];
  892. if (oid == this.kqidpt) {
  893. kqidpt = oid;
  894. } else if (oid == this.kqidsj) {
  895. kqidsj = oid;
  896. } else {
  897. kqid = oid;
  898. }
  899. }
  900. this.kqidpt = kqidpt;
  901. this.kqidsj = kqidsj;
  902. var sobj = null;
  903. for (var i = 0; i < this.kqList.length; i++) {
  904. var obj = this.kqList[i]
  905. if (obj.id == kqid) {
  906. sobj = obj;
  907. break;
  908. }
  909. }
  910. if (this.cxList.length > 0 && kqid > 0) {
  911. for (var i = 0; i < this.cxList.length; i++) {
  912. var obj = this.cxList[i];
  913. if (obj.id == this.hdidpt) {
  914. if (sobj.yhfangs == obj.salesType) {
  915. this.hdidpt = 0;
  916. }
  917. }
  918. if (obj.id == this.hdidsj) {
  919. if (sobj.yhfangs == obj.salesType) {
  920. this.hdidsj = 0;
  921. }
  922. }
  923. }
  924. }
  925. if (this.kqList.length > 0 && kqid > 0) {
  926. for (var i = 0; i < this.kqList.length; i++) {
  927. var obj = this.kqList[i];
  928. if (obj.id == this.kqidpt) {
  929. if (sobj.yhfangs == obj.yhfangs) {
  930. this.kqidpt = 0;
  931. }
  932. }
  933. if (obj.id == this.kqidsj) {
  934. if (sobj.yhfangs == obj.yhfangs) {
  935. this.kqidsj = 0;
  936. }
  937. }
  938. }
  939. }
  940. if (kqid >= 0) {
  941. if (sobj && sobj.type == 0) {
  942. this.kqidpt = kqid;
  943. } else if (sobj && sobj.type == 1) {
  944. this.kqidsj = kqid;
  945. }
  946. }
  947. this.jisuanjiner();
  948. },
  949. getNote(obj, index) {
  950. var str = '';
  951. if (index == 0) {
  952. var str = '';
  953. if (obj.salesType == 1 && obj.salesReduction > 1) { //优惠方式:1 运费,2 订单 ,3 商品
  954. str = this.$t('hongbaokq.yunfeiyh');
  955. }
  956. if (obj.salesType == 1 && obj.salesReduction < 1 && obj.salesReduction > 0) { //优惠方式:1 运费,2 订单 ,3 商品
  957. str = this.$t('hongbaokq.yunfeizk');
  958. }
  959. if (obj.salesType == 1 && obj.salesReduction == 0) { //优惠方式:1 运费,2 订单 ,3 商品
  960. str = this.$t('hongbaokq.yunfeiquanm');
  961. }
  962. if (obj.salesType == 2 && obj.salesReduction > 1) {
  963. str = this.$t('hongbaokq.dingdanyh');
  964. }
  965. if (obj.salesType == 2 && obj.salesReduction < 1) {
  966. str = this.$t('hongbaokq.dingdanzk');
  967. }
  968. if (obj.salesType == 3 && obj.salesReduction > 1) {
  969. str = this.$t('hongbaokq.shangpinyh');
  970. }
  971. if (obj.salesType == 3 && obj.salesReduction < 1) {
  972. str = this.$t('hongbaokq.shangpinzk');
  973. }
  974. if (obj.salesReduction != 0) {
  975. str = str + ' ' + obj.salesReduction;
  976. }
  977. }
  978. if (index == 1) {
  979. if (obj.yhfangs == 1 && obj.yhnum > 1) { //优惠方式:1 运费,2 订单 ,3 商品
  980. str = this.$t('hongbaokq.yunfeiyh');
  981. }
  982. if (obj.yhfangs == 1 && obj.yhnum < 1 && obj.yhnum > 0) { //优惠方式:1 运费,2 订单 ,3 商品
  983. str = this.$t('hongbaokq.yunfeizk');
  984. }
  985. if (obj.yhfangs == 1 && obj.yhnum == 0) { //优惠方式:1 运费,2 订单 ,3 商品
  986. str = this.$t('hongbaokq.yunfeiquanm');
  987. }
  988. if (obj.yhfangs == 2 && obj.yhnum > 1) {
  989. str = this.$t('hongbaokq.dingdanyh');
  990. }
  991. if (obj.yhfangs == 2 && obj.yhnum < 1) {
  992. str = this.$t('hongbaokq.dingdanzk');
  993. }
  994. if (obj.yhfangs == 3 && obj.yhnum > 1) {
  995. str = this.$t('hongbaokq.shangpinyh');
  996. }
  997. if (obj.yhfangs == 3 && obj.yhnum < 1) {
  998. str = this.$t('hongbaokq.shangpinzk');
  999. }
  1000. if (obj.yhnum != 0) {
  1001. str = str + ' ' + obj.yhnum;
  1002. }
  1003. }
  1004. return str;
  1005. },
  1006. querenyhhd() {
  1007. this.showpop = false;
  1008. },
  1009. //积分兑换
  1010. jifenduihuan() {
  1011. if (this.sumpoints > 0) {
  1012. this.isjifenduihan = !this.isjifenduihan;
  1013. } else {
  1014. this.isjifenduihan = false;
  1015. }
  1016. },
  1017. jisuandikou(dingdanjiner) {
  1018. var sumkyjine = this.sumpoints * this.pointsBl;
  1019. if (sumkyjine > dingdanjiner) {
  1020. var jifen = dingdanjiner / this.pointsBl;
  1021. jifen = parseInt(jifen);
  1022. this.points = jifen;
  1023. this.pointsReduction = jifen * this.pointsBl;
  1024. } else {
  1025. this.points = this.sumpoints;
  1026. this.pointsReduction = sumkyjine;
  1027. }
  1028. return this.pointsReduction;
  1029. },
  1030. //商品数量加减
  1031. jiajian(index, state) {
  1032. if (this.actType > 0) {
  1033. return;
  1034. }
  1035. var tempList = this.foodlist;
  1036. if (state > 0) {
  1037. var temp = tempList[index];
  1038. temp.number = temp.number + 1;
  1039. tempList[index] = temp;
  1040. this.gengxingouwuche(temp);
  1041. } else {
  1042. var temp = tempList[index];
  1043. if (temp.number > 1) {
  1044. temp.number = temp.number - 1;
  1045. tempList[index] = temp;
  1046. } else {
  1047. temp.number = temp.number - 1;
  1048. tempList.splice(index, 1);
  1049. }
  1050. this.gengxingouwuche(temp);
  1051. }
  1052. this.foodlist = tempList;
  1053. this.cuxiaoList();
  1054. if (this.foodlist.length == 0) {
  1055. uni.showToast({
  1056. title: that.$t('comp.qingxzsp'),
  1057. icon: 'none',
  1058. duration: 2500
  1059. })
  1060. }
  1061. },
  1062. xuanzcux() {
  1063. this.showpop = true;
  1064. },
  1065. chooseCancel() {
  1066. this.showpop = false;
  1067. this.zffsS = false;
  1068. console.log('chooseCancel');
  1069. },
  1070. //--------------------------------------------------------
  1071. arraytoStr(arry) {
  1072. var str = '';
  1073. if (arry.length > 0) {
  1074. for (var i = 0; i < arry.length; i++) {
  1075. str = str + arry[i] + '; ';
  1076. }
  1077. }
  1078. return str;
  1079. },
  1080. jisuanjiner() {
  1081. this.spxj = 0;
  1082. this.hyyh = 0;
  1083. this.zje = 0;
  1084. for (var i = 0; i < this.foodlist.length; i++) {
  1085. this.spxj = this.spxj + (this.foodlist[i].price + this.foodlist[i].otherPrice) * this.foodlist[i]
  1086. .number;
  1087. }
  1088. this.hyyh = this.jisuanyouhuijiner(this.spxj);
  1089. this.hyyh = parseInt(this.hyyh);
  1090. this.zje = (this.spxj + this.psf) - this.hyyh;
  1091. this.zje = parseInt(this.zje);
  1092. //开始积分抵扣
  1093. this.jisuandikou(this.zje)
  1094. this.zje = this.zje - this.pointsReduction;
  1095. this.zje = parseInt(this.zje);
  1096. //
  1097. },
  1098. jisuanyouhuijiner(price) {
  1099. var zongyouhui = 0;
  1100. this.salesReduction = 0;
  1101. this.mdSalesReduction = 0;
  1102. this.discountAmount = 0;
  1103. this.mdDiscountAmount = 0;
  1104. if (this.cxList.length > 0) {
  1105. for (var i = 0; i < this.cxList.length; i++) {
  1106. var obj = this.cxList[i];
  1107. console.log('111111', this.hdidpt, obj)
  1108. if (obj.id == this.hdidpt) {
  1109. console.log('111111', this.hdidpt, obj)
  1110. if (obj.salesType == "1") {
  1111. if (obj.salesReduction < 1) {
  1112. this.salesReduction = this.psf * (100 - obj.salesReduction * 100) / 100;
  1113. } else if (obj.salesReduction > 1) {
  1114. if (obj.salesReduction > this.psf) {
  1115. this.salesReduction = this.psf;
  1116. } else {
  1117. this.salesReduction = obj.salesReduction;
  1118. }
  1119. }
  1120. }
  1121. if (obj.salesType == "2") {
  1122. if (obj.salesReduction < 1) {
  1123. this.salesReduction = this.salesReduction + (price + this.psf) * (100 - obj
  1124. .salesReduction * 100) / 100;
  1125. } else if (obj.salesReduction > 1) {
  1126. if (obj.salesReduction > (price + this.psf)) {
  1127. this.salesReduction = (price + this.psf);
  1128. } else {
  1129. this.salesReduction = obj.salesReduction;
  1130. }
  1131. }
  1132. console.log(price, obj.salesReduction, price * (1 - obj.salesReduction))
  1133. }
  1134. if (obj.salesType == "3") {
  1135. if (obj.salesReduction < 1) {
  1136. this.salesReduction = this.salesReduction + price * (100 - obj.salesReduction * 100) /
  1137. 100;
  1138. } else if (obj.salesReduction > 1) {
  1139. if (obj.salesReduction > price) {
  1140. this.salesReduction = price;
  1141. } else {
  1142. this.salesReduction = obj.salesReduction;
  1143. }
  1144. }
  1145. }
  1146. }
  1147. if (obj.id == this.hdidsj) {
  1148. console.log('1111112', this.hdidsj, obj)
  1149. if (obj.salesType == "1") {
  1150. this.mdSalesReduction = this.mdSalesReduction + this.psf;
  1151. if (obj.salesReduction < 1) {
  1152. this.mdSalesReduction = this.psf * (100 - obj.salesReduction * 100) / 100;
  1153. } else if (obj.salesReduction > 1) {
  1154. if (obj.salesReduction > this.psf) {
  1155. this.mdSalesReduction = this.psf;
  1156. } else {
  1157. this.mdSalesReduction = obj.salesReduction;
  1158. }
  1159. }
  1160. }
  1161. if (obj.salesType == "2") {
  1162. if (obj.salesReduction < 1) {
  1163. this.mdSalesReduction = this.mdSalesReduction + (price + this.psf) * (100 - obj
  1164. .salesReduction * 100) / 100;
  1165. } else if (obj.salesReduction > 1) {
  1166. if (obj.salesReduction > (price + this.psf)) {
  1167. this.mdSalesReduction = (price + this.psf);
  1168. } else {
  1169. this.mdSalesReduction = obj.salesReduction;
  1170. }
  1171. }
  1172. }
  1173. if (obj.salesType == "3") {
  1174. if (obj.salesReduction < 1) {
  1175. this.mdSalesReduction = this.mdSalesReduction + price * (100 - obj.salesReduction *
  1176. 100) / 100;
  1177. } else if (obj.salesReduction > 1) {
  1178. if (obj.salesReduction > price) {
  1179. this.mdSalesReduction = price;
  1180. } else {
  1181. this.mdSalesReduction = obj.salesReduction;
  1182. }
  1183. }
  1184. }
  1185. }
  1186. }
  1187. }
  1188. if (this.kqList.length > 0) {
  1189. for (var i = 0; i < this.kqList.length; i++) {
  1190. var obj = this.kqList[i];
  1191. if (obj.id == this.kqidpt) {
  1192. console.log('1111113', this.kqidpt, obj)
  1193. if (obj.yhfangs == 1) {
  1194. if (obj.yhnum < 1) {
  1195. this.discountAmount = this.psf * (100 - obj.yhnum * 100) / 100;
  1196. } else if (obj.yhnum > 1) {
  1197. if (obj.yhnum > this.psf) {
  1198. this.discountAmount = this.psf;
  1199. } else {
  1200. this.discountAmount = obj.yhnum;
  1201. }
  1202. }
  1203. }
  1204. if (obj.yhfangs == 2) {
  1205. if (obj.yhnum < 1) {
  1206. this.discountAmount = (price + this.psf) * (100 - obj.yhnum * 100) / 100;
  1207. } else if (obj.yhnum > 1) {
  1208. if (obj.yhnum > (price + this.psf)) {
  1209. this.discountAmount = (price + this.psf);
  1210. } else {
  1211. this.discountAmount = obj.yhnum;
  1212. }
  1213. }
  1214. console.log(price, obj.yhnum, price * (1 - obj.yhnum))
  1215. }
  1216. if (obj.yhfangs == 3) {
  1217. if (obj.yhnum < 1) {
  1218. this.discountAmount = price * (100 - obj.yhnum * 100) / 100;
  1219. } else if (obj.yhnum > 1) {
  1220. if (obj.yhnum > price) {
  1221. this.discountAmount = price;
  1222. } else {
  1223. this.discountAmount = obj.yhnum;
  1224. }
  1225. }
  1226. }
  1227. }
  1228. if (obj.id == this.kqidsj) {
  1229. console.log('1111114', this.kqidsj, obj)
  1230. if (obj.yhfangs == 1) {
  1231. if (obj.yhnum < 1) {
  1232. this.mdDiscountAmount = this.psf * (100 - obj.yhnum * 100) / 100;
  1233. } else if (obj.yhnum > 1) {
  1234. if (obj.yhnum > this.psf) {
  1235. this.mdDiscountAmount = this.psf;
  1236. } else {
  1237. this.mdDiscountAmount = obj.yhnum;
  1238. }
  1239. }
  1240. }
  1241. if (obj.yhfangs == 2) { //订单
  1242. if (obj.yhnum > 1) {
  1243. if (obj.yhnum > (price + this.psf)) {
  1244. this.mdDiscountAmount = (price + this.psf);
  1245. } else {
  1246. this.mdDiscountAmount = obj.yhnum;
  1247. }
  1248. } else {
  1249. this.mdDiscountAmount = this.mdDiscountAmount + (price + this.psf) * (100 - obj.yhnum *
  1250. 100) / 100;
  1251. }
  1252. console.log(price, obj.yhnum, price * (1 - obj.yhnum))
  1253. }
  1254. if (obj.yhfangs == 3) { //商品
  1255. if (obj.yhnum > 1) {
  1256. if (obj.yhnum > price) {
  1257. this.mdDiscountAmount = price;
  1258. } else {
  1259. this.mdDiscountAmount = obj.yhnum;
  1260. }
  1261. } else {
  1262. this.mdDiscountAmount = this.mdDiscountAmount + price * (100 - obj.yhnum * 100) / 100;
  1263. }
  1264. console.log(price, obj.yhnum, price * (1 - obj.yhnum))
  1265. }
  1266. }
  1267. }
  1268. }
  1269. console.log(this.hdidpt, this.hdidsj, this.kqidpt, this.kqidsj)
  1270. console.log(this.salesReduction, this.mdSalesReduction, this.discountAmount, this.mdDiscountAmount)
  1271. zongyouhui = this.salesReduction + this.mdSalesReduction + this.discountAmount + this.mdDiscountAmount;
  1272. console.log('zongyouhui:', zongyouhui);
  1273. return zongyouhui;
  1274. },
  1275. sumfontnum(e) {
  1276. this.remarks = e.target.value;
  1277. },
  1278. shifodaofu() {
  1279. if (this.actType > 1) {
  1280. return;
  1281. }
  1282. if (this.shifoudf == 0) {
  1283. this.shifoudf = 1;
  1284. } else {
  1285. this.shifoudf = 0;
  1286. }
  1287. if (this.actType == 1 && this.shifoudf == 1) {
  1288. this.actTitle = this.$t('index.huodaofukan');
  1289. uni.showToast({
  1290. title: this.$t('order.xuanzezhif'),
  1291. icon: 'none',
  1292. duration: 2500
  1293. })
  1294. } else if (this.actType == 1 && this.shifoudf == 0) {
  1295. this.actTitle = this.$t('order.quzhifu');
  1296. }
  1297. console.log(this.shifoudf)
  1298. },
  1299. changaddr() {
  1300. uni.navigateTo({
  1301. url: '/pages/UserCenter/dizhi/dizhilist'
  1302. })
  1303. },
  1304. yuyueshijian() {
  1305. this.$refs.chooseTime.open()
  1306. },
  1307. changeTime(e) {
  1308. //选择的时间
  1309. console.log('选择的时间', e.value);
  1310. this.delryTime = e.value;
  1311. },
  1312. deliveryclose() {
  1313. this.delryTime = '';
  1314. },
  1315. peisong() {
  1316. if (this.actType > 0) {
  1317. return;
  1318. }
  1319. this.showAdrr = 0;
  1320. this.peisongimg = '/static/images/peisongh@3x.png';
  1321. this.ziquimg = '/static/images/ziqu@3x.png';
  1322. this.tangshiimg = '/static/images/tangshih.png';
  1323. this.Bcolor = 'whitesmoke';
  1324. this.Bcolorr = 'lightgray';
  1325. this.Bcolorrr = 'lightgray';
  1326. this.Tcolor = 'black';
  1327. this.Tcolorr = 'darkgray';
  1328. this.Tcolorrr = 'darkgray';
  1329. this.psf = parseFloat(this.freight);
  1330. this.jisuanjiner();
  1331. },
  1332. ziqu() {
  1333. if (this.actType > 0) {
  1334. return;
  1335. }
  1336. this.showAdrr = 1;
  1337. this.peisongimg = '/static/images/peisong@3x.png';
  1338. this.ziquimg = '/static/images/ziquh@3x.png';
  1339. this.tangshiimg = '/static/images/tangshih.png';
  1340. this.Bcolor = 'lightgray';
  1341. this.Bcolorr = 'whitesmoke';
  1342. this.Bcolorrr = 'lightgray';
  1343. this.Tcolor = 'darkgray';
  1344. this.Tcolorr = 'black';
  1345. this.Tcolorrr = 'darkgray';
  1346. this.psf = 0;
  1347. this.jisuanjiner();
  1348. },
  1349. tangshi() {
  1350. this.showAdrr = 2;
  1351. this.peisongimg = '/static/images/peisong@3x.png';
  1352. this.ziquimg = '/static/images/ziqu@3x.png';
  1353. this.tangshiimg = '/static/images/tangshi.png';
  1354. this.Bcolor = 'lightgray';
  1355. this.Bcolorr = 'lightgray';
  1356. this.Bcolorrr = 'whitesmoke';
  1357. this.Tcolor = 'darkgray';
  1358. this.Tcolorr = 'darkgray';
  1359. this.Tcolorrr = 'black';
  1360. this.psf = 0;
  1361. this.jisuanjiner();
  1362. },
  1363. //确认订单,要求下载app
  1364. qufukuan() {
  1365. if (this.foodlist.length == 0) {
  1366. uni.showToast({
  1367. title: this.$t('comp.qingxzsp'),
  1368. icon: 'none',
  1369. duration: 2500
  1370. })
  1371. return;
  1372. }
  1373. api('getAppDownload', {}, r => {
  1374. console.log(r)
  1375. uni.showModal({
  1376. title: this.$t('api.message'),
  1377. content: this.$t('jiesuan.xiazapp'),
  1378. showCancel: true,
  1379. cancelText: this.$t('jiesuan.xzios'),
  1380. confirmText: this.$t('jiesuan.xiazandriod'),
  1381. success: (res) => {
  1382. if (res.confirm) {
  1383. // 点击下载Android版本
  1384. const isAndroid = this.isAndroidDevice();
  1385. if (isAndroid) {
  1386. // 安卓设备自动下载并安装
  1387. this.downloadAndInstallAndroid(r.data.data.androidUrl);
  1388. } else {
  1389. // 非安卓设备直接打开下载链接
  1390. window.open(r.data.data.androidUrl, '_blank');
  1391. }
  1392. } else if (res.cancel) {
  1393. // 点击下载iOS版本
  1394. this.downloadIOSApp(r.data.data.iosUrl);
  1395. }
  1396. }
  1397. });
  1398. return;
  1399. });
  1400. return
  1401. if (this.keyixd == false) {
  1402. uni.showToast({
  1403. title: this.$t('mend.dianjiastatedy'),
  1404. icon: 'none',
  1405. duration: 2500
  1406. })
  1407. return;
  1408. }
  1409. if (this.actType == 2) { //已经支付过了!!
  1410. // uni.showToast({
  1411. // title: '已经支付过了!!',
  1412. // icon: 'none',
  1413. // duration: 2500
  1414. // })
  1415. return;
  1416. }
  1417. if (this.actType == 1) { //未支付,跳转支付
  1418. this.zffsS = true;
  1419. return;
  1420. }
  1421. var data;
  1422. if (this.ddId.length > 0) {
  1423. console.log('已经生成订单,不能重复提交');
  1424. } else {
  1425. this.ddId = '99' + new Date().valueOf();
  1426. }
  1427. var cretim = getApp().globalData.sj();
  1428. // console.log(cretim);
  1429. // return;
  1430. if (this.showAdrr == 0) {
  1431. if (this.dizhiID == '') {
  1432. uni.showToast({
  1433. title: this.$t('order.shdz'),
  1434. icon: 'none',
  1435. duration: 3500
  1436. })
  1437. return;
  1438. }
  1439. if (!this.isGetyunfei) {
  1440. uni.showToast({
  1441. title: this.$t('order.hqyfsb'),
  1442. icon: 'none',
  1443. duration: 3500
  1444. })
  1445. return;
  1446. }
  1447. data = {
  1448. "ddId": this.ddId,
  1449. "shId": this.userid,
  1450. "mdId": this.mendid,
  1451. "shdzId": this.dizhiID.id,
  1452. "amount": this.zje,
  1453. "remarks": this.remarks,
  1454. "type": 0,
  1455. "delryTime": this.delryTime, //new Date().toISOString(),
  1456. "foodlist": this.foodlist,
  1457. "freight": this.psf,
  1458. "jvli": this.jvli,
  1459. "longitude": this.mendianMs.longitude,
  1460. "latitude": this.mendianMs.latitude,
  1461. "collectPayment": this.shifoudf,
  1462. "cretim": cretim,
  1463. "yhId": this.kqidpt, //平台使用优惠券id
  1464. "mdYhId": this.kqidsj, //门店优惠券id
  1465. "activity": this.hdidpt, //平台促销活动id
  1466. "mdActivity": this.hdidsj, //门店促销活动id
  1467. "salesReduction": this.salesReduction, //平台促销減免值
  1468. "mdSalesReduction": this.mdSalesReduction, //门店促销減免值
  1469. "discountAmount": this.discountAmount, //平台优惠券优惠金额
  1470. "mdDiscountAmount": this.mdDiscountAmount, //门店优惠券优惠金额
  1471. "xiadanjiaoyan": 2
  1472. }
  1473. } else {
  1474. data = {
  1475. "ddId": this.ddId,
  1476. "shId": this.userid,
  1477. "mdId": this.mendid,
  1478. "shdzId": '',
  1479. "amount": this.zje,
  1480. "remarks": this.remarks,
  1481. "type": this.showAdrr,
  1482. "delryTime": this.delryTime, // new Date().toISOString(),
  1483. "foodlist": this.foodlist,
  1484. "freight": this.psf,
  1485. "jvli": this.jvli,
  1486. "longitude": this.mendianMs.longitude,
  1487. "latitude": this.mendianMs.latitude,
  1488. "collectPayment": this.shifoudf,
  1489. "cretim": cretim,
  1490. "yhId": this.kqidpt, //平台使用优惠券id
  1491. "mdYhId": this.kqidsj, //门店优惠券id
  1492. "activity": this.hdidpt, //平台促销活动id
  1493. "mdActivity": this.hdidsj, //门店促销活动id
  1494. "salesReduction": this.salesReduction, //平台促销減免值
  1495. "mdSalesReduction": this.mdSalesReduction, //门店促销減免值
  1496. "discountAmount": this.discountAmount, //平台优惠券优惠金额
  1497. "mdDiscountAmount": this.mdDiscountAmount, //门店优惠券优惠金额
  1498. "xiadanjiaoyan": 2
  1499. }
  1500. }
  1501. this.zhifuUrl = '';
  1502. this.addorder(data);
  1503. },
  1504. getaddressList() {
  1505. api('getaddressList', {}, r => {
  1506. this.addrList = r.data.data;
  1507. if (this.dizhiID != '') {
  1508. console.log('3333')
  1509. this.getyunfei(this.dizhiID.latitude, this.dizhiID.longitude);
  1510. } else {
  1511. if (this.addrList.length > 0) {
  1512. console.log('2222')
  1513. this.dizhiID = this.addrList[0];
  1514. this.mpImage = this.dizhiID.annexes;
  1515. this.getyunfei(this.dizhiID.latitude, this.dizhiID.longitude);
  1516. }
  1517. }
  1518. }, failc => {
  1519. //console.log('getadvertis----',failc)
  1520. })
  1521. },
  1522. getmendianDetail(id) {
  1523. api('getmendianDetail', {
  1524. id: id
  1525. }, r => {
  1526. this.mendianMs = r.data.data;
  1527. console.log('getmendianDetail', this.mendianMs);
  1528. if (this.mendianMs) {
  1529. if (this.mendianMs.state == 1) {
  1530. this.keyixd = false;
  1531. }
  1532. }
  1533. if (this.dizhiID == '') {
  1534. this.getaddressList();
  1535. } else {
  1536. console.log('111')
  1537. this.getyunfei(this.dizhiID.latitude, this.dizhiID.longitude);
  1538. }
  1539. }, failc => {
  1540. //console.log('getadvertis----',failc)
  1541. })
  1542. },
  1543. getyunfei(lat, lng) {
  1544. if (this.mendianMs == '') {
  1545. return;
  1546. }
  1547. //this.getjuliForyunfei(lat,lng);//前端请求规划路径
  1548. //this.getjuliForyunfeiHT(lat,lng);//后端请求规划路径
  1549. //先请求直线距离运费,如果规划路径运费小于直线距离则用直线距离的值
  1550. //1--------在这个方法中调用规划计算
  1551. console.log("getyunfei----------")
  1552. this.zhixianyuanfei(lat, lng);
  1553. },
  1554. //通过坐标直线计算运费
  1555. zhixianyuanfei(lat, lng) {
  1556. var that = this;
  1557. api('getyunfei', {
  1558. lat1: lng,
  1559. lng1: lat,
  1560. lat2: this.mendianMs.longitude,
  1561. lng2: this.mendianMs.latitude
  1562. }, r => {
  1563. console.log('直线运费');
  1564. console.log(r);
  1565. if (r.data.code != 200) {
  1566. return;
  1567. }
  1568. that.freight = parseInt(r.data.data.freight);
  1569. if (that.freight > 0) {} else {
  1570. that.freight = 0;
  1571. }
  1572. that.zhixianfreight = that.freight;
  1573. that.zhixianjuli = r.data.data.jvli;
  1574. that.getjuliForyunfeiHT(lat, lng);
  1575. }, failc => {
  1576. //console.log('getadvertis----',failc)
  1577. })
  1578. },
  1579. getjuliForyunfei(lat, lng) { //前端
  1580. var data = {
  1581. "origin": {
  1582. "location": {
  1583. "latLng": {
  1584. "latitude": lat,
  1585. "longitude": lng
  1586. }
  1587. }
  1588. },
  1589. "destination": {
  1590. "location": {
  1591. "latLng": {
  1592. "latitude": this.mendianMs.latitude,
  1593. "longitude": this.mendianMs.longitude
  1594. }
  1595. }
  1596. },
  1597. "travelMode": "DRIVE",
  1598. "units": "METRIC" //米
  1599. };
  1600. console.log(data);
  1601. api('getdistense', data, r => {
  1602. console.log('getadvertis----', r);
  1603. if (r.statusCode == 200) {
  1604. var dist = r.data.routes[0].distanceMeters;
  1605. console.log(dist / 1000);
  1606. this.getyunfeiWithJuli(dist / 1000);
  1607. console.log('路径运费');
  1608. } else {
  1609. this.zhixianyuanfei(lat, lng);
  1610. console.log('路径计算距离失败!');
  1611. uni.showToast({
  1612. title: this.$t('api.wangluoshibai'),
  1613. icon: 'none',
  1614. duration: 3500
  1615. })
  1616. }
  1617. }, failc => {
  1618. console.log('getadvertis----', failc)
  1619. })
  1620. },
  1621. getjuliForyunfeiHT(lat, lng) {
  1622. var that = this;
  1623. var latlng1 = '' + lat + ',' + lng;
  1624. var latlng2 = '' + this.mendianMs.latitude + ',' + this.mendianMs.longitude;
  1625. // var latlng1='10.715641,106.73932';//''+lat+','+lng;
  1626. // var latlng2='10.754999,106.735601';//''+this.mendianMs.latitude+','+this.mendianMs.longitude;
  1627. api('getluxianjvli', {
  1628. latlng1: latlng1,
  1629. latlng2: latlng2,
  1630. id: this.userid
  1631. }, r => {
  1632. console.log('getjuliForyunfeiHT', r);
  1633. if (r.data.code == 200) {
  1634. if (r.data.data[0]) {
  1635. var legs = r.data.data[0].legs;
  1636. if (legs[0]) {
  1637. var juli = legs[0].distance.value;
  1638. // uni.showToast({
  1639. // title:'通过轨迹计算运费',
  1640. // icon: 'none',
  1641. // duration: 3500
  1642. // })
  1643. if (juli > that.zhixianjuli) {
  1644. that.getyunfeiWithJuli(juli / 1000);
  1645. } else {
  1646. that.psf = that.freight;
  1647. that.jvli = that.zhixianjuli;
  1648. that.isGetyunfei = true;
  1649. console.log('直线运费');
  1650. if (this.showAdrr == 0) {
  1651. that.jisuanjiner();
  1652. }
  1653. }
  1654. return;
  1655. }
  1656. }
  1657. }
  1658. that.psf = that.freight;
  1659. that.jvli = that.zhixianjuli;
  1660. that.isGetyunfei = true;
  1661. console.log('直线运费');
  1662. if (this.showAdrr == 0) {
  1663. that.jisuanjiner();
  1664. }
  1665. }, failc => {
  1666. //console.log('getadvertis----',failc)
  1667. })
  1668. },
  1669. getyunfeiWithJuli(distence) {
  1670. var that = this;
  1671. api('getZuiyyfei', {
  1672. quli: JSON.stringify(distence)
  1673. }, r => {
  1674. console.log(r);
  1675. if (r.data.code != 200) {
  1676. return;
  1677. }
  1678. that.psf = parseInt(r.data.data.freight);
  1679. if (that.psf > 0) {} else {
  1680. that.psf = 0;
  1681. }
  1682. that.freight = that.psf;
  1683. that.jvli = r.data.data.jvli;
  1684. that.isGetyunfei = true;
  1685. if (this.showAdrr == 0) {
  1686. that.jisuanjiner();
  1687. }
  1688. }, failc => {
  1689. //console.log('getadvertis----',failc)
  1690. })
  1691. },
  1692. addorder(data) {
  1693. var that = this;
  1694. uni.showLoading({
  1695. title: 'Loading...',
  1696. mask: true
  1697. })
  1698. console.log('addorder', data);
  1699. api('addorder', data,
  1700. r => {
  1701. console.log(r);
  1702. uni.hideLoading();
  1703. if (r.data.code == 200) {
  1704. this.qingkonggouwuche();
  1705. this.ddId = data.ddId;
  1706. this.rId = r.data.data.id;
  1707. this.orderDetl = r.data.data;
  1708. if (this.shifoudf == 0) {
  1709. this.actType = 1;
  1710. this.actTitle = that.$t('order.quzhifu');
  1711. uni.showToast({
  1712. title: that.$t('order.xuanzezhif'),
  1713. icon: 'none',
  1714. duration: 2500
  1715. })
  1716. } else {
  1717. this.actType = 1;
  1718. this.actTitle = that.$t('index.huodaofukan');
  1719. //到付订单,直接更新支付状态
  1720. this.huodaofukuan();
  1721. }
  1722. } else {
  1723. uni.showToast({
  1724. title: r.data.msg,
  1725. icon: 'none',
  1726. duration: 3000
  1727. })
  1728. }
  1729. }, failc => {
  1730. uni.hideLoading();
  1731. //console.log('getadvertis----',failc)
  1732. })
  1733. },
  1734. getVNPay() {
  1735. api('setorderuzt', {
  1736. id: this.rId,
  1737. "collectPayment": 0
  1738. }, res => {
  1739. if (res.data.code != 200) {
  1740. return;
  1741. }
  1742. }, failc => {
  1743. return;
  1744. })
  1745. this.zffsS = false;
  1746. var language = uni.getStorageSync('language');
  1747. var lg;
  1748. if (language == 'yuenan') {
  1749. lg = 'vi';
  1750. } else {
  1751. lg = 'en';
  1752. }
  1753. uni.showLoading({
  1754. title: 'Loading...',
  1755. mask: true
  1756. })
  1757. api('VNPay', {
  1758. orderid: this.ddId,
  1759. amount: parseInt(this.zje),
  1760. language: lg
  1761. }, r => {
  1762. uni.hideLoading();
  1763. if (r.data.code != 200) {
  1764. uni.showToast({
  1765. title: r.data.msg,
  1766. icon: 'none',
  1767. duration: 3500
  1768. })
  1769. return;
  1770. }
  1771. this.shifouzhifu = true;
  1772. this.zhifuUrl = '/pages/OrderList/buy/Zhifuyemian?url=' + encodeURIComponent(JSON.stringify(r
  1773. .data.data)) + '&ddid=' + this.ddId;
  1774. uni.navigateTo({
  1775. url: '/pages/OrderList/buy/Zhifuyemian?url=' + encodeURIComponent(JSON.stringify(r
  1776. .data.data)) + '&ddid=' + this.ddId
  1777. })
  1778. }, failc => {
  1779. uni.hideLoading();
  1780. //console.log('getadvertis----',failc)
  1781. })
  1782. },
  1783. huodaofukuan() {
  1784. this.shifoudf = 1;
  1785. this.zffsS = false;
  1786. uni.showLoading({
  1787. title: 'Loading...',
  1788. mask: true
  1789. })
  1790. var that = this;
  1791. api('setorderuzt', {
  1792. id: this.rId,
  1793. "collectPayment": this.shifoudf
  1794. }, res => {
  1795. console.log('setorderuzt:', res)
  1796. uni.hideLoading();
  1797. if (res.data.code == 200) {
  1798. this.actType = 2;
  1799. this.actTitle = that.$t('order.yizhifu');
  1800. uni.showToast({
  1801. title: that.$t('order.xiadancg'),
  1802. icon: 'none',
  1803. duration: 2500,
  1804. mask: true
  1805. })
  1806. setTimeout(function() {
  1807. // 这里写要延时执行的代码
  1808. uni.redirectTo({
  1809. url: '/pages/OrderList/OrderDetail?ddid=' + that.ddId +
  1810. '&isShangjia=0'
  1811. })
  1812. }, 2500);
  1813. } else {
  1814. if (res.data.msg) {
  1815. uni.showToast({
  1816. title: res.data.msg,
  1817. icon: 'none',
  1818. duration: 2000
  1819. })
  1820. }
  1821. }
  1822. }, failc => {
  1823. uni.hideLoading();
  1824. //console.log('getadvertis----',failc)
  1825. })
  1826. },
  1827. setorderuzt() {
  1828. var that = this;
  1829. api('setorderuzt', {
  1830. id: this.rId,
  1831. state: 1
  1832. }, res => {
  1833. this.actType = 2;
  1834. this.actTitle = that.$t('order.yizhifu');
  1835. uni.showToast({
  1836. title: that.$t('order.xiadancg'),
  1837. icon: 'none',
  1838. duration: 2500,
  1839. mask: true
  1840. })
  1841. setTimeout(function() {
  1842. // 这里写要延时执行的代码
  1843. uni.redirectTo({
  1844. url: '/pages/OrderList/OrderDetail?ddid=' + that.ddId + '&isShangjia=0'
  1845. })
  1846. }, 2500);
  1847. }, failc => {
  1848. //console.log('getadvertis----',failc)
  1849. })
  1850. },
  1851. getorderDetl() {
  1852. var that = this;
  1853. api('getorderxq', {
  1854. ddid: this.ddId
  1855. }, r => {
  1856. this.orderDetl = r.data.data;
  1857. if (this.orderDetl.state == 1) {
  1858. that.actType = 2;
  1859. that.actTitle = that.$t('order.yizhifu');
  1860. uni.showToast({
  1861. title: that.$t('order.xiadancg'),
  1862. icon: 'none',
  1863. duration: 2500,
  1864. mask: true
  1865. })
  1866. setTimeout(function() {
  1867. // 这里写要延时执行的代码
  1868. uni.redirectTo({
  1869. url: '/pages/OrderList/OrderDetail?ddid=' + that.ddId +
  1870. '&isShangjia=0'
  1871. })
  1872. }, 2500);
  1873. }
  1874. }, failc => {
  1875. //console.log('getadvertis----',failc)
  1876. })
  1877. },
  1878. qingkonggouwuche() {
  1879. if (this.foodlist.length > 1) {
  1880. uni.setStorageSync('gouwuche', '');
  1881. return;
  1882. }
  1883. var gwc = uni.getStorageSync('gouwuche');
  1884. var gouwuche;
  1885. if ('' == gwc || null == gwc || undefined == gwc) {} else {
  1886. gouwuche = JSON.parse(gwc);
  1887. if (gouwuche.foodlist.length <= 1) {
  1888. uni.setStorageSync('gouwuche', '');
  1889. return;
  1890. }
  1891. for (var i = 0; i < gouwuche.foodlist.length; i++) {
  1892. var sp = gouwuche.foodlist[i];
  1893. if (this.foodlist[0].id == sp.id) {
  1894. gouwuche.foodlist.splice(i, 1);
  1895. let gwcS = JSON.stringify(gouwuche);
  1896. uni.setStorageSync('gouwuche', gwcS);
  1897. }
  1898. }
  1899. }
  1900. },
  1901. gengxingouwuche(item) {
  1902. var gwc = uni.getStorageSync('gouwuche');
  1903. if ('' == gwc || null == gwc || undefined == gwc) {
  1904. return;
  1905. }
  1906. var gouwuche = JSON.parse(gwc);
  1907. for (var i = 0; i < gouwuche.foodlist.length; i++) {
  1908. var sp = gouwuche.foodlist[i];
  1909. if (item.id == sp.id) {
  1910. if (item.number > 0) {
  1911. gouwuche.foodlist[i].number = item.number;
  1912. } else {
  1913. gouwuche.foodlist.splice(i, 1);
  1914. }
  1915. if (gouwuche.foodlist.length < 1) {
  1916. uni.setStorageSync('gouwuche', '');
  1917. } else {
  1918. let gwcS = JSON.stringify(gouwuche);
  1919. uni.setStorageSync('gouwuche', gwcS);
  1920. }
  1921. return;
  1922. }
  1923. }
  1924. },
  1925. pushMsg(cid, orderId) { //消息推送
  1926. api('pushMsgSJ', {
  1927. cid: cid,
  1928. title: this.$t('order.xindd'),
  1929. content: orderId,
  1930. payload: ''
  1931. }, res => {
  1932. console.log(res)
  1933. }, failc => {
  1934. //console.log('getadvertis----',failc)
  1935. })
  1936. },
  1937. selectImage() {
  1938. console.log('selectImage');
  1939. this.$refs.yhdslCropper.chooseImage();
  1940. },
  1941. uploadImg(e) {
  1942. console.log('------------uploadImg:', e)
  1943. this.spImage = e;
  1944. var that = this;
  1945. uni.uploadFile({
  1946. url: this.$upImagurl, //上传图片api
  1947. filePath: e,
  1948. name: 'file',
  1949. header: {
  1950. //"Authorization": userinfo.token
  1951. },
  1952. success: (res) => {
  1953. let group = JSON.parse(res.data);
  1954. that.mpImage = group.data;
  1955. console.log(group)
  1956. api('ADDaddress', {
  1957. id: that.dizhiID.id,
  1958. annexes: that.mpImage
  1959. },
  1960. res => {
  1961. if (res.data.code == 200) {
  1962. that.dizhiID.annexes = that.mpImage;
  1963. uni.setStorageSync("peisongdizhi", that.dizhiID);
  1964. }
  1965. console.log('getGoodsDetail:', res);
  1966. }, failc => {
  1967. //console.log('getadvertis----',failc)
  1968. })
  1969. uni.showToast({
  1970. title: that.$t('mend.shangccg'),
  1971. icon: "success"
  1972. })
  1973. }
  1974. });
  1975. },
  1976. }
  1977. }
  1978. </script>
  1979. <style lang="scss">
  1980. page {
  1981. background-color: #F2F3F7;
  1982. }
  1983. .contentV {
  1984. width: 100%;
  1985. position: relative;
  1986. }
  1987. .linesp {
  1988. width: 100%;
  1989. height: 8rpx;
  1990. background-color: aliceblue;
  1991. }
  1992. .pinglun {
  1993. margin: 16rpx;
  1994. padding: 10rpx;
  1995. width: 92%;
  1996. height: 100rpx;
  1997. border-radius: 15rpx;
  1998. border: 2rpx solid lightgray;
  1999. }
  2000. .ctinrow {
  2001. margin-top: 20rpx;
  2002. width: 100%;
  2003. height: 80rpx;
  2004. display: flex;
  2005. flex-direction: row;
  2006. align-items: center;
  2007. justify-content: center;
  2008. }
  2009. .delbtct {
  2010. margin-left: 10%;
  2011. margin-top: 20rpx;
  2012. padding-bottom: 30rpx;
  2013. width: 80%;
  2014. }
  2015. .delbt {
  2016. text-align: center;
  2017. font-size: 36rpx;
  2018. width: 100%;
  2019. height: 80rpx;
  2020. line-height: 80rpx;
  2021. color: white;
  2022. background-color: goldenrod;
  2023. border-radius: 10rpx;
  2024. }
  2025. .topSwichV {
  2026. height: 70rpx;
  2027. width: 280rpx;
  2028. border-radius: 35rpx;
  2029. display: flex;
  2030. flex-direction: row;
  2031. align-items: center;
  2032. justify-content: center;
  2033. }
  2034. .topSwichVL {
  2035. margin-left: -40rpx;
  2036. height: 70rpx;
  2037. width: 200rpx;
  2038. border-radius: 35rpx;
  2039. display: flex;
  2040. flex-direction: row;
  2041. align-items: center;
  2042. justify-content: center;
  2043. }
  2044. .toppz {
  2045. width: 50rpx;
  2046. }
  2047. .toppztext {
  2048. font-size: 30rpx;
  2049. }
  2050. .spnodetail {
  2051. display: flex;
  2052. flex-direction: row;
  2053. align-items: center;
  2054. background-color: white;
  2055. margin-top: 20rpx;
  2056. margin-bottom: 20rpx;
  2057. }
  2058. .spIcon {
  2059. margin: 20rpx;
  2060. width: 90rpx;
  2061. height: 90rpx;
  2062. }
  2063. .xiaoji {
  2064. margin-left: auto;
  2065. margin-right: 30rpx;
  2066. }
  2067. .actBTV {
  2068. width: 100%;
  2069. display: flex;
  2070. flex-direction: row;
  2071. justify-content: space-between;
  2072. align-items: center;
  2073. }
  2074. .viewinrow {
  2075. display: flex;
  2076. flex-direction: row;
  2077. align-items: center;
  2078. width: 100%;
  2079. }
  2080. .kouweisku {
  2081. padding-right: 10rpx;
  2082. color: chocolate;
  2083. font-size: 26rpx;
  2084. }
  2085. .shifdf {
  2086. height: 90rpx;
  2087. width: 90%;
  2088. margin-left: 5%;
  2089. align-items: center;
  2090. }
  2091. .shifdftext {
  2092. margin-left: 30rpx;
  2093. font-size: 30rpx;
  2094. }
  2095. .hdts {
  2096. margin-left: 30rpx;
  2097. font-size: 30rpx;
  2098. overflow: hidden;
  2099. text-overflow: ellipsis;
  2100. display: -webkit-box;
  2101. -webkit-line-clamp: 1;
  2102. -webkit-box-orient: vertical;
  2103. }
  2104. .picker-view {
  2105. width: 750rpx;
  2106. height: 300rpx;
  2107. margin-top: 10rpx;
  2108. }
  2109. .item {
  2110. line-height: 100rpx;
  2111. text-align: center;
  2112. }
  2113. .zhifbut {
  2114. text-align: center;
  2115. margin-top: 12rpx;
  2116. margin-bottom: 12rpx;
  2117. width: 80%;
  2118. border-radius: 10rpx;
  2119. color: white;
  2120. line-height: 70rpx;
  2121. }
  2122. .imageRJ {
  2123. width: 40rpx;
  2124. height: 40rpx;
  2125. margin-right: 8rpx;
  2126. }
  2127. .imageR {
  2128. width: 40rpx;
  2129. height: 40rpx;
  2130. margin-right: 30rpx;
  2131. }
  2132. .textR {
  2133. font-size: 26rpx;
  2134. margin-left: 6rpx;
  2135. margin-right: 6rpx;
  2136. }
  2137. </style>