Commit fb334a21 authored by Facius's avatar Facius

Merge branch 'dev-v1.0.0' of https://git.banshouhui.com/wuzhenzhe/study into dev-v1.0.0

parents bc7f6b93 6b2e55e9
const UNI_APP = {
apiUrl: 'http://192.168.0.208:8760',
apiUrl: 'http://192.168.0.204:8760',
qn_base_url: 'https://qn-static.banshouhui.com/study/',
qn_asset_url: 'http://deudn.c.pp.cc/',
uUrl: 'http://rest-u.yunya.com/',
uCenterUrl: 'http://192.168.0.5:8093/',//'http://rest-u.yunya.com/'
argoDebugMode: 1,
version: 'v1.0.0',
}
......
......@@ -2,7 +2,7 @@ const UNI_APP = {
apiUrl: 'https://system.banshouhui.com',
qn_base_url: 'https://qn-static.banshouhui.com/study/',
qn_asset_url: 'https://img2.banshouhui.com/',
uUrl: 'http://rest-u.banshouhui.com/',
uCenterUrl: 'http://rest-u.banshouhui.com/',
argoDebugMode: 1,
version: 'v1.0.0',
}
......
......@@ -2,7 +2,7 @@ const UNI_APP = {
apiUrl: 'https://system.dev.banshouhui.com',
qn_base_url: 'https://qn-static.banshouhui.com/study/',
qn_asset_url: 'https://img2.banshouhui.com/',
uUrl: 'http://rest-u.test.ibanshou.cn/',
uCenterUrl: 'http://rest-u.test.ibanshou.cn/',
argoDebugMode: 1,
version: 'v1.0.0',
}
......
let commonApiFun = function(vm) {
const globalUrl = process.uniEnv || {}
let ucenterApiUrl = globalUrl.uUrl
let uCenterApiUrl = globalUrl.uCenterUrl
let loginWechatAuth = async (params = {}) =>
await vm.$u.post('/wxapp/unify/authorization', params)
let payOrder = async (params = {}) => await vm.$u.post('/pay/order', params)
let payQuery = async (params = {}) => await vm.$u.get('/pay/query', params)
let getQiNiuToken = async (params = {}) =>
await vm.$u.post(ucenterApiUrl + 'v1/tokens', params)
await vm.$u.post(uCenterApiUrl + 'v1/tokens', params)
const commonApi = {
loginWechatAuth,
payOrder,
......
import { commonApiFun } from './common.js'
import { learnApiFun } from './learn.js'
import { userApiFun } from './user.js'
const apiFun = function(vm) {
let commonApi = commonApiFun(vm)
let learnApi = learnApiFun(vm)
let userApi = userApiFun(vm)
let apiUrl = {
...commonApi,
...learnApi
...learnApi,
...userApi,
}
return apiUrl
}
......
const globalUrl = process.uniEnv || {}
const apiUrl = globalUrl.apiUrl
const uCenterUrl = globalUrl.uCenterUrl
let userApiFun = function(vm) {
/* 更新学员信息 */
let updateUserInfo = async (params = {}) =>
await vm.$u.post(apiUrl + '/student/update', params)
//获取学员信息
let getUserInfo = async (params = {}) =>
await vm.$u.get(apiUrl + '/student/get', params)
//验证身份证正面
let checkIdCardFront = async (params = {}) =>
await vm.$u.post(uCenterUrl + 'v1/settled/card-front', params)
//验证身份证反面
let checkIdCardBack = async (params = {}) =>
await vm.$u.post(uCenterUrl + 'v1/settled/card-back', params)
const userApi = {
updateUserInfo,
getUserInfo,
checkIdCardFront,
checkIdCardBack,
}
return userApi
}
module.exports = {
userApiFun,
}
......@@ -11,6 +11,7 @@ const install = (Vue, vm) => {
'content-type': 'application/json; charset=utf-8',
},
loadingTime: 800,
showLoading: false,
originalData: true,
})
......
function appLogin() {
return new Promise(function(resolve, reject) {
uni.login({
success(res) {
if (!res.code) {
uni.hideLoading()
uni.showModal({
content: res.errMsg,
showCancel: false,
})
}
resolve(res)
},
fail() {
uni.hideLoading()
uni.showModal({
content: '小程序登录失败',
showCancel: false,
})
reject()
},
})
})
}
export default {
appLogin,
}
......@@ -44,34 +44,36 @@ function getPhoto(type, token) {
if (!r) {
reject(false)
}
})
let sourceType = type == 1 ? ['album'] : ['album', 'camera']
uni.chooseImage({
count: 6, //默认9
sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
sourceType: sourceType, //从相册选择
success: function(res) {
//上传七牛
let filePath = res.tempFiles[0].path //为需要上传的文件
upload(filePath, token)
.then((msg) => {
//最后七牛返回的key
resolve({
key: msg,
files: res.tempFiles,
let sourceType = type == 1 ? ['album'] : ['album', 'camera']
uni.chooseImage({
count: 6, //默认9
sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
sourceType: sourceType, //从相册选择
success: function(res) {
//上传七牛
let filePath = res.tempFiles[0].path //为需要上传的文件
upload(filePath, token)
.then((msg) => {
//最后七牛返回的key
resolve({
key: msg,
files: res.tempFiles,
})
})
})
.catch((msg) => {
console.error(msg)
reject(msg)
})
},
.catch((msg) => {
console.error(msg)
reject(msg)
})
},
})
})
})
}
//上传七牛
function upload(filePath, token) {
console.log('filePath', filePath)
console.log('token', token)
return new Promise((resolve, reject) => {
let key =
new Date().getTime() + Math.random(1000) + filePath.split('/').pop() //key为自定义文件名
......
......@@ -69,6 +69,7 @@ export default {
lists: [],
// 答案对错
answer: '',
userAnswer: ''
}
},
watch: {
......@@ -98,6 +99,8 @@ export default {
v.confirm = false // 确认答案
})
this.$set(this.lists[index], 'confirm', true)
// 用户选的答案
this.userAnswer = this.lists[index].sort
// 判断所选答案是否正确
this.answer = this.rightKey.includes(this.lists[index].sort)
? 'pass'
......@@ -114,6 +117,9 @@ export default {
if (num.length > 1) {
// 判断所选答案是否正确
const checkedList = num.map((v) => v.sort)
// 用户选的答案
this.userAnswer = checkedList.join(',')
// 判断所选答案是否正确
this.answer = equar(checkedList, this.rightKey) ? 'pass' : 'fail'
// 处理显示逻辑
this.lists.forEach((v) => {
......@@ -124,7 +130,7 @@ export default {
}
},
submitAnswer() {
this.$emit('change', this.answer, this.lists)
this.$emit('change', this.answer, this.lists, this.userAnswer)
},
},
}
......
......@@ -125,10 +125,10 @@ export default {
this.swiperIndex = current
this.swiperCurrent = current
},
answerChange(status, lists) {
answerChange(status, lists, userAnswer) {
this.$set(this.swiperList[this.swiperIndex], 'errShow', this.type === 2 ? true : status === 'fail')
this.$set(this.swiperList[this.swiperIndex], 'submitStatus', true)
this.$emit("answerChange", status, lists)
this.$emit("answerChange", status, lists, userAnswer)
},
clear () {
this.list = []
......
......@@ -26,6 +26,7 @@
"name": "mine",
"style": {
"navigationBarTitleText": "个人中心",
"navigationStyle": "custom",
"disableScroll": true
}
}
......@@ -254,6 +255,33 @@
"enablePullDownRefresh": false,
"disableScroll": true
}
},
{
"path": "address",
"name": "mineAddress",
"style": {
"navigationBarTitleText": "工作单位",
"enablePullDownRefresh": false,
"disableScroll": true
}
},
{
"path": "certify",
"name": "mineCertify",
"style": {
"navigationBarTitleText": "实名认证",
"enablePullDownRefresh": false,
"disableScroll": true
}
},
{
"path": "setting",
"name": "mineSetting",
"style": {
"navigationBarTitleText": "设置",
"enablePullDownRefresh": false,
"disableScroll": true
}
}
]
}
......
<template>
<view class="content">
<view>
<text class="title">{{title}}</text>
</view>
</view>
<view class="content">
<view>
<u-tabs-swiper
bg-color="#F4F5F7"
inactive-color="#999999"
font-size="28"
ref="uTabs"
:list="tabs"
:current="current"
@change="tabsChange"
:is-scroll="false"
:bar-width="52"
swiperWidth="750"
></u-tabs-swiper>
<swiper
class="swiper_group"
:current="swiperCurrent"
@transition="transition"
@animationfinish="animationfinish"
>
<swiper-item @touchmove.stop.prevent="stopTouchMove">
<u-form-item label="证件类型"
><u-input v-model="form.type"
/></u-form-item>
<u-form-item label="身份证"><u-input v-model="form.id"/></u-form-item>
<u-form-item label="姓名"><u-input v-model="form.name"/></u-form-item>
</swiper-item>
<swiper-item @touchmove.stop.prevent="stopTouchMove"> </swiper-item>
</swiper>
</view>
</view>
</template>
<script>
export default {
data() {
return {
title: '证书'
}
},
onLoad() {
export default {
data() {
return {
title: '证书',
tabs: [
{
name: '证书查询',
},
{
name: '我的证书',
},
],
}
},
onLoad() {},
methods: {},
}
</script>
},
methods: {
<style>
.content {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
width: 100%;
margin-top: 180rpx;
}
}
}
</script>
/* .swiper_group{
margin-top: ;
} */
</style>
<template>
<view>
<view
class="u-flex user-box u-p-l-30 u-p-t-30 u-p-r-20 u-p-b-30"
@tap="login"
>
<view class="u-m-r-10">
<u-avatar :src="avatar" size="140"></u-avatar>
<u-navbar
back-icon-color="#333333"
background="transparent"
title=" "
titleColor="#191C27"
:border-bottom="false"
title-bold
:is-back="false"
></u-navbar>
<view class="top"
><image class="background-image" :src="backgroundImage"></image>
<view
class="u-flex user-box u-p-l-30 u-p-t-30 u-p-r-20 u-p-b-30"
@tap="login"
>
<view class="u-flex-1">
<view class="u-font-18 u-p-b-20 nick-name">{{ nikeName }}</view>
<view class="login-tip">
<text v-if="isLogin"
>累计刷题量<text style="color:#2953FF">{{ loginTips }}</text
>次</text
>
<text v-else>登录可查看答题信息</text>
</view>
</view>
<view class="u-m-r-10 avatar">
<u-avatar class="avatar-iamge" :src="avatar" size="140"></u-avatar>
</view>
</view>
<view class="u-flex-1">
<view class="u-font-18 u-p-b-20">{{ nikeName }}</view>
<view class="u-font-14 u-tips-color">累计刷题俩999次</view>
</view>
</view>
<view class="u-m-t-20">
<u-cell-group>
<u-cell-item
icon="star"
title="个人信息"
value="完善度40%"
@tap="toUrl('pages/mine/info')"
></u-cell-item>
<u-cell-item
icon="photo"
title="我的题库"
@tap="toUrl('pages/mine/bank')"
></u-cell-item>
<u-cell-item
icon="coupon"
title="联系客服"
@tap="toUrl('pages/mine/customer')"
></u-cell-item>
<u-cell-item icon="coupon" title="退出登录" @tap="logout"></u-cell-item>
</u-cell-group>
<view class="">
<u-cell-group :border="false">
<u-cell-item
:border-bottom="false"
title="个人信息"
@tap="toUrl('pages/mine/info')"
:value="completeness"
:title-style="cellTitleStyle"
:value-style="{ color: '#2953FF', 'font-size': '26rpx' }"
>
<u-image
slot="icon"
width="36rpx"
height="40rpx"
:src="infoIcon"
></u-image>
</u-cell-item>
<u-cell-item
:border-bottom="false"
title="我的题库"
:title-style="cellTitleStyle"
@tap="toUrl('pages/mine/bank')"
>
<u-image
slot="icon"
width="36rpx"
height="40rpx"
:src="questionIcon"
></u-image>
</u-cell-item>
<u-cell-item
:border-bottom="false"
title="联系客服"
:title-style="cellTitleStyle"
@tap="toUrl('pages/mine/customer')"
>
<u-image
slot="icon"
width="36rpx"
height="40rpx"
:src="serviceIcon"
></u-image>
</u-cell-item>
<u-cell-item
:border-bottom="false"
title="设置"
:title-style="cellTitleStyle"
@tap="toUrl('pages/mine/setting')"
>
<u-image
slot="icon"
width="36rpx"
height="40rpx"
:src="settingIcon"
></u-image>
</u-cell-item>
</u-cell-group>
</view>
</view>
</view>
</template>
......@@ -41,21 +96,84 @@
export default {
data() {
return {
pic: 'https://uviewui.com/common/logo.png',
pic: process.uniEnv.qn_base_url + '/xitongtouxiang.png',
show: true,
countItem: [
'avatarPath',
'certificatePhotoPath',
'identityNumber',
'nickname',
'phoneNumber',
'workUnit',
],
student: {},
}
},
computed: {
infoIcon() {
return process.uniEnv.qn_base_url + '/gerenxinxi@3x.png'
},
questionIcon() {
return process.uniEnv.qn_base_url + '/wodetiku@3x.png'
},
serviceIcon() {
return process.uniEnv.qn_base_url + '/lianxikefu@3x.png'
},
settingIcon() {
return process.uniEnv.qn_base_url + '/shezhi@3x.png'
},
isLogin() {
console.log('is login', this.userInfo.nickName)
return this.userInfo.nickName != undefined
},
loginTips() {
return this.student.consumeAmount || 0
},
avatar() {
return this.userInfo.avatarUrl || this.pic
return (this.userInfo && this.userInfo.avatarUrl) || this.pic
},
nikeName() {
return this.userInfo.nickName || '未登录'
return (this.userInfo && this.userInfo.nickName) || '点击登录'
},
backgroundImage() {
return process.uniEnv.qn_base_url + 'wodetop@3x.png'
},
completeness() {
if (this.userInfo && this.userInfo.nickName) {
return '完善度' + this.asumeCount() + '%'
} else {
return ''
}
},
cellTitleStyle() {
return { 'font-size': '32rpx', coloe: '#191C27', 'margin-left': '26rpx' }
},
},
onLoad() {},
onShow() {
if (this.userInfo.nickName) {
this.$u.api.getUserInfo().then((res) => {
this.student = res
getApp().globalData.student
})
}
},
methods: {
asumeCount() {
//计算完善度
let length = this.countItem.length
let count = 0
for (let key in this.student) {
if (this.countItem.indexOf(key) != -1 && this.student[key]) {
count = count + 1
}
}
return parseInt((count / length) * 100)
},
login() {
if (this.userInfo.nickName) {
return
}
this.$u.route({
url: 'pages/login/index',
})
......@@ -65,18 +183,13 @@ export default {
url: url,
})
},
logout() {
this.$u.vuex('vuex_token', '')
this.$u.vuex('openId', '')
this.$u.vuex('userInfo', {})
},
},
}
</script>
<style lang="scss">
page {
background-color: #ededed;
background-color: #ffffff;
}
.camera {
width: 54px;
......@@ -88,5 +201,40 @@ page {
}
.user-box {
background-color: #fff;
margin-top: 380rpx;
border-top-left-radius: 30rpx;
border-top-right-radius: 30rpx;
}
.top {
width: 750rpx;
position: absolute;
top: 0;
.background-image {
position: absolute;
z-index: -1;
width: 750rpx;
height: 562rpx;
}
}
.nick-name {
font-size: 48rpx;
font-weight: bold;
color: #191c27;
}
.login-tip {
font-size: 26rpx;
color: #5a6073;
}
.avatar {
position: relative;
image {
position: absolute;
top: -70rpx;
/* 登录加外边框,未登录不加边框 */
/* padding: 5rpx;
background-color: white; */
}
}
</style>
......@@ -96,6 +96,7 @@
:numberList="complete.result"
:type="complete.type"
:visible.sync="complete.visible"
:timeout="complete.timeout"
@cancel="cancel"
@submit="submit"
>
......@@ -151,6 +152,7 @@ export default {
type: 'pass',
result: [],
visible: false,
timeout: false
},
timestamp: 60 * 60,
list: [],
......@@ -215,12 +217,11 @@ export default {
this.type = 1
break;
}
// 第一次进入,显示提示
if (this.questionList.length === 0) {
this.show = true
}
this.init()
},
methods: {
......@@ -234,7 +235,13 @@ export default {
// 列表总长度,一定要在第一次请求列表数据前明确该值
// 否则无法知道下一页是否还有数据
let total = parseInt(res) || 0
// 考试
if (this.type === 2) {
this.pageSize = 100
total = 100
}
this.total = total
// 练习模式-初始化答题卡列表
if (this.type === 1) Utils.initAnswerCardList(total, this)
this.cachePageDataMap = new Map()
......@@ -353,35 +360,43 @@ export default {
this.model = i
},
timeEnd() {
this.complete.timeout = true
this.handPapers()
},
// 作答完毕
answerChange(status, lists) {
answerChange(status, lists, userAnswer) {
// 保存答题状态
const item = this.list.find(v => v.index === this.currentIndex)
item.submitStatus = true
item.answerList = lists
item.result = status
item.errShow = this.type === 2 ? true : status === 'fail'
item.userAnswer = userAnswer
if(this.model === 1) this.saveAnswer(item)
// 更新答题卡
this.questionList[this.currentIndex] = item
this.$u.vuex('questionList', this.questionList)
this.$u.vuex('lastIndex', this.currentIndex)
if (this.type === 1){
this.questionList[this.currentIndex] = item
this.$u.vuex('questionList', this.questionList)
this.$u.vuex('lastIndex', this.currentIndex)
// 每日一练数量统计
if (this.type === 1 && this.daily.status) {
if (this.daily.count < 9) this.daily.count++
if (this.daily.count === 9) {
this.daily.visible = true
this.daily.status = false
return
// 每日一练数量统计
if (this.daily.status) {
if (this.daily.count < 9) this.daily.count++
if (this.daily.count === 9) {
this.daily.visible = true
this.daily.status = false
return
}
}
}
// 如果回答错误或者是考试模式,自动进入下一题
if ((status === 'pass' && this.model !== 2)|| this.type === 2) {
if (this.currentIndex + 1 > this.total - 1) {
if ((status === 'pass' && this.model !== 2) || this.type === 2) {
if (this.currentIndex + 1 > this.total - 1) { // 最后一题回答后
if (this.type === 2) {
this.handPapers(1)
this.submit()
}
return
}
this.$nextTick(() => {
......@@ -389,19 +404,32 @@ export default {
})
}
},
// 交卷
handPapers() {
// 保存答案
saveAnswer(info) {
const params = {
answer: info.userAnswer,
answerRight: info.result === 'pass',
questionId: info.id,
questionWarehouseId: this.questionWarehouseId,
recordId: this.recordId,
source: this.source
}
this.$u.api.answer([params])
},
// 统计分数
handPapers(type) {
const fail = this.list.filter((v) => v.result === 'fail').length // 错题数
const noStart = this.list.filter((v) => !v.result).length // 未做题数
const fraction = 0 // 分数
const fraction = this.total - noStart - fail// 分数
this.complete.result = [fail, noStart, fraction]
this.complete.type = 'pass'
this.complete.visible = true
this.complete.type = fraction < 60 ? 'fail' : 'pass'
if (!type) this.complete.visible = true
},
// 考试成绩弹框确认
submit() {
// 提前交卷
this.$u.route({
type: 'redirect',
url: '/pages/learn/score',
})
},
......@@ -415,7 +443,10 @@ export default {
},
// 每日一练弹框取消
dailyCancel() {
this.$u.route('/pages/learn/record')
this.$u.route({
type: 'redirect',
url: '/pages/learn/record',
})
},
// 收藏
collection() {
......
......@@ -135,6 +135,7 @@ function request({ currentPage, size, onSuccess, onFailed }, vm) {
}
let item = {
index: i + (currentPage - 1) * size,
id: info.id,
currentPage: currentPage,
total: data.total,
title: content.title,
......
<template>
<view class="content">
<view class="wrap">
<input
type="text"
placeholder="请输入工作单位"
v-model="student.workUnit"
/>
</view>
<button @click="submit">提交</button>
</view>
</template>
<script>
export default {
data() {
return {
student: {
workUnit: '',
},
}
},
computed: {},
onLoad() {
this.student = getApp().globalData.student
},
methods: {
submit() {
if (this.student.workUnit == '') {
this.$u.toast('请输入工作单位名称')
return
}
this.$u.api
.updateUserInfo({
workUnit: this.student.workUnit,
})
.then((res) => {
this.$u.toast('保存成功')
setTimeout(() => {
this.$u.route({
type: 'back',
})
}, 1500)
})
},
},
}
</script>
<style>
.content {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
width: 100%;
}
.wrap {
display: flex;
}
</style>
<template>
<view class="content">
<u-cell-group>
<u-cell-item
title="实名认证"
:arrow="false"
:hover-class="none"
title-style="{'font':'bold','font-size':'40rpx'}"
>
<view slot="label" style="display:flex;flex-direction: column;">
<text>上传二代身份证照片,图片大小不大于2M</text>
<view class="upload-image">
<image
class="cert-image"
:src="certFront"
mode="widthFix"
lazy-load="false"
binderror=""
bindload=""
@click="getFront"
/>
<image
class="cert-image"
style="margin-left: 30rpx;"
:src="certBack"
mode="widthFix"
lazy-load="false"
binderror=""
bindload=""
@click="getBack"
/>
</view>
</view>
</u-cell-item>
<u-cell-item
:arrow="false"
:hover-class="none"
title="姓名"
:value="name"
></u-cell-item>
<u-cell-item
:arrow="false"
:hover-class="none"
title="身份证号"
:value="getIdCardNum"
></u-cell-item>
<u-cell-item
:arrow="false"
:hover-class="none"
title="有效期"
:value="expire"
></u-cell-item>
<u-cell-item :arrow="false" :hover-class="none">
<view slot="label" style="display:flex;flex-direction: column;">
<button @click="submit">确定</button>
</view>
</u-cell-item>
</u-cell-group>
</view>
</template>
<script>
import upload from '@/common/upload'
export default {
data() {
return {
student: {},
token: '',
}
},
computed: {
certFront() {
return this.student.identityFrontPath
? process.uniEnv.qn_asset_url + this.student.identityFrontPath
: 'https://qn-static.banshouhui.com/self-support/renxiang.png'
},
certBack() {
return this.student.identityBackPath
? process.uniEnv.qn_asset_url + this.student.identityBackPath
: 'https://qn-static.banshouhui.com/self-support/guohui.png'
},
name() {
return this.student.name || ''
},
expire() {
return this.student.certificateValidityDate || ''
},
getIdCardNum() {
return this.student.identityNumber || ''
},
},
onLoad() {
this.student = getApp().globalData.student
this.token = getApp().globalData.qiNiuToken
},
methods: {
submit() {
if (
!this.student.identityNumber ||
!this.student.certificateValidityDate
) {
this.$u.toast('请上传身份证正反面信息')
return
}
this.$u.api
.updateUserInfo({
identityFrontPath: this.student.identityFrontPath,
identityBackPath: this.student.identityBackPath,
identityNumber: this.student.identityNumber,
certificateValidityDate: this.student.certificateValidityDate,
name: this.student.name,
})
.then((res) => {
this.$u.toast('认证成功')
setTimeout(() => {
this.$u.route({
type: 'back',
})
}, 1500)
})
},
getFront() {
//身份证正面图片识别
upload.getPhoto(1, this.token).then((res) => {
this.student.identityFrontPath = res.key
this.$u.api
.checkIdCardFront({ id_card_front: res.key })
.then(() => {})
.catch((data) => {
if (data.errMsg == 'request:ok') {
this.student.name = data.data.id_card_name
this.student.identityNumber = data.data.id_card_number
} else {
this.$u.toast('识别身份证信息错误')
}
})
})
},
getBack() {
//身份证反面图片识别
upload.getPhoto(1, this.token).then((res) => {
this.student.identityBackPath = res.key
this.$u.api
.checkIdCardBack({ id_card_back: res.key })
.then(() => {})
.catch((data) => {
console.log('beimian', data)
if (data.errMsg == 'request:ok') {
this.student.certificateValidityDate = data.data.id_card_expire
} else {
this.$u.toast('识别身份证信息错误')
}
})
})
},
},
}
</script>
<style>
.content {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
width: 100%;
}
.cert-image {
width: 300rpx;
height: 300rpx;
}
</style>
<template>
<view class="content">
<u-cell-group>
<u-cell-group style="width: 100%;">
<u-cell-item title="头像" @click="changeHead">
<view slot="right-icon">
<u-image width="50rpx" height="50rpx" :src="headPhoto"></u-image>
......@@ -17,126 +17,159 @@
<text v-else style="color:blue;">未上传</text>
</view>
</u-cell-item>
<u-cell-item
title="手机号"
:arrow="false"
:hover-class="none"
:value="getMobile"
></u-cell-item>
<u-cell-item title="手机号" :arrow="false" :hover-class="none">
<view slot="right-icon">
<button
hover-class="none"
class="mobile-button"
open-type="getPhoneNumber"
@getphonenumber="getPhonenumber"
>
{{ getMobile }}
</button>
</view>
</u-cell-item>
<u-cell-item
title="实名认证"
:arrow="false"
:hover-class="none"
title-style="{'font':'bold','font-size':'40rpx'}"
:value="getCertifyStatus"
@click="goCertify"
>
<view slot="label" style="display:flex;flex-direction: column;">
<text>上传二代身份证照片,图片大小不大于2M</text>
<view class="upload-image">
<image
class="cert-image"
:src="certFront"
mode="widthFix"
lazy-load="false"
binderror=""
bindload=""
@click="getFront"
/>
<image
class="cert-image"
style="margin-left: 30rpx;"
:src="certBack"
mode="widthFix"
lazy-load="false"
binderror=""
bindload=""
@click="getBack"
/>
</view>
</view>
</u-cell-item>
<u-cell-item
:arrow="false"
:hover-class="none"
title="姓名"
:value="name"
></u-cell-item>
<u-cell-item
:arrow="false"
:hover-class="none"
title="身份证号"
:value="idCardNum"
title="工作单位"
:value="getCompany"
@click="goAddress"
></u-cell-item>
<u-cell-item
:arrow="false"
:hover-class="none"
title="有效期"
:value="expire"
></u-cell-item>
<u-cell-item title="工作单位" :value="company"></u-cell-item>
</u-cell-group>
</view>
</template>
<script>
import upload from '@/common/upload'
import login from '@/common/login'
export default {
data() {
return {
title: '个人信息',
headPhoto: 'https://qn-static.banshouhui.com/self-support/avatar.gif',
headCertPhoto: 'https://qn-static.banshouhui.com/self-support/avatar.gif',
certFront: 'https://qn-static.banshouhui.com/self-support/renxiang.png',
certBack: 'https://qn-static.banshouhui.com/self-support/guohui.png',
idCardNum: '1312315661651',
expire: '2020-12-01~2090-09-01',
mobile: '1773322111',
name: '阿斯达',
company: '深圳维修会科技有限公司',
student: {},
token: null,
host: process.uniEnv.qn_asset_url,
code: '',
}
},
computed: {
headPhoto() {
return this.student.avatarPath || this.userInfo.avatarUrl
},
headCertPhoto() {
return (
this.student.certificatePhotoPath ||
process.uniEnv.qn_base_url + 'xitongtouxiang.png'
)
},
isupLoadCertPhoto() {
return true //this.member && this.member.certPhoto || false
return this.student.identityNumber || false
},
getMobile() {
return this.mobile
return this.student.phoneNumber || ''
},
getCompany() {
return this.student.workUnit || ''
},
getCertifyStatus() {
console.log(this.student.identityNumber)
return !this.student.identityNumber ? '去认证' : '已认证'
},
},
onLoad() {
this.$u.api.getQiNiuToken({ type: 'image' }).catch((data) => {
if (data.errMsg == 'request:ok') {
this.token = data.data.token //token为七牛云的token一般由后台接口提供
getApp().globalData.qiNiuToken = data.data.token
} else {
console.log('get token error', data)
this.$u.toast('获取token失败')
}
})
this.$u.api.getUserInfo().then((res) => {
this.student = res
console.log('stu', this.student)
})
},
methods: {
changeHead() {
//获取图片
upload.getPhoto(1, this.token).then((res) => {
this.headPhoto = this.host + res.key
goCertify() {
getApp().globalData.student = this.student
this.$u.route({
url: 'pages/mine/certify',
})
},
changeCertPhoto() {
//获取图片
upload.getPhoto(2, this.token).then((res) => {
//显示
this.headCertPhoto = this.host + res.key
goAddress() {
getApp().globalData.student = this.student
this.$u.route({
url: 'pages/mine/address',
})
},
getPhonenumber(e) {
var that = this
login.appLogin().then((res) => {
that.code = res.code
var code = that.code
if (e && e.detail) {
if (e.detail.errMsg.indexOf('user deny') > -1) {
//拒绝授权
} else if (e.detail.encryptedData && e.detail.iv) {
//允许授权-解析-更新手机号
let params = {
encryptedData: e.detail.encryptedData,
iv: e.detail.iv,
}
uni.checkSession({
success(ccc) {
//session_key 未过期,并且在本生命周期一直有效
params.code = code
that.$u.api.loginWechatAuth(params).then((res) => {
that.student.phoneNumber = res.phoneNumber
that.$u.api.updateUserInfo({
phoneNumber: res.phoneNumber,
})
})
},
fail() {
// session_key 已经失效,需要重新执行登录流程
that.toLogin()
},
})
} else {
this.$u.toast(e.detail.errMsg)
}
} else {
this.$u.toast('授权失败,请重新授权')
}
})
},
toLogin() {
uni.navigateTo({
url: 'pages/login/index',
})
},
getFront() {
changeHead() {
//获取图片
upload.getPhoto(1, this.token).then((res) => {
this.certFront = this.host + res.key
this.student.avatarPath = this.host + res.key
this.$u.api.updateUserInfo({
avatarPath: this.student.avatarPath,
})
})
},
getBack() {
changeCertPhoto() {
//获取图片
upload.getPhoto(1, this.token).then((res) => {
this.certBack = this.host + res.key
upload.getPhoto(2, this.token).then((res) => {
//显示
this.student.certificatePhotoPath = this.host + res.key
this.$u.api.updateUserInfo({
certificatePhotoPath: this.student.certificatePhotoPath,
})
})
},
toUrl(url) {
......@@ -185,4 +218,13 @@ export default {
.upload-image {
margin-top: 30rpx;
}
.mobile-button {
width: 200px;
height: 30px;
}
button::after {
border: none;
background-color: none;
}
</style>
<template>
<view class="content">
<u-cell-group class="cell-group" :border="false">
<u-cell-item
title="版本更新"
value="当前版本v1.1.0"
:border-bottom="false"
></u-cell-item>
</u-cell-group>
<view class="logout" @tap="logout">退出登录</view>
</view>
</template>
<script>
export default {
data() {
return {}
},
computed: {},
onLoad() {},
methods: {
logout() {
this.$u.vuex('vuex_token', '')
this.$u.vuex('openId', '')
this.$u.vuex('userInfo', {})
setTimeout(() => {
this.$u.route({
type: 'back',
})
}, 1000)
},
},
}
</script>
<style>
page {
background-color: #f7f9fc;
}
.content {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
width: 100%;
}
.cell-group {
width: 100%;
margin-top: 20rpx;
}
.logout {
width: 100%;
height: 100rpx;
margin-top: 16rpx;
background-color: white;
text-align: center;
line-height: 100rpx;
color: #fa5a49;
font-size: 32rp;
}
</style>
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