123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458 |
- <template>
- <view>
- <u-navbar title="充电桩设置"></u-navbar>
- <view class="options">
- <u-cell-group>
- <u-cell-item title="开放共享" :arrow="false">
- <view class="">
- <u-radio-group v-model="detail.enableShare" >
- <u-radio v-for="(item, index) in list2" :key="index+'a'" :name="item.value"
- :disabled="item.disabled" active-color="#00b962">
- {{item.name}}
- </u-radio>
- </u-radio-group>
- </view>
- </u-cell-item>
- <u-cell-item title="开放预约" :arrow="false">
- <view class="">
- <u-radio-group v-model="detail.enableAppointment" >
- <u-radio v-for="(item, index) in list2" :key="index+'b'" :name="item.value"
- :disabled="item.disabled" active-color="#00b962">
- {{item.name}}
- </u-radio>
- </u-radio-group>
- </view>
- </u-cell-item>
- <u-cell-item title="预约自动确认" :arrow="false">
- <view class="">
- <u-radio-group v-model="detail.autoConfirm" >
- <u-radio v-for="(item, index) in list2" :key="index+'c'" :name="item.value"
- active-color="#00b962">
- {{item.name}}
- </u-radio>
- </u-radio-group>
- </view>
- </u-cell-item>
-
-
- <u-cell-item :arrow="false" class="time-cell border-bottom" title="允许预约日期">
-
- </u-cell-item>
-
- <view class="" style="padding-left: 16px;">
- <u-checkbox-group shape="square">
-
- <u-checkbox
- v-model="item.checked"
- v-for="(item, index) in weekList" :key="index" :name="item.value"
- :disabled="item.disabled" active-color="#00b962">
-
- {{item.name}}
-
- </u-checkbox>
- </u-checkbox-group>
-
- </view>
-
- <u-picker mode="time" @confirm="confirm" v-model="show"
- :defaultTime="showTime"
- :params="params"></u-picker>
- <u-cell-item title="预约开始时段" :value="detail.shareStartTime" @click="showTimeBtn(0)" ></u-cell-item>
- <u-cell-item title="预约结束时段" :value="detail.shareEndTime" @click="showTimeBtn(1)" ></u-cell-item>
- <u-cell-item :arrow="false" class="time-cell border-bottom" title="预约时长选项">
- </u-cell-item>
- <view class="" style="padding-left: 16px;">
- <u-checkbox-group shape="square">
- <u-checkbox v-for="(item, index) in timeList"
- v-model="item.checked"
- :key="index" :name="item.value"
- :disabled="item.disabled" active-color="#00b962">
- {{item.name}}
- </u-checkbox>
- </u-checkbox-group>
- </view>
- </u-cell-group>
- </view>
- <!-- 底部按钮 -->
- <view class="bottom">
- <!-- <u-button shape='circle' class="refuse-btn">拒绝</u-button>
- <u-button type="success" shape='circle'>确认</u-button> -->
- <!-- 删除订单按钮 -->
- <u-button shape='circle' type="success" @click="submit" >保存</u-button>
- </view>
- </view>
- </template>
- <script>
- import * as API from '@/apis/finance.js'
-
- export default {
- data() {
- return {
- showTimeType:"",
- showTime:"",
- show:false,
- params: {
- year: false,
- month: false,
- day: false,
- hour: true,
- minute: true,
- second: false
- },
-
- detail:{
-
- },
-
- list2: [{
- value:"1",
- name: "是"
- },
- {
- value:"0",
- name: "否"
- }
- ],
- weekList: [
- {
- value:"1",
- name: "周一"
- },
- {
- value:"2",
- name: "周二"
- },
- {
- value:"3",
- name: "周三"
- },
-
- {
- value:"4",
- name: "周四"
- },
- {
- value:"5",
- name: "周五"
- },
- {
- value:"6",
- name: "周六"
- },
-
- {
- value:"7",
- name: "周日"
- }
- ],
- timeList: [
- {
- value:"10",
- name: "10分钟"
- },
- {
- value:"20",
- name: "20分钟"
- },
- {
- value:"30",
- name: "30分钟"
- }
- ]
- }
- },
- onLoad(op){
-
- this.id=op.id;
- this.getInfo()
- },
- methods: {
- confirm(e){
-
- var type=this.showTimeType;
- var time=e.hour+":"+e.minute;
- if(type==0){
-
- if(this.detail.shareEndTime){
- var time1=new Date("2020-1-1 "+time)
- var time2=new Date("2020-1-1 "+this.detail.shareEndTime)
- if(time1>time2){
- this.detail.shareEndTime=null;
- }
- }
- this.detail.shareStartTime=time
- }
- if(type==1){
-
- if(this.detail.shareStartTime){
- var time1=new Date("2020-1-1 "+time)
- var time2=new Date("2020-1-1 "+this.detail.shareStartTime)
- if(time1<time2){
- uni.showToast({
- title:"结束时间不可小于开始时间"
- })
- return
- }
- }
-
- this.detail.shareEndTime=time
- }
- },
- showTimeBtn(type){
- this.showTimeType=type;
- console.log(type)
- if(type=="0"){
- this.showTime=this.detail.shareStartTime
- }
- if(type=="1"){
- this.showTime=this.detail.shareEndTime
- }
- this.show=true;
- },
- submit(){
-
- var sz=[]
- for(var i in this.weekList){
- var item=this.weekList[i]
- if(item.checked){
- sz.push(item.value)
- }
- }
- var weekDay=sz.join();
-
-
- var sz2=[]
- for(var i in this.timeList){
- var item=this.timeList[i]
- if(item.checked){
- sz2.push(item.value)
- }
- }
- var reserveMinutes=sz2.join();
- var weekTime=[this.detail.shareStartTime,this.detail.shareEndTime]
- if(this.detail.enableAppointment){
- if(weekDay==""){
- uni.showToast({
- title:"开放预约功能需要选择预约日期"
- })
- return
- }
- this.detail.weekDay=weekDay
-
-
-
- this.detail.reserveMinutes=reserveMinutes
- if(!weekTime[0]){
- uni.showToast({
- title:"开放预约功能需要预约开始时间"
- })
- return
- }
- if(!weekTime[1]){
- uni.showToast({
- title:"开放预约功能需要预约结束时间"
- })
- return
- }
- if(reserveMinutes==""){
- uni.showToast({
- title:"开放预约功能需要选择预约时长"
- })
- return
- }
- this.detail.weekTime=weekTime
- console.log( this.detail )
- }
-
- uni.showLoading({
- title:"加载中",mask:true,
- })
- API.saveGunShare(this.detail).then((res) => {
-
- uni.hideLoading()
- uni.showToast({
- title:"操作成功"
- })
- }).catch(error => {
- uni.showToast({
-
- title:error
- })
- })
- },
- getInfo(){
- uni.showLoading({
- title:"加载中",mask:true,
- })
- API.gunShareDetail({
- gunId:this.id
- }).then((res) => {
- this.detail={};
- var obj=res.data.gunShare;
- for(var i in obj){
-
- if(obj[i]===true){
- this.detail[i]="1";
- }else if(obj===false){
- this.detail[i]="0";
- }else {
- this.detail[i]=obj[i];
- }
- }
- if(this.detail.reserveMinutes){
- var sz=this.detail.reserveMinutes.split(",")
- for(var i in this.timeList){
- var item=this.timeList[i]
-
- if(sz.indexOf(item.value)!=-1){
- item.checked=true;
- }
- }
- }
-
- if(this.detail.shareWeekDay){
- var sz=this.detail.shareWeekDay.split(",")
- for(var i in this.weekList){
- var item=this.weekList[i]
-
- if(sz.indexOf(item.value)!=-1){
- item.checked=true;
- }
- }
- }
-
- console.log(this.detail)
- uni.hideLoading()
-
- }).catch(error => {
- uni.showToast({
-
- title:error
- })
- })
- }
- }
- }
- </script>
- <style lang="scss">
- /deep/.u-cell_title {
- width: 30% !important;
- }
- /deep/ .u-cell {
- line-height: 20px;
- padding: 12px 20px 12px 0;
- margin-left: 12px;
- }
- /deep/.u-radio-group {
- justify-content: start !important;
- }
- /deep/.u-radio-group:last-child {
- justify-content: space-between !important;
- padding: 0 0 10px 0px;
- }
- /deep/.u-cell__value {
- text-align: left;
- color: #101010;
- font-size: 16px
- }
- /deep/.u-radio-group {
- line-height: 30px;
- width: 100%;
- display: flex;
- justify-content: space-around;
- }
- /deep/.border-bottom:after {
- border-bottom-width: 0px !important;
- }
-
-
- // 按钮
- .bottom{
- width: 100%;
- height: 56px;
- position: fixed;
- bottom: 0;
- background-color: #fff;
- display: flex;
- .refuse-btn{
- background-color: #DBDBDB;
- }
- .u-btn{
- width: 91.4%;
- height: 40px;
- margin: auto;
- font-size: 18px;
-
- }
- .cancel-btn{
- width: 91.4%;
- background-color: #dbdbdb;
- color: #666666
- }
- }
- </style>
|