下单增加保险展示

This commit is contained in:
TOP糯米 2023-03-09 14:39:48 +08:00
parent febbcb457b
commit 3f85de1f93
6 changed files with 56 additions and 2 deletions

View File

@ -8,7 +8,7 @@
<text class="desc">全面保证您的人身财产安全</text> <text class="desc">全面保证您的人身财产安全</text>
</view> </view>
<view class="switch-container"> <view class="switch-container">
<text class="price">¥ 6.00</text> <text class="price">¥ {{ price }}</text>
<view v-show="showSwitch" class="switch" @click="changeState"> <view v-show="showSwitch" class="switch" @click="changeState">
<widget-switch :open="state" /> <widget-switch :open="state" />
</view> </view>
@ -33,6 +33,10 @@ export default {
type: Boolean, type: Boolean,
default: true, default: true,
}, },
price: {
type: [Number, String],
default: 0,
},
insurance: { insurance: {
type: Boolean, type: Boolean,
default: false, default: false,

View File

@ -76,6 +76,9 @@ export default {
} }
}, },
service: { service: {
insurance: {
url: "/index/getyiwai",
},
aftermarket: { aftermarket: {
url: "/index/category2", url: "/index/category2",
}, },

View File

@ -0,0 +1,17 @@
import Vue from "vue"
let prototype = Vue.prototype;
export default {
getInsurancePrice() {
return new Promise((resolve, reject) => {
prototype.$request({
api: "service.insurance",
}).then((response) => {
if (response.code == 1) {
let money = parseFloat(response.data.money);
resolve(money > 0 ? money : 0)
}
}).catch(e => { });
});
}
}

View File

@ -32,7 +32,7 @@
</view> </view>
</view> </view>
<view class="insurance-box"> <view class="insurance-box">
<service-insurance :insurance="insurance" @change="changeInsuranceState" /> <service-insurance :price="insurancePrice" :insurance="insurance" @change="changeInsuranceState" />
</view> </view>
<view class="demand"> <view class="demand">
<text class="title">留言</text> <text class="title">留言</text>
@ -62,6 +62,7 @@ import ServicePreviewItem from "@/components/service/preview-item";
import Agreement from "@/components/auth/agreement"; import Agreement from "@/components/auth/agreement";
import WidgetTips from "@/components/widgets/tips"; import WidgetTips from "@/components/widgets/tips";
import ServiceInsurance from "@/components/service/insurance"; import ServiceInsurance from "@/components/service/insurance";
import { mapState } from "vuex";
export default { export default {
name: "order-create", name: "order-create",
data() { data() {
@ -96,8 +97,14 @@ export default {
WidgetTips, WidgetTips,
ServiceInsurance, ServiceInsurance,
}, },
computed: {
...mapState({
insurancePrice: (state) => state.service.insurancePrice,
}),
},
onLoad() { onLoad() {
this.pageConfig = getApp().globalData.pageConfig; this.pageConfig = getApp().globalData.pageConfig;
this.$store.dispatch("service/insurancePrice");
}, },
onShow() {}, onShow() {},
onReady() {}, onReady() {},

View File

@ -3,11 +3,13 @@ import Vuex from 'vuex'
import system from "@/store/modules/system" import system from "@/store/modules/system"
import user from "@/store/modules/user" import user from "@/store/modules/user"
import service from "@/store/modules/service"
Vue.use(Vuex) Vue.use(Vuex)
export default new Vuex.Store({ export default new Vuex.Store({
modules: { modules: {
system, system,
user, user,
service,
} }
}) })

View File

@ -0,0 +1,21 @@
import service from "@/core/models/service";
export default {
namespaced: true,
state: {
insurancePrice: 0,
},
getters: {},
mutations: {
insurancePrice(state, data) {
state.insurancePrice = data;
}
},
actions: {
insurancePrice(context) {
service.getInsurancePrice().then(price => {
context.commit('insurancePrice', price);
});
}
}
}