| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641 |
- <template>
- <view class="wrap" v-if="!loading">
- <!--tab-->
- <view class="top-tabbar" v-if="OrderData.delivery != 30">
- <block v-if="hasType(10)">
- <view :class="tab_type == 0 ? 'tab-item active' : 'tab-item'" @click="tabFunc(0)">快递配送</view>
- </block>
- <block v-if="hasType(20)">
- <view :class="tab_type == 1 ? 'tab-item active' : 'tab-item'" @click="tabFunc(1)">上门自提</view>
- </block>
- </view>
- <Myinfo v-if="tab_type == 0 && OrderData.delivery != 30" :Address="Address" :exist_address="exist_address"></Myinfo>
- <Storeinfo v-if="tab_type == 1 && OrderData.delivery != 30" ref="getShopinfoData" :extract_store="extract_store"
- :last_extract="last_extract"></Storeinfo>
- <!--购买的产品-->
- <view class="vender">
- <view class="list">
- <view class="item" v-for="(item, index) in ProductData" :key="index">
- <view class="d-f">
- <view class="cover">
- <image :src="item.product_image" mode="aspectFit"></image>
- </view>
- <view class="info">
- <view class="d-b-s">
- <view class="flex-1">
- <view class="title f32 gray3">{{ item.product_name }}</view>
- <view class="describe mt10 f24">{{ item.product_sku.product_attr }}</view>
- </view>
- <view>
- <view class=" count_choose">
- <view class="price">
- ¥
- <text class="num">{{ item.product_price }}</text>
- </view>
- <view class="num-wrap">
- <view class="f22 tr">×{{ item.total_num }}</view>
- </view>
- </view>
- </view>
- </view>
- </view>
- </view>
- <view class="mt10 tr f28" v-if="item.is_user_grade==true">
- <text class="redF6 f26">会员折扣价:</text>
- <text class="redF6 f32">{{item.grade_product_price}}</text>
- </view>
- </view>
- </view>
- <!--总数-->
- <view class="total-box vthl">
- <view>
- <text class="f26 gray3">共{{OrderData.order_total_num }}件商品,总价:</text>
- <text class="f20 gray3">¥</text>
- <text class="f26 gray3">{{ OrderData.order_total_price }}</text>
- </view>
- <view class="d-f">
- <view class="f26" v-if="!OrderData.force_points">
- 实付款:<text class="redF6 f20">¥</text><text class="price redF6" style="font-size: 32rpx;">{{toDecimal2(OrderData.order_pay_price)}}</text>
- </view>
- </view>
- </view>
- </view>
- <!--其它费用-->
- <view class="buy-checkout">
- <view class="item">
- <text class="key f26">订单总金额:</text>
- <view>
- <text class="redF6 f20">¥</text>
- <text class="price f32">{{ OrderData.order_total_price }}</text>
- </view>
- </view>
- <view class="item" v-if="OrderData.is_coupon">
- <text class="key">优惠券:</text>
- <block v-if="coupon_num > 0">
- <view class="vlaue orange" v-if="OrderData.coupon_id > 0" @click="onTogglePopupCoupon(coupon_list)">-¥{{ OrderData.coupon_money }}</view>
- <view v-else class="vlaue orange" @click="onTogglePopupCoupon(coupon_list)">有{{ coupon_num }}张优惠券可用<text class="icon iconfont icon-jiantou"></text></view>
- </block>
- <text v-else class="vlaue">无优惠券可用</text>
- </view>
- <view class="item">
- <text class="key">配送费用:</text>
- <view v-if="OrderData.express_price!=0">
- <text class="redF6 f20">¥</text>
- <text class="price f32">{{ OrderData.express_price }}</text>
- </view>
- <view v-else>
- <text class="">快递 免费</text>
- </view>
- </view>
- <view class="item" v-if="OrderData.reduce">
- <text class="key">满减({{ OrderData.reduce.active_name }}):</text>
- <view>
- <text class="redF6 f20">-¥</text>
- <text class="price f32">{{ OrderData.reduce.reduced_price }}</text>
- </view>
- </view>
- <view class="item" v-if="OrderData.is_use_points && OrderData.force_points == false && OrderData.points_money > 0">
- <text class="key">可用积分抵扣:</text>
- <view class="">
- <text class="price">-¥{{ OrderData.points_money }}</text>
- <switch :checked="is_use_points" style="transform: scale(0.7); margin-right: -10rpx;" @change="onShowPoints" />
- </view>
- </view>
- </view>
- <!--支付方式-->
- <view class="buy-checkout" v-if="OrderData.order_pay_price != 0">
- <view :class="pay_type == 20 ? 'item active' : 'item'" @click="payTypeFunc(20)">
- <view class="d-s-c">
- <view class="icon-box d-c-c mr10"><span class="icon iconfont icon-weixin"></span></view>
- <text class="key">微信支付:</text>
- </view>
- <view class="icon-box d-c-c"><span class="icon iconfont icon-xuanze"></span></view>
- </view>
- <view v-if="showAlipay" :class="pay_type == 30 ? 'item active' : 'item'" @click="payTypeFunc(30)">
- <view class="d-s-c">
- <view class="icon-box d-c-c mr10"><span class="icon iconfont icon-zhifubao"></span></view>
- <text class="key">支付宝支付:</text>
- </view>
- <view class="icon-box d-c-c"><span class="icon iconfont icon-xuanze"></span></view>
- </view>
- <view :class="pay_type == 10 ? 'item active' : 'item'" @click="payTypeFunc(10)">
- <view class="d-s-c">
- <view class="icon-box d-c-c mr10"><span class="icon iconfont icon-yue"></span></view>
- <text class="key">余额支付:</text><text class="redF6">{{'(可用余额:'+balance+')'}}</text>
- </view>
- <view class="icon-box d-c-c"><span class="icon iconfont icon-xuanze"></span></view>
- </view>
- </view>
- <!--买家留言-->
- <view class="buyer-message uni-textarea"><textarea class="textarea" v-model="remark" placeholder-style="color:#cccccc;"
- placeholder="选项:买家留言" /></view>
- <!--底部支付-->
- <view class="foot-pay-btns">
- <view class="price" v-if="!OrderData.force_points">
- ¥
- <text class="num">{{ OrderData.order_pay_price }}</text>
- </view>
- <view class="price" v-if="OrderData.force_points">
- <text class="gray9">所需积分</text>
- <text class="num red fb">{{ OrderData.points_num }}</text>
- <template v-if="OrderData.order_pay_price > 0">
- <text>+</text>
- ¥
- <text class="num fb">{{ OrderData.order_pay_price }}</text>
- </template>
- </view>
- <button type="primary" @click="SubmitOrder">提交订单</button>
- </view>
- <!--优惠券-->
- <Coupon :isCoupon="isCoupon" :couponList="couponList" @close="closeCouponFunc"></Coupon>
- </view>
- </template>
- <script>
- import Myinfo from './confirm-order/my-info';
- import Storeinfo from './confirm-order/store-info';
- import Coupon from './confirm-order/coupon';
- import { pay } from '@/common/pay.js';
- export default {
- components: {
- Myinfo,
- Storeinfo,
- Coupon
- },
- data() {
- return {
- /*是否加载完成*/
- loading: true,
- options: {},
- indicatorDots: true,
- autoplay: true,
- interval: 2000,
- duration: 500,
- tab_type: 0,
- /*商品id*/
- product_id: '',
- /*商品数量*/
- product_num: '',
- /*商品数据*/
- ProductData: [],
- /*订单数据数据*/
- OrderData: [],
- // 是否存在收货地址
- exist_address: false,
- /*默认地址*/
- Address: {
- region: []
- },
- extract_store: [],
- last_extract: {},
- product_sku_id: 0,
- /*配送方式*/
- delivery: 0,
- /*自提店id*/
- store_id: 0,
- /*优惠券id*/
- coupon_id: 0,
- /*是否使用积分*/
- is_use_points: 1,
- linkman: '',
- phone: '',
- remark: '',
- /*支付方式*/
- pay_type: 20,
- /*是否显示优惠券*/
- isCoupon: false,
- /*优惠券列表*/
- coupon_list: {},
- couponList: [],
- deliverySetting: [],
- /*优惠券数量*/
- coupon_num: 0,
- /*消息模板*/
- temlIds: [],
- /*是否显示支付宝支付,只有在h5,非微信内打开才显示*/
- showAlipay: false,
- balance:''
- };
- },
- onLoad(options) {
- let self = this;
- self.options = options;
- self.$fire.on('selectStoreId', function(store_id) {
- self.store_id = store_id;
- self.extract_store=store_id;
- });
- self.$fire.on('extract', function(params) {
- console.log(params);
- self.last_extract = params;
- });
- },
- onShow() {
- this.getData();
- },
- methods: {
- /**/
- hasType(e) {
- if (this.deliverySetting.indexOf(e+"") != -1) {
- return true;
- } else {
- return false;
- }
- },
- /*支付方式选择*/
- payTypeFunc(e) {
- this.pay_type = e;
- },
- /*是否使用积分选择*/
- onShowPoints: function(e) {
- let self = this;
- if (e.target.value == true) {
- self.is_use_points = 1;
- } else {
- self.is_use_points = 0;
- }
- self.getData();
- },
- /*选择优惠卷*/
- onTogglePopupCoupon(e) {
- let self = this;
- self.isCoupon = true;
- self.couponList = e;
- },
- /*关闭优惠券*/
- closeCouponFunc(e) {
- let self = this;
- self.coupon_id = e;
- this.isCoupon = false;
- self.getData();
- },
- /*获取数据*/
- getData() {
- let self = this;
- uni.showLoading({
- title: '加载中'
- });
- let callback = function(res) {
- self.OrderData = res.data.orderInfo;
- self.temlIds = res.data.template_arr;
- self.exist_address = self.OrderData.exist_address;
- self.Address = self.OrderData.address;
- self.extract_store = self.OrderData.extract_store;
-
- self.last_extract = uni.getStorageSync('extract');
- if(!self.last_extract){
- self.last_extract = self.OrderData.last_extract;
- }
- self.ProductData = self.OrderData.product_list;
- self.coupon_list = self.OrderData.coupon_list;
- self.coupon_num = Object.keys(self.coupon_list).length;
- self.balance=res.data.balance;
- if(self.OrderData.delivery == '20'){
- self.tab_type = 1;
- }
- self.deliverySetting = self.OrderData.deliverySetting;
- if (self.OrderData.order_pay_price == 0) {
- self.pay_type = 10;
- }
- self.showAlipay = res.data.show_alipay;
- self.loading = false;
- };
- // 请求的参数
- let params = {
- delivery: self.delivery,
- store_id: self.store_id,
- coupon_id: self.coupon_id,
- is_use_points: self.is_use_points,
- pay_source: self.getPlatform(),
- };
- //直接购买
- if (self.options.order_type === 'buy') {
- self._get(
- 'order.order/buy',
- Object.assign({}, params, {
- product_id: self.options.product_id,
- product_num: self.options.product_num,
- product_sku_id: self.options.product_sku_id
- }),
- function(res) {
- callback(res);
- }
- );
- }
- // 购物车结算
- else if (self.options.order_type === 'cart') {
- self._get(
- 'order.order/cart',
- Object.assign({}, params, {
- cart_ids: self.options.cart_ids || 0,
- order_type:self.options.cart_type
- }),
- function(res) {
- callback(res);
- }
- );
- }
- // 积分兑换结算
- else if (self.options.order_type == 'points') {
- self._get(
- 'plus.points.order/buy',
- Object.assign({}, params, {
- point_product_id: self.options.point_product_id,
- product_sku_id: self.options.product_sku_id,
- point_product_sku_id: self.options.point_product_sku_id,
- product_num: self.options.product_num
- }),
- function(res) {
- callback(res);
- }
- );
- }
- // 限时秒杀
- else if (self.options.order_type === 'seckill') {
- params.num = self.options.num;
- self._get(
- 'plus.seckill.order/buy',
- Object.assign({}, params, {
- seckill_product_id: self.options.seckill_product_id,
- product_sku_id: self.options.product_sku_id,
- seckill_product_sku_id: self.options.seckill_product_sku_id,
- product_num: self.options.product_num
- }),
- function(res) {
- callback(res);
- }
- );
- }
- //砍价
- else if (self.options.order_type === 'bargain') {
- self._get(
- 'plus.bargain.order/buy',
- Object.assign({}, params, {
- bargain_product_id: self.options.bargain_product_id,
- product_sku_id: self.options.product_sku_id,
- bargain_product_sku_id: self.options.bargain_product_sku_id,
- bargain_task_id: self.options.bargain_task_id
- }),
- function(res) {
- callback(res);
- }
- );
- }
- //拼团
- else if (self.options.order_type === 'assemble') {
- self._get(
- 'plus.assemble.order/buy',
- Object.assign({}, params, {
- assemble_product_id: self.options.assemble_product_id,
- product_sku_id: self.options.product_sku_id,
- assemble_product_sku_id: self.options.assemble_product_sku_id,
- product_num: self.options.product_num,
- assemble_bill_id:self.options.assemble_bill_id,
- }),
- function(res) {
- callback(res);
- }
- );
- }
- },
-
- /*选择配送方式*/
- tabFunc(e) {
- this.tab_type = e;
- if (e == 0) {
- this.delivery = 10;
- } else {
- this.delivery = 20;
- }
- this.getData();
- },
-
- /*提交订单*/
- SubmitOrder() {
- let self = this;
- uni.showLoading({
- title: '加载中',
- mask: true
- });
- let _linkman = null;
- let _phone = null;
- //if (self.$refs != null) {
- //if (self.$refs.getShopinfoData != null) {
- _phone = self.last_extract.phone;
- _linkman = self.last_extract.linkman;
- //}
- //}
- let params = {
- delivery: self.delivery,
- store_id: self.store_id.store_id,
- coupon_id: self.coupon_id,
- is_use_points: self.is_use_points,
- phone: _phone,
- linkman: _linkman,
- remark: self.remark,
- pay_type: self.pay_type,
- pay_source: self.getPlatform()
- };
- // 创建订单-直接下单
- let url = '';
- if (self.options.order_type === 'buy') {
- url = 'order.order/buy';
- params = Object.assign(params, {
- product_id: self.options.product_id,
- product_num: self.options.product_num,
- product_sku_id: self.options.product_sku_id
- });
- }
- // 创建订单-购物车结算
- if (self.options.order_type === 'cart') {
- url = 'order.order/cart';
- params = Object.assign(params, {
- cart_ids: self.options.cart_ids || 0
- });
- }
- // 创建订单-积分兑换
- if (self.options.order_type === 'points') {
- url = 'plus.points.order/buy';
- params = Object.assign(params, {
- point_product_id: self.options.point_product_id,
- product_sku_id: self.options.product_sku_id,
- point_product_sku_id: self.options.point_product_sku_id,
- product_num: self.options.product_num
- });
- }
- // 创建订单-限时秒杀
- if (self.options.order_type === 'seckill') {
- url = 'plus.seckill.order/buy';
- params.num = self.options.num;
- params = Object.assign(params, {
- seckill_product_id: self.options.seckill_product_id,
- product_sku_id: self.options.product_sku_id,
- seckill_product_sku_id: self.options.seckill_product_sku_id,
- product_num: self.options.product_num
- });
- }
- // 创建订单-砍价
- if (self.options.order_type === 'bargain') {
- url = 'plus.bargain.order/buy';
- params = Object.assign(params, {
- bargain_product_id: self.options.bargain_product_id,
- product_sku_id: self.options.product_sku_id,
- bargain_product_sku_id: self.options.bargain_product_sku_id,
- bargain_task_id: self.options.bargain_task_id
- });
- }
- // 创建订单-限时拼团
- if (self.options.order_type === 'assemble') {
- url = 'plus.assemble.order/buy';
- params = Object.assign(params, {
- assemble_product_id: self.options.assemble_product_id,
- product_sku_id: self.options.product_sku_id,
- assemble_product_sku_id: self.options.assemble_product_sku_id,
- assemble_bill_id: self.options.assemble_bill_id,
- product_num: self.options.product_num,
- });
- }
- let callback = function(){
- self._post(url, params, function(result) {
- pay(result, self);
- });
- };
-
- self.subMessage(self.temlIds, callback);
- },
- toDecimal2(x) {
- var f = parseFloat(x);
- if (isNaN(f)) {
- return "0.00";
- }
- var f = Math.round(x * 100)
- var n = Math.round(x * 1000)
- var r = n.toString().split("");
- r = r[r.length - 1];
- if (r >= 5) {
- f = (f - 1) / 100
- } else {
- f = f / 100
- }
- var s = f.toString();
- var rs = s.indexOf('.');
- if (rs < 0) {
- rs = s.length;
- s += '.';
- }
- while (s.length <= rs + 2) {
- s += '0';
- }
- return s;
- },
- }
- };
- </script>
- <style lang="scss" scoped>
- page{
- background-color: #F2F2F2;
- }
- .wrap {
- padding-bottom: 110rpx;
- }
- .d-f-c {
- display: flex;
- justify-content: space-between;
- align-items: center;
- overflow: hidden;
- padding:30rpx;
- border-bottom: 1rpx solid #D9D9D9;
- }
- .dfjac {
- display: flex;
- align-items: center;
- }
- .d-txar {
- white-space: nowrap;
- width: 200px;
- margin-right: 34rpx;
- }
- .extp {
- color: #9e9e9e;
- margin-left: 34rpx;
- }
- .vender .list .item {
- border-bottom: none;
- }
- .icon-jiantou {
- margin-left: 15rpx;
- }
- .icon-dianpu1 {
- margin-right: 15rpx;
- font-size: 28rpx;
- color: #333333;
- }
- .sup_itemtit {
- padding: 40rpx 30rpx;
- display: flex;
- align-items: center;
- }
- .vender .total-box {
- height: 87rpx;
- line-height: 87rpx;
- border-bottom: 16rpx solid #f2f2f2;
- }
- .d-f {
- display: flex;
- }
- .zt {
- padding: 2rpx 10rpx;
- margin-right: 10rpx;
- background: #E2231A;
- color: #FFFFFF;
- border-radius: 8rpx;
- font-size: 22rpx;
- }
- .icon-box .icon-zhifubao {
- color: #1296db;
- font-size: 50rpx;
- }
- .icon-dianpu1{
-
- }
- .text_area{
- width: 100%;
- height: 120rpx;
- background: #f2f2f2;
- border-radius: 6rpx;
- padding: 20rpx;
- box-sizing: border-box;
- font-size: 24rpx;
- }
- .icon-xuanze{
- font-size: 38rpx;
- }
- </style>
|