编辑代码

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, time:6}
const mode_info_json = {name: 'camera',show_img: 1}
const mode_info_json_str = JSON.stringify(mode_info_json)
const param_temp_json = {}
const param_temp_json_str =JSON.stringify(param_temp_json) 
const checkid = {
        setting: {
            param_temp: param_temp_json_str,
            mini_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", //有:canvas扫图模式、camera相机模式、web网页拍照url、mini小程序
                    mode_info: mode_info_json_str, //获取帧数据频率
                    //camera
                    // 	{name:"camera",frequency:30}
                    // 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,
                        wh_r: 1,
                        size_r: 0.65
                    }
                },
                onTake: "qrcode|clear|margin|light|shake",
                onUpload: "qrcode|clear|margin|light|shake_upload|cut"
            },    
            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,
                scope: scope_json_str,
                native: 1
            },
            margin: {
                ios: 0.65,
                android: 0.8,
                codeKey: "k",
                codeParam: "p",
                failTips: tips_json_str,
                scope: scope_json_str,
                rule: JSON.stringify([]),
                show_value: 1
            },
            margin_upload: {
                ios: 0.65,
                android: 0.8,
                codeKey: "k",
                codeParam: "p",
                failTips: tips_json_str,
                scope: scope_json_str,
                show_value: 1
            },
            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,
                    show_value: 1
            },
            light: {
                    //lightValue
                    ios: 23,
                    android: 22,
                    failTips: tips_json_str,
                    scope: scope_json_str,
                    turn_light: 1, // 是否打开手电筒
                    show_value: 1
            },
            light_upload: {
                //lightValue
                ios: 23,
                android: 22,
                failTips: tips_json_str,
                scope: scope_json_str,
                turn_light: 1 // 是否打开手电筒
            },
            clear: {
                // clearValue
                ios: 11,
                android: 11,
                failTips: tips_json_str,// 数组json,子项为对象
                scope: scope_json_str,
                show_value: 1
            },
            clear_upload:{
                // clearValue
                ios: 11,
                android: 11,
                failTips: tips_json_str,// 数组json,子项为对象
                scope: scope_json_str,
                show_value: 1
            },
            shake:{
                focus: 20,
                // 对准目标时检测抖动加速度的最大值
                take: 20,
                // 点击拍照时检测抖动加速度的最大值
                failTips:tips_json_str,
                show_value: 1
            },
            shake_upload:{
                focus: 20,
                // 对准目标时检测抖动加速度的最大值
                take: 20,
                // 点击拍照时检测抖动加速度的最大值
                failTips:tips_json_str
            },
            cut:{
                scope: scope_json_str
            },
            speacil:special_json_str
        }
    }

console.log(JSON.stringify(checkid))