Browse Source

上传图片封装

master
unknown 1 year ago
parent
commit
97dfba8ef9
  1. 64
      components/pickDateTimer/pickDateTimer.vue
  2. 7
      config/api.js
  3. 92
      config/utils.js
  4. 12
      pages.json
  5. 81
      pages/carEntry/evaluate/comp/evaluateItem.vue
  6. 251
      pages/carEntry/simulateAppointment/comp/step1 - 副本.vue
  7. 86
      pages/carEntry/simulateAppointment/comp/step1.vue
  8. 41
      pages/indexEntry/consult/consult.vue
  9. 44
      pages/indexEntry/consult/pubComplaint/pubComplaint.vue
  10. 45
      pages/indexEntry/consult/pubConsult/pubConsult.vue
  11. 65
      pages/indexEntry/enroll/registInfo/registInfo.vue
  12. 2
      pages/tabbar/index/index.vue
  13. 492
      pages/userCenter/login/face.vue
  14. 2
      pages/userCenter/login/loginByPhone.vue

64
components/pickDateTimer/pickDateTimer.vue

@ -3,7 +3,7 @@
<view class="card"> <view class="card">
<view class="dateBox"> <view class="dateBox">
<view class="month-row"> <view class="month-row">
<view class="month">2032.08</view>
<view class="month" @click="show=true">{{ currentMonth }}</view>
<view class="arrow"> <view class="arrow">
<u-icon name="arrow-down" :size="12" :color="'#1989FA'"></u-icon> <u-icon name="arrow-down" :size="12" :color="'#1989FA'"></u-icon>
</view> </view>
@ -57,17 +57,30 @@
</view> </view>
</view> </view>
<u-datetime-picker
:show="show"
v-model="chooseMonth"
:minDate="minDate"
:maxDate="maxDate"
mode="year-month"
@confirm="changeMonth"
></u-datetime-picker>
</view> </view>
</template> </template>
<script> <script>
import { getDates } from '@/config/utils.js'
import { getDates, getMonthsBetweenDates } from '@/config/utils.js'
export default { export default {
data() { data() {
return { return {
maxDate: 0,
minDate: 0,
monthArr: [],
show: false,
dateArr: [], dateArr: [],
currentDay: 0,
currentDay: 0,//
chooseDay: '', chooseDay: '',
chooseMonth: '',
timerArr: [ timerArr: [
{status: 1, timer: '06:00-07:00', id: 1}, {status: 1, timer: '06:00-07:00', id: 1},
{status: 2, timer: '06:00-07:00', id: 2}, {status: 2, timer: '06:00-07:00', id: 2},
@ -78,15 +91,46 @@
{status: 2, timer: '06:00-07:00', id: 5}, {status: 2, timer: '06:00-07:00', id: 5},
{status: 3, timer: '06:00-07:00', id: 6}, {status: 3, timer: '06:00-07:00', id: 6},
], ],
chooseTimerId: ''
chooseTimerId: '',
endDate: null,
startDate: null,
} }
}, },
mounted() { mounted() {
const startDate = new Date('2023-09-06');
const endDate = new Date();
this.dateArr = getDates(startDate, endDate);
this.startDate = new Date('2023-08-06');
this.endDate = new Date();
this.minDate = this.startDate*1
this.maxDate = this.endDate*1
this.initDate()
},
computed: {
currentMonth() {
let tiemr = new Date(this.chooseDay) * 1
return this.$u.date(tiemr, 'yyyy.mm')
}
}, },
methods: { methods: {
//
initDate() {
this.dateArr = getDates(this.startDate, this.endDate);
this.chooseDay = this.dateArr[0][0].date
console.log(this.chooseDay)
},
//
changeMonth(val) {
let startDate = this.$u.date(val.value, 'yyyy-mm-dd')
for(let i=0; i<this.dateArr.length; i++) {
for(let j=0; j<this.dateArr[i].length; j++) {
let date = this.dateArr[i][j].date
if(startDate==date) {
this.currentDay = i
this.chooseDay = date
}
}
}
this.show = false
},
// //
chooseTimerClick(item) { chooseTimerClick(item) {
if(item.status!=1) return this.$u.toast('请选择可预约时间') if(item.status!=1) return this.$u.toast('请选择可预约时间')
@ -98,10 +142,10 @@
console.log(this.chooseDay) console.log(this.chooseDay)
}, },
changeDateIndex(num) { changeDateIndex(num) {
if(this.currentDay==0&&num==-1) return
if(this.currentDay==this.dateArr.length-1&&num==1) return
if(this.currentDay==0&&num==-1) return this.$u.toast('已是可选最小日期')
if(this.currentDay==this.dateArr.length-1&&num==1) return this.$u.toast('已是可选最大日期')
this.currentDay = this.currentDay + num this.currentDay = this.currentDay + num
console.log(this.currentDay)
this.chooseDay = this.dateArr[this.currentDay][0].date
}, },

7
config/api.js

@ -70,9 +70,10 @@ export const consultationClosed = (params) => http.get('business/appcomplain/clo
export const consultationType = (params) => http.get('system/dict/consultationType',) export const consultationType = (params) => http.get('system/dict/consultationType',)
// 投诉咨询记录 // 投诉咨询记录
export const studentComplain = (params) => http.get('business/appcomplain/studentComplain', {params: params}) export const studentComplain = (params) => http.get('business/appcomplain/studentComplain', {params: params})
// 上传图片
export const uploadImg = (data) => http.post('infra/file/upload', data)
// 常见问题
export const askedQuestion = (params) => http.get('business/complainqa/page', {params: params})
// 获取地区
export const areaTree = () => http.get('system/area/tree', )
// 驾照类型 // 驾照类型
export const licenseType = () => http.get('system/dict/licenseType', ) export const licenseType = () => http.get('system/dict/licenseType', )
// 区域 // 区域

92
config/utils.js

@ -1,3 +1,8 @@
import { WX_API, H5_API, httpPrefix } from '@/config/site.config.js';
var _url = H5_API+ WX_API + httpPrefix
import store from '@/store/index.js'
export function checkToken(vm) { export function checkToken(vm) {
let expiresTime = vm.$store.state.user.vuex_loginInfo.expiresTime let expiresTime = vm.$store.state.user.vuex_loginInfo.expiresTime
let nowTime = new Date() * 1 let nowTime = new Date() * 1
@ -20,8 +25,8 @@ function dateRangeFn(dateRange) {
const daysOfWeek = ['日', '一', '二', '三', '四', '五', '六']; const daysOfWeek = ['日', '一', '二', '三', '四', '五', '六'];
const dayOfWeek = date.getDay(); const dayOfWeek = date.getDay();
const weekName = daysOfWeek[dayOfWeek]; const weekName = daysOfWeek[dayOfWeek];
console.log(dateStr)
console.log(weekName)
// console.log(dateStr)
// console.log(weekName)
if (tmp.length == 0) { if (tmp.length == 0) {
dateArr.push(tmp) dateArr.push(tmp)
} }
@ -39,6 +44,7 @@ function dateRangeFn(dateRange) {
return dateArr return dateArr
} }
// 获取两个时间段的所有日期
export function getDates(startDate, endDate) { export function getDates(startDate, endDate) {
const dates = []; const dates = [];
let currentDate = new Date(startDate); let currentDate = new Date(startDate);
@ -48,4 +54,84 @@ export function getDates(startDate, endDate) {
currentDate.setDate(currentDate.getDate() + 1); currentDate.setDate(currentDate.getDate() + 1);
} }
return dateRangeFn(dates) return dateRangeFn(dates)
}
}
// 获取两个时间段的所有月份
export function getMonthsBetweenDates(startDate, endDate) {
let months = [];
let currentDate = new Date(startDate);
while (currentDate <= endDate) {
const year = currentDate.getFullYear();
const month = currentDate.getMonth() + 1; // 月份从0开始,所以要加1
months.push(`${year}-${month.toString().padStart(2, '0')}`);
// 将当前日期设置为下一个月的第一天
currentDate.setMonth(currentDate.getMonth() + 1);
currentDate.setDate(1);
}
return months;
}
//选择图片
export function chooseImages(num=0) {
let imgNum = 3 - num
let tempArr = []
return new Promise((reslove, reject)=>{
uni.chooseImage({
count: imgNum, //允许选择的数量
sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
sourceType: ['album', 'camera'], //从相册选择
success: res => {
uni.showLoading({
title: '图片上传中...'
});
console.log(res)
res.tempFiles.forEach( async (item,index)=>{
let dataImg = await uploadImgApi(item.path, index)
if(dataImg) tempArr.push(dataImg)
if(index==res.tempFiles.length-1) {
reslove(tempArr)
}
})
}
})
})
}
export function uploadImgApi(filePath, imgName) {
console.log(filePath)
let token = 'Bearer '+ store.state.user.vuex_loginInfo.accessToken
let timer = new Date() * 1
return new Promise((reslove, reject)=>{
// 上传图片到服务器
uni.uploadFile({
url: _url + 'infra/file/upload',//接口
filePath: filePath,//要上传的图片的本地路径
name: 'file',
formData: {
path: 'complain/'+ uni.$u.date(timer, 'yyyy-mm-dd')+'/'+timer + '-'+ imgName,
type: 1,
fileSuffix: "png"
},
header: {
Authorization: token,
'tenant-id': 1
},
success(res) {
console.log('上传成功')
let res2 = JSON.parse(res.data)
reslove(res2.data)
},
fail() {
reject(0)
},
complete: (err)=> {
uni.hideLoading();
}
})
})
}

12
pages.json

@ -271,7 +271,7 @@
"style": { "style": {
"navigationBarTitleText": "咨询投诉", "navigationBarTitleText": "咨询投诉",
"navigationStyle": "custom", "navigationStyle": "custom",
"enablePullDownRefresh": false,
"enablePullDownRefresh": true,
"backgroundTextStyle": "dark" "backgroundTextStyle": "dark"
} }
}, },
@ -511,6 +511,16 @@
} }
}, },
{ {
"path": "login/face",
"style": {
"navigationBarTitleText": "登录",
"navigationStyle": "custom",
"enablePullDownRefresh": false,
"backgroundTextStyle": "dark"
}
},
{
"path": "login/loginByPhone", "path": "login/loginByPhone",
"style": { "style": {
"navigationBarTitleText": "手机号登录", "navigationBarTitleText": "手机号登录",

81
pages/carEntry/evaluate/comp/evaluateItem.vue

@ -4,10 +4,9 @@
<view class="card"> <view class="card">
<view class="top_row"> <view class="top_row">
<view class="tit">{{ info.tit }}</view> <view class="tit">{{ info.tit }}</view>
<!-- <u-checkbox-group >
<u-checkbox v-model="info.anonymity" shape="circle" label="匿名提交" :iconSize="12" name="匿名提交" :labelSize="12"></u-checkbox>
</u-checkbox-group> -->
<u-checkbox v-model="info.anonymity" shape="circle" label="匿名提交" :iconSize="12" :name="info.anonymity" :labelSize="12" @change="changeChe"></u-checkbox>
<u-checkbox-group >
<u-checkbox v-model="info.anonymity" shape="circle" label="匿名提交" :iconSize="12" name="匿名提交" :labelSize="12" @change="changeChe"></u-checkbox>
</u-checkbox-group>
</view> </view>
<view class="user_row"> <view class="user_row">
<view class="avatar"> <view class="avatar">
@ -89,8 +88,7 @@
</template> </template>
<script> <script>
import { WX_API, H5_API, prefix } from '@/config/site.config.js';
var _url = H5_API+ WX_API
import { uploadImgApi } from '@/config/utils.js'
export default { export default {
props: [ 'info' ], props: [ 'info' ],
data() { data() {
@ -118,40 +116,19 @@
uni.chooseVideo({ uni.chooseVideo({
sourceType: ['album', 'camera'], sourceType: ['album', 'camera'],
compressed: true, compressed: true,
success: (res)=> {
success: async (res)=> {
// //
console.log(res.tempFilePath); console.log(res.tempFilePath);
// //
this.uploadImgApi(res.tempFilePath, res.name, 'video')
let videoUrl = await uploadImgApi(res.tempFilePath, res.name, 'video')
if(videoUrl) this.info.videoUrl = videoUrl
}, },
fail: function (error) { fail: function (error) {
console.log(error); console.log(error);
} }
}); });
}, },
uploadVideo(filePath) {
uni.uploadFile({
url: 'https://your-upload-api.com/upload-video',
filePath: filePath,
name: 'video',
formData: {
//
},
success: function (res) {
var data = JSON.parse(res.data);
if (data.code === 0) {
//
console.log('上传成功', data);
} else {
//
console.log('上传失败', data);
}
},
fail: function (error) {
console.log('上传失败', error);
}
});
},
// //
chooseImages(type) { chooseImages(type) {
let imgNum = 3 - (this.imgArr.length) let imgNum = 3 - (this.imgArr.length)
@ -164,48 +141,14 @@
title: '图片上传中...' title: '图片上传中...'
}); });
console.log(res) console.log(res)
res.tempFiles.forEach( (item,index)=>{
this.uploadImgApi(item.path, item.name)
res.tempFiles.forEach(async (item,index)=>{
let imgLink = await uploadImgApi(item.path, index)
if(imgLink) this.info.imgArr.push(imgLink)
}) })
} }
}) })
}, },
uploadImgApi(filePath, imgName, vdo) {
console.log(filePath)
let token = 'Bearer '+ this.$store.state.user.vuex_loginInfo.accessToken
let _this = this
let timer = new Date() * 1
//
uni.uploadFile({
url: _url + 'app-api/infra/file/upload',//
filePath: filePath,//
name: 'file',
formData: {
path: 'complain/'+ uni.$u.date(name, 'yyyy-mm-dd')+'/'+timer + '-'+ imgName,
type: 1,
fileSuffix: "png"
},
header: {
Authorization: token,
'tenant-id': 1
},
success(res) {
console.log('上传成功')
let res2 = JSON.parse(res.data)
if(vdo) {
_this.info.videoUrl = res2.data
}else {
_this.info.imgArr.push(res2.data)
}
console.log(res2)
uni.hideLoading();
},
complete: (err)=> {
console.log(err)
}
})
},
} }
} }
</script> </script>

