This commit is contained in:
@fawn-nine
2024-09-25 18:17:51 +08:00
parent c0b696aa15
commit 86a1f754c2
13 changed files with 391 additions and 115 deletions

View File

@@ -2,17 +2,22 @@
<view class="page">
<z-nav-bar title="我的证书"></z-nav-bar>
<!-- 公共组件-每个页面必须引入 -->
<public-module></public-module>
<public-module></public-module>
<view class="list" v-if="certificateList.length > 0">
<view class="" style="margin: 10rpx;">
{{certificateList.length}} 个证书
</view>
</view>
<view class="item" v-for="(item,index) in certificateList" :key="index">
<view class="flex_box">
<h3>编号{{item.certificateNo}}</h3>
<view class="flex_box flex_between align-items_box">
<h3 style="font-size: 28rpx;">编号{{item.certificateNo}}</h3>
<text class="small_btn border_radius_10"
style="display: block;font-size: 28rpx; color: #55aaff; border:1px solid #55aaff"
v-if="item.certificateUrlList.length <= 0"
@click="showSubmit(item.id)">立即获取证书</text>
</view>
<view class="imgBox flex_box flex_between" >
<view class="imgBox flex_box flex_between" v-if="item.certificateUrlList.length > 0">
<view class="img" v-for="(item1,index1) in item.certificateUrlList" :key="index1">
<image @click="preveImg(item1)" :src="item1" mode="widthFix"></image>
</view>
@@ -20,6 +25,7 @@
<text class="small_btn border_radius_10 moreBtn" @click="showMore(item)">详细信息</text>
</view>
</view>
</view>
</view>
<view class="" v-else>
@@ -40,10 +46,47 @@
</view>
</view>
</u-popup>
<u-popup key="2" :show="showSubmitInfoBlank" :round="10" @close="closeManager" z-index="998"
overlay-style="z-index:998">
<view class="guanli userinfoPup">
<view class="" style="text-align: center; margin-bottom: 40rpx;">
<h3>信息确认</h3>
<text style="color: #666;">请确认以下证书信息</text>
</view>
<view class="tips border_radius_10">
<!-- {{submitInfo.name}}-{{submitInfo.photo}} -->
<view class="flex_box align-items_box item">
<text class="mr20rpx">证书姓名</text>
<text class="mr20rpx">
{{submitInfo.name && submitInfo.name != '' && submitInfo.name != null ? submitInfo.name : '未设置'}}
</text>
<text class="small_btn border_radius_10"
v-if="!submitInfo.name || submitInfo.name != '' || submitInfo.name != null"
@click="onPageJump('/pages/mine/userInfo/persData')" style="margin-left: 20rpx ; display: block; height: 30px; line-height: 30rpx;">
{{submitInfo.name && submitInfo.name != '' && submitInfo.name != null ? '去修改' : '去设置'}}
</text>
</view>
<view class="flex_box align-items_box item">
<text class="mr20rpx">证书照片</text>
<image @click="preveImg(submitInfo.photo)" class="mr20rpx"
v-if="submitInfo.photo && submitInfo.photo != '' && submitInfo.photo != null"
:src="submitInfo.photo" mode="widthFix" style="width:100rpx; height:140rpx;"></image>
<text class="mr20rpx" v-else>未上传</text>
<text class="small_btn border_radius_10"
v-if="!submitInfo.photo || submitInfo.photo != '' || submitInfo.photo != null"
@click="onPageJump('/pages/mine/userInfo/persData')"
style="margin-left: 20rpx ;display: block; height: 30px; line-height: 30rpx;">{{submitInfo.photo && submitInfo.photo != '' && submitInfo.photo != null ? '去修改' : '去上传'}}</text>
</text>
</view>
</view>
<view class="btn_box_certificate"><button @click="createCertificate">立即生成证书</button></view>
</view>
</u-popup>
<z-navigation></z-navigation>
</view>
</template>
<script>
import debounce from "@/common/debounce.js";
import $http from '@/config/requestConfig.js';
// import permission from "@/js_sdk/wa-permission/permission.js"
import {
@@ -55,7 +98,14 @@
return {
certificateList: [],
showTestTips:false,
thisInfo : undefined
thisInfo : undefined,
certificateFlag:false,
showSubmitInfoBlank:false,
submitInfo: {
img: undefined, // 证件图
name: '' // 姓名
},
thisCertificateId:undefined
}
},
//第一次加载
@@ -64,8 +114,14 @@
// this.pageType = e.type
},
//页面显示
onShow() {
async onShow() {
this.getList()
var userObj = await this.getUserData()
if (userObj) {
this.submitInfo.name = userObj.name
this.submitInfo.photo = userObj.photo
// this.showSubmitInfoBlank = true
}
},
beforeDestroy() {
@@ -78,6 +134,98 @@
},
//方法
methods: {
async showSubmit(id) {
this.thisCertificateId = id
this.showSubmitInfoBlank = true
},
async getUserData() {
let that = this;
var Ss = undefined
// 获取个人信息
if (this.userInfo.id != undefined) {
await this.$http
.post('book/user/info/' + this.userInfo.id)
.then(async (res) => {
Ss = res.user;
console.log('that.userData at line 698个人中心:', res.user)
});
return Ss
}
},
// 生成证书
createCertificate() {
debounce(async () => {
if(this.certificateFlag) return
if (this.submitInfo.name && this.submitInfo.name != null && this.submitInfo.name != '' &&
this.submitInfo.photo && this.submitInfo.photo != null && this.submitInfo.photo != '') {
} else {
uni.showModal({
title: '提示',
content: "真实姓名或证书照片未设置,请设置完成后再来生成证书吧",
cancelText: '稍后设置',
confirmText: '立即设置',
success: (res) => {
if (res.confirm) {
uni.navigateTo({
url: '/pages/mine/userInfo/persData'
})
}
}
})
return
}
this.certificateFlag = true
uni.showLoading({
title:'正在生成'
})
var data = {
"id": this.thisCertificateId //证书id
}
// console.log('证书提交数据',data,this.performanceScore.userScore);
$http.request({
url: "common/class/generateCertificateClass",
method: "POST",
data,
header: { //默认 无 说明:请求头
'Content-Type': 'application/json'
},
})
.then(async (res) => {
uni.hideLoading()
if (res.code == 0) {
console.log('证书返回值', res);
uni.showToast({
title: '生成成功',
icon: 'success'
})
setTimeout(() => {
this.getList()
this.closeManager()
// this.getScore()
}, 300)
} else {
uni.showToast({
title: res.errMsg,
icon: 'none'
})
}
setTimeout(()=>{
this.certificateFlag = false
},300)
}).catch(e => {
this.certificateFlag = false
uni.hideLoading()
uni.showToast({
title: e.errMsg,
icon: 'none'
})
});
},300)
},
// 图片预览
preveImg(url) {
console.log('dianjile fangda tu');
@@ -86,7 +234,7 @@
current: 0
});
},
// 获取班级详情
getList() {
// console.log('获取课程详情');
uni.showLoading({
@@ -124,18 +272,78 @@
},
closeManager(){
this.showTestTips = false
this.showSubmitInfoBlank = false
this.thisInfo = undefined
},
showMore(item){
this.thisInfo = item
this.showTestTips = true
}
},
// 跳转
onPageJump(url, id, modeType) {
uni.navigateTo({
url: `${url}?id=${id}&type=${modeType}`
});
},
}
};
</script>
<style lang="scss" scoped>
@import '@/style/mixin.scss';
.btn_box_certificate {
margin-top: 70rpx;
padding-bottom: 20rpx;
button {
font-size: 32rpx;
@include theme('btn_bg') color: #fff;
height: 80rpx;
line-height: 80rpx;
border-radius: 50rpx;
}
}
.guanli {
padding: 40rpx;
h3 {
text-align: center;
margin-bottom: 20rpx;
color: #333;
}
.item {
color: #333;
margin-bottom: 20rpx;
.personbox {
display: inline-block;
color: #666;
}
}
.arryItem {
.arryItemSub {
display: inline-block;
color: #666;
// padding-left: 80rpx;
}
}
text {
font-size: 30rpx;
}
}
.userinfoPup {
.tips {
// .item{justify-content: space-around;}
}
.small_btn {
color: #55aaff;
border: #55aaff 1px solid;
}
}
.page {
background-color: #ffffff;
padding: 0 20rpx;