下单增加保险展示

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>
</view>
<view class="switch-container">
<text class="price">¥ 6.00</text>
<text class="price">¥ {{ price }}</text>
<view v-show="showSwitch" class="switch" @click="changeState">
<widget-switch :open="state" />
</view>
@ -33,6 +33,10 @@ export default {
type: Boolean,
default: true,
},
price: {
type: [Number, String],
default: 0,
},
insurance: {
type: Boolean,
default: false,

View File

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

View File

@ -3,11 +3,13 @@ import Vuex from 'vuex'
import system from "@/store/modules/system"
import user from "@/store/modules/user"
import service from "@/store/modules/service"
Vue.use(Vuex)
export default new Vuex.Store({
modules: {
system,
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);
});
}
}
}