device.vue 5.9 KB

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