Browse Source

Merge branch 'master' into houxq

WINDOWS-7IFQK7E\EDY 2 years ago
parent
commit
3f1bf63677

+ 13 - 0
src/components.d.ts

@@ -11,13 +11,26 @@ declare module '@vue/runtime-core' {
     RemoteList: typeof import('./components/RemoteList/index.vue')['default']
     RouterLink: typeof import('vue-router')['RouterLink']
     RouterView: typeof import('vue-router')['RouterView']
+    VanButton: typeof import('vant/es')['Button']
     VanCard: typeof import('vant/es')['Card']
+    VanCheckbox: typeof import('vant/es')['Checkbox']
     VanConfigProvider: typeof import('vant/es')['ConfigProvider']
+    VanCountDown: typeof import('vant/es')['CountDown']
+    VanDivider: typeof import('vant/es')['Divider']
     VanGrid: typeof import('vant/es')['Grid']
     VanGridItem: typeof import('vant/es')['GridItem']
     VanIcon: typeof import('vant/es')['Icon']
+    VanImage: typeof import('vant/es')['Image']
     VanList: typeof import('vant/es')['List']
+    VanNavBar: typeof import('vant/es')['NavBar']
+    VanPicker: typeof import('vant/es')['Picker']
+    VanPopup: typeof import('vant/es')['Popup']
     VanPullRefresh: typeof import('vant/es')['PullRefresh']
+    VanSkeleton: typeof import('vant/es')['Skeleton']
+    VanStep: typeof import('vant/es')['Step']
+    VanSteps: typeof import('vant/es')['Steps']
+    VanSticky: typeof import('vant/es')['Sticky']
+    VanSubmitBar: typeof import('vant/es')['SubmitBar']
     VanSwipe: typeof import('vant/es')['Swipe']
     VanSwipeItem: typeof import('vant/es')['SwipeItem']
     VanTab: typeof import('vant/es')['Tab']

+ 91 - 79
src/pages/_home/index.vue

@@ -1,6 +1,6 @@
 <script setup>
 import user from '~/store/user';
-import { child } from '~/store/child';
+import { child, setChild } from '~/store/child';
 
 import img_bg from '~/assets/home/bg.png';
 import img_banner1 from '~/assets/home/banner1.png';
@@ -30,40 +30,42 @@ function gridHandle(item) {
   if (
     item.text == '线上课堂' ||
     item.text == '云尚活动' ||
-    item.text == '校长信箱')
-  {
+    item.text == '校长信箱') {
     showToast('该模块正在开发中~');
   };
   if (item.text == '社团选课') {
-    if (user._role=='others') {
-        window.open('https://nmlm.bozedu.net/login.html?redirect=/stxk','_self')
-      } else {
-        switch (user._role) {
-          case 'jz':
-            if(!child){
-              return showToast('家长需绑定孩子方可进入')
-            }
-            window.open('https://nmlm.bozedu.net/#/stxk/jz', '_self')
-             return
-            // return itemRoute = '/stxk/jz'
-          case 'js':
-            window.open('https://nmlm.bozedu.net/#/stxk_teacher', '_self')
-             return
-            // return itemRoute = '/stxk_teacher'
-          case 'xz':
-             window.open('https://nmlm.bozedu.net/#/stxkjsd', '_self')
-             return
-            // return itemRoute = '/stxkjsd'
-        }
+    if (user._role == 'others') {
+      window.open('https://nmlm.bozedu.net/login.html?redirect=/stxk', '_self')
+    } else {
+      switch (user._role) {
+        case 'jz':
+          // if(!child){
+          //   return showToast('家长需绑定孩子方可进入')
+          // }
+          // window.open('https://nmlm.bozedu.net/#/stxk/jz', '_self')
+          router.push('/stxk/jz')
+          return
+        // return itemRoute = '/stxk/jz'
+        case 'js':
+          // window.open('https://nmlm.bozedu.net/#/stxk_teacher', '_self')
+          router.push('/stxk_teacher')
+          return
+        // return itemRoute = '/stxk_teacher'
+        case 'xz':
+          //  window.open('https://nmlm.bozedu.net/#/stxkjsd', '_self')
+          router.push('/stxkjsd')
+          return
+        // return itemRoute = '/stxkjsd'
       }
+    }
   }
-  
+
 }
 const gridList = [
   { icon: img_djzl, text: '党建专栏', to: () => '/djzl' },
   { icon: img_qzzx, text: '求真在线', to: () => '/qzzx' },
   { icon: img_xskt, text: '线上课堂', to: () => '' },
-  {icon: img_stxk, text: '社团选课', to: () => ''},
+  { icon: img_stxk, text: '社团选课', to: () => '' },
   { icon: img_jscz, text: '教师成长', to: () => '/jscz', permission: ['js', 'xz'].includes(user._role) },
   { icon: img_yshd, text: '云尚活动', to: () => '' },
   { icon: img_xzxx, text: '校长信箱', to: () => '' },
@@ -78,7 +80,7 @@ let nic_id;
 request({
   url: '/news/info_cate/api_tree',
   data: {
-    token: user._role === 'jz' ? ( child ? child.token : "") : user.token
+    token: user._role === 'jz' ? (child ? child.token : "") : user.token
   }
 }).then(res => {
   cateData = res.data;
@@ -91,7 +93,7 @@ request({
   data: {
     nic_id: nic_id,
     urltype: 1,
-    token: user._role === 'jz' ? ( child ? child.token : ""): user.token
+    token: user._role === 'jz' ? (child ? child.token : "") : user.token
   }
 }).then(res => {
   notice = res.data.page_data[0];
@@ -118,15 +120,17 @@ function initData() {
   }).then((res) => {
     if (res.code == "1") {
       childrenList = res.data.info;
+      sessionStorage.setItem("children", JSON.stringify(res.data.info));
+      // setChild(res.data.info[0]);
     }
   });
 }
 initData();
 
 function register() {
-  if(user.token){
+  if (user.token) {
     router.push('/xszc')
-  }else{
+  } else {
     router.push('/zcdl');
   }
 }
@@ -142,12 +146,11 @@ function routerLink() {
 </script>
 
 <template>
-
   <div class="flex flex-col justify-center p-4 relative bg-no-repeat bg-contain"
     :style="{ backgroundImage: `url(${img_bg})` }">
     <!-- <van-config-provider :theme-vars="{ 'search-padding': 0 }">
-      <van-search v-model="searchText" placeholder="" />
-    </van-config-provider> -->
+          <van-search v-model="searchText" placeholder="" />
+        </van-config-provider> -->
     <van-swipe :autoplay="3000" lazy-render class="rounded-md shadow-md mt-4 min-w-270px">
       <van-swipe-item v-for="image in images" :key="image">
         <img :src="image" class="w-full" />
@@ -156,26 +159,27 @@ function routerLink() {
         <img @click="register()" src="../../assets/home/banner3.png" style="height:100%" class="w-full" alt="">
       </van-swipe-item>
     </van-swipe>
-    
+
   </div>
   <van-grid :gutter="0" class="" icon-size="65px">
-      <template  v-for="item in gridList" :key="item.text">
-        <van-grid-item v-if="item.permission || item.permission === undefined" :icon="item.icon" :text="item.text"
-          :to="item.to()" @click="gridHandle(item)" />
-      </template>
-    </van-grid>
+    <template v-for="item in gridList" :key="item.text">
+      <van-grid-item v-if="item.permission || item.permission === undefined" :icon="item.icon" :text="item.text"
+        :to="item.to()" @click="gridHandle(item)" />
+    </template>
+  </van-grid>
   <div class="px-4 flex w-full notice">
-    <div class="w-40 h-full"> 
+    <div class="w-40 h-full">
       <img class="w-19 mt-5.4" src="../../assets/images/-s-6.png" alt="">
     </div>
     <div class="text truncate cursor-pointer" @click="routerLink">
-      {{notice.name}}
+      {{ notice.name }}
     </div>
   </div>
   <van-tabs sticky swipeable>
     <van-tab v-for="cate in cateData" :title="cate.nic_name">
       <remote-list url="/news/info/index"
-        :d="{ nic_id: cate.nic_id, urltype: 1, token: user._role === 'jz' ? ( child ? child.token : ''): user.token }" class="mt-2">
+        :d="{ nic_id: cate.nic_id, urltype: 1, token: user._role === 'jz' ? (child ? child.token : '') : user.token }"
+        class="mt-2">
         <template #default="{ row: item }">
           <van-card :title="item.name" :thumb="item.img" @click="handleClickCard(item)">
             <template #price>
@@ -210,52 +214,60 @@ function routerLink() {
 .van-grid {
   width: 100%;
 }
-.van-grid-item{
+
+.van-grid-item {
   width: 100px;
 }
- .van-tabs{
+
+.van-tabs {
   padding: 0 10px !important;
   background-color: #fff;
 }
-.van-card{
+
+.van-card {
   background-color: #fff;
 }
-  .notice{
-    width: 100%;
-    align-items: center;
-    justify-content: space-between;
-    height: 60px;
+
+.notice {
+  width: 100%;
+  align-items: center;
+  justify-content: space-between;
+  height: 60px;
+  line-height: 60px;
+  background-color: #fff;
+  border-top: 1.19px solid #D8E2F0;
+  border-bottom: 1.19px solid #D8E2F0;
+
+  img {
     line-height: 60px;
-    background-color: #fff;
-    border-top: 1.19px solid #D8E2F0;
-    border-bottom: 1.19px solid #D8E2F0;
-    img{
-      line-height: 60px;
-    }
-    .text{
-      height: 60px;
-      line-height: 65px;
-    }
   }
-  .tz{
-    width: 40%;
-    vertical-align: middle;
-    font-size: 26px;
-    font-family: Regular;
-    text-align: center;
-    color: #747474;
-    letter-spacing: 0px;
-  }
-  .gg{
-    vertical-align: text-top;
-    display: inline-block;
-    width: 30%;
-    height: 23px;
-    line-height: 23px;
-    text-align: center;
-    background: #ff8700;
-    border-radius: 4px;
-    font-size: 3vw;
-    color: #fff;
+
+  .text {
+    height: 60px;
+    line-height: 65px;
   }
+}
+
+.tz {
+  width: 40%;
+  vertical-align: middle;
+  font-size: 26px;
+  font-family: Regular;
+  text-align: center;
+  color: #747474;
+  letter-spacing: 0px;
+}
+
+.gg {
+  vertical-align: text-top;
+  display: inline-block;
+  width: 30%;
+  height: 23px;
+  line-height: 23px;
+  text-align: center;
+  background: #ff8700;
+  border-radius: 4px;
+  font-size: 3vw;
+  color: #fff;
+}
 </style>

+ 5 - 1
src/pages/stxk/jz/index.vue

@@ -2,8 +2,12 @@
 import { getCountDownTime } from '~/utils/day';
 import { paddingLeft } from '~/utils/string';
 import { child } from '~/store/child';
+// import { children } from '~/store/children';
 import getTeamInfo from '~/store/team';
 
+const children = JSON.parse(sessionStorage.getItem('children'))
+console.log('children :>> ', children);
+
 function handleNavLeftClick() {
   router.replace('/home')
 }
@@ -44,7 +48,7 @@ function test(item) {
 
   <van-skeleton :row="3" :loading="loading">
     <remote-list url="/khfw/kcgl/index"
-      :d="{ token: child.token, kxq_code, grade: child.cm_info.map(({ grade }) => grade).join(',') }">
+      :d="{ token: child.token, kxq_code, grade: children?.map(child => child.cm_info.map(({ grade }) => grade).join(','))?.join(',') }">
       <template #default="{ row: item }">
         <!--  :desc="item.desc" -->
         <van-card :price="item.kk_kcfy" :desc="`讲师:${test(item)}`" :title="item.kk_name" :thumb="item.kk_img"

+ 46 - 8
src/pages/stxk/jz/kcxq.vue

@@ -1,7 +1,7 @@
 <script setup>
 import { getCountDownTime } from "~/utils/day";
 import { user } from "~/store/user";
-import { child } from "~/store/child";
+import { child as childInfo, setChild } from "~/store/child";
 import { showFailToast, showSuccessToast } from "vant";
 const oss = window.GLOBAL_CONFIG.oss;
 const props = defineProps({
@@ -9,8 +9,10 @@ const props = defineProps({
     type: String,
     required: true,
   },
-});isOpen
-
+});
+let child = $ref(childInfo);
+const children = JSON.parse(sessionStorage.getItem('children'))
+let childrenCols = $ref([])
 const router = useRouter();
 function handleNavLeftClick() {
   router.replace("/stxk/jz");
@@ -34,6 +36,17 @@ request({
 }).then((res) => {
   if (res.code === "1") {
     detailInfo = res.data.one_info;
+    const grades = (detailInfo.kk_grade_id).split(',').filter(item => item !== '')
+    console.log('grades :>> ', grades);
+    childrenCols = children.map((item) => {
+      return {
+        text: `${item.first_cm_name} ${item.user_realname}`,
+        value: item.user_id,
+        self: item,
+        disabled: grades.indexOf(item.cm_info[0].grade) === -1,
+      };
+    });
+
     detailInfo.$kk_kcfy = detailInfo.kk_kcfy * 100;
 
     if (detailInfo.khfw_kcbmxx.kkbm_id === "0") {
@@ -51,7 +64,11 @@ request({
 
 function handleSubmitbarClick() {
   console.log("handleSubmitbarClick", orderStatus, child);
-
+  const grades = (detailInfo.kk_grade_id).split(',').filter(item => item !== '')
+  if (grades.indexOf(child.cm_info[0].grade) === -1) {
+    showFailToast('该学生不在可报名年级范围内')
+    return
+  }
   request({
     url: "/khfw/kcbmxx/add",
     data: {
@@ -213,6 +230,17 @@ const orderStatusText = computed(() => {
       return "立即报名";
   }
 });
+
+function handleClickSwitchChild() {
+
+}
+const showPicker = ref(false);
+function handleConfirmSwitchChild({ selectedOptions }) {
+  showPicker.value = false;
+  console.log('selectedOptions :>> ', selectedOptions);
+  setChild(child = selectedOptions[0].self);
+  console.log('child', child)
+};
 </script>
 
 <template>
@@ -278,15 +306,25 @@ const orderStatusText = computed(() => {
             </div>
             <div>{{ item.intro }}</div>
             <!-- <ul class="list-disc list-inside">
-                                      <li>{{ detailInfo.kk_teacher.intro }}</li>
-                                    </ul> -->
+                          <li>{{ detailInfo.kk_teacher.intro }}</li>
+                        </ul> -->
           </div>
         </div>
         <div v-else>暂无数据</div>
       </div>
 
-      <van-submit-bar :price="detailInfo.$kk_kcfy" :button-text="orderStatusText" :disabled="orderStatus"
-        @submit="handleSubmitbarClick" placeholder />
+      <van-submit-bar :price="detailInfo.$kk_kcfy" :button-text="orderStatusText" :disabled="!!orderStatus"
+        @submit="handleSubmitbarClick" placeholder>
+        <template #tip>
+          <div class="flex justify-between text-sm" @click="showPicker = true">
+            <span>当前选中的小孩为 {{ child?.first_cm_name }} {{ child?.user_realname }}</span>
+            <span class="text-blue-500">切换小孩</span>
+          </div>
+          <van-popup v-model:show="showPicker" round position="bottom">
+            <van-picker :columns="childrenCols" @cancel="showPicker = false" @confirm="handleConfirmSwitchChild" />
+          </van-popup>
+        </template>
+      </van-submit-bar>
     </van-skeleton>
   </div>
 </template>

+ 5 - 3
src/pages/stxk/jz/wd/index.vue

@@ -1,5 +1,6 @@
 <script setup>
 import { child } from '~/store/child';
+const children = JSON.parse(sessionStorage.getItem('children'))
 
 const handleNavLeftClick = () => {
   router.back()
@@ -30,10 +31,11 @@ function getTagText(item) {
     </van-nav-bar>
   </van-sticky>
 
-  <remote-list url="/khfw/kcbmxx/index" :d="{ token: child.token, kkbm_s_user_id: child.user_id }">
+  <remote-list url="/khfw/kcbmxx/index"
+    :d="{ token: child.token, kkbm_s_user_id: children.map(item => item.user_id).join(',') }">
     <template #default="{ row: item }">
-      <van-card :price="item.khfw_kcgl.kk_kcfy" :desc="`讲师:`" :title="item.kk_name" :thumb="item.khfw_kcgl.kk_img"
-        @click="handleClickCard(item)">
+      <van-card :price="item.khfw_kcgl.kk_kcfy" :desc="`报名学生:${item.kkbm_s_class_name} ${item.kkbm_s_realname}`"
+        :title="item.kk_name" :thumb="item.khfw_kcgl.kk_img" @click="handleClickCard(item)">
         <template #num>
           <van-tag type="primary">{{ getTagText(item.khfw_kcbmxx) }}</van-tag>
         </template>

+ 6 - 1
src/store/child.js

@@ -1,3 +1,8 @@
 import { user } from './user';
 
-export const child = JSON.parse(localStorage.getItem(`childInfo_${user?.user_id}`))
+export let child = JSON.parse(localStorage.getItem(`childInfo_${user?.user_id}`))
+
+export function setChild(data) {
+  child = data;
+  localStorage.setItem(`childInfo_${user?.user_id}`, JSON.stringify(data));
+}

+ 11 - 0
src/store/children.js

@@ -0,0 +1,11 @@
+// uo use the following code to get the children list:
+
+await request({
+  baseURL: window.GLOBAL_CONFIG.uc,
+  url: '/user/main/my_child',
+}).then(res => {
+  if (res.code === '1') {
+    sessionStorage.setItem('children', JSON.stringify(res.data.info))
+  }
+})
+export const children = JSON.parse(sessionStorage.getItem('children'))