修复倒计时bug会被取消的bug
This commit is contained in:
parent
1a61a73237
commit
1545bf867f
@ -151,7 +151,6 @@
|
||||
</u-form-item>
|
||||
</block>
|
||||
</u--form>
|
||||
|
||||
</view>
|
||||
</template>
|
||||
|
||||
|
@ -71,8 +71,14 @@
|
||||
this.id = options.id;
|
||||
this.initCompany();
|
||||
this.initContractTypeList();
|
||||
let time = uni.getStorageSync('ctime' + this.id);
|
||||
if(time>0&&(time - Date.now())/1000>0){
|
||||
this.startTimer((time - Date.now())/1000);
|
||||
}
|
||||
},
|
||||
onUnload() {
|
||||
if(this.timerCount>0) uni.setStorageSync('ctime'+this.id, this.timerCount*1000+Date.now());
|
||||
},
|
||||
onShow() {},
|
||||
computed: {
|
||||
cTimerCount() {
|
||||
return this.timerCount;
|
||||
@ -129,14 +135,7 @@
|
||||
});
|
||||
this.initCompany();
|
||||
if (this.userInfo.contract.check_status == 3) {
|
||||
this.timerCount = 60;
|
||||
this.timer = setInterval(() => {
|
||||
this.timerCount--;
|
||||
if (this.timerCount == 0) {
|
||||
clearInterval(this.timer);
|
||||
this.initCompany();
|
||||
}
|
||||
}, 1000);
|
||||
this.startTimer();
|
||||
}
|
||||
uni.hideLoading();
|
||||
Toast('合同已发送');
|
||||
@ -149,14 +148,7 @@
|
||||
// 发送短信
|
||||
async getPostsms() {
|
||||
if (this.timerCount == 0) {
|
||||
this.timerCount = 60;
|
||||
this.timer = setInterval(() => {
|
||||
this.timerCount--;
|
||||
if (this.timerCount == 0) {
|
||||
clearInterval(this.timer);
|
||||
this.initCompany();
|
||||
}
|
||||
}, 1000);
|
||||
this.startTimer();
|
||||
let res = await postsms({
|
||||
id: this.id
|
||||
})
|
||||
@ -164,6 +156,17 @@
|
||||
this.navTo('/subpkg/submit/submit');
|
||||
}
|
||||
},
|
||||
// 定时器
|
||||
startTimer(time=60){
|
||||
this.timerCount = time.toFixed(0);
|
||||
this.timer = setInterval(() => {
|
||||
this.timerCount--;
|
||||
if (this.timerCount <= 0) {
|
||||
clearInterval(this.timer);
|
||||
this.loadUserDetail();
|
||||
}
|
||||
}, 1000);
|
||||
},
|
||||
navTo(url) {
|
||||
url ?
|
||||
uni.navigateTo({
|
||||
|
@ -11,13 +11,15 @@
|
||||
<view class="text">
|
||||
<view class="basic_name">
|
||||
<view class="name">{{userInfo.name}}</view>
|
||||
<image class="icon"
|
||||
:src="userInfo.sex==1?'../../static/icons/man.png':'../../static/icons/woman.png'">
|
||||
<image class="icon" :src="userInfo.sex==1?'../../static/icons/man.png':'../../static/icons/woman.png'">
|
||||
</image>
|
||||
<!-- <view class="role" v-if="userInfo.roles">{{userInfo.roles[0]}}</view> -->
|
||||
</view>
|
||||
<view class="id_card">
|
||||
身份证号:{{userInfo.id_card}}
|
||||
<view>身份证号:{{userInfo.id_card}}</view>
|
||||
<!-- <view class="update" @click="updateShow(userInfo.id_card, 'id_card')">
|
||||
<uni-icons type="compose" color="#F9AA32"></uni-icons>
|
||||
</view> -->
|
||||
</view>
|
||||
<view class="phone">
|
||||
联系电话:{{userInfo.phone}}
|
||||
@ -28,11 +30,11 @@
|
||||
是否为小队长:
|
||||
<u-radio-group v-model="userInfo.is_captain" style="margin-left: 16rpx;" disabled>
|
||||
<u-radio :customStyle="{marginRight: '16px'}"
|
||||
v-for="(item, index) in [{value:1,label:'是'},{value:0,label:'否'}]" :key="index"
|
||||
:label="item.label" :name="item.value">
|
||||
v-for="(item, index) in [{value:1,label:'是'},{value:0,label:'否'}]" :key="index" :label="item.label"
|
||||
:name="item.value">
|
||||
</u-radio>
|
||||
</u-radio-group>
|
||||
<view class="update" @click="updateShow(userInfo.is_captain)">
|
||||
<view class="update" @click="updateShow(userInfo.is_captain, 'is_captain')">
|
||||
<uni-icons type="compose" color="#F9AA32"></uni-icons>
|
||||
</view>
|
||||
</view>
|
||||
@ -40,21 +42,35 @@
|
||||
负责区域:<text>{{(userInfo.street_name||'')+(userInfo.village_name||'')}}</text>
|
||||
<text v-for="(item, index) in userInfo.brigade_name">{{item.brigade_name}}</text>
|
||||
</view>
|
||||
<u-popup :show="show" :round="10" mode="center">
|
||||
<u-popup :show="show.is_captain" :round="10" mode="center">
|
||||
<view class="popup">
|
||||
<view class="p_title">修改信息</view>
|
||||
<view class="p_body">
|
||||
是否为小队长:
|
||||
<u-radio-group v-model="updateForm.is_captain" style="margin: 16rpx;">
|
||||
<u-radio :customStyle="{marginRight: '16px'}"
|
||||
v-for="(item, index) in [{value:1,label:'是'},{value:0,label:'否'}]" :key="index"
|
||||
:label="item.label" :name="item.value">
|
||||
v-for="(item, index) in [{value:1,label:'是'},{value:0,label:'否'}]" :key="index" :label="item.label"
|
||||
:name="item.value">
|
||||
</u-radio>
|
||||
</u-radio-group>
|
||||
</view>
|
||||
<view class="p_button">
|
||||
<view @click="show=false">取消</view>
|
||||
<view @click="updateInfo">确认</view>
|
||||
<view @click="show.is_captain=false">取消</view>
|
||||
<view @click="updateInfo('is_captain')">确认</view>
|
||||
</view>
|
||||
</view>
|
||||
</u-popup>
|
||||
<u-popup :show="show.id_card" :round="10" mode="center">
|
||||
<view class="popup">
|
||||
<view class="p_title">修改信息</view>
|
||||
<u--form style="padding: 0 28rpx;">
|
||||
<u-form-item label="身份证号:" labelWidth="auto" labelPosition="top">
|
||||
<u--input style="border:1px solid #3175f9;" v-model="updateForm.id_card"></u--input>
|
||||
</u-form-item>
|
||||
</u--form>
|
||||
<view class="p_button">
|
||||
<view @click="show.id_card=false">取消</view>
|
||||
<view @click="updateInfo('id_card')">确认</view>
|
||||
</view>
|
||||
</view>
|
||||
</u-popup>
|
||||
@ -137,8 +153,8 @@
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<picker v-if="!userInfo.is_contract&&!userInfo.contract||(userInfo.contract&&userInfo.contract.check_status==0)" :range="contractTypeList" range-key="name"
|
||||
@change="changeType">
|
||||
<picker v-if="!userInfo.is_contract&&!userInfo.contract||(userInfo.contract&&userInfo.contract.check_status==0)"
|
||||
:range="contractTypeList" range-key="name" @change="changeType">
|
||||
<button class="btn">生成合同</button>
|
||||
</picker>
|
||||
<view v-if="userInfo.contract&&userInfo.contract.check_status==1">
|
||||
@ -216,12 +232,16 @@
|
||||
return {
|
||||
id: '',
|
||||
skeleton: true,
|
||||
show: false,
|
||||
show: {
|
||||
is_captain: false,
|
||||
id_card: false,
|
||||
},
|
||||
typeShow: false,
|
||||
timer: null, // 计时器
|
||||
timerCount: 0, //倒计时
|
||||
updateForm: {
|
||||
is_captain: 0,
|
||||
id_card: '',
|
||||
},
|
||||
userInfo: {
|
||||
qualification: {},
|
||||
@ -235,8 +255,14 @@
|
||||
if (options.id) this.id = options.id;
|
||||
this.initContractTypeList();
|
||||
this.loadUserDetail();
|
||||
let time = uni.getStorageSync('time' + this.id);
|
||||
if(time>0&&(time - Date.now())/1000>0){
|
||||
this.startTimer((time - Date.now())/1000);
|
||||
}
|
||||
},
|
||||
onUnload() {
|
||||
if(this.timerCount>0) uni.setStorageSync('time'+this.id, this.timerCount*1000+Date.now());
|
||||
},
|
||||
onShow() {},
|
||||
computed: {
|
||||
cTimerCount() {
|
||||
return this.timerCount;
|
||||
@ -261,19 +287,24 @@
|
||||
url: url,
|
||||
}) : Toast('暂未开放')
|
||||
},
|
||||
updateShow(value) {
|
||||
this.updateForm.is_captain = value;
|
||||
this.show = true;
|
||||
updateShow(value, type) {
|
||||
this.updateForm[type] = value;
|
||||
this.show[type] = true;
|
||||
},
|
||||
// 更新信息
|
||||
async updateInfo() {
|
||||
let res = await loginSetInfo({
|
||||
async updateInfo(type) {
|
||||
try {
|
||||
let form = {
|
||||
user_id: this.userInfo.id,
|
||||
is_captain: this.updateForm.is_captain
|
||||
});
|
||||
this.userInfo.is_captain = this.updateForm.is_captain;
|
||||
};
|
||||
form[type] = this.updateForm[type];
|
||||
let res = await loginSetInfo(form);
|
||||
this.userInfo[type] = this.updateForm[type];
|
||||
Toast('更新成功');
|
||||
this.show = false;
|
||||
} catch (e) {
|
||||
Toast(e.msg || '更新失败')
|
||||
}
|
||||
},
|
||||
changeType(e) {
|
||||
// console.log(this.contractTypeList[e.detail.value]);
|
||||
@ -293,7 +324,7 @@
|
||||
// 生成合同
|
||||
async createContract(data) {
|
||||
uni.showLoading({
|
||||
title:'合同生成中',
|
||||
title: '合同生成中',
|
||||
mask: true
|
||||
})
|
||||
let res = await userInitiateContract({
|
||||
@ -307,9 +338,9 @@
|
||||
},
|
||||
// 发送合同
|
||||
async addContract(data) {
|
||||
try{
|
||||
try {
|
||||
uni.showLoading({
|
||||
title:'合同发送中',
|
||||
title: '合同发送中',
|
||||
mask: true
|
||||
})
|
||||
let res = await userDraftingcontracts({
|
||||
@ -317,40 +348,47 @@
|
||||
});
|
||||
this.loadUserDetail();
|
||||
if (this.userInfo.contract.check_status == 3) {
|
||||
this.timerCount = 60;
|
||||
this.timer = setInterval(() => {
|
||||
this.timerCount--;
|
||||
if (this.timerCount == 0) {
|
||||
clearInterval(this.timer);
|
||||
this.loadUserDetail();
|
||||
}
|
||||
}, 1000);
|
||||
this.startTimer();
|
||||
}
|
||||
uni.hideLoading();
|
||||
Toast('合同已发送');
|
||||
this.navTo('/subpkg/submit/submit');
|
||||
}catch(e){
|
||||
} catch (e) {
|
||||
uni.hideLoading();
|
||||
Toast('合同发送失败');
|
||||
Toast(e.msg || '合同发送失败');
|
||||
}
|
||||
},
|
||||
// 发送短信
|
||||
async getPostsms() {
|
||||
try {
|
||||
uni.showLoading({
|
||||
title: '发送中',
|
||||
mask: true
|
||||
})
|
||||
if (this.timerCount == 0) {
|
||||
this.timerCount = 60;
|
||||
this.startTimer();
|
||||
let res = await userPostsms({
|
||||
id: this.userInfo.id
|
||||
})
|
||||
uni.hideLoading();
|
||||
Toast('短信已发送');
|
||||
this.navTo('/subpkg/submit/submit');
|
||||
}
|
||||
} catch (e) {
|
||||
uni.hideLoading();
|
||||
Toast(e.msg || '合同发送失败');
|
||||
}
|
||||
},
|
||||
// 定时器
|
||||
startTimer(time=60){
|
||||
this.timerCount = time.toFixed(0);
|
||||
this.timer = setInterval(() => {
|
||||
this.timerCount--;
|
||||
if (this.timerCount == 0) {
|
||||
if (this.timerCount <= 0) {
|
||||
clearInterval(this.timer);
|
||||
this.loadUserDetail();
|
||||
}
|
||||
}, 1000);
|
||||
let res = await userPostsms({
|
||||
id: this.userInfo.id
|
||||
})
|
||||
Toast('短信已发送');
|
||||
this.navTo('/subpkg/submit/submit');
|
||||
}
|
||||
},
|
||||
loadUserDetail() {
|
||||
if (!this.id) return;
|
||||
@ -415,6 +453,7 @@
|
||||
}
|
||||
|
||||
.text {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: space-between;
|
||||
@ -447,6 +486,10 @@
|
||||
}
|
||||
}
|
||||
|
||||
.id_card {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user