123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287 |
- const app = getApp()
- import { debounce, getDetectFileType } from '../../utils/util/util'
- import FileUploader from '../../utils/upload/upload_file_chunk'
- Page({
- data: {
- // 是否显示信息
- showSystemInfo: false,
- //系统信息
- systemInfo: null,
- //系统信息字符串展示
- systemInfoStr: null,
- //是否是K8容器中运行的小程序
- isKEightDevice: false,
- /**
- * 初始化刷脸服务
- */
- //入参打印
- initObj: null,
- //结果
- initResult: null,
- //初始化入参
- initParams: {},
- /**
- * 调用1:N刷脸
- */
- //入参打印
- oneVNObj: null,
- //结果
- oneVNResult: null,
- //调用服务入参
- oneVNParams: {},
- //服务编码
- oneVNServiceCode: "",
- /**
- * 调用订阅授权服务
- */
- //入参打印
- authObj: null,
- //结果
- authResult: null,
- //调用服务入参
- authParams: {},
- //服务编码
- authServiceCode: "",
- downloadFileChunkItem: {
- status: '',
- errorTips: '',
- chunkIndex: 0,
- totalChunks: 0,
- url: '',
- fileType: '',
- fileName: '测试',
- originalUrl: 'https://tx.hz-hanghui.com:8088/yx-fyzd/file/img/localPreviewPageUrl.jpg',
- // originalUrl: 'https://vipmp4i.vodfile.m1905.com/202411161120/d92631080d326316a8d249a67161916d/video/moss/2024/11/15/v202411152H376OYBGLJZWLWT/v202411152H376OYBGLJZWLWT.mp4',
- // 'https://vipmp4i.vodfile.m1905.com/202411161120/d92631080d326316a8d249a67161916d/video/moss/2024/11/15/v202411152H376OYBGLJZWLWT/v202411152H376OYBGLJZWLWT.mp4'
- },
- videoChunkItem: {
- chunkIndex: 0,
- totalChunks: 0,
- url: '',
- width: 0,
- height: 0,
- },
- activeTab: 0,
- menuList: [
- /*{
- name: 'web-view',
- id: -1,
- ampe_params: []
- },*/
- {
- name: '系统信息',
- id: 0,
- ampe_params: []
- },
- {
- name: '刷脸指令',
- id: 1,
- ampe_params: [
- {
- name: "刷脸初始化请求",
- number: "A1",
- aromeCode: "",
- initParams: {
- "action": "initFace",
- "event": "open",
- "taskId": "A1",
- "params": {
- "serviceId": "",
- "query": "",
- "scope": ""
- }
- }
- },
- {
- name: "唤起刷脸请求1:N",
- number: "A2",
- aromeCode: "",
- initParams: {
- "action": "getFaceInfo",
- "event": "open",
- "taskId": "A2"
- }
- },
- {
- name: "唤起刷脸请求1:1",
- number: "A3",
- aromeCode: "",
- initParams: {
- "action": "getFaceInfoPersonCard",
- "event": "open",
- "taskId": "A3",
- "params": {
- "certName": "",
- "certNo": "",
- "certPhotoBase64Str": ""
- }
- }
- },
- {
- name: '刷脸入库',
- tips: '调用刷脸(老年食堂)',
- aromeCode: "",
- number: "A4",
- initParams: {
- "action": "doStorageFaceInfo",
- "event": "open",
- "taskId": "A4",
- "params": {
- "appid": "2021003181682188",
- "orgOutId": "hanghuijingquTest3",
- "componentOutId": "day_label_sign_online",
- "isvPid": "2088721034139660"
- }
- // "params": {
- // "appId":"2021004147600083",
- // "orgOutId":"huanggangzhangzheshitang",
- // "componentOutId":"day_label_sign_online",
- // "isvPid":"2088741779695636"
- // }
- }
- },
- {
- name: '刷证/输证⼊库',
- tips: '调用刷证/输证入库(老年食堂)',
- aromeCode: "",
- number: "A5",
- initParams: {
- "action": "doStorageFaceInfo",
- "event": "open",
- "taskId": "A5",
- "params": {
- "uniqueId": "2021003181682188",
- "name": "XXXXXX",
- "certNo": "XXXXXX",
- "phone": "XXXXXX"
- }
- }
- },
- ]
- },
- {
- name: '刷身份证',
- id: 2,
- ampe_params: [
- {
- name: "开启刷身份证(单次)",
- number: "B1",
- aromeCode: '',
- initParams: {
- "action": "getIDCardInfo",
- "event": "open",
- "taskId": "B1",
- "params": {
- "infoType": "base,photo,other"
- }
- }
- },
- {
- name: "关闭刷身份证(单次)",
- number: "B2",
- aromeCode: '',
- initParams: {
- "action": "closeIDCardInfo",
- "event": "open",
- "taskId": "B2",
- "params": {
- "infoType": "base,photo,other"
- }
- }
- },
- {
- name: "身份证持续监听",
- aromeCode: "initIDCardListener",
- number: "B3",
- initParams: {}
- },
- ]
- },
- {
- name: '二维码',
- id: 3,
- ampe_params: [
- {
- name: "开启刷⼆维码(单次)",
- number: "C1",
- aromeCode: "",
- initParams: {
- "action": "getQRCode",
- "event": "open",
- "taskId": "C1"
- }
- },
- {
- name: "二维码持续监听",
- aromeCode: "initQRListener",
- number: "C2",
- initParams: {}
- },
- ]
- },
- {
- name: '麦克风',
- id: 4,
- ampe_params: [
- {
- name: "开启⻨克⻛(持续)",
- tips: 'app持续发录⾳数据给小程序',
- number: "D1",
- aromeCode: "",
- initParams: {
- "action": "startMicrophoneListener",
- "event": "open",
- "taskId": "D1",
- "params": {
- "intervalTime": 1000,//2.9.0版本及之后版本已废弃该字段
- "isMicrophoneSourceData": false //2.9.8版本添加
- }
- }
- },
- {
- name: "停⽌⻨克⻛监听",
- number: "D3",
- aromeCode: "",
- initParams: {
- "action": "stopMicrophoneListener",
- "event": "open",
- "taskId": "D3",
- }
- },
- {
- name: "⻨克⻛持续监听",
- aromeCode: "initMicrophoneListener",
- number: "D2",
- isCumulative: false,
- initParams: {}
- },
- ]
- },
- {
- name: '设备信息',
- id: 5,
- ampe_params: [
- {
- name: "开启设备信息请求",
- number: "E1",
- aromeCode: "",
- initParams: {
- "action": "getDeviceInfo",
- "event": "open",
- "taskId": "E1",
- }
- },
- ]
- },
- {
- name: '语音播报请求',
- id: 6,
- ampe_params: [
- {
- name: "语⾳播报请求",
- aromeCode: "",
- number: "F1",
- initParams: {
- "action": "speech",
- "event": "open",
- "taskId": "F1",
- "params": {
- "text": "要播报的⽂字内容",
- "pitch": 1.0,
- "rate": 1.0
- }
- }
- },
- {
- name: "语音停止请求",
- aromeCode: "",
- number: "F2",
- initParams: {
- "action": "speechStop",
- "event": "open",
- "taskId": "F2",
- }
- },
- ]
- },
- {
- name: '手输身份证号',
- id: 7,
- ampe_params: [
- {
- name: "手输身份证号",
- aromeCode: "",
- number: "G1",
- initParams: {
- "action": "enterIDNumber",
- "event": "open",
- "taskId": "G1"
- }
- },
- ]
- },
- {
- name: '小票打印机小程序',
- id: 8,
- ampe_params: [
- {
- name: "小票打印机小程序",
- number: "H1",
- aromeCode: "",
- initParams: {
- "action": "receiptPrinting",
- "event": "open",
- "taskId": "H1",
- "params": {
- "printList": [{
- "text": "测试⽂字打印",
- "textSize": 26,
- "bold": false,
- "algin": "left"
- }, {
- "imageBase64": "测试图⽚打印,实际传⼊base64图⽚值/9j/4AAQSkZJRgABAgAAAQABABntRS5Sj//",
- "width": 376,
- "height": 376
- }]
- }
- }
- },
- ]
- },
- {
- name: '小程序超时',
- id: 9,
- ampe_params: [
- {
- name: "超时监听",
- aromeCode: "ampeOperationTimeout",
- number: "I1",
- initParams: {}
- },
- ]
- },
- {
- name: '红外感应',
- id: 10,
- ampe_params: [
- {
- name: "开启红外感应监听",
- aromeCode: "",
- number: "J1",
- initParams: {
- "action": "startInfraredInductionListener",
- "event": "open",
- "taskId": "J1",
- "params": {
- "intervalTime": 3000
- }
- }
- },
- {
- name: "停⽌红外感应监听",
- aromeCode: "",
- number: "J3",
- initParams: {
- "action": "stopInfraredInductionListener",
- "event": "open",
- "taskId": "J3",
- }
- },
- {
- name: "红外感应持续监听",
- aromeCode: "initInfraredInductionListener",
- number: "J2",
- initParams: {}
- },
- ]
- },
- {
- name: '双屏异显',
- id: 11,
- ampe_params: [
- {
- name: "副屏显示不同⻚⾯",
- aromeCode: "",
- number: "K1",
- initParams: {
- "action": "openSecondaryScreen",
- "event": "open",
- "taskId": "K1",
- "params": {
- "secondaryScreenBase64": "https://tx.hz-hanghui.com:8088/yx-fyzd/file/upload/imagesnew/20241107/570733822954438656.png"
- }
- }
- },
- {
- name: "关闭副屏显示",
- aromeCode: "",
- number: "K2",
- initParams: {
- "action": "closeSecondaryScreen",
- "event": "close",
- "taskId": "K2",
- }
- },
- {
- name: "获取副屏显示/关闭的状态",
- aromeCode: "",
- number: "K3",
- initParams: {
- "action": "getSecondaryScreenState",
- "event": "open",
- "taskId": "K3",
- }
- },
- ]
- },
- {
- name: '社保卡',
- id: 12,
- ampe_params: [
- {
- name: '读取社保卡信息(单次)',
- aromeCode: "",
- number: "L1",
- initParams: {
- "action": "getSocialSecurityCardInfo",
- "event": "open",
- "taskId": "K3",
- }
- },
- {
- name: '获取社保卡配置信息(单次)',
- aromeCode: "",
- number: "L2",
- initParams: {
- "action": "socialSecurityCardConfig",
- "event": "open",
- "taskId": "K3",
- }
- },
- {
- name: '开启社保卡读取监听(持续)',
- aromeCode: "socialSecurityCardListener",
- number: "L3",
- initParams: {}
- },
- ]
- },
- {
- name: 'NFC',
- id: 13,
- ampe_params: [
- {
- name: '启动NFC轮询A',
- aromeCode: "",
- number: "M1-1",
- initParams: {
- "action": "startCPUCardLoopRead",
- "event": "open",
- "taskId": "M1-1",
- "params": {
- "intervalTime": "5000",
- }
- }
- },
- {
- name: '启动NFC轮询B',
- aromeCode: "",
- number: "M1-2",
- initParams: {
- "action": "startCPUCardLoopRead",
- "event": "open",
- "taskId": "M1-2",
- "params": {
- "intervalTime": "5000",
- "isComeBackFailed": true //2.9.8版本添加
- }
- }
- },
- {
- name: '停止NFC轮询',
- aromeCode: "",
- number: "M3",
- initParams: {
- "action": "stopCPUCardLoopRead",
- }
- },
- {
- name: 'NFC监听',
- aromeCode: "CPUCardListener",
- number: "M2",
- initParams: {}
- },
- {
- name: '单次读取NFC',
- aromeCode: "",
- number: "M4",
- initParams: {
- "action": "readOnceCPUCardInfo",
- }
- },
- {
- name: '发送NFC-APDU命令',
- aromeCode: "",
- number: "M5",
- initParams: {
- "action": "sendCPUCardCommand",
- "event": "open",
- "taskId": "M5",
- "params": {
- "commandApdu": "0084000008",
- "type": "1",
- "slot": "1"
- }
- }
- },
- {
- name: '发送NFC-APDU命令集',
- aromeCode: "",
- number: "M6",
- initParams: {
- "action": "sendCPUCardApduCommands",
- "event": "open",
- "taskId": "M6",
- "params": {
- "commandApdus": ["0084000008", "0084000008", "0084000008"],
- "type": "1",
- "slot": "1"
- }
- }
- },
- {
- name: '冷复位',
- aromeCode: "",
- number: "M7",
- initParams: {
- "action": "psamCardColdReset",
- "event": "open",
- "taskId": "M7",
- "params": {
- "slot": "1"
- }
- }
- },
- {
- name: '启动蜂鸣器',
- aromeCode: "",
- number: "M8",
- initParams: {
- "action": "startBuzzer",
- "event": "open",
- "taskId": "M8",
- "params": {
- "beep": "50",
- }
- }
- },
- ]
- },
- {
- name: 'M1卡',
- id: 14,
- ampe_params: [
- {
- name: '关闭循环读取M1卡',
- aromeCode: "",
- number: "N3",
- initParams: {
- "action": "doM1Listener",
- "event": "stop",
- "taskId": "N3",
- }
- },
- {
- name: '开始循环读取M1卡',
- aromeCode: "",
- number: "N2",
- initParams: {
- "action": "doM1Listener",
- "event": "start",
- "taskId": "N2",
- "params": {
- //读取的扇区
- "sector": 15,
- //读取的块:支持指定多个块区,返回的数据会将0,1,2,3块区的内容按顺序拼接返回
- "block": "0,1,2,3",
- //读取密钥
- "secretKey": "FFFFFFFFFFFF"
- }
- }
- },
- {
- name: 'M1卡读取监听',
- aromeCode: "initM1Listener",
- number: "N1",
- initParams: {}
- },
- {
- name: '单次M1卡写入',
- aromeCode: "",
- number: "N4",
- initParams: {
- "action": "doM1Write",
- "event": "",
- "taskId": "N4",
- "params": {
- //写入的扇区
- "sector": 15,
- //写入的块: 只能指定一个块区,如需要写入多个块,可以调用多次
- "block": 0,
- //写入密钥
- "secretKey": "FFFFFFFFFFFF",
- //写入内容
- "content": "字符串utf-8"
- }
- }
- },
- {
- name: '擦除M1卡内容',
- aromeCode: "",
- number: "N5",
- initParams: {
- "action": "doM1Clear",
- "event": "",
- "taskId": "N5",
- "params": {
- //清空的扇区
- "sector": 15,
- //清空的块: 只能指定一个块区,如需要清空多个块,可以调用多次
- "block": 0,
- //写入密钥
- "secretKey": "FFFFFFFFFFFF",
- //填入的初始值-Number
- "value": 0
- }
- }
- },
- ]
- },
- {
- name: 'ASR(数科版)',
- id: 20,
- ampe_params: [
- {
- name: '初始化语音识别配置',
- aromeCode: "",
- number: "S1",
- initParams: {
- "action": "doASR",
- "event": "init",
- "taskId": "3",
- "params": {
- //租户ID,咨询服务商提供
- "tenantCode": "hanghui",
- //识别语种,非必填,默认中文-cn;英⽂-en,⻄班⽛⽂-es,菲律宾文-phl,印尼⽂-id
- "lang": "cn"
- }
- }
- },
- {
- name: '声明语音识别监听回调函数',
- aromeCode: "initASR",
- number: "S2",
- initParams: {}
- },
- {
- name: '开始语音识别',
- aromeCode: "",
- number: "S3",
- initParams: {
- "action": "doASR",
- "event": "start",
- "taskId": "S3",
- "params": {}
- }
- },
- {
- name: '停止语音识别',
- aromeCode: "",
- number: "S4",
- initParams: {
- "action": "doASR",
- "event": "stop",
- "taskId": "S4",
- "params": {}
- }
- },
- ]
- },
- {
- name: '关闭小程序',
- id: 15,
- ampe_params: [
- {
- name: '关闭小程序',
- aromeCode: "",
- number: "O1",
- initParams: {
- "action": "deviceConfig",
- "event": "open",
- "taskId": "O1",
- "params": {
- "deviceConfig": {
- "exitApplet": 1
- }
- }
- }
- },
- ]
- },
- {
- name: '显示/隐藏导航栏',
- id: 16,
- ampe_params: [
- {
- name: '开启导航栏(仅本次运⾏有效)',
- aromeCode: "",
- number: "P1",
- initParams: {
- "action": "deviceConfig",
- "event": "open",
- "taskId": "P1",
- "params": {
- "deviceConfig": {
- "hideNavigationBar": 2
- }
- }
- }
- },
- {
- name: '隐藏导航栏(仅本次运⾏有效)',
- aromeCode: "",
- number: "P2",
- initParams: {
- "action": "deviceConfig",
- "event": "open",
- "taskId": "P2",
- "params": {
- "deviceConfig": {
- "hideNavigationBar": 1
- }
- }
- }
- },
- ]
- },
- {
- name: '显示/隐藏通知栏',
- id: 17,
- ampe_params: [
- {
- name: '开启通知栏(仅本次运⾏有效)',
- aromeCode: "",
- number: "Q1",
- initParams: {
- "action": "deviceConfig",
- "event": "open",
- "taskId": "Q1",
- "params": {
- "deviceConfig": {
- "hideNotificationBar": 2
- }
- }
- }
- },
- {
- name: '隐藏通知栏(仅本次运⾏有效)',
- aromeCode: "",
- number: "Q2",
- initParams: {
- "action": "deviceConfig",
- "event": "open",
- "taskId": "Q2",
- "params": {
- "deviceConfig": {
- "hideNotificationBar": 1
- }
- }
- }
- },
- ]
- },
- {
- name: '右上角悬浮关闭小程序按钮',
- id: 18,
- ampe_params: [
- {
- name: '右上角悬浮关闭小程序按钮(根据指定AppId)',
- aromeCode: "",
- number: "R1",
- initParams: {
- "action": "floatingExitButton",
- "event": "open",
- "taskId": "R1",
- "params": {
- "isOpen": true,
- "appId": "123456"
- }
- }
- },
- ]
- },
- {
- name: '扬声器',
- id: 20,
- ampe_params: [
- {
- name: '获取扬声器音量',
- aromeCode: "",
- number: "R1",
- initParams: {
- "action": "loudspeaker",
- "event": "get",
- "taskId": "R1",
- "params": {
- }
- }
- }, {
- name: '设置扬声器音量',
- aromeCode: "",
- number: "R1",
- initParams: {
- "action": "loudspeaker",
- "event": "set",
- "taskId": "R1",
- "params": {
- "volume": "0.95"
- }
- }
- }, {
- name: '获取缓存文件列表',
- aromeCode: "",
- number: "z1",
- initParams: {
- "action": "storage",
- "event": "get",
- "taskId": "z1",
- "params": {}
- }
- }, {
- name: '缓存文件',
- aromeCode: "",
- number: "z2",
- initParams: {
- "action": "storage",
- "event": "set",
- "taskId": "z2",
- "params": {
- fileName: "夏伟浩.mp4",
- fileUrl: "https://wallpaper-static.cheetahfun.com/wallpaper/sites/dynamics/vm5.mp4"
- }
- }
- }, {
- name: '移除缓存文件',
- aromeCode: "",
- number: "z3",
- initParams: {
- "action": "storage",
- "event": "remove",
- "taskId": "z3",
- "params": {
- fileName: "夏伟浩",
- fileType: ".mp4",
- path: "/storage/emulated/0/Download/夏伟浩.mp4"
- }
- }
- },
- ]
- },
- // {
- // name: '附件上传',
- // id: 19,
- // ampe_params: []
- // },
- ],
- },
- onLoad(query) {
- this.setData({
- activeTab: 0,
- })
- my.pageScrollTo({
- selector: `.menu-box-0`,
- // offsetTop: -12,//偏移的位置
- duration: 300,
- });
- },
- // 切换 Menu
- onMenuChange(e) {
- console.log(e)
- let currentItem = e.currentTarget.dataset.item;
- this.setData({
- activeTab: currentItem.id,
- })
- my.pageScrollTo({
- selector: `.menu-box-${currentItem.id}`,
- // offsetTop: -12,//偏移的位置
- duration: 300,
- });
- },
- //切换系统信息的显示
- changeMsg() {
- let { showSystemInfo } = this.data;
- this.setData({
- showSystemInfo: !showSystemInfo
- })
- },
- //初始化接口
- doInit() {
- let that = this
- let params = JSON.parse(JSON.stringify(that.data.initParams))
- this.setData({
- initObj: JSON.stringify(params)
- })
- my.call("aromeInitBpaasService", params, (res) => {
- that.setData({
- initResult: JSON.stringify(res)
- })
- })
- },
- //调用刷脸
- doOneVN() {
- let that = this
- let params = JSON.parse(JSON.stringify(that.data.oneVNParams))
- that.setData({
- oneVNObj: JSON.stringify(params) + "----服务编码: " + that.data.oneVNServiceCode
- })
- console.log(JSON.stringify(params) + "----服务编码: " + that.data.oneVNServiceCode)
- my.call('aromeStartBpaasService', {
- serviceCode: that.data.oneVNServiceCode,
- params: params,
- taskId: parseInt(Math.random() * 1000000 + 1)
- }, (res) => {
- that.setData({
- oneVNResult: JSON.stringify(res)
- })
- app.data.authParams.user_id = res.alipayUid || ""
- app.data.authParams.ftoken = res.ftoken || ""
- })
- },
- //调用授权服务
- doAuth() {
- let that = this
- let params = JSON.parse(JSON.stringify(that.data.authParams))
- that.setData({
- authObj: JSON.stringify(params) + "----服务编码: " + that.data.authServiceCode
- })
- my.call('aromeStartBpaasService', {
- serviceCode: that.data.authServiceCode,
- params: params,
- taskId: parseInt(Math.random() * 1000000 + 1)
- }, (res) => {
- that.setData({
- authResult: JSON.stringify(res)
- })
- })
- },
- //关闭结果
- close(e) {
- let type = e.currentTarget.dataset.type
- switch (type) {
- case "init":
- this.setData({
- initResult: null,
- initObj: null
- })
- break;
- case "oneVN":
- this.setData({
- oneVNResult: null,
- oneVNObj: null
- })
- break;
- case "auth":
- this.setData({
- authObj: null,
- authResult: null
- })
- break;
- case "imgUpload":
- this.setData({
- 'downloadFileChunkItem.status': '',
- 'downloadFileChunkItem.errorTips': '',
- 'downloadFileChunkItem.chunkIndex': 0,
- 'downloadFileChunkItem.totalChunks': 0,
- 'downloadFileChunkItem.url': '',
- 'downloadFileChunkItem.fileType': '',
- 'downloadFileChunkItem.fileName': '测试',
- 'downloadFileChunkItem.originalUrl': 'https://tx.hz-hanghui.com:8088/yx-fyzd/file/img/localPreviewPageUrl.jpg',
- // 'downloadFileChunkItem.originalUrl': 'https://vipmp4i.vodfile.m1905.com/202411161120/d92631080d326316a8d249a67161916d/video/moss/2024/11/15/v202411152H376OYBGLJZWLWT/v202411152H376OYBGLJZWLWT.mp4',
- })
- break;
- case "videoUpload":
- this.setData({
- 'videoChunkItem.chunkIndex': 0,
- 'videoChunkItem.totalChunks': 0,
- 'videoChunkItem.url': '',
- 'videoChunkItem.width': 0,
- 'videoChunkItem.height': 0,
- })
- break;
- default:
- break;
- }
- },
- //进入设置页
- doSetting(e) {
- let route = {
- init: "/pages/setInit/setInit",
- oneVN: "/pages/setOneVN/setOneVN",
- auth: "/pages/setAuth/setAuth"
- }
- let type = e.currentTarget.dataset.type
- my.navigateTo({
- url: route[type]
- })
- },
- //更新配置信息
- updateConfig() {
- this.data.initParams = app.data.initParams;
- this.data.oneVNParams = app.data.oneVNParams;
- this.data.oneVNServiceCode = app.data.oneVNServiceCode;
- this.data.authParams = app.data.authParams;
- this.data.authServiceCode = app.data.authServiceCode;
- },
- handleChange(e) {
- let field = e.currentTarget.dataset.field;
- let json = e.detail.value
- console.log(json)
- this.setData({
- [`downloadFileChunkItem.${field}`]: json
- })
- },
- async handleUpload(e) {
- let type = e.currentTarget.dataset.type;
- let _this = this
- // my.downloadFile({
- // url: 'http://img.alicdn.com/tfs/TB1x669SXXXXXbdaFXXXXXXXXXX-520-280.jpg',
- // success(res) {
- // console.log('downloadFile success:',res.apFilePath,res.tempFilePath); // apFilePath 与 tempFilePath 等价
- // },
- // fail(res) {
- // console.log('downloadFile fail:',res);
- // },
- // });
- // 数据重置
- this.setData({
- 'downloadFileChunkItem.status': 'padding',
- 'downloadFileChunkItem.chunkIndex': 0,
- 'downloadFileChunkItem.totalChunks': 0,
- 'downloadFileChunkItem.url': '',
- 'downloadFileChunkItem.fileType': '',
- })
- const uploader = new FileUploader({
- url: _this.data.downloadFileChunkItem.originalUrl, // 文件路径
- chunkSize: 512 * 1024, // 每片大小为 512KB
- fileName: _this.data.downloadFileChunkItem.fileName, // 文件名
- retryLimit: 3 // 每片的最大重试次数
- });
- // 开始上传
- await uploader.startUpload((status, res) => {
- console.log('callback', res)
- _this.setData({
- 'downloadFileChunkItem.status': status,
- })
- if (status == 'success') {
- let params = res.params
- _this.setData({
- 'downloadFileChunkItem.chunkIndex': params.currentIndex + 1,
- 'downloadFileChunkItem.totalChunks': params.totalChunks,
- })
- } else {
- _this.setData({
- 'downloadFileChunkItem.errorTips': res,
- })
- }
- })
- _this.setData({
- 'downloadFileChunkItem.url': uploader.filePath,
- 'downloadFileChunkItem.fileType': (uploader.fileType || '').match(/^[^\/]+/)[0],
- })
- console.log(uploader.filePath)
- /* if (type == 'img') {
- my.chooseImage({
- // 可以根据您的业务按需选择使用 ['album'] 或 ['camera'] 或 ['album', 'camera']
- sourceType: ['album'],
- success: function (res) {
- console.log(res);
- let tempFilePath = res.tempFilePaths[0]
- let arr = []
- const uploader = new FileUploader({
- filePath: 'https://tx.hz-hanghui.com:8088/yx-fyzd/file/img/localPreviewPageUrl.jpg', // 文件路径
- chunkSize: 512 * 1024, // 每片大小为 512KB
- fileName: '测试图片', // 文件名
- // retryLimit: 3 // 每片的最大重试次数
- });
- // 开始上传
- uploader.startUpload((e) => {
- console.log('callback', e)
- _this.setData({
- 'imgChunkItem.chunkIndex': e.chunkIndex + 1,
- 'imgChunkItem.totalChunks': e.totalChunks,
- })
- })
- _this.setData({
- 'imgChunkItem.url': tempFilePath,
- })
- // const fs = my.getFileSystemManager();
- // fs.readFile({
- // // readFile 不传入 encodding 参数,则以 ArrayBuffer 方式读取
- // filePath: `${res.tempFilePaths[0]}`,
- // success: ({ data }) => {
- // console.log(data)
- // const arrayBuffer = data; // 文件的 ArrayBuffer 数据
- // const base64 = my.arrayBufferToBase64(arrayBuffer);
- // _this.setData({
- // fileUrl: `data:image/png;base64,${base64}`
- // })
- // console.log("base64", `data:image/png;base64,${base64}`);
- // },
- // });
- },
- fail: function (err) {
- console.log(err);
- },
- });
- } else if (type == 'video') {
- my.chooseVideo({
- // 可以根据您的业务按需选择使用 [‘camera'] 或者 ['album', 'camera']
- sourceType: ['album'],
- success: async function (res) {
- console.log(res);
- const tempFilePath = res.tempFilePath;
- const uploader = new FileUploader({
- filePath: tempFilePath, // 文件路径
- chunkSize: 512 * 1024, // 每片大小为 512KB
- fileName: '测试视频', // 文件名
- retryLimit: 3 // 每片的最大重试次数
- });
- // 开始上传
- uploader.startUpload((e) => {
- console.log('callback', e)
- _this.setData({
- 'videoChunkItem.chunkIndex': e.chunkIndex + 1,
- 'videoChunkItem.totalChunks': e.totalChunks,
- })
- })
- _this.setData({
- 'videoChunkItem.url': tempFilePath,
- 'videoChunkItem.width': res.width,
- 'videoChunkItem.height': res.height,
- })
- // // 2. 读取文件内容为 ArrayBuffer
- // const fileManager = my.getFileSystemManager();
- // fileManager.readFile({
- // filePath: tempFilePath,
- // success: ({ data }) => {
- // const arrayBuffer = data; // 文件的 ArrayBuffer 数据
- // console.log(arrayBuffer)
- // },
- // fail: (err) => {
- // console.error('文件读取失败', err);
- // }
- // });
- },
- fail: function (err) {
- console.log(err);
- },
- });
- }*/
- },
- goToWebView() {
- // my.getLocation({
- // type: 1, // 获取经纬度和省市区县数据
- // success: (res) => {
- // console.log(res);
- // my.showModal({
- // title: '提示',
- // content: res && JSON.stringify(res),
- // success: function(res) {
- // console.log(res);
- // },
- // fail: function(err) {
- // console.log(err);
- // }
- // });
- // },
- // fail: (error) => {
- // console.error('定位失败: ', JSON.stringify(error));
- // },
- // complete: (res) => {
- // console.log(res);
- // },
- // });
- my.navigateTo({
- url: '/pages/digitalHumans/digitalHumans'
- })
- },
- onReady() {
- // 页面加载完成
- },
- onShow() {
- this.setData({
- systemInfo: app.data.systemInfo,
- systemInfoStr: JSON.stringify(app.data.systemInfo),
- isKEightDevice: app.data.isKEightDevice,
- initObj: null,
- initResult: null,
- oneVNObj: null,
- oneVNResult: null,
- authObj: null,
- authResult: null
- });
- this.updateConfig();
- },
- onHide() {
- // 页面隐藏
- },
- onUnload() {
- // 页面被关闭
- },
- onTitleClick() {
- // 标题被点击
- },
- onPullDownRefresh() {
- // 页面被下拉
- },
- onReachBottom() {
- // 页面被拉到底部
- },
- onShareAppMessage() {
- // 返回自定义分享信息
- },
- // 页面的 onPageScroll 事件处理函数
- onPageScroll: debounce(function (e) {
- // 创建选择器对象
- const query = my.createSelectorQuery();
- console.log(e)
- query.selectAll('.scroll-item')
- .boundingClientRect()
- .exec((res) => {
- // console.log('ssssssssssssssssssssss===', res[0]);
- let obj = (res[0] || []).filter(fv => fv.bottom > 0)[0] || {}
- console.log(obj, obj.dataset.id)
- this.setData({
- activeTab: obj.dataset.id
- })
- // bottom height
- });
- }, 100),
- });
|