|
|
@@ -1,103 +1,70 @@
|
|
|
<template>
|
|
|
- <div class="app-content">
|
|
|
- <!-- tabs -->
|
|
|
- <app-tabs
|
|
|
- :tabs="tabs"
|
|
|
- :currentTab="tabIndex"
|
|
|
- :isFixed="true"
|
|
|
- :borderLeft="true"
|
|
|
- @change="tabChange"
|
|
|
- itemWidth="50%"
|
|
|
- />
|
|
|
- <!-- 配送 -->
|
|
|
+ <view class="app-content">
|
|
|
+ <app-tabs :tabs="tabs" :currentTab="tabIndex" :isFixed="true" :borderLeft="true" @change="tabChange" itemWidth="50%" />
|
|
|
<form @submit="formSubmit">
|
|
|
<block v-if="tabIndex == 0">
|
|
|
<app-delivery-module ref="appDelivery" @changeAddress="changeAddress" />
|
|
|
</block>
|
|
|
- <!-- 自取 -->
|
|
|
<block v-else>
|
|
|
- <!-- 收花人 -->
|
|
|
- <div class="module-com">
|
|
|
+ <view class="module-com">
|
|
|
<tui-list-cell class="line-cell" :hover="false">
|
|
|
- <div class="tui-title">手机号</div>
|
|
|
- <input
|
|
|
- v-model="mentionForm.bookMobile"
|
|
|
- placeholder-class="phcolor"
|
|
|
- class="tui-input"
|
|
|
- name="phone"
|
|
|
- placeholder="请输入手机号"
|
|
|
- type="number"
|
|
|
- />
|
|
|
+ <view class="tui-title">手机号</view>
|
|
|
+ <input v-model="mentionForm.bookMobile" placeholder-class="phcolor" class="tui-input" name="phone" placeholder="请输入手机号" type="number" />
|
|
|
</tui-list-cell>
|
|
|
- </div>
|
|
|
+ </view>
|
|
|
</block>
|
|
|
|
|
|
- <!-- 商品金额 -->
|
|
|
- <div class="module-com shop-price-wrap">
|
|
|
- <div class="module-tit">商品信息</div>
|
|
|
- <div class="module-det">
|
|
|
- <app-list-module v-if="!$util.isEmpty(goodsInfo)" :goodsStyleId="option.goodsStyleId" :info="goodsInfo" />
|
|
|
- <div class="shop-prompt" v-if="!$util.isEmpty(orderShop)" @click="showAlert = true">
|
|
|
- <div>
|
|
|
+ <view class="module-com shop-price-wrap">
|
|
|
+ <view class="module-tit">商品信息</view>
|
|
|
+ <view class="module-det">
|
|
|
+ <app-list-module v-if="!$util.isEmpty(goodsInfo)" :info="goodsInfo" />
|
|
|
+ <view class="shop-prompt" v-if="!$util.isEmpty(orderShop)" @click="showAlert = true">
|
|
|
+ <view>
|
|
|
<span>{{ `运费(${showDistance}公里)` }}</span>
|
|
|
<i class="iconfont iconchangjianwentixiangguanwenti2" style="font-size:45upx;"></i>
|
|
|
- </div>
|
|
|
- <div>¥{{ freightPrice }}</div>
|
|
|
- </div>
|
|
|
+ </view>
|
|
|
+ <view>¥{{ freightPrice }}</view>
|
|
|
+ </view>
|
|
|
+ <view class="shop-prompt">
|
|
|
+ <view>总计</view>
|
|
|
+ <view>¥{{ totalPrice }}</view>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
|
|
|
- <div class="shop-prompt">
|
|
|
- <div>总计</div>
|
|
|
- <div>¥{{ totalPrice }}</div>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- <!-- 可选优惠 -->
|
|
|
- <div class="module-com discount-wrap" v-if="!$util.isEmpty(discountArr)">
|
|
|
- <div class="module-tit">可选优惠</div>
|
|
|
- <div class="module-det">
|
|
|
- <app-coupon-sel
|
|
|
- ref="couponSel"
|
|
|
- @calcDiscount="calcDiscount"
|
|
|
- :discountArr="['member', 'coupon']"
|
|
|
- />
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- <app-trademark />
|
|
|
- <view style="width:100%;height:90upx"></view>
|
|
|
- <!-- 按钮 -->
|
|
|
- <div class="page-btn app-footer">
|
|
|
- <div class="flex-center">
|
|
|
+ <view style="width:100vw;height:200upx"></view>
|
|
|
+
|
|
|
+ <view class="page-btn app-footer">
|
|
|
+ <view class="flex-center">
|
|
|
<span>应付款</span>
|
|
|
<span class="app-price">
|
|
|
<span>¥</span>
|
|
|
<span class="app-size-40">{{ mayPayAmount }}</span>
|
|
|
</span>
|
|
|
- </div>
|
|
|
+ </view>
|
|
|
<button class="button-com red" formType="submit">确认</button>
|
|
|
- </div>
|
|
|
+ </view>
|
|
|
</form>
|
|
|
- <!-- 弹窗 -->
|
|
|
<alert-module :show="showAlert" @click="hideAlert" @cancel="hideAlert">
|
|
|
- <div class="alt-content" v-if="!$util.isEmpty(orderShop)">
|
|
|
- <div>
|
|
|
+ <view class="alt-content" v-if="!$util.isEmpty(orderShop)">
|
|
|
+ <view>
|
|
|
<span class="app-price">{{ `${orderShop.freight.first}公里`}}</span>内免运费
|
|
|
- </div>
|
|
|
- <div>
|
|
|
+ </view>
|
|
|
+ <view>
|
|
|
<span>超过每增加1公里运费加</span>
|
|
|
<span class="app-price">{{ `${orderShop.freight.add}元` }}</span>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
</alert-module>
|
|
|
- </div>
|
|
|
+ </view>
|
|
|
</template>
|
|
|
-
|
|
|
<script>
|
|
|
import { mapGetters } from "vuex";
|
|
|
import AppTabs from "@/components/plugin/tabs";
|
|
|
import TuiListCell from "@/components/plugin/list-cell";
|
|
|
import AppDeliveryModule from "@/components/app-delivery";
|
|
|
import AppTrademark from "@/components/module/app-trademark";
|
|
|
-import AppListModule from "@/components/module/app-order-list";
|
|
|
+import AppListModule from "@/components/module/app-order-list2";
|
|
|
import AppCouponSel from "@/components/app-coupon-sel";
|
|
|
import AlertModule from "@/components/plugin/alert";
|
|
|
const form = require("@/utils/formValidation.js");
|
|
|
@@ -129,7 +96,6 @@ export default {
|
|
|
}
|
|
|
],
|
|
|
showAlert: false,
|
|
|
- // form
|
|
|
form: {
|
|
|
anonymity: "0", // 是否匿名 0不 1要
|
|
|
sendDistance: "", // 配送距离,根据腾讯js进行计算
|
|
|
@@ -140,15 +106,12 @@ export default {
|
|
|
receiveLat: "", // 收花人纬度
|
|
|
receiveLong: "" // 收花人经度
|
|
|
},
|
|
|
- // 自提form
|
|
|
mentionForm: {
|
|
|
bookMobile: ""
|
|
|
},
|
|
|
discountArr: false,
|
|
|
- // 运费
|
|
|
freightPrice: 0,
|
|
|
goodsNum: 1,
|
|
|
- //显示的距离
|
|
|
showDistance: 0,
|
|
|
totalPrice: 0,
|
|
|
memberDiscount: 1,
|
|
|
@@ -159,38 +122,24 @@ export default {
|
|
|
computed: {
|
|
|
...mapGetters({ orderShop: "getOrderShop" }),
|
|
|
...mapGetters({ shopUser: "getShopUser" }),
|
|
|
- mayPayAmount: function() {
|
|
|
- let price =
|
|
|
- (this.goodsInfo.price * this.goodsInfo.buyNum + this.freightPrice) *
|
|
|
- this.memberDiscount -
|
|
|
- this.couponDiscountAmount;
|
|
|
- return price.toFixed(2);
|
|
|
+ mayPayAmount(){
|
|
|
+ let price = (this.goodsInfo.price * this.goodsInfo.buyNum + this.freightPrice) * this.memberDiscount - this.couponDiscountAmount
|
|
|
+ return parseFloat(price.toFixed(2))
|
|
|
}
|
|
|
},
|
|
|
watch: {
|
|
|
//运费变化则总金额和应付金额变化
|
|
|
freightPrice(newVal) {
|
|
|
let price = this.goodsInfo.price * this.goodsInfo.buyNum + newVal;
|
|
|
- this.totalPrice = price.toFixed(2);
|
|
|
+ this.totalPrice = parseFloat(price.toFixed(2))
|
|
|
}
|
|
|
},
|
|
|
- onLoad() {
|
|
|
- },
|
|
|
- created() {},
|
|
|
methods: {
|
|
|
init() {
|
|
|
- let goodsInfo = uni.getStorageSync("buyGoodsDetil");
|
|
|
-
|
|
|
- goodsInfo.price = this.option.goodsStyleId
|
|
|
- ? goodsInfo.goodsStyleList[this.option.selIndex].price
|
|
|
- : goodsInfo.price;
|
|
|
|
|
|
- getOrderShop().then(() => {
|
|
|
- this.$refs.couponSel._getUserDiscount().then(discountData => {
|
|
|
- this.discountArr = discountData;
|
|
|
- });
|
|
|
- });
|
|
|
+ let goodsInfo = uni.getStorageSync("buyGoodsDetil")
|
|
|
|
|
|
+ getOrderShop()
|
|
|
getShopUser();
|
|
|
|
|
|
goodsInfo.buyNum = this.option.goodsNum;
|
|
|
@@ -198,17 +147,39 @@ export default {
|
|
|
|
|
|
this.totalPrice = goodsInfo.price * this.option.goodsNum;
|
|
|
|
|
|
- // 初始化上个页面带入的值
|
|
|
Object.keys(this.form).forEach((i, index) => {
|
|
|
this.form[i] = this.option[i];
|
|
|
+ })
|
|
|
+
|
|
|
+ },
|
|
|
+ tabChange(e) {
|
|
|
+ this.tabIndex = e.index;
|
|
|
+ },
|
|
|
+ hideAlert() {
|
|
|
+ this.showAlert = false;
|
|
|
+ },
|
|
|
+ anonymityChange(e) {
|
|
|
+ this.form.anonymity = this.form.anonymity == 1 ? 0 : 1;
|
|
|
+ },
|
|
|
+ //计算客户距离和运费
|
|
|
+ changeAddress(e) {
|
|
|
+ let lat = this.$refs.appDelivery.region.latitude;
|
|
|
+ let long = this.$refs.appDelivery.region.longitude;
|
|
|
+ getUserDistance({ lat: lat, lng: long }).then(res => {
|
|
|
+ this.freightPrice = res.data.fee;
|
|
|
+ this.showDistance = res.data.showDistance;
|
|
|
});
|
|
|
},
|
|
|
- //最终会员优惠的折扣和优惠券优惠金额
|
|
|
- calcDiscount(discountData) {
|
|
|
- this.memberDiscount = discountData.memberDiscount;
|
|
|
- this.couponDiscountAmount = discountData.couponDiscountAmount;
|
|
|
+ formSubmit(e) {
|
|
|
+ let rules = [];
|
|
|
+ let formData = e.detail.value;
|
|
|
+ let checkRes = form.validation(formData, rules);
|
|
|
+ if (!checkRes) {
|
|
|
+ this.createOrderFn()
|
|
|
+ } else {
|
|
|
+ this.$msg(checkRes);
|
|
|
+ }
|
|
|
},
|
|
|
- // 生成订单
|
|
|
createOrderFn() {
|
|
|
let addForm = {};
|
|
|
let form =
|
|
|
@@ -244,57 +215,12 @@ export default {
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- createOrder({
|
|
|
- needSend: this.tabIndex == 0 ? "1" : "0",
|
|
|
- ...form,
|
|
|
- ...this.form,
|
|
|
- ...addForm,
|
|
|
- ...region
|
|
|
- }).then(res => {
|
|
|
- uni.removeStorageSync("buyGoodsDetil");
|
|
|
- this.$util.pageTo({
|
|
|
- url: "/pages/callback/index",
|
|
|
- type: 2,
|
|
|
- query: {
|
|
|
- pageStatus: 1,
|
|
|
- ...res.data
|
|
|
- }
|
|
|
- });
|
|
|
+ uni.showLoading({mask:true})
|
|
|
+ createOrder({ needSend: this.tabIndex == 0 ? "1" : "0", ...form, ...this.form, ...addForm, ...region }).then(res => {
|
|
|
+ uni.hideLoading()
|
|
|
+ uni.removeStorageSync("buyGoodsDetil")
|
|
|
+ this.$util.pageTo({ url: "/pages/callback/index", type: 2, query: { pageStatus: 1, ...res.data } })
|
|
|
});
|
|
|
- },
|
|
|
- confirmFn() {
|
|
|
- this.createOrderFn();
|
|
|
- },
|
|
|
- tabChange(e) {
|
|
|
- this.tabIndex = e.index;
|
|
|
- },
|
|
|
- hideAlert() {
|
|
|
- this.showAlert = false;
|
|
|
- },
|
|
|
- anonymityChange(e) {
|
|
|
- this.form.anonymity = this.form.anonymity == 1 ? 0 : 1;
|
|
|
- },
|
|
|
- // 选择地址
|
|
|
- changeAddress(e) {
|
|
|
- // 计算客户距离和运费
|
|
|
- let lat = this.$refs.appDelivery.region.latitude;
|
|
|
- let long = this.$refs.appDelivery.region.longitude;
|
|
|
- getUserDistance({ lat: lat, lng: long }).then(res => {
|
|
|
- this.freightPrice = res.data.fee;
|
|
|
- this.showDistance = res.data.showDistance;
|
|
|
- });
|
|
|
- },
|
|
|
- // 表单验证
|
|
|
- formSubmit(e) {
|
|
|
- let rules = [];
|
|
|
- let formData = e.detail.value;
|
|
|
- let checkRes = form.validation(formData, rules);
|
|
|
- if (!checkRes) {
|
|
|
- this.confirmFn();
|
|
|
- } else {
|
|
|
- this.$msg(checkRes);
|
|
|
- }
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
@@ -303,7 +229,7 @@ export default {
|
|
|
<style lang='scss' scoped>
|
|
|
.app-content {
|
|
|
padding-top: 100upx;
|
|
|
- padding-bottom: 120upx;
|
|
|
+ padding-bottom: 160upx;
|
|
|
min-height: calc(100vh - 220upx);
|
|
|
.module-com {
|
|
|
margin-bottom: 20upx;
|
|
|
@@ -379,7 +305,6 @@ export default {
|
|
|
width: 270upx;
|
|
|
}
|
|
|
}
|
|
|
-// 弹窗
|
|
|
/deep/.tui-alert-content {
|
|
|
padding: 40upx 40upx;
|
|
|
}
|