|
@ -2,24 +2,37 @@ |
|
|
<view class="deduction-popup"> |
|
|
<view class="deduction-popup"> |
|
|
<popup-template |
|
|
<popup-template |
|
|
title="充值时长" |
|
|
title="充值时长" |
|
|
:show="show" |
|
|
|
|
|
|
|
|
:show="isShow" |
|
|
|
|
|
@click:close="hide" |
|
|
> |
|
|
> |
|
|
<view class="rp-container"> |
|
|
<view class="rp-container"> |
|
|
<kv-line label="水阀卡卡号:">20195171564566</kv-line> |
|
|
|
|
|
<kv-line label="手机号码:">18316466456</kv-line> |
|
|
|
|
|
<kv-line label="可用时长:"><text class="rc-orange">100分00秒</text></kv-line> |
|
|
|
|
|
|
|
|
<kv-line label="水阀卡卡号:">{{ initData.water_card_no || '-' }}</kv-line> |
|
|
|
|
|
<kv-line label="手机号码:">{{ initData.mobile || '-' }}</kv-line> |
|
|
|
|
|
<kv-line label="可用时长:"><text class="rc-orange">{{ initData.valid_duration_text || '-' }}</text></kv-line> |
|
|
<view class="rc-space"></view> |
|
|
<view class="rc-space"></view> |
|
|
<number-edit label="扣减时长"></number-edit> |
|
|
|
|
|
|
|
|
<number-edit label="扣减时长" v-model="editData.deductDuration"></number-edit> |
|
|
|
|
|
<view class="rc-time-select"> |
|
|
|
|
|
<view class="rts-name">开始日期</view> |
|
|
|
|
|
<picker mode="date" :value="editData.sDate" @change="sDateChange"> |
|
|
|
|
|
<input disabled type="text" v-model="editData.sDate" class="rts-ipt" placeholder="开始日期"> |
|
|
|
|
|
</picker> |
|
|
|
|
|
</view> |
|
|
<view class="rc-time-select"> |
|
|
<view class="rc-time-select"> |
|
|
<view class="rts-name">开始时间</view> |
|
|
<view class="rts-name">开始时间</view> |
|
|
<picker> |
|
|
|
|
|
<input disabled type="text" class="rts-ipt" placeholder="开始时间"> |
|
|
|
|
|
|
|
|
<picker mode="multiSelector" :range="timePickerList" :value="editData.sTime" @change="sTimeChange"> |
|
|
|
|
|
<input disabled type="text" v-model="editData.sTime" class="rts-ipt" placeholder="开始时间"> |
|
|
|
|
|
</picker> |
|
|
|
|
|
</view> |
|
|
|
|
|
<view class="rc-time-select"> |
|
|
|
|
|
<view class="rts-name">结束日期</view> |
|
|
|
|
|
<picker mode="date" :value="editData.eDate" @change="eDateChange"> |
|
|
|
|
|
<input disabled type="text" v-model="editData.eDate" class="rts-ipt" placeholder="结束日期"> |
|
|
</picker> |
|
|
</picker> |
|
|
</view> |
|
|
</view> |
|
|
<view class="rc-time-select"> |
|
|
<view class="rc-time-select"> |
|
|
<view class="rts-name">结束时间</view> |
|
|
<view class="rts-name">结束时间</view> |
|
|
<picker> |
|
|
|
|
|
<input disabled type="text" class="rts-ipt" placeholder="结束时间"> |
|
|
|
|
|
|
|
|
<picker mode="multiSelector" :range="timePickerList" :value="editData.eTime" @change="eTimeChange"> |
|
|
|
|
|
<input disabled type="text" v-model="editData.eTime" class="rts-ipt" placeholder="结束时间"> |
|
|
</picker> |
|
|
</picker> |
|
|
</view> |
|
|
</view> |
|
|
<textarea class="rc-remark" placeholder="备注(选填)"></textarea> |
|
|
<textarea class="rc-remark" placeholder="备注(选填)"></textarea> |
|
@ -33,15 +46,131 @@ |
|
|
import popup_template from "./template.vue"; |
|
|
import popup_template from "./template.vue"; |
|
|
import kv_line from "@/components/kv_line.vue"; |
|
|
import kv_line from "@/components/kv_line.vue"; |
|
|
import number_edit from "../number_edit.vue"; |
|
|
import number_edit from "../number_edit.vue"; |
|
|
|
|
|
import { formatDate, formatNumber, formatTime, showNone } from "@/utils/util"; |
|
|
export default { |
|
|
export default { |
|
|
components: { |
|
|
components: { |
|
|
'popup-template': popup_template, |
|
|
'popup-template': popup_template, |
|
|
'kv-line': kv_line, |
|
|
'kv-line': kv_line, |
|
|
'number-edit': number_edit |
|
|
'number-edit': number_edit |
|
|
}, |
|
|
}, |
|
|
|
|
|
watch: { |
|
|
|
|
|
'editData.deductDuration': { |
|
|
|
|
|
handler(nVal, oVal){ |
|
|
|
|
|
this.initDeductTime(); |
|
|
|
|
|
}, |
|
|
|
|
|
deep: true |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
data(){ |
|
|
data(){ |
|
|
return { |
|
|
return { |
|
|
show: true |
|
|
|
|
|
|
|
|
isShow: false, |
|
|
|
|
|
timePickerList: this.getTimePickerList(), |
|
|
|
|
|
initData: { |
|
|
|
|
|
/** |
|
|
|
|
|
* @param {String} water_card_no |
|
|
|
|
|
* @param {String} mobile |
|
|
|
|
|
* @param {String} valid_duration_text |
|
|
|
|
|
* @param {Number} valid_duration |
|
|
|
|
|
* @param {Function} success |
|
|
|
|
|
* */ |
|
|
|
|
|
}, |
|
|
|
|
|
editData: { |
|
|
|
|
|
deductDuration: 10, |
|
|
|
|
|
sDate: '', |
|
|
|
|
|
eDate: '', |
|
|
|
|
|
sTime: '', |
|
|
|
|
|
eTime: '', |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
|
|
|
methods: { |
|
|
|
|
|
sDateChange(e){ |
|
|
|
|
|
if(!this.isCorrectTimeScope({ sDate: e.detail.value }))return; |
|
|
|
|
|
this.editData.sDate = e.detail.value; |
|
|
|
|
|
this.getDeductDurationForTimeChange({}); |
|
|
|
|
|
}, |
|
|
|
|
|
sTimeChange(e){ |
|
|
|
|
|
let { timePickerList, editData } = this; |
|
|
|
|
|
let _timeStr = this.getPickerTimeStr(e.detail.value, timePickerList); |
|
|
|
|
|
if(!this.isCorrectTimeScope({ sTime: _timeStr }))return; |
|
|
|
|
|
this.editData.sTime = _timeStr; |
|
|
|
|
|
this.getDeductDurationForTimeChange({}); |
|
|
|
|
|
}, |
|
|
|
|
|
eDateChange(e){ |
|
|
|
|
|
if(!this.isCorrectTimeScope({ eDate: e.detail.value }))return; |
|
|
|
|
|
this.editData.eDate = e.detail.value; |
|
|
|
|
|
this.getDeductDurationForTimeChange({}); |
|
|
|
|
|
}, |
|
|
|
|
|
eTimeChange(e){ |
|
|
|
|
|
let { timePickerList } = this; |
|
|
|
|
|
let _timeStr = this.getPickerTimeStr(e.detail.value, timePickerList); |
|
|
|
|
|
if(!this.isCorrectTimeScope({ eTime: _timeStr }))return; |
|
|
|
|
|
this.editData.eTime = _timeStr; |
|
|
|
|
|
this.getDeductDurationForTimeChange({}); |
|
|
|
|
|
}, |
|
|
|
|
|
getDeductDurationForTimeChange(){ |
|
|
|
|
|
let { sDate, sTime, eDate, eTime } = this.editData; |
|
|
|
|
|
let _startStr = `${sDate} ${sTime}`; |
|
|
|
|
|
let _endStr = `${eDate} ${eTime}`; |
|
|
|
|
|
let _startStamp = new Date(this.getCalDate(_startStr)).getTime(); |
|
|
|
|
|
let _endStamp = new Date(this.getCalDate(_endStr)).getTime(); |
|
|
|
|
|
this.editData.deductDuration = (_endStamp - _startStamp) / 1000 / 60; |
|
|
|
|
|
}, |
|
|
|
|
|
isCorrectTimeScope({ |
|
|
|
|
|
sDate = '', sTime = '', eDate = '', eTime = '' |
|
|
|
|
|
}){ |
|
|
|
|
|
let _sDate = sDate || this.editData.sDate; |
|
|
|
|
|
let _sTime = sTime || this.editData.sTime; |
|
|
|
|
|
let _eDate = eDate || this.editData.eDate; |
|
|
|
|
|
let _eTime = eTime || this.editData.eTime; |
|
|
|
|
|
let _startStr = `${_sDate} ${_sTime}`; |
|
|
|
|
|
let _endStr = `${_eDate} ${_eTime}`; |
|
|
|
|
|
let _startStamp = new Date(this.getCalDate(_startStr)).getTime(); |
|
|
|
|
|
let _endStamp = new Date(this.getCalDate(_endStr)).getTime(); |
|
|
|
|
|
if(_startStamp >= _endStamp){ |
|
|
|
|
|
showNone('开始时间不能大于结束时间!'); |
|
|
|
|
|
return false; |
|
|
|
|
|
}else{ |
|
|
|
|
|
return true; |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
|
|
|
getPickerTimeStr(value = [], pickList = []){ |
|
|
|
|
|
let [ _hourList, _minuteList, _secondList ] = pickList; |
|
|
|
|
|
let [ _hour, _minute, _second ] = value; |
|
|
|
|
|
return `${_hourList[_hour]}:${_minuteList[_minute]}:${_secondList[_second]}`; |
|
|
|
|
|
}, |
|
|
|
|
|
getCalDate(dateStr){ |
|
|
|
|
|
return dateStr.replace(/\-/g, '/') || ''; |
|
|
|
|
|
}, |
|
|
|
|
|
initDeductTime(){ |
|
|
|
|
|
let { deductDuration, sDate, sTime } = this.editData; |
|
|
|
|
|
let _startStr = `${this.getCalDate(sDate)} ${sTime}`; |
|
|
|
|
|
let _curDate = _startStr === ' ' ? new Date() : new Date(_startStr); |
|
|
|
|
|
let _curTimeStamp = _curDate.getTime(); |
|
|
|
|
|
let _deductLaterTimeStamp = _curTimeStamp + deductDuration * 60 * 1000; |
|
|
|
|
|
let _startArr = formatTime(new Date(_curTimeStamp)).split(' '); |
|
|
|
|
|
let _endStr = formatTime(new Date(_deductLaterTimeStamp)).split(' '); |
|
|
|
|
|
this.editData.sDate = _startArr[0]; |
|
|
|
|
|
this.editData.sTime = _startArr[1]; |
|
|
|
|
|
this.editData.eDate = _endStr[0]; |
|
|
|
|
|
this.editData.eTime = _endStr[1]; |
|
|
|
|
|
}, |
|
|
|
|
|
getTimePickerList(){ |
|
|
|
|
|
let _hourList = new Array(24).fill(0).map((e, i) => formatNumber(i)); |
|
|
|
|
|
let _minuteList = new Array(60).fill(0).map((e, i) => formatNumber(i)); |
|
|
|
|
|
let _secondList = new Array(60).fill(0).map((e, i) => formatNumber(i)); |
|
|
|
|
|
return [_hourList, _minuteList, _secondList]; |
|
|
|
|
|
}, |
|
|
|
|
|
init(data){ |
|
|
|
|
|
this.initData = data || {}; |
|
|
|
|
|
this.show(); |
|
|
|
|
|
this.initDeductTime(); |
|
|
|
|
|
}, |
|
|
|
|
|
show(){ |
|
|
|
|
|
this.isShow = true; |
|
|
|
|
|
}, |
|
|
|
|
|
hide(){ |
|
|
|
|
|
this.isShow = false; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -66,7 +195,7 @@ export default { |
|
|
.rts-ipt{ |
|
|
.rts-ipt{ |
|
|
display: block; |
|
|
display: block; |
|
|
box-sizing: border-box; |
|
|
box-sizing: border-box; |
|
|
padding: 10upx 30upx; |
|
|
|
|
|
|
|
|
padding: 0upx 30upx; |
|
|
width: 358upx; |
|
|
width: 358upx; |
|
|
height: 56upx; |
|
|
height: 56upx; |
|
|
border-radius: 10upx; |
|
|
border-radius: 10upx; |
|
|