home.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. <template>
  2. <view class="tabPage" :style="{'min-height':h+'px', 'padding-top':mt+'px'}">
  3. <image class="topbg" src="https://transcend.ringzle.com/xiaozhi-app/profile/2025/05/29/a0418f81-84a3-4764-b5f6-48c4beb88ee0.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="https://transcend.ringzle.com/xiaozhi-app/profile/2025/05/29/d3ebb319-374c-43db-bd49-64e31c83f12e.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. uni.navigateTo({
  44. url:'/pagesHome/dialogDetail'
  45. })
  46. },
  47. methods:{
  48. getAgentModelList(){
  49. return new Promise((resolve,reject)=>{
  50. this.$api.get('/agent/template').then(res=>{
  51. if(res.data.code!==0) return this.$showToast(res.data.msg)
  52. if(res.data.data.length){
  53. let map = new Map();
  54. res.data.data.forEach(l=>{
  55. map.set(l.systemPrompt,l)
  56. })
  57. this.modelMap = map;
  58. }
  59. resolve()
  60. })
  61. })
  62. },
  63. getDeviceList(){
  64. this.$api.get(`/device/bind/${null}`).then(res=>{
  65. if(res.data.code!==0) return this.$showToast(res.data.msg)
  66. this.list = res.data.data;
  67. this.list.forEach(l=>{
  68. l.roleModelName = this.modelMap.get(l?.agent?.systemPrompt)?.agentName;
  69. })
  70. })
  71. },
  72. addDevice(){
  73. this.$refs.bdRef.show = true;
  74. },
  75. unbindSuccess(){
  76. this.getDeviceList();
  77. }
  78. }
  79. }
  80. </script>
  81. <style scoped lang="less">
  82. .tabPage{
  83. background: #FFFFFF;
  84. padding-bottom: 192rpx;
  85. box-sizing: border-box;
  86. .topbg{
  87. width: 100%;
  88. height: 720rpx;
  89. position: fixed;
  90. top: 0;
  91. left: 0;
  92. }
  93. .box{
  94. position: relative;
  95. width: calc(100% - 60rpx);
  96. background: #FFFFFF;
  97. box-shadow: 0rpx 4rpx 20rpx 0rpx rgba(0,0,0,0.04);
  98. border-radius: 32rpx;
  99. border: 1rpx solid #D9F159;
  100. box-sizing: border-box;
  101. }
  102. .list{
  103. position: relative;
  104. margin: 0 30rpx 0;
  105. width: calc(100% - 60rpx);
  106. height: calc(100vh - 740rpx);
  107. ::v-deep .u-list{
  108. width: 100%;
  109. height: 100% !important;
  110. }
  111. ::v-deep .u-list-item{
  112. width: 100%;
  113. }
  114. .l_box{
  115. width: 100%;
  116. padding: 49rpx 30rpx 40rpx;
  117. margin-top: 20rpx;
  118. .l_top{
  119. .lt_l{
  120. font-family: PingFang-SC, PingFang-SC;
  121. font-weight: bold;
  122. font-size: 32rpx;
  123. color: #111111;
  124. line-height: 40rpx;
  125. }
  126. .lt_r{
  127. image{
  128. width: 42rpx;
  129. height: 42rpx;
  130. margin-right: 34rpx;
  131. }
  132. .ltr_zt{
  133. font-family: PingFangSC, PingFang SC;
  134. font-weight: 400;
  135. font-size: 26rpx;
  136. line-height: 37rpx;
  137. padding-left: 22rpx;
  138. position: relative;
  139. &::before{
  140. content: '';
  141. width: 12rpx;
  142. height: 12rpx;
  143. border-radius: 50%;
  144. position: absolute;
  145. left: 0;
  146. top: 50%;
  147. margin-top: -6rpx;
  148. }
  149. &.zx{
  150. color: #1B50FF;
  151. &::before{
  152. background: #1B50FF;
  153. }
  154. }
  155. &.lx{
  156. color: #C7C7C7;
  157. &::before{
  158. background: #C7C7C7;
  159. }
  160. }
  161. }
  162. }
  163. }
  164. .l_content{
  165. border-top: 1rpx solid #E2E2E2;
  166. margin-top: 37rpx;
  167. padding-top: 36rpx;
  168. overflow: hidden;
  169. .lc_role{
  170. .lcr_l{
  171. width: 148rpx;
  172. height: 148rpx;
  173. border-radius: 50%;
  174. }
  175. .lcr_r{
  176. width: calc(100% - 148rpx);
  177. padding-left: 30rpx;
  178. box-sizing: border-box;
  179. p{
  180. font-family: PingFang-SC, PingFang-SC;
  181. font-weight: bold;
  182. font-size: 32rpx;
  183. color: #111111;
  184. line-height: 32rpx;
  185. overflow: hidden;
  186. white-space: nowrap;
  187. text-overflow: ellipsis;
  188. }
  189. .text{
  190. font-family: PingFangSC, PingFang SC;
  191. font-weight: 400;
  192. font-size: 24rpx;
  193. color: #7C8592;
  194. line-height: 24rpx;
  195. margin-top: 24rpx;
  196. }
  197. }
  198. }
  199. .lc_info{
  200. margin-top: 36rpx;
  201. font-family: PingFangSC, PingFang SC;
  202. font-weight: 400;
  203. font-size: 24rpx;
  204. color: #7C8592;
  205. line-height: 40rpx;
  206. }
  207. .lc_btns{
  208. margin-top: 62rpx;
  209. margin-left: -1rpx;
  210. overflow: hidden;
  211. .lcb_pre{
  212. width: calc(100% / 3);
  213. height: 37rpx;
  214. border-left: 1rpx solid #72832B;
  215. font-family: PingFang-SC, PingFang-SC;
  216. font-weight: bold;
  217. font-size: 26rpx;
  218. color: #72832B;
  219. line-height: 37rpx;
  220. text-align: center;
  221. }
  222. }
  223. }
  224. }
  225. }
  226. .empty{
  227. display: flex;
  228. flex-direction: column;
  229. align-items: center;
  230. margin: 392rpx 30rpx 0;
  231. padding: 84rpx 40rpx 64rpx;
  232. image{
  233. width: 64rpx;
  234. height: 66rpx;
  235. }
  236. p{
  237. font-family: PingFangSC, PingFang SC;
  238. font-weight: 400;
  239. font-size: 30rpx;
  240. color: #A6A6A6;
  241. line-height: 42rpx;
  242. text-align: center;
  243. margin-top: 30rpx;
  244. }
  245. .zt_btn{
  246. margin-top: 80rpx;
  247. }
  248. }
  249. }
  250. </style>