index.vue 25 KB

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