Quellcode durchsuchen

feat:更新代码

jinx vor 3 Jahren
Ursprung
Commit
790320f026

+ 4 - 0
src/api/sence/index.js

@@ -1,2 +1,6 @@
 import { get, post } from '@/util/http/request'
 export const senceList = (params) => post('/scene/list', params)
+export const sync4dkkSceneData = (params) => get('/scene/sync4dkkSceneData', params)
+export const renewToken = (params) => post('/token/renewToken', params)
+export const generateDefaultLiveRoom = (params) => post('/scene/generateDefaultLiveRoom', params)
+export const brandBindList = (params) => get('/brand/brandBindList', params)

+ 88 - 92
src/components/searchForm/index.vue

@@ -27,120 +27,116 @@
       <el-button type="primary"
                  @click="handleSearch">查询</el-button>
     </div>
-    <div class="buttonBox"
-         v-if="searchFormData.action">
-      <!-- <slot name="button"></slot> -->
+    <!-- <div class="buttonBox"
+         v-if="searchFormData.action"> -->
+    <div class="buttonBox">
+      <slot name="button"></slot>
 
-      <el-button @click="o.clickFun"
+      <!-- <el-button @click="o.clickFun"
                  v-for="(o,key) in searchFormData.action"
                  :key="key"
                  :type="o.type ||'success'">
         {{o.name}}
-      </el-button>
+      </el-button> -->
     </div>
 
   </div>
 </template>
 
 <script>
