jiesuanYe.vue 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164
  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" thumb="/static/images/dizhil@3x.png"
  27. 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')" :note="delryTime.length>0?delryTime:('10~20 '+$t('order.Xfenzhongsd'))" :rightText="$t('order.yuyueshijian')" thumb="/static/images/time@3x.png"
  31. thumb-size="sm" @click="yuyueshijian" link></uni-list-item>
  32. </uni-list>
  33. <label class="linesp"></label>
  34. <label class="linesp"></label>
  35. <uni-list>
  36. <uni-list-item :title="$t('index.goodslist')"></uni-list-item>
  37. </uni-list>
  38. <view v-for="(items,indexs) in gouwuche">
  39. <view class="contentInRowL">
  40. <netImage style="margin-left: 12rpx;margin-top: 10rpx;" width="60" height="60" bradius="30" :mysrc="items.logo" mymode="scaleToFill"></netImage>
  41. <text>{{items.posName}}</text>
  42. </view>
  43. <view v-for="(item,findex) in items.food">
  44. <view class="spnodetail">
  45. <view class="">
  46. <myImage class="spIcon" :mysrc="item.image" mymode="scaleToFill"></myImage>
  47. </view>
  48. <view style="width: 82%;">
  49. <view class="actBTV">
  50. <view style="font-size: 30rpx;width: 100%;">
  51. <text class="text2row" style="width: 100%;">{{item.name}}</text>
  52. </view>
  53. <view class="contentInRowL">
  54. <image v-if="item.number>0" class="imageRJ" src="/static/meishi/jianh.png" mode="aspectFit" @click="jiajian(findex,-1)"></image>
  55. <text v-if="item.number>0" class="textR">{{item.number}}</text>
  56. <image class="imageR" src="/static/meishi/jiah.png" mode="aspectFit" @click="jiajian(findex,1)"></image>
  57. </view>
  58. </view>
  59. <view class="actBTV">
  60. <view style="font-size: 26rpx;color: blueviolet;">{{$t('shangpin.shoujia')}}: {{$formPr(item.price+item.otherPrice)}}{{$t('locale.huobidw')}}</view>
  61. <view class="xiaoji" style="font-size: 28rpx;color: brown;">{{$t('shangpin.xiaoji')}}: {{$formPr((item.price+item.otherPrice)*item.number)}}{{$t('locale.huobidw')}}</view>
  62. </view>
  63. <view class="viewinrow" >
  64. <text class="kouweisku">{{arraytoStr(item.ask)}}</text>
  65. </view>
  66. <view v-if="item.beizhu" class="">
  67. <text style="font-size: 30rpx;color:#00A6FF;">{{item.beizhu}}</text>
  68. </view>
  69. </view>
  70. </view>
  71. </view>
  72. </view>
  73. <!-- <label class="linesp"></label>
  74. <label class="linesp"></label>
  75. <uni-list style="color: darkgreen;">
  76. <uni-list-item :title="$t('index.hongbaokq')" :note="yhhd" thumb="/static/images/hongbkqh@3x.png"
  77. thumb-size="sm" @click="xuanzcux" link></uni-list-item>
  78. </uni-list> -->
  79. <label class="linesp"></label>
  80. <label class="linesp"></label>
  81. <view class="contentInRowS shifdf" @click="shifodaofu">
  82. <view class="contentInRowC">
  83. <image style="width: 50rpx;height: 50rpx;" src="/static/images/payflact@3x.png" mode="scaleToFill"></image>
  84. <text class="shifdftext" :style="shifoudf==0?'color:darkgray;':'color:fuchsia;'">{{$t('index.huodaofukan')}}</text>
  85. </view>
  86. <image v-if="shifoudf==1" style="width: 50rpx;height: 50rpx;" src="/static/images/dagoul.png" mode="scaleToFill"></image>
  87. </view>
  88. <label class="linesp"></label>
  89. <label class="linesp"></label>
  90. <uni-list>
  91. <uni-list-item :title="$t('order.beizhu')"></uni-list-item>
  92. </uni-list>
  93. <textarea class="pinglun" :placeholder="$t('order.srddbz')" :value="remarks" @input="sumfontnum"></textarea>
  94. <label class="linesp"></label>
  95. <label class="linesp"></label>
  96. <view v-if="showAdrr==0">
  97. <uni-list>
  98. <uni-list-item :title="$t('order.menpaizp')"></uni-list-item>
  99. </uni-list>
  100. <view class="contentColumnC" style="margin-top: 30rpx;" @click="selectImage">
  101. <netImage width="640" height="640" :mysrc="mpImage" mymode="scaleToFill" ></netImage>
  102. </view>
  103. <view class="linesp" style="margin-top: 20rpx;"></view>
  104. <label class="linesp"></label>
  105. </view>
  106. <uni-list>
  107. <uni-list-item :title="$t('order.shangpinxj')" :rightText="$formPr(spxj)+$t('locale.huobidw')" />
  108. <uni-list-item :title="$t('order.peisongfei')" :rightText="$formPr(psf)+$t('locale.huobidw')"/>
  109. <uni-list-item :title="$t('order.youhuijine')" :rightText="$formPr(hyyh)+$t('locale.huobidw')"/>
  110. </uni-list>
  111. <label class="linesp"></label>
  112. <label class="linesp"></label>
  113. <uni-list>
  114. <uni-list-item :title="$t('order.zhifujine')" :rightText="$formPr(zje)+$t('locale.huobidw')"/>
  115. </uni-list>
  116. <label class="linesp"></label>
  117. <label class="linesp"></label>
  118. <view class="delbtct">
  119. <view class="delbt" @click="qufukuan">
  120. <label >{{actTitle}}</label>
  121. </view>
  122. </view>
  123. <label class="linesp"></label>
  124. <liu-delivery-time @change="changeTime" @close="deliveryclose" ref="chooseTime" :title="$t('order.yuyueshijian')"></liu-delivery-time>
  125. <yhdslCropper ref="yhdslCropper" :quality="1" mode="scale" @uploadImg="uploadImg" :scale="scale"></yhdslCropper>
  126. <popViewGG :tips="$t('index.hongbaokq')" :show="showpop" :acttips="$t('order.queding')" :maskClosable="true" :isCancel="true" @chooseCancel="chooseCancel">
  127. <picker-view :indicator-style="indicatorStyle" @change="bindChange" class="picker-view">
  128. <picker-view-column>
  129. <view class="item" v-for="(item,index) in range" :key="index">{{item}}</view>
  130. </picker-view-column>
  131. </picker-view>
  132. </popViewGG>
  133. <popViewGG :tips="$t('order.zhifufangshi')" :show="zffsS" :showbotom="false" :maskClosable="true" :isCancel="true" @chooseCancel="chooseCancel">
  134. <view class="contentColumnC" style="width: 100%;background-color: whitesmoke;">
  135. <view class="zhifbut" style="background-color: deeppink;" @click="huodaofukuan">{{$t('index.huodaofukan')}}</view>
  136. <!-- <view class="zhifbut" style="background-color:#00A6FF;" @click="getVNPay">VNPAY</view> -->
  137. </view>
  138. </popViewGG>
  139. </view>
  140. </template>
  141. <script>
  142. // import uniList from '@/uni_modules/uni-list/uni-list.vue';
  143. // import uniListItem from '@/uni_modules/uni-list-item/uni-list-item.vue';
  144. // import uniAd from '@/uni_modules/uni-list-ad/uni-list-ad.vue';
  145. // import uniChat from '@/uni_modules/uni-list-chat/uni-list-chat.vue';
  146. import yhdslCropper from '@/components/yhdsl-cropper/yhdsl-cropper.vue';
  147. import api from "@/pages/api/api.js"
  148. export default {
  149. components:{
  150. yhdslCropper//,uniList,uniListItem
  151. },
  152. data() {
  153. return {
  154. mendid:0,
  155. userid:0,
  156. ddId:'',
  157. rId:'',
  158. showAdrr:0,
  159. gouwuche:[],
  160. Bcolor:'whitesmoke',
  161. Bcolorr:'lightgray',
  162. Bcolorrr:'lightgray',
  163. Tcolor:'black',
  164. Tcolorr:'darkgray',
  165. Tcolorrr:'darkgray',
  166. peisongimg:'/static/images/peisongh@3x.png',
  167. ziquimg:'/static/images/ziqu@3x.png',
  168. tangshiimg:'/static/images/tangshih.png',
  169. actTitle:this.$t('order.querendd'),
  170. actType:0,
  171. remarks:'',
  172. spxj:0.00,
  173. psf:0.00,
  174. freight:0.00,
  175. hyyh:0.00,
  176. zje:0.00,
  177. jvli:0.00,
  178. dizhiID:'',
  179. addrList:[],
  180. peisongdizhiaddress:'',
  181. peisongdizhiname:'',
  182. peisongdizhiphone:'',
  183. zfindex:0,
  184. delryTime:'',
  185. isGetyunfei:false,
  186. mendianMs:'',
  187. cid:'',
  188. orderDetl:'',
  189. shifouzhifu:false,
  190. zhifuUrl:'',
  191. shifoudf:0,
  192. scale:1,
  193. baseUrl:this.$baseImagurl,
  194. mpImage:'',
  195. cxList:'',
  196. yhhd:'',
  197. range: [],
  198. youhuiindex:-1,
  199. showpop:false,
  200. indicatorStyle: 'height: 50px;',
  201. zffsS:false,
  202. keyixd:true
  203. }
  204. },
  205. onLoad(option) {
  206. var gwc = uni.getStorageSync('gouwuche');
  207. if(''==gwc||null==gwc||undefined==gwc){
  208. this.gouwuche=[];
  209. return
  210. }
  211. else{
  212. this.gouwuche = JSON.parse(gwc);
  213. }
  214. this.mendid=option.mendid;
  215. this.userid=option.userid;
  216. this.cuxiaoList();
  217. this.cid = uni.getStorageSync("cid");
  218. //console.log(this.cid);
  219. },
  220. onShow() {
  221. var temp=uni.getStorageSync("peisongdizhi");
  222. if(undefined==temp||null==temp||''==temp ){
  223. this.dizhiID='';
  224. this.getaddressList();
  225. }
  226. else{
  227. this.dizhiID= temp;
  228. this.mpImage=this.dizhiID.annexes;
  229. }
  230. this.isGetyunfei = false;
  231. if(this.mendianMs==''){
  232. this.getmendianDetail(this.mendid);
  233. }
  234. else{
  235. if(this.dizhiID==''){
  236. this.getaddressList();
  237. }
  238. else{
  239. console.log('4444')
  240. this.getyunfei(this.dizhiID.latitude,this.dizhiID.longitude);
  241. }
  242. }
  243. //this.getorderDetl();
  244. if(this.shifouzhifu){
  245. this.shifouzhifu=false;
  246. this.getorderDetl();
  247. }
  248. },
  249. methods: {
  250. //促销
  251. cuxiaoList(){
  252. var price=0;
  253. for(var i=0;i<this.foodlist.length;i++){
  254. price=price+(this.foodlist[i].price+this.foodlist[i].otherPrice)*this.foodlist[i].number;
  255. }
  256. api('cuxiaoList',{
  257. mdId:this.mendid,
  258. price:price
  259. },r=>{
  260. console.log('-----------',r)
  261. if(r.data.code==200){
  262. this.cxList=r.data.data;
  263. this.range=[];
  264. if(this.cxList.length>0){
  265. this.yhhd=this.$t('order.qingxzyhkq');
  266. for(var i=0;i<this.cxList.length;i++){
  267. var obj=this.cxList[i];
  268. this.range.push(obj.salesName);
  269. }
  270. }
  271. else{
  272. this.yhhd=this.$t('order.zanwuyhkq');
  273. }
  274. }
  275. this.jisuanjiner();
  276. },failc=>{
  277. //console.log('getadvertis----',failc)
  278. })
  279. },
  280. jiajian(index,state){
  281. if(this.actType>0){
  282. return;
  283. }
  284. var tempList = this.foodlist;
  285. if(state>0){
  286. var temp = tempList[index];
  287. temp.number=temp.number+1;
  288. tempList[index]=temp;
  289. }
  290. else{
  291. var temp = tempList[index];
  292. if(temp.number>1){
  293. temp.number=temp.number-1;
  294. tempList[index]=temp;
  295. }
  296. else{
  297. tempList.splice(index,1);
  298. }
  299. }
  300. this.foodlist=tempList;
  301. this.cuxiaoList();
  302. if(this.foodlist.length==0){
  303. uni.showToast({
  304. title: that.$t('comp.qingxzsp'),
  305. icon: 'none',
  306. duration: 2500
  307. })
  308. }
  309. },
  310. xuanzcux(){
  311. if(this.youhuiindex<0&&this.cxList.length>0){
  312. this.youhuiindex=0;
  313. this.yhhd=this.cxList[this.youhuiindex].salesName;
  314. this.jisuanjiner();
  315. }
  316. this.showpop=true;
  317. },
  318. bindChange (e) {
  319. var val = e.detail.value[0];
  320. this.youhuiindex=val;
  321. this.yhhd=this.cxList[this.youhuiindex].salesName;
  322. console.log(val)
  323. this.jisuanjiner();
  324. },
  325. chooseCancel(){
  326. this.showpop=false;
  327. this.zffsS=false;
  328. console.log('chooseCancel');
  329. },
  330. //--------------------------------------------------------
  331. arraytoStr(arry){
  332. var str='';
  333. if(arry.length>0){
  334. for(var i=0;i<arry.length;i++){
  335. str=str+arry[i]+'; ';
  336. }
  337. }
  338. return str;
  339. },
  340. jisuanjiner(){
  341. this.spxj=0;
  342. this.hyyh=0;
  343. this.zje=0;
  344. for(var i=0;i<this.foodlist.length;i++){
  345. this.spxj=this.spxj+(this.foodlist[i].price+this.foodlist[i].otherPrice)*this.foodlist[i].number;
  346. }
  347. this.hyyh=this.jisuanyouhuijiner(this.spxj);
  348. this.hyyh=parseInt(this.hyyh);
  349. this.zje=(this.spxj+this.psf)-this.hyyh;
  350. this.zje=parseInt(this.zje);
  351. },
  352. jisuanyouhuijiner(price){
  353. var zongyouhui=0;
  354. if(this.cxList.length>0&&this.youhuiindex>=0){
  355. var obj=this.cxList[this.youhuiindex];
  356. if(obj.salesType=="0"){
  357. zongyouhui=zongyouhui+this.psf;
  358. if(obj.salesReduction<1){
  359. zongyouhui=this.psf*(100-obj.salesReduction*100)/100;
  360. }
  361. else if(obj.salesReduction>1){
  362. if(obj.salesReduction>this.psf){
  363. zongyouhui=this.psf;
  364. }
  365. else{
  366. zongyouhui=obj.salesReduction;
  367. }
  368. }
  369. }
  370. if(obj.salesType=="1"){
  371. zongyouhui=zongyouhui+price*(100-obj.salesReduction*100)/100;
  372. console.log(price,obj.salesReduction,price*(1-obj.salesReduction))
  373. }
  374. if(obj.salesType=="2"){
  375. zongyouhui=zongyouhui+obj.salesReduction;
  376. }
  377. }
  378. return zongyouhui;
  379. },
  380. sumfontnum(e){
  381. this.remarks=e.target.value;
  382. },
  383. shifodaofu(){
  384. if(this.actType>1){
  385. return;
  386. }
  387. if(this.shifoudf==0){
  388. this.shifoudf=1;
  389. }
  390. else{
  391. this.shifoudf=0;
  392. }
  393. if(this.actType==1&&this.shifoudf==1){
  394. this.actTitle = this.$t('index.huodaofukan');
  395. uni.showToast({
  396. title: this.$t('order.xuanzezhif'),
  397. icon: 'none',
  398. duration: 2500
  399. })
  400. }
  401. else if(this.actType==1&&this.shifoudf==0){
  402. this.actTitle = this.$t('order.quzhifu');
  403. }
  404. console.log(this.shifoudf)
  405. },
  406. changaddr(){
  407. uni.navigateTo({
  408. url:'/pages/UserCenter/dizhi/dizhilist'
  409. })
  410. },
  411. yuyueshijian(){
  412. this.$refs.chooseTime.open()
  413. },
  414. changeTime(e) {
  415. //选择的时间
  416. console.log('选择的时间',e.value);
  417. this.delryTime = e.value;
  418. },
  419. deliveryclose(){
  420. this.delryTime='';
  421. },
  422. peisong(){
  423. if(this.actType>0){
  424. return;
  425. }
  426. this.showAdrr=0;
  427. this.peisongimg='/static/images/peisongh@3x.png';
  428. this.ziquimg='/static/images/ziqu@3x.png';
  429. this.tangshiimg='/static/images/tangshih.png';
  430. this.Bcolor='whitesmoke';
  431. this.Bcolorr='lightgray';
  432. this.Bcolorrr='lightgray';
  433. this.Tcolor='black';
  434. this.Tcolorr='darkgray';
  435. this.Tcolorrr='darkgray';
  436. this.psf=parseFloat(this.freight);
  437. this.jisuanjiner();
  438. },
  439. ziqu(){
  440. if(this.actType>0){
  441. return;
  442. }
  443. this.showAdrr=1;
  444. this.peisongimg='/static/images/peisong@3x.png';
  445. this.ziquimg='/static/images/ziquh@3x.png';
  446. this.tangshiimg='/static/images/tangshih.png';
  447. this.Bcolor='lightgray';
  448. this.Bcolorr='whitesmoke';
  449. this.Bcolorrr='lightgray';
  450. this.Tcolor='darkgray';
  451. this.Tcolorr='black';
  452. this.Tcolorrr='darkgray';
  453. this.psf=0;
  454. this.jisuanjiner();
  455. },
  456. tangshi(){
  457. this.showAdrr=2;
  458. this.peisongimg='/static/images/peisong@3x.png';
  459. this.ziquimg='/static/images/ziqu@3x.png';
  460. this.tangshiimg='/static/images/tangshi.png';
  461. this.Bcolor='lightgray';
  462. this.Bcolorr='lightgray';
  463. this.Bcolorrr='whitesmoke';
  464. this.Tcolor='darkgray';
  465. this.Tcolorr='darkgray';
  466. this.Tcolorrr='black';
  467. this.psf=0;
  468. this.jisuanjiner();
  469. },
  470. qufukuan(){
  471. if(this.foodlist.length==0){
  472. uni.showToast({
  473. title: that.$t('comp.qingxzsp'),
  474. icon: 'none',
  475. duration: 2500
  476. })
  477. return;
  478. }
  479. if(this.keyixd==false){
  480. uni.showToast({
  481. title: this.$t('mend.dianjiastatedy'),
  482. icon: 'none',
  483. duration: 2500
  484. })
  485. return;
  486. }
  487. if(this.actType==2){//已经支付过了!!
  488. // uni.showToast({
  489. // title: '已经支付过了!!',
  490. // icon: 'none',
  491. // duration: 2500
  492. // })
  493. return;
  494. }
  495. if(this.actType==1){//未支付,跳转支付
  496. this.zffsS=true;
  497. return;
  498. }
  499. var data;
  500. if(this.ddId.length>0){
  501. console.log('已经生成订单,不能重复提交');
  502. }
  503. else{
  504. this.ddId='99'+ new Date().valueOf();
  505. }
  506. var yhid='';
  507. if(this.cxList.length>0&&this.youhuiindex>=0){
  508. var obj=this.cxList[this.youhuiindex];
  509. yhid=obj.id;
  510. }
  511. var cretim=getApp().globalData.sj();
  512. // console.log(cretim);
  513. // return;
  514. if(this.showAdrr==0){
  515. if(this.dizhiID==''){
  516. uni.showToast({
  517. title: this.$t('order.shdz'),
  518. icon: 'none',
  519. duration: 3500
  520. })
  521. return;
  522. }
  523. if(!this.isGetyunfei){
  524. uni.showToast({
  525. title: this.$t('order.hqyfsb'),
  526. icon: 'none',
  527. duration: 3500
  528. })
  529. return;
  530. }
  531. data={
  532. "ddId": this.ddId,
  533. "shId": this.userid,
  534. "mdId": this.mendid,
  535. "activity":yhid,
  536. "shdzId": this.dizhiID.id,
  537. "amount":this.zje,
  538. "discountAmount":this.hyyh,
  539. "remarks": this.remarks,
  540. "type": 0,
  541. "delryTime": this.delryTime,//new Date().toISOString(),
  542. "foodlist": this.foodlist,
  543. "freight": this.psf,
  544. "jvli": this.jvli,
  545. "longitude": this.mendianMs.longitude,
  546. "latitude":this.mendianMs.latitude,
  547. "collectPayment":this.shifoudf,
  548. "cretim":cretim
  549. }
  550. }
  551. else{
  552. data={
  553. "ddId": this.ddId,
  554. "shId": this.userid,
  555. "mdId": this.mendid,
  556. "activity":yhid,
  557. "shdzId": '',
  558. "amount":this.zje,
  559. "discountAmount":this.hyyh,
  560. "remarks": this.remarks,
  561. "type": this.showAdrr,
  562. "delryTime":this.delryTime,// new Date().toISOString(),
  563. "foodlist": this.foodlist,
  564. "freight": this.psf,
  565. "jvli": this.jvli,
  566. "longitude": this.mendianMs.longitude,
  567. "latitude":this.mendianMs.latitude,
  568. "collectPayment":this.shifoudf,
  569. "cretim":cretim
  570. }
  571. }
  572. this.zhifuUrl='';
  573. this.addorder(data);
  574. },
  575. getaddressList(){
  576. api('getaddressList',{
  577. },r=>{
  578. this.addrList=r.data.data;
  579. if(this.dizhiID!=''){
  580. console.log('3333')
  581. this.getyunfei(this.dizhiID.latitude,this.dizhiID.longitude);
  582. }
  583. else{
  584. if(this.addrList.length>0){
  585. console.log('2222')
  586. this.dizhiID=this.addrList[0];
  587. this.mpImage=this.dizhiID.annexes;
  588. this.getyunfei(this.dizhiID.latitude,this.dizhiID.longitude);
  589. }
  590. }
  591. },failc=>{
  592. //console.log('getadvertis----',failc)
  593. })
  594. },
  595. getmendianDetail(id){
  596. api('getmendianDetail',{
  597. id:id
  598. },r=>{
  599. this.mendianMs=r.data.data;
  600. console.log('getmendianDetail',this.mendianMs);
  601. if(this.mendianMs){
  602. if(this.mendianMs.state==1){
  603. this.keyixd=false;
  604. }
  605. }
  606. if(this.dizhiID==''){
  607. this.getaddressList();
  608. }
  609. else{
  610. console.log('111')
  611. this.getyunfei(this.dizhiID.latitude,this.dizhiID.longitude);
  612. }
  613. this.cuxiaoList();
  614. },failc=>{
  615. //console.log('getadvertis----',failc)
  616. })
  617. },
  618. getyunfei(lat,lng){
  619. var that = this;
  620. if(this.mendianMs==''){
  621. return;
  622. }
  623. //this.getjuliForyunfei(lat,lng);//前端请求
  624. this.getjuliForyunfeiHT(lat,lng);//后端请求
  625. },
  626. //通过坐标直线计算运费
  627. zhixianyuanfei(lat,lng){
  628. var that = this;
  629. api('getyunfei',{
  630. lat1:lng,
  631. lng1:lat,
  632. lat2:this.mendianMs.longitude,
  633. lng2:this.mendianMs.latitude
  634. },r=>{
  635. console.log('直线运费');
  636. console.log(r);
  637. if(r.data.code!=200){
  638. return;
  639. }
  640. that.psf = parseInt(r.data.data.freight);
  641. if(that.psf>0){
  642. }
  643. else{
  644. that.psf=0;
  645. }
  646. that.freight = that.psf;
  647. that.jvli = r.data.data.jvli;
  648. that.isGetyunfei=true;
  649. console.log('直线运费');
  650. if(this.showAdrr==0){
  651. that.jisuanjiner();
  652. }
  653. },failc=>{
  654. //console.log('getadvertis----',failc)
  655. })
  656. },
  657. getjuliForyunfei(lat,lng){//前端
  658. var data={
  659. "origin":{
  660. "location":{
  661. "latLng":{
  662. "latitude":lat,
  663. "longitude":lng
  664. }
  665. }
  666. },
  667. "destination":{
  668. "location":{
  669. "latLng":{
  670. "latitude":this.mendianMs.latitude,
  671. "longitude":this.mendianMs.longitude
  672. }
  673. }
  674. },
  675. "travelMode": "DRIVE",
  676. "units": "METRIC"//米
  677. };
  678. console.log(data);
  679. api('getdistense',data,r=>{
  680. console.log('getadvertis----',r);
  681. if(r.statusCode==200){
  682. var dist = r.data.routes[0].distanceMeters;
  683. console.log(dist/1000);
  684. this.getyunfeiWithJuli(dist/1000);
  685. console.log('路径运费');
  686. }
  687. else{
  688. this.zhixianyuanfei(lat,lng);
  689. console.log('路径计算距离失败!');
  690. uni.showToast({
  691. title:'计算距离失败!',
  692. icon: 'none',
  693. duration: 3500
  694. })
  695. }
  696. },failc=>{
  697. console.log('getadvertis----',failc)
  698. })
  699. },
  700. getjuliForyunfeiHT(lat,lng){
  701. var that = this;
  702. var latlng1=''+lat+','+lng;
  703. var latlng2=''+this.mendianMs.latitude+','+this.mendianMs.longitude;
  704. // var latlng1='10.715641,106.73932';//''+lat+','+lng;
  705. // var latlng2='10.754999,106.735601';//''+this.mendianMs.latitude+','+this.mendianMs.longitude;
  706. api('getluxianjvli',{
  707. latlng1:latlng1,
  708. latlng2:latlng2,
  709. id:this.userid
  710. },r=>{
  711. console.log('getjuliForyunfeiHT',r);
  712. if(r.data.code==200){
  713. if(r.data.data[0]){
  714. var legs =r.data.data[0].legs;
  715. if(legs[0]){
  716. var juli = legs[0].distance.value;
  717. // uni.showToast({
  718. // title:'通过轨迹计算运费',
  719. // icon: 'none',
  720. // duration: 3500
  721. // })
  722. this.getyunfeiWithJuli(juli/1000);
  723. return;
  724. }
  725. }
  726. }
  727. // uni.showToast({
  728. // title:'直线距离计算运费',
  729. // icon: 'none',
  730. // duration: 3500
  731. // })
  732. this.zhixianyuanfei(lat,lng);
  733. },failc=>{
  734. //console.log('getadvertis----',failc)
  735. })
  736. },
  737. getyunfeiWithJuli(distence){
  738. var that = this;
  739. api('getZuiyyfei',{
  740. quli:JSON.stringify(distence)
  741. },r=>{
  742. console.log(r);
  743. if(r.data.code!=200){
  744. return;
  745. }
  746. that.psf = parseInt(r.data.data.freight);
  747. if(that.psf>0){
  748. }
  749. else{
  750. that.psf=0;
  751. }
  752. that.freight = that.psf;
  753. that.jvli = r.data.data.jvli;
  754. that.isGetyunfei=true;
  755. if(this.showAdrr==0){
  756. that.jisuanjiner();
  757. }
  758. },failc=>{
  759. //console.log('getadvertis----',failc)
  760. })
  761. },
  762. addorder(data){
  763. var that = this;
  764. uni.showLoading({
  765. title:'Loading...',
  766. mask:true
  767. })
  768. console.log('addorder',data);
  769. api('addorder',data,
  770. r=>{
  771. console.log(r);
  772. uni.hideLoading();
  773. if(r.data.code==200){
  774. this.qingkonggouwuche();
  775. this.ddId=data.ddId;
  776. this.rId=r.data.data.id;
  777. this.orderDetl=r.data.data;
  778. if(this.shifoudf==0){
  779. this.actType = 1;
  780. this.actTitle = that.$t('order.quzhifu');
  781. uni.showToast({
  782. title: that.$t('order.xuanzezhif'),
  783. icon: 'none',
  784. duration: 2500
  785. })
  786. }
  787. else{
  788. this.actType = 1;
  789. this.actTitle = that.$t('index.huodaofukan');
  790. //到付订单,直接更新支付状态
  791. this.huodaofukuan();
  792. }
  793. }
  794. else{
  795. uni.showToast({
  796. title: r.data.msg,
  797. icon: 'none',
  798. duration: 2000
  799. })
  800. }
  801. },failc=>{
  802. uni.hideLoading();
  803. //console.log('getadvertis----',failc)
  804. })
  805. },
  806. getVNPay(){
  807. api('setorderuzt',{
  808. id:this.rId,
  809. "collectPayment":0
  810. },res=>{
  811. if(res.data.code!=200){
  812. return;
  813. }
  814. },failc=>{
  815. return;
  816. })
  817. this.zffsS=false;
  818. var language = uni.getStorageSync('language');
  819. var lg;
  820. if(language=='yuenan'){
  821. lg='vi';
  822. }
  823. else{
  824. lg='en';
  825. }
  826. uni.showLoading({
  827. title:'Loading...',
  828. mask:true
  829. })
  830. api('VNPay',{
  831. orderid:this.ddId,
  832. amount:parseInt(this.zje),
  833. language:lg
  834. },r=>{
  835. uni.hideLoading();
  836. if(r.data.code!=200){
  837. uni.showToast({
  838. title: r.data.msg,
  839. icon: 'none',
  840. duration: 3500
  841. })
  842. return;
  843. }
  844. this.shifouzhifu=true;
  845. this.zhifuUrl='/pages/OrderList/buy/Zhifuyemian?url='+ encodeURIComponent(JSON.stringify(r.data.data))+'&ddid='+this.ddId;
  846. uni.navigateTo({
  847. url:'/pages/OrderList/buy/Zhifuyemian?url='+ encodeURIComponent(JSON.stringify(r.data.data))+'&ddid='+this.ddId
  848. })
  849. },failc=>{
  850. uni.hideLoading();
  851. //console.log('getadvertis----',failc)
  852. })
  853. },
  854. huodaofukuan(){
  855. this.shifoudf=1;
  856. this.zffsS=false;
  857. uni.showLoading({
  858. title:'Loading...',
  859. mask:true
  860. })
  861. var that = this;
  862. api('setorderuzt',{
  863. id:this.rId,
  864. "collectPayment":this.shifoudf
  865. },res=>{
  866. console.log('setorderuzt:',res)
  867. uni.hideLoading();
  868. if(res.data.code==200){
  869. this.actType = 2;
  870. this.actTitle = that.$t('order.yizhifu');
  871. uni.redirectTo({
  872. url:'/pages/OrderList/OrderDetail?ddid='+this.ddId+'&isShangjia=0'
  873. })
  874. }
  875. else{
  876. if(res.data.msg){
  877. uni.showToast({
  878. title: res.data.msg,
  879. icon: 'none',
  880. duration: 2000
  881. })
  882. }
  883. }
  884. },failc=>{
  885. uni.hideLoading();
  886. //console.log('getadvertis----',failc)
  887. })
  888. },
  889. setorderuzt(){
  890. var that = this;
  891. api('setorderuzt',{
  892. id:this.rId,
  893. state:1
  894. },res=>{
  895. this.actType = 2;
  896. this.actTitle = that.$t('order.yizhifu');
  897. uni.redirectTo({
  898. url:'/pages/OrderList/OrderDetail?ddid='+this.ddId+'&isShangjia=0'
  899. })
  900. },failc=>{
  901. //console.log('getadvertis----',failc)
  902. })
  903. },
  904. getorderDetl(){
  905. var that = this;
  906. api('getorderxq',{
  907. ddid:this.ddId
  908. },r=>{
  909. this.orderDetl=r.data.data;
  910. if(this.orderDetl.state==1){
  911. that.actType = 2;
  912. that.actTitle = that.$t('order.yizhifu');
  913. uni.redirectTo({
  914. url:'/pages/OrderList/OrderDetail?ddid='+this.ddId+'&isShangjia=0'
  915. })
  916. }
  917. },failc=>{
  918. //console.log('getadvertis----',failc)
  919. })
  920. },
  921. qingkonggouwuche(){
  922. uni.setStorageSync('gouwuche','');
  923. return;
  924. },
  925. pushMsg(cid,orderId){//消息推送
  926. api('pushMsgSJ',{
  927. cid:cid,
  928. title:'您有新订单了',
  929. content:orderId,
  930. payload:''
  931. },res=>{
  932. console.log(res)
  933. },failc=>{
  934. //console.log('getadvertis----',failc)
  935. })
  936. },
  937. selectImage(){
  938. console.log('selectImage');
  939. this.$refs.yhdslCropper.chooseImage();
  940. },
  941. uploadImg(e) {
  942. console.log('------------uploadImg:',e)
  943. this.spImage = e;
  944. var that = this;
  945. uni.uploadFile({
  946. url: this.$upImagurl, //上传图片api
  947. filePath: e,
  948. name: 'file',
  949. header:{
  950. //"Authorization": userinfo.token
  951. },
  952. success: (res) => {
  953. let group = JSON.parse(res.data);
  954. that.mpImage=group.data;
  955. console.log(group)
  956. api('ADDaddress',{
  957. id:that.dizhiID.id,
  958. annexes:that.mpImage
  959. },
  960. res=>{
  961. if(res.data.code==200){
  962. that.dizhiID.annexes=that.mpImage;
  963. uni.setStorageSync("peisongdizhi",that.dizhiID);
  964. }
  965. console.log('getGoodsDetail:',res);
  966. },failc=>{
  967. //console.log('getadvertis----',failc)
  968. })
  969. uni.showToast({
  970. title:that.$t('mend.shangccg'),
  971. icon:"success"
  972. })
  973. }
  974. });
  975. },
  976. }
  977. }
  978. </script>
  979. <style lang="scss">
  980. page{
  981. background-color: #F2F3F7;
  982. }
  983. .contentV{
  984. width:100%;
  985. position: relative;
  986. }
  987. .linesp{
  988. width:100%;
  989. height: 8rpx;
  990. background-color: aliceblue;
  991. }
  992. .pinglun{
  993. margin: 16rpx;
  994. padding: 10rpx;
  995. width:92%;
  996. height: 100rpx;
  997. border-radius: 15rpx;
  998. border: 2rpx solid lightgray;
  999. }
  1000. .ctinrow{
  1001. margin-top: 20rpx;
  1002. width:100%;
  1003. height: 80rpx;
  1004. display: flex;
  1005. flex-direction: row;
  1006. align-items: center;
  1007. justify-content: center;
  1008. }
  1009. .delbtct{
  1010. margin-left: 10%;
  1011. margin-top: 20rpx;
  1012. padding-bottom: 30rpx;
  1013. width:80%;
  1014. }
  1015. .delbt{
  1016. text-align: center;
  1017. font-size: 36rpx;
  1018. width:100%;
  1019. height: 80rpx;
  1020. line-height: 80rpx;
  1021. color: white;
  1022. background-color: goldenrod;
  1023. border-radius: 10rpx;
  1024. }
  1025. .topSwichV{
  1026. height: 70rpx;
  1027. width: 280rpx;
  1028. border-radius: 35rpx;
  1029. display: flex;
  1030. flex-direction: row;
  1031. align-items: center;
  1032. justify-content: center;
  1033. }
  1034. .topSwichVL{
  1035. margin-left: -40rpx;
  1036. height: 70rpx;
  1037. width: 200rpx;
  1038. border-radius: 35rpx;
  1039. display: flex;
  1040. flex-direction: row;
  1041. align-items: center;
  1042. justify-content: center;
  1043. }
  1044. .toppz{
  1045. width: 50rpx;
  1046. }
  1047. .toppztext{
  1048. font-size: 30rpx;
  1049. }
  1050. .spnodetail{
  1051. display: flex;
  1052. flex-direction: row;
  1053. align-items: center;
  1054. background-color: white;
  1055. margin-top: 20rpx;
  1056. margin-bottom: 20rpx;
  1057. }
  1058. .spIcon{
  1059. margin: 20rpx;
  1060. width: 90rpx;
  1061. height: 90rpx;
  1062. }
  1063. .xiaoji{
  1064. margin-left: auto;
  1065. margin-right: 30rpx;
  1066. }
  1067. .actBTV{
  1068. width: 100%;
  1069. display: flex;
  1070. flex-direction: row;
  1071. justify-content:space-between;
  1072. align-items: center;
  1073. }
  1074. .viewinrow{
  1075. display: flex;
  1076. flex-direction: row;
  1077. align-items: center;
  1078. width: 100%;
  1079. }
  1080. .kouweisku{
  1081. padding-right: 10rpx;
  1082. color: chocolate;
  1083. font-size: 26rpx;
  1084. }
  1085. .shifdf{
  1086. height: 90rpx;
  1087. width: 90%;
  1088. margin-left: 5%;
  1089. align-items: center;
  1090. }
  1091. .shifdftext{
  1092. margin-left: 30rpx;
  1093. font-size: 30rpx;
  1094. }
  1095. .picker-view {
  1096. width: 750rpx;
  1097. height: 300rpx;
  1098. margin-top: 10rpx;
  1099. }
  1100. .item {
  1101. line-height: 100rpx;
  1102. text-align: center;
  1103. }
  1104. .zhifbut{
  1105. text-align:center;
  1106. margin-top: 12rpx;
  1107. margin-bottom: 12rpx;
  1108. width: 80%;
  1109. border-radius: 10rpx;
  1110. color: white;
  1111. line-height: 70rpx;
  1112. }
  1113. .imageRJ{
  1114. width: 40rpx;
  1115. height: 40rpx;
  1116. margin-right: 8rpx;
  1117. }
  1118. .imageR{
  1119. width: 40rpx;
  1120. height: 40rpx;
  1121. margin-right: 30rpx;
  1122. }
  1123. .textR{
  1124. font-size: 26rpx;
  1125. margin-left: 6rpx;
  1126. margin-right: 6rpx;
  1127. }
  1128. </style>