index.vue 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985
  1. <template>
  2. <view class="content">
  3. <!-- <navigation-custom :config="config" :scrollTop="scrollTopNav" @customConduct="customConduct" :scrollMaxHeight="scrollMaxHeight" /> -->
  4. <scroll-view
  5. id="scrollview"
  6. class="chat-box"
  7. :style="{ height: style.contentViewHeight + 'px' }"
  8. scroll-y="true"
  9. :scroll-with-animation="false"
  10. :scroll-top="scrollTop"
  11. @scrolltoupper="lower()"
  12. >
  13. <view class="auth" v-if="!isAuth">
  14. <text>对不起,您还未登录!请</text>
  15. <button @click="goAuthPage">授权登录</button>
  16. </view>
  17. <!-- <view class="tips-box">
  18. {{nowTime}}
  19. </view> -->
  20. <!-- <view class="tips-box tips-title">
  21. 您好,智能投顾很高兴为您服务!
  22. </view> -->
  23. <!-- <view class="talk-box">
  24. <view class="talk-head-box">
  25. <image src="../../static/rabotHead.png" mode="" class="talk-head"></image>
  26. </view>
  27. <view class="talk-content">您好,欢迎您使用阿拉灯神丁。我可以给您提供股票投资建议,快来试试吧。</view>
  28. </view> -->
  29. <view v-for="chat in talkList" :key="chat.talkType" class="m-item">
  30. <view class="talk-box talk-box-end" v-show="chat.content">
  31. <view class="talk-reply">{{ chat.content }}</view>
  32. <view class="talk-head-box"><image :src="userHeadUrl" mode="" class="talk-head" @click.stop="goUserSelf"></image></view>
  33. </view>
  34. <view class="talk-box">
  35. <view class="talk-head-box"><image :src="rabotHeadImg" mode="" class="talk-head"></image></view>
  36. <view class="talk-content">
  37. {{ chat.reply }}
  38. <text class="goRechargeText" v-if="chat.isRecharge" @click.stop="goSharePage()">去分享</text>
  39. </view>
  40. </view>
  41. </view>
  42. </scroll-view>
  43. <view class="send-box" :style="{ 'padding-bottom': isShowKeyBoard + 'px' }">
  44. <image :src="[!isVoiceType ? '/static/icon/voice-icon.png' : '/static/icon/keyBoard-icon.png']" @click.stop="tabVoice()"></image>
  45. <view class="voice-mode" v-if="isVoiceType" @click="asrStart">语音识别</view>
  46. <!-- <view>{{arsRes}}</view> -->
  47. <!-- 语音识别 -->
  48. <wechat-asr ref="weixinAsr" @callback="asrResult" />
  49. <input
  50. type="text"
  51. v-if="!isVoiceType"
  52. class="enter-box"
  53. v-model="inputInfo"
  54. :adjust-position="true"
  55. @focus="isNeedAuth()"
  56. :style="{ width: inputWidth }"
  57. confirm-hold="true"
  58. confirm-type="send"
  59. @confirm="sendInputInfo"
  60. />
  61. <!-- @input='isInputing' -->
  62. <!-- <button type="primary" class="submit-message" @click="sendInputInfo()" v-if='isShowSend'>发送</button> -->
  63. <image src="/static/setIcon.png" @click.stop="openModal()" v-if="isShowSetCenter"></image>
  64. </view>
  65. <view>
  66. <uni-popup ref="showCountsModal" type="center" :custom="true">
  67. <view class="uni-tip everyDay-box">
  68. <image src="/static/rabotHead.png" mode="aspectFit"></image>
  69. <view>恭喜你获取{{ everyDayCounts || 0}}次查询机会</view>
  70. <button type="default" @click.stop="addEveryDayCounts">我知道啦</button>
  71. </view>
  72. </uni-popup>
  73. </view>
  74. <!-- 录音UI效果
  75. <view class="record" :class="recording?'':'hidden'">
  76. <view class="ing" :class="willStop?'hidden':''"><image src="../../static/icon/send-icon.png" style="width: 64rpx;height: 64rpx;"></image></view>
  77. <view class="cancel" :class="willStop?'':'hidden'"><image src="../../static/icon/cancel-icon.png" style="width: 64rpx;height: 64rpx;"></image></view>
  78. <view class="tis" :class="willStop?'change':''">{{recordTis}}</view>
  79. </view> -->
  80. <!-- <drag-button :isDock="true" :existTabBar="true" @btnClick="goUserSelf" /> -->
  81. <uni-popup ref="popup" type="bottom">
  82. <view class="uni-share">
  83. <view class="uni-share-content">
  84. <view class="uni-share-content-box" @click.stop="goUserSelf">
  85. <view class="uni-share-content-image"><image src="/static/icon/userSetIcon.png" class="image" /></view>
  86. <view class="uni-share-content-text">个人中心</view>
  87. </view>
  88. <view class="uni-share-content-box" @click.stop="goSharePage">
  89. <view class="uni-share-content-image"><image src="/static/icon/share-icon1.png" class="image" /></view>
  90. <view class="uni-share-content-text">去分享</view>
  91. </view>
  92. <!-- <view class="uni-share-content-box" @click.stop='tabVoice' >
  93. <view class="uni-share-content-image">
  94. <image src="/static/icon/userSetIcon.png" class="image" />
  95. </view>
  96. <view class="uni-share-content-text">语音输入</view>
  97. </view> -->
  98. <view class="uni-share-content-box" @click.stop="cleanChatRecord()">
  99. <view class="uni-share-content-image"><image src="/static/icon/clean-icon.png" class="image" /></view>
  100. <view class="uni-share-content-text">清空</view>
  101. </view>
  102. <!-- <view class="uni-share-content-box" @click.stop='goRecharge' v-if="!isIos">
  103. <view class="uni-share-content-image">
  104. <image src="/static/icon/recharge.png" class="image" />
  105. </view>
  106. <view class="uni-share-content-text">去充值</view>
  107. </view> -->
  108. </view>
  109. <view class="uni-share-btn" @click="cancelModal()">取消</view>
  110. </view>
  111. </uni-popup>
  112. </view>
  113. </template>
  114. <script>
  115. import uniPopup from "@/components/uni-popup/uni-popup.vue"
  116. import WechatAsr from '../chat/chat.vue';
  117. var md5 = require("../../common/md5.js");
  118. var page = 1;
  119. const recorderManager = uni.getRecorderManager();
  120. const innerAudioContext = uni.createInnerAudioContext();
  121. export default {
  122. data() {
  123. return {
  124. isShowSend:false,
  125. isShowSetModal:false,
  126. isShowSetCenter:true,
  127. isShowRecharge:false,
  128. inputWidth:'70%',
  129. title: 'RABOT',
  130. nowTime: '',
  131. nowHeight: '622px',
  132. inputInfo: '',
  133. isShowKeyBoard:0,
  134. rabotHeadImg: "../../static/rabotHead.png",
  135. userHeadUrl: getApp().globalData.user_headUrl || '../../static/userDefault.png',
  136. talkList: [],
  137. scrollTopNav: 0, // 当linear为true的时候需要通过onpagescroll传递参数
  138. scrollMaxHeight: 200 ,//滑动的高度限制,超过这个高度即背景全部显示
  139. scrollTop:0,
  140. scrollRequestEnable: true,
  141. pageSize:10,
  142. isIos:Boolean,
  143. style: {
  144. pageHeight: 0,
  145. contentViewHeight: 0,
  146. footViewHeight: 90,
  147. mitemHeight: 0
  148. },
  149. isAuth:true,
  150. iv:'',
  151. session_key:'',
  152. encryptedData:'',
  153. //录音相关参数
  154. isVoiceType:false,
  155. RECORDER:uni.getRecorderManager(),
  156. isVoice:false,
  157. voiceTis:'按住 说话',
  158. recordTis:"手指上滑 取消发送",
  159. recording:false,
  160. willStop:false,
  161. initPoint:{identifier:0,Y:0},
  162. recordTimer:null,
  163. recordLength:0,
  164. //播放语音相关参数
  165. AUDIO:uni.createInnerAudioContext(),
  166. playMsgid:null,
  167. VoiceTimer:null,
  168. voicePath: '',
  169. arsRes: '',
  170. inviteId:'',
  171. everyDayCounts:''
  172. }
  173. },
  174. components: {
  175. uniPopup,
  176. WechatAsr
  177. },
  178. onPageScroll(e) {
  179. this.scrollTopNav = e.scrollTop;
  180. },
  181. onShareAppMessage(){
  182. return {
  183. title: '阿拉灯神丁',
  184. path: '/pages/index/index?inviteId=' + getApp().globalData.user_id
  185. }
  186. },
  187. onLoad(options) {
  188. if(options.inviteId){
  189. this.inviteId = options.inviteId;
  190. getApp().globalData.inviteId = options.inviteId;
  191. console.log('inviteId:',getApp().globalData.inviteId)
  192. }
  193. this.userLogin();
  194. this.getEquipmentHeight();
  195. },
  196. onShow() {
  197. //this.getNowTime();
  198. this.userHeadUrl = getApp().globalData.user_headUrl || '../../static/userDefault.png',
  199. getApp().globalData.isAuth ? this.isAuth = true : this.isAuth = false ;
  200. getApp().globalData.user_id ? this.getUserStorage(): this.title = 'RABOT' ;
  201. getApp().globalData.user_id ? this.getHistory() : this.title = 'RABOT' ;
  202. },
  203. methods: {
  204. userLogin(){
  205. uni.showLoading({})
  206. uni.login({
  207. success: (res) => {
  208. this.getCodeRabot(res)
  209. }
  210. });
  211. },
  212. // 获取用户信息
  213. getUserInfo(e) {
  214. console.log(e);
  215. if (e.detail.errMsg == "getUserInfo:ok") {
  216. this.iv = e.detail.iv;
  217. this.encryptedData = e.detail.encryptedData;
  218. this.loginUserInfo()
  219. } else {
  220. console.log("用户信息授权失败");
  221. this.isShowAuthBtn = true;
  222. }
  223. },
  224. loginUserInfo(){
  225. let that = this;
  226. uni.request({
  227. url:getApp().globalData.shareUrl, //需要设置为全局
  228. method: 'POST',
  229. header: {
  230. 'content-type': 'application/x-www-form-urlencoded'
  231. },
  232. data: {
  233. method: 'auth',
  234. timestamp: getApp().globalData.globalTimestamp, //Date.now()
  235. //uid:getApp().globalData.user_id,
  236. sign: md5('auth' + getApp().globalData.globalTimestamp),
  237. //nickname:getApp().globalData.user_name,
  238. //headimg:getApp().globalData.user_headUrl,
  239. iv:that.iv,
  240. session_key:that.session_key,
  241. encryptedData:that.encryptedData,
  242. invited:that.inviteId
  243. },
  244. success: res => {
  245. that.isAuth = true;
  246. getApp().globalData.user_id = res.data.msg.id;
  247. getApp().globalData.open_id = res.data.msg.openid;
  248. getApp().globalData.isAuth = that.isAuth;
  249. getApp().globalData.times = res.data.msg.times;
  250. getApp().globalData.total_times = res.data.msg.total_times;
  251. getApp().globalData.user_headUrl = res.data.msg.headimg;
  252. getApp().globalData.user_name = res.data.msg.name;
  253. that.userHeadUrl = res.data.msg.headimg || '../../static/userDefault.png';
  254. that.getUserStorage();
  255. that.getHistory();
  256. }
  257. });
  258. },
  259. getCodeRabot(res){
  260. let that = this;
  261. uni.request({
  262. url:getApp().globalData.shareUrl, //需要设置为全局
  263. method: 'POST',
  264. header: {
  265. 'content-type': 'application/x-www-form-urlencoded'
  266. },
  267. data: {
  268. method: 'login',
  269. timestamp: getApp().globalData.globalTimestamp, //Date.now()
  270. code: res.code,
  271. sign: md5('login' + getApp().globalData.globalTimestamp),
  272. },
  273. success: res => {
  274. var isAuth = res.data.msg.isauth === 1;
  275. that.session_key = res.data.msg.session_key;
  276. if(isAuth){
  277. this.isAuth = true;
  278. getApp().globalData.user_id = res.data.msg.id;
  279. getApp().globalData.open_id = res.data.msg.openid;
  280. getApp().globalData.isAuth = true;
  281. getApp().globalData.times = res.data.msg.times;
  282. getApp().globalData.total_times = res.data.msg.total_times;
  283. getApp().globalData.user_headUrl = res.data.msg.headimg;
  284. getApp().globalData.user_name = res.data.msg.name;
  285. that.userHeadUrl = res.data.msg.headimg || '../../static/userDefault.png';
  286. that.getUserStorage();
  287. that.getHistory();
  288. }else{
  289. getApp().globalData.session_key = res.data.msg.session_key;
  290. that.isAuth = isAuth;
  291. getApp().globalData.isAuth = isAuth;
  292. wx.hideLoading();
  293. }
  294. }
  295. });
  296. },
  297. getNowTime() {
  298. let time = new Date();
  299. let y = time.getFullYear();
  300. let m = time.getMonth() + 1;
  301. let d = time.getDate();
  302. let h = time.getHours();
  303. let i = time.getMinutes();
  304. i = i > 10 ? i : '0' + i;
  305. this.nowTime = y + "年" + m + "月" + d + "日" + " " + h + ":" + i
  306. },
  307. getUserStorage(){
  308. let that = this
  309. uni.getStorage({
  310. key: 'getTime',
  311. success: function (res) {
  312. let nowTime = Date.now();
  313. let lastTime = res.data;
  314. if(nowTime - lastTime >= 86400000){
  315. that.getEveryDayCounts()
  316. }else {
  317. return false
  318. }
  319. },
  320. fail:function () {
  321. that.getEveryDayCounts()
  322. }
  323. });
  324. },
  325. getEveryDayCounts(){
  326. let that = this;
  327. uni.request({
  328. url: getApp().globalData.shareUrl, //需要设置为全局
  329. method: 'POST',
  330. header: {
  331. 'content-type': 'application/x-www-form-urlencoded'
  332. },
  333. data: {
  334. method: 'add_freegive_times',
  335. timestamp: getApp().globalData.globalTimestamp, //Date.now()
  336. uid: getApp().globalData.user_id,
  337. sign: md5('add_freegive_times' + getApp().globalData.globalTimestamp),
  338. },
  339. success: res => {
  340. if(res.data.code === 200){
  341. that.everyDayCounts = res.data.msg.times;
  342. that.$refs.showCountsModal.open();
  343. uni.setStorage({
  344. key: 'getTime',
  345. data:Date.now(),
  346. success: function () {
  347. console.log('success');
  348. //that.$refs.showCountsModal.close()
  349. }
  350. });
  351. }
  352. else {
  353. // uni.showToast({
  354. // title:res.data.msg,
  355. // icon:'none',
  356. // duration:1500
  357. // })
  358. return false
  359. }
  360. }
  361. });
  362. },
  363. addEveryDayCounts(){
  364. console.log('已领取');
  365. this.$refs.showCountsModal.close()
  366. },
  367. getEquipmentHeight() {
  368. const height = uni.getSystemInfoSync().windowHeight;
  369. this.nowHeight = height + 'px';
  370. getApp().globalData.glbalHeight = this.nowHeight;
  371. this.style.pageHeight = height;
  372. this.style.contentViewHeight = height - uni.getSystemInfoSync().screenWidth / 750 * (100) -7; //像素 因为给出的是像素高度 然后我们用的是upx 所以换算一下
  373. },
  374. scrollToBottom() {
  375. let that = this;
  376. let query = uni.createSelectorQuery();
  377. query.selectAll('.m-item').boundingClientRect();
  378. query.select('#scrollview').boundingClientRect();
  379. query.exec((res) => {
  380. that.style.mitemHeight = 0;
  381. res[0].forEach((rect) => that.style.mitemHeight = that.style.mitemHeight + rect.height + 40) //获取所有内部子元素的高度
  382. // 因为vue的虚拟DOM 每次生成的新消息都是之前的,所以采用异步setTimeout 主要就是添加了这红字
  383. that.scrollTop = that.style.mitemHeight - that.style.contentViewHeight
  384. // setTimeout(() => {
  385. // if (that.style.mitemHeight > (that.style.contentViewHeight - 100)) { //判断子元素高度是否大于显示高度
  386. // that.scrollTop = that.style.mitemHeight - that.style.contentViewHeight //用子元素的高度减去显示的高度就获益获得序言滚动的高度
  387. // }
  388. // }, 100)
  389. })
  390. },
  391. getHistory(isShow) {
  392. // if(getApp.globalData.isAuth){this.isAuth = true}
  393. let that = this;
  394. uni.request({
  395. url: getApp().globalData.shareUrl, //需要设置为全局
  396. method: 'POST',
  397. header: {
  398. 'content-type': 'application/x-www-form-urlencoded'
  399. },
  400. data: {
  401. method: 'question_list',
  402. timestamp: getApp().globalData.globalTimestamp, //Date.now()
  403. uid: getApp().globalData.user_id,
  404. sign: md5('question_list' + getApp().globalData.globalTimestamp),
  405. page: page || 1,
  406. pageSize: 10,
  407. },
  408. success: res => {
  409. uni.hideLoading()
  410. that.isIos = getApp().globalData.isIos;
  411. if(isShow){
  412. res.data.msg[0].isRecharge = 1
  413. }
  414. if(page === 1){
  415. that.scrollRequestEnable = true;
  416. that.talkList = ((res.data.msg).reverse());
  417. setTimeout(()=>{
  418. that.scrollToBottom()
  419. },100)
  420. }else if (page > 1 && res.data.msg.length === that.pageSize) {
  421. that.scrollRequestEnable = true;
  422. that.talkList.unshift(...((res.data.msg).reverse()));
  423. }else if (page > 1 && (res.data.msg.length > 0) && (res.data.msg.length < that.pageSize)){
  424. that.scrollRequestEnable = true;
  425. that.talkList.unshift(...((res.data.msg).reverse()));
  426. }else if (page > 1 && res.data.msg.length == 0){
  427. that.scrollRequestEnable = false;
  428. }
  429. }
  430. });
  431. },
  432. goUserSelf() {
  433. this.$refs.popup.close()
  434. uni.navigateTo({
  435. url: '../selfInfo/selfInfo'
  436. })
  437. },
  438. goRecharge() {
  439. this.$refs.popup.close()
  440. uni.navigateTo({
  441. url: '../selfInfo/payList/payList'
  442. })
  443. },
  444. sendMsgRequest(msg) {
  445. if(getApp().globalData.user_id=='') return false;
  446. let that = this;
  447. uni.request({
  448. url: getApp().globalData.shareUrl, //需要设置为全局
  449. method: 'POST',
  450. header: {
  451. 'content-type': 'application/x-www-form-urlencoded'
  452. },
  453. data: {
  454. method: 'question',
  455. timestamp: getApp().globalData.globalTimestamp, //Date.now()
  456. uid: getApp().globalData.user_id,
  457. sign: md5('question' + getApp().globalData.globalTimestamp),
  458. content: msg
  459. },
  460. success: res => {
  461. if(res.data.code === 100){
  462. that.isShowRecharge = true;
  463. that.inputInfo = '';
  464. that.getHistory('show');
  465. }else {
  466. that.inputInfo = '';
  467. that.getHistory();
  468. that.isShowRecharge = false
  469. }
  470. }
  471. });
  472. },
  473. sendInputInfo() {
  474. // this.inputWidth = '80%';
  475. // this.isShowSend = false;
  476. // this.isShowSetCenter = true;
  477. if (!this.inputInfo) {
  478. uni.showToast({
  479. title: '请输入股票代码',
  480. icon: 'none'
  481. });
  482. } else {
  483. page = 1;
  484. this.sendMsgRequest(this.inputInfo)
  485. }
  486. },
  487. isInputing(){
  488. if (this.inputInfo) {
  489. this.inputWidth = '72%';
  490. this.isShowSend = true;
  491. this.isShowSetCenter = false;
  492. } else {
  493. this.inputWidth = '80%';
  494. this.isShowSend = false;
  495. this.isShowSetCenter = true;
  496. }
  497. },
  498. isNeedAuth(){
  499. if(!this.isAuth){
  500. setTimeout(()=>{
  501. uni.navigateTo({
  502. url: '../auth/index',
  503. success: res => {},
  504. fail: () => {},
  505. complete: () => {}
  506. });
  507. },500)
  508. }
  509. },
  510. // 滚动至底部触发的事件
  511. lower() {
  512. if (this.scrollRequestEnable) {
  513. // 允许滚动时,触底page加一,重新请求数据
  514. console.log(666)
  515. page++;
  516. this.getHistory();
  517. } else {
  518. // 不允许滚动时,只显示"到底了"提示
  519. // this.showBottem = true
  520. console.log('noData')
  521. }
  522. },
  523. getInputFocus(e){
  524. //this.isShowKeyBoard = e.detail.height
  525. },
  526. getInputBlur(){
  527. //this.isShowKeyBoard = 0
  528. },
  529. goSharePage(){
  530. uni.navigateTo({
  531. url: '../share/sharePage',
  532. success: res => {},
  533. fail: () => {},
  534. complete: () => {}
  535. });
  536. },
  537. tabVoice(){
  538. this.isVoiceType = !this.isVoiceType;
  539. },
  540. clearChat(){
  541. },
  542. goAuthPage(){
  543. uni.navigateTo({
  544. url: '../auth/index',
  545. success: res => {},
  546. fail: () => {},
  547. complete: () => {}
  548. });
  549. },
  550. openModal(){
  551. // 需要在 popup 组件,指定 ref 为 popup
  552. if(!this.isAuth){
  553. uni.navigateTo({
  554. url: '../auth/index',
  555. success: res => {},
  556. fail: () => {},
  557. complete: () => {}
  558. });
  559. }else {
  560. this.$refs.popup.open();
  561. }
  562. },
  563. cancelModal(){
  564. // 需要在 popup 组件,指定 ref 为 popup
  565. this.$refs.popup.close();
  566. },
  567. //情况聊天记录
  568. cleanChatRecord(){
  569. if(getApp().globalData.user_id=='') return false;
  570. let that = this;
  571. uni.request({
  572. url: getApp().globalData.shareUrl, //需要设置为全局
  573. method: 'POST',
  574. header: {
  575. 'content-type': 'application/x-www-form-urlencoded'
  576. },
  577. data: {
  578. method: 'clear_question',
  579. timestamp: getApp().globalData.globalTimestamp, //Date.now()
  580. uid: getApp().globalData.user_id,
  581. sign: md5('clear_question' + getApp().globalData.globalTimestamp),
  582. },
  583. success: res => {
  584. console.log(res)
  585. if(res.data.code === 200){
  586. uni.showToast({
  587. title: '清除成功',
  588. icon:'none',
  589. duration:1500
  590. });
  591. that.$refs.popup.close();
  592. page = 1;
  593. that.getHistory();
  594. }else{
  595. uni.showToast({
  596. title: res.data.msg,
  597. icon:'none',
  598. duration:1500
  599. });
  600. }
  601. }
  602. });
  603. },
  604. // 语音识别
  605. asrStart () {
  606. let that = this;
  607. this.$jiuaiDebounce.canDoFunction({
  608. key:"asrStart",//基于此值判断是否可以操作,如两个方法传入了同样的key,则会混淆,建议传入调用此事件的方法名,简单好梳理
  609. time:3000,//如果传入time字段,则为定时器后,自动解除锁定状态,单位(毫秒)
  610. success:()=>{//成功中调用应该操作的方法,被锁定状态不会执行此代码块内的方法
  611. that.$refs.weixinAsr.show();
  612. console.log(666)
  613. }
  614. })
  615. },
  616. asrResult (res) {
  617. //this.arsRes = res;
  618. res = res.substring(0,res.length-1)
  619. page = 1;
  620. this.sendMsgRequest(res)
  621. }
  622. },
  623. onShareAppMessage(){
  624. }
  625. }
  626. </script>
  627. <style>
  628. .content {
  629. text-align: center;
  630. }
  631. .chat-box {
  632. background: #f4f5f7;
  633. padding-top: 3%;
  634. /* padding-bottom: 100upx; */
  635. }
  636. .tips-box {
  637. background: #d5d5da;
  638. font-size: 28upx;
  639. color: #fff;
  640. border-radius: 30upx;
  641. width: 50%;
  642. margin: 0 auto;
  643. height: 50rpx;
  644. line-height: 50rpx;
  645. }
  646. .tips-title {
  647. width: 70%;
  648. margin-top: 5%;
  649. font-size: 30rpx;
  650. height: 70rpx;
  651. line-height: 70rpx;
  652. }
  653. .send-box {
  654. width: 100%;
  655. height: 90rpx;
  656. position: fixed;
  657. bottom: 0;
  658. background: #f4f0ed;
  659. display: flex;
  660. align-items: center;
  661. padding: 2upx;
  662. }
  663. .talk-box {
  664. display: flex;
  665. justify-content: flex-start;
  666. align-items: center;
  667. margin-top: 3%;
  668. }
  669. .talk-box-end {
  670. justify-content: flex-end;
  671. }
  672. .talk-head-box {
  673. width: 80rpx;
  674. height: 80rpx;
  675. border-radius: 30rpx;
  676. margin-left: 2%;
  677. margin-right: 2%;
  678. }
  679. .talk-head {
  680. width: 100%;
  681. height: 100%;
  682. border-radius: 50%;
  683. }
  684. .talk-content {
  685. padding: 2%;
  686. background: #fff;
  687. font-size: 28rpx;
  688. border-top-right-radius: 20rpx;
  689. border-bottom-left-radius: 20rpx;
  690. border-bottom-right-radius: 20rpx;
  691. text-align: left;
  692. max-width: 70%;
  693. }
  694. .talk-reply {
  695. padding: 2%;
  696. background: #9eea6a;
  697. font-size: 28rpx;
  698. border-top-left-radius: 20rpx;
  699. border-bottom-left-radius: 20rpx;
  700. border-bottom-right-radius: 20rpx;
  701. text-align: left;
  702. max-width: 70%;
  703. }
  704. .goRechargeText {
  705. color: #0a98d5;
  706. }
  707. .enter-box {
  708. height: 70rpx;
  709. background: #fff;
  710. border-radius: 1%;
  711. text-align: left;
  712. margin: 8px;
  713. margin-bottom: 10px;
  714. padding-left: 8px;
  715. }
  716. .send-box image {
  717. width: 60rpx;
  718. height: 60rpx;
  719. margin-right: 10upx;
  720. margin-left: 10upx;
  721. }
  722. .submit-message {
  723. width: 18%;
  724. margin-right: 20upx;
  725. height: 70rpx;
  726. font-size: 28rpx;
  727. line-height: 70rpx;
  728. color: #fff;
  729. background-color: #0a98d5 !important;
  730. }
  731. .logo {
  732. height: 200upx;
  733. width: 200upx;
  734. margin-top: 200upx;
  735. margin-left: auto;
  736. margin-right: auto;
  737. margin-bottom: 50upx;
  738. }
  739. .text-area {
  740. display: flex;
  741. justify-content: center;
  742. }
  743. .title {
  744. font-size: 36upx;
  745. color: #8f8f94;
  746. }
  747. .uniFab {
  748. width: 98px;
  749. height: 36px;
  750. background: rgba(231, 247, 236, 1);
  751. box-shadow: -6px 5px 74px 0px rgba(60, 188, 99, 0.08);
  752. border-radius: 100px 0px 0px 100px;
  753. right: 0upx;
  754. position: fixed;
  755. z-index: 9999;
  756. top: 50%;
  757. display: flex;
  758. justify-content: center;
  759. align-items: center;
  760. }
  761. .uniFab text {
  762. width: 64px;
  763. font-size: 16px;
  764. font-family: PingFangSC;
  765. font-weight: 600;
  766. color: rgba(60, 188, 99, 1);
  767. text-shadow: 0px 1px 2px rgba(12, 39, 20, 0.2);
  768. }
  769. .uni-share-content {
  770. display: flex;
  771. flex-wrap: wrap;
  772. padding: 15px;
  773. /* justify-content: center */
  774. }
  775. .uni-share-content-box {
  776. display: flex;
  777. flex-direction: column;
  778. align-items: center;
  779. width: 25%;
  780. box-sizing: border-box;
  781. }
  782. .uni-share-content-image {
  783. display: flex;
  784. justify-content: center;
  785. align-items: center;
  786. width: 60upx;
  787. height: 60upx;
  788. overflow: hidden;
  789. border-radius: 10upx;
  790. }
  791. .uni-share-content-image .image {
  792. width: 100%;
  793. height: 100%;
  794. }
  795. .uni-share-content-text {
  796. font-size: 26upx;
  797. color: #333;
  798. padding-top: 5px;
  799. padding-bottom: 10px;
  800. }
  801. .uni-share-btn {
  802. height: 90upx;
  803. line-height: 90upx;
  804. border-top: 1px #f5f5f5 solid;
  805. text-align: center;
  806. color: #666;
  807. font-size: 30rpx;
  808. }
  809. /* .placeHolder {
  810. padding:2px
  811. } */
  812. .auth {
  813. display: flex;
  814. flex-direction: row;
  815. font-size: 14px;
  816. justify-content: center;
  817. align-items: center;
  818. background-color: #eee;
  819. }
  820. .auth button {
  821. font-size: 14px;
  822. padding: 0px;
  823. margin: 0px;
  824. color: #007aff;
  825. background-color: #eee;
  826. }
  827. .auth button:after {
  828. border: 0px;
  829. }
  830. .voice-mode {
  831. width: 70%;
  832. height: 70rpx;
  833. background: #fff;
  834. border-radius: 1%;
  835. text-align: left;
  836. margin: 8px;
  837. margin-bottom: 10px;
  838. padding-left: 8px;
  839. text-align: center;
  840. line-height: 70upx;
  841. font-size: 30upx;
  842. }
  843. .icon {
  844. font-family: 'HMfont-home' !important;
  845. font-size: 56upx;
  846. font-style: normal;
  847. color: #333;
  848. }
  849. .hidden {
  850. display: none !important;
  851. }
  852. .record {
  853. width: 40vw;
  854. height: 40vw;
  855. position: fixed;
  856. top: 55%;
  857. left: 30%;
  858. background-color: rgba(0, 0, 0, 0.6);
  859. border-radius: 20upx;
  860. }
  861. .ing {
  862. width: 100%;
  863. height: 30vw;
  864. display: flex;
  865. justify-content: center;
  866. align-items: center;
  867. // 模拟录音音效动画
  868. }
  869. @keyframes volatility {
  870. 0% {
  871. background-position: 0% 130%;
  872. }
  873. 20% {
  874. background-position: 0% 150%;
  875. }
  876. 30% {
  877. background-position: 0% 155%;
  878. }
  879. 40% {
  880. background-position: 0% 150%;
  881. }
  882. 50% {
  883. background-position: 0% 145%;
  884. }
  885. 70% {
  886. background-position: 0% 150%;
  887. }
  888. 80% {
  889. background-position: 0% 155%;
  890. }
  891. 90% {
  892. background-position: 0% 140%;
  893. }
  894. 100% {
  895. background-position: 0% 135%;
  896. }
  897. }
  898. .cancel {
  899. width: 100%;
  900. height: 30vw;
  901. display: flex;
  902. justify-content: center;
  903. align-items: center;
  904. }
  905. .icon {
  906. background-image: linear-gradient(to bottom, #f09b37, #fff 50%);
  907. background-size: 100% 200%;
  908. animation: volatility 1.5s ease-in-out -1.5s infinite alternate;
  909. -webkit-background-clip: text;
  910. -webkit-text-fill-color: transparent;
  911. font-size: 150upx;
  912. color: #f09b37;
  913. }
  914. .tis {
  915. width: 100%;
  916. height: 10vw;
  917. display: flex;
  918. justify-content: center;
  919. font-size: 28upx;
  920. color: #fff;
  921. }
  922. .change {
  923. color: #f09b37;
  924. }
  925. .everyDay-box {
  926. background: #fff;
  927. padding: 20px;
  928. border-radius: 5%;
  929. }
  930. .everyDay-box image {
  931. width: 240rpx;
  932. height: 240rpx;
  933. }
  934. .everyDay-box view {
  935. font-size: 28rpx;
  936. }
  937. .everyDay-box button {
  938. font-size: 28rpx;
  939. margin-top: 5%;
  940. color: #fff;
  941. background: #00bfff;
  942. }
  943. </style>