home.vue 5.8 KB

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