home.vue 5.9 KB

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