dialog.vue 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  1. <template>
  2. <view class="tabPage" :style="{'min-height':h+'px', 'padding-top':mt+'px'}">
  3. <u-navbar title="创衡正念企业教练" bgColor="#FFFFFF" :titleStyle="{'font-size':'32rpx','font-weight':'bold'}">
  4. <view class="u-nav-slot" slot="left" style="display: flex;background-color: transparent;">
  5. <image src="@/static/history_dialog.png" style="width: 42rpx;height: 42rpx;" @tap="reviewHistory"></image>
  6. <image src="@/static/new_dialog.png" style="width: 42rpx;height: 42rpx;margin-left: 40rpx;" @tap="startNewDialog"></image>
  7. </view>
  8. </u-navbar>
  9. <div class="dialogs container" ref="myContainer">
  10. <div class="d_answer init">
  11. <div class="da_top adfac">
  12. <image src="@/static/logo.png"></image>
  13. <text>创衡正念企业教练</text>
  14. </div>
  15. <div class="da_content">
  16. Hi,我是企业教练,很高兴遇见你!我随时可以回答您的问题!
  17. </div>
  18. </div>
  19. <div v-for="(item,index) in dialogList" :key="index">
  20. <div class="d_question">
  21. <div class="dq_text">{{ item.question }}</div>
  22. </div>
  23. <div class="d_answer">
  24. <div class="da_top adfac">
  25. <image src="@/static/logo.png"></image>
  26. <text>创衡正念企业教练</text>
  27. </div>
  28. <div class="da_content">
  29. <u-parse :content="item.answer"></u-parse>
  30. <div class="dc_btns adfacjb" v-if="item.answer">
  31. <div class="db_l">
  32. <image :src="item.copy?require('@/static/copy_active.png'):require('@/static/copy.png')" @tap="toCopy(item,index)"></image>
  33. <image :src="item.upvote?require('@/static/upvote_active.png'):require('@/static/upvote.png')" @tap="toUpvote(item,index)"></image>
  34. <image :src="item.comment?require('@/static/comment_active.png'):require('@/static/comment.png')" @tap="toComment(item,index)"></image>
  35. </div>
  36. <div class="db_r">
  37. <image :src="item.share?require('@/static/share_active.png'):require('@/static/share.png')" @tap="toShare(item,index)"></image>
  38. </div>
  39. </div>
  40. </div>
  41. </div>
  42. </div>
  43. </div>
  44. <div class="ask adfacjb">
  45. <div class="a_l">
  46. <input type="text" v-model="question" placeholder="请输入您的问题" @confirm="sendQuestion">
  47. </div>
  48. <image class="a_r" src="@/static/send.png" @tap="sendQuestion"></image>
  49. </div>
  50. <u-modal :show="commentShow" title="评论" @confirm="commentConfirm" @cancel="commentCancel" @close="commentCancel" :showCancelButton="true">
  51. <u-textarea v-model="content" placeholder="对于我们的回答您是否不满意,您有更好的答案建议吗?"></u-textarea>
  52. </u-modal>
  53. <u-popup :show="historyShow" mode="left" @close="historyClose">
  54. <view class="history" :style="{'min-height':h+'px', 'padding-top':mt+'px'}">
  55. <u-navbar title="历史回答" bgColor="#FFFFFF" :titleStyle="{'font-size':'32rpx','font-weight':'bold'}" style="width: 672rpx;">
  56. <view class="u-nav-slot" slot="left" style="display: flex;background-color: transparent;">
  57. <image src="@/static/arrow_left_hei.png" style="width: 40rpx;height: 40rpx;" @tap="historyClose"></image>
  58. </view>
  59. </u-navbar>
  60. <div class="h_list">
  61. <div class="hl_item" v-for="(item,index) in historyList" :key="index">
  62. <div class="hi_date">{{item.date}}</div>
  63. <div class="hl_pre" v-for="(pre,idx) in item.list" :key="idx">
  64. {{pre.name}}
  65. </div>
  66. </div>
  67. </div>
  68. </view>
  69. </u-popup>
  70. <Tabbar :tabbarIndex="0"></Tabbar>
  71. </view>
  72. </template>
  73. <script>
  74. var timer = null;
  75. import Tabbar from '@/components/CusTabbar/index.vue'
  76. export default {
  77. components:{ Tabbar },
  78. data(){
  79. return {
  80. question:'',
  81. dialogList:[],
  82. windex:0,
  83. commentShow:false,
  84. content:'',
  85. cindex:'',
  86. historyShow:false,
  87. historyList:[
  88. {
  89. date:'今天',
  90. list:[
  91. {name:'教练的标准是什么'},
  92. {name:'教练的标准是什么?'},
  93. ]
  94. },
  95. {
  96. date:'2025-05-12',
  97. list:[
  98. {name:'小众水果网名创意分享'},
  99. {name:'教练的标准是什么?'},
  100. ]
  101. },
  102. ]
  103. }
  104. },
  105. methods:{
  106. reviewHistory(){
  107. this.historyShow = true;
  108. },
  109. startNewDialog(){
  110. clearInterval(timer)
  111. this.dialogList = [];
  112. this.question = '';
  113. },
  114. historyClose(){
  115. this.historyShow = false;
  116. },
  117. sendQuestion(){
  118. if(!this.question) return this.$showToast('请输入问题');
  119. let answer = `<div style="font-size: 30rpx;color: #252525;line-height: 54rpx;">
  120. 你好!请问你是想了解教练的相关信息,还是需要运动、健身或其他方面的指导呢?
  121. 无论是健身计划、技巧提升,还是职业教练的选择,我都可以为你提供建议。请告诉我你的具体需求,我会尽力帮助你!
  122. <br><br>
  123. 例如:
  124. <br><br>
  125. <b>·健身教练:</b>想要制定增肌/减脂计划?<br>
  126. <b>运动技巧:</b>想提升某项运动(如游泳、跑步)的水平?<br>
  127. <b>职业教练:</b>如何考取教练资格证或选择靠谱的教练?<br>
  128. 期待你的详细需求!
  129. </div>`;
  130. let qa = {
  131. question:JSON.parse(JSON.stringify(this.question)),
  132. answer:'',
  133. copy:false,
  134. upvote:false,
  135. comment:'',
  136. share:false,
  137. }
  138. this.dialogList = [...this.dialogList,...[qa]];
  139. this.question = '';
  140. timer = setInterval(()=>{
  141. if(this.windex<answer.length){
  142. this.windex+=1;
  143. this.$set(this.dialogList[this.dialogList.length-1],'answer',answer.substring(0,this.windex));
  144. }else{
  145. this.windex = 0;
  146. clearInterval(timer)
  147. }
  148. },50)
  149. },
  150. toCopy(item,index){
  151. this.$set(this.dialogList[index],'copy',!this.dialogList[index].copy);
  152. },
  153. toUpvote(item,index){
  154. this.$set(this.dialogList[index],'upvote',!this.dialogList[index].upvote);
  155. },
  156. toComment(item,index){
  157. this.cindex = index;
  158. this.commentShow = true;
  159. },
  160. toShare(item,index){
  161. this.$set(this.dialogList[index],'share',!this.dialogList[index].share);
  162. },
  163. commentConfirm(){
  164. this.$set(this.dialogList[this.cindex],'comment',this.content);
  165. this.commentShow = false;
  166. },
  167. commentCancel(){
  168. this.content = '';
  169. this.commentShow = false;
  170. },
  171. }
  172. }
  173. </script>
  174. <style>
  175. .history .u-navbar .u-status-bar,.history .u-navbar .u-navbar__content{
  176. width: 672rpx !important;
  177. }
  178. </style>
  179. <style scoped lang="scss">
  180. .tabPage{
  181. position: relative;
  182. background: #F7F2F6;
  183. display: flex;
  184. flex-direction: column;
  185. .history{
  186. width: 672rpx;
  187. height: 100vh;
  188. background: #FFFFFF;
  189. box-sizing: border-box;
  190. display: flex;
  191. flex-direction: column;
  192. .h_list{
  193. flex: 1;
  194. width: 100%;
  195. padding: 0 64rpx;
  196. box-sizing: border-box;
  197. margin-top: 20rpx;
  198. overflow-y: auto;
  199. .hl_item{
  200. margin-top: 64rpx;
  201. &:first-child{
  202. margin-top: 0;
  203. }
  204. .hi_date{
  205. font-family: PingFangSC, PingFang SC;
  206. font-weight: 400;
  207. font-size: 30rpx;
  208. color: #A4A4A4;
  209. line-height: 42rpx;
  210. }
  211. .hl_pre{
  212. font-family: PingFangSC, PingFang SC;
  213. font-weight: 400;
  214. font-size: 30rpx;
  215. color: #000000;
  216. line-height: 42rpx;
  217. margin-top: 48rpx;
  218. }
  219. }
  220. }
  221. }
  222. .dialogs{
  223. width: 100%;
  224. padding: 34rpx 36rpx 164rpx;
  225. flex: 1;
  226. box-sizing: border-box;
  227. overflow-y: auto;
  228. .d_answer{
  229. margin-top: 40rpx;
  230. &.init{
  231. margin-top: 0;
  232. }
  233. .da_top{
  234. image{
  235. width: 48rpx;
  236. height: 48rpx;
  237. }
  238. text{
  239. font-family: PingFang-SC, PingFang-SC;
  240. font-weight: bold;
  241. font-size: 30rpx;
  242. color: #505050;
  243. line-height: 42rpx;
  244. margin-left: 20rpx;
  245. }
  246. }
  247. .da_content{
  248. padding: 30rpx 32rpx;
  249. margin-top: 20rpx;
  250. background: #FFFFFF;
  251. border-radius: 4rpx 24rpx 24rpx 24rpx;
  252. .dc_btns{
  253. margin-top: 44rpx;
  254. image{
  255. width: 48rpx;
  256. height: 48rpx;
  257. }
  258. .db_l{
  259. image{
  260. margin-right: 40rpx;
  261. }
  262. }
  263. }
  264. }
  265. }
  266. .d_question{
  267. margin-top: 40rpx;
  268. display: flex;
  269. justify-content: flex-end;
  270. .dq_text{
  271. background: #833478;
  272. border-radius: 24rpx 4rpx 24rpx 24rpx;
  273. font-family: PingFangSC, PingFang SC;
  274. font-weight: 400;
  275. font-size: 30rpx;
  276. color: #FFFFFF;
  277. line-height: 42rpx;
  278. text-align: right;
  279. padding: 26rpx 30rpx;
  280. }
  281. }
  282. }
  283. .ask{
  284. width: 100%;
  285. height: 130rpx;
  286. background: #FFFFFF;
  287. padding: 21rpx 30rpx;
  288. box-sizing: border-box;
  289. position: fixed;
  290. left: 0;
  291. bottom: 172rpx;
  292. z-index: 2;
  293. .a_l{
  294. width: calc(100% - 102rpx);
  295. height: 88rpx;
  296. padding: 20rpx 30rpx;
  297. box-sizing: border-box;
  298. border-radius: 44rpx;
  299. border: 2rpx solid rgba(131,52,120,0.74);
  300. input{
  301. border: none;
  302. font-family: PingFangSC, PingFang SC;
  303. font-weight: 400;
  304. font-size: 28rpx;
  305. color: #252525;
  306. line-height: 48rpx;
  307. &::placeholder{
  308. color: #808080;
  309. }
  310. }
  311. }
  312. .a_r{
  313. width: 72rpx;
  314. height: 72rpx;
  315. border-radius: 36rpx;
  316. }
  317. }
  318. }
  319. </style>