-import {
-  defineComponent,
-  reactive,
-  ref,
-  toRefs,
-  onMounted,
-  getCurrentInstance,
-} from 'vue'
+import { defineComponent, reactive, ref, toRefs, onMounted, getCurrentInstance } from 'vue'
 import { useRoute, useRouter } from 'vue-router'
 export default defineComponent({
-  props: {
-    searchFormData: {
-      type: Object,
-      default: {},
+    props: {
+        searchFormData: {
+            type: Object,
+            default: {},
+        },
     },
-  },
-  setup() {
-    const { ctx } = getCurrentInstance()
-    const data = reactive({
-      searchData: {},
+    setup() {
+        const { ctx } = getCurrentInstance()
+        const data = reactive({
+            searchData: {},
 
-      input: ref(''),
-      value: ref(''),
-      options: [
-        {
-          value: 'Option1',
-          label: 'Option1',
-        },
-        {
-          value: 'Option2',
-          label: 'Option2',
-        },
-        {
-          value: 'Option3',
-          label: 'Option3',
-        },
-        {
-          value: 'Option4',
-          label: 'Option4',
-        },
-        {
-          value: 'Option5',
-          label: 'Option5',
-        },
-      ],
-    })
-    onMounted(() => {
-      initSearch(ctx.searchFormData.searchList)
-    })
-    const handleSearch = () => {
-      ctx.$emit('handleSearch', data.searchData)
-    }
-    const initSearch = (list) => {
-      console.log(list.length)
-      if (list && list.length > 0) {
-        list.forEach((item, index) => {
-          data.searchData[item.model] = item.text || ''
+            input: ref(''),
+            value: ref(''),
+            options: [
+                {
+                    value: 'Option1',
+                    label: 'Option1',
+                },
+                {
+                    value: 'Option2',
+                    label: 'Option2',
+                },
+                {
+                    value: 'Option3',
+                    label: 'Option3',
+                },
+                {
+                    value: 'Option4',
+                    label: 'Option4',
+                },
+                {
+                    value: 'Option5',
+                    label: 'Option5',
+                },
+            ],
         })
-      }
-    }
-    return {
-      handleSearch,
-      ...toRefs(data),
-    }
-  },
-  components: {},
+        onMounted(() => {
+            initSearch(ctx.searchFormData.searchList)
+        })
+        const handleSearch = () => {
+            ctx.$emit('handleSearch', data.searchData)
+        }
+        const initSearch = list => {
+            // console.log(list.length)
+            if (list && list.length > 0) {
+                list.forEach((item, index) => {
+                    data.searchData[item.model] = item.text || ''
+                })
+            }
+        }
+        return {
+            handleSearch,
+            ...toRefs(data),
+        }
+    },
+    components: {},
 })
 </script>
 
 <style scoped lang="scss">
 #searchForm {
-  width: 100%;
-  height: 80px;
-  box-shadow: 0 0 12px 0 rgba(0, 0, 0, 0.1);
-  background: #fff;
-  padding: 0 20px;
-  line-height: 80px;
-  box-sizing: border-box;
-  border-radius: 3px;
-  //   display: flex;
-  //   align-items: center;
-  //   justify-content: space-between;
-  .searchBox {
-    display: flex;
-    align-items: center;
-    justify-content: flex-start;
-    float: left;
-    .inputBox {
-      width: 150px;
-      margin-right: 10px;
+    width: 100%;
+    // height: 80px;
+    // max-height: 80px;
+    box-shadow: 0 0 12px 0 rgba(0, 0, 0, 0.1);
+    background: #fff;
+    padding: 0 20px;
+    line-height: 80px;
+    box-sizing: border-box;
+    border-radius: 3px;
+    // display: flex;
+    // align-items: center;
+    // justify-content: space-between;
+    overflow: hidden;
+    .searchBox {
+        display: flex;
+        align-items: center;
+        justify-content: flex-start;
+        float: left;
+        .inputBox {
+            width: 150px;
+            margin-right: 10px;
+        }
+        .selectBox {
+            width: 150px;
+            margin-right: 10px;
+        }
     }
-    .selectBox {
-      width: 150px;
-      margin-right: 10px;
+    .buttonBox {
+        float: right;
     }
-  }
-  .buttonBox {
-    float: right;
-  }
 }
 </style>

+ 135 - 141
src/components/tableForm/index.vue

@@ -1,71 +1,69 @@
 <template>
   <div id="dataBox">
     <searchForm v-if="searchFormData"
-                :searchFormData="searchFormData"
+                :searchFormData="searchFormData ||[]"
                 @handleSearch="handleSearch">
-      <!-- <template #button>
-        <slot name="button">
 
-        </slot>
+      <template #button>
+        <slot name="button"></slot>
+      </template>
 
-      </template> -->
     </searchForm>
     <div id="tableForm">
       <div class="tableContent">
         <el-table v-loading="loading"
                   :data="tableData"
                   style="width: 100%">
-          <el-table-column v-for="(item, i) in tableHeader"
-                           :key="i"
-                           :prop="item.prop"
-                           :label="item.label"
-                           :width="item.width"
-                           :filters="item.filters"
-                           :column-key="item.columnKey"
-                           :filtered-value="item.filteredValue"
-                           :filter-multiple="item.filterMultiple"
-                           :align="item.center || 'center'">
-            <!-- <slot name="column">
+          <template v-for="(item, i) in tableHeader"
+                    :key="i">
+            <el-table-column v-if="!item.hidden"
+                             :prop="item.prop"
+                             :label="item.label"
+                             :width="item.width"
+                             :filters="item.filters"
+                             :column-key="item.columnKey"
+                             :filtered-value="item.filteredValue"
+                             :filter-multiple="item.filterMultiple"
+                             :align="item.center || 'center'">
+              <!-- <slot name="column">
           </slot> -->
-            <template #default="scope">
-              <v-solt v-if="item.render"
-                      :render="item.render"
-                      :row="scope.row"
-                      :index="scope.$index"
-                      :column="item"></v-solt>
-              <div v-else-if="item.action">
-                <el-link :underline="o.underline || false"
-                         href="javascripy:;"
-                         @click="o.clickFun(scope.$index,scope.row)"
-                         v-for="(o,key) in item.action"
-                         :key="key"
-                         :type="o.type ||'primary'">
-                  {{o.name}}
-                </el-link>
-              </div>
-              <span v-else>{{scope.row[item.prop] || '-'}}</span>
-            </template>
-          </el-table-column>
+              <template #default="scope">
+                <v-solt v-if="item.render"
+                        :render="item.render"
+                        :row="scope.row"
+                        :index="scope.$index"
+                        :column="item"></v-solt>
+                <div v-else-if="item.action">
+                  <el-link :underline="o.underline || false"
+                           href="javascripy:;"
+                           @click="o.clickFun(scope.$index,scope.row)"
+                           v-for="(o,key) in item.action"
+                           :key="key"
+                           :type="o.type ||'primary'">
+                    {{o.name}}
+                  </el-link>
+                </div>
 
+                <span v-else>{{scope.row[item.prop] || '-'}}</span>
+              </template>
+            </el-table-column>
+          </template>
+
+          <slot name="action"
+                :data="loading">
+          </slot>
         </el-table>
       </div>
-      <div class="paginationBox">
+      <div class="
+                paginationBox">
 
-        <el-pagination v-model:currentPage="currentPage2"
-                       layout="prev, pager, next"
+        <el-pagination v-model:currentPage="currentPage"
+                       layout="sizes,prev, pager, next"
                        :page-sizes="sizes"
                        :page-size="sizes[0]"
-                       :total="pageInfo.total || 100"
+                       :total="100"
                        @size-change="handleSizeChange"
                        @current-change="handlePageChange"></el-pagination>
-        <!-- <el-pagination v-model:currentPage="currentPage2"
-                       :page-sizes="sizes"
-                       :page-size="sizes[0]"
-                       layout="prev, pager, next"
-                       :total="pageInfo.total"
-                       @size-change="handleSizeChange"
-                       @current-change="handlePageChange">
-        </el-pagination> -->
 
       </div>
     </div>
@@ -74,114 +72,110 @@
 </template>
 
 <script>
-import {
-  defineComponent,
-  reactive,
-  ref,
-  toRefs,
-  onMounted,
-  getCurrentInstance,
-} from 'vue'
+import { defineComponent, reactive, ref, toRefs, onMounted, getCurrentInstance } from 'vue'
 import { useRoute, useRouter } from 'vue-router'
 import searchForm from '@/components/searchForm/index.vue'
 import vSolt from './vSolt.vue'
 export default defineComponent({
-  // props: ['dataApi', 'tableHeader'],
-  props: {
-    handleSearch: Function,
-    handleSizeChange: Function,
-    handlePageChange: Function,
-    config: {
-      type: Object,
-      default: function () {
-        return null
-      },
-    },
-    tableHeader: Array,
-    tableData: {
-      type: Array,
-      default: function () {
-        return []
-      },
-    },
-    searchFormData: {
-      type: Object,
-      default: function () {
-        return null
-      },
+    // props: ['dataApi', 'tableHeader'],
+    props: {
+        handleSearch: Function, //搜索方法
+        handleSizeChange: Function, //size方法
+        handlePageChange: Function, //页码方法
+        config: {
+            type: Object,
+            default: function () {
+                return null
+            },
+        },
+        tableHeader: Array, //表格头部配置
+        tableData: {
+            //表格数据
+            type: Array,
+            default: function () {
+                return []
+            },
+        },
+        searchFormData: {
+            //搜索头部配置
+            type: Object,
+            default: function () {
+                return null
+            },
+        },
+        pageInfo: {
+            //分页相关配置
+            type: Object,
+            default: function () {
+                return null
+            },
+        },
+        loading: {
+            type: Boolean,
+            default: false,
+        },
     },
-    pageInfo: {
-      type: Object,
-      default: function () {
-        return null
-      },
-    },
-    loading: {
-      type: Boolean,
-      default: false,
-    },
-  },
-  setup(props, context) {
-    const { ctx } = getCurrentInstance()
-    const data = reactive({
-      sizes: [10, 30, 50, 100],
-      currentPage2: ref(1),
-      // tableData: [],
-      pageParam: {
-        limit: 10,
-        nd: 1635487948418,
-        order: 'asc',
-        page: 1,
-        sidx: '',
-        token: localStorage.getItem('token'),
-        _search: false,
-      },
-    })
-    onMounted(() => {
-      // handleTableData()
-    })
-    const handleTableData = () => {
-      props
-        .dataApi(data.pageParam)
-        .then((res) => {
-          console.log(res)
-          data.tableData = res.page.list
+    setup(props, context) {
+        const { ctx } = getCurrentInstance()
+        const data = reactive({
+            sizes: [10, 30, 50, 100],
+            currentPage: ref(1),
+            // tableData: [],
+            pageParam: {
+                limit: 10,
+                nd: 1635487948418,
+                order: 'asc',
+                page: 1,
+                sidx: '',
+                token: localStorage.getItem('token'),
+                _search: false,
+            },
         })
-        .catch((err) => {})
-    }
+        onMounted(() => {
+            // handleTableData()
+        })
+        const handleTableData = () => {
+            props
+                .dataApi(data.pageParam)
+                .then(res => {
+                    console.log(res)
+                    data.tableData = res.page.list
+                })
+                .catch(err => {})
+        }
 
-    return {
-      ...toRefs(data),
-    }
-  },
-  components: { searchForm, vSolt },
+        return {
+            ...toRefs(data),
+        }
+    },
+    components: { searchForm, vSolt },
 })
 </script>
 
 <style lang="scss">
 #tableForm {
-  margin-top: 20px;
-  box-shadow: 0 0 12px 0 rgba(0, 0, 0, 0.1);
-  border-radius: 4px;
-  background: #fff;
-  overflow: hidden;
-  padding: 20px;
-  box-sizing: border-box;
-  .el-table {
-    .cell {
-      display: flex;
-      align-items: center;
-      justify-content: center;
-      .el-link {
-        margin-right: 5px;
-      }
+    margin-top: 20px;
+    box-shadow: 0 0 12px 0 rgba(0, 0, 0, 0.1);
+    border-radius: 4px;
+    background: #fff;
+    overflow: hidden;
+    padding: 20px;
+    box-sizing: border-box;
+    .el-table {
+        .cell {
+            display: flex;
+            align-items: center;
+            justify-content: center;
+            .el-link {
+                margin-right: 5px;
+            }
+        }
     }
-  }
 }
 .paginationBox {
-  display: flex;
-  align-items: center;
-  justify-content: flex-end;
-  margin-top: 20px;
+    display: flex;
+    align-items: center;
+    justify-content: flex-end;
+    margin-top: 20px;
 }
 </style>

+ 73 - 77
src/layout/content/components/topbar.vue

@@ -3,7 +3,7 @@
     <div class="navTitle">{{ title }}</div>
 
     <div class="accountMsg">
-      <div class="name"><i class="fa fa-user"></i>项王装饰</div>
+      <div class="name"><i class="fa fa-user"></i>{{userName}}</div>
       <div class="password">
         <i class="fa fa-lock"></i>
         修改密码
@@ -17,97 +17,93 @@
 </template>
 
 <script>
-import {
-  defineComponent,
-  reactive,
-  ref,
-  toRefs,
-  onMounted,
-  getCurrentInstance,
-  computed,
-} from 'vue'
+import { defineComponent, reactive, ref, toRefs, onMounted, getCurrentInstance, computed } from 'vue'
 import { useRoute, useRouter } from 'vue-router'
 import { ElMessage } from 'element-plus'
 import confirm from '@/components/confirm'
 import { useStore } from 'vuex'
 export default defineComponent({
-  setup() {
-    const store = useStore()
-    const router = useRouter()
-    const route = useRoute()
-    const data = reactive({
-      // title: store.state.navTitle,
-    })
-    const title = computed(() => {
-      return store.state.navTitle
-    })
-
-    const logout = async () => {
-      let res = await confirm({
-        title: '注:您确定要安全退出本次登录吗?',
-      })
-      if (res) {
-        store.commit('removeUserInfo')
-        store.commit('removeToken')
-        router.push('/login')
-        ElMessage({
-          type: 'success',
-          message: '退出成功',
+    setup() {
+        const { ctx } = getCurrentInstance()
+        const store = useStore()
+        const router = useRouter()
+        const route = useRoute()
+        const data = reactive({
+            userName: JSON.parse(localStorage.getItem('userInfo')).username,
+            // title: store.state.navTitle,
+        })
+        const title = computed(() => {
+            return store.state.navTitle
         })
-      }
-    }
 
-    return {
-      logout,
-      title,
-      ...toRefs(data),
-    }
-  },
-  components: {},
+        const logout = async () => {
+            let res = await confirm({
+                title: '注:您确定要安全退出本次登录吗?',
+            })
+            if (res) {
+                store.commit('removeUserInfo')
+                store.commit('removeToken')
+                router.push('/login')
+                ElMessage({
+                    type: 'success',
+                    message: '退出成功',
+                })
+            }
+        }
+        onMounted(() => {
+            // data.userName = JSON.parse(localStorage.getItem('userInfo')).username
+        })
+        return {
+            logout,
+            title,
+            ...toRefs(data),
+        }
+    },
+    components: {},
 })
 </script>
 
 <style scoped lang="scss">
 #topBar {
-  width: 100%;
-  height: 60px;
-  box-shadow: 0 0 12px 0 rgba(0, 0, 0, 0.1);
-  background: #fff;
-  padding: 0 20px;
-  line-height: 60px;
-  box-sizing: border-box;
-  display: flex;
-  align-items: center;
-  justify-content: space-between;
-  z-index: 10;
-  position: relative;
-  .navTitle {
-    font-size: 18px;
-    color: #666;
-  }
-  .accountMsg {
+    width: 100%;
+    height: 60px;
+    box-shadow: 0 0 12px 0 rgba(0, 0, 0, 0.1);
+    background: #fff;
+    padding: 0 20px;
+    line-height: 60px;
+    box-sizing: border-box;
     display: flex;
     align-items: center;
-    justify-content: center;
-    > div {
-      margin-left: 10px;
-      cursor: pointer;
-      color: #999c9e;
-      font-size: 14px;
-      &:first-of-type {
-        cursor: default;
-        &:hover {
-          color: #999c9e;
+    justify-content: space-between;
+    z-index: 10;
+    position: relative;
+    .navTitle {
+        font-size: 18px;
+        color: #666;
+    }
+    .accountMsg {
+        display: flex;
+        align-items: center;
+        justify-content: center;
+        > div {
+            margin-left: 10px;
+            cursor: pointer;
+            color: #999c9e;
+            font-size: 14px;
+            &:first-of-type {
+                cursor: default;
+                &:hover {
+                    color: #999c9e;
+                }
+            }
+            &:hover {
+                color: #409eff;
+            }
+            // margin-right: 5px;
+            > i {
+                margin-right: 2px;
+            }
         }
-      }
-      &:hover {
-        color: #409eff;
-      }
-      // margin-right: 5px;
-      > i {
-        margin-right: 2px;
-      }
     }
-  }
 }
 </style>

+ 81 - 67
src/layout/login/login.vue

@@ -1,7 +1,11 @@
 <template>
   <div id="login">
     <el-button type="primary"
-               @click="login">登录</el-button>
+               @click="login(1)">超级管理员登录</el-button>
+    <el-button type="primary"
+               @click="login(2)">管理员登录</el-button>
+    <el-button type="primary"
+               @click="login(3)">员工登录</el-button>
     <input v-model="captcha"
            type=""
            name="" />
@@ -18,78 +22,88 @@ import { useStore } from 'vuex'
 import { Base64 } from 'js-base64'
 import { loginapi, menuList, infoAnon } from '@/api/api'
 import { encodeStr } from '@/util/common'
+import { ElMessageBox, ElMessage } from 'element-plus'
 import { setLocalStorage } from '@/util/browser'
 export default defineComponent({
-  name: 'login',
-  components: {},
-  setup(props, ctx) {
-    const store = useStore()
-    const router = useRouter()
-    const route = useRoute()
-    // console.log(route)
-    // console.log(router)
-    const data = reactive({
-      show: false,
-      username: '18819272208',
-      password: 'zfb123456',
-      //   captcha: "",
-    })
-    console.log(data)
-    const login = () => {
-      data.show = true
-      console.log(data.show)
-      // let params = {
-      //   username: data.username,
-      //   password: encodeStr(Base64.encode(data.password)),
-      //   // password: data.password,
-      //   captcha: data.captcha,
-      // };
-      let params = new FormData()
-      params.append('username', import.meta.env.VITE_USER_NAME)
-      params.append(
-        'password',
-        encodeStr(Base64.encode(import.meta.env.VITE_PASS_WORD))
-      )
+    name: 'login',
+    components: {},
+    setup(props, ctx) {
+        const store = useStore()
+        const router = useRouter()
+        const route = useRoute()
+        // console.log(route)
+        // console.log(router)
+        const data = reactive({
+            show: false,
+            username: '18819272208',
+            password: 'zfb123456',
+            //   captcha: "",
+        })
+        console.log(data)
+        const login = type => {
+            data.show = true
+            console.log(data.show)
+            // let params = {
+            //   username: data.username,
+            //   password: encodeStr(Base64.encode(data.password)),
+            //   // password: data.password,
+            //   captcha: data.captcha,
+            // };
+            let user
+            if (type == 1) {
+                user = import.meta.env.VITE_USER_NAME
+            } else if (type == 2) {
+                user = import.meta.env.VITE_USER_NAME1
+            } else {
+                user = import.meta.env.VITE_USER_NAME2
+            }
+            let params = new FormData()
+            params.append('username', user)
+            params.append('password', encodeStr(Base64.encode(import.meta.env.VITE_PASS_WORD)))
 
-      loginapi(params)
-        .then((res) => {
-          console.log(res)
+            loginapi(params)
+                .then(res => {
+                    console.log(res)
 
-          store.commit('setToken', res.token)
-          router.push('/home')
-          infoAnon(res.user.userId)
-            .then((res) => {
-              console.log(res)
-              store.commit('setUserInfo', res.user)
-            })
-            .catch((err) => {})
-          menuList()
-            .then((res) => {
-              if (res.code == 0) {
-                console.log(res)
-                store.commit('setMenuList', res.menuList)
-                console.log(store.state.menuList)
-              } else {
-              }
-              // store.commit('setToken', res.token)
-            })
-            .catch((err) => {})
-        })
-        .catch((err) => {
-          console.log(params)
-          console.log(err)
-        })
-    }
+                    store.commit('setToken', res.token)
+                    infoAnon(res.user.userId)
+                        .then(res => {
+                            // console.log(res)
+                            store.commit('setUserInfo', res.user)
+                            router.push('/home')
+                            ElMessage({
+                                type: 'success',
+                                message: '登录成功',
+                            })
+                        })
+                        .catch(err => {})
+                    menuList()
+                        .then(res => {
+                            if (res.code == 0) {
+                                console.log(res)
+                                store.commit('setMenuList', res.menuList)
+                                // console.log(store.state.menuList)
+                            } else {
+                            }
+                            // store.commit('setToken', res.token)
+                        })
+                        .catch(err => {})
+                })
+                .catch(err => {
+                    console.log(params)
+                    console.log(err)
+                })
+        }
 
-    onMounted(() => {
-      //   wenben.value.style = "display:none;";
-    })
+        onMounted(() => {
+            //   wenben.value.style = "display:none;";
+        })
 
-    return {
-      login,
-      ...toRefs(data),
-    }
-  },
+        return {
+            login,
+            ...toRefs(data),
+        }
+    },
 })
 </script>
 

+ 0 - 1
src/main.js

@@ -8,7 +8,6 @@ import router from './router'
 import store from './store'
 import authDirective from '@/util/directive'
 import injectIcon from '@/components/icon'
-console.log(import.meta.env.VITE_USER_NAME)
 const app = createApp(App)
 // app.component('edit',Edit)
 authDirective(app, store)

+ 1 - 0
src/store/actions.js

@@ -2,6 +2,7 @@ const actions = {
     setUserInfo(vuex, v) {
         console.log('进来了')
         vuex.commit('setUserInfo', v)
+        window.localStorage.setItem('userInfo',JSON.stringify(v))
     },
 }
 export default actions

+ 8 - 2
src/util/http/http.js

@@ -1,5 +1,6 @@
 import axios from 'axios'
 import router from '@/router' // 创建axios
+import {  ElMessage } from 'element-plus'
 const service = axios.create({
     baseURL: '/',
     timeout: 30000,
@@ -21,8 +22,13 @@ service.interceptors.request.use(function (config) {
 // 添加响应拦截器
 service.interceptors.response.use(function (response) {
     // 对响应数据做点什么
-    console.log('res', response);
-
+    // console.log('res', response);
+     if(response.data.code==500){
+      ElMessage({
+          type: 'error',
+          message: response.data.msg,
+      })
+    }
     return response;
 }, function (error) {
     // 对响应错误做点什么

+ 150 - 9
src/views/live/live.vue

@@ -1,18 +1,159 @@
 <template>
-  <div id="page">live</div>
+  <div id="page">
+    <tableForm :loading="loading"
+               :tableData="tableData"
+               :tableHeader="tableHeader"
+               :searchFormData="searchFormData"
+               :pageInfo="pageInfo"
+               :handleSearch="handleSearch"
+               @handleSizeChange="handleSizeChange">
+      <template #button>
+        <el-button type="success">新增</el-button>
+      </template>
+    </tableForm>
+  </div>
 </template>
 
 <script>
-import { defineComponent, reactive, ref, toRefs, onMounted } from 'vue'
+import { defineComponent, reactive, ref, toRefs, onMounted, h } from 'vue'
 import { useRoute, useRouter } from 'vue-router'
+import tableForm from '@/components/tableForm/index.vue'
+import { brandBindList } from '@/api/sence'
 export default defineComponent({
-  setup() {
-    const data = reactive()
-    return {
-      ...toRefs(data),
-    }
-  },
-  components: {},
+    setup() {
+        const data = reactive({
+            loading: false,
+            tableData: [],
+            pageInfo: {},
+            userInfo: JSON.parse(localStorage.getItem('userInfo')),
+            pageParam: {
+                deptId: JSON.parse(localStorage.getItem('userInfo')).deptId,
+                limit: 10,
+                page: 1,
+            },
+        })
+        const searchFormData = ref({
+            formData: {},
+            searchList: [
+                {
+                    type: 'input',
+                    model: 'input_data',
+                    inputType: 'text',
+                    placeholder: '场景名称',
+                },
+                {
+                    type: 'select',
+                    model: 'select2',
+                    inputType: 'text',
+                    placeholder: '场景名称',
+                },
+                {
+                    type: 'select',
+                    model: 'select1',
+                    inputType: 'text',
+                    placeholder: '场景名称',
+                },
+            ],
+        })
+        const tableHeader = ref([
+            { prop: 'name', label: '直播间名称' },
+            { prop: 'type', label: '类型' },
+            { prop: 'sceneName', label: '场景名称' },
+            { prop: 'liveRoomUrl', label: '场景链接' },
+            {
+                prop: 'appListPicUrl',
+                label: '封面',
+                render: params => {
+                    // console.log(params.row.thumb)
+                    if (params.row.appListPicUrl == '' || !params.row.appListPicUrl) {
+                        return h('img', {
+                            style: {
+                                width: '100px',
+                                height: '100px',
+                            },
+                            src: '/src/assets/img/no_bg.png',
+                        })
+                    } else {
+                        return h('img', {
+                            style: {
+                                width: '100px',
+                                height: '100px',
+                            },
+                            src: params.row.appListPicUrl,
+                        })
+                    }
+                },
+            },
+            { prop: 'bindShowerNameList', label: '已绑定主播' },
+            {
+                prop: 'livestreamStatus',
+                label: '是否开播',
+                render: params => {
+                    if (params.row.livestreamStatus == 0) {
+                        return h(
+                            'span',
+                            {
+                                style: {
+                                    fontSize: '10px',
+                                    fontWeight: 600,
+                                    backgroundColor: ' #ed5565',
+                                    color: '#FFFFFF',
+                                    padding: '3px 8px',
+                                },
+                            },
+                            '否'
+                        )
+                    } else {
+                        return h(
+                            'span',
+                            {
+                                style: {
+                                    fontSize: '10px',
+                                    fontWeight: 600,
+                                    backgroundColor: ' #409EFF',
+                                    color: '#FFFFFF',
+                                    padding: '3px 8px',
+                                },
+                            },
+                            '是'
+                        )
+                    }
+                },
+            },
+        ])
+        onMounted(() => {
+            getLiveList()
+        })
+        const handleSearch = res => {
+            console.log('handleSearch', res)
+        }
+        const handleSizeChange = () => {}
+        const getLiveList = async () => {
+            data.loading = true
+            try {
+                let res = await brandBindList(data.pageParam)
+                data.loading = false
+                if (res.code == 0) {
+                    console.log(res)
+                    data.tableData = res.list
+
+                    console.log(data.tableData)
+                    data.pageInfo = res
+                }
+            } catch (err) {
+                data.loading = false
+            }
+        }
+        return {
+            handleSizeChange,
+            getLiveList,
+            tableHeader,
+            searchFormData,
+            handleSearch,
+            ...toRefs(data),
+        }
+    },
+    components: { tableForm },
 })
 </script>
 

+ 127 - 47
src/views/sence/sence.vue

@@ -11,18 +11,39 @@
                :handlePageChange="handlePageChange"
                :handleSizeChange="handleSizeChange">
 
-      <!-- <template #button>
-        <el-button type="success">新增</el-button>
-      </template> -->
+      <template #button>
+        <el-button type="success"
+                   @click="syncScene">同步场景</el-button>
+      </template>
 
-      <!-- <template #column>
+      <template #action>
         <el-table-column label="操作"
                          align="center">
-          <el-link type="primary">绑定主播</el-link>
-          <el-link type="success">编辑</el-link>
-          <el-link type="danger">删除</el-link>
+          <template #default="scope">
+            <div>
+
+              <!-- <el-link :underline="false"
+                       @click='hanldeDelRow(scope)'
+                       type="danger">删除</el-link> -->
+
+              <el-link :underline="false"
+                       @click="editRow(scope)"
+                       type="primary">修改</el-link>
+              <el-link v-auths="[6,8]"
+                       :underline="false"
+                       @click="openFdkk(scope)"
+                       type="primary">打开编辑器</el-link>
+              <el-link v-auths="[6,8]"
+                       v-if="!scope.row.lived"
+                       :underline="false"
+                       @click="toLive(scope)"
+                       type="primary">生成直播间</el-link>
+            </div>
+
+          </template>
+
         </el-table-column>
-      </template> -->
+      </template>
     </tableForm>
 
     <!-- 弹窗 -->
@@ -34,7 +55,8 @@
       <el-form label-width="140px"
                :model="editData">
         <el-form-item label="场景名称">
-          <el-input v-model="editData.sceneName"></el-input>
+          <el-input disabled
+                    v-model="editData.sceneName"></el-input>
         </el-form-item>
         <el-form-item label="封面">
           <div class="picBox">
@@ -74,9 +96,9 @@
 
       <template #footer>
         <span class="dialog-footer">
-          <el-button @click="dialogVisible = false">取消</el-button>
+          <el-button @click="handleClose">取消</el-button>
           <el-button type="primary"
-                     @click="dialogVisible = false">确认</el-button>
+                     @click="handleCommit">确认</el-button>
         </span>
       </template>
     </el-dialog>
@@ -86,15 +108,16 @@
 <script>
 import { defineComponent, reactive, ref, toRefs, onMounted, getCurrentInstance, h } from 'vue'
 import { useRoute, useRouter } from 'vue-router'
-import { ElMessageBox } from 'element-plus'
+import { ElMessageBox, ElMessage } from 'element-plus'
 import tableForm from '@/components/tableForm/index.vue'
-import { senceList } from '@/api/sence'
+import { senceList, sync4dkkSceneData, renewToken, generateDefaultLiveRoom } from '@/api/sence'
 // import { Edit } from '@element-plus/icons'
 export default defineComponent({
     components: { tableForm },
     setup(props) {
         const { ctx } = getCurrentInstance()
         const data = reactive({
+            userInfo: JSON.parse(localStorage.getItem('userInfo')),
             radio1: '1',
             editData: {},
             loading: true,
@@ -131,8 +154,51 @@ export default defineComponent({
             //   },
             // ],
         })
+        const toLive = scope => {
+            console.log(scope.row)
+
+            ElMessageBox.confirm('是否要生成直播间?', {
+                confirmButtonText: '确认',
+                cancelButtonText: '取消',
+            })
+                .then(async () => {
+                    let token = localStorage.getItem('token')
+                    let params = {
+                        sceneNum: scope.row.num,
+                        token: token,
+                    }
+                    let res = await generateDefaultLiveRoom(params)
+                    console.log(res)
+                    if (res.code == 0) {
+                        handleTableData()
+
+                        ElMessage({
+                            type: 'success',
+                            message: '操作成功',
+                        })
+                    }
+                })
+                .catch(() => {
+                    // catch error
+                })
+        }
+        const openFdkk = async scope => {
+            console.log(scope.row)
+            let token = localStorage.getItem('token')
+            let params = {
+                sceneNum: scope.row.num,
+                token: token,
+                userName: data.userInfo.mobile,
+            }
+
+            let res = await renewToken(params)
+        }
         const handleClose = () => {
-            console.log('handleClose')
+            data.editData = {}
+            data.dialogVisible = false
+        }
+        const handleCommit = () => {
+            handleClose()
         }
         const tableHeader = ref([
             { prop: 'sceneName', label: '场景名称' },
@@ -186,34 +252,35 @@ export default defineComponent({
                     }
                 },
             },
-            {
-                // prop: 'action',
-                label: '操作',
-                action: [
-                    {
-                        name: '修改',
-                        type: 'danger',
-                        clickFun: (index, row) => {
-                            // console.log(index, row)
-                            editRow(index, row)
-                        },
-                    },
-                    {
-                        name: '打开编辑器',
-                        type: 'success',
-                        clickFun: (index, row) => {
-                            console.log(index, row)
-                        },
-                    },
-                    {
-                        name: '生成直播间',
-                        clickFun: (index, row) => {
-                            console.log(index, row)
-                            hanldeDelRow(index, row)
-                        },
-                    },
-                ],
-            },
+            // {
+            //     // prop: 'action',
+            //     label: '操作',
+            //     hidden: JSON.parse(localStorage.getItem('userInfo')).roleIdList[0] == 5,
+            //     action: [
+            //         {
+            //             name: '修改',
+            //             type: 'danger',
+            //             clickFun: (index, row) => {
+            //                 // console.log(index, row)
+            //                 editRow(index, row)
+            //             },
+            //         },
+            //         {
+            //             name: '打开编辑器',
+            //             type: 'success',
+            //             clickFun: (index, row) => {
+            //                 console.log(index, row)
+            //             },
+            //         },
+            //         {
+            //             name: '生成直播间',
+            //             clickFun: (index, row) => {
+            //                 console.log(index, row)
+            //                 hanldeDelRow(index, row)
+            //             },
+            //         },
+            //     ],
+            // },
         ])
         const tableData = ref([])
 
@@ -249,32 +316,45 @@ export default defineComponent({
             data.pageInfo = res.page
             console.log(tableData)
         }
-        const editRow = (index, row) => {
+        const editRow = scope => {
+            console.log(scope)
             data.dialogVisible = true
 
-            data.editData = JSON.parse(JSON.stringify(row))
+            data.editData = JSON.parse(JSON.stringify(scope.row))
             console.log(data.editData)
         }
-        const hanldeDelRow = (index, row) => {
-            ElMessageBox.confirm('是否删除数据?', {
+        const hanldeDelRow = scope => {
+            ElMessageBox.confirm('是否删除数据?', {
                 confirmButtonText: '确认',
                 cancelButtonText: '取消',
             })
                 .then(() => {
-                    tableData.value.splice(index, 1)
+                    tableData.value.splice(scope.$index, 1)
                 })
                 .catch(() => {
                     // catch error
                 })
         }
+
+        const syncScene = async () => {
+            let res = await sync4dkkSceneData()
+            console.log(res)
+        }
+
         return {
             handleSizeChange,
             handlePageChange,
             handleSearch,
             handleTableData,
             handleClose,
+            handleCommit,
             tableHeader,
             tableData,
+            editRow,
+            hanldeDelRow,
+            syncScene,
+            openFdkk,
+            toLive,
             searchFormData,
             ...toRefs(data),
         }

+ 4 - 0
vite.config.js

@@ -67,6 +67,10 @@ export default defineConfig({
         target: 'http://192.168.0.47:8190',
         changeOrigin: true,
       },
+      '/brand': {
+        target: 'http://192.168.0.47:8190',
+        changeOrigin: true,
+      },
     },
 
     //proxy: {