roleModel.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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="http://106.54.209.120:8188/static/selected_dh.png" v-if="midx===index"></image>
  8. {{item.agentName}}
  9. </div>
  10. </div>
  11. <div class="adffcacjc">
  12. <image src="http://106.54.209.120:8188/static/avatar_default.png"></image>
  13. <p>{{agentDto.agentName||''}}</p>
  14. </div>
  15. <div class="desc">{{agentDto.systemPrompt||''}}</div>
  16. <div class="zt_btn" @tap="confirm">确认选择</div>
  17. </view>
  18. </template>
  19. <script>
  20. export default {
  21. data(){
  22. return {
  23. midx:0,
  24. list:[],
  25. agentDto:null,
  26. modelMap:new Map()
  27. }
  28. },
  29. onLoad() {
  30. this.getAgentModelList()
  31. },
  32. methods:{
  33. getAgentModelList(){
  34. this.$api.get('/agent/template').then(res=>{
  35. if(res.data.code!==0) return this.$showToast(res.data.msg)
  36. this.list = res.data.data;
  37. if(this.list.length){
  38. this.agentDto = this.list[0];
  39. let map = new Map();
  40. this.list.forEach(l=>{
  41. map.set(l.agentName,l)
  42. })
  43. this.modelMap = map;
  44. }
  45. })
  46. },
  47. changeModel(item,index){
  48. this.midx = index;
  49. this.agentDto = this.modelMap.get(item.agentName);
  50. },
  51. confirm(){
  52. this.getOpenerEventChannel().emit('selectRoleModel',this.agentDto)
  53. uni.navigateBack();
  54. }
  55. }
  56. }
  57. </script>
  58. <style scoped lang="less">
  59. .page{
  60. width: 100%;
  61. background: #FFFFFF;
  62. padding: 0 30rpx 30rpx;
  63. box-sizing: border-box;
  64. overflow: hidden;
  65. .title{
  66. font-family: PingFang-SC, PingFang-SC;
  67. font-weight: bold;
  68. font-size: 32rpx;
  69. color: #111111;
  70. line-height: 32rpx;
  71. margin-top: 30rpx;
  72. span{
  73. color: #F31616;
  74. }
  75. }
  76. .list{
  77. width: 100%;
  78. margin-top: 12rpx;
  79. display: flex;
  80. flex-wrap: wrap;
  81. margin-left: -10rpx;
  82. .pre{
  83. margin-top: 20rpx;
  84. margin-left: 15rpx;
  85. width: calc(100% / 3 - 21rpx);
  86. height: 80rpx;
  87. background: #FFFFFF;
  88. border-radius: 16rpx;
  89. border: 1rpx solid #C7C7C7;
  90. font-family: PingFangSC, PingFang SC;
  91. font-weight: 400;
  92. font-size: 28rpx;
  93. color: #333333;
  94. line-height: 80rpx;
  95. text-align: center;
  96. position: relative;
  97. &.active{
  98. background: #D9F159;
  99. border: 1rpx solid #D9F159;
  100. font-weight: bold;
  101. color: #111111;
  102. }
  103. image{
  104. width: 48rpx;
  105. height: 48rpx;
  106. position: absolute;
  107. right: 0;
  108. bottom: 0;
  109. z-index: 22;
  110. }
  111. }
  112. }
  113. .adffcacjc image{
  114. width: 240rpx;
  115. height: 240rpx;
  116. margin-top: 95rpx;
  117. }
  118. p{
  119. font-family: PingFang-SC, PingFang-SC;
  120. font-weight: bold;
  121. font-size: 48rpx;
  122. color: #111111;
  123. line-height: 67rpx;
  124. text-align: center;
  125. margin-top: 24rpx;
  126. }
  127. .desc{
  128. font-family: PingFangSC, PingFang SC;
  129. font-weight: 400;
  130. font-size: 26rpx;
  131. color: #7C8592;
  132. line-height: 37rpx;
  133. margin-top: 36rpx;
  134. }
  135. .zt_btn{
  136. margin-top: 285rpx;
  137. }
  138. }
  139. </style>