|
|
@@ -15,15 +15,33 @@
|
|
|
|
|
|
<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 == 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">
|
|
|
+ <block v-if="form.sendType == 2">
|
|
|
<app-delivery-module ref="appDelivery" @changeAddress="changeAddress" />
|
|
|
</block>
|
|
|
+ <block v-if="form.sendType == 1">
|
|
|
+ <view class="module-com input-line-wrap">
|
|
|
+ <tui-list-cell class="line-cell" :hover="false">
|
|
|
+ <view class="tui-title">手机号</view>
|
|
|
+ <input v-model="bookMobile" placeholder-class="phcolor" class="tui-input" name="bookMobile" placeholder="请输入手机号" maxlength="50" type="text" />
|
|
|
+ </tui-list-cell>
|
|
|
+ </view>
|
|
|
+ </block>
|
|
|
+
|
|
|
+ <view class="module-com input-line-wrap" v-if="form.sendType == 2">
|
|
|
+ <tui-list-cell class="line-cell" :hover="false">
|
|
|
+ <view class="tui-title">距离</view>
|
|
|
+ <view class="tui-input">{{ showDistance }}公里</view>
|
|
|
+ </tui-list-cell>
|
|
|
+ <tui-list-cell class="line-cell" :hover="false">
|
|
|
+ <view class="tui-title">运费</view>
|
|
|
+ <view class="tui-input">¥{{ freightPrice?parseFloat(freightPrice):0 }}</view>
|
|
|
+ </tui-list-cell>
|
|
|
+ </view>
|
|
|
+ <view style="height:90upx;"> </view>
|
|
|
|
|
|
<view class="page-btn app-footer">
|
|
|
<view class="flex-center">
|
|
|
@@ -48,13 +66,12 @@ import AppTrademark from "@/components/module/app-trademark";
|
|
|
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");
|
|
|
import { getShopUser } from "@/utils/auth";
|
|
|
import { getOrderShop } from "@/utils/config";
|
|
|
import { createOrder,freight } from "@/api/order";
|
|
|
import { getUserDistance } from "@/api/express";
|
|
|
export default {
|
|
|
- name: "order-buy",
|
|
|
+ name: "buy",
|
|
|
components: {
|
|
|
AppTabs,
|
|
|
AppDeliveryModule,
|
|
|
@@ -79,16 +96,14 @@ export default {
|
|
|
receiveLong: "",
|
|
|
sendType:2
|
|
|
},
|
|
|
- mentionForm: {
|
|
|
- bookMobile: ""
|
|
|
- },
|
|
|
discountArr: false,
|
|
|
freightPrice: 0,
|
|
|
goodsNum: 1,
|
|
|
showDistance: 0,
|
|
|
goodsTotalPrice: 0,
|
|
|
memberDiscount: 1,
|
|
|
- couponDiscountAmount: 0
|
|
|
+ couponDiscountAmount: 0,
|
|
|
+ bookMobile:''
|
|
|
};
|
|
|
},
|
|
|
mounted() {},
|
|
|
@@ -96,7 +111,8 @@ export default {
|
|
|
...mapGetters({ orderShop: "getOrderShop" }),
|
|
|
...mapGetters({ shopUser: "getShopUser" }),
|
|
|
mayPayAmount(){
|
|
|
- let price = (this.goodsInfo.price * this.goodsInfo.buyNum + this.freightPrice) * this.memberDiscount - this.couponDiscountAmount
|
|
|
+ let price = this.goodsInfo.price * this.goodsInfo.buyNum
|
|
|
+ price = Number(this.freightPrice)+Number(price)
|
|
|
return parseFloat(price.toFixed(2))
|
|
|
}
|
|
|
},
|
|
|
@@ -111,6 +127,9 @@ export default {
|
|
|
goodsInfo.buyNum = this.option.goodsNum;
|
|
|
this.goodsInfo = goodsInfo;
|
|
|
|
|
|
+ this.form.goodsId = this.option.goodsId
|
|
|
+ this.form.goodsNum = this.option.goodsNum
|
|
|
+
|
|
|
this.goodsTotalPrice = goodsInfo.price * this.option.goodsNum;
|
|
|
this.goodsTotalPrice = this.goodsTotalPrice.toFixed(2)
|
|
|
this.goodsTotalPrice = parseFloat(this.goodsTotalPrice)
|
|
|
@@ -119,66 +138,24 @@ export default {
|
|
|
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)
|
|
|
- }
|
|
|
- })
|
|
|
+ this.changeAddress()
|
|
|
}
|
|
|
- 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;
|
|
|
- },
|
|
|
- //计算客户距离和运费
|
|
|
- changeAddress(e) {
|
|
|
+ changeAddress() {
|
|
|
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.freightPrice = res.data.fee?parseFloat(res.data.fee):0;
|
|
|
this.showDistance = res.data.showDistance;
|
|
|
});
|
|
|
},
|
|
|
formSubmit(e) {
|
|
|
- let rules = [];
|
|
|
- let formData = e.detail.value;
|
|
|
- let checkRes = form.validation(formData, rules);
|
|
|
- if (!checkRes) {
|
|
|
- this.createOrderFn()
|
|
|
- } else {
|
|
|
- this.$msg(checkRes);
|
|
|
- }
|
|
|
+ this.createOrderFn()
|
|
|
},
|
|
|
createOrderFn() {
|
|
|
- let addForm = {};
|
|
|
- let form = this.tabIndex == 0 ? this.$refs.appDelivery.form : this.mentionForm
|
|
|
- let region = this.tabIndex == 0 ? this.$refs.appDelivery.region : {};
|
|
|
- if (this.$refs.couponSel) {
|
|
|
- addForm.couponId = this.$refs.couponSel.couponId;
|
|
|
- }
|
|
|
- if (this.tabIndex == 0) {
|
|
|
+ let form = {}
|
|
|
+ if (this.form.sendType == 2) {
|
|
|
+ form = this.$refs.appDelivery.form
|
|
|
let receiveUserName = form.receiveUserName;
|
|
|
if (this.$util.isEmpty(receiveUserName)) {
|
|
|
this.$msg("请填写收花人姓名");
|
|
|
@@ -189,10 +166,9 @@ export default {
|
|
|
this.$msg("请填写收花人电话");
|
|
|
return false;
|
|
|
}
|
|
|
- let reachDate = form.reachDate;
|
|
|
let address = form.address;
|
|
|
if (this.$util.isEmpty(address)) {
|
|
|
- this.$msg("请填写地址!");
|
|
|
+ this.$msg("请填写地址");
|
|
|
return false;
|
|
|
}
|
|
|
let bookMobile = form.bookMobile;
|
|
|
@@ -200,9 +176,19 @@ export default {
|
|
|
this.$msg("请填写订花人电话");
|
|
|
return false;
|
|
|
}
|
|
|
+ }else{
|
|
|
+ if(this.$util.isEmpty(this.bookMobile)){
|
|
|
+ this.$msg('请填写手机号')
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ if(this.$util.checkMobile(this.bookMobile) == false){
|
|
|
+ this.$msg('手机号填写错误')
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ form = {bookMobile:this.bookMobile}
|
|
|
}
|
|
|
uni.showLoading({mask:true})
|
|
|
- createOrder({ needSend: this.tabIndex == 0 ? "1" : "0", ...form, ...this.form, ...addForm, ...region }).then(res => {
|
|
|
+ createOrder({...form, ...this.form}).then(res => {
|
|
|
uni.hideLoading()
|
|
|
uni.removeStorageSync("buyGoodsDetil")
|
|
|
this.$util.pageTo({ url: "/pages/callback/index", type: 2, query: { pageStatus: 1, ...res.data } })
|
|
|
@@ -211,11 +197,11 @@ export default {
|
|
|
}
|
|
|
};
|
|
|
</script>
|
|
|
-
|
|
|
<style lang='scss' scoped>
|
|
|
.app-content {
|
|
|
- padding-bottom: 160upx;
|
|
|
+ padding-bottom: 220upx;
|
|
|
min-height: calc(100vh - 220upx);
|
|
|
+ margin-bottom:100upx;
|
|
|
.module-com {
|
|
|
margin-bottom: 20upx;
|
|
|
background-color: #fff;
|