Просмотр исходного кода

Merge branch 'master' into jenkins

lex 2 лет назад
Родитель
Сommit
999b44bb3b

+ 8 - 17
src/helpers/native-message.ts

@@ -27,21 +27,17 @@ window.postMessage = (message: IPostMessage) => {
 type CallBack = (evt?: IPostMessage) => void
 
 // eslint-disable-next-line @typescript-eslint/no-empty-function
-const loop = () => { }
+const loop = () => {}
 
 const calls: { [key: string]: CallBack | CallBack[] } = {}
 
 const browserInfo = browser()
 
 if (browserInfo.isApp) {
-  window.addEventListener('message', evt => {
+  window.addEventListener('message', (evt) => {
     try {
       console.log('message', evt.data)
-      const data = evt.data
-        ? typeof evt.data === 'object'
-          ? evt.data
-          : JSON.parse(evt.data)
-        : {}
+      const data = evt.data ? (typeof evt.data === 'object' ? evt.data : JSON.parse(evt.data)) : {}
       const uuid = data.content?.uuid || data.uuid
       // console.log(uuid, data.content, 'uuid')
       try {
@@ -55,9 +51,7 @@ if (browserInfo.isApp) {
         // console.log('data', data)
       }
       if (!uuid) {
-        const keys = Object.keys(calls).filter(
-          key => key.indexOf(data.api) === 0
-        )
+        const keys = Object.keys(calls).filter((key) => key.indexOf(data.api) === 0)
         // console.log(keys, 'keys')
         // console.log(data, 'data')
         for (const key of keys) {
@@ -85,7 +79,6 @@ export const postMessage = (data: IPostMessage, callback?: CallBack) => {
     calls[uuid] = callback || loop
     data.content = data.content ? { ...data.content, uuid } : { uuid }
     instance.postMessage(JSON.stringify(data))
-    console.log('send:', JSON.stringify(data))
   }
 }
 
@@ -111,15 +104,13 @@ export const removeListenerMessage = (api: string, callback: CallBack) => {
     const uuid = api
     if (Array.isArray(calls[uuid])) {
       const indexOf = (calls[uuid] as CallBack[]).indexOf(callback)
-        ; (calls[uuid] as CallBack[]).splice(indexOf, 1)
+      ;(calls[uuid] as CallBack[]).splice(indexOf, 1)
     }
   }
 }
 
-export const promisefiyPostMessage = (
-  data: IPostMessage
-): Promise<IPostMessage | undefined> => {
-  return new Promise(resolve => {
-    postMessage(data, res => resolve(res))
+export const promisefiyPostMessage = (data: IPostMessage): Promise<IPostMessage | undefined> => {
+  return new Promise((resolve) => {
+    postMessage(data, (res) => resolve(res))
   })
 }

+ 6 - 2
src/school/attendance/components/teacher-attendDetail.tsx

@@ -58,7 +58,7 @@ export default defineComponent({
         })
         closeSheet()
       } catch (e) {
-        showToast('发起聊天失败')
+        showToast('拨号失败')
         closeSheet()
       }
     }
@@ -83,6 +83,10 @@ export default defineComponent({
     })
 
     const setAddress = async (myPoint: string) => {
+      if (!myPoint) {
+        showToast('当前暂无定位')
+        return
+      }
       console.log(myPoint, attendanceScope.value)
       try {
         await postMessage({
@@ -90,7 +94,7 @@ export default defineComponent({
           content: {
             type: 'display',
             orginPoint: teacherAttInfo.value.addressLongitudeLatitude,
-            myPoint,
+            myPoint: myPoint,
             limitDistance: attendanceScope.value
           }
         })

+ 11 - 6
src/school/school-detail/eidt-school.tsx

@@ -10,7 +10,7 @@ import locIcon from './images/loc-icon.png'
 import request from '@/helpers/request'
 import { areas } from '@/helpers/area'
 import OUpload from '@/components/o-upload'
-import { postMessage } from '@/helpers/native-message'
+import { listenerMessage, postMessage } from '@/helpers/native-message'
 export default defineComponent({
   name: 'school-detail',
   setup() {
@@ -118,15 +118,13 @@ export default defineComponent({
     })
     const setAddress = async () => {
       try {
-        await postMessage(
+        postMessage(
           {
             api: 'sourseMapApi',
             content: { type: 'modify', orginPoint: forms.addressLongitudeLatitude }
           },
           (data: any) => {
-            console.log('---------')
-            console.log(data.content.nowPoint, data.content.address)
-            console.log('---------')
+            console.log(data.content.nowPoint, data.content.address, '------')
             forms.addressLongitudeLatitude = data.content.nowPoint
             forms.address = data.content.address
           }
@@ -135,10 +133,17 @@ export default defineComponent({
         console.log(e)
       }
     }
+
+    onMounted(() => {
+      listenerMessage('sourseMapApi', (data: any) => {
+        console.log(data.content.nowPoint, data.content.address)
+        forms.addressLongitudeLatitude = data.content.nowPoint
+        forms.address = data.content.address
+      })
+    })
     return () => (
       <>
         <div class={styles.schoolEidtWrap}>
-          <OHeader></OHeader>
           <div class={styles.eidtWrap}>
             <CellGroup inset>
               <div class={styles.schoolDtailWrap} onClick={setSchoolIcon}>

+ 53 - 0
src/views/unit-test/model/choice-question/index.module.less

@@ -0,0 +1,53 @@
+.unitSubject {
+  padding: 15px;
+  margin: 0 13px;
+  background-color: #fff;
+  overflow: hidden;
+  border-radius: 10px;
+}
+.unitSubjectTitle {
+  display: flex;
+  align-items: center;
+  flex-wrap: wrap;
+  font-size: 16px;
+  font-weight: 500;
+  color: #333333;
+  line-height: 26px;
+  .unitScore {
+    color: #777777;
+  }
+}
+.unitTitleImg {
+  padding-top: 20px;
+  padding-bottom: 10px;
+  width: 100%;
+}
+
+.unitAnswers {
+  padding-bottom: 30px;
+  .unitAnswer {
+    margin-top: 15px;
+    background: #f6f6f6;
+    border-radius: 8px;
+    padding: 15px 12px;
+    display: flex;
+    align-items: center;
+    font-size: 16px;
+    font-weight: 500;
+    color: #333333;
+    .option {
+      margin-right: 10px;
+    }
+    .value {
+      :global {
+        .van-image {
+          height: 38px;
+        }
+      }
+    }
+  }
+  .active {
+    background-color: #ffebdd;
+    color: #f67146;
+  }
+}

+ 92 - 0
src/views/unit-test/model/choice-question/index.tsx

@@ -0,0 +1,92 @@
+import { Tag, Image } from 'vant'
+import { defineComponent, PropType, reactive } from 'vue'
+import { labelOptions } from '../../unit'
+import styles from './index.module.less'
+
+export default defineComponent({
+  name: 'choice-question',
+  props: {
+    value: {
+      type: [String, Number, Array],
+      default: ''
+    },
+    type: {
+      type: String as PropType<'radio' | 'checkbox'>,
+      default: 'radio'
+    },
+    answers: {
+      type: Object,
+      default: {}
+    }
+  },
+  emits: ['update:value'],
+  setup(props, { emit }) {
+    const state = reactive({
+      options: [
+        {
+          index: 1,
+          value: 'Sol'
+        },
+        {
+          index: 2,
+          value: 'Sal'
+        },
+        {
+          index: 3,
+          value: 'La'
+        },
+        {
+          index: 4,
+          value: 'Si'
+        }
+      ]
+    })
+
+    const onSelect = (item: any) => {
+      if (props.type === 'checkbox') {
+        // 判断是否已选过
+        const value: any = props.value
+        if (value.includes(item.index)) {
+          const index = value.findIndex((v: any) => v === item.index)
+          value.splice(index, 1)
+          emit('update:value', [...value])
+        } else {
+          emit('update:value', [item.index, ...value])
+        }
+      } else {
+        emit('update:value', item.index)
+      }
+    }
+    return () => (
+      <div class={styles.unitSubject}>
+        <div class={styles.unitSubjectTitle}>
+          1、选出与方框内音符时值相同的节奏阶段 <span class={styles.unitScore}>(5分)</span>
+          <Tag type="primary">{props.type === 'radio' ? '单选题' : '多选题'}</Tag>
+        </div>
+        <Image
+          class={styles.unitTitleImg}
+          src="https://lanhu-dds-backend.oss-cn-beijing.aliyuncs.com/merge_image/imgs/dbb27307d428424c8efb9f26032cfa1a_mergeImage.png"
+        />
+
+        <div class={styles.unitAnswers}>
+          {/* styles.active */}
+          {state.options.map((item: any) => (
+            <div
+              class={[
+                styles.unitAnswer,
+                props.type === 'radio' && props.value === item.index && styles.active,
+                props.type === 'checkbox' &&
+                  (props.value as any).includes(item.index) &&
+                  styles.active
+              ]}
+              onClick={() => onSelect(item)}
+            >
+              <span class={styles.option}>{labelOptions[item.index]}.</span>
+              <div class={styles.value}>{item.value}</div>
+            </div>
+          ))}
+        </div>
+      </div>
+    )
+  }
+})

+ 0 - 17
src/views/unit-test/unit-detail/index.module.less

@@ -44,20 +44,3 @@
   flex-shrink: 0;
   margin-left: 18px;
 }
-
-.unitSubject {
-  padding: 15px;
-  margin: 0 13px;
-  background-color: #fff;
-  overflow: hidden;
-  border-radius: 10px;
-}
-.unitSubjectTitle {
-  font-size: 16px;
-  font-weight: 500;
-  color: #333333;
-  line-height: 26px;
-  .unitScore {
-    color: #777777;
-  }
-}

+ 13 - 12
src/views/unit-test/unit-detail/index.tsx

@@ -7,6 +7,7 @@ import iconQuestionNums from '../images/icon-question-nums.png'
 import iconCountDown from '../images/icon-count-down.png'
 import iconButtonList from '../images/icon-button-list.png'
 import OSticky from '@/components/o-sticky'
+import ChoiceQuestion from '../model/choice-question'
 
 export default defineComponent({
   name: 'unit-detail',
@@ -15,7 +16,8 @@ export default defineComponent({
     const router = useRouter()
     const swipeRef = ref()
     const state = reactive({
-      visiableNotice: false
+      visiableNotice: false,
+      answerList: {}
     })
     return () => (
       <div class={styles.unitDetail}>
@@ -37,20 +39,19 @@ export default defineComponent({
           }}
         </Cell>
 
-        <Swipe loop={false} showIndicators={false} ref={swipeRef} duration={300}>
+        <Swipe
+          loop={false}
+          showIndicators={false}
+          ref={swipeRef}
+          duration={300}
+          touchable={false}
+          lazyRender
+        >
           <SwipeItem>
-            <div class={styles.unitSubject}>
-              <div class={styles.unitSubjectTitle}>
-                1、选出与方框内音符时值相同的节奏阶段 <span class={styles.unitScore}>(5分)</span>
-                <Tag type="primary">单选题</Tag>
-              </div>
-              <Image src="https://lanhu-dds-backend.oss-cn-beijing.aliyuncs.com/merge_image/imgs/dbb27307d428424c8efb9f26032cfa1a_mergeImage.png" />
-            </div>
+            <ChoiceQuestion v-model:value={state.answerList[0]} type="checkbox" />
           </SwipeItem>
           <SwipeItem>
-            <div class={styles.unitSubject}>
-              <Image src="https://lanhu-dds-backend.oss-cn-beijing.aliyuncs.com/merge_image/imgs/dbb27307d428424c8efb9f26032cfa1a_mergeImage.png" />
-            </div>
+            <ChoiceQuestion />
           </SwipeItem>
         </Swipe>
 

+ 12 - 0
src/views/unit-test/unit.ts

@@ -0,0 +1,12 @@
+export const labelOptions = {
+  1: 'A',
+  2: 'B',
+  3: 'C',
+  4: 'D',
+  5: 'E',
+  6: 'F',
+  7: 'G',
+  8: 'H',
+  9: 'I',
+  10: 'J'
+}