新增关闭功能
This commit is contained in:
parent
7c349b94e9
commit
082badc787
6
App.vue
6
App.vue
|
@ -2,6 +2,11 @@
|
|||
export default {
|
||||
onLaunch: function(info) {
|
||||
console.log('App Launch');
|
||||
uni.sendHostEvent('log',info, (ret) => {
|
||||
//发送消息成功回调
|
||||
console.log('消息成功app' + JSON.stringify(info));
|
||||
|
||||
});
|
||||
if (info.referrerInfo?.extraData?.uniMP) {
|
||||
uni.setStorageSync('uniMP', info.referrerInfo?.extraData?.uniMP);
|
||||
uni.setStorageSync('APP_token', info.referrerInfo?.extraData?.token);
|
||||
|
@ -24,4 +29,5 @@
|
|||
|
||||
<style>
|
||||
/*每个页面公共css */
|
||||
|
||||
</style>
|
||||
|
|
30
api/api.js
30
api/api.js
|
@ -18,6 +18,36 @@ export function ttWss(data) {
|
|||
return requesta.post(`index/tts`, data);
|
||||
}
|
||||
|
||||
//图片识别
|
||||
export function ttocr(data) {
|
||||
return request.post(`xun_fei/ocr`, data);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// base64 转 二进制流(blob)
|
||||
export function dataURLtoBlob(dataurl) {
|
||||
// console.log(dataurl);
|
||||
// let str = "data:audio/wav;base64," + dataurl.slice(2)
|
||||
// console.log(str);
|
||||
let mime = "audio/wav"
|
||||
// var arr = str.split(","),
|
||||
// mime = arr[0].match(/:(.*?);/),
|
||||
// let bstr = atob(arr[1])
|
||||
let bstr = atob(dataurl)
|
||||
let n = bstr.length
|
||||
let u8arr = new Uint8Array(n);
|
||||
while (n--) {
|
||||
u8arr[n] = bstr.charCodeAt(n);
|
||||
}
|
||||
console.log(u8arr)
|
||||
// return new Blob([u8arr], {
|
||||
// type: mime,
|
||||
// });
|
||||
}
|
||||
|
||||
|
||||
// -防抖
|
||||
export function debounce(fn, wait) {
|
||||
let delay = wait || 500
|
||||
|
|
|
@ -0,0 +1,92 @@
|
|||
<template>
|
||||
<view class="contentgb">
|
||||
<view class="return_top">
|
||||
<view class="z-bootm-img1" @click="returnbom()">
|
||||
<image src="@/static/icon/fb1.png" mode="aspectFit"></image>
|
||||
</view>
|
||||
<view class="z-bootm-l"></view>
|
||||
<view class="z-bootm-img2" @click="returnbom()">
|
||||
<image src="@/static/icon/fb2.png" mode="aspectFit"></image>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
</view>
|
||||
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
returnbom() {
|
||||
uni.sendHostEvent('closeApp', (ret) => {
|
||||
//发送消息成功回调
|
||||
console.log('关闭应用' + JSON.stringify(ret));
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.contentgb {
|
||||
|
||||
width: 166rpx;
|
||||
height: 56rpx;
|
||||
|
||||
.return_top {
|
||||
width: 166rpx;
|
||||
height: 56rpx;
|
||||
background: rgba(255, 255, 255, 0.6);
|
||||
border-radius: 44rpx 44rpx;
|
||||
|
||||
position: relative;
|
||||
|
||||
.z-bootm-img1 {
|
||||
width: 41rpx;
|
||||
height: 13rpx;
|
||||
|
||||
position: absolute;
|
||||
top: 20rpx;
|
||||
left: 25rpx;
|
||||
|
||||
image {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
.z-bootm-l {
|
||||
width: 1px;
|
||||
height: 32rpx;
|
||||
background: rgba(0, 0, 0, 0.2);
|
||||
margin: auto 0;
|
||||
|
||||
position: absolute;
|
||||
top: 10rpx;
|
||||
left: 85rpx;
|
||||
}
|
||||
|
||||
.z-bootm-img2 {
|
||||
width: 38rpx;
|
||||
height: 34rpx;
|
||||
margin-top: -15rpx;
|
||||
margin-left: -15rpx;
|
||||
position: absolute;
|
||||
right: 25rpx;
|
||||
top: 25rpx;
|
||||
|
||||
image {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
</style>
|
|
@ -0,0 +1,444 @@
|
|||
<template>
|
||||
<view class="qiqb-ctx" v-bind:class="{'on':show}">
|
||||
<view class="qiqb-ctx-box">
|
||||
<!-- <text @click="show=false"></text> -->
|
||||
<canvas canvas-id="ctx" style="width:330px;height:300px" v-show="img_show"></canvas>
|
||||
</view>
|
||||
<view class="qiqb-ctx-btns u-border-bottom">
|
||||
<view>分享至</view>
|
||||
<view>长按海报可转发分享</view>
|
||||
<view>
|
||||
<!-- <text>微信好友</text><text>分享朋友圈</text> -->
|
||||
<text @click="down">保存图片</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="qiqb-ctx-close" @click="show=false">取消</view>
|
||||
</view>
|
||||
</template>
|
||||
<!-- https://crmeb-test.shop.lihaink.cn/api/upload/image/field -->
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: "share",
|
||||
|
||||
data() {
|
||||
return {
|
||||
show: false,
|
||||
img_show: true,
|
||||
mode: 'img',
|
||||
list: [],
|
||||
pext1: '',
|
||||
pext2: ''
|
||||
}
|
||||
},
|
||||
onLoad() {
|
||||
uni.$on('add', function(res) {
|
||||
console.log(res.listData) // 为 B 页面传过来的值
|
||||
})
|
||||
},
|
||||
mounted() {
|
||||
// console.log(this.list,'222222')
|
||||
},
|
||||
|
||||
|
||||
methods: {
|
||||
//子组件接受参数
|
||||
refresh(index) {
|
||||
this.list = index;
|
||||
this.pext1 = index[index.length - 2].content
|
||||
this.pext2 = index[index.length - 1].content
|
||||
// console.log(this.list)
|
||||
},
|
||||
init() { // 通过opt传参数
|
||||
|
||||
uni.showLoading({
|
||||
title: '生成中'
|
||||
})
|
||||
let self = this
|
||||
let ctx = uni.createCanvasContext('ctx')
|
||||
// 绘制背景 宽度 高度 圆角 颜色
|
||||
self.drawBg(ctx, 330, 300, 8, '#fff')
|
||||
|
||||
// 需要用到的图片提前循环下载好,本地除外
|
||||
uni.downloadFile({
|
||||
url: 'http://banbai.oss-cn-beijing.aliyuncs.com/20230524/96e80fb572e35d4acebdce67dbd41f30.jpg',
|
||||
success: function(e) {
|
||||
let img = e.tempFilePath // 封面图
|
||||
uni.downloadFile({
|
||||
url: 'http://banbai.oss-cn-beijing.aliyuncs.com/20230524/96e80fb572e35d4acebdce67dbd41f30.jpg',
|
||||
success: function(e) {
|
||||
let photo = e.tempFilePath // 头像
|
||||
uni.downloadFile({
|
||||
url: 'http://banbai.oss-cn-beijing.aliyuncs.com/20230606/f0738e1ff432c08b369ca5e4b906a34a.png',
|
||||
success: function(e) {
|
||||
uni.hideLoading()
|
||||
let qrcode = e.tempFilePath // 二维码
|
||||
self.drawTxtOne(ctx, '农业咨询小程序', 220, 35, 100,
|
||||
'#222', 12, false)
|
||||
// 绘制圆角头像 图片地址 距离左边 距离上边 宽度 高度 圆角
|
||||
self.drawImg(ctx,
|
||||
'https://lihai001.oss-cn-chengdu.aliyuncs.com/storage/202310/20231013091310.png',
|
||||
170, 10, 40, 40, 20)
|
||||
self.drawImg(ctx,
|
||||
'https://lihai001.oss-cn-chengdu.aliyuncs.com/storage/202310/20231013091059.png',
|
||||
10, 50, 40, 40, 20)
|
||||
|
||||
self.drawImg(ctx,
|
||||
'https://lihai001.oss-cn-chengdu.aliyuncs.com/storage/202310/20231013091310.png',
|
||||
10, 118, 40, 40, 20)
|
||||
|
||||
// 绘制封面图 图片地址 距离左边 距离上边 宽度 高度 圆角
|
||||
// self.drawImg(ctx, img, 10, 120, 210, 260, 8)
|
||||
|
||||
// 绘制二维码 图片地址 距离左边 距离上边 宽度 高度 圆角
|
||||
self.drawImg(ctx,
|
||||
'https://lihai001.oss-cn-chengdu.aliyuncs.com/storage/202310/ai_qr_20231013091327.jpg',
|
||||
174, 195, 100, 100, 0)
|
||||
|
||||
// 绘制单行文字 图片地址 距离左边 距离上边 宽度 颜色 字号 加粗
|
||||
self.drawTxtOne(ctx, self.pext1, 60, 70, 100,
|
||||
'#222', 12, false)
|
||||
// self.drawTxtTwo(ctx, self.pext1, 60, 64, 80,
|
||||
// '#222', 13)
|
||||
// self.drawTxtTwo(ctx, self.pext1, 60,64,
|
||||
// 190, 20, '#222', 12)
|
||||
// 绘制单行文字 图片地址 距离左边 距离上边 宽度 颜色 字号 加粗
|
||||
// self.drawTxtOne(ctx, '邀请您一起购好物', 60, 80, 100,
|
||||
// '#666', 9, false)
|
||||
|
||||
// 绘制两行文字 图片地址 距离左边 距离上边 宽度 行高 颜色 字号
|
||||
self.drawTxtFour(ctx,
|
||||
self.pext2,
|
||||
60, 120,
|
||||
190, 20, '#222', 12)
|
||||
|
||||
// 绘制单行文字 图片地址 距离左边 距离上边 宽度 颜色 字号 加粗
|
||||
self.drawTxtOne(ctx, '下载二维码', 15, 250, 100,
|
||||
'#666', 11, false)
|
||||
|
||||
// 绘制单行文字 图片地址 距离左边 距离上边 宽度 颜色 字号 加粗
|
||||
// self.drawTxtOne(ctx, '今日特价:¥', 15, 350, 100,
|
||||
// '#ED3327', 11, false)
|
||||
|
||||
// 绘制单行文字 图片地址 距离左边 距离上边 宽度 颜色 字号 加粗
|
||||
// self.drawTxtOne(ctx, '86.00', 82, 350, 100,
|
||||
// '#ED3327', 11, true)
|
||||
|
||||
// 绘制删除文字 图片地址 距离左边 距离上边 行高 颜色 字号 加粗
|
||||
// self.drawTxtDel(ctx, '原价:20', 15, 370, 4,
|
||||
// '#818181', 10, false)
|
||||
|
||||
// 结束绘制
|
||||
ctx.draw()
|
||||
self.show = true
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
down() {
|
||||
uni.showLoading({
|
||||
title: '保存中'
|
||||
})
|
||||
uni.canvasToTempFilePath({
|
||||
canvasId: 'ctx',
|
||||
quality: 1,
|
||||
success: (res) => {
|
||||
uni.hideLoading()
|
||||
console.log(res)
|
||||
this.$emit('down', res)
|
||||
this.show = false
|
||||
// 保存到相册 自定义实现
|
||||
uni.saveImageToPhotosAlbum({
|
||||
filePath: res.tempFilePath,
|
||||
success: (res) => {
|
||||
console.log('保存')
|
||||
uni.showModal({
|
||||
title: '保存成功'
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
// 绘制背景 宽度 高度 圆角 颜色
|
||||
drawBg(ctx, w, h, r, color) {
|
||||
let x = 0
|
||||
let y = 0
|
||||
ctx.setFillStyle(color)
|
||||
ctx.save()
|
||||
ctx.beginPath()
|
||||
ctx.moveTo(x + r, y)
|
||||
ctx.arcTo(x + w, y, x + w, y + h, r)
|
||||
ctx.arcTo(x + w, y + h, x, y + h, r)
|
||||
ctx.arcTo(x, y + h, x, y, r)
|
||||
ctx.arcTo(x, y, x + w, y, r)
|
||||
ctx.closePath()
|
||||
ctx.fill()
|
||||
},
|
||||
// 绘制图片 图片地址 距离左边 距离上边 宽度 高度 圆角
|
||||
drawImg(ctx, img, x, y, w, h, r) {
|
||||
let self = this
|
||||
ctx.save()
|
||||
ctx.beginPath()
|
||||
ctx.arc(x + r, y + r, r, Math.PI, Math.PI * 1.5)
|
||||
ctx.arc(x + w - r, y + r, r, Math.PI * 1.5, Math.PI * 2)
|
||||
ctx.arc(x + w - r, y + h - r, r, 0, Math.PI * 0.5)
|
||||
ctx.arc(x + r, y + h - r, r, Math.PI * 0.5, Math.PI)
|
||||
ctx.clip()
|
||||
ctx.drawImage(img, x, y, w, h)
|
||||
ctx.restore()
|
||||
},
|
||||
// 绘制单行文字 图片地址 距离左边 距离上边 宽度 颜色 字号 加粗
|
||||
drawTxtOne(ctx, text, x, y, maxWidth, color, size, bold) {
|
||||
ctx.save()
|
||||
ctx.beginPath()
|
||||
let chr = text.split("")
|
||||
let temp = ""
|
||||
let row = []
|
||||
ctx.setFontSize(size)
|
||||
ctx.setFillStyle(color)
|
||||
for (let a = 0; a < chr.length; a++) {
|
||||
if (ctx.measureText(temp).width < maxWidth) {
|
||||
temp += chr[a]
|
||||
}
|
||||
}
|
||||
row.push(temp)
|
||||
if (ctx.measureText(temp).width > maxWidth) row[0] = row[0] + '...'
|
||||
|
||||
for (var b = 0; b < row.length; b++) {
|
||||
ctx.fillStyle = color
|
||||
if (bold) {
|
||||
ctx.font = 'normal bold ' + size + 'px sans-serif'
|
||||
} else {
|
||||
ctx.font = 'normal ' + size + 'px sans-serif'
|
||||
}
|
||||
ctx.fillText(row[b], x, y)
|
||||
}
|
||||
},
|
||||
// 绘制两行文字 图片地址 距离左边 距离上边 宽度 行高 颜色 字号
|
||||
drawTxtTwo(ctx, text, x, y, maxWidth, lineHeight, color, size) {
|
||||
ctx.save()
|
||||
ctx.beginPath()
|
||||
let chr = text.split("")
|
||||
let temp = ""
|
||||
let row = []
|
||||
ctx.setFontSize(size)
|
||||
ctx.setFillStyle(color)
|
||||
for (let a = 0; a < chr.length; a++) {
|
||||
if (ctx.measureText(temp).width < maxWidth) {
|
||||
temp += chr[a];
|
||||
} else {
|
||||
a--
|
||||
row.push(temp)
|
||||
temp = ""
|
||||
}
|
||||
}
|
||||
row.push(temp)
|
||||
if (row.length > 2) {
|
||||
let rowCut = row.slice(0, 2)
|
||||
let rowPart = rowCut[1]
|
||||
let test = ""
|
||||
let empty = []
|
||||
for (var a = 0; a < rowPart.length; a++) {
|
||||
if (ctx.measureText(test).width < maxWidth) {
|
||||
test += rowPart[a]
|
||||
} else {
|
||||
break
|
||||
}
|
||||
}
|
||||
empty.push(test)
|
||||
var group = empty[0] + "..."
|
||||
rowCut.splice(1, 1, group)
|
||||
row = rowCut
|
||||
}
|
||||
for (var b = 0; b < row.length; b++) {
|
||||
ctx.fillStyle = color
|
||||
ctx.font = 'normal ' + size + 'px sans-serif'
|
||||
ctx.fillText(row[b], x, y + b * lineHeight, 300)
|
||||
}
|
||||
},
|
||||
drawTxtFour(ctx, text, x, y, maxWidth, lineHeight, color, size) {
|
||||
ctx.save()
|
||||
ctx.beginPath()
|
||||
let chr = text.split("")
|
||||
let temp = ""
|
||||
let row = []
|
||||
ctx.setFontSize(size)
|
||||
ctx.setFillStyle(color)
|
||||
for (let a = 0; a < chr.length; a++) {
|
||||
if (ctx.measureText(temp).width < maxWidth) {
|
||||
temp += chr[a];
|
||||
} else {
|
||||
a--
|
||||
row.push(temp)
|
||||
temp = ""
|
||||
}
|
||||
}
|
||||
row.push(temp)
|
||||
if (row.length > 4) {
|
||||
let rowCut = row.slice(0, 4)
|
||||
let rowPart = rowCut[1]
|
||||
let test = ""
|
||||
let empty = []
|
||||
for (var a = 0; a < rowPart.length; a++) {
|
||||
if (ctx.measureText(test).width < maxWidth) {
|
||||
test += rowPart[a]
|
||||
} else {
|
||||
break
|
||||
}
|
||||
}
|
||||
empty.push(test)
|
||||
var group = empty[0] + "..."
|
||||
rowCut.splice(1, 1, group)
|
||||
row = rowCut
|
||||
}
|
||||
for (var b = 0; b < row.length; b++) {
|
||||
ctx.fillStyle = color
|
||||
ctx.font = 'normal ' + size + 'px sans-serif'
|
||||
ctx.fillText(row[b], x, y + b * lineHeight, 300)
|
||||
}
|
||||
},
|
||||
// 绘制删除线文字 图片地址 距离左边 距离上边 行高 颜色 字号 加粗
|
||||
drawTxtDel(ctx, txt, x, y, h, color, size) {
|
||||
ctx.fillStyle = color
|
||||
ctx.font = 'normal ' + size + 'px sans-serif'
|
||||
ctx.fillText(txt, x, y)
|
||||
|
||||
ctx.beginPath()
|
||||
let width = ctx.measureText(txt).width;
|
||||
ctx.rect(x, y - h, width, 1)
|
||||
ctx.fillStyle = color
|
||||
ctx.fill()
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.qiqb-ctx {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
z-index: -1;
|
||||
display: flex;
|
||||
background: rgba(0, 0, 0, .6);
|
||||
opacity: 0;
|
||||
transition: all .3s;
|
||||
flex-direction: column;
|
||||
align-items: flex-end;
|
||||
justify-content: flex-end
|
||||
}
|
||||
|
||||
.qiqb-ctx.on {
|
||||
z-index: 2000;
|
||||
opacity: 1
|
||||
}
|
||||
|
||||
.qiqb-ctx-box {
|
||||
position: relative;
|
||||
display: flex;
|
||||
padding: 30upx 0 40upx;
|
||||
width: 750upx;
|
||||
justify-content: center
|
||||
}
|
||||
|
||||
.qiqb-ctx-box text {
|
||||
position: absolute;
|
||||
top: -40upx;
|
||||
right: 145upx;
|
||||
display: inline-flex;
|
||||
width: 47upx;
|
||||
height: 47upx;
|
||||
background: url('img/close.png');
|
||||
background-size: 100% 100%
|
||||
}
|
||||
|
||||
.qiqb-ctx-btns {
|
||||
display: flex;
|
||||
width: 750upx;
|
||||
height: 330upx;
|
||||
border-radius: 20upx 20upx 0 0;
|
||||
background: #fff;
|
||||
flex-direction: row;
|
||||
flex-direction: column;
|
||||
align-items: center
|
||||
}
|
||||
|
||||
.qiqb-ctx-btns view:nth-child(1) {
|
||||
display: flex;
|
||||
padding-top: 10upx;
|
||||
height: 80upx;
|
||||
font-weight: 700;
|
||||
font-size: 30upx;
|
||||
align-items: center
|
||||
}
|
||||
|
||||
.qiqb-ctx-btns view:nth-child(2) {
|
||||
height: 80upx;
|
||||
color: #666;
|
||||
font-size: 24upx
|
||||
}
|
||||
|
||||
.qiqb-ctx-btns view:nth-child(3) {
|
||||
display: flex;
|
||||
padding-bottom: 30upx;
|
||||
font-size: 26upx;
|
||||
flex-direction: row;
|
||||
align-items: center
|
||||
}
|
||||
|
||||
.qiqb-ctx-btns view:nth-child(3) text {
|
||||
display: flex;
|
||||
width: 250upx;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center
|
||||
}
|
||||
|
||||
.qiqb-ctx-btns view:nth-child(3) text:nth-child(1)::before {
|
||||
display: inline-flex;
|
||||
margin-bottom: 20upx;
|
||||
width: 86upx;
|
||||
height: 86upx;
|
||||
background: url('img/3.png');
|
||||
background-size: 100% 100%;
|
||||
content: ''
|
||||
}
|
||||
|
||||
.qiqb-ctx-btns view:nth-child(3) text:nth-child(2)::before {
|
||||
display: inline-flex;
|
||||
margin-bottom: 20upx;
|
||||
width: 86upx;
|
||||
height: 86upx;
|
||||
background: url('img/1.png');
|
||||
background-size: 100% 100%;
|
||||
content: ''
|
||||
}
|
||||
|
||||
.qiqb-ctx-btns view:nth-child(3) text:nth-child(3)::before {
|
||||
display: inline-flex;
|
||||
margin-bottom: 20upx;
|
||||
width: 86upx;
|
||||
height: 86upx;
|
||||
background: url('img/2.png');
|
||||
background-size: 100% 100%;
|
||||
content: ''
|
||||
}
|
||||
|
||||
.qiqb-ctx-close {
|
||||
display: flex;
|
||||
padding-bottom: 50upx;
|
||||
width: 100%;
|
||||
height: 150upx;
|
||||
background: #fff;
|
||||
font-size: 32upx;
|
||||
align-items: center;
|
||||
justify-content: center
|
||||
}
|
||||
</style>
|
|
@ -39,7 +39,7 @@ function baseRequest(url, method, data, {
|
|||
data: data || {},
|
||||
success: (res) => {
|
||||
// #ifdef APP-PLUS
|
||||
// console.log('app', Url + '/api/' + url, res.data);
|
||||
|
||||
|
||||
// #endif
|
||||
if (noVerify)
|
||||
|
|
|
@ -40,7 +40,7 @@ function baseRequest(url, method, data, {
|
|||
success: (res) => {
|
||||
|
||||
// #ifdef APP-PLUS
|
||||
// console.log('app', Url + '/api/' + url, res.data);
|
||||
console.log('app', Url + '/api/' + url, res.data);
|
||||
|
||||
// #endif
|
||||
if (noVerify)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name" : "情感咨询",
|
||||
"appid" : "__UNI__8080F14",
|
||||
"name" : "农业咨询",
|
||||
"appid" : "__UNI__9620511",
|
||||
"description" : "",
|
||||
"versionName" : "1.0.0",
|
||||
"versionCode" : "100",
|
||||
|
@ -17,26 +17,34 @@
|
|||
"delay" : 0
|
||||
},
|
||||
/* 模块配置 */
|
||||
"modules" : {},
|
||||
"modules" : {
|
||||
"Record" : {},
|
||||
"Speech" : {},
|
||||
"Camera" : {}
|
||||
},
|
||||
/* 应用发布信息 */
|
||||
"distribute" : {
|
||||
/* android打包配置 */
|
||||
"android" : {
|
||||
"permissions" : [
|
||||
"<uses-permission android:name=\"android.permission.CHANGE_NETWORK_STATE\"/>",
|
||||
"<uses-permission android:name=\"android.permission.MOUNT_UNMOUNT_FILESYSTEMS\"/>",
|
||||
"<uses-permission android:name=\"android.permission.VIBRATE\"/>",
|
||||
"<uses-permission android:name=\"android.permission.READ_LOGS\"/>",
|
||||
"<uses-permission android:name=\"android.permission.ACCESS_WIFI_STATE\"/>",
|
||||
"<uses-feature android:name=\"android.hardware.camera\"/>",
|
||||
"<uses-feature android:name=\"android.hardware.camera.autofocus\"/>",
|
||||
"<uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\"/>",
|
||||
"<uses-permission android:name=\"android.permission.ACCESS_WIFI_STATE\"/>",
|
||||
"<uses-permission android:name=\"android.permission.CAMERA\"/>",
|
||||
"<uses-permission android:name=\"android.permission.GET_ACCOUNTS\"/>",
|
||||
"<uses-permission android:name=\"android.permission.READ_PHONE_STATE\"/>",
|
||||
"<uses-permission android:name=\"android.permission.CHANGE_NETWORK_STATE\"/>",
|
||||
"<uses-permission android:name=\"android.permission.CHANGE_WIFI_STATE\"/>",
|
||||
"<uses-permission android:name=\"android.permission.WAKE_LOCK\"/>",
|
||||
"<uses-permission android:name=\"android.permission.FLASHLIGHT\"/>",
|
||||
"<uses-feature android:name=\"android.hardware.camera\"/>",
|
||||
"<uses-permission android:name=\"android.permission.GET_ACCOUNTS\"/>",
|
||||
"<uses-permission android:name=\"android.permission.INTERNET\"/>",
|
||||
"<uses-permission android:name=\"android.permission.MOUNT_UNMOUNT_FILESYSTEMS\"/>",
|
||||
"<uses-permission android:name=\"android.permission.READ_EXTERNAL_STORAGE\"/>",
|
||||
"<uses-permission android:name=\"android.permission.READ_LOGS\"/>",
|
||||
"<uses-permission android:name=\"android.permission.READ_PHONE_STATE\"/>",
|
||||
"<uses-permission android:name=\"android.permission.RECORD_AUDIO\"/>",
|
||||
"<uses-permission android:name=\"android.permission.VIBRATE\"/>",
|
||||
"<uses-permission android:name=\"android.permission.WAKE_LOCK\"/>",
|
||||
"<uses-permission android:name=\"android.permission.WRITE_EXTERNAL_STORAGE\"/>",
|
||||
"<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>"
|
||||
],
|
||||
"abiFilters" : [ "armeabi-v7a", "arm64-v8a", "x86" ]
|
||||
|
@ -47,7 +55,25 @@
|
|||
},
|
||||
/* SDK配置 */
|
||||
"sdkConfigs" : {
|
||||
"ad" : {}
|
||||
"ad" : {},
|
||||
"speech" : {},
|
||||
"share" : {}
|
||||
}
|
||||
},
|
||||
"nativePlugins" : {
|
||||
"YL-SpeechRecognition" : {
|
||||
"__plugin_info__" : {
|
||||
"name" : "YL-SpeechRecognition-语音合成,语音听写,基于科大讯飞,双端 - [试用版,仅用于自定义调试基座]",
|
||||
"description" : "语音合成,语音听写,基于科大讯飞,双端(QQ:453503875,微信同)",
|
||||
"platforms" : "Android,iOS",
|
||||
"url" : "https://ext.dcloud.net.cn/plugin?id=9512",
|
||||
"android_package_name" : "",
|
||||
"ios_bundle_id" : "",
|
||||
"isCloud" : true,
|
||||
"bought" : 0,
|
||||
"pid" : "9512",
|
||||
"parameters" : {}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -55,7 +81,7 @@
|
|||
"quickapp" : {},
|
||||
/* 小程序特有相关 */
|
||||
"mp-weixin" : {
|
||||
"appid" : "",
|
||||
"appid" : "wx3267f87bc81f2890",
|
||||
"setting" : {
|
||||
"urlCheck" : false
|
||||
},
|
||||
|
|
|
@ -5,9 +5,10 @@
|
|||
<view class="conten-top">
|
||||
<view class="" style="position: absolute;left: 30rpx;"><i class="iconfont icon-xiangzuo"
|
||||
style="font-size: 40rpx;text-align: left;"></i></view>
|
||||
<view class="" style="font-size: 30rpx;">
|
||||
<view class="" style="font-size: 30rpx;margin-top: 10rpx;">
|
||||
情感咨询
|
||||
</view>
|
||||
<returntop class="container-retun"/>
|
||||
</view>
|
||||
<view style="padding-top:var(--status-bar-height);padding-bottom: 30rpx; margin-bottom: 30rpx;"></view>
|
||||
|
||||
|
@ -17,26 +18,26 @@
|
|||
<view class="placeholder"></view>
|
||||
<view class="box-1" id="list-box" ref="box">
|
||||
<view class="talk-list">
|
||||
<view class="talk-list-con">
|
||||
<view class="talk-list-con-title">
|
||||
您好!
|
||||
</view>
|
||||
<view class="talk-list-con-title1">
|
||||
您可以和我说任何有关情感的问题。<br />
|
||||
例如下面的问题,赶快试试吧!
|
||||
</view>
|
||||
<view class="talk-list-con-title2">
|
||||
<text style="margin-top: 15rpx;"> 下方输入:</text>
|
||||
<view class="" @click="sendDetail('当我被爱情伤害时,我该如何重新振作起来?')">
|
||||
当我被爱情伤害时,我该如何重新振作起来?
|
||||
<image src="../../static/icon/airight.png" mode=""></image>
|
||||
<view class="talk-list-con">
|
||||
<view class="talk-list-con-title">
|
||||
您好!
|
||||
</view>
|
||||
<view class="talk-list-con-title1">
|
||||
您可以和我说任何有关情感的问题。<br />
|
||||
例如下面的问题,赶快试试吧!
|
||||
</view>
|
||||
<view class="talk-list-con-title2">
|
||||
<text style="margin-top: 15rpx;"> 下方输入:</text>
|
||||
<view class="" @click="sendDetail('怎么保持心情愉快')">
|
||||
怎么保持心情愉快
|
||||
<image src="../../static/icon/airight.png" mode=""></image>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
|
||||
</view>
|
||||
<view v-for="(item,index) in talkList" :key="index" :id="`msg-${item.id}`">
|
||||
<view class="item flex_col" :class="item.type == 1 ? 'push':'pull' ">
|
||||
|
||||
|
||||
<image :src="item.type==1?avatar:item.pic" mode="aspectFill" class="pic" v-if="item.pic">
|
||||
</image>
|
||||
<view class="content" v-if="item.id=='@'">
|
||||
|
@ -49,11 +50,9 @@
|
|||
<view class="" v-else>
|
||||
<view v-if="talkList.length-1==index" class="multiline-text">
|
||||
<view class="content">
|
||||
<view class="" v-if="item.type==3"
|
||||
style="border: 1px solid #2573fb;margin-left: 20rpx;">
|
||||
<image :src="item.Image" mode="" style="width: 200rpx;height: 200rpx;"
|
||||
@click="previewImage(item.Image)"></image>
|
||||
<view class="">{{c_content}}</view>
|
||||
<view class="" v-if="item.type==3" style="border: 1px solid #2573fb;margin-left: 20rpx;">
|
||||
<image :src="item.Image" mode="" style="width: 200rpx;height: 200rpx;" @click="previewImage(item.Image)"></image>
|
||||
<view class="">{{c_content}}</view>
|
||||
</view>
|
||||
<view class="" v-else>
|
||||
<bing-math v-if="c_content!=''" :key="`math-${item.id}`" class="bing-math1"
|
||||
|
@ -91,10 +90,8 @@
|
|||
|
||||
|
||||
<!-- <rich-text :nodes="item.content"></rich-text> -->
|
||||
<view class="" v-if="item.type==3"
|
||||
style="border: 1px solid #2573fb;margin-left: 20rpx;">
|
||||
<image :src="item.Image" mode="" style="width: 200rpx;height: 200rpx;"
|
||||
@click="previewImage(item.Image)"></image>
|
||||
<view class="" v-if="item.type==3" style="border: 1px solid #2573fb;margin-left: 20rpx;">
|
||||
<image :src="item.Image" mode="" style="width: 200rpx;height: 200rpx;" @click="previewImage(item.Image)"></image>
|
||||
</view>
|
||||
<view class="" v-else>
|
||||
<view class="content multiline-text">
|
||||
|
@ -251,19 +248,20 @@
|
|||
import qiqbshare from "@/components/qiqb-share/qiqb-share.vue"
|
||||
|
||||
|
||||
import returntop from '@/components/content-top/index.vue'
|
||||
const recorderManager = uni.getRecorderManager()
|
||||
const innerAudioContext = uni.createInnerAudioContext()
|
||||
export default {
|
||||
components: {
|
||||
'bing-math': BingMath,
|
||||
'qiqbshare': qiqbshare,
|
||||
|
||||
returntop
|
||||
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
wssType: 'qinggan', // 网络连接类型
|
||||
avatarType: "/static/icon/qg.png", // AI头像类型
|
||||
wssType: 'qinggan', // 网络连接类型
|
||||
avatarType: "/static/icon/qg.png", // AI头像类型
|
||||
talkList: [],
|
||||
ajax: {
|
||||
rows: 15, //每页数量
|
||||
|
@ -321,7 +319,7 @@
|
|||
Imageurl: '',
|
||||
content1: '',
|
||||
audioContext: null, // 存储当前的innerAudioContext实例
|
||||
|
||||
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
|
@ -345,7 +343,7 @@
|
|||
|
||||
|
||||
},
|
||||
|
||||
|
||||
onLoad() {
|
||||
let avatar = uni.getStorageSync('avatar');
|
||||
avatar ? this.avatar = avatar : null;
|
||||
|
@ -373,7 +371,7 @@
|
|||
// obeyMuteSwitch: false
|
||||
// })
|
||||
let that = this;
|
||||
|
||||
|
||||
recorderManager.onStop(function(res) {
|
||||
// 解决第一次录音,挂实例挂载问题
|
||||
that.$nextTick(() => {
|
||||
|
@ -382,7 +380,7 @@
|
|||
that.voicePath = res.tempFilePath;
|
||||
})
|
||||
});
|
||||
|
||||
|
||||
},
|
||||
|
||||
watch: {
|
||||
|
@ -479,7 +477,7 @@
|
|||
sourceType: ['album'], //这要注意,camera掉拍照,album是打开手机相册
|
||||
success: (res) => {
|
||||
// const tempFilePaths = res.tempFilePaths;
|
||||
console.log(res.tempFilePaths, '2222222222')
|
||||
console.log(res.tempFilePaths,'2222222222')
|
||||
uni.uploadFile({
|
||||
url: HTTP_REQUEST_URL + '/api/upload/image', // 上传地址
|
||||
filePath: res.tempFilePaths[0], // 要上传的文件路径
|
||||
|
@ -490,7 +488,7 @@
|
|||
success: function(res) {
|
||||
|
||||
let data = JSON.parse(res.data)
|
||||
console.log(data, '222222222222')
|
||||
console.log(data,'222222222222')
|
||||
if (data.code == 1) {
|
||||
// this.File()
|
||||
let data1 = {
|
||||
|
@ -588,24 +586,24 @@
|
|||
}
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
//图片预览
|
||||
previewImage(url) {
|
||||
previewImage(url){
|
||||
uni.previewImage({
|
||||
urls: [url], // 图片地址数组
|
||||
current: url, // 当前预览的图片地址
|
||||
success: function() {
|
||||
console.log('预览图片成功');
|
||||
},
|
||||
fail: function(error) {
|
||||
console.error('预览图片失败', error);
|
||||
}
|
||||
urls: [url], // 图片地址数组
|
||||
current: url, // 当前预览的图片地址
|
||||
success: function() {
|
||||
console.log('预览图片成功');
|
||||
},
|
||||
fail: function(error) {
|
||||
console.error('预览图片失败', error);
|
||||
}
|
||||
});
|
||||
},
|
||||
//图片转文字
|
||||
imgfile(tempFilePath) {
|
||||
let that = this
|
||||
that.content1 = ''
|
||||
that.content1=''
|
||||
// console.log(tempFilePath, '2')
|
||||
ttocr({
|
||||
image: tempFilePath
|
||||
|
@ -619,7 +617,7 @@
|
|||
that.gnishow = false
|
||||
|
||||
that.talkList = that.talkList.filter(item => item.id !== '@');
|
||||
|
||||
|
||||
if (res.data.words.length > 0) {
|
||||
|
||||
for (let i in res.data.words) {
|
||||
|
@ -736,7 +734,7 @@
|
|||
},
|
||||
//语音转文字
|
||||
uploadFile(tempFilePath) {
|
||||
|
||||
|
||||
let that = this
|
||||
// console.log(tempFilePath)
|
||||
uni.uploadFile({
|
||||
|
@ -747,14 +745,14 @@
|
|||
'content-type': 'multipart/form-data'
|
||||
},
|
||||
success: function(res) {
|
||||
|
||||
|
||||
|
||||
|
||||
let data = JSON.parse(res.data)
|
||||
if (data.code == 1) {
|
||||
uni.showToast({
|
||||
title: '语音识别成功'
|
||||
});
|
||||
|
||||
|
||||
that.talkList = that.talkList.filter(item => item.id !== '@');
|
||||
if (data.data.words.length > 0) {
|
||||
that.content = data.data.words
|
||||
|
@ -766,16 +764,16 @@
|
|||
title: '语音识别失败'
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
},
|
||||
fail: function(error) {
|
||||
// 上传失败处理逻辑
|
||||
that.deletespeech()
|
||||
console.log(error, 11);
|
||||
uni.hideLoading();
|
||||
|
||||
|
||||
}
|
||||
})
|
||||
},
|
||||
|
@ -814,32 +812,32 @@
|
|||
},
|
||||
|
||||
|
||||
|
||||
|
||||
start(e) {
|
||||
|
||||
this.onFeedTap()
|
||||
this.touchT = new Date().getTime();
|
||||
this.islong = true
|
||||
this.risshow = false
|
||||
this.$refs.popup.open('center')
|
||||
// 限制时长
|
||||
this.timer = setInterval(() => {
|
||||
this.num++
|
||||
}, 1000)
|
||||
this.btnStatus = 1
|
||||
recorderManager.start({
|
||||
//时长5分钟,单位毫秒
|
||||
duration: 300000,
|
||||
|
||||
// format: "pcm",
|
||||
});
|
||||
|
||||
this.touchStartX = e.touches[0].pageX; // 获取触摸时的原点
|
||||
this.touchStartY = e.touches[0].pageY; // 获取触摸时的原点
|
||||
|
||||
this.onFeedTap()
|
||||
this.touchT = new Date().getTime();
|
||||
this.islong = true
|
||||
this.risshow = false
|
||||
this.$refs.popup.open('center')
|
||||
// 限制时长
|
||||
this.timer = setInterval(() => {
|
||||
this.num++
|
||||
}, 1000)
|
||||
this.btnStatus = 1
|
||||
recorderManager.start({
|
||||
//时长5分钟,单位毫秒
|
||||
duration: 300000,
|
||||
|
||||
// format: "pcm",
|
||||
});
|
||||
|
||||
this.touchStartX = e.touches[0].pageX; // 获取触摸时的原点
|
||||
this.touchStartY = e.touches[0].pageY; // 获取触摸时的原点
|
||||
|
||||
},
|
||||
move(e) {
|
||||
|
||||
|
||||
let that = this;
|
||||
let moveX = this.touchMoveX - e.touches[0].pageX;
|
||||
let moveY = this.touchMoveY - e.touches[0].pageY;
|
||||
|
@ -870,15 +868,15 @@
|
|||
|
||||
|
||||
this.touchE = new Date().getTime();
|
||||
|
||||
|
||||
if (this.islong) {
|
||||
this.closePop()
|
||||
|
||||
|
||||
this.islong = false
|
||||
clearInterval(this.timer)
|
||||
this.btnStatus = 0
|
||||
recorderManager.stop();
|
||||
|
||||
|
||||
// this.closePop()
|
||||
if (this.risshow == false && this.touchE - this.touchT > 3000) {
|
||||
let data = {
|
||||
|
@ -887,7 +885,7 @@
|
|||
"type": 2,
|
||||
}
|
||||
this.talkList.push(data);
|
||||
|
||||
|
||||
// 异步,解决录音结束后,路径没赋值就传值,导致的路径为空
|
||||
setTimeout(() => {
|
||||
let obj = {
|
||||
|
@ -898,31 +896,31 @@
|
|||
soundTime: this.num
|
||||
}]
|
||||
}
|
||||
|
||||
|
||||
if (this.voicePath.length > 0 && this.risshow == false) {
|
||||
// this.huashow=true
|
||||
this.TabItemTap()
|
||||
|
||||
|
||||
|
||||
|
||||
throttle(this.uploadFile(this.voicePath), 1000)
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
this.num = 0
|
||||
}, 500)
|
||||
|
||||
|
||||
} else {
|
||||
if (!this.risshow) {
|
||||
uni.showModal({
|
||||
title: "录音时长不超过3s"
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
},
|
||||
|
@ -996,18 +994,18 @@
|
|||
//音频播放
|
||||
|
||||
palyaudio(items, i) {
|
||||
|
||||
|
||||
// console.log(this.talkList,items.audio_file,'000000')
|
||||
if (this.audioContext) {
|
||||
// 停止上一段对话内容的播放
|
||||
this.audioContext.stop();
|
||||
this.audioContext = null;
|
||||
}
|
||||
|
||||
|
||||
this.talkList.forEach((item, index) => {
|
||||
if (index != i) {
|
||||
item.playStatus = true
|
||||
|
||||
|
||||
}
|
||||
// item.playStatus = (index == i);
|
||||
});
|
||||
|
@ -1016,15 +1014,15 @@
|
|||
this.talkList[i].playStatus = !this.talkList[i].playStatus
|
||||
|
||||
if (!this.talkList[i].playStatus) {
|
||||
|
||||
if (items.audio_file.length > 0) {
|
||||
|
||||
if(items.audio_file.length>0){
|
||||
innerAudioContext.src = items.audio_file;
|
||||
innerAudioContext.play()
|
||||
this.talkList[i].playStatus = false
|
||||
} else {
|
||||
this.talkList[i].playStatus = true
|
||||
}else{
|
||||
this.talkList[i].playStatus = true
|
||||
}
|
||||
|
||||
|
||||
|
||||
} else {
|
||||
innerAudioContext.pause()
|
||||
|
@ -1184,28 +1182,28 @@
|
|||
},
|
||||
// 关闭连接
|
||||
closeSocketTask() {
|
||||
|
||||
try {
|
||||
this.talkList = this.talkList.filter(item => item.id !== '@');
|
||||
clearInterval(this.timer);
|
||||
this.talkList[this.talkList.length - 1].audio_file = ''
|
||||
this.talkList[this.talkList.length - 1].content = this.c_content + '';
|
||||
// console.log(this.talkList[this.talkList.length - 1].content);
|
||||
// this.c_content = '';
|
||||
// this.n_content = '';
|
||||
this.socketTask.close({
|
||||
code: 500, // APP端存在BUG,正常关闭的code为1000,无法正常关闭,需要将code换为其他值
|
||||
complete: (res) => {
|
||||
this.showStop = false;
|
||||
console.log('主动断开', res);
|
||||
this.wsLiveFlag = false;
|
||||
}
|
||||
})
|
||||
} catch (e) {
|
||||
//TODO handle the exception
|
||||
}
|
||||
|
||||
|
||||
|
||||
try {
|
||||
this.talkList = this.talkList.filter(item => item.id !== '@');
|
||||
clearInterval(this.timer);
|
||||
this.talkList[this.talkList.length - 1].audio_file=''
|
||||
this.talkList[this.talkList.length - 1].content = this.c_content + '';
|
||||
// console.log(this.talkList[this.talkList.length - 1].content);
|
||||
// this.c_content = '';
|
||||
// this.n_content = '';
|
||||
this.socketTask.close({
|
||||
code: 500, // APP端存在BUG,正常关闭的code为1000,无法正常关闭,需要将code换为其他值
|
||||
complete: (res) => {
|
||||
this.showStop = false;
|
||||
console.log('主动断开', res);
|
||||
this.wsLiveFlag = false;
|
||||
}
|
||||
})
|
||||
} catch (e) {
|
||||
//TODO handle the exception
|
||||
}
|
||||
|
||||
|
||||
},
|
||||
|
||||
// 发送信息
|
||||
|
@ -1217,8 +1215,8 @@
|
|||
})
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// 将当前发送信息 添加到消息列表。
|
||||
let data = {
|
||||
"id": new Date().getTime(),
|
||||
|
@ -1254,7 +1252,7 @@
|
|||
|
||||
|
||||
},
|
||||
|
||||
|
||||
send1() {
|
||||
if (!this.content1) {
|
||||
uni.showToast({
|
||||
|
@ -1339,7 +1337,7 @@
|
|||
// }
|
||||
// }
|
||||
// };
|
||||
|
||||
|
||||
if (this.historyTextList.length > 9) this.params = JSON.parse(JSON.stringify(this
|
||||
.historyTextList
|
||||
.splice(-9)));
|
||||
|
@ -1367,11 +1365,11 @@
|
|||
realThis.tempRes = realThis.tempRes + dataArray[i].content
|
||||
|
||||
}
|
||||
if (this.n_content.length > 0) {
|
||||
if(this.n_content.length>0){
|
||||
this.nums = this.talkList.length - 1
|
||||
this.txtspeech(this.n_content, this.talkList.length -
|
||||
1)
|
||||
this.showStop = true;
|
||||
this.showStop = true;
|
||||
}
|
||||
this.cavshare(this.talkList)
|
||||
let temp = JSON.parse(res.data)
|
||||
|
@ -1396,7 +1394,7 @@
|
|||
"role": "assistant",
|
||||
"content": this.tempRes
|
||||
})
|
||||
|
||||
|
||||
setTimeout(() => {
|
||||
let that = this
|
||||
realThis.socketTask.close({
|
||||
|
@ -1605,9 +1603,15 @@
|
|||
top: 0;
|
||||
position: fixed;
|
||||
z-index: 10;
|
||||
.container-retun{
|
||||
position: absolute;
|
||||
right: 20rpx;
|
||||
padding-top: var(--status-bar-height);
|
||||
top: 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
.popup_box {
|
||||
height: 100vh;
|
||||
width: 100vw;
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Binary file not shown.
After Width: | Height: | Size: 446 B |
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
Loading…
Reference in New Issue