| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178 |
- <template>
- <view class="content">
- <!-- <navigation-custom :config="config" :scrollTop="scrollTopNav" @customConduct="customConduct" :scrollMaxHeight="scrollMaxHeight" /> -->
- <scroll-view
- id="scrollview"
- class="chat-box"
- :style="{ height: style.contentViewHeight + 'px' }"
- scroll-y="true"
- :scroll-with-animation="false"
- :scroll-top="scrollTop"
- @scrolltoupper="lower()"
- >
- <view class="auth" v-if="!isAuth">
- <text>对不起,您还未登录!请</text>
- <button @click="goAuthPage">授权登录</button>
- </view>
- <!-- <view class="tips-box">
- {{nowTime}}
- </view> -->
- <!-- <view class="tips-box tips-title">
- 您好,智能投顾很高兴为您服务!
- </view> -->
- <!-- <view class="talk-box">
- <view class="talk-head-box">
- <image src="../../static/rabotHead.png" mode="" class="talk-head"></image>
- </view>
- <view class="talk-content">您好,欢迎您使用阿拉灯神丁。我可以给您提供股票投资建议,快来试试吧。</view>
- </view> -->
- <view v-for="chat in talkList" :key="chat.talkType" class="m-item">
- <view class="talk-box talk-box-end" v-show="chat.content">
- <view class="talk-reply">{{ chat.content }}</view>
- <view class="talk-head-box"><image :src="userHeadUrl" mode="" class="talk-head" @click.stop="goUserSelf"></image></view>
- </view>
- <view class="talk-box">
- <view class="talk-head-box"><image :src="rabotHeadImg" mode="" class="talk-head"></image></view>
- <view class="talk-content">
- {{ chat.reply }}
- <text class="goRechargeText" v-if="chat.isRecharge" @click.stop="goSharePage()">去分享</text>
- </view>
- </view>
- </view>
- </scroll-view>
- <view class="send-box" :style="{ 'padding-bottom': isShowKeyBoard + 'px' }">
- <image :src="[!isVoiceType ? '/static/icon/voice-icon.png' : '/static/icon/keyBoard-icon.png']" @click.stop="tabVoice()"></image>
- <view class="voice-mode" v-if="isVoiceType" @touchstart="longPressStart" @touchend="touchMoveEnd">按住说话</view>
- <!-- <view>{{arsRes}}</view> -->
- <!-- 语音识别 -->
- <!-- <wechat-asr ref="weixinAsr" @callback="asrResult" /> -->
- <input
- type="text"
- v-if="!isVoiceType"
- class="enter-box"
- v-model="inputInfo"
- :adjust-position="true"
- @focus="isNeedAuth()"
- :style="{ width: inputWidth }"
- confirm-hold="true"
- confirm-type="send"
- @confirm="sendInputInfo"
- />
- <!-- @input='isInputing' -->
- <!-- <button type="primary" class="submit-message" @click="sendInputInfo()" v-if='isShowSend'>发送</button> -->
- <image src="/static/setIcon.png" @click.stop="openModal()" v-if="isShowSetCenter"></image>
- </view>
- <view>
- <uni-popup ref="showCountsModal" type="center" :custom="true">
- <view class="uni-tip everyDay-box">
- <image src="/static/rabotHead.png" mode="aspectFit"></image>
- <view>恭喜你获取{{ everyDayCounts || 0}}次查询机会</view>
- <button type="default" @click.stop="addEveryDayCounts">我知道啦</button>
- </view>
- </uni-popup>
- </view>
- <view class="mask" v-show="isShowVoice">
- <view class="weixin-asr">
- <view class="title">语音识别</view>
- <!-- 动画 -->
- <view class="spinner">
- <view class="rect rect1"></view>
- <view class="rect rect2"></view>
- <view class="rect rect3"></view>
- <view class="rect rect4"></view>
- <view class="rect rect5"></view>
- </view>
- <view class="tip">说出股票代码</view>
- <!-- <view>{{resultText}}</view> -->
- <button class="btn" type="default" @click="recordStop">说完了</button>
- </view>
- </view>
- <uni-popup ref="popup" type="bottom">
- <view class="uni-share">
- <view class="uni-share-content">
- <view class="uni-share-content-box" @click.stop="goUserSelf">
- <view class="uni-share-content-image"><image src="/static/icon/userSetIcon.png" class="image" /></view>
- <view class="uni-share-content-text">个人中心</view>
- </view>
- <view class="uni-share-content-box" @click.stop="goSharePage">
- <view class="uni-share-content-image"><image src="/static/icon/share-icon1.png" class="image" /></view>
- <view class="uni-share-content-text">去分享</view>
- </view>
- <!-- <view class="uni-share-content-box" @click.stop='tabVoice' >
- <view class="uni-share-content-image">
- <image src="/static/icon/userSetIcon.png" class="image" />
- </view>
- <view class="uni-share-content-text">语音输入</view>
- </view> -->
- <view class="uni-share-content-box" @click.stop="cleanChatRecord()">
- <view class="uni-share-content-image"><image src="/static/icon/clean-icon.png" class="image" /></view>
- <view class="uni-share-content-text">清空</view>
- </view>
- <!-- <view class="uni-share-content-box" @click.stop='goRecharge' v-if="!isIos">
- <view class="uni-share-content-image">
- <image src="/static/icon/recharge.png" class="image" />
- </view>
- <view class="uni-share-content-text">去充值</view>
- </view> -->
- </view>
- <view class="uni-share-btn" @click="cancelModal()">取消</view>
- </view>
- </uni-popup>
- </view>
- </template>
- <script>
- import uniPopup from "@/components/uni-popup/uni-popup.vue"
- import WechatAsr from '../chat/chat.vue';
- var md5 = require("../../common/md5.js");
- var page = 1;
- const recorderManager = uni.getRecorderManager();
- const innerAudioContext = uni.createInnerAudioContext();
- const WechatSI = requirePlugin("WechatSI");
- const ASRManager = WechatSI.getRecordRecognitionManager();
- export default {
- data() {
- return {
- isShowVoice:false,
- isShowSend:false,
- isShowSetModal:false,
- isShowSetCenter:true,
- isShowRecharge:false,
- inputWidth:'70%',
- title: 'RABOT',
- nowTime: '',
- nowHeight: '622px',
- inputInfo: '',
- isShowKeyBoard:0,
- rabotHeadImg: "../../static/rabotHead.png",
- userHeadUrl: getApp().globalData.user_headUrl || '../../static/userDefault.png',
- talkList: [],
- scrollTopNav: 0, // 当linear为true的时候需要通过onpagescroll传递参数
- scrollMaxHeight: 200 ,//滑动的高度限制,超过这个高度即背景全部显示
- scrollTop:0,
- scrollRequestEnable: true,
- pageSize:10,
- isIos:Boolean,
- style: {
- pageHeight: 0,
- contentViewHeight: 0,
- footViewHeight: 90,
- mitemHeight: 0
- },
- isAuth:true,
- iv:'',
- session_key:'',
- encryptedData:'',
- //录音相关参数
- isVoiceType:false,
- RECORDER:uni.getRecorderManager(),
- isVoice:false,
- voiceTis:'按住 说话',
- recordTis:"手指上滑 取消发送",
- recording:false,
- willStop:false,
- initPoint:{identifier:0,Y:0},
- recordTimer:null,
- recordLength:0,
- //播放语音相关参数
- AUDIO:uni.createInnerAudioContext(),
- playMsgid:null,
- VoiceTimer:null,
- voicePath: '',
- arsRes: '',
- inviteId:'',
- everyDayCounts:''
- }
- },
- components: {
- uniPopup,
- WechatAsr
- },
- onPageScroll(e) {
- this.scrollTopNav = e.scrollTop;
- },
- onReady () {
- // 录音开启成功回调
- ASRManager.onStart = function (res) {
- _this.isShowVoice = true;
- }
-
- const _this = this;
- // 识别错误事件
- ASRManager.onError = (res) => {
- _this.isShowVoice = false;
- // uni.showToast({
- // title:'请再试一次',
- // icon:'none',
- // duration:2000
- // })
- }
-
- // 录音停止回调
- ASRManager.onStop = function (res) {
- if (res && res.result) {
- // _this.resultText = res.result;
- // _this.$emit('callback', res.result);
- res = (res.result).substring(0,res.result.length-1)
- console.log(res)
- page = 1;
- _this.sendMsgRequest(res)
- } else {
- uni.showToast({
- icon: 'none',
- title: '抱歉,没听到您的声音哦'
- })
- }
- }
- },
- onShareAppMessage(){
- return {
- title: '阿拉灯神丁',
- path: '/pages/index/index?inviteId=' + getApp().globalData.user_id
- }
- },
- onLoad(options) {
- if(options.inviteId){
- page = 1;
- this.inviteId = options.inviteId;
- getApp().globalData.inviteId = options.inviteId;
- console.log('inviteId:',getApp().globalData.inviteId)
- }
- this.userLogin();
- this.getEquipmentHeight();
- },
- onShow() {
- //this.getNowTime();
- this.userHeadUrl = getApp().globalData.user_headUrl || '../../static/userDefault.png',
- getApp().globalData.isAuth ? this.isAuth = true : this.isAuth = false ;
- getApp().globalData.user_id ? this.getUserStorage(): this.title = 'RABOT' ;
- getApp().globalData.user_id ? this.isShowRecharge ? this.getHistory('show') : this.getHistory() : this.title = 'RABOT' ;
- },
- methods: {
- userLogin(){
- uni.showLoading({})
- uni.login({
- success: (res) => {
- this.getCodeRabot(res)
- }
- });
- },
- // 获取用户信息
- getUserInfo(e) {
- console.log(e);
- if (e.detail.errMsg == "getUserInfo:ok") {
- this.iv = e.detail.iv;
- this.encryptedData = e.detail.encryptedData;
- this.loginUserInfo()
- } else {
- console.log("用户信息授权失败");
- this.isShowAuthBtn = true;
- }
- },
- loginUserInfo(){
- let that = this;
- uni.request({
- url:getApp().globalData.shareUrl, //需要设置为全局
- method: 'POST',
- header: {
- 'content-type': 'application/x-www-form-urlencoded'
- },
- data: {
- method: 'auth',
- timestamp: getApp().globalData.globalTimestamp, //Date.now()
- //uid:getApp().globalData.user_id,
- sign: md5('auth' + getApp().globalData.globalTimestamp),
- //nickname:getApp().globalData.user_name,
- //headimg:getApp().globalData.user_headUrl,
- iv:that.iv,
- session_key:that.session_key,
- encryptedData:that.encryptedData,
- invited:that.inviteId
- },
- success: res => {
- that.isAuth = true;
- getApp().globalData.user_id = res.data.msg.id;
- getApp().globalData.open_id = res.data.msg.openid;
- getApp().globalData.isAuth = that.isAuth;
- getApp().globalData.times = res.data.msg.times;
- getApp().globalData.total_times = res.data.msg.total_times;
- getApp().globalData.user_headUrl = res.data.msg.headimg;
- getApp().globalData.user_name = res.data.msg.name;
- that.userHeadUrl = res.data.msg.headimg || '../../static/userDefault.png';
- that.getUserStorage();
- that.getHistory();
- }
- });
- },
- getCodeRabot(res){
- let that = this;
- uni.request({
- url:getApp().globalData.shareUrl, //需要设置为全局
- method: 'POST',
- header: {
- 'content-type': 'application/x-www-form-urlencoded'
- },
- data: {
- method: 'login',
- timestamp: getApp().globalData.globalTimestamp, //Date.now()
- code: res.code,
- sign: md5('login' + getApp().globalData.globalTimestamp),
- },
- success: res => {
- var isAuth = res.data.msg.isauth === 1;
- that.session_key = res.data.msg.session_key;
- if(isAuth){
- this.isAuth = true;
- getApp().globalData.user_id = res.data.msg.id;
- getApp().globalData.open_id = res.data.msg.openid;
- getApp().globalData.isAuth = true;
- getApp().globalData.times = res.data.msg.times;
- getApp().globalData.total_times = res.data.msg.total_times;
- getApp().globalData.user_headUrl = res.data.msg.headimg;
- getApp().globalData.user_name = res.data.msg.name;
- that.userHeadUrl = res.data.msg.headimg || '../../static/userDefault.png';
- that.getUserStorage();
- that.getHistory();
- }else{
- getApp().globalData.session_key = res.data.msg.session_key;
- that.isAuth = isAuth;
- getApp().globalData.isAuth = isAuth;
- wx.hideLoading();
- }
- }
- });
- },
- getNowTime() {
- let time = new Date();
- let y = time.getFullYear();
- let m = time.getMonth() + 1;
- let d = time.getDate();
- let h = time.getHours();
- let i = time.getMinutes();
- i = i > 10 ? i : '0' + i;
- this.nowTime = y + "年" + m + "月" + d + "日" + " " + h + ":" + i
- },
- getUserStorage(){
- let that = this
- uni.getStorage({
- key: 'getTime',
- success: function (res) {
- let nowTime = Date.now();
- let lastTime = res.data;
- if(nowTime - lastTime >= 86400000){
- that.getEveryDayCounts()
- }else {
- return false
- }
- },
- fail:function () {
- that.getEveryDayCounts()
- }
- });
- },
- getEveryDayCounts(){
- let that = this;
- uni.request({
- url: getApp().globalData.shareUrl, //需要设置为全局
- method: 'POST',
- header: {
- 'content-type': 'application/x-www-form-urlencoded'
- },
- data: {
- method: 'add_freegive_times',
- timestamp: getApp().globalData.globalTimestamp, //Date.now()
- uid: getApp().globalData.user_id,
- sign: md5('add_freegive_times' + getApp().globalData.globalTimestamp),
- },
- success: res => {
- if(res.data.code === 200){
- that.everyDayCounts = res.data.msg.times;
- that.$refs.showCountsModal.open();
- uni.setStorage({
- key: 'getTime',
- data:Date.now(),
- success: function () {
- console.log('success');
- //that.$refs.showCountsModal.close()
- }
- });
- }
- else {
- // uni.showToast({
- // title:res.data.msg,
- // icon:'none',
- // duration:1500
- // })
- return false
- }
- }
- });
- },
- addEveryDayCounts(){
- console.log('已领取');
- this.$refs.showCountsModal.close()
- },
- getEquipmentHeight() {
- const height = uni.getSystemInfoSync().windowHeight;
- this.nowHeight = height + 'px';
- getApp().globalData.glbalHeight = this.nowHeight;
- this.style.pageHeight = height;
- this.style.contentViewHeight = height - uni.getSystemInfoSync().screenWidth / 750 * (100) -7; //像素 因为给出的是像素高度 然后我们用的是upx 所以换算一下
- },
- scrollToBottom() {
- let that = this;
- let query = uni.createSelectorQuery();
- query.selectAll('.m-item').boundingClientRect();
- query.select('#scrollview').boundingClientRect();
- query.exec((res) => {
- that.style.mitemHeight = 0;
- res[0].forEach((rect) => that.style.mitemHeight = that.style.mitemHeight + rect.height + 40) //获取所有内部子元素的高度
- // 因为vue的虚拟DOM 每次生成的新消息都是之前的,所以采用异步setTimeout 主要就是添加了这红字
- that.scrollTop = that.style.mitemHeight - that.style.contentViewHeight
- // setTimeout(() => {
- // if (that.style.mitemHeight > (that.style.contentViewHeight - 100)) { //判断子元素高度是否大于显示高度
- // that.scrollTop = that.style.mitemHeight - that.style.contentViewHeight //用子元素的高度减去显示的高度就获益获得序言滚动的高度
- // }
- // }, 100)
- })
- },
- getHistory(isShow) {
- // if(getApp.globalData.isAuth){this.isAuth = true}
- let that = this;
- uni.request({
- url: getApp().globalData.shareUrl, //需要设置为全局
- method: 'POST',
- header: {
- 'content-type': 'application/x-www-form-urlencoded'
- },
- data: {
- method: 'question_list',
- timestamp: getApp().globalData.globalTimestamp, //Date.now()
- uid: getApp().globalData.user_id,
- sign: md5('question_list' + getApp().globalData.globalTimestamp),
- page: page || 1,
- pageSize: 10,
- },
- success: res => {
- uni.hideLoading()
- that.isIos = getApp().globalData.isIos;
- if(isShow){
- res.data.msg[0].isRecharge = 1
- }
- if(page === 1){
- that.scrollRequestEnable = true;
- that.talkList = ((res.data.msg).reverse());
- setTimeout(()=>{
- that.scrollToBottom()
- },100)
- }else if (page > 1 && res.data.msg.length === that.pageSize) {
- that.scrollRequestEnable = true;
- that.talkList.unshift(...((res.data.msg).reverse()));
- }else if (page > 1 && (res.data.msg.length > 0) && (res.data.msg.length < that.pageSize)){
- that.scrollRequestEnable = true;
- that.talkList.unshift(...((res.data.msg).reverse()));
- }else if (page > 1 && res.data.msg.length == 0){
- that.scrollRequestEnable = false;
- }
- }
- });
- },
- goUserSelf() {
- this.$refs.popup.close()
- uni.navigateTo({
- url: '../selfInfo/selfInfo'
- })
- },
- goRecharge() {
- this.$refs.popup.close()
- uni.navigateTo({
- url: '../selfInfo/payList/payList'
- })
- },
- sendMsgRequest(msg) {
- if(getApp().globalData.user_id=='') return false;
- let that = this;
- uni.request({
- url: getApp().globalData.shareUrl, //需要设置为全局
- method: 'POST',
- header: {
- 'content-type': 'application/x-www-form-urlencoded'
- },
- data: {
- method: 'question',
- timestamp: getApp().globalData.globalTimestamp, //Date.now()
- uid: getApp().globalData.user_id,
- sign: md5('question' + getApp().globalData.globalTimestamp),
- content: msg
- },
- success: res => {
- if(res.data.code === 100){
- that.isShowRecharge = true;
- that.inputInfo = '';
- that.getHistory('show');
- }else {
- that.inputInfo = '';
- that.getHistory();
- that.isShowRecharge = false
- }
- }
- });
- },
- sendInputInfo() {
- // this.inputWidth = '80%';
- // this.isShowSend = false;
- // this.isShowSetCenter = true;
- if (!this.inputInfo) {
- uni.showToast({
- title: '请输入股票代码',
- icon: 'none'
- });
- } else {
- page = 1;
- this.sendMsgRequest(this.inputInfo)
- }
- },
- isInputing(){
- if (this.inputInfo) {
- this.inputWidth = '72%';
- this.isShowSend = true;
- this.isShowSetCenter = false;
- } else {
- this.inputWidth = '80%';
- this.isShowSend = false;
- this.isShowSetCenter = true;
- }
- },
- isNeedAuth(){
- if(!this.isAuth){
- setTimeout(()=>{
- uni.navigateTo({
- url: '../auth/index',
- success: res => {},
- fail: () => {},
- complete: () => {}
- });
- },500)
- }
- },
- // 滚动至底部触发的事件
- lower() {
- if (this.scrollRequestEnable) {
- // 允许滚动时,触底page加一,重新请求数据
- console.log(666)
- page++;
- this.getHistory();
- } else {
- // 不允许滚动时,只显示"到底了"提示
- // this.showBottem = true
- console.log('noData')
- }
- },
- getInputFocus(e){
- //this.isShowKeyBoard = e.detail.height
- },
- getInputBlur(){
- //this.isShowKeyBoard = 0
- },
- goSharePage(){
- uni.navigateTo({
- url: '../share/sharePage',
- success: res => {},
- fail: () => {},
- complete: () => {}
- });
- },
- tabVoice(){
- this.isVoiceType = !this.isVoiceType;
- },
- clearChat(){
- },
- goAuthPage(){
- uni.navigateTo({
- url: '../auth/index',
- success: res => {},
- fail: () => {},
- complete: () => {}
- });
- },
- openModal(){
- // 需要在 popup 组件,指定 ref 为 popup
- if(!this.isAuth){
- uni.navigateTo({
- url: '../auth/index',
- success: res => {},
- fail: () => {},
- complete: () => {}
- });
- }else {
- this.$refs.popup.open();
- }
- },
- cancelModal(){
- // 需要在 popup 组件,指定 ref 为 popup
- this.$refs.popup.close();
- },
- //情况聊天记录
- cleanChatRecord(){
- if(getApp().globalData.user_id=='') return false;
- let that = this;
- uni.request({
- url: getApp().globalData.shareUrl, //需要设置为全局
- method: 'POST',
- header: {
- 'content-type': 'application/x-www-form-urlencoded'
- },
- data: {
- method: 'clear_question',
- timestamp: getApp().globalData.globalTimestamp, //Date.now()
- uid: getApp().globalData.user_id,
- sign: md5('clear_question' + getApp().globalData.globalTimestamp),
- },
- success: res => {
- console.log(res)
- if(res.data.code === 200){
- uni.showToast({
- title: '清除成功',
- icon:'none',
- duration:1500
- });
- that.$refs.popup.close();
- page = 1;
- that.getHistory();
- }else{
- uni.showToast({
- title: res.data.msg,
- icon:'none',
- duration:1500
- });
- }
- }
- });
- },
- // 语音识别
- show() {
- const _this = this;
- // 获取是否授权信息
- uni.getSetting({
- success(res) {
- if (res && res.authSetting && res.authSetting.hasOwnProperty('scope.record')) {
- if (res.authSetting['scope.record']) {
- start();
- } else { // 拒绝授权,打开授权设置
- uni.showModal({
- title: '麦克风授权',
- content: '点击确定重新获取授权。',
- success: function(res) {
- if (res.confirm) {
- uni.openSetting({
- success: res => {
- console.log('授权成功');
- }
- });
- }
- }
- });
- }
- } else {
- start();
- }
- }
- })
-
- function start () {
- ASRManager.start({
- lang: "zh_CN"
- });
- }
- },
- // 录音停止
- recordStop () {
- this.isShowVoice = false;
- ASRManager.stop();
- },
-
- // asrStart () {
- // let that = this;
- // this.$jiuaiDebounce.canDoFunction({
- // key:"asrStart",//基于此值判断是否可以操作,如两个方法传入了同样的key,则会混淆,建议传入调用此事件的方法名,简单好梳理
- // time:3000,//如果传入time字段,则为定时器后,自动解除锁定状态,单位(毫秒)
- // success:()=>{//成功中调用应该操作的方法,被锁定状态不会执行此代码块内的方法
- // this.isShowVoice = true;
- // this.show();
- // console.log(666)
- // }
- // })
- // },
- longPressStart(){
- this.show();
- },
- touchMoveEnd(){
- this.recordStop()
- },
- asrResult (res) {
- //this.arsRes = res;
- res = res.substring(0,res.length-1)
- page = 1;
- this.sendMsgRequest(res)
- }
- },
- onShareAppMessage(){
- }
- }
- </script>
- <style lang="scss">
- .content {
- text-align: center;
- }
- .chat-box {
- background: #f4f5f7;
- padding-top: 3%;
- /* padding-bottom: 100upx; */
- }
- .tips-box {
- background: #d5d5da;
- font-size: 28upx;
- color: #fff;
- border-radius: 30upx;
- width: 50%;
- margin: 0 auto;
- height: 50rpx;
- line-height: 50rpx;
- }
- .tips-title {
- width: 70%;
- margin-top: 5%;
- font-size: 30rpx;
- height: 70rpx;
- line-height: 70rpx;
- }
- .send-box {
- width: 100%;
- height: 90rpx;
- position: fixed;
- bottom: 0;
- background: #f4f0ed;
- display: flex;
- align-items: center;
- padding: 2upx;
- }
- .talk-box {
- display: flex;
- justify-content: flex-start;
- align-items: center;
- margin-top: 3%;
- }
- .talk-box-end {
- justify-content: flex-end;
- }
- .talk-head-box {
- width: 80rpx;
- height: 80rpx;
- border-radius: 30rpx;
- margin-left: 2%;
- margin-right: 2%;
- }
- .talk-head {
- width: 100%;
- height: 100%;
- border-radius: 50%;
- }
- .talk-content {
- padding: 2%;
- background: #fff;
- font-size: 28rpx;
- border-top-right-radius: 20rpx;
- border-bottom-left-radius: 20rpx;
- border-bottom-right-radius: 20rpx;
- text-align: left;
- max-width: 70%;
- }
- .talk-reply {
- padding: 2%;
- background: #9eea6a;
- font-size: 28rpx;
- border-top-left-radius: 20rpx;
- border-bottom-left-radius: 20rpx;
- border-bottom-right-radius: 20rpx;
- text-align: left;
- max-width: 70%;
- }
- .goRechargeText {
- color: #0a98d5;
- }
- .enter-box {
- height: 70rpx;
- background: #fff;
- border-radius: 1%;
- text-align: left;
- margin: 8px;
- margin-bottom: 10px;
- padding-left: 8px;
- }
- .send-box image {
- width: 60rpx;
- height: 60rpx;
- margin-right: 10upx;
- margin-left: 10upx;
- }
- .submit-message {
- width: 18%;
- margin-right: 20upx;
- height: 70rpx;
- font-size: 28rpx;
- line-height: 70rpx;
- color: #fff;
- background-color: #0a98d5 !important;
- }
- .logo {
- height: 200upx;
- width: 200upx;
- margin-top: 200upx;
- margin-left: auto;
- margin-right: auto;
- margin-bottom: 50upx;
- }
- .text-area {
- display: flex;
- justify-content: center;
- }
- .title {
- font-size: 36upx;
- color: #8f8f94;
- }
- .uniFab {
- width: 98px;
- height: 36px;
- background: rgba(231, 247, 236, 1);
- box-shadow: -6px 5px 74px 0px rgba(60, 188, 99, 0.08);
- border-radius: 100px 0px 0px 100px;
- right: 0upx;
- position: fixed;
- z-index: 9999;
- top: 50%;
- display: flex;
- justify-content: center;
- align-items: center;
- }
- .uniFab text {
- width: 64px;
- font-size: 16px;
- font-family: PingFangSC;
- font-weight: 600;
- color: rgba(60, 188, 99, 1);
- text-shadow: 0px 1px 2px rgba(12, 39, 20, 0.2);
- }
- .uni-share-content {
- display: flex;
- flex-wrap: wrap;
- padding: 15px;
- /* justify-content: center */
- }
- .uni-share-content-box {
- display: flex;
- flex-direction: column;
- align-items: center;
- width: 25%;
- box-sizing: border-box;
- }
- .uni-share-content-image {
- display: flex;
- justify-content: center;
- align-items: center;
- width: 60upx;
- height: 60upx;
- overflow: hidden;
- border-radius: 10upx;
- }
- .uni-share-content-image .image {
- width: 100%;
- height: 100%;
- }
- .uni-share-content-text {
- font-size: 26upx;
- color: #333;
- padding-top: 5px;
- padding-bottom: 10px;
- }
- .uni-share-btn {
- height: 90upx;
- line-height: 90upx;
- border-top: 1px #f5f5f5 solid;
- text-align: center;
- color: #666;
- font-size: 30rpx;
- }
- /* .placeHolder {
- padding:2px
- } */
- .auth {
- display: flex;
- flex-direction: row;
- font-size: 14px;
- justify-content: center;
- align-items: center;
- background-color: #eee;
- }
- .auth button {
- font-size: 14px;
- padding: 0px;
- margin: 0px;
- color: #007aff;
- background-color: #eee;
- }
- .auth button:after {
- border: 0px;
- }
- .voice-mode {
- width: 70%;
- height: 70rpx;
- background: #fff;
- border-radius: 1%;
- text-align: left;
- margin: 8px;
- margin-bottom: 10px;
- padding-left: 8px;
- text-align: center;
- line-height: 70upx;
- font-size: 30upx;
- }
- .icon {
- font-family: 'HMfont-home' !important;
- font-size: 56upx;
- font-style: normal;
- color: #333;
- }
- .hidden {
- display: none !important;
- }
- .record {
- width: 40vw;
- height: 40vw;
- position: fixed;
- top: 55%;
- left: 30%;
- background-color: rgba(0, 0, 0, 0.6);
- border-radius: 20upx;
- }
- .ing {
- width: 100%;
- height: 30vw;
- display: flex;
- justify-content: center;
- align-items: center;
- // 模拟录音音效动画
- }
- @keyframes volatility {
- 0% {
- background-position: 0% 130%;
- }
- 20% {
- background-position: 0% 150%;
- }
- 30% {
- background-position: 0% 155%;
- }
- 40% {
- background-position: 0% 150%;
- }
- 50% {
- background-position: 0% 145%;
- }
- 70% {
- background-position: 0% 150%;
- }
- 80% {
- background-position: 0% 155%;
- }
- 90% {
- background-position: 0% 140%;
- }
- 100% {
- background-position: 0% 135%;
- }
- }
- .cancel {
- width: 100%;
- height: 30vw;
- display: flex;
- justify-content: center;
- align-items: center;
- }
- .icon {
- background-image: linear-gradient(to bottom, #f09b37, #fff 50%);
- background-size: 100% 200%;
- animation: volatility 1.5s ease-in-out -1.5s infinite alternate;
- -webkit-background-clip: text;
- -webkit-text-fill-color: transparent;
- font-size: 150upx;
- color: #f09b37;
- }
- .tis {
- width: 100%;
- height: 10vw;
- display: flex;
- justify-content: center;
- font-size: 28upx;
- color: #fff;
- }
- .change {
- color: #f09b37;
- }
- .everyDay-box {
- background: #fff;
- padding: 20px;
- border-radius: 5%;
- }
- .everyDay-box image {
- width: 240rpx;
- height: 240rpx;
- }
- .everyDay-box view {
- font-size: 28rpx;
- }
- .everyDay-box button {
- font-size: 28rpx;
- margin-top: 5%;
- color: #fff;
- background: #00bfff;
- }
- .mask {
- position: fixed;
- top: 0;
- left: 0;
- z-index: 300;
- width: 100%;
- height: 100%;
- background: rgba(0, 0, 0, .54);
- }
- .weixin-asr {
- position: absolute;
- top: calc(50% - #{477upx / 2});
- left: 0;
- right: 0;
- margin: 0 auto;
- width: 560upx;
- height: 477upx;
- background: #fff;
- text-align: center;
- transform: .5s ease-out .5s;
- .title {
- margin-top: 42upx;
- color: #000;
- font-size: 34upx;
- font-weight: 500;
- }
- .spinner {
- margin: 50upx;
- height: 100upx;
- }
- .tip {
- color: #787878;
- }
- .btn {
- margin-top: 28upx;
- width: 225upx;
- height: 82upx;
- background: #27BCEF;
- color: #fff;
- font-size: 34upx;
- line-height: 82upx;
- border-radius: 82upx;
- }
- }
-
- .spinner {
- text-align: center;
- }
-
- .spinner > .rect {
- background-color: #EDAA35;
- height: 100%;
- border-radius: 13upx;
- width: 13upx;
- display: inline-block;
-
- -webkit-animation: stretchdelay 1.2s infinite ease-in-out;
- animation: stretchdelay 1.2s infinite ease-in-out;
-
- & + .rect {
- margin-left: 15upx;
- }
- }
-
- .spinner .rect2 {
- -webkit-animation-delay: -1.1s;
- animation-delay: -1.1s;
- }
-
- .spinner .rect3 {
- -webkit-animation-delay: -1.0s;
- animation-delay: -1.0s;
- }
-
- .spinner .rect4 {
- -webkit-animation-delay: -0.9s;
- animation-delay: -0.9s;
- }
-
- .spinner .rect5 {
- -webkit-animation-delay: -0.8s;
- animation-delay: -0.8s;
- }
-
- @-webkit-keyframes stretchdelay {
- 0%, 40%, 100% { -webkit-transform: scaleY(0.4) }
- 20% { -webkit-transform: scaleY(1.0) }
- }
-
- @keyframes stretchdelay {
- 0%, 40%, 100% {
- transform: scaleY(0.4);
- -webkit-transform: scaleY(0.4);
- } 20% {
- transform: scaleY(1.0);
- -webkit-transform: scaleY(1.0);
- }
- }
- </style>
|