DetailView.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  1. <script setup>
  2. import { ref, reactive, toRefs, onMounted } from "vue";
  3. import NavBarPage from "../components/NavBarPage.vue";
  4. import selectPage from "./result/selectPage.vue";
  5. import { fetchTaskCreate } from "./utils/api";
  6. import { showToast } from "vant";
  7. import { useRouter } from "vue-router";
  8. const router = useRouter();
  9. const selectedRole = ref("");
  10. const selectedNature = ref(null);
  11. const selectedRounds = ref(0);
  12. const sceneType = ref("")
  13. const rolelist = ref([]);
  14. const roleOptions = JSON.parse(localStorage.getItem('role')).roleOption
  15. const roundsOptions = [
  16. { text: 5, value: 5 },
  17. { text: 8, value: 8 },
  18. { text: 10, value: 10 },
  19. ];
  20. const naturesOptions =[
  21. { text: "固执己见,不愿妥协", value: "固执己见,不愿妥协" },
  22. { text: "细心周到,考虑周全", value: "细心周到,考虑周全" },
  23. { text: "易怒暴躁,难以沟通", value: "易怒暴躁,难以沟通" },
  24. { text: "幽默风趣,气氛活跃", value: "幽默风趣,气氛活跃" },
  25. { text: "自私冷漠,缺乏同理", value: "自私冷漠,缺乏同理" },
  26. ]
  27. const handleSelectNature = (option) => {
  28. selectedNature.value = option.value;
  29. };
  30. const handleSelectRoles = (option) => {
  31. selectedRole.value = option.value;
  32. };
  33. const handleSelectRounds = (option) => {
  34. selectedRounds.value = option.value;
  35. };
  36. const handleExam = async () => {
  37. if (!selectedRole.value || !selectedNature.value || !selectedRounds.value) {
  38. showToast("请选择角色、性格和轮数");
  39. return;
  40. }
  41. const data = {
  42. tutoringRole: selectedRole.value,
  43. personality: selectedNature.value,
  44. round: selectedRounds.value,
  45. sceneType:sceneType.value,
  46. };
  47. try {
  48. const { body } = await fetchTaskCreate(data);
  49. router.push({
  50. name: "ChatTts",
  51. query: { taskId: body, round: selectedRounds.value , sceneType:sceneType.value },
  52. });
  53. } catch (error) {
  54. console.log(error);
  55. }
  56. };
  57. onMounted(() => {
  58. const role = JSON.parse(localStorage.getItem('role'))
  59. rolelist.value = role
  60. sceneType.value = role.sceneType
  61. localStorage.removeItem("chatHistory");
  62. localStorage.removeItem("status");
  63. });
  64. </script>
  65. <template>
  66. <div class="detail">
  67. <nav-bar-page title="课程详情" />
  68. <div style="height: 46px"></div>
  69. <div class="content">
  70. <div class="banner">
  71. <img :src="rolelist.image" alt="" />
  72. </div>
  73. <div class="produce">
  74. <p>{{ rolelist.title }}</p>
  75. <div class="p_content">
  76. <span class="bg">背景:</span>
  77. <span>{{ rolelist.description }}</span>
  78. </div>
  79. </div>
  80. <div class="rules">
  81. <div class="title">
  82. <van-icon
  83. name="records-o"
  84. size="1.5rem"
  85. color="rgba(64,149,229,1)"
  86. style="font-weight: bold"
  87. />
  88. <span>规则</span>
  89. </div>
  90. <div class="r_content">
  91. <div class="r_item">
  92. <label for="roles">陪练角色</label>
  93. <selectPage
  94. :optionValue="roleOptions"
  95. placeholder="请选择角色"
  96. @update:selectedOption="handleSelectRoles"
  97. />
  98. </div>
  99. <div class="r_item">
  100. <label for="nature">陪练性格</label>
  101. <selectPage
  102. :optionValue="naturesOptions"
  103. placeholder="请选择性格"
  104. @update:selectedOption="handleSelectNature"
  105. />
  106. </div>
  107. <div class="r_item">
  108. <label for="rounds">交互轮次</label>
  109. <selectPage
  110. :optionValue="roundsOptions"
  111. placeholder="请选择轮次"
  112. @update:selectedOption="handleSelectRounds"
  113. />
  114. </div>
  115. </div>
  116. </div>
  117. <div class="bottom">
  118. <button class="exam" @click="handleExam">考试</button>
  119. <button>练习</button>
  120. </div>
  121. </div>
  122. </div>
  123. </template>
  124. <style scoped lang="less">
  125. .detail {
  126. width: 100%;
  127. height: 100%;
  128. // overflow: hidden;
  129. /* background-color: #f5f5f5; */
  130. .content {
  131. padding: 0 1.88rem;
  132. }
  133. .produce {
  134. margin-top: 1.63rem;
  135. p {
  136. color: rgba(16, 16, 16, 1);
  137. font-size: 1rem;
  138. font-family: Times New Roman-regular;
  139. }
  140. .p_content {
  141. margin-top: 0.5rem;
  142. width: 100%;
  143. max-height: 9rem;
  144. overflow: scroll;
  145. }
  146. span {
  147. line-height: 1.25rem;
  148. color: rgba(102, 102, 102, 1);
  149. font-size: 0.88rem;
  150. text-align: left;
  151. font-family: SourceHanSansSC-bold;
  152. }
  153. .bg {
  154. font-weight: 600;
  155. color: #000;
  156. }
  157. }
  158. .rules {
  159. margin: 2.38rem 0;
  160. width: 100%;
  161. height: 13.69rem;
  162. line-height: 1.25rem;
  163. border-radius: 0.75rem;
  164. background-color: rgba(255, 255, 255, 1);
  165. color: rgba(16, 16, 16, 1);
  166. font-size: 0.88rem;
  167. text-align: center;
  168. box-shadow: 0rem 0.06rem 0.88rem 0rem rgba(0, 1, 130, 0.08);
  169. font-family: -regular;
  170. .title {
  171. display: flex;
  172. align-items: center;
  173. padding: 1.03rem 0.88rem;
  174. }
  175. .title span {
  176. margin-left: 0.31rem;
  177. color: rgba(64, 149, 229, 1);
  178. font-size: 1rem;
  179. font-family: Times New Roman-regular;
  180. }
  181. .r_content {
  182. margin-top: 0.44rem;
  183. }
  184. .r_item {
  185. display: flex;
  186. // justify-content: space-between;
  187. align-items: center;
  188. padding: 0 1.75rem;
  189. margin-bottom: 0.75rem;
  190. font-size: 0.88rem;
  191. color: rgba(16, 16, 16, 1);
  192. }
  193. .r_item select {
  194. width: 11.56rem;
  195. height: 2rem;
  196. line-height: 1.25rem;
  197. border-radius: 0.38rem;
  198. font-family: PingFangSC-regular;
  199. border: 0.06rem solid rgba(187, 187, 187, 1);
  200. padding: 0 10px;
  201. -webkit-appearance: none;
  202. -moz-appearance: none;
  203. appearance: none;
  204. background: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20width%3D%2224%22%20height%3D%2224%22%3E%3Cpath%20fill%3D%22%23000%22%20fill-opacity%3D%22.9%22%20fill-rule%3D%22evenodd%22%20d%3D%22M17.35%209.65a.5.5%200%200%200-.7%200L12%2014.29%207.35%209.65a.5.5%200%201%200-.7.7l5%205c.2.2.5.2.7%200l5-5a.5.5%200%200%200%200-.7%22%20clip-rule%3D%22evenodd%22%2F%3E%3C%2Fsvg%3E")
  205. no-repeat right 10px center;
  206. background-size: 1.5rem 1.5rem;
  207. /* 调整箭头的大小 */
  208. }
  209. .r_item label {
  210. // width: 3.5rem;
  211. // height: 1.25rem;
  212. // line-height: 1.25rem;
  213. // color: rgba(16,16,16,1);
  214. // font-size: 0.88rem;
  215. // text-align: left;
  216. font-family: PingFangSC-medium;
  217. margin-right: 1.1rem;
  218. }
  219. }
  220. .bottom {
  221. width: 100%;
  222. display: flex;
  223. justify-content: space-between;
  224. margin-bottom: 1.38rem;
  225. button {
  226. width: 10rem;
  227. height: 2.44rem;
  228. line-height: 1.25rem;
  229. border-radius: 0.38rem 0.38rem 0.38rem 0.38rem;
  230. background-color: rgba(243, 249, 255, 1);
  231. font-size: 0.88rem;
  232. text-align: center;
  233. font-family: -regular;
  234. border: 0.06rem solid rgba(163, 208, 253, 1);
  235. color: #1989fa;
  236. }
  237. .exam {
  238. color: #fff;
  239. background-color: rgba(64, 149, 229, 1);
  240. margin-right: 0.63rem;
  241. }
  242. }
  243. }
  244. .banner {
  245. height: 11.63rem;
  246. border-radius: 0.75rem;
  247. background-color: rgba(229, 229, 229, 1);
  248. overflow: hidden;
  249. }
  250. .banner img {
  251. width: 100%;
  252. height: 11.63rem;
  253. object-fit: cover;
  254. }
  255. </style>