chuangte_bike_newxcx/page_shanghu/gongzuotai/ChargingTemplate.vue
2025-04-16 09:14:52 +08:00

397 lines
9.5 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<view class="page">
<u-navbar title="模板管理" :border-bottom="false" :background="bgc" title-color='#000' title-size='36'
height='45'></u-navbar>
<view class="modelCard" v-for="(item,index) in list" :key="index">
<view class="tit">
<view class="">
{{item.name}}
</view>
<view class="">
<u-switch v-model="item.status == 0 ? true : false" @change="change(item)"></u-switch>
</view>
</view>
<view class="line"></view>
<view class="info">
<view class="lis">
<view class="info_li">
说明:<span>{{item.instructions == null ? '--' : item.instructions}}</span>
</view>
<view>
<view v-if="item.ridingRule==1">
<view class="card" style="width: 100%;">
<view class="li info_li" style="display: flex;flex-wrap: nowrap;">
<view class="left">
起步价:
</view>
<view class="right">
{{item.startRule.startingPrice}}元(含{{item.startRule.startingTime}}<span
v-if="item.rentalUnit=='minutes'">分钟</span><span
v-if="item.rentalUnit=='hours'">小时</span><span
v-if="item.rentalUnit=='day'">天</span>
</view>
</view>
<view class="li info_li" style="display: flex;flex-wrap: nowrap;">
<view class="left">
时长费:
</view>
<view class="right">
{{item.startRule.timeoutPrice}}元/{{ item.startRule.timeoutTime}}<span
v-if="item.rentalUnit=='minutes'">分钟</span><span
v-if="item.rentalUnit=='hours'">小时</span><span
v-if="item.rentalUnit=='day'">天</span>
</view>
</view>
</view>
</view>
<view v-if="item.ridingRule==2">
<view class="tit" style="margin-top: 50rpx;">
{{item.name}}
</view>
<view class="card">
<view class="li" style="margin-top: 10rpx;"
v-for="(items,indexs) in item.startRule.rule"
v-if="indexs!=item.startRule.rule.length-1">
<view class="left" v-if="indexs==0">
区间计费
</view>
<view class="left" v-if="indexs!=0">
</view>
<view class="right">
{{items.start}}-{{items.end}}<span
v-if="item.rentalUnit=='minutes'">分钟</span>
<span v-if="item.rentalUnit=='hours'">小时</span>
<span v-if="item.rentalUnit=='day'">天</span>,
每{{items.eachUnit}}<span v-if="item.rentalUnit=='minutes'">分钟</span>
<span v-if="item.rentalUnit=='hours'">小时</span>
<span v-if="item.rentalUnit=='day'">天</span>/{{items.fee}}元
</view>
</view>
<view class="li" style="margin-top: 10rpx;"
v-for="(items,indexs) in item.startRule.rule"
v-if="indexs==item.startRule.rule.length-1">
<view class="left">
</view>
<view class="right">
>{{items.start}}<span v-if="item.rentalUnit=='minutes'">分钟</span>
<span v-if="item.rentalUnit=='hours'">小时</span>
<span v-if="item.rentalUnit=='day'">天</span>,
每{{items.eachUnit}}<span v-if="item.rentalUnit=='minutes'">分钟</span>
<span v-if="item.rentalUnit=='hours'">小时</span>
<span v-if="item.rentalUnit=='day'">天</span>/{{items.fee}}元
</view>
</view>
</view>
<view class="tips">
<view class="yuan">
</view>
<view class="txt">
区间计费是在使用车辆时时,不同时段内的收费标准
</view>
</view>
</view>
</view>
<!-- <view class="info_li">
运营区外调度费:<span>{{item.dispatchFee}}KM</span>
</view>
<view class="info_li">
停车点外调度费:<span>{{item.vehicleManagementFee}}KM</span>
</view>
-->
</view>
</view>
<!-- <view class="txt_li">
<view class="li">
所属门店:<span>云行租车</span>
</view>
<view class="li">
满电续航:<span>50.00km</span>
</view>
</view> -->
<view class="line" ></view>
<view class="btn_li">
<view class="btn1" @click="del(item)">
删除
</view>
<view class="btn2" @click="todetail(item)">
编辑
</view>
</view>
</view>
<view class="" style="width: 100%;text-align: center;color: #ccc;margin-top: 30rpx;">
当前没有更多模版咯...
</view>
<view class="btn" @click="addmodel()">
新增模板
</view>
</view>
</template>
<script>
export default {
data() {
return {
bgc: {
backgroundColor: "#fff",
},
list: [],
}
},
onShow() {
this.getModelList()
},
methods: {
// 停用按钮
change(item){
console.log(item);
let data = {
id:item.id,
status:item.status == 0 ? 1 : 0
}
this.$u.put(`/bst/suit`,data).then(res =>{
if(res.code == 200){
uni.showToast({
title: '操作成功',
icon: 'success',
duration:2000
})
this.getModelList()
}else{
uni.showToast({
title: res.msg,
icon: 'none',
duration:2000
})
}
})
},
addmodel() {
uni.navigateTo({
url: '/page_shanghu/gongzuotai/ChargingDetail'
})
},
del(item) {
// 显示确认删除的提示框
uni.showModal({
title: '确认删除',
content: '确定删除该收费方式?',
success: (res) => {
if (res.confirm) {
// 如果用户点击了确认,执行删除操作
this.$u.delete(`/bst/suit/${item.id}`).then((res) => {
if (res.code == 200) {
this.getModelList(); // 刷新列表
} else {
// 处理接口返回错误的情况
uni.showToast({
title: res.msg,
icon: 'none',
duration:2000
});
}
})
} else if (res.cancel) {
// 用户取消删除操作
console.log('取消删除')
}
}
});
},
todetail(item) {
uni.navigateTo({
url: '/page_shanghu/gongzuotai/ChargingDetail?ruleId=' + item.id
})
},
getModelList() {
this.$u.get(`/bst/suit/list?pageNum=1&pageSize=999`).then((res) => {
if (res.code == 200) {
this.list = res.rows.map(item => {
try {
item.startRule = item.startRule
} catch (e) {
console.error('Invalid JSON in startRule:', item.startRule)
}
return item
})
} else {
uni.showToast({
title: res.msg,
icon: 'none',
duration:2000
})
}
})
},
}
}
</script>
<style lang="scss" scoped>
page {
background-color: #f8f9fa;
}
.page {
padding: 24rpx;
padding-bottom: 170rpx;
background-color: #f8f9fa;
.modelCard {
margin-bottom: 20rpx;
background: #FFFFFF;
border-radius: 16rpx;
box-shadow: 0 4rpx 24rpx rgba(0, 0, 0, 0.04);
overflow: hidden;
transition: all 0.3s ease;
&:active {
transform: scale(0.98);
}
.tit {
padding: 20rpx;
font-weight: 600;
font-size: 36rpx;
color: #1a1a1a;
border-bottom: 1rpx solid #f0f0f0;
display: flex;
justify-content: space-between;
align-items: center;
}
.info {
padding: 20rpx;
.lis {
.info_li {
margin-bottom: 10rpx;
margin-top: 10rpx;
font-size: 28rpx;
color: #666;
line-height: 1.6;
span {
color: #333;
font-weight: 500;
}
}
}
}
.card {
background: #f9fafb;
border-radius: 12rpx;
padding:10rpx 20rpx;
box-sizing: border-box;
.li {
display: flex;
align-items: center;
font-size: 26rpx;
color: #555;
.left {
width: 160rpx;
font-weight: 500;
color: #333;
}
.right {
flex: 1;
color: #666;
}
}
}
.tips {
display: flex;
align-items: center;
margin-top: 16rpx;
padding: 16rpx;
background: #f0f7ff;
border-radius: 8rpx;
.yuan {
width: 16rpx;
height: 16rpx;
background: #4C97E7;
border-radius: 50%;
margin-right: 12rpx;
}
.txt {
font-size: 24rpx;
color: #4C97E7;
}
}
.btn_li {
display: flex;
border-top: 1rpx solid #f0f0f0;
.btn1, .btn2 {
flex: 1;
height: 96rpx;
display: flex;
align-items: center;
justify-content: center;
font-size: 32rpx;
font-weight: 500;
transition: all 0.2s ease;
&:active {
opacity: 0.8;
}
}
.btn1 {
color: #ff4d4f;
border-right: 1rpx solid #f0f0f0;
}
.btn2 {
color: #4C97E7;
}
}
}
.no-more {
padding: 20rpx 0;
font-size: 28rpx;
color: #999;
text-align: center;
}
.btn {
position: fixed;
left: 50%;
bottom: 48rpx;
transform: translateX(-50%);
width: 90%;
height: 96rpx;
background: linear-gradient(90deg, #4C97E7, #6ab0ff);
border-radius: 48rpx;
display: flex;
align-items: center;
justify-content: center;
color: #fff;
font-size: 36rpx;
font-weight: 500;
box-shadow: 0 8rpx 24rpx rgba(76, 151, 231, 0.3);
transition: all 0.2s ease;
&:active {
transform: translateX(-50%) scale(0.98);
}
}
}
</style>