index.vue 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974
  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-icon.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.isAuth = false ;
  199. getApp().globalData.isAuth ? this.getHistory() : this.isAuth = false ;
  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. }
  357. }
  358. });
  359. },
  360. addEveryDayCounts(){
  361. console.log('已领取');
  362. this.$refs.showCountsModal.close()
  363. },
  364. getEquipmentHeight() {
  365. const height = uni.getSystemInfoSync().windowHeight;
  366. this.nowHeight = height + 'px';
  367. getApp().globalData.glbalHeight = this.nowHeight;
  368. this.style.pageHeight = height;
  369. this.style.contentViewHeight = height - uni.getSystemInfoSync().screenWidth / 750 * (100) -7; //像素 因为给出的是像素高度 然后我们用的是upx 所以换算一下
  370. },
  371. scrollToBottom() {
  372. let that = this;
  373. let query = uni.createSelectorQuery();
  374. query.selectAll('.m-item').boundingClientRect();
  375. query.select('#scrollview').boundingClientRect();
  376. query.exec((res) => {
  377. that.style.mitemHeight = 0;
  378. res[0].forEach((rect) => that.style.mitemHeight = that.style.mitemHeight + rect.height + 40) //获取所有内部子元素的高度
  379. // 因为vue的虚拟DOM 每次生成的新消息都是之前的,所以采用异步setTimeout 主要就是添加了这红字
  380. that.scrollTop = that.style.mitemHeight - that.style.contentViewHeight
  381. // setTimeout(() => {
  382. // if (that.style.mitemHeight > (that.style.contentViewHeight - 100)) { //判断子元素高度是否大于显示高度
  383. // that.scrollTop = that.style.mitemHeight - that.style.contentViewHeight //用子元素的高度减去显示的高度就获益获得序言滚动的高度
  384. // }
  385. // }, 100)
  386. })
  387. },
  388. getHistory(isShow) {
  389. // if(getApp.globalData.isAuth){this.isAuth = true}
  390. let that = this;
  391. uni.request({
  392. url: getApp().globalData.shareUrl, //需要设置为全局
  393. method: 'POST',
  394. header: {
  395. 'content-type': 'application/x-www-form-urlencoded'
  396. },
  397. data: {
  398. method: 'question_list',
  399. timestamp: getApp().globalData.globalTimestamp, //Date.now()
  400. uid: getApp().globalData.user_id,
  401. sign: md5('question_list' + getApp().globalData.globalTimestamp),
  402. page: page || 1,
  403. pageSize: 10,
  404. },
  405. success: res => {
  406. uni.hideLoading()
  407. that.isIos = getApp().globalData.isIos;
  408. if(isShow){
  409. res.data.msg[0].isRecharge = 1
  410. }
  411. if(page === 1){
  412. that.scrollRequestEnable = true;
  413. that.talkList = ((res.data.msg).reverse());
  414. setTimeout(()=>{
  415. that.scrollToBottom()
  416. },100)
  417. }else if (page > 1 && res.data.msg.length === that.pageSize) {
  418. that.scrollRequestEnable = true;
  419. that.talkList.unshift(...((res.data.msg).reverse()));
  420. }else if (page > 1 && (res.data.msg.length > 0) && (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){
  424. that.scrollRequestEnable = false;
  425. }
  426. }
  427. });
  428. },
  429. goUserSelf() {
  430. this.$refs.popup.close()
  431. uni.navigateTo({
  432. url: '../selfInfo/selfInfo'
  433. })
  434. },
  435. goRecharge() {
  436. this.$refs.popup.close()
  437. uni.navigateTo({
  438. url: '../selfInfo/payList/payList'
  439. })
  440. },
  441. sendMsgRequest(msg) {
  442. if(getApp().globalData.user_id=='') return false;
  443. let that = this;
  444. uni.request({
  445. url: getApp().globalData.shareUrl, //需要设置为全局
  446. method: 'POST',
  447. header: {
  448. 'content-type': 'application/x-www-form-urlencoded'
  449. },
  450. data: {
  451. method: 'question',
  452. timestamp: getApp().globalData.globalTimestamp, //Date.now()
  453. uid: getApp().globalData.user_id,
  454. sign: md5('question' + getApp().globalData.globalTimestamp),
  455. content: msg
  456. },
  457. success: res => {
  458. if(res.data.code === 100){
  459. that.isShowRecharge = true;
  460. that.inputInfo = '';
  461. that.getHistory('show');
  462. }else {
  463. that.inputInfo = '';
  464. that.getHistory();
  465. that.isShowRecharge = false
  466. }
  467. }
  468. });
  469. },
  470. sendInputInfo() {
  471. // this.inputWidth = '80%';
  472. // this.isShowSend = false;
  473. // this.isShowSetCenter = true;
  474. if (!this.inputInfo) {
  475. uni.showToast({
  476. title: '请输入股票代码',
  477. icon: 'none'
  478. });
  479. } else {
  480. page = 1;
  481. this.sendMsgRequest(this.inputInfo)
  482. }
  483. },
  484. isInputing(){
  485. if (this.inputInfo) {
  486. this.inputWidth = '72%';
  487. this.isShowSend = true;
  488. this.isShowSetCenter = false;
  489. } else {
  490. this.inputWidth = '80%';
  491. this.isShowSend = false;
  492. this.isShowSetCenter = true;
  493. }
  494. },
  495. isNeedAuth(){
  496. if(!this.isAuth){
  497. setTimeout(()=>{
  498. uni.navigateTo({
  499. url: '../auth/index',
  500. success: res => {},
  501. fail: () => {},
  502. complete: () => {}
  503. });
  504. },500)
  505. }
  506. },
  507. // 滚动至底部触发的事件
  508. lower() {
  509. if (this.scrollRequestEnable) {
  510. // 允许滚动时,触底page加一,重新请求数据
  511. console.log(666)
  512. page++;
  513. this.getHistory();
  514. } else {
  515. // 不允许滚动时,只显示"到底了"提示
  516. // this.showBottem = true
  517. console.log('noData')
  518. }
  519. },
  520. getInputFocus(e){
  521. //this.isShowKeyBoard = e.detail.height
  522. },
  523. getInputBlur(){
  524. //this.isShowKeyBoard = 0
  525. },
  526. goSharePage(){
  527. uni.navigateTo({
  528. url: '../share/sharePage',
  529. success: res => {},
  530. fail: () => {},
  531. complete: () => {}
  532. });
  533. },
  534. tabVoice(){
  535. this.isVoiceType = !this.isVoiceType;
  536. },
  537. clearChat(){
  538. },
  539. goAuthPage(){
  540. uni.navigateTo({
  541. url: '../auth/index',
  542. success: res => {},
  543. fail: () => {},
  544. complete: () => {}
  545. });
  546. },
  547. openModal(){
  548. // 需要在 popup 组件,指定 ref 为 popup
  549. if(!this.isAuth){
  550. uni.navigateTo({
  551. url: '../auth/index',
  552. success: res => {},
  553. fail: () => {},
  554. complete: () => {}
  555. });
  556. }else {
  557. this.$refs.popup.open();
  558. }
  559. },
  560. cancelModal(){
  561. // 需要在 popup 组件,指定 ref 为 popup
  562. this.$refs.popup.close();
  563. },
  564. //情况聊天记录
  565. cleanChatRecord(){
  566. if(getApp().globalData.user_id=='') return false;
  567. let that = this;
  568. uni.request({
  569. url: getApp().globalData.shareUrl, //需要设置为全局
  570. method: 'POST',
  571. header: {
  572. 'content-type': 'application/x-www-form-urlencoded'
  573. },
  574. data: {
  575. method: 'clear_question',
  576. timestamp: getApp().globalData.globalTimestamp, //Date.now()
  577. uid: getApp().globalData.user_id,
  578. sign: md5('clear_question' + getApp().globalData.globalTimestamp),
  579. },
  580. success: res => {
  581. console.log(res)
  582. if(res.data.code === 200){
  583. uni.showToast({
  584. title: '清除成功',
  585. icon:'none',
  586. duration:1500
  587. });
  588. that.$refs.popup.close();
  589. page = 1;
  590. that.getHistory();
  591. }else{
  592. uni.showToast({
  593. title: res.data.msg,
  594. icon:'none',
  595. duration:1500
  596. });
  597. }
  598. }
  599. });
  600. },
  601. // 语音识别
  602. asrStart () {
  603. this.$refs.weixinAsr.show();
  604. },
  605. asrResult (res) {
  606. //this.arsRes = res;
  607. res = res.substring(0,res.length-1)
  608. page = 1;
  609. this.sendMsgRequest(res)
  610. }
  611. },
  612. onShareAppMessage(){
  613. }
  614. }
  615. </script>
  616. <style>
  617. .content {
  618. text-align: center;
  619. }
  620. .chat-box {
  621. background: #f4f5f7;
  622. padding-top: 3%;
  623. /* padding-bottom: 100upx; */
  624. }
  625. .tips-box {
  626. background: #d5d5da;
  627. font-size: 28upx;
  628. color: #fff;
  629. border-radius: 30upx;
  630. width: 50%;
  631. margin: 0 auto;
  632. height: 50rpx;
  633. line-height: 50rpx;
  634. }
  635. .tips-title {
  636. width: 70%;
  637. margin-top: 5%;
  638. font-size: 30rpx;
  639. height: 70rpx;
  640. line-height: 70rpx;
  641. }
  642. .send-box {
  643. width: 100%;
  644. height: 90rpx;
  645. position: fixed;
  646. bottom: 0;
  647. background: #f4f0ed;
  648. display: flex;
  649. align-items: center;
  650. padding: 2upx;
  651. }
  652. .talk-box {
  653. display: flex;
  654. justify-content: flex-start;
  655. align-items: center;
  656. margin-top: 3%;
  657. }
  658. .talk-box-end {
  659. justify-content: flex-end;
  660. }
  661. .talk-head-box {
  662. width: 80rpx;
  663. height: 80rpx;
  664. border-radius: 30rpx;
  665. margin-left: 2%;
  666. margin-right: 2%;
  667. }
  668. .talk-head {
  669. width: 100%;
  670. height: 100%;
  671. border-radius: 50%;
  672. }
  673. .talk-content {
  674. padding: 2%;
  675. background: #fff;
  676. font-size: 28rpx;
  677. border-top-right-radius: 20rpx;
  678. border-bottom-left-radius: 20rpx;
  679. border-bottom-right-radius: 20rpx;
  680. text-align: left;
  681. max-width: 70%;
  682. }
  683. .talk-reply {
  684. padding: 2%;
  685. background: #9eea6a;
  686. font-size: 28rpx;
  687. border-top-left-radius: 20rpx;
  688. border-bottom-left-radius: 20rpx;
  689. border-bottom-right-radius: 20rpx;
  690. text-align: left;
  691. max-width: 70%;
  692. }
  693. .goRechargeText {
  694. color: #0a98d5;
  695. }
  696. .enter-box {
  697. height: 70rpx;
  698. background: #fff;
  699. border-radius: 1%;
  700. text-align: left;
  701. margin: 8px;
  702. margin-bottom: 10px;
  703. padding-left: 8px;
  704. }
  705. .send-box image {
  706. width: 60rpx;
  707. height: 60rpx;
  708. margin-right: 10upx;
  709. margin-left: 10upx;
  710. }
  711. .submit-message {
  712. width: 18%;
  713. margin-right: 20upx;
  714. height: 70rpx;
  715. font-size: 28rpx;
  716. line-height: 70rpx;
  717. color: #fff;
  718. background-color: #0a98d5 !important;
  719. }
  720. .logo {
  721. height: 200upx;
  722. width: 200upx;
  723. margin-top: 200upx;
  724. margin-left: auto;
  725. margin-right: auto;
  726. margin-bottom: 50upx;
  727. }
  728. .text-area {
  729. display: flex;
  730. justify-content: center;
  731. }
  732. .title {
  733. font-size: 36upx;
  734. color: #8f8f94;
  735. }
  736. .uniFab {
  737. width: 98px;
  738. height: 36px;
  739. background: rgba(231, 247, 236, 1);
  740. box-shadow: -6px 5px 74px 0px rgba(60, 188, 99, 0.08);
  741. border-radius: 100px 0px 0px 100px;
  742. right: 0upx;
  743. position: fixed;
  744. z-index: 9999;
  745. top: 50%;
  746. display: flex;
  747. justify-content: center;
  748. align-items: center;
  749. }
  750. .uniFab text {
  751. width: 64px;
  752. font-size: 16px;
  753. font-family: PingFangSC;
  754. font-weight: 600;
  755. color: rgba(60, 188, 99, 1);
  756. text-shadow: 0px 1px 2px rgba(12, 39, 20, 0.2);
  757. }
  758. .uni-share-content {
  759. display: flex;
  760. flex-wrap: wrap;
  761. padding: 15px;
  762. /* justify-content: center */
  763. }
  764. .uni-share-content-box {
  765. display: flex;
  766. flex-direction: column;
  767. align-items: center;
  768. width: 25%;
  769. box-sizing: border-box;
  770. }
  771. .uni-share-content-image {
  772. display: flex;
  773. justify-content: center;
  774. align-items: center;
  775. width: 60upx;
  776. height: 60upx;
  777. overflow: hidden;
  778. border-radius: 10upx;
  779. }
  780. .uni-share-content-image .image {
  781. width: 100%;
  782. height: 100%;
  783. }
  784. .uni-share-content-text {
  785. font-size: 26upx;
  786. color: #333;
  787. padding-top: 5px;
  788. padding-bottom: 10px;
  789. }
  790. .uni-share-btn {
  791. height: 90upx;
  792. line-height: 90upx;
  793. border-top: 1px #f5f5f5 solid;
  794. text-align: center;
  795. color: #666;
  796. font-size: 30rpx;
  797. }
  798. /* .placeHolder {
  799. padding:2px
  800. } */
  801. .auth {
  802. display: flex;
  803. flex-direction: row;
  804. font-size: 14px;
  805. justify-content: center;
  806. align-items: center;
  807. background-color: #eee;
  808. }
  809. .auth button {
  810. font-size: 14px;
  811. padding: 0px;
  812. margin: 0px;
  813. color: #007aff;
  814. background-color: #eee;
  815. }
  816. .auth button:after {
  817. border: 0px;
  818. }
  819. .voice-mode {
  820. width: 70%;
  821. height: 70rpx;
  822. background: #fff;
  823. border-radius: 1%;
  824. text-align: left;
  825. margin: 8px;
  826. margin-bottom: 10px;
  827. padding-left: 8px;
  828. text-align: center;
  829. line-height: 70upx;
  830. font-size: 30upx;
  831. }
  832. .icon {
  833. font-family: 'HMfont-home' !important;
  834. font-size: 56upx;
  835. font-style: normal;
  836. color: #333;
  837. }
  838. .hidden {
  839. display: none !important;
  840. }
  841. .record {
  842. width: 40vw;
  843. height: 40vw;
  844. position: fixed;
  845. top: 55%;
  846. left: 30%;
  847. background-color: rgba(0, 0, 0, 0.6);
  848. border-radius: 20upx;
  849. }
  850. .ing {
  851. width: 100%;
  852. height: 30vw;
  853. display: flex;
  854. justify-content: center;
  855. align-items: center;
  856. // 模拟录音音效动画
  857. }
  858. @keyframes volatility {
  859. 0% {
  860. background-position: 0% 130%;
  861. }
  862. 20% {
  863. background-position: 0% 150%;
  864. }
  865. 30% {
  866. background-position: 0% 155%;
  867. }
  868. 40% {
  869. background-position: 0% 150%;
  870. }
  871. 50% {
  872. background-position: 0% 145%;
  873. }
  874. 70% {
  875. background-position: 0% 150%;
  876. }
  877. 80% {
  878. background-position: 0% 155%;
  879. }
  880. 90% {
  881. background-position: 0% 140%;
  882. }
  883. 100% {
  884. background-position: 0% 135%;
  885. }
  886. }
  887. .cancel {
  888. width: 100%;
  889. height: 30vw;
  890. display: flex;
  891. justify-content: center;
  892. align-items: center;
  893. }
  894. .icon {
  895. background-image: linear-gradient(to bottom, #f09b37, #fff 50%);
  896. background-size: 100% 200%;
  897. animation: volatility 1.5s ease-in-out -1.5s infinite alternate;
  898. -webkit-background-clip: text;
  899. -webkit-text-fill-color: transparent;
  900. font-size: 150upx;
  901. color: #f09b37;
  902. }
  903. .tis {
  904. width: 100%;
  905. height: 10vw;
  906. display: flex;
  907. justify-content: center;
  908. font-size: 28upx;
  909. color: #fff;
  910. }
  911. .change {
  912. color: #f09b37;
  913. }
  914. .everyDay-box {
  915. background: #fff;
  916. padding: 20px;
  917. border-radius: 5%;
  918. }
  919. .everyDay-box image {
  920. width: 240rpx;
  921. height: 240rpx;
  922. }
  923. .everyDay-box view {
  924. font-size: 28rpx;
  925. }
  926. .everyDay-box button {
  927. font-size: 28rpx;
  928. margin-top: 5%;
  929. color: #fff;
  930. background: #00bfff;
  931. }
  932. </style>