takenotes.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580
  1. <template>
  2. <view>
  3. <view style="color: #fff;">
  4. <tn-nav-bar backgroundColor="#26B3A0" :bottomShadow="false">问答记录</tn-nav-bar>
  5. </view>
  6. <z-paging ref="paging" refresher-complete-delay="200" v-model="jobList" @query="queryList">
  7. <view slot="top" class="z_tabs" :style="{ marginTop: tobheight + 'px' }"></view>
  8. <view class="container">
  9. <view class="form">
  10. <block v-for="(item, index) in jobList" :key="index">
  11. <view class="panel">
  12. <view class="head">
  13. <view class="title">问:{{ item.question }}</view>
  14. </view>
  15. <u-read-more :toggle="true" showHeight="200" color="#26B3A0">
  16. <text class="content">{{ item.answer.replace(/^\s+|\s+$/g, '') }}</text>
  17. </u-read-more>
  18. <view class="bottom">
  19. {{appInfo.site_name?appInfo.site_name:'AI智能问答机器人'}}回答时间:{{ item.created_at }}
  20. </view>
  21. <view class="tn-flex justify-between">
  22. <view @click="copyText(item.answer)" hover-class="hoversubmit" class="onekey">一键复制
  23. </view>
  24. </view>
  25. <!-- <view class="circle" @click.stop="gallerydel(index)">
  26. <u-icon name="close-circle-fill" color="#e83a30" size="24"></u-icon>
  27. </view> -->
  28. </view>
  29. </block>
  30. </view>
  31. </view>
  32. </z-paging>
  33. <u-popup :show="showPoster" mode="bottom" :round="10" @close="close" @open="open">
  34. <view class="poster">
  35. <wike-painter isH5PathToBase64 :board="posterObj" @success="posterSuccess" ref="painter"></wike-painter>
  36. <view class="footer-btn">
  37. <view class="" @click="showPoster = false">退出</view>
  38. <view class="save" @click="toSave">保存/分享</view>
  39. </view>
  40. </view>
  41. </u-popup>
  42. <!-- <wike-loading-page :isLoading="isLoading"></wike-loading-page> -->
  43. </view>
  44. </template>
  45. <script>
  46. import {
  47. mapMutations,
  48. mapActions,
  49. mapState,
  50. mapGetters
  51. } from 'vuex';
  52. import {
  53. quesRecord
  54. } from '@/api/my/index.js'
  55. export default {
  56. data() {
  57. return {
  58. recordList: [],
  59. jobList: [],
  60. tobheight: 45,
  61. // platform: this.$platform.get(),
  62. isLoading: true,
  63. themeColor: '#007AFF',
  64. showPoster: false,
  65. posterObj: {},
  66. qrcode: '',
  67. spmplatform: 0,
  68. appInfo: {
  69. site_name: 'AI助手'
  70. }
  71. };
  72. },
  73. computed: {
  74. // ...mapGetters(['appInfo', 'userInfo', 'hasLogin'])
  75. },
  76. async onLoad() {
  77. const that = this;
  78. },
  79. methods: {
  80. async queryList(pageNo, pageSize) {
  81. //这里的pageNo和pageSize会自动计算好,直接传给服务器即可
  82. const params = {
  83. page: pageNo,
  84. per_page: pageSize
  85. };
  86. let res = await quesRecord(params)
  87. if (res.code == 0) {
  88. // this.jobList = res.data.data
  89. this.$refs.paging.complete(res.data.data);
  90. this.isLoading = false;
  91. }
  92. console.log('问答记录返回值', res, this.jobList);
  93. // this.$http('question.my', params).then(res => {
  94. // if (res.code == 0) {
  95. // uni.setNavigationBarTitle({
  96. // title: this.appInfo.site_name
  97. // });
  98. // }
  99. // });
  100. },
  101. // questionlist(){
  102. // this.$http('question.list').then(res=>{
  103. // if(res.code == 0){
  104. // }
  105. // })
  106. // },
  107. toSave() {
  108. uni.showLoading({
  109. title: '海报生成中'
  110. });
  111. this.$refs.painter.canvasToTempFilePathSync({
  112. // 在nvue里是jpeg
  113. fileType: 'jpg',
  114. quality: 1,
  115. success: res => {
  116. // this.path = res.tempFilePath;
  117. // this.$refs.posterImg.open();
  118. // this.show_poster = true;
  119. // console.log(res.tempFilePath);
  120. // 非H5 保存到相册
  121. // H5 提示用户长按图另存
  122. // #ifdef MP-WEIXIN
  123. // uni.saveImageToPhotosAlbum({
  124. // filePath: res.tempFilePath,
  125. // success: function() {
  126. // uni.showToast({
  127. // title: '保存成功'
  128. // });
  129. // that.showPoster = false;
  130. // }
  131. // });
  132. wx.showShareImageMenu({
  133. path: res.tempFilePath
  134. })
  135. this.showPoster = false;
  136. uni.hideLoading();
  137. // #endif
  138. // #ifdef H5
  139. this.showPoster = false;
  140. uni.hideLoading();
  141. uni.showModal({
  142. confirmColor: '#26B3A0',
  143. confirmText: '查看图片',
  144. title: '提示',
  145. content: '查看图片后长按图片即可保存或分享',
  146. success(src) {
  147. if (src.confirm) {
  148. uni.previewImage({
  149. urls: [res.tempFilePath]
  150. });
  151. } else if (src.cancel) {
  152. this.showPoster = true;
  153. }
  154. }
  155. });
  156. // #endif
  157. }
  158. });
  159. },
  160. commonqrcodePath() {
  161. let spm = this.userInfo.id + '.1.0.' + this.spmplatform + '.1';
  162. this.$http('common.qrcodePath', {
  163. spm: spm
  164. }).then(res => {
  165. if (res.code == 0) {
  166. this.qrcode = res.data;
  167. }
  168. });
  169. },
  170. copyText(text) {
  171. uni.setClipboardData({
  172. data: text,
  173. success: function() {
  174. // console.log('success');
  175. uni.showToast({
  176. title: '复制成功'
  177. });
  178. }
  179. });
  180. },
  181. gallerydel(e) {
  182. var that = this;
  183. uni.showModal({
  184. confirmText: '删除',
  185. content: '是否删除此问答记录',
  186. title: '提示',
  187. confirmColor: '#26B3A0',
  188. success(res) {
  189. // console.log(res);
  190. if (res.confirm) {
  191. that.$http('question.del', {
  192. id: that.jobList[e].id
  193. }).then(res => {
  194. if (res.code == 0) {
  195. uni.showToast({
  196. title: '删除成功'
  197. })
  198. // that.drawList = []
  199. that.$refs.paging.reload(true);
  200. } else {
  201. uni.showToast({
  202. title: '删除失败',
  203. icon: 'none'
  204. })
  205. }
  206. });
  207. }
  208. }
  209. })
  210. },
  211. onSubmit() {
  212. uni.navigateTo({
  213. url: '/pages/main/answer/index'
  214. });
  215. },
  216. createPoster(e) {
  217. let that = this;
  218. (this.posterObj = {
  219. width: '670rpx',
  220. background: '#fff',
  221. borderRadius: '16rpx',
  222. css: {
  223. // 根节点若无尺寸,自动获取父级节点
  224. width: '670rpx'
  225. },
  226. views: [{
  227. type: 'view',
  228. css: {
  229. marginTop: '20rpx',
  230. paddingLeft: '10rpx',
  231. display: 'flex'
  232. },
  233. views: [{
  234. type: 'image',
  235. src: this.userInfo.avatar ? this.userInfo.avatar :
  236. '/static/images/head.jpg',
  237. css: {
  238. marginTop: '10rpx',
  239. marginLeft: '10rpx',
  240. borderRadius: '16rpx',
  241. width: '80rpx',
  242. height: '80rpx',
  243. border: '2rpx solid #fff',
  244. objectFit: 'cover'
  245. }
  246. },
  247. {
  248. type: 'view',
  249. css: {
  250. marginTop: '10rpx',
  251. marginLeft: '20rpx'
  252. // display:'flex',
  253. // flexDirection:'column'
  254. },
  255. views: [{
  256. type: 'view',
  257. views: [{
  258. type: 'text',
  259. text: this.userInfo.nickname ? this.userInfo
  260. .nickname : '提问者',
  261. css: {
  262. marginTop: '10rpx',
  263. fontSize: '28rpx',
  264. fontWeight: 'bold',
  265. color: '#1A2033',
  266. lineHeight: '28rpx'
  267. }
  268. }]
  269. },
  270. {
  271. type: 'view',
  272. views: [{
  273. type: 'text',
  274. text: '我的提问',
  275. css: {
  276. marginTop: '15rpx',
  277. fontSize: '22rpx',
  278. // fontWeight: 'bold',
  279. color: '#999',
  280. lineHeight: '25rpx'
  281. }
  282. }]
  283. }
  284. ]
  285. }
  286. ]
  287. },
  288. {
  289. type: 'view',
  290. css: {
  291. marginTop: '20rpx',
  292. width: '610rpx',
  293. padding: '10rpx',
  294. background: '#d2f8d3',
  295. borderRadius: '16rpx',
  296. marginLeft: '20rpx',
  297. marginRight: '10rpx'
  298. },
  299. views: [{
  300. type: 'text',
  301. text: that.jobList[e].question,
  302. css: {
  303. fontSize: '28rpx',
  304. color: '#1A2033',
  305. lineHeight: '45rpx',
  306. lineClamp: 2,
  307. paddingLeft: '10rpx',
  308. paddingRight: '10rpx',
  309. width: '590rpx'
  310. // padding:'10rpx'
  311. }
  312. }]
  313. },
  314. {
  315. type: 'view',
  316. css: {
  317. marginTop: '20rpx',
  318. paddingLeft: '10rpx',
  319. display: 'flex'
  320. },
  321. views: [{
  322. type: 'image',
  323. src: '/static/images/open.png',
  324. css: {
  325. marginTop: '10rpx',
  326. marginLeft: '10rpx',
  327. borderRadius: '16rpx',
  328. width: '80rpx',
  329. height: '80rpx',
  330. border: '2rpx solid #fff',
  331. objectFit: 'cover'
  332. }
  333. },
  334. {
  335. type: 'view',
  336. css: {
  337. marginTop: '10rpx',
  338. marginLeft: '20rpx'
  339. // display:'flex',
  340. // flexDirection:'column'
  341. },
  342. views: [{
  343. type: 'view',
  344. views: [{
  345. type: 'text',
  346. text: this.appInfo.site_name ? this.appInfo
  347. .site_name : 'AI智能问答机器人',
  348. css: {
  349. marginTop: '10rpx',
  350. fontSize: '28rpx',
  351. fontWeight: 'bold',
  352. color: '#1A2033',
  353. lineHeight: '28rpx'
  354. }
  355. }]
  356. },
  357. {
  358. type: 'view',
  359. views: [{
  360. type: 'text',
  361. text: '回答结果',
  362. css: {
  363. marginTop: '15rpx',
  364. fontSize: '22rpx',
  365. // fontWeight: 'bold',
  366. color: '#999',
  367. lineHeight: '25rpx'
  368. }
  369. }]
  370. }
  371. ]
  372. }
  373. ]
  374. },
  375. {
  376. type: 'view',
  377. css: {
  378. marginTop: '20rpx',
  379. width: '610rpx',
  380. padding: '10rpx',
  381. background: '#f5f6f8',
  382. borderRadius: '16rpx',
  383. marginLeft: '20rpx',
  384. marginRight: '10rpx'
  385. },
  386. views: [{
  387. type: 'text',
  388. text: uni.$u.trim(that.jobList[e].answer),
  389. css: {
  390. fontSize: '28rpx',
  391. color: '#1A2033',
  392. lineHeight: '45rpx',
  393. lineClamp: 11,
  394. width: '590rpx',
  395. // paddingLeft: '10rpx',
  396. // paddingTop: '10rpx',
  397. padding: '10rpx'
  398. }
  399. }]
  400. },
  401. {
  402. type: 'view',
  403. css: {
  404. marginTop: '20rpx',
  405. width: '100%',
  406. textAlign: 'center'
  407. },
  408. // #ifdef H5
  409. views: [{
  410. type: 'qrcode',
  411. text: this.qrcode,
  412. css: {
  413. width: '200rpx',
  414. height: '200rpx'
  415. }
  416. }],
  417. // #endif
  418. // #ifdef MP-WEIXIN
  419. views: [{
  420. type: 'image',
  421. src: this.qrcode,
  422. css: {
  423. width: '200rpx',
  424. height: '200rpx'
  425. }
  426. }]
  427. // #endif
  428. },
  429. {
  430. type: 'text',
  431. text: '———— ' + '长按识别 | 欢迎使用' + ' ————',
  432. css: {
  433. marginTop: '20rpx',
  434. width: '100%',
  435. textAlign: 'center',
  436. fontSize: '24rpx',
  437. color: '#989FB3',
  438. lineHeight: '33rpx'
  439. }
  440. }
  441. ]
  442. }),
  443. (this.showPoster = true);
  444. }
  445. }
  446. };
  447. </script>
  448. <style lang="scss">
  449. page {
  450. background: #f6f7fb;
  451. }
  452. .form {
  453. width: 90%;
  454. margin: 0 auto;
  455. z-index: 999;
  456. .header {
  457. margin-bottom: 30rpx;
  458. .title {
  459. text-align: center;
  460. color: #fff;
  461. margin: 30rpx 0rpx;
  462. }
  463. }
  464. .panel {
  465. padding: 30rpx;
  466. background-color: #fff;
  467. border-radius: 30rpx;
  468. margin: 30rpx 0;
  469. position: relative;
  470. // box-shadow: 0rpx 10rpx 10rpx #eee;
  471. // margin-bottom: 15rpx;
  472. .bottom {
  473. font-size: 24rpx;
  474. }
  475. .head {
  476. border-bottom: 1rpx solid #eee;
  477. padding-bottom: 30rpx;
  478. margin-bottom: 30rpx;
  479. .title {
  480. font-weight: bolder;
  481. font-size: 35rpx;
  482. }
  483. }
  484. .content {
  485. // margin: 30rpx 0rpx;
  486. }
  487. .bottom {
  488. background-color: #f0faf8;
  489. color: #26b3a0;
  490. padding: 15rpx;
  491. border-radius: 10rpx;
  492. margin: 30rpx 0;
  493. }
  494. .onekey {
  495. background-color: #26b3a0;
  496. color: #fff;
  497. padding: 15rpx;
  498. // font-weight: bold;
  499. border-radius: 10rpx;
  500. text-align: center;
  501. font-size: 24rpx;
  502. width: 48%;
  503. }
  504. .hoversubmit {
  505. background: #f7f7f7;
  506. color: #acacb3;
  507. }
  508. }
  509. }
  510. .bg {
  511. position: fixed;
  512. top: 0rpx;
  513. left: 0rpx;
  514. width: 100%;
  515. background-color: #26b3a0;
  516. min-height: 200rpx;
  517. border-radius: 0rpx 0rpx 140rpx 140rpx;
  518. z-index: -1;
  519. }
  520. .poster {
  521. padding: 24rpx 40rpx;
  522. .footer-btn {
  523. margin-top: 24rpx;
  524. display: flex;
  525. align-items: center;
  526. justify-content: space-between;
  527. view {
  528. width: 319rpx;
  529. height: 66rpx;
  530. border-radius: 40rpx;
  531. border: 1px solid #4070ff;
  532. font-size: 26rpx;
  533. font-family: PingFangSC-Regular, PingFang SC;
  534. font-weight: 400;
  535. color: #4070ff;
  536. line-height: 66rpx;
  537. text-align: center;
  538. }
  539. .save {
  540. background: #4070ff;
  541. color: #ffffff;
  542. }
  543. }
  544. }
  545. .circle {
  546. position: absolute;
  547. right: -12rpx;
  548. top: -12rpx;
  549. background: #fff;
  550. border-radius: 50%;
  551. }
  552. </style>