Parcourir la source

Merge branch 'master' of http://git.cc-lotus.info/zkzx/zkzx_web

YY il y a 1 an
Parent
commit
ee1ff44340
3 fichiers modifiés avec 117 ajouts et 7 suppressions
  1. 60 4
      src/views/channel/index.vue
  2. 56 2
      src/views/live/index.vue
  3. 1 1
      src/views/login/index.vue

+ 60 - 4
src/views/channel/index.vue

@@ -58,20 +58,30 @@
         </div>
       </el-col>
     </el-row>
+    <cDialog :dialog="dialog" @handleClose="toClose">
+      <template v-slot:info>
+        <el-col :span="24" class="dialog_one" v-if="dialog.type == '1'">
+          <cForm :span="24" :fields="fields" :form="form" :rules="rules" @save="toSave" submitText="提交登录"> </cForm>
+        </el-col>
+      </template>
+    </cDialog>
   </div>
 </template>
 
 <script setup lang="ts">
 // 基础
 import type { Ref } from 'vue';
-// reactive,
-import { onMounted, ref } from 'vue';
+import { onMounted, ref, reactive } from 'vue';
+import type { FormRules } from 'element-plus';
+import { ElMessage } from 'element-plus';
 // 接口
 import { TrainStore } from '@common/src/stores/allAdmin/train';
 import { ChannelStore } from '@common/src/stores/allAdmin/channel';
+import { TokenStore } from '@common/src/stores/user/token'; // 解析
 import type { IQueryResult } from '@/util/types.util';
 const channel = ChannelStore();
 const train = TrainStore();
+const tokenAxiso = TokenStore();
 // 加载中
 const loading: Ref<any> = ref(false);
 const activeNames: Ref<any> = ref(['1', '2']);
@@ -79,6 +89,19 @@ const science: Ref<any> = ref([]); // 科技频道
 const trainLiat: Ref<any> = ref([]); // 培训问诊
 const src: Ref<any> = ref('/src/assets/channel-1.jpg');
 const url: Ref<any> = ref('/src/assets/channel-3.jpg');
