dialog.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325
  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">
  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.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. <div class="a_r" @tap="sendQuestion"></div>
  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. },
  162. commentConfirm(){
  163. this.$set(this.dialogList[this.cindex],'comment',this.content);
  164. this.commentShow = false;
  165. },
  166. commentCancel(){
  167. this.content = '';
  168. this.commentShow = false;
  169. },
  170. }
  171. }
  172. </script>
  173. <style>
  174. .history .u-navbar .u-status-bar,.history .u-navbar .u-navbar__content{
  175. width: 672rpx !important;
  176. }
  177. </style>
  178. <style scoped lang="scss">
  179. .tabPage{
  180. position: relative;
  181. background: #F7F2F6;
  182. display: flex;
  183. flex-direction: column;
  184. .history{
  185. width: 672rpx;
  186. height: 100vh;
  187. background: #FFFFFF;
  188. box-sizing: border-box;
  189. display: flex;
  190. flex-direction: column;
  191. .h_list{
  192. flex: 1;
  193. width: 100%;
  194. padding: 0 64rpx;
  195. box-sizing: border-box;
  196. margin-top: 20rpx;
  197. overflow-y: auto;
  198. .hl_item{
  199. margin-top: 64rpx;
  200. &:first-child{
  201. margin-top: 0;
  202. }
  203. .hi_date{
  204. font-family: PingFangSC, PingFang SC;
  205. font-weight: 400;
  206. font-size: 30rpx;
  207. color: #A4A4A4;
  208. line-height: 42rpx;
  209. }
  210. .hl_pre{
  211. font-family: PingFangSC, PingFang SC;
  212. font-weight: 400;
  213. font-size: 30rpx;
  214. color: #000000;
  215. line-height: 42rpx;
  216. margin-top: 48rpx;
  217. }
  218. }
  219. }
  220. }
  221. .dialogs{
  222. width: 100%;
  223. padding: 34rpx 36rpx 164rpx;
  224. flex: 1;
  225. box-sizing: border-box;
  226. overflow-y: auto;
  227. .d_answer{
  228. margin-top: 40rpx;
  229. &.init{
  230. margin-top: 0;
  231. }
  232. .da_top{
  233. image{
  234. width: 48rpx;
  235. height: 48rpx;
  236. }
  237. text{
  238. font-family: PingFang-SC, PingFang-SC;
  239. font-weight: bold;
  240. font-size: 30rpx;
  241. color: #505050;
  242. line-height: 42rpx;
  243. margin-left: 20rpx;
  244. }
  245. }
  246. .da_content{
  247. padding: 30rpx 32rpx;
  248. margin-top: 20rpx;
  249. background: #FFFFFF;
  250. border-radius: 4rpx 24rpx 24rpx 24rpx;
  251. .dc_btns{
  252. margin-top: 44rpx;
  253. image{
  254. width: 48rpx;
  255. height: 48rpx;
  256. }
  257. .db_l{
  258. image{
  259. margin-right: 40rpx;
  260. }
  261. }
  262. }
  263. }
  264. }
  265. .d_question{
  266. margin-top: 40rpx;
  267. display: flex;
  268. justify-content: flex-end;
  269. .dq_text{
  270. background: #833478;
  271. border-radius: 24rpx 4rpx 24rpx 24rpx;
  272. font-family: PingFangSC, PingFang SC;
  273. font-weight: 400;
  274. font-size: 30rpx;
  275. color: #FFFFFF;
  276. line-height: 42rpx;
  277. text-align: right;
  278. padding: 26rpx 30rpx;
  279. }
  280. }
  281. }
  282. .ask{
  283. width: 100%;
  284. height: 130rpx;
  285. background: #FFFFFF;
  286. padding: 21rpx 30rpx;
  287. box-sizing: border-box;
  288. position: fixed;
  289. left: 0;
  290. bottom: 172rpx;
  291. z-index: 2;
  292. .a_l{
  293. width: calc(100% - 102rpx);
  294. height: 88rpx;
  295. padding: 20rpx 30rpx;
  296. box-sizing: border-box;
  297. border-radius: 44rpx;
  298. border: 2rpx solid rgba(131,52,120,0.74);
  299. input{
  300. border: none;
  301. font-family: PingFangSC, PingFang SC;
  302. font-weight: 400;
  303. font-size: 28rpx;
  304. color: #252525;
  305. line-height: 48rpx;
  306. &::placeholder{
  307. color: #808080;
  308. }
  309. }
  310. }
  311. .a_r{
  312. width: 72rpx;
  313. height: 72rpx;
  314. background: #833478;
  315. border-radius: 36rpx;
  316. }
  317. }
  318. }
  319. </style>