251
pages/carEntry/simulateAppointment/comp/step1 - 副本.vue

@ -0,0 +1,251 @@
<template>
<view class="step1">
<view class="card">
<view class="dateBox">
<view class="month-row">
<view class="month">2032.08</view>
<view class="arrow">
<u-icon name="arrow-down" :size="12" :color="'#1989FA'"></u-icon>
</view>
</view>
<view class="date_row">
<view class="icon left" @click="changeDateIndex(-1)">
<u-icon name="arrow-left" :size="12" :color="'#fff'"></u-icon>
</view>
<view class="dateArr" >
<view class="dateWidth" v-for="(item,index) in dateArr[currentDay]" :key="index" @click="chooseDate(item)" >
<view class="date" :class="{active: chooseDay==item.date}">
<view class="week">{{ item.week }}</view>
<view class="num">{{ item.num }}</view>
</view>
</view>
</view>
<view class="icon right" @click="changeDateIndex(1)">
<u-icon name="arrow-right" :size="12" :color="'#fff'"></u-icon>
</view>
</view>
</view>
</view>
<view class="card">
<view class="timeCon">
<view class="h2">上午</view>
<view class="time_box">
<view class="time_item" v-for="(item,index) in timerArr" :key="index" @click="chooseTimerClick(item)" :class="{active: item.id==chooseTimerId, disable: item.status!==1}">
<view class="lab" v-if="item.status==3">已过期</view>
<view class="lab" v-if="item.status==2">已约满</view>
<view class="lab" v-if="item.status==1">可预约</view>
<view class="time">{{ item.timer }}</view>
</view>
</view>
<view class="h2">下午</view>
<view class="time_box">
<view class="time_item" v-for="(item,index) in timerArr2" :key="index" @click="chooseTimerClick(item)" :class="{active: item.id==chooseTimerId,disable: item.status!==1}">
<view class="lab" v-if="item.status==3">已过期</view>
<view class="lab" v-if="item.status==2">已约满</view>
<view class="lab" v-if="item.status==1">可预约</view>
<view class="time">{{ item.timer }}</view>
</view>
</view>
</view>
</view>
<view class="btn" @click="changeStep(2)">下一步</view>
</view>
</template>
<script>
import { getDates } from '@/config/utils.js'
export default {
data() {
return {
dateArr: [],
currentDay: 0,
chooseDay: '',
timerArr: [
{status: 1, timer: '06:00-07:00', id: 1},
{status: 2, timer: '06:00-07:00', id: 2},
{status: 3, timer: '06:00-07:00', id: 3},
],
timerArr2: [
{status: 1, timer: '06:00-07:00', id: 4},
{status: 2, timer: '06:00-07:00', id: 5},
{status: 3, timer: '06:00-07:00', id: 6},
],
chooseTimerId: ''
}
},
mounted() {
const startDate = new Date('2023-09-06');
const endDate = new Date();
this.dateArr = getDates(startDate, endDate);
},
methods: {
//
chooseTimerClick(item) {
if(item.status!=1) return this.$u.toast('请选择可预约时间')
this.chooseTimerId = item.id
},
//
chooseDate(item) {
this.chooseDay = item.date
console.log(this.chooseDay)
},
changeDateIndex(num) {
if(this.currentDay==0&&num==-1) return
if(this.currentDay==this.dateArr.length-1&&num==1) return
this.currentDay = this.currentDay + num
console.log(this.currentDay)
},
changeStep(val) {
this.$emit('changeStep', val)
},
}
}
</script>
<style lang="scss" scoped>
.card {
width: 100%;
margin-bottom: 24rpx;
overflow: hidden;
.dateBox {
padding: 36rpx 0 40rpx 0;
.month-row {
display: flex;
justify-content: center;
align-items: center;
margin-bottom: 36rpx;
.month {
font-size: 32rpx;
color: $themC;
}
.arrow {
margin-left: 6rpx;
}
}
.date_row {
width: 100%;
height: 100rpx;
position: relative;
.icon {
width: 40rpx;
height: 40rpx;
background: rgba(51,51,51,0.18);
backdrop-filter: blur(4rpx);
position: absolute;
top: 50%;
transform: translateY(-50%);
display: flex;
align-items: center;
justify-content: center;
border-radius: 50%;
&.left {
left: 16rpx;
}
&.right {
right: 16rpx;
}
}
.dateArr {
display: flex;
padding: 0 70rpx;
// justify-content: space-between;
&.oneDate {
justify-content: center;
}
.dateWidth {
width: 20%;
display: flex;
justify-content: center;
}
.date {
width: 74rpx;
height: 100rpx;
border-radius: 16rpx;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
font-size: 28rpx;
color: #333;
&.active {
background: rgba(25,137,250,0.1);
border: 2rpx solid #1989FA;
color: $themC;
}
.week {
}
.num {
margin-top: 4rpx;
}
}
}
}
}
}
.card {
.timeCon {
padding: 0 24rpx 40rpx 24rpx;
}
.h2 {
line-height: 90rpx;
font-weight: 500;
color: #333;
}
.time_box {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
.time_item {
width: 30%;
height: 120rpx;
background: #F8F8F8;
border-radius: 12rpx;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
border-radius: 12rpx;
color: #333;
&.active {
background: rgba(25,137,250,0.1);
border: 2rpx solid #1989FA;
color: $themC;
}
&.disable {
opacity: 0.4;
}
.lab {
font-size: 28rpx;
font-weight: 500;
}
.time {
font-size: 24rpx;
margin-top: 4rpx;
}
}
}
}
.btn {
width: 47%;
height: 72rpx;
background: #1989FA;
border-radius: 8rpx;
font-size: 28rpx;
color: #fff;
text-align: center;
line-height: 72rpx;
margin: 108rpx auto 50rpx auto;
}
</style>

