编辑代码

const pages_json = [
                {
                    weight_level: 10,
                    target: "ss",
                    content: ""
                }
            ]
const pages_json_str = JSON.stringify(pages_json)

const scope_json = {top:20,bottom:20,left:20,right:20}
const scope_json_str = JSON.stringify(scope_json)

const tips_json = [{count:1,text:'tip',image:'http:#'}]
const tips_json_str = JSON.stringify(tips_json)
const special_json = {
                producer1:{ //如xiaomi,
                    mode_arr: [{ name: 'k40', zoom: 2, frame_size: 0.5, clear_min: 100, shake_take: 0.4, shake_focus: 0.2 }],
                    default_zoom: 2,
                },
                producer2: {}
            }
const special_json_str = JSON.stringify(special_json)

const mode_info_json = {name: 'canvas',frequency:30}
const mode_info_json_str = JSON.stringify(mode_info_json)

const checkid = {
        setting: {
            check_id: "010102",
            version: "1.0.0",
            program_name: "小程序名称",
            product_url: "http://#",
            producer: "客户",
            producer_id: "客户id",
            product_name: "产品名称",
            product_id: "01",
            watermark_id: "02",
            oss_path: "oss文件存储路径",
            entry_qrcode_url: "http://",
            entry_web_url: "http://#",
            pages: "home|success|unknown|tips|trace|web",
            auth: "user_info|gps|take_photo",
            takePhoto:{
                config: {
                    mode: "canvas", //扫图模式|camera相机模式|web网页拍照url|mini小程序
                    mode_info: mode_info_json_str, //获取帧数据频率
                    //camera
                    // 	{name:"camera"}
                    // web
                    // 	{name:"web",url:"http://#"}
                    // 		网页拍照web_url
                    // mini ={name:"mini",config:{}}
                    // 	config
                    // 		appId
                    // 		path
                    // 		extraData
                    // 		envVersion
                    // 		shortLink
                    // 	mini
                    zoom: {
                        ios: 2, //float/int
                        android: 5 //float/int
                    },
                    frame: {
                        isopen: 1,
                        hasRotate: 1,
                        mode: 1, // 初始方向:竖直(不旋转)
                        showLine: 1,
                        url: "http://#",
                        size: 0.65,
                        wh: 1,
                    }
                },
                onTake: {
                    qrcode: 1, //"检测到二维码时允许上传"
                    light: 1,
                    clear: 1,
                    shake: 1,
                },
                onUpload: {
                    qrcode_upload: 1, //检测到二维码时允许上传
                    light: 1,
                    clear: 1,
                    shake: 1,
                    cut: 1,
                }
            },    
            background: {
                color: "white",
                url: "http://#",
            },
            logo: {
                url: "http://#",
                position: "left" //center|right
            },
            upload: {
                path: "http://#",
                header: {
                    x_api_key: "apikey",
                    x_tusin_token:"x_tusin_token"
                }
            },
            state: 1, //1运营中|2停止运营|3开发中
            livetime: 123456 //			time
        },
        pages: {
            //item:{[]}=》此处等同success级别,仅用于表明数据结构
            home: pages_json_str,
            success: pages_json_str,
            trace: pages_json_str,
            unknown: pages_json_str,
            tips: pages_json_str,
            // tips:{
            //     tip_copy_colorless: pages_json_str,
            //     tip_copy_colorful: pages_json_str,
            //     tip_screen: pages_json_str,
            //     tip_unclear: pages_json_str,
            //     tip_small: pages_json_str
            // },
            web: pages_json_str,
            stop: pages_json_str
        },
        library: {
            qrcode: {
                isQrcode: 1,
                isBarcode: 1,
                codeKey: "k",
                codeParam: "p",
                failTips: tips_json_str,
                margin: {
                    ios: 0.65,
                    android: 0.8
                },
                scope: scope_json_str,
            },
            qrcode_upload: { // 根据setting的takePhoto里的onUpload是否包含xxx_upload决定是否读取该字段
                    isQrcode: 1,
                    isBarcode: 1,
                    codeKey: "k",
                    codeParam: "p",
                    failTips: tips_json_str,
                    margin: {
                        ios: 0.65,
                        android: 0.8
                    },
                    scope: scope_json_str,
            },
            light: {
                take:{
                    //lightValue
                    ios: 23,
                    android: 22,
                    failTips: tips_json_str,
                    scope: scope_json_str,
                    turn_light: 1 // 是否打开手电筒
                },
                upload: {
                    //lightValue
                    ios: 23,
                    android: 22,
                    failTips: tips_json_str,
                    scope: scope_json_str,
                    turn_light: 1 // 是否打开手电筒
                },
            },
            clear: {
                take: {
                    // clearValue
                    ios: 11,
                    android: 11,
                    failTips: tips_json_str,// 数组json,子项为对象
                    scope: scope_json_str
                },
                upload:{
                    // clearValue
                    ios: 11,
                    android: 11,
                    failTips: tips_json_str,// 数组json,子项为对象
                    scope: scope_json_str
                }
            },
            shake:{
                take: {
                    focus: 20,
                    // 对准目标时检测抖动加速度的最大值
                    take: 20,
                    // 点击拍照时检测抖动加速度的最大值
                    failTips:tips_json_str
                },
                upload:{
                    focus: 20,
                    // 对准目标时检测抖动加速度的最大值
                    take: 20,
                    // 点击拍照时检测抖动加速度的最大值
                    failTips:tips_json_str
                },
            },
            cut:{
                take: {
                    scope: scope_json_str
                },
                upload:{
                    scope: scope_json_str
                },
            },
            speacil:special_json_str
        }
    }

console.log(JSON.stringify(checkid))