123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256 |
- <template>
- <view class="page" :style="{'min-height':h+'px', 'padding-top':mt+'px'}">
- <cus-header title='设备管理'></cus-header>
- <template v-if="list.length">
- <div class="list" :style="{'height':'calc(100vh - '+(mt+100)+'px)'}">
- <u-list>
- <u-list-item v-for="(item, index) in list" :key="index">
- <device-box :item="item" @unbindSuccess="unbindSuccess"></device-box>
- </u-list-item>
- </u-list>
- </div>
- </template>
- <template v-else>
- <div class="empty adffcacjc" :style="{'height':'calc(100vh - '+(mt+100)+'px)'}">
- <image src="http://106.54.209.120:8188/static/empty_device.png"></image>
- <p>暂无绑定设备</p>
- </div>
- </template>
- <div class="btns adfacjb">
- <div class="zt_btn" @tap="scanBindDevice">扫码绑定设备</div>
- <div class="zt_btn" @tap="wifiBindDevice">配网并绑定设备</div>
- </div>
- </view>
- </template>
- <script>
- import deviceBox from '@/components/deviceBox/index.vue'
- export default {
- components:{
- deviceBox
- },
- data(){
- return {
- list:[]
- }
- },
- async onShow() {
- await this.getAgentModelList()
- this.getList();
- },
- methods:{
- getAgentModelList(){
- return new Promise((resolve,reject)=>{
- this.$api.get('/agent/template').then(res=>{
- if(res.data.code!==0) return this.$showToast(res.data.msg)
- if(res.data.data.length){
- let map = new Map();
- res.data.data.forEach(l=>{
- map.set(l.systemPrompt,l)
- })
- this.modelMap = map;
- }
- resolve()
- })
- })
- },
- getList(){
- this.$api.get(`/device/bind/${null}`).then(res=>{
- if(res.data.code!==0) return this.$showToast(res.data.msg)
- this.list = res.data.data;
- this.list.forEach(l=>{
- l.roleModelName = this.modelMap.get(l.agent.systemPrompt).agentName;
- })
- })
- },
- scanBindDevice(){
- let that = this;
- uni.scanCode({
- success: (res) => {
- let result = JSON.parse(res.result);
- if(res.errMsg==='scanCode:ok'){
- that.$api.post('/device/bindAdd',{
- ...result,
- "type": "",
- "userId": 0,
- "agentId": ""
- }).then(res=>{
- if(res.data.code!==0) return that.$showToast(res.data.msg)
- that.$showToast('绑定成功')
- setTimeout(()=>{
- this.getList();
- },1500)
- })
- }
- }
- })
- },
- wifiBindDevice(){
- uni.navigateTo({
- url:'/pagesMy/deviceAdd'
- })
- },
- unbindSuccess(){
- this.getList();
- }
- }
- }
- </script>
- <style scoped lang="less">
- .page{
- background: #FFFFFF;
- padding: 0 21rpx 172rpx;
- box-sizing: border-box;
-
- .box{
- position: relative;
- width: calc(100% - 60rpx);
- background: #FFFFFF;
- box-shadow: 0rpx 4rpx 20rpx 0rpx rgba(0,0,0,0.04);
- border-radius: 32rpx;
- border: 1rpx solid #D9F159;
- box-sizing: border-box;
- }
-
- .list{
- position: relative;
- ::v-deep .u-list{
- width: 100%;
- height: 100% !important;
- }
- ::v-deep .u-list-item{
- width: 100%;
- }
- .l_box{
- width: 100%;
- padding: 49rpx 30rpx 40rpx;
- margin-top: 20rpx;
- .l_top{
- .lt_l{
- font-family: PingFang-SC, PingFang-SC;
- font-weight: bold;
- font-size: 32rpx;
- color: #111111;
- line-height: 40rpx;
- }
- .lt_r{
- image{
- width: 42rpx;
- height: 42rpx;
- margin-right: 34rpx;
- }
- .ltr_zt{
- font-family: PingFangSC, PingFang SC;
- font-weight: 400;
- font-size: 26rpx;
- line-height: 37rpx;
- padding-left: 22rpx;
- position: relative;
- &::before{
- content: '';
- width: 12rpx;
- height: 12rpx;
- border-radius: 50%;
- position: absolute;
- left: 0;
- top: 50%;
- margin-top: -6rpx;
- }
- &.zx{
- color: #1B50FF;
- &::before{
- background: #1B50FF;
- }
- }
- &.lx{
- color: #C7C7C7;
- &::before{
- background: #C7C7C7;
- }
- }
- }
- }
- }
- .l_content{
- border-top: 1rpx solid #E2E2E2;
- margin-top: 37rpx;
- padding-top: 36rpx;
- overflow: hidden;
- .lc_role{
- .lcr_l{
- width: 148rpx;
- height: 148rpx;
- border-radius: 50%;
- }
- .lcr_r{
- width: calc(100% - 148rpx);
- padding-left: 30rpx;
- box-sizing: border-box;
- p{
- font-family: PingFang-SC, PingFang-SC;
- font-weight: bold;
- font-size: 32rpx;
- color: #111111;
- line-height: 32rpx;
- overflow: hidden;
- white-space: nowrap;
- text-overflow: ellipsis;
- }
- .text{
- font-family: PingFangSC, PingFang SC;
- font-weight: 400;
- font-size: 24rpx;
- color: #7C8592;
- line-height: 24rpx;
- margin-top: 24rpx;
- }
- }
- }
- .lc_btns{
- margin-top: 62rpx;
- margin-left: -1rpx;
- overflow: hidden;
- .lcb_pre{
- width: calc(100% / 3);
- height: 37rpx;
- border-left: 1rpx solid #72832B;
- font-family: PingFang-SC, PingFang-SC;
- font-weight: bold;
- font-size: 26rpx;
- color: #72832B;
- line-height: 37rpx;
- text-align: center;
- }
- }
- }
- }
- }
-
- .empty{
- image{
- width: 64rpx;
- height: 66rpx;
- }
- p{
- font-family: PingFangSC, PingFang SC;
- font-weight: 400;
- font-size: 30rpx;
- color: #A6A6A6;
- line-height: 42rpx;
- text-align: center;
- margin-top: 30rpx;
- }
- }
-
- .btns{
- width: calc(100% - 60rpx);
- position: fixed;
- left: 20rpx;
- bottom: 64rpx;
- .zt_btn{
- width: calc(50% - 15rpx);
- }
- }
- }
- </style>
|