confirm-order.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641
  1. <template>
  2. <view class="wrap" v-if="!loading">
  3. <!--tab-->
  4. <view class="top-tabbar" v-if="OrderData.delivery != 30">
  5. <block v-if="hasType(10)">
  6. <view :class="tab_type == 0 ? 'tab-item active' : 'tab-item'" @click="tabFunc(0)">快递配送</view>
  7. </block>
  8. <block v-if="hasType(20)">
  9. <view :class="tab_type == 1 ? 'tab-item active' : 'tab-item'" @click="tabFunc(1)">上门自提</view>
  10. </block>
  11. </view>
  12. <Myinfo v-if="tab_type == 0 && OrderData.delivery != 30" :Address="Address" :exist_address="exist_address"></Myinfo>
  13. <Storeinfo v-if="tab_type == 1 && OrderData.delivery != 30" ref="getShopinfoData" :extract_store="extract_store"
  14. :last_extract="last_extract"></Storeinfo>
  15. <!--购买的产品-->
  16. <view class="vender">
  17. <view class="list">
  18. <view class="item" v-for="(item, index) in ProductData" :key="index">
  19. <view class="d-f">
  20. <view class="cover">
  21. <image :src="item.product_image" mode="aspectFit"></image>
  22. </view>
  23. <view class="info">
  24. <view class="d-b-s">
  25. <view class="flex-1">
  26. <view class="title f32 gray3">{{ item.product_name }}</view>
  27. <view class="describe mt10 f24">{{ item.product_sku.product_attr }}</view>
  28. </view>
  29. <view>
  30. <view class=" count_choose">
  31. <view class="price">
  32. ¥
  33. <text class="num">{{ item.product_price }}</text>
  34. </view>
  35. <view class="num-wrap">
  36. <view class="f22 tr">×{{ item.total_num }}</view>
  37. </view>
  38. </view>
  39. </view>
  40. </view>
  41. </view>
  42. </view>
  43. <view class="mt10 tr f28" v-if="item.is_user_grade==true">
  44. <text class="redF6 f26">会员折扣价:</text>
  45. <text class="redF6 f32">{{item.grade_product_price}}</text>
  46. </view>
  47. </view>
  48. </view>
  49. <!--总数-->
  50. <view class="total-box vthl">
  51. <view>
  52. <text class="f26 gray3">共{{OrderData.order_total_num }}件商品,总价:</text>
  53. <text class="f20 gray3">¥</text>
  54. <text class="f26 gray3">{{ OrderData.order_total_price }}</text>
  55. </view>
  56. <view class="d-f">
  57. <view class="f26" v-if="!OrderData.force_points">
  58. 实付款:<text class="redF6 f20">¥</text><text class="price redF6" style="font-size: 32rpx;">{{toDecimal2(OrderData.order_pay_price)}}</text>
  59. </view>
  60. </view>
  61. </view>
  62. </view>
  63. <!--其它费用-->
  64. <view class="buy-checkout">
  65. <view class="item">
  66. <text class="key f26">订单总金额:</text>
  67. <view>
  68. <text class="redF6 f20">¥</text>
  69. <text class="price f32">{{ OrderData.order_total_price }}</text>
  70. </view>
  71. </view>
  72. <view class="item" v-if="OrderData.is_coupon">
  73. <text class="key">优惠券:</text>
  74. <block v-if="coupon_num > 0">
  75. <view class="vlaue orange" v-if="OrderData.coupon_id > 0" @click="onTogglePopupCoupon(coupon_list)">-¥{{ OrderData.coupon_money }}</view>
  76. <view v-else class="vlaue orange" @click="onTogglePopupCoupon(coupon_list)">有{{ coupon_num }}张优惠券可用<text class="icon iconfont icon-jiantou"></text></view>
  77. </block>
  78. <text v-else class="vlaue">无优惠券可用</text>
  79. </view>
  80. <view class="item">
  81. <text class="key">配送费用:</text>
  82. <view v-if="OrderData.express_price!=0">
  83. <text class="redF6 f20">¥</text>
  84. <text class="price f32">{{ OrderData.express_price }}</text>
  85. </view>
  86. <view v-else>
  87. <text class="">快递 免费</text>
  88. </view>
  89. </view>
  90. <view class="item" v-if="OrderData.reduce">
  91. <text class="key">满减({{ OrderData.reduce.active_name }}):</text>
  92. <view>
  93. <text class="redF6 f20">-¥</text>
  94. <text class="price f32">{{ OrderData.reduce.reduced_price }}</text>
  95. </view>
  96. </view>
  97. <view class="item" v-if="OrderData.is_use_points && OrderData.force_points == false && OrderData.points_money > 0">
  98. <text class="key">可用积分抵扣:</text>
  99. <view class="">
  100. <text class="price">-¥{{ OrderData.points_money }}</text>
  101. <switch :checked="is_use_points" style="transform: scale(0.7); margin-right: -10rpx;" @change="onShowPoints" />
  102. </view>
  103. </view>
  104. </view>
  105. <!--支付方式-->
  106. <view class="buy-checkout" v-if="OrderData.order_pay_price != 0">
  107. <view :class="pay_type == 20 ? 'item active' : 'item'" @click="payTypeFunc(20)">
  108. <view class="d-s-c">
  109. <view class="icon-box d-c-c mr10"><span class="icon iconfont icon-weixin"></span></view>
  110. <text class="key">微信支付:</text>
  111. </view>
  112. <view class="icon-box d-c-c"><span class="icon iconfont icon-xuanze"></span></view>
  113. </view>
  114. <view v-if="showAlipay" :class="pay_type == 30 ? 'item active' : 'item'" @click="payTypeFunc(30)">
  115. <view class="d-s-c">
  116. <view class="icon-box d-c-c mr10"><span class="icon iconfont icon-zhifubao"></span></view>
  117. <text class="key">支付宝支付:</text>
  118. </view>
  119. <view class="icon-box d-c-c"><span class="icon iconfont icon-xuanze"></span></view>
  120. </view>
  121. <view :class="pay_type == 10 ? 'item active' : 'item'" @click="payTypeFunc(10)">
  122. <view class="d-s-c">
  123. <view class="icon-box d-c-c mr10"><span class="icon iconfont icon-yue"></span></view>
  124. <text class="key">余额支付:</text><text class="redF6">{{'(可用余额:'+balance+')'}}</text>
  125. </view>
  126. <view class="icon-box d-c-c"><span class="icon iconfont icon-xuanze"></span></view>
  127. </view>
  128. </view>
  129. <!--买家留言-->
  130. <view class="buyer-message uni-textarea"><textarea class="textarea" v-model="remark" placeholder-style="color:#cccccc;"
  131. placeholder="选项:买家留言" /></view>
  132. <!--底部支付-->
  133. <view class="foot-pay-btns">
  134. <view class="price" v-if="!OrderData.force_points">
  135. ¥
  136. <text class="num">{{ OrderData.order_pay_price }}</text>
  137. </view>
  138. <view class="price" v-if="OrderData.force_points">
  139. <text class="gray9">所需积分</text>
  140. <text class="num red fb">{{ OrderData.points_num }}</text>
  141. <template v-if="OrderData.order_pay_price > 0">
  142. <text>+</text>
  143. ¥
  144. <text class="num fb">{{ OrderData.order_pay_price }}</text>
  145. </template>
  146. </view>
  147. <button type="primary" @click="SubmitOrder">提交订单</button>
  148. </view>
  149. <!--优惠券-->
  150. <Coupon :isCoupon="isCoupon" :couponList="couponList" @close="closeCouponFunc"></Coupon>
  151. </view>
  152. </template>
  153. <script>
  154. import Myinfo from './confirm-order/my-info';
  155. import Storeinfo from './confirm-order/store-info';
  156. import Coupon from './confirm-order/coupon';
  157. import { pay } from '@/common/pay.js';
  158. export default {
  159. components: {
  160. Myinfo,
  161. Storeinfo,
  162. Coupon
  163. },
  164. data() {
  165. return {
  166. /*是否加载完成*/
  167. loading: true,
  168. options: {},
  169. indicatorDots: true,
  170. autoplay: true,
  171. interval: 2000,
  172. duration: 500,
  173. tab_type: 0,
  174. /*商品id*/
  175. product_id: '',
  176. /*商品数量*/
  177. product_num: '',
  178. /*商品数据*/
  179. ProductData: [],
  180. /*订单数据数据*/
  181. OrderData: [],
  182. // 是否存在收货地址
  183. exist_address: false,
  184. /*默认地址*/
  185. Address: {
  186. region: []
  187. },
  188. extract_store: [],
  189. last_extract: {},
  190. product_sku_id: 0,
  191. /*配送方式*/
  192. delivery: 0,
  193. /*自提店id*/
  194. store_id: 0,
  195. /*优惠券id*/
  196. coupon_id: 0,
  197. /*是否使用积分*/
  198. is_use_points: 1,
  199. linkman: '',
  200. phone: '',
  201. remark: '',
  202. /*支付方式*/
  203. pay_type: 20,
  204. /*是否显示优惠券*/
  205. isCoupon: false,
  206. /*优惠券列表*/
  207. coupon_list: {},
  208. couponList: [],
  209. deliverySetting: [],
  210. /*优惠券数量*/
  211. coupon_num: 0,
  212. /*消息模板*/
  213. temlIds: [],
  214. /*是否显示支付宝支付,只有在h5,非微信内打开才显示*/
  215. showAlipay: false,
  216. balance:''
  217. };
  218. },
  219. onLoad(options) {
  220. let self = this;
  221. self.options = options;
  222. self.$fire.on('selectStoreId', function(store_id) {
  223. self.store_id = store_id;
  224. self.extract_store=store_id;
  225. });
  226. self.$fire.on('extract', function(params) {
  227. console.log(params);
  228. self.last_extract = params;
  229. });
  230. },
  231. onShow() {
  232. this.getData();
  233. },
  234. methods: {
  235. /**/
  236. hasType(e) {
  237. if (this.deliverySetting.indexOf(e+"") != -1) {
  238. return true;
  239. } else {
  240. return false;
  241. }
  242. },
  243. /*支付方式选择*/
  244. payTypeFunc(e) {
  245. this.pay_type = e;
  246. },
  247. /*是否使用积分选择*/
  248. onShowPoints: function(e) {
  249. let self = this;
  250. if (e.target.value == true) {
  251. self.is_use_points = 1;
  252. } else {
  253. self.is_use_points = 0;
  254. }
  255. self.getData();
  256. },
  257. /*选择优惠卷*/
  258. onTogglePopupCoupon(e) {
  259. let self = this;
  260. self.isCoupon = true;
  261. self.couponList = e;
  262. },
  263. /*关闭优惠券*/
  264. closeCouponFunc(e) {
  265. let self = this;
  266. self.coupon_id = e;
  267. this.isCoupon = false;
  268. self.getData();
  269. },
  270. /*获取数据*/
  271. getData() {
  272. let self = this;
  273. uni.showLoading({
  274. title: '加载中'
  275. });
  276. let callback = function(res) {
  277. self.OrderData = res.data.orderInfo;
  278. self.temlIds = res.data.template_arr;
  279. self.exist_address = self.OrderData.exist_address;
  280. self.Address = self.OrderData.address;
  281. self.extract_store = self.OrderData.extract_store;
  282. self.last_extract = uni.getStorageSync('extract');
  283. if(!self.last_extract){
  284. self.last_extract = self.OrderData.last_extract;
  285. }
  286. self.ProductData = self.OrderData.product_list;
  287. self.coupon_list = self.OrderData.coupon_list;
  288. self.coupon_num = Object.keys(self.coupon_list).length;
  289. self.balance=res.data.balance;
  290. if(self.OrderData.delivery == '20'){
  291. self.tab_type = 1;
  292. }
  293. self.deliverySetting = self.OrderData.deliverySetting;
  294. if (self.OrderData.order_pay_price == 0) {
  295. self.pay_type = 10;
  296. }
  297. self.showAlipay = res.data.show_alipay;
  298. self.loading = false;
  299. };
  300. // 请求的参数
  301. let params = {
  302. delivery: self.delivery,
  303. store_id: self.store_id,
  304. coupon_id: self.coupon_id,
  305. is_use_points: self.is_use_points,
  306. pay_source: self.getPlatform(),
  307. };
  308. //直接购买
  309. if (self.options.order_type === 'buy') {
  310. self._get(
  311. 'order.order/buy',
  312. Object.assign({}, params, {
  313. product_id: self.options.product_id,
  314. product_num: self.options.product_num,
  315. product_sku_id: self.options.product_sku_id
  316. }),
  317. function(res) {
  318. callback(res);
  319. }
  320. );
  321. }
  322. // 购物车结算
  323. else if (self.options.order_type === 'cart') {
  324. self._get(
  325. 'order.order/cart',
  326. Object.assign({}, params, {
  327. cart_ids: self.options.cart_ids || 0,
  328. order_type:self.options.cart_type
  329. }),
  330. function(res) {
  331. callback(res);
  332. }
  333. );
  334. }
  335. // 积分兑换结算
  336. else if (self.options.order_type == 'points') {
  337. self._get(
  338. 'plus.points.order/buy',
  339. Object.assign({}, params, {
  340. point_product_id: self.options.point_product_id,
  341. product_sku_id: self.options.product_sku_id,
  342. point_product_sku_id: self.options.point_product_sku_id,
  343. product_num: self.options.product_num
  344. }),
  345. function(res) {
  346. callback(res);
  347. }
  348. );
  349. }
  350. // 限时秒杀
  351. else if (self.options.order_type === 'seckill') {
  352. params.num = self.options.num;
  353. self._get(
  354. 'plus.seckill.order/buy',
  355. Object.assign({}, params, {
  356. seckill_product_id: self.options.seckill_product_id,
  357. product_sku_id: self.options.product_sku_id,
  358. seckill_product_sku_id: self.options.seckill_product_sku_id,
  359. product_num: self.options.product_num
  360. }),
  361. function(res) {
  362. callback(res);
  363. }
  364. );
  365. }
  366. //砍价
  367. else if (self.options.order_type === 'bargain') {
  368. self._get(
  369. 'plus.bargain.order/buy',
  370. Object.assign({}, params, {
  371. bargain_product_id: self.options.bargain_product_id,
  372. product_sku_id: self.options.product_sku_id,
  373. bargain_product_sku_id: self.options.bargain_product_sku_id,
  374. bargain_task_id: self.options.bargain_task_id
  375. }),
  376. function(res) {
  377. callback(res);
  378. }
  379. );
  380. }
  381. //拼团
  382. else if (self.options.order_type === 'assemble') {
  383. self._get(
  384. 'plus.assemble.order/buy',
  385. Object.assign({}, params, {
  386. assemble_product_id: self.options.assemble_product_id,
  387. product_sku_id: self.options.product_sku_id,
  388. assemble_product_sku_id: self.options.assemble_product_sku_id,
  389. product_num: self.options.product_num,
  390. assemble_bill_id:self.options.assemble_bill_id,
  391. }),
  392. function(res) {
  393. callback(res);
  394. }
  395. );
  396. }
  397. },
  398. /*选择配送方式*/
  399. tabFunc(e) {
  400. this.tab_type = e;
  401. if (e == 0) {
  402. this.delivery = 10;
  403. } else {
  404. this.delivery = 20;
  405. }
  406. this.getData();
  407. },
  408. /*提交订单*/
  409. SubmitOrder() {
  410. let self = this;
  411. uni.showLoading({
  412. title: '加载中',
  413. mask: true
  414. });
  415. let _linkman = null;
  416. let _phone = null;
  417. //if (self.$refs != null) {
  418. //if (self.$refs.getShopinfoData != null) {
  419. _phone = self.last_extract.phone;
  420. _linkman = self.last_extract.linkman;
  421. //}
  422. //}
  423. let params = {
  424. delivery: self.delivery,
  425. store_id: self.store_id.store_id,
  426. coupon_id: self.coupon_id,
  427. is_use_points: self.is_use_points,
  428. phone: _phone,
  429. linkman: _linkman,
  430. remark: self.remark,
  431. pay_type: self.pay_type,
  432. pay_source: self.getPlatform()
  433. };
  434. // 创建订单-直接下单
  435. let url = '';
  436. if (self.options.order_type === 'buy') {
  437. url = 'order.order/buy';
  438. params = Object.assign(params, {
  439. product_id: self.options.product_id,
  440. product_num: self.options.product_num,
  441. product_sku_id: self.options.product_sku_id
  442. });
  443. }
  444. // 创建订单-购物车结算
  445. if (self.options.order_type === 'cart') {
  446. url = 'order.order/cart';
  447. params = Object.assign(params, {
  448. cart_ids: self.options.cart_ids || 0
  449. });
  450. }
  451. // 创建订单-积分兑换
  452. if (self.options.order_type === 'points') {
  453. url = 'plus.points.order/buy';
  454. params = Object.assign(params, {
  455. point_product_id: self.options.point_product_id,
  456. product_sku_id: self.options.product_sku_id,
  457. point_product_sku_id: self.options.point_product_sku_id,
  458. product_num: self.options.product_num
  459. });
  460. }
  461. // 创建订单-限时秒杀
  462. if (self.options.order_type === 'seckill') {
  463. url = 'plus.seckill.order/buy';
  464. params.num = self.options.num;
  465. params = Object.assign(params, {
  466. seckill_product_id: self.options.seckill_product_id,
  467. product_sku_id: self.options.product_sku_id,
  468. seckill_product_sku_id: self.options.seckill_product_sku_id,
  469. product_num: self.options.product_num
  470. });
  471. }
  472. // 创建订单-砍价
  473. if (self.options.order_type === 'bargain') {
  474. url = 'plus.bargain.order/buy';
  475. params = Object.assign(params, {
  476. bargain_product_id: self.options.bargain_product_id,
  477. product_sku_id: self.options.product_sku_id,
  478. bargain_product_sku_id: self.options.bargain_product_sku_id,
  479. bargain_task_id: self.options.bargain_task_id
  480. });
  481. }
  482. // 创建订单-限时拼团
  483. if (self.options.order_type === 'assemble') {
  484. url = 'plus.assemble.order/buy';
  485. params = Object.assign(params, {
  486. assemble_product_id: self.options.assemble_product_id,
  487. product_sku_id: self.options.product_sku_id,
  488. assemble_product_sku_id: self.options.assemble_product_sku_id,
  489. assemble_bill_id: self.options.assemble_bill_id,
  490. product_num: self.options.product_num,
  491. });
  492. }
  493. let callback = function(){
  494. self._post(url, params, function(result) {
  495. pay(result, self);
  496. });
  497. };
  498. self.subMessage(self.temlIds, callback);
  499. },
  500. toDecimal2(x) {
  501. var f = parseFloat(x);
  502. if (isNaN(f)) {
  503. return "0.00";
  504. }
  505. var f = Math.round(x * 100)
  506. var n = Math.round(x * 1000)
  507. var r = n.toString().split("");
  508. r = r[r.length - 1];
  509. if (r >= 5) {
  510. f = (f - 1) / 100
  511. } else {
  512. f = f / 100
  513. }
  514. var s = f.toString();
  515. var rs = s.indexOf('.');
  516. if (rs < 0) {
  517. rs = s.length;
  518. s += '.';
  519. }
  520. while (s.length <= rs + 2) {
  521. s += '0';
  522. }
  523. return s;
  524. },
  525. }
  526. };
  527. </script>
  528. <style lang="scss" scoped>
  529. page{
  530. background-color: #F2F2F2;
  531. }
  532. .wrap {
  533. padding-bottom: 110rpx;
  534. }
  535. .d-f-c {
  536. display: flex;
  537. justify-content: space-between;
  538. align-items: center;
  539. overflow: hidden;
  540. padding:30rpx;
  541. border-bottom: 1rpx solid #D9D9D9;
  542. }
  543. .dfjac {
  544. display: flex;
  545. align-items: center;
  546. }
  547. .d-txar {
  548. white-space: nowrap;
  549. width: 200px;
  550. margin-right: 34rpx;
  551. }
  552. .extp {
  553. color: #9e9e9e;
  554. margin-left: 34rpx;
  555. }
  556. .vender .list .item {
  557. border-bottom: none;
  558. }
  559. .icon-jiantou {
  560. margin-left: 15rpx;
  561. }
  562. .icon-dianpu1 {
  563. margin-right: 15rpx;
  564. font-size: 28rpx;
  565. color: #333333;
  566. }
  567. .sup_itemtit {
  568. padding: 40rpx 30rpx;
  569. display: flex;
  570. align-items: center;
  571. }
  572. .vender .total-box {
  573. height: 87rpx;
  574. line-height: 87rpx;
  575. border-bottom: 16rpx solid #f2f2f2;
  576. }
  577. .d-f {
  578. display: flex;
  579. }
  580. .zt {
  581. padding: 2rpx 10rpx;
  582. margin-right: 10rpx;
  583. background: #E2231A;
  584. color: #FFFFFF;
  585. border-radius: 8rpx;
  586. font-size: 22rpx;
  587. }
  588. .icon-box .icon-zhifubao {
  589. color: #1296db;
  590. font-size: 50rpx;
  591. }
  592. .icon-dianpu1{
  593. }
  594. .text_area{
  595. width: 100%;
  596. height: 120rpx;
  597. background: #f2f2f2;
  598. border-radius: 6rpx;
  599. padding: 20rpx;
  600. box-sizing: border-box;
  601. font-size: 24rpx;
  602. }
  603. .icon-xuanze{
  604. font-size: 38rpx;
  605. }
  606. </style>