confirmOrder.vue 34 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246
  1. <template>
  2. <view class="pages">
  3. <!-- 地址 -->
  4. <view class="text-center text-red" v-if="isTrue && orderType == 2">超出配送距离</view>
  5. <view class="food">
  6. <view class="flex bg justify-between padding-lr-xl">
  7. <view @click="switchTab(2)" :class="orderType == 2 ? 'select' : ''" class="tabBtn"
  8. v-if="XCXIsSelect == '是'">
  9. <view class="title">外卖配送</view>
  10. <view :class="orderType == 2 ? 'active' : ''"></view>
  11. </view>
  12. <view @click="switchTab(1)" :class="orderType == 1 ? 'select' : ''" class="tabBtn">
  13. <view class="title">到店自取</view>
  14. <view :class="orderType == 1 ? 'active' : ''"></view>
  15. </view>
  16. </view>
  17. <view v-if="orderType == 1">
  18. <!-- <view class="text-black text-lg margin-top">商家地址</view> -->
  19. <view class="flex margin-top" style="">
  20. <u-icon name="map" size="50"></u-icon>
  21. <view class="flex-sub padding-tb-sm margin-left-sm">
  22. <view class="text-lg text-bold text-black">
  23. <text>{{ dataList.shopName }}</text>
  24. <text class="margin-left-sm" @click="call">{{ dataList.shopPhone }}</text>
  25. </view>
  26. <view class="text-df margin-top-xs" style="color: #999999;" @click="goMap">
  27. {{ dataList.detailedAddress }}
  28. </view>
  29. </view>
  30. </view>
  31. </view>
  32. <view class="" v-if="orderType == 2">
  33. <view class="goods_address" v-if="JSON.stringify(address) == '{}'" @click="goAddress">
  34. <view class="address_box">
  35. <view class="address_name">请选择收货地址</view>
  36. <view class="address_image margin-left">
  37. <image src="../../../static/images/index/right.png"></image>
  38. </view>
  39. </view>
  40. </view>
  41. <view class="flex margin-top" style="" v-else @click="goAddress">
  42. <u-icon name="map" size="50"></u-icon>
  43. <view class="flex-sub padding-tb-sm margin-left-sm">
  44. <view class="text-lg text-bold text-black">
  45. <text>{{ address.userName }}</text>
  46. <text class="margin-left-sm">{{ address.userPhone }}</text>
  47. </view>
  48. <view class="text-df margin-top-xs" style="color: #999999;">
  49. {{ address.province }}{{ address.city }}{{ address.district }}{{ address.addressDetail }}
  50. </view>
  51. </view>
  52. <view class="address_image margin-left">
  53. <image src="../../../static/images/index/right.png"></image>
  54. </view>
  55. </view>
  56. </view>
  57. </view>
  58. <!-- 商品 -->
  59. <view class="food">
  60. <view class="tosend_header_food" v-for="(item, index) in goodsList" :key="index">
  61. <view class="tosend_header_food_le">
  62. <image :src="item.goodsPicture[0]" style="border-radius: 10rpx;" mode=""></image>
  63. </view>
  64. <view class="flex-sub margin-left-sm">
  65. <view class="flex justify-between align-center">
  66. <view class="text-lg text-bold text-black">{{ item.goodsName }}</view>
  67. <view class="text-lg text-bold text-black">
  68. <text class="text-sm">¥</text>
  69. {{ item.goodsPrice }}
  70. </view>
  71. </view>
  72. <view class="flex justify-between align-center text-gray">
  73. <view v-if="item.skuMessage">{{ item.skuMessage }}</view>
  74. <view>x{{ item.goodsNum }}</view>
  75. </view>
  76. <view class="flex justify-between align-center text-gray margin-tb-sm">
  77. <view>打包费</view>
  78. <view class="">¥{{ item.goodsPack }} / 份</view>
  79. </view>
  80. </view>
  81. </view>
  82. <!-- <view class="tosend_header_do do_top" v-if="item.goodsPack>0" >
  83. <view>打包费</view>
  84. <view class="tosend_header_do_ri">¥{{item.goodsPack}}</view>
  85. </view> -->
  86. <view class="tosend_header_do justify-between" v-if="paotuiMoney > 0 && orderType == 2">
  87. <view>跑腿费</view>
  88. <view class="tosend_header_do_ri">¥{{ paotuiMoney }}</view>
  89. </view>
  90. <view class="tosend_header_do justify-between do_bot" @click="isShow">
  91. <view>优惠券</view>
  92. <view class="tosend_header_do_ri" v-if="coupon">- ¥{{ coupon.money }}</view>
  93. <view v-else>
  94. <image src="../../../static/images/order/right1.png" style="width: 14rpx;height: 24rpx;" mode="">
  95. </image>
  96. </view>
  97. </view>
  98. <view class="tosend_header_do justify-between do_bot" @click="huodongShow">
  99. <view>优惠活动</view>
  100. <view class="tosend_header_do_ri" v-if="coupon">- ¥{{ coupon.money }}</view>
  101. <view v-else>
  102. <image src="../../../static/images/order/right1.png" style="width: 14rpx;height: 24rpx;" mode="">
  103. </image>
  104. </view>
  105. </view>
  106. <view class="tosend_header_do justify-between">
  107. <view class="tosend_header_do_le2">合计</view>
  108. <view class="tosend_header_do_ri2">
  109. <text>¥</text>
  110. {{ totalPrice1 }}
  111. </view>
  112. </view>
  113. </view>
  114. <!-- 订单备注 -->
  115. <view class="food">
  116. <view class="padding-tb-sm text-lg text-bold text-bold text-black">订单备注</view>
  117. <view class="flex align-center justify-between padding-tb-sm padding-lr"
  118. style="background: #f5f5f5;width: 100%;">
  119. <u-input v-model="remark" type="textarea" placeholder="请输入订单备注" height="180" maxlength="200"
  120. style="width: 100%;"></u-input>
  121. </view>
  122. </view>
  123. <!-- 支付方式 -->
  124. <view class="food">
  125. <view class="padding-tb-sm text-lg text-bold text-bold text-black">支付方式</view>
  126. <view style="height: 100upx;" v-for="(item, index) in openLists" :key="index">
  127. <view class="flex align-center justify-between padding-tb" v-if="item.text != '零钱'">
  128. <image :src="item.image" style="width: 55rpx;height: 55rpx;border-radius: 50upx;"></image>
  129. <view class="flex-sub text-xl margin-left">{{ item.text }}</view>
  130. <radio-group name="openWay" style="margin-left: 20upx;" @change="selectWay(item)">
  131. <label class="tui-radio">
  132. <radio class="red" :checked="openWay === item.id ? true : false" />
  133. </label>
  134. </radio-group>
  135. </view>
  136. <view class="flex align-center justify-between padding-tb" v-if="item.text === '零钱'">
  137. <image :src="item.image" style="width: 55rpx;height: 55rpx;border-radius: 50upx;"></image>
  138. <view class="flex-sub text-xl margin-left">{{ item.text }} <text
  139. style="font-size: 30rpx;margin-left: 10rpx;"
  140. v-if="userMoney && userMoney > 0">(余额:{{userMoney}})</text>
  141. <!-- <text v-else
  142. style="font-size: 30rpx;margin-left: 10rpx;text-decoration:underline;color: #ea0000;"
  143. @tap="goCash()">去充值</text> -->
  144. </view>
  145. <radio-group name="openWay" style="margin-left: 20upx;" @change="selectWay(item)">
  146. <label class="tui-radio">
  147. <radio class="red" :checked="openWay === item.id ? true : false" />
  148. </label>
  149. </radio-group>
  150. </view>
  151. </view>
  152. </view>
  153. <view style="height: 120rpx;"></view>
  154. <!-- 结算 -->
  155. <view class="goorder">
  156. <!-- <view class="goorder_but" @click="toSettlement">立即结算</view> -->
  157. <view class="goorder_but" :class="isTrue && orderType == 2 ? 'goorder_but_' : ''" @click="toSettlement">立即结算
  158. </view>
  159. </view>
  160. <view class="hintPopul" v-if="shopDet && shopDet.putawayFlag == 1">
  161. <view class="content_">
  162. <image src="../../../static/images/index/shop.png" style="width: 200rpx;height: 180rpx;"></image>
  163. <view class="text-xl text-bold">店铺打烊啦</view>
  164. <view class="hintText margin-top-sm text-gray">现在店铺已经打烊了,营业时间</view>
  165. <view class="margin-top-xs text-gray margin-bottom">{{ shopDet.businessHours }}-{{ shopDet.lockHours }}
  166. </view>
  167. <view class="Btns" @click="goBack()">知道了</view>
  168. </view>
  169. </view>
  170. <u-popup v-model="show" mode="center" :closeable="true" close-icon-pos="top-right" close-icon="close-circle"
  171. close-icon-size="50" border-radius="20" width="80%" @close="close">
  172. <view class="padding bg-gray">
  173. <view class="text-center text-lg text-bold margin-bottom-sm">可用优惠券</view>
  174. <scroll-view scroll-y="true" style="height: 600rpx;" v-if="couponList.length > 0">
  175. <view class="flex justify-between align-center radius margin-tb-sm padding-sm bg-white"
  176. v-for="(item, index) in couponList" :key="index" @click="selCoupon(item)">
  177. <view>
  178. <view>{{ item.couponName }}</view>
  179. <view>有效期至{{ item.expirationTime }}</view>
  180. </view>
  181. <view class="text-sm text-bold">
  182. ¥
  183. <text class="text-lg">{{ item.money }}</text>
  184. </view>
  185. </view>
  186. </scroll-view>
  187. <view v-if="couponList.length == 0"
  188. style="height: 100rpx;line-height: 100rpx;text-align: center;font-weight: 700;">暂无可用优惠券</view>
  189. </view>
  190. </u-popup>
  191. <!-- 选择优惠活动 -->
  192. <u-popup v-model="youhui" mode="center" :closeable="true" close-icon-pos="top-right" close-icon="close-circle"
  193. close-icon-size="50" border-radius="20" width="80%" @close="closeYouhui()">
  194. <view class="padding bg-gray">
  195. <view class="text-center text-lg text-bold margin-bottom-sm">可用优惠活动</view>
  196. <scroll-view scroll-y="true" style="height: 600rpx;" v-if="huoList.length > 0">
  197. <view class="flex justify-between align-center radius margin-tb-sm padding-sm bg-white"
  198. v-for="(item, index) in huoList" :key="index">
  199. <view>
  200. <view>{{ item.activityTitle }}</view>
  201. <view>有效期至{{ item.activityEndTime }}</view>
  202. </view>
  203. <!-- <view class="text-sm text-bold">
  204. ¥
  205. <text class="text-lg" v-if="item.activityType=='2'">{{ item.money }}</text>
  206. <text class="text-lg" v-if="item.activityType=='2'">{{ item.money }}</text>
  207. <text class="text-lg" v-if="item.activityType=='4'">全场打{{ item.discountAmount }}折</text>
  208. </view> -->
  209. </view>
  210. </scroll-view>
  211. <view v-if="huoList.length == 0"
  212. style="height: 100rpx;line-height: 100rpx;text-align: center;font-weight: 700;">暂无可用优惠活动</view>
  213. </view>
  214. </u-popup>
  215. </view>
  216. </template>
  217. <script>
  218. export default {
  219. data() {
  220. return {
  221. userMoney: 0,
  222. shopDet: '',
  223. isThrottle: true, //防抖,待支付结果返回后继续
  224. storeCommodityId: 0,
  225. openLists: [],
  226. openWay: 2,
  227. orderId: '',
  228. page: 1,
  229. limit: 100,
  230. dataList: [],
  231. packMoney: 0, //打包费
  232. totalPrice: 0,
  233. totalPrice1: 0,
  234. address: {}, //地址
  235. addressId: '',
  236. parentId: '',
  237. shopId: '',
  238. show: false,
  239. youhui:false,//优惠活动
  240. coupon: '',//选择的优惠券信息
  241. couponList: [],
  242. huoList:[],//可用活动
  243. orderType: 2,
  244. paotuiMoney: 0,
  245. dabaoMoney: 0,
  246. goodsMoney: null,
  247. distance: 0,
  248. isTrue: false,
  249. goodsList: [],
  250. XCXIsSelect: '是',
  251. remark: '',
  252. GoodsorderId: '',
  253. ifPaotui:0,//是否满减
  254. lng:'',
  255. lat:''
  256. };
  257. },
  258. onLoad(option) {
  259. // #ifdef APP
  260. this.openLists = [{
  261. image: '../../../static/images/my/weixin.png',
  262. text: '微信',
  263. id: 2
  264. },
  265. {
  266. image: '../../../static/images/my/zhifubao.png',
  267. text: '支付宝',
  268. id: 3
  269. },
  270. {
  271. image: '../../../static/images/my/jinbi.png',
  272. text: '零钱',
  273. id: 1
  274. }
  275. ];
  276. // #endif
  277. // #ifdef MP-WEIXIN
  278. this.XCXIsSelect = this.$queue.getData('XCXIsSelect') ? this.$queue.getData('XCXIsSelect') : '是';
  279. this.openLists = [{
  280. image: '../../../static/images/my/weixin.png',
  281. text: '微信',
  282. id: 2
  283. },
  284. {
  285. image: '../../../static/images/my/jinbi.png',
  286. text: '零钱',
  287. id: 1
  288. }
  289. ];
  290. // #endif
  291. // #ifdef H5
  292. this.openLists = [{
  293. image: '../../../static/images/my/weixin.png',
  294. text: '微信',
  295. id: 2
  296. },
  297. {
  298. image: '../../../static/images/my/zhifubao.png',
  299. text: '支付宝',
  300. id: 3
  301. },
  302. {
  303. image: '../../../static/images/my/jinbi.png',
  304. text: '零钱',
  305. id: 1
  306. }
  307. ];
  308. // #endif
  309. this.shopId = option.shopId;
  310. // #ifndef H5
  311. uni.getLocation({
  312. type: 'gcj02', //返回可以用于uni.openLocation的经纬度
  313. success: function(res) {
  314. this.lat = res.latitude;
  315. this.lng = res.longitude;
  316. }
  317. });
  318. this.getShopDet(this.shopId);
  319. // #endif
  320. // #ifdef H5
  321. uni.getLocation({
  322. type: 'gcj02', //返回可以用于uni.openLocation的经纬度
  323. success: function(res) {
  324. this.lat = res.latitude;
  325. this.lng = res.longitude;
  326. }
  327. });
  328. this.getShopDet(this.shopId);
  329. // #endif
  330. this.orderType = option.orderType;
  331. if (option.orderId) {
  332. this.orderId = option.orderId;
  333. }
  334. uni.showLoading({
  335. title: '加载中...'
  336. });
  337. // this.getOrderList();
  338. this.getAddressList();
  339. },
  340. onShow() {
  341. this.getMsgData();
  342. console.log(uni.getStorageSync('addressId'), '地址id');
  343. this.addressId = this.addressId ? this.addressId : uni.getStorageSync('addressId');
  344. if (this.addressId) {
  345. console.log(this.addressId, '地址id');
  346. this.address = {};
  347. this.getAddressDet(this.addressId);
  348. }
  349. },
  350. methods: {
  351. goCash() {
  352. uni.navigateTo({
  353. url: '/my/wallet/index'
  354. });
  355. },
  356. getMsgData() {
  357. this.$Request.get("/app/userintegral/findUserMessage").then(res => {
  358. if (res.code == 0 && res.data) {
  359. this.userMoney = res.data.userMoney ? res.data.userMoney : 0;
  360. }
  361. });
  362. },
  363. //获取店铺详情
  364. getShopDet(shopId) {
  365. let data = {
  366. shopId,
  367. lng: this.lng,
  368. lat: this.lat
  369. };
  370. this.$Request.get('/app/goods/selectGoodsList', data).then(res => {
  371. if (res.code == 0 && res.data) {
  372. this.shopDet = res.data.goodsShop;
  373. this.ifPaotui=res.data.goodsShop.enableFullReductionFlag
  374. this.getOrderList();
  375. }
  376. });
  377. },
  378. goBack() {
  379. uni.navigateBack({});
  380. },
  381. isShow() {
  382. this.show = true;
  383. },
  384. //选择优惠活动弹框
  385. huodongShow(){
  386. this.youhui=true
  387. },
  388. getDistance() {
  389. if (this.address.lng && this.dataList.shopLng) {
  390. let data = {
  391. ol: this.address.lng,
  392. od: this.address.lat,
  393. dl: this.dataList.shopLng,
  394. dd: this.dataList.shopLat
  395. };
  396. this.$Request.post('/app/tbindent/distance', data).then(res => {
  397. if (res.code == 0) {
  398. this.distance = res.data;
  399. if (this.distance > Number(this.dataList.distributionDistance)) {
  400. this.isTrue = true;
  401. } else {
  402. this.isTrue = false;
  403. }
  404. }
  405. });
  406. }
  407. },
  408. close() {
  409. this.show = false;
  410. },
  411. closeYouhui() {
  412. this.youhui = false;
  413. },
  414. switchTab(e) {
  415. this.orderType = e;
  416. this.coupon = '';
  417. if (JSON.stringify(this.address) != '{}') {
  418. this.getDistance();
  419. }
  420. if (this.orderType == 2) {
  421. this.totalPrice1 = parseFloat(parseFloat(this.totalPrice) + parseFloat(this.paotuiMoney) + parseFloat(
  422. this.dabaoMoney)).toFixed(2);
  423. } else {
  424. this.totalPrice1 = parseFloat(parseFloat(this.totalPrice) + parseFloat(this.dabaoMoney)).toFixed(2);
  425. }
  426. if (this.coupon) {
  427. let totalMoney = parseFloat(parseFloat(this.totalPrice1) - (parseFloat(this.coupon.money) ? parseFloat(
  428. this.coupon.money) : 0)).toFixed(2);
  429. if (totalMoney <= 0) {
  430. this.totalPrice1 = 0.01;
  431. } else {
  432. this.totalPrice1 = totalMoney;
  433. }
  434. }
  435. },
  436. // 删除优惠券
  437. detCoupon() {
  438. let data = {
  439. orderId: this.dataList.orderId
  440. };
  441. this.$Request.post('/app/order/deleteCouponByOrderId', data).then(res => {
  442. if (res.code == 0) {}
  443. });
  444. },
  445. // 选择优惠券
  446. selCoupon(item) {
  447. this.coupon = item;
  448. if (this.orderType == 2) {
  449. this.totalPrice1 = parseFloat(this.totalPrice + this.paotuiMoney + this.dabaoMoney).toFixed(2);
  450. } else {
  451. this.totalPrice1 = parseFloat(this.totalPrice + this.dabaoMoney).toFixed(2);
  452. }
  453. let totalMoney = parseFloat(this.totalPrice1 - (this.coupon.money ? this.coupon.money : 0)).toFixed(2);
  454. if (totalMoney <= 0) {
  455. this.totalPrice1 = 0.01;
  456. } else {
  457. this.totalPrice1 = totalMoney;
  458. }
  459. let data = {
  460. parentId: this.dataList.parentId,
  461. couponId: this.coupon ? this.coupon.id : ''
  462. };
  463. this.$Request.post('/app/order/employCoupon', data).then(res => {
  464. if (res.code == 0) {
  465. this.show = false;
  466. }
  467. });
  468. },
  469. // 优惠卷列表
  470. getCouponList() {
  471. // console.log(this.paotuiMoney)
  472. // console.log(this.dabaoMoney, '123123')
  473. let minMoney =
  474. this.orderType == 2 ?
  475. parseFloat(parseFloat(this.totalPrice) + parseFloat(this.paotuiMoney) + parseFloat(this.dabaoMoney))
  476. .toFixed(2) :
  477. parseFloat(this.totalPrice).toFixed(2);
  478. let data = {
  479. shopId: this.dataList.shopId,
  480. page: 1,
  481. limit: 10,
  482. minMoney: minMoney
  483. };
  484. this.$Request.get('/app/coupon/selectUserCouponList', data).then(res => {
  485. if (res.code == 0) {
  486. this.couponList = res.data.list;
  487. }
  488. });
  489. },
  490. // 优惠活动列表
  491. getHuoList(){
  492. let data = {
  493. orderId: this.dataList.orderId,
  494. };
  495. this.$Request.get(`/app/activity/suit-activity/${this.dataList.orderId}`, data).then(res => {
  496. if (res.code == 0) {
  497. this.huoList = res.data;
  498. }
  499. });
  500. },
  501. //拼单支付成功取消订单
  502. cancelPinDan() {
  503. let that = this;
  504. // if (that.orderId) {
  505. // let data = {
  506. // orderId: that.orderId
  507. // };
  508. // that.$Request.post('/app/order/deleteOrder', data).then(res => {
  509. // if (res.code == 0) {
  510. // uni.removeStorageSync('orderId');
  511. // }
  512. // });
  513. // }
  514. },
  515. // 商品列表
  516. getOrderList() {
  517. let data = {
  518. shopId: this.shopId,
  519. status: 1,
  520. page: 1,
  521. limit: 1000
  522. // orderType: this.orderType
  523. };
  524. this.$Request.get('/app/order/selectAllOrderList', data).then(res => {
  525. uni.hideLoading();
  526. if (res.code == 0 && res.data.pageUtils.list) {
  527. this.GoodsorderId = res.data.pageUtils.list[0].orderId;
  528. this.dataList = res.data.pageUtils.list[0];
  529. if (this.dataList && this.dataList.orderGoodsList && this.dataList.orderGoodsList[0]) {
  530. this.dataList.orderGoodsList[0].forEach(res => {
  531. res.goodsPicture = res.goodsPicture.split(',');
  532. this.dabaoMoney += res.goodsPack * res.goodsNum;
  533. this.goodsMoney += res.goodsPrice * res.goodsNum;
  534. this.goodsMoney = parseFloat(this.goodsMoney + this.dabaoMoney);
  535. });
  536. this.goodsList = this.dataList.orderGoodsList[0];
  537. }
  538. // this.paotuiMoney = this.dataList.errandMoney
  539. if(this.ifPaotui==1){
  540. this.paotuiMoney = this.dataList.errandMoney;
  541. }else if(this.ifPaotui==0){
  542. // 判断商品金额是否大于最低减免配送费金额
  543. console.log(this.goodsMoney, '商品总金额', res,this.dataList.exemptMinMoney)
  544. if (Number(this.goodsMoney) >= Number(this.dataList.exemptMinMoney)) {
  545. this.paotuiMoney = 0;
  546. } else {
  547. this.paotuiMoney = this.dataList.errandMoney;
  548. }
  549. }
  550. this.totalPrice = res.data.money;
  551. if (this.orderType == 2) {
  552. this.totalPrice1 = parseFloat(parseFloat(this.totalPrice) + parseFloat(this
  553. .paotuiMoney) + parseFloat(this.dabaoMoney)).toFixed(2);
  554. } else {
  555. this.totalPrice1 = parseFloat(parseFloat(this.totalPrice) + parseFloat(this
  556. .dabaoMoney)).toFixed(2);
  557. }
  558. // console.log(this.dataList)
  559. this.getCouponList();
  560. this.getHuoList();
  561. this.detCoupon();
  562. this.getDistance();
  563. }
  564. });
  565. },
  566. selectWay(item) {
  567. this.openWay = item.id;
  568. },
  569. takeReark() {
  570. let datas = {
  571. orderId: this.GoodsorderId,
  572. remark: this.remark
  573. };
  574. this.$Request.post('/app/order/updateOrdersRemark', datas).then(res => {
  575. if (res.code == 0) {} else {
  576. uni.showToast({
  577. title: res.msg,
  578. icon: 'none'
  579. });
  580. }
  581. });
  582. },
  583. // 立即结算
  584. toSettlement() {
  585. if (this.isThrottle == false) {
  586. return
  587. }
  588. let that = this;
  589. if (this.isTrue && this.orderType == 2) {
  590. uni.showToast({
  591. title: '超出配送范围',
  592. icon: 'none'
  593. });
  594. reutrn;
  595. }
  596. if (this.orderType == 2 && !this.address.addressId) {
  597. uni.showToast({
  598. title: '请选择收货地址',
  599. icon: 'none'
  600. });
  601. return;
  602. }
  603. if (this.remark) {
  604. this.takeReark();
  605. }
  606. uni.showLoading({
  607. title: '支付中...'
  608. });
  609. this.isThrottle = false
  610. if (this.openWay == 1) {
  611. //零钱支付
  612. let data = {
  613. parentId: this.dataList.parentId,
  614. couponId: this.coupon ? this.coupon.id : '',
  615. addressId: this.address.addressId ? this.address.addressId : '',
  616. orderType: this.orderType
  617. };
  618. this.$Request.post('/app/wxPay/balanceOrder', data).then(res => {
  619. if (res.code == 0) {
  620. uni.hideLoading();
  621. that.$queue.showToast('支付成功');
  622. that.cancelPinDan();
  623. setTimeout(function() {
  624. that.isThrottle = true
  625. uni.switchTab({
  626. url: '/pages/order/index'
  627. });
  628. }, 1000);
  629. } else {
  630. that.$queue.showToast(res.msg);
  631. that.isThrottle = true
  632. }
  633. });
  634. } else if (this.openWay == 2) {
  635. //微信支付
  636. // #ifdef H5
  637. let data = {
  638. parentId: this.dataList.parentId,
  639. couponId: this.coupon ? this.coupon.id : '',
  640. addressId: this.address.addressId ? this.address.addressId : '',
  641. orderType: this.orderType,
  642. type: 2
  643. };
  644. this.$Request.post('/app/wxPay/wxPayJsApiOrder', data).then(res => {
  645. uni.hideLoading();
  646. if (res.code == 0) {
  647. this.callPay(res.data);
  648. } else {
  649. uni.showToast({
  650. title: res.msg,
  651. icon: 'none'
  652. });
  653. this.isThrottle = true
  654. }
  655. });
  656. // #endif
  657. // #ifdef MP-WEIXIN
  658. let data = {
  659. parentId: this.dataList.parentId,
  660. couponId: this.coupon ? this.coupon.id : '',
  661. addressId: this.address.addressId ? this.address.addressId : '',
  662. orderType: this.orderType,
  663. type: 3
  664. };
  665. this.$Request.post('/app/wxPay/wxPayJsApiOrder', data).then(res => {
  666. // uni.hideLoading();
  667. if (res.code == 0) {
  668. uni.requestPayment({
  669. provider: 'wxpay',
  670. timeStamp: res.data.timestamp,
  671. nonceStr: res.data.noncestr,
  672. package: res.data.package,
  673. signType: res.data.signType,
  674. paySign: res.data.sign,
  675. success: function(suc) {
  676. that.cancelPinDan();
  677. uni.hideLoading();
  678. that.$queue.showToast('支付成功');
  679. setTimeout(function() {
  680. that.isThrottle = true
  681. uni.switchTab({
  682. url: '/pages/order/index'
  683. });
  684. }, 1000);
  685. },
  686. fail: function(err) {
  687. console.log('fail:' + JSON.stringify(err));
  688. that.isThrottle = true
  689. uni.showToast({
  690. title: '支付失败',
  691. icon: 'none'
  692. });
  693. }
  694. });
  695. } else {
  696. uni.showToast({
  697. title: res.msg,
  698. icon: 'none'
  699. });
  700. that.isThrottle = true
  701. }
  702. });
  703. // #endif
  704. // #ifdef APP
  705. let data = {
  706. type: 1,
  707. parentId: this.dataList.parentId,
  708. couponId: this.coupon ? this.coupon.id : '',
  709. addressId: this.address.addressId ? this.address.addressId : '',
  710. orderType: this.orderType
  711. };
  712. this.$Request.post('/app/wxPay/wxPayJsApiOrder', data).then(res => {
  713. console.log(res);
  714. this.showpay = false;
  715. if (res.code == 0) {
  716. this.isCheckPay(res.code, 'wxpay', JSON.stringify(res.data));
  717. } else {
  718. that.isThrottle = true
  719. }
  720. });
  721. // #endif
  722. } else if (this.openWay == 3) {
  723. // #ifdef H5
  724. let data = {
  725. type: 5,
  726. parentId: this.dataList.parentId,
  727. couponId: this.coupon ? this.coupon.id : '',
  728. addressId: this.address.addressId ? this.address.addressId : '',
  729. orderType: this.orderType
  730. };
  731. this.$Request.post('/app/wxPay/wxPayJsApiOrder', data).then(res => {
  732. this.showpay = false;
  733. this.isThrottle = true
  734. const div = document.createElement('div');
  735. div.innerHTML = res.data; //此处form就是后台返回接收到的数据
  736. document.body.appendChild(div);
  737. document.forms[0].submit();
  738. });
  739. // #endif
  740. // #ifdef APP
  741. let data = {
  742. type: 4,
  743. parentId: this.dataList.parentId,
  744. couponId: this.coupon ? this.coupon.id : '',
  745. addressId: this.address.addressId ? this.address.addressId : '',
  746. orderType: this.orderType
  747. };
  748. this.$Request.post('/app/wxPay/wxPayJsApiOrder', data).then(res => {
  749. this.showpay = false;
  750. this.setPayment('alipay', res.data);
  751. });
  752. // #endif
  753. }
  754. },
  755. callPay: function(response) {
  756. if (typeof WeixinJSBridge === 'undefined') {
  757. if (document.addEventListener) {
  758. document.addEventListener('WeixinJSBridgeReady', this.onBridgeReady(response), false);
  759. } else if (document.attachEvent) {
  760. document.attachEvent('WeixinJSBridgeReady', this.onBridgeReady(response));
  761. document.attachEvent('onWeixinJSBridgeReady', this.onBridgeReady(response));
  762. }
  763. } else {
  764. this.onBridgeReady(response);
  765. }
  766. },
  767. onBridgeReady: function(response) {
  768. let that = this;
  769. if (!response.package) {
  770. return;
  771. }
  772. WeixinJSBridge.invoke(
  773. 'getBrandWCPayRequest', {
  774. appId: response.appid, //公众号名称,由商户传入
  775. timeStamp: response.timestamp, //时间戳,自1970年以来的秒数
  776. nonceStr: response.noncestr, //随机串
  777. package: response.package,
  778. signType: response.signType, //微信签名方式:
  779. paySign: response.sign //微信签名
  780. },
  781. function(res) {
  782. if (res.err_msg === 'get_brand_wcpay_request:ok') {
  783. // 使用以上方式判断前端返回,微信团队郑重提示:
  784. //res.err_msg将在用户支付成功后返回ok,但并不保证它绝对可靠。
  785. that.cancelPinDan();
  786. that.$queue.showToast('支付成功');
  787. setTimeout(function() {
  788. uni.switchTab({
  789. url: '/pages/order/index'
  790. });
  791. that.isThrottle = true
  792. }, 1000);
  793. } else {
  794. uni.hideLoading();
  795. that.isThrottle = true
  796. }
  797. WeixinJSBridge.log(response.err_msg);
  798. }
  799. );
  800. },
  801. isCheckPay(code, name, order) {
  802. if (code == 0) {
  803. console.log('999999999999');
  804. this.setPayment(name, order);
  805. } else {
  806. uni.hideLoading();
  807. uni.showToast({
  808. title: '支付信息有误'
  809. });
  810. this.isThrottle = true
  811. }
  812. },
  813. setPayment(name, order) {
  814. let that = this;
  815. console.log(777777777, name, order);
  816. uni.requestPayment({
  817. provider: name,
  818. orderInfo: order, //微信、支付宝订单数据
  819. success: function(res) {
  820. uni.hideLoading();
  821. that.cancelPinDan();
  822. uni.showLoading({
  823. title: '支付成功',
  824. icon: 'none'
  825. });
  826. setTimeout(function() {
  827. that.isThrottle = true
  828. uni.navigateBack();
  829. }, 1000);
  830. },
  831. fail: function(err) {
  832. uni.hideLoading();
  833. that.isThrottle = true
  834. },
  835. complete() {
  836. that.isThrottle = true
  837. uni.hideLoading();
  838. }
  839. });
  840. },
  841. // 获取选择的地址
  842. getAddressDet(e) {
  843. this.$Request.get('/app/address/selectAddressById?addressId=' + e).then(res => {
  844. if (res.code == 0) {
  845. this.address = res.data;
  846. if (JSON.stringify(this.address) != '{}') {
  847. this.getDistance();
  848. }
  849. uni.removeStorageSync('addressId');
  850. }
  851. });
  852. },
  853. // 获取地址列表
  854. getAddressList() {
  855. let that = this;
  856. let data = {
  857. page: 1,
  858. limit: 100
  859. };
  860. that.$Request.get('/app/address/selectAddressList', data).then(res => {
  861. if (res.code == 0) {
  862. that.address = res.data.list[0] ? res.data.list[0] : {};
  863. res.data.list.forEach(ret => {
  864. if (ret.addressDefault == 1) {
  865. that.address = ret;
  866. }
  867. });
  868. if (JSON.stringify(this.address) != '{}') {
  869. this.getDistance();
  870. }
  871. }
  872. });
  873. },
  874. goAddress() {
  875. uni.navigateTo({
  876. url: '/my/address/index?add=1'
  877. });
  878. },
  879. // 点击调起地图查看位置
  880. goMap() {
  881. // let that = this
  882. // let plugin = requirePlugin('routePlan');
  883. // let key = 'A3RBZ-23MHW-PTPR5-RLCER-UJTXQ-JIF2G'; //使用在腾讯位置服务申请的key
  884. // let referer = that.dataList.shopName; //调用插件的app的名称
  885. // let endPoint = JSON.stringify({ //终点
  886. // 'name': that.dataList.shopName,
  887. // 'latitude': that.dataList.shopLat,
  888. // 'longitude': that.dataList.shopLng,
  889. // });
  890. // wx.navigateTo({
  891. // url: 'plugin://routePlan/index?key=' + key + '&referer=' + referer + '&endPoint=' + endPoint
  892. // });
  893. let that = this;
  894. let lati = parseFloat(that.dataList.shopLat);
  895. let longi = parseFloat(that.dataList.shopLng);
  896. uni.authorize({
  897. scope: 'scope.userLocation',
  898. success(res) {
  899. uni.openLocation({
  900. name: that.dataList.shopName,
  901. latitude: lati,
  902. longitude: longi,
  903. success: function() {}
  904. });
  905. },
  906. fail(err) {}
  907. });
  908. },
  909. // 打电话
  910. call() {
  911. uni.makePhoneCall({
  912. phoneNumber: this.dataList.shopPhone
  913. });
  914. }
  915. }
  916. };
  917. </script>
  918. <style scoped>
  919. .hintPopul {
  920. width: 100%;
  921. height: 100vh;
  922. position: fixed;
  923. top: 0;
  924. background: rgba(0, 0, 0, 0.4);
  925. z-index: 999;
  926. }
  927. .content_ {
  928. position: absolute;
  929. left: 0;
  930. right: 0;
  931. top: 0;
  932. bottom: 0;
  933. margin: auto;
  934. text-align: center;
  935. width: 500rpx;
  936. height: 400rpx;
  937. border-radius: 20rpx;
  938. background-color: #fff;
  939. padding-top: 120rpx;
  940. }
  941. .content_ image {
  942. position: absolute;
  943. top: -50rpx;
  944. left: 0;
  945. right: 0;
  946. margin: auto;
  947. }
  948. .hintText {
  949. font-size: 30rpx;
  950. }
  951. .Btns {
  952. width: 460rpx;
  953. height: 60rpx;
  954. line-height: 60rpx;
  955. text-align: center;
  956. background: #fcd202;
  957. font-size: 28rpx;
  958. border: 2rpx solid #fcd202;
  959. color: #333333;
  960. border-radius: 50rpx;
  961. font-weight: 700;
  962. margin: auto;
  963. }
  964. .goods_address {
  965. width: 94%;
  966. background: #ffffff;
  967. height: 120rpx;
  968. margin: 20rpx auto 0;
  969. border-radius: 18rpx;
  970. }
  971. .address_box {
  972. width: 90%;
  973. margin: 0 auto;
  974. height: 120rpx;
  975. display: flex;
  976. line-height: 120rpx;
  977. }
  978. .address_name {
  979. flex: 1;
  980. font-size: 30rpx;
  981. }
  982. .address_image {
  983. /* flex: 1; */
  984. display: flex;
  985. justify-content: flex-end;
  986. align-items: center;
  987. }
  988. .address_image image {
  989. width: 25rpx;
  990. height: 40rpx;
  991. }
  992. /* 地址 */
  993. .address {
  994. width: 88%;
  995. margin: 3% auto;
  996. padding: 3%;
  997. display: flex;
  998. background-color: #ffffff;
  999. border-radius: 18rpx;
  1000. }
  1001. .adderss_le {
  1002. width: 90%;
  1003. line-height: 1.5;
  1004. }
  1005. .adderss_le_text {
  1006. font-size: 30rpx;
  1007. font-weight: bold;
  1008. color: #333333;
  1009. }
  1010. .adderss_le_text2 {
  1011. font-size: 24rpx;
  1012. font-weight: 500;
  1013. color: #999999;
  1014. display: flex;
  1015. }
  1016. .adderss_le_text2 view {
  1017. margin-left: 2%;
  1018. }
  1019. .adderss_le_text2 view:first-child {
  1020. margin-left: 0;
  1021. }
  1022. .adderss_ri {
  1023. width: 10%;
  1024. text-align: right;
  1025. line-height: 3;
  1026. }
  1027. .adderss_ri image {
  1028. width: 18rpx;
  1029. height: 30rpx;
  1030. }
  1031. /* 商品 */
  1032. .food {
  1033. width: 94%;
  1034. margin: 3% auto;
  1035. padding: 3%;
  1036. background-color: #ffffff;
  1037. border-radius: 18rpx;
  1038. }
  1039. .tosend_header_food {
  1040. width: 100%;
  1041. display: flex;
  1042. margin-top: 3%;
  1043. }
  1044. .tosend_header_food_le {
  1045. width: 15%;
  1046. }
  1047. .tosend_header_food_le image {
  1048. width: 110rpx;
  1049. height: 110rpx;
  1050. border-radius: 10rpx;
  1051. }
  1052. .tosend_header_food_ce {
  1053. margin: 0 0 0 4%;
  1054. width: 57%;
  1055. }
  1056. .tosend_header_food_ri {
  1057. text-align: right;
  1058. width: 25%;
  1059. }
  1060. .tosend_header_food_text {
  1061. font-size: 34rpx;
  1062. font-weight: 500;
  1063. color: #333333;
  1064. line-height: 1.8;
  1065. }
  1066. .tosend_header_food_text text {
  1067. font-size: 25rpx;
  1068. }
  1069. .tosend_header_food_text2 {
  1070. font-size: 28rpx;
  1071. font-weight: 500;
  1072. color: #999999;
  1073. }
  1074. .do_top {
  1075. padding-top: 3%;
  1076. }
  1077. .do_bot {
  1078. padding-bottom: 3%;
  1079. border-bottom: 2rpx solid #e6e6e6;
  1080. }
  1081. .tosend_header_do {
  1082. width: 100%;
  1083. color: #333333;
  1084. font-size: 30rpx;
  1085. display: flex;
  1086. margin-top: 20rpx;
  1087. line-height: 1.5;
  1088. }
  1089. .tosend_header_do view {
  1090. /* flex: 1; */
  1091. }
  1092. .tosend_header_do_ri {
  1093. text-align: right;
  1094. }
  1095. .tosend_header_do_le2 {
  1096. font-family: PingFang SC;
  1097. font-weight: 500;
  1098. color: #999999;
  1099. padding-top: 1.5%;
  1100. }
  1101. .tosend_header_do_ri2 {
  1102. text-align: right;
  1103. color: #ea0000;
  1104. font-size: 40rpx;
  1105. }
  1106. .tosend_header_do_ri2 text {
  1107. font-size: 30rpx;
  1108. }
  1109. /* 支付 */
  1110. /* .payment_all{
  1111. width: 88%;margin: 3% auto;padding: 3%;background-color: #FFFFFF;
  1112. border-radius: 18rpx;
  1113. }
  1114. .payment{
  1115. width: 100%;display: flex;margin-top: 3%;
  1116. }
  1117. .payment_le{
  1118. width: 13%;
  1119. }
  1120. .payment_le image{
  1121. width: 60rpx;height: 60rpx;
  1122. }
  1123. .payment_ce{
  1124. width: 52%;
  1125. font-size: 30rpx;
  1126. font-weight: bold;
  1127. color: #333333;line-height: 60rpx;
  1128. }
  1129. .payment_ri{
  1130. width: 35%;text-align: right;line-height: 60rpx;
  1131. } */
  1132. /* 结算 */
  1133. .goorder {
  1134. width: 100%;
  1135. padding: 2% 3%;
  1136. position: fixed;
  1137. bottom: 0;
  1138. background-color: #ffffff;
  1139. z-index: 999;
  1140. }
  1141. .goorder_but {
  1142. width: 100%;
  1143. line-height: 3.5;
  1144. text-align: center;
  1145. background: #fcd202;
  1146. border-radius: 36rpx;
  1147. font-weight: 700;
  1148. }
  1149. .goorder_but_ {
  1150. opacity: 0.5;
  1151. }
  1152. .bg {
  1153. background-color: #ffffff;
  1154. }
  1155. .tabBtn {
  1156. /* background-color: #f6f6fa; */
  1157. height: 60rpx;
  1158. line-height: 60rpx;
  1159. color: #999999;
  1160. font-size: 38rpx;
  1161. }
  1162. .active {
  1163. /* width: 82rpx; */
  1164. height: 6rpx;
  1165. background: #fcd202;
  1166. /* position: relative;
  1167. top: -20rpx; */
  1168. z-index: 9;
  1169. }
  1170. </style>