86
pages/carEntry/simulateAppointment/comp/step1.vue

@ -1,102 +1,24 @@
<template> <template>
<view class="step1"> <view class="step1">
<view class="card">
<view class="dateBox">
<view class="month-row">
<view class="month">2032.08</view>
<view class="arrow">
<u-icon name="arrow-down" :size="12" :color="'#1989FA'"></u-icon>
</view>
</view>
<view class="date_row">
<view class="icon left" @click="changeDateIndex(-1)">
<u-icon name="arrow-left" :size="12" :color="'#fff'"></u-icon>
</view>
<view class="dateArr" >
<view class="dateWidth" v-for="(item,index) in dateArr[currentDay]" :key="index" @click="chooseDate(item)" >
<view class="date" :class="{active: chooseDay==item.date}">
<view class="week">{{ item.week }}</view>
<view class="num">{{ item.num }}</view>
</view>
</view>
</view>
<view class="icon right" @click="changeDateIndex(1)">
<u-icon name="arrow-right" :size="12" :color="'#fff'"></u-icon>
</view>
</view>
</view>
</view>
<view class="card">
<view class="timeCon">
<view class="h2">上午</view>
<view class="time_box">
<view class="time_item" v-for="(item,index) in timerArr" :key="index" @click="chooseTimerClick(item)" :class="{active: item.id==chooseTimerId, disable: item.status!==1}">
<view class="lab" v-if="item.status==3">已过期</view>
<view class="lab" v-if="item.status==2">已约满</view>
<view class="lab" v-if="item.status==1">可预约</view>
<view class="time">{{ item.timer }}</view>
</view>
</view>
<view class="h2">下午</view>
<view class="time_box">
<view class="time_item" v-for="(item,index) in timerArr2" :key="index" @click="chooseTimerClick(item)" :class="{active: item.id==chooseTimerId,disable: item.status!==1}">
<view class="lab" v-if="item.status==3">已过期</view>
<view class="lab" v-if="item.status==2">已约满</view>
<view class="lab" v-if="item.status==1">可预约</view>
<view class="time">{{ item.timer }}</view>
</view>
</view>
</view>
</view>
<pickDateTimer/>
<view class="btn" @click="changeStep(2)">下一步</view> <view class="btn" @click="changeStep(2)">下一步</view>
</view> </view>
</template> </template>
<script> <script>
import { getDates } from '@/config/utils.js'
export default { export default {
data() { data() {
return { return {
dateArr: [],
currentDay: 0,
chooseDay: '',
timerArr: [
{status: 1, timer: '06:00-07:00', id: 1},
{status: 2, timer: '06:00-07:00', id: 2},
{status: 3, timer: '06:00-07:00', id: 3},
],
timerArr2: [
{status: 1, timer: '06:00-07:00', id: 4},
{status: 2, timer: '06:00-07:00', id: 5},
{status: 3, timer: '06:00-07:00', id: 6},
],
chooseTimerId: ''
} }
}, },
mounted() { mounted() {
const startDate = new Date('2023-09-06');
const endDate = new Date();
this.dateArr = getDates(startDate, endDate);
}, },
methods: { methods: {
//
chooseTimerClick(item) {
if(item.status!=1) return this.$u.toast('请选择可预约时间')
this.chooseTimerId = item.id
},
//
chooseDate(item) {
this.chooseDay = item.date
console.log(this.chooseDay)
},
changeDateIndex(num) {
if(this.currentDay==0&&num==-1) return
if(this.currentDay==this.dateArr.length-1&&num==1) return
this.currentDay = this.currentDay + num
console.log(this.currentDay)
},
changeStep(val) { changeStep(val) {
this.$emit('changeStep', val) this.$emit('changeStep', val)
}, },

41
pages/indexEntry/consult/consult.vue

@ -16,35 +16,62 @@
<view class="h1">常风问题</view> <view class="h1">常风问题</view>
<view class="card que"> <view class="card que">
<u-collapse :body-style="itemStyle" :border="false"> <u-collapse :body-style="itemStyle" :border="false">
<u-collapse-item :title="item.head" v-for="(item, index) in itemList" :key="index" style="border-bottom: 1rpx solid #E8E9EC;">
{{item.body}}
<u-collapse-item :title="item.question" v-for="(item, index) in itemList" :key="index" style="border-bottom: 1rpx solid #E8E9EC;">
<text style=" color: #999;">{{item.answer}}</text>
<!-- {{item.answer}} -->
</u-collapse-item> </u-collapse-item>
</u-collapse> </u-collapse>
</view> </view>
</view> </view>
</view> </view>
<view style="padding: 20rpx 0;" v-if="itemList.length">
<u-loadmore :status="status" />
</view>
<nodata v-if="!itemList.length&&status=='nomore'"></nodata>
</view> </view>
</template> </template>
<script> <script>
import { askedQuestion } from '@/config/api.js'
export default { export default {
data() { data() {
return { return {
itemStyle: { itemStyle: {
marginLeft:'20rpx', marginLeft:'20rpx',
}, },
itemList: [
{head: '画沙', body: '用手中的流沙画一个你呀,用手中的流沙画一个你呀,用手中的流沙画一个你呀,'}
],
itemList: [],
tabArr: [ tabArr: [
{text: '我要咨询', icon: require('../../../static/images/index/ic_zixun.png'), url:'/pages/indexEntry/consult/pubConsult/pubConsult', id: 1}, {text: '我要咨询', icon: require('../../../static/images/index/ic_zixun.png'), url:'/pages/indexEntry/consult/pubConsult/pubConsult', id: 1},
{text: '我要投诉', icon: require('../../../static/images/index/ic_tousu.png'), url: '/pages/indexEntry/consult/pubComplaint/pubComplaint', id: 2,}, {text: '我要投诉', icon: require('../../../static/images/index/ic_tousu.png'), url: '/pages/indexEntry/consult/pubComplaint/pubComplaint', id: 2,},
{text: '查看记录', icon: require('../../../static/images/index/ic_jilu.png'), url: '/pages/indexEntry/consult/record/record', id: 3}, {text: '查看记录', icon: require('../../../static/images/index/ic_jilu.png'), url: '/pages/indexEntry/consult/record/record', id: 3},
]
],
params: {
pageNo: 1,
pageSize: 20
},
status: 'loading'
} }
}, },
onLoad() {
this.askedQuestionFn()
},
onPullDownRefresh() {
this.params.pageNo = 1
this.itemList = []
this.askedQuestionFn().then(()=>{ uni.stopPullDownRefresh()})
},
methods: { methods: {
async askedQuestionFn() {
const {data: res} = await askedQuestion(this.params)
this.params.pageNo ++
this.itemList.push(...res.list)
this.total = res.total
if(this.itemList.length>=this.total) {
this.status = 'nomore'
}else {
this.status = 'loadmore'
}
}
} }
} }
</script> </script>

44
pages/indexEntry/consult/pubComplaint/pubComplaint.vue

@ -100,9 +100,9 @@
<script> <script>
import { createcomplain, consultationType } from '@/config/api.js' import { createcomplain, consultationType } from '@/config/api.js'
import { WX_API, H5_API, prefix } from '@/config/site.config.js';
import searchSchool from '@/pages/indexEntry/enroll/registInfo/comp/searchSchool.vue' import searchSchool from '@/pages/indexEntry/enroll/registInfo/comp/searchSchool.vue'
var _url = H5_API+ WX_API
import { uploadImgApi } from '@/config/utils.js'
export default { export default {
components: { searchSchool }, components: { searchSchool },
@ -196,45 +196,15 @@
uni.showLoading({ uni.showLoading({
title: '图片上传中...' title: '图片上传中...'
}); });
console.log(res)
res.tempFiles.forEach( (item,index)=>{
this.uploadImgApi(item.path, item.name)
// console.log(res)
res.tempFiles.forEach( async (item,index)=>{
let imgLink = await uploadImgApi(item.path, item.name)
this.imgArr.push(imgLink)
}) })
} }
}) })
}, },
uploadImgApi(filePath, imgName) {
console.log(filePath)
let token = 'Bearer '+ this.$store.state.user.vuex_loginInfo.accessToken
let _this = this
let timer = new Date() * 1
//
uni.uploadFile({
url: _url + 'app-api/infra/file/upload',//
filePath: filePath,//
name: 'file',
formData: {
path: 'complain/'+ uni.$u.date(name, 'yyyy-mm-dd')+'/'+timer + '-'+ imgName,
type: 1,
fileSuffix: "png"
},
header: {
Authorization: token,
'tenant-id': 1
},
success(res) {
console.log('上传成功')
let res2 = JSON.parse(res.data)
_this.imgArr.push(res2.data)
console.log(res2)
uni.hideLoading();
},
complete: (err)=> {
console.log(err)
}
})
},
async submintFn() { async submintFn() {
if(!this.btnActive) return if(!this.btnActive) return
if(!this.form.content) return this.$u.toast('请输入内容') if(!this.form.content) return this.$u.toast('请输入内容')

45
pages/indexEntry/consult/pubConsult/pubConsult.vue

@ -44,9 +44,9 @@
</template> </template>
<script> <script>
import { WX_API, H5_API, prefix } from '@/config/site.config.js';
import { createconsult } from '@/config/api.js' import { createconsult } from '@/config/api.js'
var _url = H5_API+ WX_API
import { uploadImgApi } from '@/config/utils.js'
// let url = 'api' // let url = 'api'
export default { export default {
data() { data() {
@ -91,44 +91,17 @@
uni.showLoading({ uni.showLoading({
title: '图片上传中...' title: '图片上传中...'
}); });
res.tempFiles.forEach( (item,index)=>{
this.uploadImgApi(item.path, item.name)
console.log(res)
console.log('图片信息')
res.tempFiles.forEach(async (item,index)=>{
// ,
const imgLink = await uploadImgApi(item.path, index)
this.imgArr.push(imgLink)
}) })
} }
}) })
}, },
uploadImgApi(filePath, imgName) {
console.log(filePath)
let token = 'Bearer '+ this.$store.state.user.vuex_loginInfo.accessToken
let _this = this
let timer = new Date() * 1
//
uni.uploadFile({
url: _url + 'app-api/infra/file/upload',//
filePath: filePath,//
name: 'file',
formData: {
path: 'complain/'+ uni.$u.date(name, 'yyyy-mm-dd')+timer + '-'+ imgName,
type: 1,
fileSuffix: "png"
},
header: {
Authorization: token,
'tenant-id': 1
},
success(res) {
console.log('上传成功')
let res2 = JSON.parse(res.data)
_this.imgArr.push(res2.data)
console.log(res2)
uni.hideLoading();
},
complete: (err)=> {
console.log(err)
}
})
},
} }
} }
</script> </script>

