|
|
@@ -1,38 +1,29 @@
|
|
|
<template>
|
|
|
<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>
|
|
|
- <view class="module-com">
|
|
|
- <tui-list-cell class="line-cell" :hover="false">
|
|
|
- <view class="tui-title">订花人电话</view>
|
|
|
- <input v-model="mentionForm.bookMobile" placeholder-class="phcolor" class="tui-input" name="phone" placeholder="请输入手机号" type="number" />
|
|
|
- </tui-list-cell>
|
|
|
- </view>
|
|
|
- </block>
|
|
|
|
|
|
+ <form @submit="formSubmit">
|
|
|
<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>
|
|
|
- </view>
|
|
|
- <view>¥{{ freightPrice }}</view>
|
|
|
- </view>
|
|
|
<view class="shop-prompt">
|
|
|
- <view>总计</view>
|
|
|
- <view>¥{{ totalPrice }}</view>
|
|
|
+ <view>商品合计</view>
|
|
|
+ <view>¥{{ goodsTotalPrice }}</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
|
|
|
- <view style="width:100vw;height:200upx"></view>
|
|
|
+ <view class="module-com input-line-wrap">
|
|
|
+ <tui-list-cell class="line-cell" :hover="false" :arrow="false" >
|
|
|
+ <button class="admin-button-com big" :class="[form.sendType == 2 ? 'blue' : 'default']" style="width:180upx;margin-right:20upx;" @click="changeSendType(2)">跑腿送</button>
|
|
|
+ <button class="admin-button-com big" :class="[form.sendType == 1 ? 'blue' : 'default']" style="width:180upx;margin-right:20upx;" @click="changeSendType(1)">到店自取</button>
|
|
|
+ <button class="admin-button-com big" :class="[form.sendType == 0 ? 'blue' : 'default']" style="width:180upx;" @click="changeSendType(0)">有车上门</button>
|
|
|
+ </tui-list-cell>
|
|
|
+ </view>
|
|
|
+
|
|
|
+ <block v-if="form.sendType != 1">
|
|
|
+ <app-delivery-module ref="appDelivery" @changeAddress="changeAddress" />
|
|
|
+ </block>
|
|
|
|
|
|
<view class="page-btn app-footer">
|
|
|
<view class="flex-center">
|
|
|
@@ -45,17 +36,7 @@
|
|
|
<button class="button-com red" formType="submit">确认</button>
|
|
|
</view>
|
|
|
</form>
|
|
|
- <alert-module :show="showAlert" @click="hideAlert" @cancel="hideAlert">
|
|
|
- <view class="alt-content" v-if="!$util.isEmpty(orderShop)">
|
|
|
- <view>
|
|
|
- <span class="app-price">{{ `${orderShop.freight.first}公里`}}</span>内免运费
|
|
|
- </view>
|
|
|
- <view>
|
|
|
- <span>超过每增加1公里运费加</span>
|
|
|
- <span class="app-price">{{ `${orderShop.freight.add}元` }}</span>
|
|
|
- </view>
|
|
|
- </view>
|
|
|
- </alert-module>
|
|
|
+
|
|
|
</view>
|
|
|
</template>
|
|
|
<script>
|
|
|
@@ -70,7 +51,7 @@ import AlertModule from "@/components/plugin/alert";
|
|
|
const form = require("@/utils/formValidation.js");
|
|
|
import { getShopUser } from "@/utils/auth";
|
|
|
import { getOrderShop } from "@/utils/config";
|
|
|
-import { createOrder } from "@/api/order";
|
|
|
+import { createOrder,freight } from "@/api/order";
|
|
|
import { getUserDistance } from "@/api/express";
|
|
|
export default {
|
|
|
name: "order-buy",
|
|
|
@@ -87,20 +68,16 @@ export default {
|
|
|
return {
|
|
|
goodsInfo: {},
|
|
|
tabIndex: 0,
|
|
|
- tabs: [
|
|
|
- { name: "帮我送" },
|
|
|
- { name: "到店自取" }
|
|
|
- ],
|
|
|
showAlert: false,
|
|
|
form: {
|
|
|
- sendDistance: "", // 配送距离,根据腾讯js进行计算
|
|
|
- goodsId: "", // 【商城下单特有字段】商品id
|
|
|
- goodsStyleId: "", // 【商城下单特有字段】商品款式id
|
|
|
- goodsNum: "", // 【商城下单特有字段】商品数量
|
|
|
- couponId: "0", // 优惠券id,默认0没有使用优惠券
|
|
|
- receiveLat: "", // 收花人纬度
|
|
|
- receiveLong: "", // 收花人经度
|
|
|
- sendType:0
|
|
|
+ sendDistance:"",
|
|
|
+ goodsId: "",
|
|
|
+ goodsStyleId: "",
|
|
|
+ goodsNum: "",
|
|
|
+ couponId: "0",
|
|
|
+ receiveLat: "",
|
|
|
+ receiveLong: "",
|
|
|
+ sendType:2
|
|
|
},
|
|
|
mentionForm: {
|
|
|
bookMobile: ""
|
|
|
@@ -109,7 +86,7 @@ export default {
|
|
|
freightPrice: 0,
|
|
|
goodsNum: 1,
|
|
|
showDistance: 0,
|
|
|
- totalPrice: 0,
|
|
|
+ goodsTotalPrice: 0,
|
|
|
memberDiscount: 1,
|
|
|
couponDiscountAmount: 0
|
|
|
};
|
|
|
@@ -123,13 +100,6 @@ export default {
|
|
|
return parseFloat(price.toFixed(2))
|
|
|
}
|
|
|
},
|
|
|
- watch: {
|
|
|
- //运费变化则总金额和应付金额变化
|
|
|
- freightPrice(newVal) {
|
|
|
- let price = this.goodsInfo.price * this.goodsInfo.buyNum + newVal;
|
|
|
- this.totalPrice = parseFloat(price.toFixed(2))
|
|
|
- }
|
|
|
- },
|
|
|
methods: {
|
|
|
init() {
|
|
|
|
|
|
@@ -141,21 +111,44 @@ export default {
|
|
|
goodsInfo.buyNum = this.option.goodsNum;
|
|
|
this.goodsInfo = goodsInfo;
|
|
|
|
|
|
- this.totalPrice = goodsInfo.price * this.option.goodsNum;
|
|
|
-
|
|
|
- Object.keys(this.form).forEach((i, index) => {
|
|
|
- this.form[i] = this.option[i];
|
|
|
- })
|
|
|
+ this.goodsTotalPrice = goodsInfo.price * this.option.goodsNum;
|
|
|
+ this.goodsTotalPrice = this.goodsTotalPrice.toFixed(2)
|
|
|
+ this.goodsTotalPrice = parseFloat(this.goodsTotalPrice)
|
|
|
|
|
|
},
|
|
|
- tabChange(e) {
|
|
|
- this.tabIndex = e.index;
|
|
|
- if(e.index == 0){
|
|
|
- this.form.sendType =0
|
|
|
- }else{
|
|
|
- this.form.sendType =1
|
|
|
- }
|
|
|
- },
|
|
|
+ changeSendType(num){
|
|
|
+ this.form.sendType = num
|
|
|
+ if(num == 2){
|
|
|
+ //计算运费
|
|
|
+ this.calcFreight()
|
|
|
+ }
|
|
|
+ },
|
|
|
+ calcFreight() {
|
|
|
+ let weight = 0
|
|
|
+ if(!this.$util.isEmpty(this.selectList)){
|
|
|
+ this.selectList.forEach((item,idx,arr) => {
|
|
|
+ if(Number(item.bigCount)>0){
|
|
|
+ let add = Number(item.weight)*Number(item.bigCount)
|
|
|
+ weight = Number(weight) + Number(add)
|
|
|
+ }else{
|
|
|
+ let unitWeight = item.weight/item.ratio
|
|
|
+ let add = Number(unitWeight)*Number(item.smallCount)
|
|
|
+ weight = Number(weight) + Number(add)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ weight = Number(weight).toFixed(2)
|
|
|
+
|
|
|
+ let params = {
|
|
|
+ ghsId: this.options.id,
|
|
|
+ weight:weight
|
|
|
+ };
|
|
|
+ freight(params).then(res => {
|
|
|
+ if(res.code == 1){
|
|
|
+ this.form.sendCost = res.data.fee?parseFloat(res.data.fee):0
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
hideAlert() {
|
|
|
this.showAlert = false;
|
|
|
},
|
|
|
@@ -221,7 +214,6 @@ export default {
|
|
|
|
|
|
<style lang='scss' scoped>
|
|
|
.app-content {
|
|
|
- padding-top: 100upx;
|
|
|
padding-bottom: 160upx;
|
|
|
min-height: calc(100vh - 220upx);
|
|
|
.module-com {
|