device.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  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. try{
  70. let result = JSON.parse(res.result);
  71. if(res.errMsg==='scanCode:ok'){
  72. uni.navigateTo({
  73. url:'/pagesMy/scanResult?scanParams='+JSON.stringify(result)
  74. })
  75. }
  76. }catch(e){
  77. that.$showModal('扫码失败,请检查设备二维码。')
  78. }
  79. }
  80. })
  81. },
  82. wifiBindDevice(){
  83. uni.navigateTo({
  84. url:'/pagesMy/deviceAdd'
  85. })
  86. },
  87. unbindSuccess(){
  88. this.getList();
  89. }
  90. }
  91. }
  92. </script>
  93. <style scoped lang="less">
  94. .page{
  95. background: #FFFFFF;
  96. padding: 0 21rpx 172rpx;
  97. box-sizing: border-box;
  98. .box{
  99. position: relative;
  100. width: calc(100% - 60rpx);
  101. background: #FFFFFF;
  102. box-shadow: 0rpx 4rpx 20rpx 0rpx rgba(0,0,0,0.04);
  103. border-radius: 32rpx;
  104. border: 1rpx solid #D9F159;
  105. box-sizing: border-box;
  106. }
  107. .list{
  108. position: relative;
  109. ::v-deep .u-list{
  110. width: 100%;
  111. height: 100% !important;
  112. }
  113. ::v-deep .u-list-item{
  114. width: 100%;
  115. }
  116. .l_box{
  117. width: 100%;
  118. padding: 49rpx 30rpx 40rpx;
  119. margin-top: 20rpx;
  120. .l_top{
  121. .lt_l{
  122. font-family: PingFang-SC, PingFang-SC;
  123. font-weight: bold;
  124. font-size: 32rpx;
  125. color: #111111;
  126. line-height: 40rpx;
  127. }
  128. .lt_r{
  129. image{
  130. width: 42rpx;
  131. height: 42rpx;
  132. margin-right: 34rpx;
  133. }
  134. .ltr_zt{
  135. font-family: PingFangSC, PingFang SC;
  136. font-weight: 400;
  137. font-size: 26rpx;
  138. line-height: 37rpx;
  139. padding-left: 22rpx;
  140. position: relative;
  141. &::before{
  142. content: '';
  143. width: 12rpx;
  144. height: 12rpx;
  145. border-radius: 50%;
  146. position: absolute;
  147. left: 0;
  148. top: 50%;
  149. margin-top: -6rpx;
  150. }
  151. &.zx{
  152. color: #1B50FF;
  153. &::before{
  154. background: #1B50FF;
  155. }
  156. }
  157. &.lx{
  158. color: #C7C7C7;
  159. &::before{
  160. background: #C7C7C7;
  161. }
  162. }
  163. }
  164. }
  165. }
  166. .l_content{
  167. border-top: 1rpx solid #E2E2E2;
  168. margin-top: 37rpx;
  169. padding-top: 36rpx;
  170. overflow: hidden;
  171. .lc_role{
  172. .lcr_l{
  173. width: 148rpx;
  174. height: 148rpx;
  175. border-radius: 50%;
  176. }
  177. .lcr_r{
  178. width: calc(100% - 148rpx);
  179. padding-left: 30rpx;
  180. box-sizing: border-box;
  181. p{
  182. font-family: PingFang-SC, PingFang-SC;
  183. font-weight: bold;
  184. font-size: 32rpx;
  185. color: #111111;
  186. line-height: 32rpx;
  187. overflow: hidden;
  188. white-space: nowrap;
  189. text-overflow: ellipsis;
  190. }
  191. .text{
  192. font-family: PingFangSC, PingFang SC;
  193. font-weight: 400;
  194. font-size: 24rpx;
  195. color: #7C8592;
  196. line-height: 24rpx;
  197. margin-top: 24rpx;
  198. }
  199. }
  200. }
  201. .lc_btns{
  202. margin-top: 62rpx;
  203. margin-left: -1rpx;
  204. overflow: hidden;
  205. .lcb_pre{
  206. width: calc(100% / 3);
  207. height: 37rpx;
  208. border-left: 1rpx solid #72832B;
  209. font-family: PingFang-SC, PingFang-SC;
  210. font-weight: bold;
  211. font-size: 26rpx;
  212. color: #72832B;
  213. line-height: 37rpx;
  214. text-align: center;
  215. }
  216. }
  217. }
  218. }
  219. }
  220. .empty{
  221. image{
  222. width: 64rpx;
  223. height: 66rpx;
  224. }
  225. p{
  226. font-family: PingFangSC, PingFang SC;
  227. font-weight: 400;
  228. font-size: 30rpx;
  229. color: #A6A6A6;
  230. line-height: 42rpx;
  231. text-align: center;
  232. margin-top: 30rpx;
  233. }
  234. }
  235. .btns{
  236. width: calc(100% - 60rpx);
  237. position: fixed;
  238. left: 20rpx;
  239. bottom: 64rpx;
  240. .zt_btn{
  241. width: calc(50% - 15rpx);
  242. }
  243. }
  244. }
  245. </style>