65
pages/indexEntry/enroll/registInfo/registInfo.vue

@ -147,7 +147,7 @@
</view> </view>
<view class="card" v-if="form.radiovalue2==1"> <view class="card" v-if="form.radiovalue2==1">
<view class="row">
<view class="row" @click="cityShowFn">
<view class="lab">来源城市</view> <view class="lab">来源城市</view>
<view class="rightCon"> <view class="rightCon">
<view class="row"> <view class="row">
@ -272,6 +272,8 @@
<u-picker :show="showSubjectPass" :columns="columnsSubject" keyName="label" @confirm="confirmSubjectPass" @cancel="showSubjectPass=false"></u-picker> <u-picker :show="showSubjectPass" :columns="columnsSubject" keyName="label" @confirm="confirmSubjectPass" @cancel="showSubjectPass=false"></u-picker>
<!-- 待科目 --> <!-- 待科目 -->
<u-picker :show="showSubjectTreat" :columns="columnsSubject" keyName="label" @confirm="confirmTreat" @cancel="showSubjectTreat=false"></u-picker> <u-picker :show="showSubjectTreat" :columns="columnsSubject" keyName="label" @confirm="confirmTreat" @cancel="showSubjectTreat=false"></u-picker>
<!-- 城市 -->
<u-picker :show="showCity" ref="uPicker" :columns="[cityArr]" @confirm="confirmCity" @change="changeHandler" keyName="name"></u-picker>
</view> </view>
</template> </template>
@ -280,10 +282,12 @@
import comfigPopup from './comp/comfigPopup' import comfigPopup from './comp/comfigPopup'
import searchSchool from './comp/searchSchool' import searchSchool from './comp/searchSchool'
import oldDrive from './comp/oldDrive' import oldDrive from './comp/oldDrive'
import { areaTree } from '@/config/api.js'
export default { export default {
components: { comfigPopup, searchSchool, oldDrive }, components: { comfigPopup, searchSchool, oldDrive },
data() { data() {
return { return {
showCity: false,
showPopup: false, showPopup: false,
showClassModel: false, showClassModel: false,
showCar: false, showCar: false,
@ -327,7 +331,9 @@
showSchool: false, showSchool: false,
radiolist1: [ {name: '初领', id: 1}, {name: '增驾', id: 2}], radiolist1: [ {name: '初领', id: 1}, {name: '增驾', id: 2}],
radiolist2: [ {name: '是', id: 1}, {name: '否', id: 2}], radiolist2: [ {name: '是', id: 1}, {name: '否', id: 2}],
radiolist3: [ {name: '全款', id: 1}, {name: '预付款', id: 2}]
radiolist3: [ {name: '全款', id: 1}, {name: '预付款', id: 2}],
cityArr: [],
cityArr2: [[]]
} }
}, },
onLoad() { onLoad() {
@ -335,7 +341,7 @@
console.log(item) console.log(item)
this.form.coach = item.name this.form.coach = item.name
}) })
this.areaTreeFn()
let schoolClass = this.$store.state.school.schoolClass let schoolClass = this.$store.state.school.schoolClass
console.log(schoolClass) console.log(schoolClass)
if(schoolClass.id) { if(schoolClass.id) {
@ -355,6 +361,59 @@
} }
}, },
methods: { methods: {
cityShowFn() {
this.showCity = true
// picker = this.$refs.uPicker
},
changeHandler(e) {
const {
columnIndex,
value,
values, // values
index,
// pickerref
picker = this.$refs.uPicker
} = e
// ()
if (columnIndex === 0) {
// pickerthis
picker.setColumnValues(1, this.cityArr2[index])
}
},
// columnIndexvaluevalues
confirmCity(e) {
console.log('confirm', e)
this.showCity = false
},
//
async areaTreeFn() {
const {data: res} = await areaTree()
this.cityArr = res.map(item=>{
let obj = {
id: item.id,
name: item.name
}
this.cityArr2[0].push(this.traverse(item.children))
return obj
})
console.log(this.cityArr)
console.log(this.cityArr2)
// this.showCity = res
},
traverse(arr, result=[]) {
for (var i = 0; i < arr.length; i++) {
let item = arr[i]
let obj = {
id: item.id,
name: item.name
}
result.push(obj)
if(item.children.length) {
this.traverse(item.children, result)
}
}
return result;
},
// //
chooseSchool(item) { chooseSchool(item) {
this.form.school = item.name this.form.school = item.name

2
pages/tabbar/index/index.vue

@ -1,5 +1,6 @@
<template> <template>
<view class="main pageBg"> <view class="main pageBg">
<button @click="$goPage('/pages/userCenter/login/face')">进入人脸识别</button>
<view style="background-color: #2170FD; width: 100%;height: 20rpx;"></view> <view style="background-color: #2170FD; width: 100%;height: 20rpx;"></view>
<!-- <u-navbar title=" " :bgColor="bgColor" :autoBack="false"> <!-- <u-navbar title=" " :bgColor="bgColor" :autoBack="false">
<view class="" slot="left"> <view class="" slot="left">
@ -287,7 +288,6 @@
}, },
onShow() { onShow() {
}, },
computed: { computed: {
// joe() { // joe() {

492
pages/userCenter/login/face.vue

@ -0,0 +1,492 @@
<template>
<view class="page-content">
<!-- #ifdef MP-WEIXIN -->
<!-- <u-navbar title="人脸识别" :is-back="true" :background="{backgroundColor: '#ffffff'}"></u-navbar> -->
<topNavbar title="人脸识别"></topNavbar>
<!-- #endif -->
<view class="containerV">
<view class="headerV">
<view class="top-tips1">
<view>请将正对手机头部匹配摄像区域</view>
</view>
<view class="top-tips2">
为了便于识别认证请拍摄本人头像
</view>
</view>
<!-- <u-circle-progress active-color="#2979ff" :percent="80"> -->
<view class="contentV">
<view class="mark"></view>
<image v-if="tempImg" mode="widthFix" :src="tempImg" />
<camera v-if='isAuthCamera' class="camera" :device-position="devicePosition ?'front': 'back'"
flash="off" resolution='high'>
</camera>
<view v-show="!tempImg && tipsText" class="tipV">{{ tipsText }}</view>
</view>
<!-- </u-circle-progress> -->
<view class="footerV">
<view style="width: 100%;">
<view v-if="!tempImg" style="width: 100%;">
<view class="bottom-tips-2">该照片仅作为你认证的凭证</view>
</view>
</view>
</view>
</view>
</view>
</template>
<script>
import { WX_API, H5_API, prefix } from '@/config/site.config.js';
import { createconsult } from '@/config/api.js'
var _url = H5_API+ WX_API
export default {
name: 'index',
components: {},
data() {
return {
tipsText: '', //
tempImg: '', //
BASE_API: '',
cameraEngine: null, //
devicePosition: true, //
isAuthCamera: true, //
uploadUrl: _url + 'app-api/infra/file/upload',
faceGetResult: '',
count: 0,
isload:false,//
}
},
onLoad(options) {
this.initData()
},
mounted() {
},
methods: {
//
initData() {
// #ifdef MP-WEIXIN
// 1
wx.initFaceDetect()
// 2 camera CameraContext
this.cameraEngine = wx.createCameraContext()
// 3 Camera
const listener = this.cameraEngine.onCameraFrame((frame) => {
if (this.tempImg) {
return;
}
// 4使 wx.initFaceDetect 使
wx.faceDetect({
frameBuffer: frame.data,
width: frame.width,
height: frame.height,
enablePoint: true,
enableConf: true,
enableAngle: true,
enableMultiFace: true,
success: (faceData) => {
let face = faceData.faceInfo[0]
if (faceData.x == -1 || faceData.y == -1) {
this.tipsText = '检测不到人'
}
if (faceData.faceInfo.length > 1) {
this.tipsText = '请保证只有一个人'
} else {
const {
pitch,
roll,
yaw
} = face.angleArray;
const standard = 0.5
if (Math.abs(pitch) >= standard || Math.abs(roll) >= standard ||
Math.abs(yaw) >= standard) {
this.tipsText = '请平视摄像头'
} else if (face.confArray.global <= 0.8 || face.confArray.leftEye <=
0.8 || face.confArray.mouth <= 0.8 || face.confArray.nose <= 0.8 ||
face.confArray.rightEye <= 0.8) {
this.tipsText = '请勿遮挡五官'
} else {
// this.tipsText = ''
//
this.handleTakePhotoClick()
}
}
},
fail: (err) => {
if (err.x == -1 || err.y == -1) {
this.tipsText = '检测不到人'
} else {
this.tipsText = err.errMsg || '网络错误,请退出页面重试'
}
},
})
})
// 5
listener.start()
// #endif
},
//
handleTakePhotoClick() {
// if (this.tipsText != "" && this.tipsText != "") {
// return;
// }
if(this.isload) return
this.isload = true
uni.getSetting({
success: (res) => {
if (!res.authSetting['scope.camera']) {
this.isAuthCamera = false
uni.openSetting({
success: (res) => {
if (res.authSetting['scope.camera']) {
this.isAuthCamera = true;
}
}
})
}
}
})
this.cameraEngine.takePhoto({
quality: "high",
success: ({
tempImagePath
}) => {
this.tempImg = tempImagePath
// this.isAuthCamera = false
uni.showLoading({
title: '人脸核身中,请耐心等待....'
})
this.upLoad(tempImagePath)
console.log('tempImagePath', tempImagePath)
}
})
},
async upLoad(imgPath) {
console.log('然后这里imgPath1111', imgPath)
// this.againEvent()
// return
const url = await this.UpImgResolve(imgPath, this.uploadUrl)
this.faceGetResultEvent(url)
console.log('然后这里imgPath', url, '9d1b7998-4949-46c7-a39f-726aad966664')
// imgPath
//
},
UpImgResolve(file, url) {
let that = this
let token = 'Bearer '+ this.$store.state.user.vuex_loginInfo.accessToken
let _this = this
let timer = new Date() * 1
//
setTimeout((res => {
console.log('3122223')
uni.hideLoading();
that.againEvent()
}), 10000)
return new Promise(function(resolve, reject) {
uni.uploadFile({
url: _url + 'app-api/infra/file/upload',//
filePath: file,//
name: 'file',
formData: {
path: 'complain/'+ uni.$u.date(timer, 'yyyy-mm-dd')+timer,
type: 1,
fileSuffix: "png"
},
header: {
Authorization: token,
'tenant-id': 1
},
success: function(uploadFileRes) {
if (!uploadFileRes.data) return that.againEvent()
const urlJosn = JSON.parse(uploadFileRes.data)
console.log('拿到照片地址---',urlJosn.data)
resolve(urlJosn.data)
},
error(res) {
console.log('313', res)
uni.hideLoading();
that.againEvent()
},
catach(res) {
console.log('3122223', res)
uni.hideLoading();
that.againEvent()
}
});
})
},
faceGetResultEvent(url) {
let that = this
console.log('走进核身---',url)
uni.request({
url: that.faceGetResult,
method: "post",
data: {
'livenessType': 'SILENT',
'type': 3,
'imageUrl': url,
'identityType':2,
'url':url
},
header: {
'token': uni.getStorageSync('accessToken')
},
success: (res) => {
uni.hideLoading()
console.log('走进核身返回数据---',res )
if (res.data.code != 200) {
uni.showToast({
title: '核身失败',
icon: "none",
mask: true,
})
that.againEvent()
return
} else {
that.$u.route({
type: 'tab',
url: '/pages/tabbar/index/index'
});
}
console.log('res', 1111, res)
},
fail:(res)=>{
console.log('核身失败原因---', res)
}
})
},
//
againEvent() {
uni.hideLoading()
this.count++
if (this.count >= 5) {
uni.showToast({
title: '核身失败',
icon: "none",
mask: true,
})
return uni.navigateBack()
}
setTimeout((res => {
this.isload = false
this.tempImg = false
this.isAuthCamera = true
this.devicePosition = true
}), 1500)
}
}
}
</script>
<style lang="scss" scoped>
page {
background: #fff;
}
.page-content {
width: 100%;
height: 100%;
.containerV {
width: 100%;
height: 100%;
.headerV {
.top-tips1 {
margin-top: 60rpx;
color: #1C1C1C;
font-size: 36rpx;
text-align: center;
}
.top-tips2 {
margin-top: 20rpx;
color: #00AAFF;
font-size: 28rpx;
text-align: center;
}
}
.contentVLine {
// border-radius:50%;
// width: 450rpx;
// height: 450rpx;
// overflow: hidden;
// margin: 0 auto;
// border:100rpx solid #fff;
// position: absolute;
// left: 0;
// top: 0;
// z-index: 99;
}
.contentV {
position: relative;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
margin-top: 30rpx;
width: 450rpx;
height: 450rpx;
margin: 80rpx auto;
border-radius: 50%;
border: 20px solid #eee;
border-radius: 50%;
.tipV {
bottom: 30rpx;
position: absolute;
line-height: 90rpx;
padding-left: 24rpx;
padding-right: 24rpx;
max-width: calc(100vw - 50rpx * 2);
text-align: center;
font-size: 30rpx;
background: #000000;
opacity: 0.75;
color: #FFFFFF;
border-radius: 16rpx;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
z-index: 5;
}
.camera {
width: 450rpx !important;
height: 450rpx !important;
border-radius: 50% !important;
overflow: hidden;
position: absolute;
left: -38rpx;
top: -38rpx;
z-index: -1;
}
.mark {
position: absolute;
left: 0;
top: 0;
z-index: 2;
width: 100%;
height: 100%;
// background:deeppink;
background-size: 750rpx 661rpx;
}
image {
position: absolute;
width: 450rpx;
height: 450rpx;
z-index: 3;
border-radius: 50%;
}
}
.footerV {
width: 100%;
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
.privacyV {
padding-top: 30rpx;
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
.text {
font-size: 30rpx;
color: #1C1C1C;
text-align: center;
line-height: 42rpx;
margin-left: 15rpx;
text {
font-size: 30rpx;
color: #00AAFF;
text-align: center;
line-height: 42rpx;
}
}
.icon {
width: 40rpx;
height: 47rpx;
background: green;
background-size: 100% auto;
}
}
.bottom-tips-2 {
margin-top: 20rpx;
color: #999999;
text-align: center;
font-size: 26rpx;
}
.take-photo-bgV {
width: 100%;
margin-top: 30rpx;
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
.btn-take-photo {
margin: 0rpx 80rpx 0rpx 80rpx;
width: 196rpx;
height: 196rpx;
background: yellow;
background-size: 100% auto;
}
.btn-change-upload {
left: 130rpx;
width: 80rpx;
height: 80rpx;
background: blue;
background-size: 100% auto;
}
.btn-change-camera {
right: 130rpx;
width: 80rpx;
height: 80rpx;
background: red;
background-size: 100% auto;
}
}
.confirmV {
margin: 200rpx 100rpx 0rpx 100rpx;
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
.btn-cancel {
font-size: 32rpx;
color: #1C1C1C;
}
.btn-ok {
font-size: 32rpx;
color: #00AAFF;
}
}
}
}
}
</style>

2
pages/userCenter/login/loginByPhone.vue

@ -30,6 +30,7 @@
<view style="margin-top: 40rpx;"> <view style="margin-top: 40rpx;">
<privacyRadion :isCheck="isCheck" @changeRadio="changeRadio"></privacyRadion> <privacyRadion :isCheck="isCheck" @changeRadio="changeRadio"></privacyRadion>
</view> </view>
<!-- <button @click="$goPage('/pages/userCenter/login/face')">进入人脸识别</button> -->
</view> </view>
</view> </view>
</template> </template>
@ -105,6 +106,7 @@
const res = await loginSMS(obj) const res = await loginSMS(obj)
this.$store.commit('update_vuex_loginInfo',res.data) this.$store.commit('update_vuex_loginInfo',res.data)
this.$store.dispatch('getUserInfo') this.$store.dispatch('getUserInfo')
// this.$goPage('/pages/userCenter/login/face')
uni.switchTab({ uni.switchTab({
url: '/pages/tabbar/index/index' url: '/pages/tabbar/index/index'
}) })

Loading…
Cancel
Save