dwh hace 2 años
padre
commit
0be1b71b1b

+ 2 - 2
package.json

@@ -9,15 +9,14 @@
   "dependencies": {
     "@tencentcloud/chat-uikit-vue": "^1.0.8",
     "ali-oss": "^6.17.1",
+    "autoprefixer": "^7.1.2",
     "axios": "^1.1.2",
     "core-js": "^3.8.3",
     "cos-wx-sdk-v5": "^1.0.10",
-    "autoprefixer": "^7.1.2",
     "crypto-js": "^4.1.1",
     "device-detector-js": "^3.0.3",
     "html2canvas": "^1.4.1",
     "jquery": "^3.6.1",
-    "js-audio-recorder": "^1.0.7",
     "js-base64": "^3.7.2",
     "moment": "^2.29.4",
     "postcss-pxtorem": "^5.1.1",
@@ -39,6 +38,7 @@
     "@vue/cli-plugin-vuex": "~5.0.0",
     "@vue/cli-service": "~5.0.0",
     "autoprefixer": "^7.1.2",
+    "js-audio-recorder": "^1.0.7",
     "postcss": "^8.4.18",
     "postcss-loader": "^7.0.1",
     "postcss-pxtorem": "^5.1.1",

+ 36 - 72
src/views/chatting/chatting.vue

@@ -71,7 +71,7 @@
 					<div class="voice-text font22 fw400">
 						{{voiceText}}
 					</div>
-					<img :src="`${assetsUrl}talk-voice-${isRecording?'delete':'open'}.png`" mode="aspectFill" class="voice-img" @longpress="handleLongPress" @touchmove="handleTouchMove" @touchend="handleTouchEnd"></img>
+					<img :src="`${assetsUrl}talk-voice-${isRecording?'delete':'open'}.png`" mode="aspectFill" class="voice-img"@touchstart="handleTouchStart" @touchmove="handleTouchMove" @touchend="handleTouchEnd"></img>
 				</div>
 				<div class="emoji-panel" :style="{'height':`${showActionIndex===3?'200px':'0px'}`}">
 					<Emoji @enterEmoji="appendMessage"></Emoji>
@@ -100,6 +100,8 @@
 	import Emoji from '../../components/Emoji/emoji.vue'
 	import {assetsUrl,hasSafeArea} from '../../util/index.js';
 	import {getPolicy,computeSignature,getKey} from '@/util/oss.js';
+	import Recorder from 'js-audio-recorder';
+	
 	export default {
 		components: {
 			Emoji,
@@ -125,6 +127,7 @@
 				inputText:'',
 				showSendBtn:false,
 				showActionIndex:-1,
+				recorder:null,
 				voiceText:'按住说话,松手发送',
 				recordTimeTotal:60,//最大长度,30秒
 				isRecording:false,
@@ -153,7 +156,13 @@
 				return JSON.parse(localStorage.getItem('otherInfo'))
 			}
 		},
-		
+		created(){
+			this.recorder = new Recorder({
+				sampleBits: 16,                 // 采样位数,支持 8 或 16,默认是16
+				sampleRate: 16000,              // 采样率,支持 11025、16000、22050、24000、44100、48000,根据浏览器默认值,我的chrome是48000
+				numChannels: 1, 
+			});
+		},
 		mounted() {
 			this.$on('videoPlayerHandler', value => {
 				console.log(value);
@@ -161,7 +170,7 @@
 				this.videoMessage = value.message;
 			});
 			this.conversationID=this.$route.params.conversationid;
-			console.log(this.conversationID)
+			console.log('conversationID:',this.conversationID)
 			this.$TUIKit.setMessageRead({
 				conversationID:this.conversationID
 			})
@@ -313,76 +322,31 @@
 			appendMessage(e) {
 				this.inputText+=e.detail.message;
 			},
-			startRecordManage(){
-				// 加载声音录制管理器
-				this.recorderManager = uni.getRecorderManager();
-				console.log(this.recorderManager)
-				this.recorderManager.onStop(res => {
-					console.log(res)
-					clearInterval(this.recordTimer);
-					// 兼容 uniapp 打包app,duration 和 fileSize 需要用户自己补充
-					// 文件大小 = (音频码率) x 时间长度(单位:秒) / 8
-					let msg = {
-						duration: res.duration ? res.duration : this.recordTime * 1000,
-						tempFilePath: res.tempFilePath,
-						fileSize: res.fileSize ? res.fileSize : ((48 * this.recordTime) / 8) * 1024
-					};
-					uni.hideLoading();
-					// 兼容 uniapp 语音消息没有duration
-					if (this.canSend) {
-						if (msg.duration < 1000) {
-							uni.showToast({
-								title: '录音时间太短',
-								icon: 'none'
-							});
-						} else {
-							// res.tempFilePath 存储录音文件的临时路径
-							const message = uni.$TUIKit.createAudioMessage({
-								to: String(this.userInfo.id),
-								conversationType: this.conversation.type,
-								payload: {
-									file: msg
-								}
-							});
-							this.$sendTIMMessage(message);
+			handleLongPress(e) {
+				this.recorder.start().then(()=>{
+					this.startPoint=e.touches[0];
+					this.voiceText='正在录音,上划可取消';
+					this.isRecording=true;
+					this.recordTime=0;
+					this.recordTimer = setInterval(() => {
+						this.recordTime++;
+						if(this.recorTime>=this.recordTimeTotal){
+							this.recorder.stop();
+							clearInterval(this.recordTimer);
+							this.recordTimer=null;
 						}
-					}
-					this.startPoint=0;
-					this.isRecording=false;
-					this.canSend=true;
-					this.voiceText='按住说话,松手发送';
-				});
-				this.recorderManager.onError(err=>{
-					console.log(err)
+					}, 1000);
+				}).catch(err=>{
+					console.log(err);
 				})
+				
 			},
-			handleLongPress(e) {
-				uni.vibrateShort();
-				this.recorderManager.start({
-					duration: 60000,
-					// 录音的时长,单位 ms,最大值 600000(10 分钟)
-					sampleRate: 44100,
-					// 采样率
-					numberOfChannels: 1,
-					// 录音通道数
-					encodeBitRate: 192000,
-					// 编码码率
-					format: 'aac' // 音频格式,选择此格式创建的音频消息,可以在即时通信 IM 全平台(Android、iOS、微信小程序和Web)互通
-				});
-				this.startPoint=e.touches[0];
-				this.voiceText='正在录音,上划可取消';
-				this.isRecording=true;
-				this.recordTime=0;
-				this.recordTimer = setInterval(() => {
-					this.recordTime++;
-					if(this.recorTime>=this.recordTimeTotal){
-						this.recorderManager.stop();
-						clearInterval(this.recordTimer);
-						this.recordTimer=null;
-					}
-				}, 1000);
+			handleTouchStart(e){
+				this.timeOutEvent = setTimeout(()=> {
+					this.handleLongPress(e);
+				}, 500); 
+				return false;
 			},
-			
 			// 录音时的手势上划移动距离对应文案变化
 			handleTouchMove(e) {
 				if (this.isRecording) {
@@ -402,8 +366,8 @@
 			handleTouchEnd() {
 				this.isRecording=false;
 				this.voiceText='按住说话,松手发送';
-				uni.hideLoading();
-				this.recorderManager.stop();
+				let voiceFile=this.recorder.getPCMBlob();
+				console.log(voiceFile)
 			},
 			sendTextMessage() {
 				const to = String(this.userInfo.id);
@@ -434,7 +398,7 @@
 				if (!this.isCompleted) {
 					this.$TUIKit
 						.getMessageList({
-							conversationID: conversation.conversationID,
+							conversationID: this.conversationID,
 							nextReqMessageID: this.nextReqMessageID,
 							count: 15
 						})

+ 1 - 1
src/views/messages/messages.vue

@@ -243,7 +243,7 @@
 				this.$TUIKit.getConversationList().then(res=>{
 					console.log(res.data.conversationList)
 					for(let i=0;i<res.data.conversationList.length;i++){
-						res.data.conversationList[i].lastMessage.lastTimeStr=this.$moment(res.data.conversationList[i].lastMessage.lastTime*1000).format('YYYY-MM-DD hh:mm:ss');
+						res.data.conversationList[i].lastMessage.lastTimeStr=this.$moment(res.data.conversationList[i].lastMessage.lastTime*1000).format('YYYY-MM-DD HH:mm:ss');
 						if(res.data.conversationList[i].lastMessage.type==='TIMImageElem'){
 							res.data.conversationList[i].lastMessage.payload.text="[图片消息]"
 						}

+ 3 - 3
src/views/search/search.vue

@@ -62,8 +62,8 @@
 				</div>
 			</div>
 		</div>
-		<div class="no-more font24 fw400" v-if="users!==null">没有更多了</div>
-		<Status type="noData" text="暂无数据" v-if="showNoData||!users||users===[]"></Status>
+		<div class="no-more font24 fw400" v-if="users===[]">没有更多了</div>
+		<Status type="noData" text="暂无数据" v-if="showNoData"></Status>
 	</div>
 </template>
 
@@ -107,7 +107,7 @@
 				users:null,
 				searchs:[],
 				inputFocus:true,
-				showNoData:true
+				showNoData:false
 			};
 		},
 		onLoad() {

+ 17 - 2
src/views/vip/vip.vue

@@ -221,9 +221,9 @@
 								title:'提示',
 								message:'是否充值成功'
 							}).then(()=>{
-								
+								this.payResult();
 							}).catch(()=>{
-								
+								this.$toast('充值失败,请重试');
 							})
 						}
 						else{
@@ -235,6 +235,21 @@
 				}
 				
 				
+			},
+			payResult(){
+				this.$api.pay
+				    .loadOrder({outTradeNo: localStorage.getItem('outTradeNo')})
+				    .then((res) => {
+				        if (res.succ) {
+				            if (res.status===true||res.status==='Succ') {
+								this.$toast('充值成功');
+				            } else {
+				                this.$toast('充值失败,请重试');
+				            }
+				        }
+				    }).catch(() => {
+						this.$toast('校验订单失败!');
+				})
 			},
 			toService(){
 				window.location.href=`sugarpark://${encodeURIComponent('https://work.weixin.qq.com/kfid/kfca1b21d2f7e8a18e9')}`;