{"id":29636,"date":"2024-11-25T15:36:46","date_gmt":"2024-11-25T07:36:46","guid":{"rendered":"https:\/\/fwq.ai\/blog\/29636\/"},"modified":"2024-11-25T15:36:46","modified_gmt":"2024-11-25T07:36:46","slug":"%e5%be%ae%e4%bf%a1jssdk%e6%8e%a5%e5%8f%a3%e5%be%97%e5%88%b0%e7%9a%84%e5%9b%be%e7%89%87%e6%98%be%e7%a4%ba%e9%97%ae%e9%a2%98","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/29636\/","title":{"rendered":"\u5fae\u4fe1jssdk\u63a5\u53e3\u5f97\u5230\u7684\u56fe\u7247\u663e\u793a\u95ee\u9898"},"content":{"rendered":"<p>\u8fd9\u51e0\u5929\u7814\u7a76\u4e86\u4e00\u4e0b\u8fd9\u4e2a\u5fae\u4fe1\u516c\u4f17\u5e73\u53f0\u7684\u5f00\u53d1\u7684\u95ee\u9898<br \/>\u5728\u4f7f\u7528chooseimage\u8c03\u7528\u83b7\u53d6\u5230\u4e86\u7684\u65f6\u5019\u4e00\u76f4\u663e\u793a\u4e0d\u51fa\u6765\uff0c\u767e\u5ea6\u4e86\u4e00\u4e9b\u5e16\u5b50\u7ed3\u679c\u90fd\u4e0d\u662f\u5f88\u597d\uff0c\u540e\u6765\u7ec8\u4e8e\u7814\u7a76\u51fa\u6765\u600e\u4e48\u663e\u793a\u51fa\u6765\u4e86\uff0c\u73b0\u5728\u5199\u51fa\u6765\u505a\u4e00\u4e2a\u5907\u4efd<\/p>\n<p>\u4f7f\u7528\u5fae\u4fe1DK\u7684\u65f6\u5019\u9047\u5230\u7684\u4e00\u4e9b\u95ee\u9898<br \/>\u5728\u914d\u7f6eS\u63a5\u53e3\u57df\u540d\u7684\u65f6\u5019\u9700\u8981\u7528\u4e00\u7ea7\u57df\u540d\uff0c\u4e0d\u80fd\u4f7f\u7528\u4e8c\u7ea7\u57df\u540d\uff0c\u5e76\u4e14\u4e0d\u80fd\u5e26http \u6216\u8005https<br \/>\u5982\u6211\u7684\u6d4b\u8bd5\u56fe\u7247\u7f51\u5740\u662f<\/p>\n<h2>applinzi.com<\/h2>\n<hr>\n<pre>\/\/html\u91cc\u7684\u4e3b\u8981\u4ee3\u7801\r\n&lt;body ontouchstart=\"\"&gt;\r\n \u4e0a\u4f20\u56fe\u7247\u7684\u6d4b\u8bd5\r\n \u56fe\u50cf\u63a5\u53e3\r\n      &lt;span class=\"desc\"&gt;\u62cd\u7167\u6216\u4ece\u624b\u673a\u76f8\u518c\u4e2d\u9009\u56fe\u63a5\u53e3&lt;\/span&gt;\r\n      &lt;button class=\"btn btn_primary\" id=\"chooseImage\" onclick=\"chooseImg_Opinion()\"&gt;chooseImage&lt;\/button&gt;\r\n    &lt;span&gt;\u56fe\u7247\u9884\u89c8&lt;\/span&gt;\r\n    &lt;p id=\"photo\"&gt;&lt;\/p&gt;\r\n&lt;\/body&gt;\r\n\r\n\/\/js\u91cc\u7684\u4e3b\u8981\u4ee3\u7801\r\n&lt;script&gt;\r\n    wx.ready(function () {\r\n        \/\/\u81ea\u52a8\u6267\u884c\u7684\r\n        wx.checkJsApi({\r\n            jsApiList: [\r\n                'chooseImage',\r\n            ],\r\n            success: function (res) {\r\n                \/\/ alert(JSON.stringify(res));\r\n                \/\/ alert(JSON.stringify(res.checkResult.getLocation));\r\n                \/\/ if (res.checkResult.getLocation == false) {\r\n                    \/\/ alert('\u4f60\u7684\u5fae\u4fe1\u7248\u672c\u592a\u4f4e\uff0c\u4e0d\u652f\u6301\u5fae\u4fe1JS\u63a5\u53e3\uff0c\u8bf7\u5347\u7ea7\u5230\u6700\u65b0\u7684\u5fae\u4fe1\u7248\u672c\uff01');\r\n                    \/\/ return;\r\n                \/\/ }\r\n            }\r\n        });\r\n    });\r\n    wx.error(function (res) {\r\n        alert(res.errMsg);\r\n    });\r\n function chooseImg_Opinion() {\r\n                wx.chooseImage({\r\n                    success: function (res) {\r\n                        showImgs_Opinion(res);\r\n                    }\r\n                });\r\n            }\r\n function showImgs_Opinion(res) {\r\n\/\/\u4e3b\u8981\u662f\u8fd9\u4e00\u5757\u7684\u4ee3\u7801\r\n     var parent = document.getElementById('photo');\r\n     var p = document.createElement(\"p\");\r\n    \/\/\u8bbe\u7f6e p \u5c5e\u6027\uff0c\u5982 id\r\n    p.setAttribute(\"id\", \"imgp\");\r\n     var _html=\"\";\r\n    for(var i in res.localIds){\r\n           var photoSrc=res.localIds[i];\r\n           _html=_html+'\r\n\u56fe\u7247'+i+':&lt;img  src=\"'+photoSrc+'\"    style=\"max-width:90%\"  style=\"max-width:90%\" \/ alt=\"\u5fae\u4fe1jssdk\u63a5\u53e3\u5f97\u5230\u7684\u56fe\u7247\u663e\u793a\u95ee\u9898\" &gt;\n';\r\n    }\r\n\u3000\u3000p.innerHTML = _html;\r\n\u3000\u3000parent.appendChild(p);\r\n &lt;\/script&gt;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5fae\u4fe1jssdk\u63a5\u53e3\u5f97\u5230\u7684\u56fe\u7247\u663e\u793a\u95ee\u9898\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8fd9\u51e0\u5929\u7814\u7a76\u4e86\u4e00\u4e0b\u8fd9\u4e2a\u5fae\u4fe1\u516c\u4f17\u5e73\u53f0\u7684\u5f00\u53d1\u7684\u95ee\u9898\u5728\u4f7f\u7528chooseimage\u8c03\u7528\u83b7\u53d6\u5230\u4e86\u7684\u65f6\u5019\u4e00\u76f4\u663e\u793a\u4e0d\u51fa\u6765\uff0c\u767e\u5ea6\u4e86\u4e00\u4e9b\u5e16\u5b50\u7ed3\u679c\u90fd\u4e0d\u662f\u5f88\u597d\uff0c\u540e\u6765\u7ec8\u4e8e\u7814\u7a76\u51fa\u6765\u600e\u4e48\u663e\u793a\u51fa\u6765\u4e86\uff0c\u73b0\u5728\u5199\u51fa\u6765\u505a\u4e00\u4e2a\u5907\u4efd \u4f7f\u7528\u5fae\u4fe1DK\u7684\u65f6\u5019\u9047\u5230\u7684\u4e00\u4e9b\u95ee\u9898\u5728\u914d\u7f6eS\u63a5\u53e3\u57df\u540d\u7684\u65f6\u5019\u9700\u8981\u7528\u4e00\u7ea7\u57df\u540d\uff0c\u4e0d\u80fd\u4f7f\u7528\u4e8c\u7ea7\u57df\u540d\uff0c\u5e76\u4e14\u4e0d\u80fd\u5e26http \u6216\u8005https\u5982\u6211\u7684\u6d4b\u8bd5\u56fe\u7247\u7f51\u5740\u662f applinzi.com \/\/html\u91cc\u7684\u4e3b\u8981\u4ee3\u7801 &lt;body ontouchstart=&#8221;&#8221;&gt; \u4e0a\u4f20\u56fe\u7247\u7684\u6d4b\u8bd5 \u56fe\u50cf\u63a5\u53e3 &lt;span class=&#8221;desc&#8221;&gt;\u62cd\u7167\u6216\u4ece\u624b\u673a\u76f8\u518c\u4e2d\u9009\u56fe\u63a5\u53e3&lt;\/span&gt; &lt;button class=&#8221;btn btn_primary&#8221; id=&#8221;chooseImage&#8221; onclick=&#8221;chooseImg_Opinion()&#8221;&gt;chooseImage&lt;\/button&gt; &lt;span&gt;\u56fe\u7247\u9884\u89c8&lt;\/span&gt; &lt;p id=&#8221;photo&#8221;&gt;&lt;\/p&gt; &lt;\/body&gt; \/\/js\u91cc\u7684\u4e3b\u8981\u4ee3\u7801 &lt;script&gt; wx.ready(function () { \/\/\u81ea\u52a8\u6267\u884c\u7684 wx.checkJsApi({ jsApiList: [ &#8216;chooseImage&#8217;, ], success: function (res) { \/\/ alert(JSON.stringify(res)); \/\/ alert(JSON.stringify(res.checkResult.getLocation)); \/\/ if (res.checkResult.getLocation == false) { \/\/ alert(&#8216;\u4f60\u7684\u5fae\u4fe1\u7248\u672c\u592a\u4f4e\uff0c\u4e0d\u652f\u6301\u5fae\u4fe1JS\u63a5\u53e3\uff0c\u8bf7\u5347\u7ea7\u5230\u6700\u65b0\u7684\u5fae\u4fe1\u7248\u672c\uff01&#8217;); \/\/ return; \/\/ } } }); }); wx.error(function [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[19],"tags":[],"class_list":["post-29636","post","type-post","status-publish","format-standard","hentry","category-19"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/29636","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=29636"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/29636\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=29636"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=29636"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=29636"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}