+
+// 弹框
+const dialog: Ref<any> = ref({ type: '1', show: false, title: '信息管理' });
+let form: Ref<any> = ref({});
+// 表单
+let fields: Ref<any[]> = ref([
+  { label: '房间号', model: 'room_id', options: { disabled: true } },
+  { label: '密码', model: 'password', type: 'password' }
+]);
+const rules = reactive<FormRules>({
+  password: [{ required: true, message: '请输入账号密码', trigger: 'blur' }]
+});
+
 // 请求
 onMounted(async () => {
   loading.value = true;
@@ -103,8 +126,41 @@ const search = async () => {
   }
 };
 const toLogin = (e, value) => {
-  console.log(value);
-  console.log(e);
+  let object: any = { room_id: e.room_id, type: value };
+  form.value = object;
+  dialog.value = { title: '展会登录', show: true, type: '1' };
+};
+// 提交登录
+const toSave = async (data) => {
+  let res: IQueryResult;
+  let type = data.type;
+  delete data.type;
+  if (type == '1') res = await channel.login(data);
+  else if (type == '2') res = await train.login(data);
+  if (res.errcode == '0') {
+    ElMessage({ message: '登录成功', type: 'success' });
+    localStorage.setItem('token', `${res.data}`);
+    // 解析token跳转页面
+    tokenView();
+  } else {
+    ElMessage({ message: `${res.errmsg}`, type: 'error' });
+  }
+};
+const tokenView = async () => {
+  let res: IQueryResult = await tokenAxiso.tokenInfo();
+  if (res.errcode == '0') {
+    // let user = res.data as any;
+    let env = import.meta.env.VITE_APP_ENV;
+    let path = '';
+    if (env == 'development') path = 'http://localhost:8004/zkzxlive';
+    else path = '/zkzxlive';
+    window.open(path);
+  }
+};
+// 弹框关闭
+const toClose = () => {
+  form.value = {};
+  dialog.value = { title: '展会登录', show: false, type: '1' };
 };
 const toJump = (e) => {
   console.log(e);

+ 56 - 2
src/views/live/index.vue

@@ -89,6 +89,13 @@
         </div>
       </el-col>
     </el-row>
+    <cDialog :dialog="dialog" @handleClose="toClose">
+      <template v-slot:info>
+        <el-col :span="24" class="dialog_one" v-if="dialog.type == '1'">
+          <cForm :span="24" :fields="fields" :form="form" :rules="rules" @save="toSave" submitText="提交登录"> </cForm>
+        </el-col>
+      </template>
+    </cDialog>
   </div>
 </template>
 
@@ -96,11 +103,15 @@
 // 基础
 import type { Ref } from 'vue';
 // reactive,
-import { onMounted, ref } from 'vue';
+import { onMounted, ref, reactive } from 'vue';
+import type { FormRules } from 'element-plus';
+import { ElMessage } from 'element-plus';
 // 接口
 import { DockStore } from '@common/src/stores/allAdmin/dock';
+import { TokenStore } from '@common/src/stores/user/token'; // 解析
 import type { IQueryResult } from '@/util/types.util';
 const dock = DockStore();
+const tokenAxiso = TokenStore();
 // 加载中
 const loading: Ref<any> = ref(false);
 const activeNames: Ref<any> = ref('1');
@@ -109,6 +120,18 @@ const endscience: Ref<any> = ref([]); // 结束
 const nextList: Ref<any> = ref([]); // 准备
 const src: Ref<any> = ref('/src/assets/live-1.jpg');
 
+// 弹框
+const dialog: Ref<any> = ref({ type: '1', show: false, title: '信息管理' });
+let form: Ref<any> = ref({});
+// 表单
+let fields: Ref<any[]> = ref([
+  { label: '房间号', model: 'room_id', options: { disabled: true } },
+  { label: '密码', model: 'password', type: 'password' }
+]);
+const rules = reactive<FormRules>({
+  password: [{ required: true, message: '请输入账号密码', trigger: 'blur' }]
+});
+
 // 请求
 onMounted(async () => {
   loading.value = true;
@@ -152,8 +175,39 @@ const search = async () => {
     endscience.value = data;
   }
 };
+// 管理登录
 const toLogin = (e) => {
-  console.log(e);
+  let object: any = { room_id: e.room_id };
+  form.value = object;
+  dialog.value = { title: '展会登录', show: true, type: '1' };
+};
+// 提交登录
+const toSave = async (data) => {
+  let res: IQueryResult = await dock.login(data);
+  if (res.errcode == '0') {
+    ElMessage({ message: '登录成功', type: 'success' });
+    localStorage.setItem('token', `${res.data}`);
+    // 解析token跳转页面
+    tokenView();
+  } else {
+    ElMessage({ message: `${res.errmsg}`, type: 'error' });
+  }
+};
+const tokenView = async () => {
+  let res: IQueryResult = await tokenAxiso.tokenInfo();
+  if (res.errcode == '0') {
+    // let user = res.data as any;
+    let env = import.meta.env.VITE_APP_ENV;
+    let path = '';
+    if (env == 'development') path = 'http://localhost:8004/zkzxlive';
+    else path = '/zkzxlive';
+    window.open(path);
+  }
+};
+// 弹框关闭
+const toClose = () => {
+  form.value = {};
+  dialog.value = { title: '展会登录', show: false, type: '1' };
 };
 const toJump = (e) => {
   console.log(e);

+ 1 - 1
src/views/login/index.vue

@@ -74,7 +74,7 @@ import { AdminStore } from '@common/src/stores/admins/admin'; // 管理员
 import { PersonalStore } from '@common/src/stores/admins/personal'; // 个人
 import { CompanyStore } from '@common/src/stores/admins/company'; // 企业
 import { ExpertStore } from '@common/src/stores/admins/expert'; // 专家
-import { TokenStore } from '@common/src/stores/user/token'; // 专家
+import { TokenStore } from '@common/src/stores/user/token'; // 解析
 import type { IQueryResult } from '@/util/types.util';
 const adminAxios = AdminStore();
 const personalAxios = PersonalStore();