Browse Source

feat: 开启摄像头修改

TIANYONG 11 months ago
parent
commit
8d3c366e01

+ 15 - 0
src/page-instrument/header-top/settting/index.module.less

@@ -158,4 +158,19 @@
             }
         }
     }
+}
+
+.slider {
+    width: 60%;
+    margin-right: 20px;
+
+    .sliderBtn {
+        width: 40px;
+        color: #fff;
+        font-size: 12px;
+        line-height: 20px;
+        text-align: center;
+        background-color: var(--van-primary-color);
+        border-radius: 20px;
+    }
 }

+ 30 - 3
src/page-instrument/header-top/settting/index.tsx

@@ -2,8 +2,9 @@ import { defineComponent, reactive } from "vue";
 import styles from "./index.module.less"
 import { headImg } from "../image";
 import { headTopData } from "../index"
-import { Switch, showToast, Field, Popup } from "vant";
+import { Switch, showToast, Field, Popup, Slider } from "vant";
 import state, { refreshMusicSvg } from "/src/state"
+import { api_closeCamera, api_openCamera, api_savePicture } from "/src/helpers/communication";
 import { smoothAnimationState} from "/src/page-instrument/view-detail/smoothAnimation"
 import Recommendation from "../../custom-plugins/helper-model/recommendation";
 import { resetRenderMusicScore } from "/src/view/music-score";
@@ -55,8 +56,34 @@ export default defineComponent({
                         </div>   
                         <div class={styles.cellBox}>
                             <div class={styles.tit}>摄像头</div>
-                            <Switch v-model={state.setting.camera}></Switch>
-                        </div>                                              
+                            <Switch 
+                                v-model={state.setting.camera}
+                                onChange={ async (value) => {
+                                    if (value) {
+                                        const res = await api_openCamera();
+                                        // 没有授权
+                                        if (res?.content?.reson) {
+                                            state.setting.camera = false
+                                        }
+                                    } else {
+                                        api_closeCamera();
+                                    }
+                                }}                                
+                            ></Switch>
+                        </div>   
+                        <div class={styles.cellBox} style={{ display: state.setting.camera ? "" : "none" }}>
+                            <div class={styles.tit}>透明度</div>
+                            <Slider
+                                class={styles.slider}
+                                min={0}
+                                max={100}
+                                v-model:modelValue={state.setting.cameraOpacity}
+                            >
+                                {{
+                                    button: () => <div class={styles.sliderBtn}>{state.setting.cameraOpacity}</div>,
+                                }}
+                            </Slider>
+                        </div>                                                                     
                         <div class={styles.cellBox}>
                             <div class={styles.tit}>标准音高</div>
                             <div class={styles.frequency}>