roleModel.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. <template>
  2. <view class="page" :style="{'min-height':h+'px', 'padding-top':mt+'px'}">
  3. <cus-header title='角色模板'></cus-header>
  4. <div class="title">选择角色模板<span>*</span></div>
  5. <div class="list">
  6. <div class="pre" v-for="(item,index) in list" :key="index" :class="{'active':midx===index}" @tap="changeModel(item,index)">
  7. <image src="https://transcend.ringzle.com/xiaozhi-app/profile/2025/05/29/8e24c230-a530-48ae-a2ed-d41262b9a051.png" v-if="midx===index"></image>
  8. {{item.agentName}}
  9. </div>
  10. </div>
  11. <div class="adffcacjc">
  12. <image src="https://transcend.ringzle.com/xiaozhi-app/profile/2025/05/29/24380873-b8d7-413c-8d9d-d997fe13685d.png"></image>
  13. <p>{{agentDto.agentName||''}}</p>
  14. </div>
  15. <div class="desc">
  16. <!-- <u-read-more :toggle="true" showHeight="300rpx">
  17. <rich-text :nodes="agentDto.systemPrompt||''"></rich-text>
  18. </u-read-more> -->
  19. <!-- {{agentDto.systemPrompt||''}} -->
  20. <u-textarea v-model="agentDto.systemPrompt" autoHeight :maxlength="-1" border="none" disabled="disabled"></u-textarea>
  21. </div>
  22. <div class="zt_btn" @tap="confirm">确认选择</div>
  23. </view>
  24. </template>
  25. <script>
  26. export default {
  27. data(){
  28. return {
  29. midx:0,
  30. list:[],
  31. agentDto:null,
  32. modelMap:new Map()
  33. }
  34. },
  35. onLoad() {
  36. this.getAgentModelList()
  37. },
  38. methods:{
  39. getAgentModelList(){
  40. this.$api.get('/agent/template').then(res=>{
  41. if(res.data.code!==0) return this.$showToast(res.data.msg)
  42. this.list = res.data.data;
  43. if(this.list.length){
  44. this.agentDto = this.list[0];
  45. let map = new Map();
  46. this.list.forEach(l=>{
  47. map.set(l.agentName,l)
  48. })
  49. this.modelMap = map;
  50. }
  51. })
  52. },
  53. changeModel(item,index){
  54. this.midx = index;
  55. this.agentDto = this.modelMap.get(item.agentName);
  56. },
  57. confirm(){
  58. let dto = JSON.parse(JSON.stringify(this.agentDto));
  59. delete dto.agentName;
  60. this.getOpenerEventChannel().emit('selectRoleModel',dto)
  61. uni.navigateBack();
  62. }
  63. }
  64. }
  65. </script>
  66. <style scoped lang="scss">
  67. ::v-deep .desc .u-textarea{
  68. padding: 0 20rpx !important;
  69. font-size: 26rpx !important;
  70. color: #7C8592 !important;
  71. line-height: 37rpx !important;
  72. background: transparent !important;
  73. }
  74. .page{
  75. width: 100%;
  76. background: #FFFFFF;
  77. padding: 0 30rpx 150rpx;
  78. box-sizing: border-box;
  79. .title{
  80. font-family: PingFang-SC, PingFang-SC;
  81. font-weight: bold;
  82. font-size: 32rpx;
  83. color: #111111;
  84. line-height: 32rpx;
  85. margin-top: 30rpx;
  86. span{
  87. color: #F31616;
  88. }
  89. }
  90. .list{
  91. width: 100%;
  92. margin-top: 12rpx;
  93. display: flex;
  94. flex-wrap: wrap;
  95. margin-left: -10rpx;
  96. .pre{
  97. margin-top: 20rpx;
  98. margin-left: 15rpx;
  99. width: calc(100% / 3 - 21rpx);
  100. height: 80rpx;
  101. background: #FFFFFF;
  102. border-radius: 16rpx;
  103. border: 1rpx solid #C7C7C7;
  104. font-family: PingFangSC, PingFang SC;
  105. font-weight: 400;
  106. font-size: 28rpx;
  107. color: #333333;
  108. line-height: 80rpx;
  109. text-align: center;
  110. position: relative;
  111. &.active{
  112. background: #D9F159;
  113. border: 1rpx solid #D9F159;
  114. font-weight: bold;
  115. color: #111111;
  116. }
  117. image{
  118. width: 48rpx;
  119. height: 48rpx;
  120. position: absolute;
  121. right: 0;
  122. bottom: 0;
  123. z-index: 22;
  124. }
  125. }
  126. }
  127. .adffcacjc image{
  128. width: 240rpx;
  129. height: 240rpx;
  130. margin-top: 95rpx;
  131. }
  132. p{
  133. font-family: PingFang-SC, PingFang-SC;
  134. font-weight: bold;
  135. font-size: 48rpx;
  136. color: #111111;
  137. line-height: 67rpx;
  138. text-align: center;
  139. margin-top: 24rpx;
  140. }
  141. .desc{
  142. font-family: PingFangSC, PingFang SC;
  143. font-weight: 400;
  144. font-size: 26rpx;
  145. color: #7C8592;
  146. line-height: 37rpx;
  147. margin-top: 36rpx;
  148. }
  149. .zt_btn{
  150. width: calc(100% - 60rpx);
  151. position: fixed;
  152. left: 30rpx;
  153. bottom: 30rpx;
  154. z-index: 999;
  155. }
  156. }
  157. </style>