Commit 917f9eec authored by linwenqing's avatar linwenqing

refactor:我的页面的上传和识别身份证接口替换,证书页面调整

parent 3425f23b
const globalUrl = process.uniEnv || {} const globalUrl = process.uniEnv || {}
const apiUrl = globalUrl.apiUrl const apiUrl = globalUrl.apiUrl
const apiUrlZBo = globalUrl.apiUrlZBo
const uCenterUrl = globalUrl.uCenterUrl const uCenterUrl = globalUrl.uCenterUrl
let userApiFun = function(vm) { let userApiFun = function(vm) {
/* 更新学员信息 */ /* 更新学员信息 */
...@@ -14,21 +15,29 @@ let userApiFun = function(vm) { ...@@ -14,21 +15,29 @@ let userApiFun = function(vm) {
//验证身份证反面 //验证身份证反面
let checkIdCardBack = async (params = {}) => let checkIdCardBack = async (params = {}) =>
await vm.$u.post(uCenterUrl + 'v1/settled/card-back', params) await vm.$u.post(uCenterUrl + 'v1/settled/card-back', params)
//获取国家证列表
let getCountryCertList = async (params = {}) => let getCountryCertList = async (params = {}) =>
await vm.$u.post(apiUrl + '/rest/certificate/query', params) await vm.$u.post(apiUrl + '/rest/certificate/query', params)
//获取学时证列表
let getlearnCertList = async (params = {}) => let getlearnCertList = async (params = {}) =>
await vm.$u.get(apiUrl + '/rest/question/getSchoolCertificate', params) await vm.$u.get(apiUrl + '/rest/question/getSchoolCertificate', params)
//获取学时证详情
let getlearnCertDetail = async (questionWarehouseId, params = {}) => let getlearnCertDetail = async (questionWarehouseId) =>
await vm.$u.get( await vm.$u.get(
apiUrl + '/rest/question/getSchoolCertificate/' + questionWarehouseId, apiUrl + '/rest/question/getSchoolCertificate/' + questionWarehouseId
params
) )
//证书查询结果
let getCertFromOut = async (params = {}) => let getCertFromOut = async (params = {}) =>
await vm.$u.get(apiUrl + '/rest/certificate/national', params) await vm.$u.get(apiUrl + '/rest/certificate/national', params)
//身份证识别
let getCertifyInfoByType = async (type, params = {}) =>
await vm.$u.get(apiUrlZBo + '/student/get/idCard/' + type, params)
//获取学员题库列表
let getUserQuestionWareHouse = async (params = {}) =>
await vm.$u.get(
apiUrl + '/rest/question/query/allStudentQuestionWarehouse',
params
)
const userApi = { const userApi = {
updateUserInfo, updateUserInfo,
...@@ -39,6 +48,8 @@ let userApiFun = function(vm) { ...@@ -39,6 +48,8 @@ let userApiFun = function(vm) {
getlearnCertList, getlearnCertList,
getlearnCertDetail, getlearnCertDetail,
getCertFromOut, getCertFromOut,
getCertifyInfoByType,
getUserQuestionWareHouse,
} }
return userApi return userApi
} }
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
"style": { "style": {
"navigationBarTitleText": "证书", "navigationBarTitleText": "证书",
"navigationStyle": "custom", "navigationStyle": "custom",
"disableScroll": false "disableScroll": true
} }
}, },
{ {
......
...@@ -14,15 +14,11 @@ ...@@ -14,15 +14,11 @@
<u-image :src="topImage" height="116rpx" width="100%"></u-image> <u-image :src="topImage" height="116rpx" width="100%"></u-image>
</view> </view>
<view class="table-list"> <view class="table-list">
<view v-if="type == 'country'" class="item"> <view class="item" v-for="(data, k) in dataList">
<view class="name">{{ certName }}</view> <view class="name">{{ certName[k] }}</view>
<view class="table"> <view class="table">
<u-table border-color="#9EA5BB"> <u-table border-color="#9EA5BB">
<u-tr <u-tr v-for="(item, i) in data" :key="i" class="u-tr">
v-for="(item, i) in data.certificateTextContent"
:key="i"
class="u-tr"
>
<u-td <u-td
v-for="(val, name, index) in item" v-for="(val, name, index) in item"
:key="index" :key="index"
...@@ -48,16 +44,13 @@ ...@@ -48,16 +44,13 @@
export default { export default {
data() { data() {
return { return {
data: { dataList: [],
certificateTextContent: [],
},
learnData: {}, learnData: {},
type: null, certName: [],
certName: '',
topImage: process.uniEnv.qn_base_url + 'tezhongzuoyepingtai@2x.png', topImage: process.uniEnv.qn_base_url + 'tezhongzuoyepingtai@2x.png',
} }
}, },
onShow: function() { onLoad: function() {
this.formatDataByType() this.formatDataByType()
}, },
computed: { computed: {
...@@ -111,39 +104,33 @@ export default { ...@@ -111,39 +104,33 @@ export default {
return return
} }
let certData = getApp().globalData.certItemData let certData = getApp().globalData.certItemData
this.certName = certData.certificateName let countryData = []
if (certData.type == 'country') { let certName = []
console.log('ok') let count, list
this.type = 'country' for (let k in certData) {
this.certName = certData.certificateName countryData[k] = []
let countryData = [] count = certData[k].data.count || 2
let count = certData.data.count || 2 certName[k] = certData[k].certificateName.replace('作业', '证')
let list //格式化表格数据为json
console.log('data is', certData.data) if (!certData[k].data.certificateTextContent) {
if (!certData.data.certificateTextContent) {
list = JSON.parse( list = JSON.parse(
JSON.parse(JSON.stringify(certData.data.certificateContent)) JSON.parse(JSON.stringify(certData[k].data.certificateContent))
) )
console.log('list is', list)
} else { } else {
list = certData.data.certificateTextContent list = certData[k].data.certificateTextContent
} }
//组合表格数据
for (let key in list) { for (let key in list) {
countryData[key] = [] countryData[k][key] = []
for (let i = 1; i <= count; i++) { for (let i = 1; i <= count; i++) {
countryData[key].push(list[key]['filedName_' + i]) countryData[k][key].push(list[key]['filedName_' + i])
countryData[key].push(list[key]['filedValue_' + i]) countryData[k][key].push(list[key]['filedValue_' + i])
} }
} }
console.log('data countryData', countryData)
certData.data.certificateTextContent = countryData
this.data = certData.data
console.log('data log', this.data)
} else if (certData.type == 'learn') {
this.type = 'learn'
this.learnData = certData.data
} }
this.certName = certName
this.dataList = countryData
console.log('data redo log', this.dataList)
}, },
}, },
} }
...@@ -162,7 +149,7 @@ export default { ...@@ -162,7 +149,7 @@ export default {
background-color: #2953ff; background-color: #2953ff;
background-size: 100% 920rpx; background-size: 100% 920rpx;
background-repeat: no-repeat; background-repeat: no-repeat;
height: 120vh; height: 100vh;
position: absolute; position: absolute;
top: 0; top: 0;
width: 100%; width: 100%;
......
...@@ -93,8 +93,9 @@ export default { ...@@ -93,8 +93,9 @@ export default {
computed: { computed: {
nowDate(){ nowDate(){
var Today=new Date(); var Today=new Date();
let m = (Today.getMonth()+1) let m = String(Today.getMonth()+1)
let d = Today.getDate() let d = String(Today.getDate())
console.log('d length', d.length)
return (Today.getFullYear() + '.' + (m.length > 1 ? m : '0' + m) + '.' + (d.length > 1 ? d : '0' + d)) return (Today.getFullYear() + '.' + (m.length > 1 ? m : '0' + m) + '.' + (d.length > 1 ? d : '0' + d))
}, },
headPhoto(){ headPhoto(){
......
This diff is collapsed.
...@@ -50,176 +50,7 @@ export default { ...@@ -50,176 +50,7 @@ export default {
}, },
onLoad() { onLoad() {
this.$u.api.getUserQuestionWareHouse().then((res) => { this.$u.api.getUserQuestionWareHouse().then((res) => {
res = [ console.log('tiku list', res)
{
id: '1415266126815821824',
createTime: '2021-07-14 19:05:14',
createdBy: '1415215255998431232',
updateTime: '2021-07-14 19:05:14',
updatedBy: '1415215255998431232',
echoMap: {
studentId: {
id: '1414459877807357952',
createTime: '2021-07-12 13:41:29',
createdBy: '3',
updateTime: '2021-07-20 20:41:13',
updatedBy: '1414459877807357952',
echoMap: {},
cardCount: null,
consumeAmount: null,
loginTime: null,
unionid: '',
nickname: '',
name: '',
phoneNumber: '11111111111',
avatarPath: '',
identityNumber: '',
identityFrontPath: '',
identityBackPath: '',
certificatePhotoPath: '',
certificateValidityDate: null,
workUnit: '',
address: '',
},
questionWarehouseId: {
id: '1414854649273384960',
createTime: '2021-07-13 15:50:10',
createdBy: '1413688964405002240',
updateTime: '2021-07-22 19:21:00',
updatedBy: '1413688964405002240',
echoMap: {},
institutionId: '1',
subjectId: '1418169087225233408',
title: '测试题库',
subtitle: '大狼狗',
description: 'sad',
effectiveTime: '0',
provinceId: '470715',
cityId: '475286',
type: '1',
price: '100.00',
realPrice: '60.00',
state: true,
remark: '',
version: '0',
},
cardId: {
id: '1416278788987158528',
createTime: '2021-07-17 14:09:11',
createdBy: '1410776147574128640',
updateTime: '2021-07-17 14:09:11',
updatedBy: '1410776147574128640',
echoMap: {},
unitPrice: null,
buyTime: null,
subjectNames: null,
instrtutionId: '1',
studentId: null,
questionWarehouseId: '1',
cardType: '02',
cardNumber: '621001200010719',
cardSecret: '9923sibv',
cardStatus: 5,
isEnable: 1,
effectiveDay: 30,
bindingTime: null,
activationTime: null,
sourceType: {
code: 'INSTRTUTION_SEND',
desc: '机构发卡',
},
sourceOrderId: '1416278788521590784',
},
},
questionWarehouseId: '1414854649273384960',
studentId: '1414459877807357952',
cardId: '1416278788987158528',
},
{
id: '1415602594134360064',
createTime: '2021-07-15 17:41:51',
createdBy: '1415215255998431232',
updateTime: '2021-07-15 17:41:51',
updatedBy: null,
echoMap: {
studentId: {
id: '1414459877807357952',
createTime: '2021-07-12 13:41:29',
createdBy: '3',
updateTime: '2021-07-20 20:41:13',
updatedBy: '1414459877807357952',
echoMap: {},
cardCount: null,
consumeAmount: null,
loginTime: null,
unionid: '',
nickname: '',
name: '',
phoneNumber: '11111111111',
avatarPath: '',
identityNumber: '',
identityFrontPath: '',
identityBackPath: '',
certificatePhotoPath: '',
certificateValidityDate: null,
workUnit: '',
address: '',
},
questionWarehouseId: {
id: '1',
createTime: '2021-07-12 16:33:20',
createdBy: null,
updateTime: '2021-07-21 14:40:44',
updatedBy: '1413688964405002240',
echoMap: {},
institutionId: '1',
subjectId: '1413687160678121472',
title: '测试1',
subtitle: '侧首',
description: '哈哈哈哈',
effectiveTime: '1',
provinceId: '470715',
cityId: '475286',
type: '1',
price: '100.00',
realPrice: '50.00',
state: true,
remark: '123231',
version: null,
},
cardId: {
id: '1416278788987158528',
createTime: '2021-07-17 14:09:11',
createdBy: '1410776147574128640',
updateTime: '2021-07-17 14:09:11',
updatedBy: '1410776147574128640',
echoMap: {},
unitPrice: null,
buyTime: null,
subjectNames: null,
instrtutionId: '1',
studentId: null,
questionWarehouseId: '1',
cardType: '02',
cardNumber: '621001200010719',
cardSecret: '9923sibv',
cardStatus: 15,
isEnable: 1,
effectiveDay: 30,
bindingTime: null,
activationTime: null,
sourceType: {
code: 'INSTRTUTION_SEND',
desc: '机构发卡',
},
sourceOrderId: '1416278788521590784',
},
},
questionWarehouseId: '1',
studentId: '1414459877807357952',
cardId: '1416278788987158528',
},
]
let length = res.length let length = res.length
if (res.length <= 0) { if (res.length <= 0) {
this.lists = [] this.lists = []
...@@ -237,7 +68,6 @@ export default { ...@@ -237,7 +68,6 @@ export default {
//绑卡或支付时间 //绑卡或支付时间
data[i].title = res[i].echoMap.questionWarehouseId.title data[i].title = res[i].echoMap.questionWarehouseId.title
data[i].subtitle = res[i].echoMap.questionWarehouseId.subtitle
data[i].time = data[i].time =
res[i].echoMap.cardId.bindingTime || res[i].echoMap.cardId.bindingTime ||
res[i].echoMap.cardId.buyTime || res[i].echoMap.cardId.buyTime ||
...@@ -247,18 +77,28 @@ export default { ...@@ -247,18 +77,28 @@ export default {
case 0: case 0:
status = '未绑定' status = '未绑定'
data[i].statusStyle = { color: '#9EA5BB' } data[i].statusStyle = { color: '#9EA5BB' }
data[i].subtitle = '请前往绑定'
break break
case 5: case 5:
status = '已绑定' status = '已绑定'
data[i].statusStyle = { color: '#2953FF' } data[i].statusStyle = { color: '#2953FF' }
data[i].subtitle = '请前往首页答题联系吧'
break break
case 10: case 10:
status = '已激活' status = '已激活'
data[i].statusStyle = { color: '#2953FF' } data[i].statusStyle = { color: '#2953FF' }
let leaveDay = 0
if (res[i].echoMap.cardId && res[i].echoMap.cardId.activationTime) {
let diff = this.datedifference(sDate1, sDate2)
leaveDay = res[i].echoMap.cardId.effectiveDay - diff
leaveDay = leaveDay > 0 ? leaveDay : 0
}
data[i].subtitle = '题库将于' + leaveDay + '天后到期'
break break
case 15: case 15:
status = '已失效' status = '已失效'
data[i].statusStyle = { color: '#9EA5BB' } data[i].statusStyle = { color: '#9EA5BB' }
data[i].subtitle = '题库已失效'
break break
default: default:
break break
...@@ -266,9 +106,21 @@ export default { ...@@ -266,9 +106,21 @@ export default {
data[i].status = status data[i].status = status
} }
this.lists = data this.lists = data
console.log(data) console.log('tiku data', data)
}) })
}, },
methods: {
datedifference(sDate1, sDate2) {
//2021-01-01,2020-02-01,31
var dateSpan, tempDate, iDays
sDate1 = Date.parse(sDate1)
sDate2 = Date.parse(sDate2)
dateSpan = sDate2 - sDate1
dateSpan = Math.abs(dateSpan)
iDays = Math.floor(dateSpan / (24 * 3600 * 1000))
return iDays
},
},
} }
</script> </script>
......
...@@ -150,15 +150,16 @@ export default { ...@@ -150,15 +150,16 @@ export default {
upload.getPhoto(1, this.token).then((res) => { upload.getPhoto(1, this.token).then((res) => {
this.student.identityFrontPath = res.key this.student.identityFrontPath = res.key
this.$u.api this.$u.api
.checkIdCardFront({ id_card_front: res.key }) .getCertifyInfoByType('front', {
.then(() => {}) url: process.uniEnv.qn_asset_url + res.key,
})
.then((res) => {
console.log('识别结果', res)
this.student.name = res.name
this.student.identityNumber = res.number
})
.catch((data) => { .catch((data) => {
if (data.errMsg == 'request:ok') { this.$u.toast('识别身份证信息错误')
this.student.name = data.data.id_card_name
this.student.identityNumber = data.data.id_card_number
} else {
this.$u.toast('识别身份证信息错误')
}
}) })
}) })
}, },
...@@ -167,14 +168,15 @@ export default { ...@@ -167,14 +168,15 @@ export default {
upload.getPhoto(1, this.token).then((res) => { upload.getPhoto(1, this.token).then((res) => {
this.student.identityBackPath = res.key this.student.identityBackPath = res.key
this.$u.api this.$u.api
.checkIdCardBack({ id_card_back: res.key }) .getCertifyInfoByType('back', {
.then(() => {}) url: process.uniEnv.qn_asset_url + res.key,
})
.then((res) => {
console.log('识别结果', res)
this.student.certificateValidityDate = res.expire
})
.catch((data) => { .catch((data) => {
if (data.errMsg == 'request:ok') { this.$u.toast('识别身份证信息错误')
this.student.certificateValidityDate = data.data.id_card_expire
} else {
this.$u.toast('识别身份证信息错误')
}
}) })
}) })
}, },
......
...@@ -82,7 +82,9 @@ import login from '@/common/login' ...@@ -82,7 +82,9 @@ import login from '@/common/login'
export default { export default {
data() { data() {
return { return {
student: {}, student: {
isCertify: false,
},
token: null, token: null,
code: '', code: '',
} }
...@@ -94,6 +96,10 @@ export default { ...@@ -94,6 +96,10 @@ export default {
) )
}, },
headCertPhoto() { headCertPhoto() {
console.log(
'touxiang bianle',
this.student ? this.student.certificatePhotoPath : 'kong'
)
return ( return (
(this.student && this.student.certificatePhotoPath) || (this.student && this.student.certificatePhotoPath) ||
process.uniEnv.qn_base_url + 'xitongtouxiang.png' process.uniEnv.qn_base_url + 'xitongtouxiang.png'
...@@ -115,20 +121,21 @@ export default { ...@@ -115,20 +121,21 @@ export default {
return (this.student && this.student.workUnit) || '去填写' return (this.student && this.student.workUnit) || '去填写'
}, },
getCertifyStatus() { getCertifyStatus() {
return this.student && this.student.isCertify ? '已认证' : '去认证' console.log('is cert', this.student.isCertify)
return this.student.isCertify ? '已认证' : '去认证'
}, },
}, },
onLoad() { onLoad() {
this.$u.api this.$u.api
.getQiNiuToken({ bucketName: 'banshou-userprofile' }) .getQiNiuToken({ bucketName: 'banshou-userprofile' })
.then((res) => { .then((res) => {
this.token = data.data.token //token为七牛云的token一般由后台接口提供 console.log('chushihua token', res)
getApp().globalData.qiNiuToken = data.data.token this.token = res //token为七牛云的token一般由后台接口提供
getApp().globalData.qiNiuToken = res
}) })
this.$u.api.getUserInfo().then((res) => { this.$u.api.getUserInfo().then((res) => {
if (res && res.identityNumber) { console.log('huoqu userinfo', res)
this.student.isCertify = true res.isCertify = res && res.identityNumber.length > 5 ? true : false
}
this.student = res this.student = res
}) })
}, },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment