app
wangxia 5 months ago
parent eaae6306a7
commit 9375cbb5ab

@ -1,21 +1,36 @@
<template> <template>
<div class="g_p_10 g_position_rela"> <div class="g_p_10 g_position_rela">
<div class="g_bg_f g_p_10 g_radius_8"> <div class="g_bg_f g_p_10 g_radius_8">
<u-line-progress class="g_position_abso" v-if="ailoading" style="position: fixed; width: 100%; top: -13px; left: 0px; z-index: 99999" active-color="#3578f6" :percent="defaultPercent" :round="false" height="8" :show-percent="false" inactiveColor="#f5f5f5"></u-line-progress> <u-line-progress class="g_position_abso" v-if="ailoading" style="position: fixed; width: 100%; top: -2px; left: 0px; z-index: 99999" active-color="#3578f6" :percent="defaultPercent" :round="false" height="8" :show-percent="false" inactiveColor="#f5f5f5"></u-line-progress>
<gao-ChatSSEClient ref="sseTest" @onOpen="openCore" @onError="errorCore" @onMessage="messageCore" @onFinish="finishCore" /> <gao-ChatSSEClient ref="sseTest" @onOpen="openCore" @onError="errorCore" @onMessage="messageCore" @onFinish="finishCore" />
<textarea class data-type="desp" v-model="aitext" placeholder="粘贴老乡信息, 用AI识别 " placeholder-style="color:#999" :maxlength="-1" :style="{ width: '100%', height: true ? '104px' : '104px' }"></textarea> <div class="g_pb_8" v-if="currentImg" @click="currentImg = ''">
<img :src="currentImg" class="g_w_48 g_h_48 g_radius_8" alt />
</div>
<textarea class data-type="desp" v-model="aitext" placeholder="粘贴老乡信息, 用AI识别 " placeholder-style="color:#999" :maxlength="-1" :style="{ width: '100%', 'min-height': true ? '104px' : '104px' }"></textarea>
<div class> <div class>
<view class="g_flex_row_end flex_center"> <view class="g_flex_row_end flex_center">
<view class="iconfont icon-jia1 g_c_9 g_mr_8 g_fs_20"></view> <view class="iconfont icon-jia1 g_c_9 g_mr_8 g_fs_20 g_position_rela biggerSize" @click="chooseImgShow = true"></view>
<view class="g_mr_8 g_w_72 g_fw_600"> <view class="g_mr_8 g_w_72 g_fw_600">
<g-button size="small_auto" type="none" height="24" :fontSize="12" @clickBtn="getClipboard" :btnText="(aitext ? '清空' : '粘贴') + '内容'"></g-button> <g-button size="small_auto" type="none" height="24" :fontSize="12" @clickBtn="getClipboard" :btnText="(aitext ? '清空' : '粘贴') + '内容'"></g-button>
</view> </view>
<view @click.stop="getCoze" class="g_w_72 g_fw_600"> <view class="g_w_72 g_fw_600">
<g-button size="small_auto" gradual="linear-gradient(-130deg, #5c6cf7, #9963f9)" icon="icon-aitubiao" type="gradual" height="24" :fontSize="12" btnText="AI识别" @clickBtn="getCoze"></g-button> <g-button size="small_auto" gradual="linear-gradient(-130deg, #5c6cf7, #9963f9)" icon="icon-aitubiao" type="gradual" height="24" :fontSize="12" btnText="AI识别" @clickBtn="getCoze"></g-button>
</view> </view>
</view> </view>
</div> </div>
</div> </div>
<u-popup v-model="chooseImgShow" mode="bottom" z-index="999999" border-radius="12" :closeable="false" :mask-close-able="true" @close="chooseImgShow = false">
<div class="g_text_c g_bg_f_5 g_fs_17">
<div class="g_bg_f">
<div class="g_c_3">
<div class="g_p_16 g_border_e_t" @click="uploadPhoto('camera')"></div>
<div class="g_p_16 g_border_e_t" @click="uploadPhotoByChat"></div>
<div class="g_p_16 g_border_e_t" @click="uploadPhoto('album')"></div>
</div>
</div>
<div class="g_p_16 g_mt_10 g_bg_f" style="padding-bottom: calc(constant(safe-area-inset-bottom) + 16px); padding-bottom: calc(env(safe-area-inset-bottom) + 16px)" @click="chooseImgShow = false">取消</div>
</div>
</u-popup>
</div> </div>
</template> </template>
@ -33,6 +48,8 @@ export default {
token: '', token: '',
id: '', id: '',
}, },
chooseImgShow: false,
currentImg: '',
} }
}, },
created() { created() {
@ -47,16 +64,17 @@ export default {
console.log('error sse', err) console.log('error sse', err)
}, },
messageCore(msg) { messageCore(msg) {
let that = this
console.log('message sse', msg) console.log('message sse', msg)
// if (msg.event == 'Done') { if (msg.event == 'Done') {
// if (!that.formInfo.jobName) { clearInterval(that.timer)
// clearInterval(that.timer) that.ailoading = false
// that.ailoading = false } else if (msg.event == 'Message') {
// } let info = JSON.parse(msg.data)
// } else { if (info.node_type == 'End') {
// let job = JSON.parse(msg.data) this.setInfo(info)
// checkDataInfo(job) }
// } }
}, },
getAiToken() { getAiToken() {
let that = this let that = this
@ -68,6 +86,57 @@ export default {
} }
}) })
}, },
uploadPhoto($sourceType = ['album', 'camera']) {
let that = this
console.log('$sourceType', $sourceType)
uni.chooseImage({
count: 1, //9
sizeType: ['original'], //
sourceType: $sourceType, //album camera 使
success: function (res) {
console.log('选取文件数据:', res)
that.uploadCozeFile(res.tempFilePaths[0])
},
})
},
uploadCozeFile(tempFilePath) {
let that = this
that.chooseImgShow = false
that.currentImg = tempFilePath
uni.uploadFile({
url: 'https://api.coze.cn/v1/files/upload',
method: 'POST',
filePath: tempFilePath,
name: 'file',
header: {
Authorization: 'Bearer ' + that.aiConfig.token,
'Content-Type': 'multipart/form-data',
},
formData: {},
success: function (res) {
console.log('文件', res)
let data = JSON.parse(res.data)
that.appCoze(data.data.id)
},
fail: function (err) {
console.log(err)
},
})
},
uploadPhotoByChat() {
let that = this
uni.chooseMessageFile({
count: 1,
type: 'image',
success(res) {
console.log('resresresresresres', res)
if (res.errMsg == 'chooseMessageFile:ok') {
console.log('res', res)
that.uploadCozeFile(res.tempFiles[0].path)
}
},
})
},
getClipboard() { getClipboard() {
let that = this let that = this
if (this.aitext) { if (this.aitext) {
@ -87,6 +156,30 @@ export default {
}) })
} }
}, },
setInfo(parsed) {
let that = this
const finalData = JSON.parse(parsed.content)
if (finalData) {
console.log('解析后的用户信息:', finalData)
let info = {
idCard: finalData.idcard,
address: finalData.address,
name: finalData.username,
nation: finalData.nation,
userName: finalData.username,
sex: finalData.sex ? (finalData.sex == '男' ? 1 : 2) : '',
age: finalData.age,
tel: finalData.tel,
}
// uni.$emit('getTownsman', { info })
that.$emit('outputInfo', info)
//
that.ailoading = false
} else {
that.ailoading = false
}
clearInterval(that.timer)
},
getCoze() { getCoze() {
let that = this let that = this
if (!that.aitext) { if (!that.aitext) {
@ -96,27 +189,40 @@ export default {
}) })
return false return false
} }
this.appCoze()
},
appCoze(_id) {
let that = this
let parameters = {}
// //
that.ailoading = true that.ailoading = true
that.defaultPercent = 3 that.defaultPercent = 3
that.timer = setInterval(() => { that.timer = setInterval(() => {
that.defaultPercent = that.defaultPercent < 15 ? (that.defaultPercent = 15) : that.defaultPercent + 1 that.defaultPercent = that.defaultPercent < 15 ? (that.defaultPercent = 15) : that.defaultPercent + 3
// console.log('12313123123123123') // console.log('12313123123123123')
if (that.defaultPercent >= 99) { if (that.defaultPercent >= 99) {
clearInterval(that.timer) clearInterval(that.timer)
} }
}, 500) }, 150)
that.timer1 = setTimeout(() => { that.timer1 = setTimeout(() => {
console.log('5687678678678678678') console.log('5687678678678678678')
that.ailoading = false that.ailoading = false
clearInterval(that.timer) clearInterval(that.timer)
// setLoading() // setLoading()
}, 30000) }, 30000)
this.appCoze() if (_id) {
parameters = {
img: {
file_id: _id,
}, },
appCoze() { }
let that = this } else {
parameters = {
txt: that.aitext,
}
}
this.$refs.sseTest.startChat({ this.$refs.sseTest.startChat({
/** /**
* 将它换成你的地址 * 将它换成你的地址
@ -127,17 +233,15 @@ export default {
// //
headers: { headers: {
// that.aiConfig.token // that.aiConfig.token
Authorization: 'Bearer ' + 'pat_cHNGkdbe3VRsmpMUXCNbZVt1ltDVyCI8k2bt9soIm2te76KXmtIfrOMKJ7xdwtYc', Authorization: 'Bearer ' + that.aiConfig.token,
'Content-Type': 'application/json', 'Content-Type': 'application/json',
}, },
// post // post
method: 'post', method: 'post',
body: { body: {
parameters: { parameters,
txt: that.aitext,
},
// workflow_id: that.aiConfig.id, // workflow_id: that.aiConfig.id,
workflow_id: '7520535773797318690', workflow_id: '7520814905613664310',
// workflow_id: '7492238568816656410', // workflow_id: '7492238568816656410',
}, },
}) })

@ -1,12 +1,12 @@
<template> <template>
<view class="p-root-detail-fellow g_w_all g_h_all g_bg_f_5 g_kuaishou"> <view class="p-root-detail-fellow g_w_all g_h_all g_bg_f_5 g_kuaishou">
<view> <view>
<AiApply class /> <AiApply class @outputInfo="getTownsManInfo" />
<view class="g_h_10"></view> <view class="g_h_10"></view>
<g-panel-form-slot :list="[ <g-panel-form-slot :list="[
{ {
icon: '', icon: '',
label: '老乡电话', label: '工友电话',
result: '', result: '',
path: '', path: '',
value: info.tel, value: info.tel,
@ -14,7 +14,7 @@
placeholder: '请输入联系电话', placeholder: '请输入联系电话',
type: 'slot', type: 'slot',
pColumn: 8, pColumn: 8,
require: true, require: false,
}, },
]" @changeMobile="handleClickMobile"></g-panel-form-slot> ]" @changeMobile="handleClickMobile"></g-panel-form-slot>
<view class="g_h_10"></view> <view class="g_h_10"></view>
@ -43,7 +43,7 @@
placeholder: '请输入身份证号', placeholder: '请输入身份证号',
type: 'slot', type: 'slot',
pColumn: 8, pColumn: 8,
require: true, require: false,
}, },
{ {
icon: '', icon: '',
@ -54,7 +54,7 @@
tip: 'slot-sex', tip: 'slot-sex',
type: 'slot', type: 'slot',
pColumn: 12, pColumn: 12,
require: true, require: false,
customRequire: true, customRequire: true,
}, },
{ {
@ -67,7 +67,7 @@
placeholder: '请输入年龄', placeholder: '请输入年龄',
type: 'slot', type: 'slot',
pColumn: 8, pColumn: 8,
require: true, require: false,
}, },
{ {
icon: '', icon: '',
@ -78,7 +78,7 @@
path: '', path: '',
tip: 'slot-nation', tip: 'slot-nation',
pColumn: 12, pColumn: 12,
require: true, require: false,
type: 'slot', type: 'slot',
customRequire: true, customRequire: true,
}, },
@ -200,6 +200,14 @@ export default {
let that = this let that = this
}, },
methods: { methods: {
getTownsManInfo(info) {
let that = this
console.log('info', info)
that.info = {
...info,
nation: info.nation + '族',
}
},
handleClickName(e) { handleClickName(e) {
this.info.name = this.info.userName = e this.info.name = this.info.userName = e
}, },
@ -299,41 +307,28 @@ export default {
}) })
return false return false
} }
if (!that.info.sex) { if (!that.info.tel && !that.info.idCard) {
uni.showToast({
icon: 'none',
title: '请选择性别',
})
return false
}
if (!that.info.age) {
uni.showToast({ uni.showToast({
icon: 'none', icon: 'none',
title: '请输入年龄', title: '请至少输入手机号或者身份证号',
}) })
return false return false
} }
if (!that.info.nation) { if (that.info.tel && !that.G.setReg(that.info.tel, 'tel')) {
uni.showToast({
icon: 'none',
title: '请选择民族',
})
return false
}
if (!that.G.setReg(that.info.tel, 'tel')) {
uni.showToast({ uni.showToast({
icon: 'none', icon: 'none',
title: '请输入正确的手机号', title: '请输入正确的手机号',
}) })
return false return false
} }
if (!that.G.setReg(that.info.idCard, 'idcard')) { if (that.info.idCard && !that.G.isValidIdCard(that.info.idCard)) {
uni.showToast({ uni.showToast({
icon: 'none', icon: 'none',
title: '请输入正确的身份证号', title: '请输入正确的身份证号',
}) })
return false return false
} }
console.log(that.info) console.log(that.info)
if (that.imgList.length > 0) { if (that.imgList.length > 0) {
that.info.imgs = that.imgList that.info.imgs = that.imgList
@ -346,14 +341,14 @@ export default {
let that = this let that = this
that.G.uploadImg((res) => { that.G.uploadImg((res) => {
console.log('res', res) console.log('res', res)
that.info.name = res.info.name that.info.name = res.info.name || ''
that.info.sex = res.info.sex ? (res.info.sex == '男' ? 1 : 2) : '' that.info.sex = res.info.sex ? (res.info.sex == '男' ? 1 : 2) : ''
that.info.age = res.info.age that.info.age = res.info.age || ''
that.info.nation = res.info.nationality that.info.nation = res.info.nationality || ''
that.info.idCard = res.info.num that.info.idCard = res.info.num || ''
that.info.idCardImageUrl = res.image that.info.idCardImageUrl = res.image || ''
that.info.userName = res.info.name that.info.userName = res.info.name || ''
that.info.address = res.info.address that.info.address = res.info.address || ''
that.nation.forEach((item, index) => { that.nation.forEach((item, index) => {
if (item == that.info.nation) { if (item == that.info.nation) {
that.nationIndex = index that.nationIndex = index

@ -1,6 +1,6 @@
<template> <template>
<view class="p-root-home-quick g_w_all g_bg_f_5 g_kuaishou"> <view class="p-root-home-quick g_w_all g_bg_f_5 g_kuaishou">
<AiApply class=""/> <AiApply class="" @outputInfo="getTownsManInfo"/>
<view class=""> <view class="">
<view class="card-tip g_pt_12 g_pb_8 g_pl_20 g_c_6">老乡信息</view> <view class="card-tip g_pt_12 g_pb_8 g_pl_20 g_c_6">老乡信息</view>
@ -295,6 +295,11 @@ export default {
}, 1); }, 1);
}, },
methods: { methods: {
getTownsManInfo(info){
console.log('info',info);
uni.$emit('getTownsman', { info })
},
getJobDetail($data) { getJobDetail($data) {
let that = this; let that = this;
that.G.Get( that.G.Get(

@ -841,3 +841,14 @@ $max-radius: 49;
.g_mb_50 { .g_mb_50 {
margin-bottom: 50px; margin-bottom: 50px;
} }
.biggerSize::after {
content: "";
/* display: inline-block; */
width: 150%;
height: 140%;
position: absolute;
left: 50%;
top: 50%;
z-index: 99;
transform: translate(-50%, -50%);
}

@ -1085,6 +1085,23 @@ let data = {
return /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/.test($str); return /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/.test($str);
} }
}, },
isValidIdCard (idCard) {
const idCardRegex = /^[1-9]\d{5}(18|19|20)\d{2}(0[1-9]|1[0-2])(0[1-9]|[1-2][0-9]|3[0-1])\d{3}[\dXx]$/;
if (!idCardRegex.test(idCard)) {
return false;
}
const factors = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2];
const checkCodeList = ['1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2'];
let sum = 0;
for (let i = 0; i < 17; i++) {
sum += parseInt(idCard[i]) * factors[i];
}
const checkCode = checkCodeList[sum % 11];
return checkCode === idCard[17].toUpperCase();
},
/* /// /* ///
*/ */
titleToStr ($obj) { titleToStr ($obj) {

Loading…
Cancel
Save