@gov-api-package/subscribe-manager
Advanced tools
Comparing version 1.0.6 to 1.0.7
@@ -1,1 +0,1 @@ | ||
"use strict";function createCommonjsModule(e,t){return e(t={exports:{}},t.exports),t.exports}var crypt=createCommonjsModule(function(e){var o,n;o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",n={rotl:function(e,t){return e<<t|e>>>32-t},rotr:function(e,t){return e<<32-t|e>>>t},endian:function(e){if(e.constructor==Number)return 16711935&n.rotl(e,8)|4278255360&n.rotl(e,24);for(var t=0;t<e.length;t++)e[t]=n.endian(e[t]);return e},randomBytes:function(e){for(var t=[];0<e;e--)t.push(Math.floor(256*Math.random()));return t},bytesToWords:function(e){for(var t=[],n=0,a=0;n<e.length;n++,a+=8)t[a>>>5]|=e[n]<<24-a%32;return t},wordsToBytes:function(e){for(var t=[],n=0;n<32*e.length;n+=8)t.push(e[n>>>5]>>>24-n%32&255);return t},bytesToHex:function(e){for(var t=[],n=0;n<e.length;n++)t.push((e[n]>>>4).toString(16)),t.push((15&e[n]).toString(16));return t.join("")},hexToBytes:function(e){for(var t=[],n=0;n<e.length;n+=2)t.push(parseInt(e.substr(n,2),16));return t},bytesToBase64:function(e){for(var t=[],n=0;n<e.length;n+=3)for(var a=e[n]<<16|e[n+1]<<8|e[n+2],r=0;r<4;r++)8*n+6*r<=8*e.length?t.push(o.charAt(a>>>6*(3-r)&63)):t.push("=");return t.join("")},base64ToBytes:function(e){e=e.replace(/[^A-Z0-9+\/]/gi,"");for(var t=[],n=0,a=0;n<e.length;a=++n%4)0!=a&&t.push((o.indexOf(e.charAt(n-1))&Math.pow(2,-2*a+8)-1)<<2*a|o.indexOf(e.charAt(n))>>>6-2*a);return t}},e.exports=n}),charenc={utf8:{stringToBytes:function(e){return charenc.bin.stringToBytes(unescape(encodeURIComponent(e)))},bytesToString:function(e){return decodeURIComponent(escape(charenc.bin.bytesToString(e)))}},bin:{stringToBytes:function(e){for(var t=[],n=0;n<e.length;n++)t.push(255&e.charCodeAt(n));return t},bytesToString:function(e){for(var t=[],n=0;n<e.length;n++)t.push(String.fromCharCode(e[n]));return t.join("")}}},charenc_1=charenc,isBuffer_1=function(e){return null!=e&&(isBuffer(e)||isSlowBuffer(e)||!!e._isBuffer)};function isBuffer(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function isSlowBuffer(e){return"function"==typeof e.readFloatLE&&"function"==typeof e.slice&&isBuffer(e.slice(0,0))}var md5=createCommonjsModule(function(e){function m(d,f){d.constructor==String?d=(f&&"binary"===f.encoding?w:h).stringToBytes(d):b(d)?d=Array.prototype.slice.call(d,0):Array.isArray(d)||d.constructor===Uint8Array||(d=d.toString());for(var e=S.bytesToWords(d),f=8*d.length,t=1732584193,n=-271733879,a=-1732584194,r=271733878,o=0;o<e.length;o++)e[o]=16711935&(e[o]<<8|e[o]>>>24)|4278255360&(e[o]<<24|e[o]>>>8);e[f>>>5]|=128<<f%32,e[14+(64+f>>>9<<4)]=f;for(var s=m._ff,i=m._gg,u=m._hh,c=m._ii,o=0;o<e.length;o+=16){var p=t,l=n,y=a,g=r,t=s(t,n,a,r,e[o+0],7,-680876936),r=s(r,t,n,a,e[o+1],12,-389564586),a=s(a,r,t,n,e[o+2],17,606105819),n=s(n,a,r,t,e[o+3],22,-1044525330);t=s(t,n,a,r,e[o+4],7,-176418897),r=s(r,t,n,a,e[o+5],12,1200080426),a=s(a,r,t,n,e[o+6],17,-1473231341),n=s(n,a,r,t,e[o+7],22,-45705983),t=s(t,n,a,r,e[o+8],7,1770035416),r=s(r,t,n,a,e[o+9],12,-1958414417),a=s(a,r,t,n,e[o+10],17,-42063),n=s(n,a,r,t,e[o+11],22,-1990404162),t=s(t,n,a,r,e[o+12],7,1804603682),r=s(r,t,n,a,e[o+13],12,-40341101),a=s(a,r,t,n,e[o+14],17,-1502002290),t=i(t,n=s(n,a,r,t,e[o+15],22,1236535329),a,r,e[o+1],5,-165796510),r=i(r,t,n,a,e[o+6],9,-1069501632),a=i(a,r,t,n,e[o+11],14,643717713),n=i(n,a,r,t,e[o+0],20,-373897302),t=i(t,n,a,r,e[o+5],5,-701558691),r=i(r,t,n,a,e[o+10],9,38016083),a=i(a,r,t,n,e[o+15],14,-660478335),n=i(n,a,r,t,e[o+4],20,-405537848),t=i(t,n,a,r,e[o+9],5,568446438),r=i(r,t,n,a,e[o+14],9,-1019803690),a=i(a,r,t,n,e[o+3],14,-187363961),n=i(n,a,r,t,e[o+8],20,1163531501),t=i(t,n,a,r,e[o+13],5,-1444681467),r=i(r,t,n,a,e[o+2],9,-51403784),a=i(a,r,t,n,e[o+7],14,1735328473),t=u(t,n=i(n,a,r,t,e[o+12],20,-1926607734),a,r,e[o+5],4,-378558),r=u(r,t,n,a,e[o+8],11,-2022574463),a=u(a,r,t,n,e[o+11],16,1839030562),n=u(n,a,r,t,e[o+14],23,-35309556),t=u(t,n,a,r,e[o+1],4,-1530992060),r=u(r,t,n,a,e[o+4],11,1272893353),a=u(a,r,t,n,e[o+7],16,-155497632),n=u(n,a,r,t,e[o+10],23,-1094730640),t=u(t,n,a,r,e[o+13],4,681279174),r=u(r,t,n,a,e[o+0],11,-358537222),a=u(a,r,t,n,e[o+3],16,-722521979),n=u(n,a,r,t,e[o+6],23,76029189),t=u(t,n,a,r,e[o+9],4,-640364487),r=u(r,t,n,a,e[o+12],11,-421815835),a=u(a,r,t,n,e[o+15],16,530742520),t=c(t,n=u(n,a,r,t,e[o+2],23,-995338651),a,r,e[o+0],6,-198630844),r=c(r,t,n,a,e[o+7],10,1126891415),a=c(a,r,t,n,e[o+14],15,-1416354905),n=c(n,a,r,t,e[o+5],21,-57434055),t=c(t,n,a,r,e[o+12],6,1700485571),r=c(r,t,n,a,e[o+3],10,-1894986606),a=c(a,r,t,n,e[o+10],15,-1051523),n=c(n,a,r,t,e[o+1],21,-2054922799),t=c(t,n,a,r,e[o+8],6,1873313359),r=c(r,t,n,a,e[o+15],10,-30611744),a=c(a,r,t,n,e[o+6],15,-1560198380),n=c(n,a,r,t,e[o+13],21,1309151649),t=c(t,n,a,r,e[o+4],6,-145523070),r=c(r,t,n,a,e[o+11],10,-1120210379),a=c(a,r,t,n,e[o+2],15,718787259),n=c(n,a,r,t,e[o+9],21,-343485551),t=t+p>>>0,n=n+l>>>0,a=a+y>>>0,r=r+g>>>0}return S.endian([t,n,a,r])}var S,h,b,w;S=crypt,h=charenc_1.utf8,b=isBuffer_1,w=charenc_1.bin,m._ff=function(e,t,n,a,r,o,s){e=e+(t&n|~t&a)+(r>>>0)+s;return(e<<o|e>>>32-o)+t},m._gg=function(e,t,n,a,r,o,s){e=e+(t&a|n&~a)+(r>>>0)+s;return(e<<o|e>>>32-o)+t},m._hh=function(e,t,n,a,r,o,s){e=e+(t^n^a)+(r>>>0)+s;return(e<<o|e>>>32-o)+t},m._ii=function(e,t,n,a,r,o,s){e=e+(n^(t|~a))+(r>>>0)+s;return(e<<o|e>>>32-o)+t},m._blocksize=16,m._digestsize=16,e.exports=function(e,t){if(null==e)throw new Error("Illegal argument "+e);e=S.wordsToBytes(m(e,t));return t&&t.asBytes?e:t&&t.asString?w.bytesToString(e):S.bytesToHex(e)}});const SUB_HOST="https://zw.baidusmartapps.com",SUB_QUERY=SUB_HOST+"/ma/zw/subscribe/get_subscribe",SUB_UPDATE=SUB_HOST+"/ma/zw/subscribe/miniapp/subscribe",SUB_MODIFY_INTERVENE=SUB_HOST+"/ma/zw/subscribe/miniapp/modifyintervene",CITY_LIST=SUB_HOST+"/ma/zw/city_list";let locationMap=null;const SUB_SOURCE_MAP={baiduboxapp:405384,bdlite:10014697,tomas:23164036,defaultValue:405384};let appKey,res=swan.getEnvInfoSync();res instanceof Error&&(res={}),appKey=res.appKey||"";const getSystemInfo=()=>new Promise((t,e)=>{swan.getSystemInfo({success:e=>{t(e)},fail:e})});async function getSwanId(){return new Promise((t,e)=>{swan.getSwanId({success(e){t(e.data.swanid)},fail:e})})}async function getQuerySubParams(e){var t=Date.now().toString(),n=await md5(`timestamp=${t}&appKey=`+appKey);return{data:{card_flag:e,appKey:appKey,timestamp:t,sign:n},header:{"Content-Type":"application/x-www-form-urlencoded"},method:"POST"}}async function querySub(e,a){const{data:r,header:o,method:s}=await getQuerySubParams(e);return new Promise((t,n)=>{r.openId=a,swan.request({url:SUB_QUERY,data:r,header:o,method:s,success:e=>{e.data&&!+e.data.status?t(e.data.data[0]):n(e.data)},fail:n})})}async function getCityList(){if(locationMap)return Promise.resolve(locationMap);const t=Date.now().toString(),a=await md5(`timestamp=${t}&appKey=`+appKey);return new Promise((n,e)=>{swan.request({url:CITY_LIST,data:{timestamp:t,appKey:appKey,sign:a},success:e=>{if(e&&e.data&&0===e.data.code){const o=["北京","上海","天津","重庆"],t=e.data.data;locationMap=new Map,t.forEach(e=>{const{label:t,value:n,children:a}=e,r=o.includes(t)?t+"市":t;locationMap.set(r,String(n)),a.forEach(e=>{var{label:e,value:t}=e,e=o.includes(e)?e+"市":e;locationMap.set(r+e,String(t))})}),n(locationMap)}},fail:e})})}async function getLocation(){return new Promise((e,t)=>{swan.getLocation({type:"gcj02",success:e,fail:t})})}async function getUpdateSubParams(e,t,d,n){let a={};if(n){var{intervene:n,interveneType:r}=n;if(n)a.intervene=n;else if(r&&+r<=2)try{var o=await Promise.all([getCityList(),getLocation()]);if(o){const c=o[0]||null;var s,i=o[1]||null;c&&i&&({city:u,province:s}=i,u&&s&&(a.intervene=JSON.stringify([{type:r,value:c.get(1==+r?s+u:s)}])))}}catch(e){}}var{platform:n,host:o}=await getSystemInfo(),i=await getSwanId(),r=Date.now().toString(),u=await md5(`timestamp=${r}&appKey=`+appKey);return{method:"POST",data:{subscribeID:e,opType:t,sourceFlag:d,source:1,appKey:appKey,timestamp:r,swanId:i,sourceApp:getSourceApp(o),deviceType:"android"===n?2:1,sign:u,...a},header:{"Content-Type":"application/x-www-form-urlencoded"}}}async function updateSub(e,a,t,n,r){const{method:o,data:s,header:i}=await getUpdateSubParams(e,t,n,r);return new Promise((t,n)=>{s.openId=a,swan.request({url:SUB_UPDATE,method:o,data:s,header:i,success:e=>{e.data.code&&(e.data.code=+e.data.code),e.data&&(e.data.sendData=s),e.data?t(e.data):n()},fail:n})})}async function modifyIntervene(e,n,t,a,r){const{method:o,data:s,header:i}=await getUpdateSubParams(e,t,a);return new Promise((t,e)=>{swan.request({url:SUB_MODIFY_INTERVENE,method:o,data:{openId:n,intervene:JSON.stringify(r),...s},header:i,success:e=>{t(e)},fail:e})})}function toManage(){swan.navigateToSmartProgram({appKey:"FV8FuO4q887e9aj54GZpQHlwEUOd1XVc",path:"/pages/home/index"})}const addSub=(e,t,n,a)=>updateSub(e,t,1,n,a),cancelSub=(e,t,n)=>updateSub(e,t,0,n),getSourceApp=e=>SUB_SOURCE_MAP[e]||SUB_SOURCE_MAP.defaultValue;var index={querySub:querySub,addSub:addSub,cancelSub:cancelSub,toManage:toManage,modifyIntervene:modifyIntervene};module.exports=index; | ||
"use strict";function createCommonjsModule(e,t){return e(t={exports:{}},t.exports),t.exports}var crypt=createCommonjsModule(function(e){var o,n;o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",n={rotl:function(e,t){return e<<t|e>>>32-t},rotr:function(e,t){return e<<32-t|e>>>t},endian:function(e){if(e.constructor==Number)return 16711935&n.rotl(e,8)|4278255360&n.rotl(e,24);for(var t=0;t<e.length;t++)e[t]=n.endian(e[t]);return e},randomBytes:function(e){for(var t=[];0<e;e--)t.push(Math.floor(256*Math.random()));return t},bytesToWords:function(e){for(var t=[],n=0,a=0;n<e.length;n++,a+=8)t[a>>>5]|=e[n]<<24-a%32;return t},wordsToBytes:function(e){for(var t=[],n=0;n<32*e.length;n+=8)t.push(e[n>>>5]>>>24-n%32&255);return t},bytesToHex:function(e){for(var t=[],n=0;n<e.length;n++)t.push((e[n]>>>4).toString(16)),t.push((15&e[n]).toString(16));return t.join("")},hexToBytes:function(e){for(var t=[],n=0;n<e.length;n+=2)t.push(parseInt(e.substr(n,2),16));return t},bytesToBase64:function(e){for(var t=[],n=0;n<e.length;n+=3)for(var a=e[n]<<16|e[n+1]<<8|e[n+2],r=0;r<4;r++)8*n+6*r<=8*e.length?t.push(o.charAt(a>>>6*(3-r)&63)):t.push("=");return t.join("")},base64ToBytes:function(e){e=e.replace(/[^A-Z0-9+\/]/gi,"");for(var t=[],n=0,a=0;n<e.length;a=++n%4)0!=a&&t.push((o.indexOf(e.charAt(n-1))&Math.pow(2,-2*a+8)-1)<<2*a|o.indexOf(e.charAt(n))>>>6-2*a);return t}},e.exports=n}),charenc={utf8:{stringToBytes:function(e){return charenc.bin.stringToBytes(unescape(encodeURIComponent(e)))},bytesToString:function(e){return decodeURIComponent(escape(charenc.bin.bytesToString(e)))}},bin:{stringToBytes:function(e){for(var t=[],n=0;n<e.length;n++)t.push(255&e.charCodeAt(n));return t},bytesToString:function(e){for(var t=[],n=0;n<e.length;n++)t.push(String.fromCharCode(e[n]));return t.join("")}}},charenc_1=charenc,isBuffer_1=function(e){return null!=e&&(isBuffer(e)||isSlowBuffer(e)||!!e._isBuffer)};function isBuffer(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function isSlowBuffer(e){return"function"==typeof e.readFloatLE&&"function"==typeof e.slice&&isBuffer(e.slice(0,0))}var md5=createCommonjsModule(function(e){function m(e,t){e.constructor==String?e=(t&&"binary"===t.encoding?w:h).stringToBytes(e):b(e)?e=Array.prototype.slice.call(e,0):Array.isArray(e)||e.constructor===Uint8Array||(e=e.toString());for(var n=S.bytesToWords(e),t=8*e.length,a=1732584193,r=-271733879,o=-1732584194,s=271733878,i=0;i<n.length;i++)n[i]=16711935&(n[i]<<8|n[i]>>>24)|4278255360&(n[i]<<24|n[i]>>>8);n[t>>>5]|=128<<t%32,n[14+(64+t>>>9<<4)]=t;for(var u=m._ff,c=m._gg,d=m._hh,f=m._ii,i=0;i<n.length;i+=16){var p=a,l=r,y=o,g=s,a=u(a,r,o,s,n[i+0],7,-680876936),s=u(s,a,r,o,n[i+1],12,-389564586),o=u(o,s,a,r,n[i+2],17,606105819),r=u(r,o,s,a,n[i+3],22,-1044525330);a=u(a,r,o,s,n[i+4],7,-176418897),s=u(s,a,r,o,n[i+5],12,1200080426),o=u(o,s,a,r,n[i+6],17,-1473231341),r=u(r,o,s,a,n[i+7],22,-45705983),a=u(a,r,o,s,n[i+8],7,1770035416),s=u(s,a,r,o,n[i+9],12,-1958414417),o=u(o,s,a,r,n[i+10],17,-42063),r=u(r,o,s,a,n[i+11],22,-1990404162),a=u(a,r,o,s,n[i+12],7,1804603682),s=u(s,a,r,o,n[i+13],12,-40341101),o=u(o,s,a,r,n[i+14],17,-1502002290),a=c(a,r=u(r,o,s,a,n[i+15],22,1236535329),o,s,n[i+1],5,-165796510),s=c(s,a,r,o,n[i+6],9,-1069501632),o=c(o,s,a,r,n[i+11],14,643717713),r=c(r,o,s,a,n[i+0],20,-373897302),a=c(a,r,o,s,n[i+5],5,-701558691),s=c(s,a,r,o,n[i+10],9,38016083),o=c(o,s,a,r,n[i+15],14,-660478335),r=c(r,o,s,a,n[i+4],20,-405537848),a=c(a,r,o,s,n[i+9],5,568446438),s=c(s,a,r,o,n[i+14],9,-1019803690),o=c(o,s,a,r,n[i+3],14,-187363961),r=c(r,o,s,a,n[i+8],20,1163531501),a=c(a,r,o,s,n[i+13],5,-1444681467),s=c(s,a,r,o,n[i+2],9,-51403784),o=c(o,s,a,r,n[i+7],14,1735328473),a=d(a,r=c(r,o,s,a,n[i+12],20,-1926607734),o,s,n[i+5],4,-378558),s=d(s,a,r,o,n[i+8],11,-2022574463),o=d(o,s,a,r,n[i+11],16,1839030562),r=d(r,o,s,a,n[i+14],23,-35309556),a=d(a,r,o,s,n[i+1],4,-1530992060),s=d(s,a,r,o,n[i+4],11,1272893353),o=d(o,s,a,r,n[i+7],16,-155497632),r=d(r,o,s,a,n[i+10],23,-1094730640),a=d(a,r,o,s,n[i+13],4,681279174),s=d(s,a,r,o,n[i+0],11,-358537222),o=d(o,s,a,r,n[i+3],16,-722521979),r=d(r,o,s,a,n[i+6],23,76029189),a=d(a,r,o,s,n[i+9],4,-640364487),s=d(s,a,r,o,n[i+12],11,-421815835),o=d(o,s,a,r,n[i+15],16,530742520),a=f(a,r=d(r,o,s,a,n[i+2],23,-995338651),o,s,n[i+0],6,-198630844),s=f(s,a,r,o,n[i+7],10,1126891415),o=f(o,s,a,r,n[i+14],15,-1416354905),r=f(r,o,s,a,n[i+5],21,-57434055),a=f(a,r,o,s,n[i+12],6,1700485571),s=f(s,a,r,o,n[i+3],10,-1894986606),o=f(o,s,a,r,n[i+10],15,-1051523),r=f(r,o,s,a,n[i+1],21,-2054922799),a=f(a,r,o,s,n[i+8],6,1873313359),s=f(s,a,r,o,n[i+15],10,-30611744),o=f(o,s,a,r,n[i+6],15,-1560198380),r=f(r,o,s,a,n[i+13],21,1309151649),a=f(a,r,o,s,n[i+4],6,-145523070),s=f(s,a,r,o,n[i+11],10,-1120210379),o=f(o,s,a,r,n[i+2],15,718787259),r=f(r,o,s,a,n[i+9],21,-343485551),a=a+p>>>0,r=r+l>>>0,o=o+y>>>0,s=s+g>>>0}return S.endian([a,r,o,s])}var S,h,b,w;S=crypt,h=charenc_1.utf8,b=isBuffer_1,w=charenc_1.bin,m._ff=function(e,t,n,a,r,o,s){e=e+(t&n|~t&a)+(r>>>0)+s;return(e<<o|e>>>32-o)+t},m._gg=function(e,t,n,a,r,o,s){e=e+(t&a|n&~a)+(r>>>0)+s;return(e<<o|e>>>32-o)+t},m._hh=function(e,t,n,a,r,o,s){e=e+(t^n^a)+(r>>>0)+s;return(e<<o|e>>>32-o)+t},m._ii=function(e,t,n,a,r,o,s){e=e+(n^(t|~a))+(r>>>0)+s;return(e<<o|e>>>32-o)+t},m._blocksize=16,m._digestsize=16,e.exports=function(e,t){if(null==e)throw new Error("Illegal argument "+e);e=S.wordsToBytes(m(e,t));return t&&t.asBytes?e:t&&t.asString?w.bytesToString(e):S.bytesToHex(e)}});const SUB_HOST="https://zw.baidusmartapps.com",SUB_QUERY=SUB_HOST+"/ma/zw/subscribe/get_subscribe",SUB_UPDATE=SUB_HOST+"/ma/zw/subscribe/miniapp/subscribe",SUB_MODIFY_INTERVENE=SUB_HOST+"/ma/zw/subscribe/miniapp/modifyintervene",CITY_LIST=SUB_HOST+"/ma/zw/city_list";let locationMap=null;const SUB_SOURCE_MAP={baiduboxapp:405384,bdlite:10014697,tomas:23164036,defaultValue:405384};let appKey,res=swan.getEnvInfoSync();res instanceof Error&&(res={}),appKey=res.appKey||"";const getSystemInfo=()=>new Promise((t,e)=>{swan.getSystemInfo({success:e=>{t(e)},fail:e})});async function getSwanId(){return new Promise((t,e)=>{swan.getSwanId({success(e){t(e.data.swanid)},fail:e})})}async function getQuerySubParams(e){var t=Date.now().toString(),n=await md5(`timestamp=${t}&appKey=`+appKey);return{data:{card_flag:e,appKey:appKey,timestamp:t,sign:n},header:{"Content-Type":"application/x-www-form-urlencoded"},method:"POST"}}async function querySub(e,a){const{data:r,header:o,method:s}=await getQuerySubParams(e);return new Promise((t,n)=>{r.openId=a,swan.request({url:SUB_QUERY,data:r,header:o,method:s,success:e=>{e.data&&!+e.data.status?t(e.data.data[0]):n(e.data)},fail:n})})}async function getCityList(){if(locationMap)return Promise.resolve(locationMap);const t=Date.now().toString(),a=await md5(`timestamp=${t}&appKey=`+appKey);return new Promise((n,e)=>{swan.request({url:CITY_LIST,data:{timestamp:t,appKey:appKey,sign:a},success:e=>{if(e&&e.data&&0===e.data.code){const o=["北京","上海","天津","重庆"],t=e.data.data;locationMap=new Map,t.forEach(e=>{const{label:t,value:n,children:a}=e,r=o.includes(t)?t+"市":t;locationMap.set(r,String(n)),a.forEach(e=>{var{label:e,value:t}=e,e=o.includes(e)?e+"市":e;locationMap.set(r+e,String(t))})}),n(locationMap)}},fail:e})})}async function getLocation(){return new Promise((e,t)=>{swan.getLocation({type:"gcj02",success:e,fail:t})})}async function getUpdateSubParams(e,t,n,a){let r={};if(a){var{intervene:a,interveneType:o}=a;if(a)r.intervene=a;else if(o&&+o<=2)try{var s=await Promise.all([getCityList(),getLocation()]);if(s){const d=s[0]||null;var i,u=s[1]||null;d&&u&&({city:c,province:i}=u,c&&i&&(r.intervene=JSON.stringify([{type:o,value:d.get(1==+o?i+c:i)}])))}}catch(e){}}var{platform:a,host:s}=await getSystemInfo(),u=await getSwanId(),o=Date.now().toString(),c=await md5(`timestamp=${o}&appKey=`+appKey);return{method:"POST",data:{subscribeID:e,opType:t,sourceFlag:n,source:1,appKey:appKey,timestamp:o,swanId:u,sourceApp:getSourceApp(s),deviceType:"android"===a?2:1,sign:c,...r},header:{"Content-Type":"application/x-www-form-urlencoded"}}}async function updateSub(e,a,t,n,r){const{method:o,data:s,header:i}=await getUpdateSubParams(e,t,n,r);return new Promise((t,n)=>{s.openId=a,swan.request({url:SUB_UPDATE,method:o,data:s,header:i,success:e=>{e.data.code&&(e.data.code=+e.data.code),e.data&&(e.data.sendData=s),e.data?t(e.data):n()},fail:n})})}async function modifyIntervene(e,n,t,a,r){const{method:o,data:s,header:i}=await getUpdateSubParams(e,t,a);return new Promise((t,e)=>{swan.request({url:SUB_MODIFY_INTERVENE,method:o,data:{openId:n,intervene:JSON.stringify(r),...s},header:i,success:e=>{t(e)},fail:e})})}function toManage(){swan.navigateToSmartProgram({appKey:"FV8FuO4q887e9aj54GZpQHlwEUOd1XVc",path:"/pages/home/index"})}const addSub=(e,t,n,a)=>updateSub(e,t,1,n,a),cancelSub=(e,t,n)=>updateSub(e,t,0,n),getSourceApp=e=>SUB_SOURCE_MAP[e]||SUB_SOURCE_MAP.defaultValue;var index={querySub:querySub,addSub:addSub,cancelSub:cancelSub,toManage:toManage,modifyIntervene:modifyIntervene};module.exports=index; |
{ | ||
"name": "@gov-api-package/subscribe-manager", | ||
"version": "1.0.6", | ||
"version": "1.0.7", | ||
"description": "订阅和订阅状态查询", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
1