index.vue 25 KB

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