home.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. <template>
  2. <view class="tabPage" :style="{'min-height':h+'px', 'padding-top':mt+'px'}">
  3. <image class="topbg" src="http://106.54.209.120:8188/static/home_topbg.png"></image>
  4. <template v-if="list.length">
  5. <div class="list" :style="{'margin-top':(360-mt-61)+'px'}">
  6. <u-list>
  7. <u-list-item v-for="(item, index) in list" :key="index">
  8. <device-box :item="item" :showInfo="true" @unbindSuccess="unbindSuccess"></device-box>
  9. </u-list-item>
  10. </u-list>
  11. </div>
  12. </template>
  13. <template v-else>
  14. <div class="empty box">
  15. <image src="http://106.54.209.120:8188/static/empty_device.png"></image>
  16. <p>暂无设备,快去添加开始聊天吧~</p>
  17. <div class="zt_btn" @tap="addDevice"> + 添加新设备</div>
  18. </div>
  19. </template>
  20. <cus-tabbar :tabbarIndex="0"></cus-tabbar>
  21. <bind-device ref="bdRef"></bind-device>
  22. </view>
  23. </template>
  24. <script>
  25. import cusTabbar from '@/components/CusTabbar/index.vue'
  26. import bindDevice from '@/components/bindDevice/index.vue'
  27. import deviceBox from '@/components/deviceBox/index.vue'
  28. export default {
  29. components:{
  30. cusTabbar,
  31. bindDevice,
  32. deviceBox
  33. },
  34. data(){
  35. return {
  36. list:[],
  37. modelMap:new Map()
  38. }
  39. },
  40. async onShow() {
  41. await this.getAgentModelList()
  42. this.getDeviceList();
  43. },
  44. methods:{
  45. getAgentModelList(){
  46. return new Promise((resolve,reject)=>{
  47. this.$api.get('/agent/template').then(res=>{
  48. if(res.data.code!==0) return this.$showToast(res.data.msg)
  49. if(res.data.data.length){
  50. let map = new Map();
  51. res.data.data.forEach(l=>{
  52. map.set(l.systemPrompt,l)
  53. })
  54. this.modelMap = map;
  55. }
  56. resolve()
  57. })
  58. })
  59. },
  60. getDeviceList(){
  61. this.$api.get(`/device/bind/${null}`).then(res=>{
  62. if(res.data.code!==0) return this.$showToast(res.data.msg)
  63. this.list = res.data.data;
  64. this.list.forEach(l=>{
  65. l.roleModelName = this.modelMap.get(l.agent.systemPrompt).agentName;
  66. })
  67. })
  68. },
  69. addDevice(){
  70. this.$refs.bdRef.show = true;
  71. },
  72. unbindSuccess(){
  73. this.getDeviceList();
  74. }
  75. }
  76. }
  77. </script>
  78. <style scoped lang="less">
  79. .tabPage{
  80. background: #FFFFFF;
  81. padding-bottom: 192rpx;
  82. box-sizing: border-box;
  83. .topbg{
  84. width: 100%;
  85. height: 720rpx;
  86. position: fixed;
  87. top: 0;
  88. left: 0;
  89. }
  90. .box{
  91. position: relative;
  92. width: calc(100% - 60rpx);
  93. background: #FFFFFF;
  94. box-shadow: 0rpx 4rpx 20rpx 0rpx rgba(0,0,0,0.04);
  95. border-radius: 32rpx;
  96. border: 1rpx solid #D9F159;
  97. box-sizing: border-box;
  98. }
  99. .list{
  100. position: relative;
  101. margin: 0 30rpx 0;
  102. width: calc(100% - 60rpx);
  103. height: calc(100vh - 740rpx);
  104. ::v-deep .u-list{
  105. width: 100%;
  106. height: 100% !important;
  107. }
  108. ::v-deep .u-list-item{
  109. width: 100%;
  110. }
  111. .l_box{
  112. width: 100%;
  113. padding: 49rpx 30rpx 40rpx;
  114. margin-top: 20rpx;
  115. .l_top{
  116. .lt_l{
  117. font-family: PingFang-SC, PingFang-SC;
  118. font-weight: bold;
  119. font-size: 32rpx;
  120. color: #111111;
  121. line-height: 40rpx;
  122. }
  123. .lt_r{
  124. image{
  125. width: 42rpx;
  126. height: 42rpx;
  127. margin-right: 34rpx;
  128. }
  129. .ltr_zt{
  130. font-family: PingFangSC, PingFang SC;
  131. font-weight: 400;
  132. font-size: 26rpx;
  133. line-height: 37rpx;
  134. padding-left: 22rpx;
  135. position: relative;
  136. &::before{
  137. content: '';
  138. width: 12rpx;
  139. height: 12rpx;
  140. border-radius: 50%;
  141. position: absolute;
  142. left: 0;
  143. top: 50%;
  144. margin-top: -6rpx;
  145. }
  146. &.zx{
  147. color: #1B50FF;
  148. &::before{
  149. background: #1B50FF;
  150. }
  151. }
  152. &.lx{
  153. color: #C7C7C7;
  154. &::before{
  155. background: #C7C7C7;
  156. }
  157. }
  158. }
  159. }
  160. }
  161. .l_content{
  162. border-top: 1rpx solid #E2E2E2;
  163. margin-top: 37rpx;
  164. padding-top: 36rpx;
  165. overflow: hidden;
  166. .lc_role{
  167. .lcr_l{
  168. width: 148rpx;
  169. height: 148rpx;
  170. border-radius: 50%;
  171. }
  172. .lcr_r{
  173. width: calc(100% - 148rpx);
  174. padding-left: 30rpx;
  175. box-sizing: border-box;
  176. p{
  177. font-family: PingFang-SC, PingFang-SC;
  178. font-weight: bold;
  179. font-size: 32rpx;
  180. color: #111111;
  181. line-height: 32rpx;
  182. overflow: hidden;
  183. white-space: nowrap;
  184. text-overflow: ellipsis;
  185. }
  186. .text{
  187. font-family: PingFangSC, PingFang SC;
  188. font-weight: 400;
  189. font-size: 24rpx;
  190. color: #7C8592;
  191. line-height: 24rpx;
  192. margin-top: 24rpx;
  193. }
  194. }
  195. }
  196. .lc_info{
  197. margin-top: 36rpx;
  198. font-family: PingFangSC, PingFang SC;
  199. font-weight: 400;
  200. font-size: 24rpx;
  201. color: #7C8592;
  202. line-height: 40rpx;
  203. }
  204. .lc_btns{
  205. margin-top: 62rpx;
  206. margin-left: -1rpx;
  207. overflow: hidden;
  208. .lcb_pre{
  209. width: calc(100% / 3);
  210. height: 37rpx;
  211. border-left: 1rpx solid #72832B;
  212. font-family: PingFang-SC, PingFang-SC;
  213. font-weight: bold;
  214. font-size: 26rpx;
  215. color: #72832B;
  216. line-height: 37rpx;
  217. text-align: center;
  218. }
  219. }
  220. }
  221. }
  222. }
  223. .empty{
  224. display: flex;
  225. flex-direction: column;
  226. align-items: center;
  227. margin: 392rpx 30rpx 0;
  228. padding: 84rpx 40rpx 64rpx;
  229. image{
  230. width: 64rpx;
  231. height: 66rpx;
  232. }
  233. p{
  234. font-family: PingFangSC, PingFang SC;
  235. font-weight: 400;
  236. font-size: 30rpx;
  237. color: #A6A6A6;
  238. line-height: 42rpx;
  239. text-align: center;
  240. margin-top: 30rpx;
  241. }
  242. .zt_btn{
  243. margin-top: 80rpx;
  244. }
  245. }
  246. }
  247. </style>