{"id":34261,"date":"2024-11-25T08:27:51","date_gmt":"2024-11-25T00:27:51","guid":{"rendered":"https:\/\/fwq.ai\/blog\/34261\/"},"modified":"2024-11-25T08:27:51","modified_gmt":"2024-11-25T00:27:51","slug":"%e5%bd%92%e7%ba%b3%e6%95%b4%e7%90%86%e5%be%ae%e4%bf%a1%e5%b0%8f%e7%a8%8b%e5%ba%8f%e6%9d%83%e9%99%90%e6%8e%a5%e5%8f%a3","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/34261\/","title":{"rendered":"\u5f52\u7eb3\u6574\u7406\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u6743\u9650\u63a5\u53e3"},"content":{"rendered":"<p>\u672c\u7bc7\u6587\u7ae0\u7ed9\u5927\u5bb6\u5e26\u6765\u4e86\u5173\u4e8e\u7684\u76f8\u5173\u95ee\u9898\uff0c\u5176\u4e2d\u4e3b\u8981\u4ecb\u7ecd\u4e86\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u4e2d\u7684\u6743\u9650\u63a5\u53e3\u7684\u76f8\u5173\u5185\u5bb9\uff0c\u5305\u62ec\u4e86\u7528\u6237\u6388\u6743\u63a5\u53e3\u3001\u83b7\u53d6\u7528\u6237\u6743\u9650\u8bbe\u7f6e\u63a5\u53e3\u3001\u6253\u5f00\u7528\u6237\u6743\u9650\u8bbe\u7f6e\u63a5\u53e3\u7b49\u5185\u5bb9\uff0c\u4e0b\u9762\u4e00\u8d77\u6765\u770b\u4e00\u4e0b\uff0c\u5e0c\u671b\u5bf9\u5927\u5bb6\u6709\u5e2e\u52a9\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/000\/000\/067\/6281c798dd20b552.png\" class=\"aligncenter\" title=\"\u5f52\u7eb3\u6574\u7406\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u6743\u9650\u63a5\u53e3\u63d2\u56fe\" alt=\"\u5f52\u7eb3\u6574\u7406\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u6743\u9650\u63a5\u53e3\u63d2\u56fe\" \/><\/p>\n<p>\u3010\u76f8\u5173\u5b66\u4e60\u63a8\u8350\uff1a\u3011<\/p>\n<h2>1\u3001\u6743\u9650\u63a5\u53e3<\/h2>\n<p>\u2003\u2003\u90e8\u5206\u63a5\u53e3\u9700\u8981\u7ecf\u8fc7\u7528\u6237\u6388\u6743\u7edf\u4e00\u624d\u80fd\u8c03\u7528\u3002\u6211\u4eec\u628a\u8fd9\u4e9b\u63a5\u53e3\u6309\u4f7f\u7528\u8303\u56f4\u5206\u6210\u591a\u4e2ascope\uff0c\u7528\u6237\u9009\u62e9\u5bf9scope\u8fdb\u884c\u6388\u6743\uff0c\u5f53\u6388\u6743\u7ed9\u4e00\u4e2ascope\u4e4b\u540e\uff0c\u5176\u5bf9\u5e94\u7684\u6240\u6709\u63a5\u53e3\u90fd\u53ef\u4ee5\u76f4\u63a5\u4f7f\u7528\uff0c\u6b64\u7c7b\u63a5\u53e3\u8c03\u7528\u65f6\uff1a<\/p>\n<ul>\n<li>\u5982\u679c\u7528\u6237\u672a\u63a5\u53d7\u6216\u62d2\u7edd\u6b64\u6743\u9650\uff0c\u4f1a\u5f39\u7a97\u8be2\u95ee\u7528\u6237\uff0c\u7528\u6237\u5355\u51fb\u7edf\u4e00\u540e\u65b9\u53ef\u8c03\u7528\u63a5\u53e3\u3002<\/li>\n<li>\u5982\u679c\u7528\u6237\u5df2\u6388\u6743\uff0c\u53ef\u4ee5\u76f4\u63a5\u8c03\u7528\u63a5\u53e3\u3002<\/li>\n<li>\u5982\u679c\u7528\u6237\u5df2\u62d2\u7edd\u6388\u6743\uff0c\u5219\u4e0d\u4f1a\u51fa\u73b0\u5f39\u7a97\uff0c\u800c\u4f1a\u76f4\u63a5\u8fdb\u5165\u63a5\u53e3fail\u56de\u8c03\u3002<\/li>\n<\/ul>\n<p>\u2003\u2003\u6b64\u7c7b\u63a5\u53e3\u518d\u6743\u9650\u4e2d\u7684\u5bf9\u8c61scope\u7684\u5b57\u6bb5\u548c\u63a5\u53e3\u7684\u5bf9\u5e94\u5173\u7cfb\u5982\u4e0b\u8868\u6240\u793a\u3002<\/p>\n<table>\n<thead>\n<tr>\n<th>scope<\/th>\n<th>\u5bf9\u5e94\u63a5\u53e3<\/th>\n<th>\u63cf\u8ff0<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>scope.userLocation<\/td>\n<td>wx.getLocation, wx.chooseLocation, wx.startLocationUpdate<\/td>\n<td>\u5730\u7406\u4f4d\u7f6e<\/td>\n<\/tr>\n<tr>\n<td>scope.userLocationBackground<\/td>\n<td>wx.startLocationUpdateBackground<\/td>\n<td>\u540e\u53f0\u5b9a\u4f4d<\/td>\n<\/tr>\n<tr>\n<td>scope.record<\/td>\n<td>wx.startRecord, wx.joinVoIPChat, RecorderManager.start<\/td>\n<td>\u9ea6\u514b\u98ce<\/td>\n<\/tr>\n<tr>\n<td>scope.camera<\/td>\n<td>camera\u7ec4\u4ef6, wx.createVKSession<\/td>\n<td>\u6444\u50cf\u5934<\/td>\n<\/tr>\n<tr>\n<td>scope.bluetooth<\/td>\n<td>wx.openBluetoothAdapter, wx.createBLEPeripheralServer<\/td>\n<td>\u84dd\u7259<\/td>\n<\/tr>\n<tr>\n<td>scope.writePhotosAlbum<\/td>\n<td>wx.saveImageToPhotosAlbum, wx.saveVideoToPhotosAlbum<\/td>\n<td>\u6dfb\u52a0\u5230\u76f8\u518c<\/td>\n<\/tr>\n<tr>\n<td>scope.addPhoneContact<\/td>\n<td>wx.wx.addPhoneContact<\/td>\n<td>\u6dfb\u52a0\u5230\u8054\u7cfb\u4eba<\/td>\n<\/tr>\n<tr>\n<td>scope.addPhoneCalendar<\/td>\n<td>wx.addPhoneRepeatCalendar, wx.addPhoneCalendar<\/td>\n<td>\u6dfb\u52a0\u5230\u65e5\u5386<\/td>\n<\/tr>\n<tr>\n<td>scope.werun<\/td>\n<td>wx.getWeRunData<\/td>\n<td>\u5fae\u4fe1\u8fd0\u52a8\u6b65\u6570<\/td>\n<\/tr>\n<tr>\n<td>scope.address<\/td>\n<td>wx.chooseAddress<\/td>\n<td>\u901a\u8baf\u5730\u5740\uff08\u5df2\u53d6\u6d88\u6388\u6743\uff0c\u53ef\u4ee5\u76f4\u63a5\u8c03\u7528\u5bf9\u5e94\u63a5\u53e3\uff09<\/td>\n<\/tr>\n<tr>\n<td>scope.invoiceTitle<\/td>\n<td>wx.chooseInvoiceTitle<\/td>\n<td>\u53d1\u7968\u62ac\u5934\uff08\u5df2\u53d6\u6d88\u6388\u6743\uff0c\u53ef\u4ee5\u76f4\u63a5\u8c03\u7528\u5bf9\u5e94\u63a5\u53e3\uff09<\/td>\n<\/tr>\n<tr>\n<td>scope.invoice<\/td>\n<td>wx.chooseInvoice<\/td>\n<td>\u83b7\u53d6\u53d1\u7968\uff08\u5df2\u53d6\u6d88\u6388\u6743\uff0c\u53ef\u4ee5\u76f4\u63a5\u8c03\u7528\u5bf9\u5e94\u63a5\u53e3\uff09<\/td>\n<\/tr>\n<tr>\n<td>scope.userInfo<\/td>\n<td>wx.getUserInfo<\/td>\n<td>\u7528\u6237\u4fe1\u606f\uff08\u5c0f\u7a0b\u5e8f\u5df2\u56de\u6536\uff0c\u8bf7\u4f7f\u7528\u5934\u50cf\u6635\u79f0\u586b\u5199\uff0c\u5c0f\u6e38\u620f\u53ef\u7ee7\u7eed\u8c03\u7528\uff09<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u2003\u2003\u5c0f\u7a0b\u5e8f\u63d0\u4f9b\u4e86\u4e09\u7ec4\u63a5\u53e3\u5bf9\u63a5\u53e3\u6743\u9650\u8fdb\u884c\u76f8\u5e94\u7684\u64cd\u4f5c\uff1awx.getSetting()\u83b7\u53d6\u7528\u6237\u5f53\u524d\u7684\u6388\u6743\u72b6\u6001\uff1bwx.openSetting()\u6253\u5f00\u8bbe\u7f6e\u754c\u9762\u4ee5\u5f15\u5bfc\u7528\u6237\u5f00\u542f\u6388\u6743\uff1bwx.authorize()\u6539\u53d8\u6388\u6743\u72b6\u6001\u3002<\/p>\n<h2>1.1 \u7528\u6237\u6388\u6743\u63a5\u53e3wx.authorize(Object object)<\/h2>\n<p>\u2003\u2003\u63d0\u524d\u5411\u7528\u6237\u53d1\u8d77\u6388\u6743\u8bf7\u6c42\u3002\u8be5\u63a5\u53e3\u8c03\u7528\u540e\u4f1a\u7acb\u523b\u5f39\u7a97\u8be2\u95ee\u7528\u6237\u662f\u5426\u540c\u610f\u6388\u6743\u5c0f\u7a0b\u5e8f\u4f7f\u7528\u67d0\u9879\u529f\u80fd\u6216\u83b7\u53d6\u7528\u6237\u7684\u67d0\u4e9b\u6570\u636e\uff0c\u4f46\u4e0d\u4f1a\u5b9e\u9645\u8c03\u7528\u5bf9\u5e94\u63a5\u53e3\u3002\u5982\u679c\u7528\u6237\u4e4b\u524d\u5df2\u7ecf\u540c\u610f\u6388\u6743\uff0c\u5219\u4e0d\u4f1a\u51fa\u73b0\u5f39\u7a97\uff0c\u76f4\u63a5\u8fd4\u56de\u6210\u529f\u3002\u5c5e\u6027\u5982\u4e0b\u8868\u6240\u793a\u3002<\/p>\n<table>\n<thead>\n<tr>\n<th>\u5c5e\u6027<\/th>\n<th>\u7c7b\u578b<\/th>\n<th>\u9ed8\u8ba4\u503c<\/th>\n<th>\u5fc5\u586b<\/th>\n<th>\u8bf4\u660e<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>scope<\/td>\n<td>string<\/td>\n<td><\/td>\n<td>\u662f<\/td>\n<td>\u9700\u8981\u83b7\u53d6\u6743\u9650\u7684 scope\uff0c\u8be6\u89c1 scope \u5217\u8868<\/td>\n<\/tr>\n<tr>\n<td>success<\/td>\n<td>function<\/td>\n<td><\/td>\n<td>\u5426<\/td>\n<td>\u63a5\u53e3\u8c03\u7528\u6210\u529f\u7684\u56de\u8c03\u51fd\u6570<\/td>\n<\/tr>\n<tr>\n<td>fail<\/td>\n<td>function<\/td>\n<td><\/td>\n<td>\u5426<\/td>\n<td>\u63a5\u53e3\u8c03\u7528\u5931\u8d25\u7684\u56de\u8c03\u51fd\u6570<\/td>\n<\/tr>\n<tr>\n<td>complete<\/td>\n<td>function<\/td>\n<td><\/td>\n<td>\u5426<\/td>\n<td>\u63a5\u53e3\u8c03\u7528\u7ed3\u675f\u7684\u56de\u8c03\u51fd\u6570\uff08\u8c03\u7528\u6210\u529f\u3001\u5931\u8d25\u90fd\u4f1a\u6267\u884c\uff09<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u2003\u2003\u5b98\u7f51\u7684\u793a\u4f8b\u4ee3\u7801\uff1a<\/p>\n<pre>\/\/ \u53ef\u4ee5\u901a\u8fc7 wx.getSetting \u5148\u67e5\u8be2\u4e00\u4e0b\u7528\u6237\u662f\u5426\u6388\u6743\u4e86 \"scope.record\" \u8fd9\u4e2a scopewx.getSetting({\n  success(res) {\n    if (!res.authSetting['scope.record']) {\n      wx.authorize({\n        scope: 'scope.record',\n        success () {\n          \/\/ \u7528\u6237\u5df2\u7ecf\u540c\u610f\u5c0f\u7a0b\u5e8f\u4f7f\u7528\u5f55\u97f3\u529f\u80fd\uff0c\u540e\u7eed\u8c03\u7528 wx.startRecord \u63a5\u53e3\u4e0d\u4f1a\u5f39\u7a97\u8be2\u95ee\n          wx.startRecord()\n        }\n      })\n    }\n  }})<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<h2>1.2 \u83b7\u53d6\u7528\u6237\u6743\u9650\u8bbe\u7f6e\u63a5\u53e3wx.getSetting(Object object)<\/h2>\n<p>\u2003\u2003\u8be5\u63a5\u53e3\u83b7\u53d6\u7528\u6237\u7684\u5f53\u524d\u8bbe\u7f6e\u3002\u8fd4\u56de\u503c\u4e2d\u53ea\u4f1a\u51fa\u73b0\u5c0f\u7a0b\u5e8f\u5df2\u7ecf\u5411\u7528\u6237\u8bf7\u6c42\u8fc7\u7684\u6743\u9650\u3002\u5c5e\u6027\u5982\u4e0b\uff1a<\/p>\n<table>\n<thead>\n<tr>\n<th>\u5c5e\u6027<\/th>\n<th>\u7c7b\u578b<\/th>\n<th>\u9ed8\u8ba4\u503c<\/th>\n<th>\u5fc5\u586b<\/th>\n<th>\u8bf4\u660e<\/th>\n<th>\u6700\u4f4e\u7248\u672c<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>withSubscriptions<\/td>\n<td>Boolean<\/td>\n<td>false<\/td>\n<td>\u5426<\/td>\n<td>\u662f\u5426\u540c\u65f6\u83b7\u53d6\u7528\u6237\u8ba2\u9605\u6d88\u606f\u7684\u8ba2\u9605\u72b6\u6001\uff0c\u9ed8\u8ba4\u4e0d\u83b7\u53d6\u3002\u6ce8\u610f\uff1awithSubscriptions \u53ea\u8fd4\u56de\u7528\u6237\u52fe\u9009\u8fc7\u8ba2\u9605\u9762\u677f\u4e2d\u7684\u201c\u603b\u662f\u4fdd\u6301\u4ee5\u4e0a\u9009\u62e9\uff0c\u4e0d\u518d\u8be2\u95ee\u201d\u7684\u8ba2\u9605\u6d88\u606f\u3002<\/td>\n<td>2.10.1<\/td>\n<\/tr>\n<tr>\n<td>success<\/td>\n<td>function<\/td>\n<td><\/td>\n<td>\u5426<\/td>\n<td>\u63a5\u53e3\u8c03\u7528\u6210\u529f\u7684\u56de\u8c03\u51fd\u6570<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>fail<\/td>\n<td>function<\/td>\n<td><\/td>\n<td>\u5426<\/td>\n<td>\u63a5\u53e3\u8c03\u7528\u5931\u8d25\u7684\u56de\u8c03\u51fd\u6570<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>complete<\/td>\n<td>function<\/td>\n<td><\/td>\n<td>\u5426<\/td>\n<td>\u63a5\u53e3\u8c03\u7528\u7ed3\u675f\u7684\u56de\u8c03\u51fd\u6570\uff08\u8c03\u7528\u6210\u529f\u3001\u5931\u8d25\u90fd\u4f1a\u6267\u884c\uff09<\/td>\n<td><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>object.success\u56de\u8c03\u51fd\u6570\u5982\u4e0b\uff1a<\/p>\n<table>\n<thead>\n<tr>\n<th>\u5c5e\u6027<\/th>\n<th>\u7c7b\u578b<\/th>\n<th>\u8bf4\u660e<\/th>\n<th>\u6700\u4f4e\u7248\u672c<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>authSetting<\/td>\n<td>AuthSetting<\/td>\n<td>\u7528\u6237\u6388\u6743\u7ed3\u679c<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>subscriptionsSetting<\/td>\n<td>SubscriptionsSetting<\/td>\n<td>\u7528\u6237\u8ba2\u9605\u6d88\u606f\u8bbe\u7f6e\uff0c\u63a5\u53e3\u53c2\u6570withSubscriptions\u503c\u4e3atrue\u65f6\u624d\u4f1a\u8fd4\u56de\u3002<\/td>\n<td>2.10.1<\/td>\n<\/tr>\n<tr>\n<td>miniprogramAuthSetting<\/td>\n<td>AuthSetting<\/td>\n<td>\u5728\u63d2\u4ef6\u4e2d\u8c03\u7528\u65f6\uff0c\u5f53\u524d\u5bbf\u4e3b\u5c0f\u7a0b\u5e8f\u7684\u7528\u6237\u6388\u6743\u7ed3\u679c<\/td>\n<td><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u2003\u2003\u5b98\u7f51\u793a\u4f8b\u4ee3\u7801\uff1a<\/p>\n<pre>wx.getSetting({\n  success (res) {\n    console.log(res.authSetting)\n    \/\/ res.authSetting = {\n    \/\/   \"scope.userInfo\": true,\n    \/\/   \"scope.userLocation\": true\n    \/\/ }\n  }})<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<h2>1.3 \u6253\u5f00\u7528\u6237\u6743\u9650\u8bbe\u7f6e\u63a5\u53e3wx.openSetting(Object object)<\/h2>\n<p>\u2003\u2003\u8be5\u63a5\u53e3\u8c03\u7528\u5ba2\u6237\u7aef\u5c0f\u7a0b\u5e8f\u8bbe\u7f6e\u754c\u9762\uff0c\u8fd4\u56de\u7528\u6237\u8bbe\u7f6e\u7684\u64cd\u4f5c\u7ed3\u679c\u3002\u8bbe\u7f6e\u754c\u9762\u53ea\u4f1a\u51fa\u73b0\u5c0f\u7a0b\u5e8f\u5df2\u7ecf\u5411\u7528\u6237\u8bf7\u6c42\u8fc7\u7684\u6743\u9650\u3002<\/p>\n<table>\n<thead>\n<tr>\n<th>\u5c5e\u6027<\/th>\n<th>\u7c7b\u578b<\/th>\n<th>\u9ed8\u8ba4\u503c<\/th>\n<th>\u5fc5\u586b<\/th>\n<th>\u8bf4\u660e<\/th>\n<th>\u6700\u4f4e\u7248\u672c<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>withSubscriptions<\/td>\n<td>Boolean<\/td>\n<td>false<\/td>\n<td>\u5426<\/td>\n<td>\u662f\u5426\u540c\u65f6\u83b7\u53d6\u7528\u6237\u8ba2\u9605\u6d88\u606f\u7684\u8ba2\u9605\u72b6\u6001\uff0c\u9ed8\u8ba4\u4e0d\u83b7\u53d6\u3002\u6ce8\u610f\uff1awithSubscriptions \u53ea\u8fd4\u56de\u7528\u6237\u52fe\u9009\u8fc7\u8ba2\u9605\u9762\u677f\u4e2d\u7684\u201c\u603b\u662f\u4fdd\u6301\u4ee5\u4e0a\u9009\u62e9\uff0c\u4e0d\u518d\u8be2\u95ee\u201d\u7684\u8ba2\u9605\u6d88\u606f\u3002<\/td>\n<td>2.10.3<\/td>\n<\/tr>\n<tr>\n<td>success<\/td>\n<td>function<\/td>\n<td><\/td>\n<td>\u5426<\/td>\n<td>\u63a5\u53e3\u8c03\u7528\u6210\u529f\u7684\u56de\u8c03\u51fd\u6570<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>fail<\/td>\n<td>function<\/td>\n<td><\/td>\n<td>\u5426<\/td>\n<td>\u63a5\u53e3\u8c03\u7528\u5931\u8d25\u7684\u56de\u8c03\u51fd\u6570<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>complete<\/td>\n<td>function<\/td>\n<td><\/td>\n<td>\u5426<\/td>\n<td>\u63a5\u53e3\u8c03\u7528\u7ed3\u675f\u7684\u56de\u8c03\u51fd\u6570\uff08\u8c03\u7528\u6210\u529f\u3001\u5931\u8d25\u90fd\u4f1a\u6267\u884c\uff09<\/td>\n<td><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>object.success\u56de\u8c03\u51fd\u6570\u5982\u4e0b:<\/p>\n<table>\n<thead>\n<tr>\n<th>\u5c5e\u6027<\/th>\n<th>\u7c7b\u578b<\/th>\n<th>\u8bf4\u660e<\/th>\n<th>\u6700\u4f4e\u7248\u672c<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>authSetting<\/td>\n<td>AuthSetting<\/td>\n<td>\u7528\u6237\u6388\u6743\u7ed3\u679c<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>subscriptionsSetting<\/td>\n<td>SubscriptionsSetting<\/td>\n<td>\u7528\u6237\u8ba2\u9605\u6d88\u606f\u8bbe\u7f6e\uff0c\u63a5\u53e3\u53c2\u6570withSubscriptions\u503c\u4e3atrue\u65f6\u624d\u4f1a\u8fd4\u56de\u3002<\/td>\n<td>2.10.3<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<ul>\n<li>\u6ce8\u610f\uff1a2.3.0 \u7248\u672c\u5f00\u59cb\uff0c\u7528\u6237\u53d1\u751f\u70b9\u51fb\u884c\u4e3a\u540e\uff0c\u624d\u53ef\u4ee5\u8df3\u8f6c\u6253\u5f00\u8bbe\u7f6e\u9875\uff0c\u7ba1\u7406\u6388\u6743\u4fe1\u606f\u3002<\/li>\n<\/ul>\n<p>\u2003\u2003\u5b98\u7f51\u793a\u4f8b\u4ee3\u7801\uff1a<\/p>\n<pre>wx.openSetting({\n  success (res) {\n    console.log(res.authSetting)\n    \/\/ res.authSetting = {\n    \/\/   \"scope.userInfo\": true,\n    \/\/   \"scope.userLocation\": true\n    \/\/ }\n  }})<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<h2>2\u3001\u6388\u6743\u6848\u4f8b<\/h2>\n<p>\u2003\u2003\u672c\u4f8b\u4f7f\u7528\u83b7\u53d6\u5730\u7406\u4f4d\u7f6e\u63a5\u53e3wx.getLocation()\u548c\u5f00\u59cb\u5f55\u97f3\u63a5\u53e3wx.startRecord()\u8fdb\u884c\u76f8\u5173\u64cd\u4f5c\uff0c\u800c\u8fd9\u4e24\u4e2a\u63a5\u53e3\u90fd\u9700\u8981\u8bbe\u7f6e\u64cd\u4f5c\u6743\u9650\u3002<\/p>\n<p>Setting.wxml\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n<pre>&lt;!--index.wxml--&gt;&lt;view class=\"body\" bindtap=\"location1\"&gt;\u83b7\u53d6\u5730\u7406\u4f4d\u7f6e&lt;\/view&gt;&lt;view  class=\"body\"&gt;{{context}}&lt;\/view&gt;&lt;view class=\"body\" bindtap=\"location2\"&gt;\u5f00\u59cb\u5f55\u97f3&lt;\/view&gt;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>Setting.js\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n<pre>\/\/index.js\/\/\u83b7\u53d6\u5e94\u7528\u5b9e\u4f8bconst app = getApp()Page({\n  data: {\n   \n  },\n  \n  onLoad: function () {\n    context:''\n  },\n  location1:function(){\t\/\/\u83b7\u53d6\u5730\u7406\u4f4d\u7f6e\n    var that=this\n    wx.getSetting({\t\/\/\u83b7\u53d6\u7528\u6237\u6743\u9650\u8bbe\u7f6e\u63a5\u53e3\n      success(res) {\n        console.log(res)\n        if (!res.authSetting['scope.userLocation']) {\n          wx.authorize({\t\t\/\/\u6388\u6743\n            scope: 'scope.userLocation',\t\/\/\u5730\u7406\u4f4d\u7f6e\u6743\u9650\uff0c\u770b\u7ebf\u4e0a\u9762\u7684scope\u5bf9\u5e94\u7684\u53c2\u6570\n            success() {\n              wx.getLocation({\t\t\/\/\u83b7\u53d6\u5f53\u524d\u7684\u5730\u7406\u4f4d\u7f6e\n                success: function(res) {\n                 console.log(res)\n                  that.setData({ context: \"\u4f60\u6240\u5728\u7684\u7ecf\u5ea6\u662f\" + res.latitude+\"\u4f60\u6240\u5728\u7684\u7eac\u5ea6\u662f\"+res.longitude})\n                },\n              })\n            }\n          })\n        }\n      }\n    })\n  },\n \n  location2: function () {\t\t\t\/\/\u5f55\u97f3\n    var that = this\n  \n        wx.getSetting({\n          success(res) {\n            console.log(res.authSetting)\n            if (!res.authSetting['scope.record']) {\n              wx.openSetting({\t\t\/\/\u6253\u5f00\u7528\u6237\u6743\u9650\u8bbe\u7f6e\u754c\u9762\n                success(res) {\n                  console.log(res)\n                  wx.startRecord({\t\t\/\/\u5f00\u59cb\u5f55\u97f3\n                    success(res) {\n                      const tempFilePath = res.tempFilePath\n                      console.log(\"\u5f55\u97f3\u7ed3\u675f\")\n                    }\n              })\n            } \n        })\n        }}\n        })\n  }})<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u2003\u2003 location()1\u51fd\u6570\u5b9e\u73b0\u83b7\u53d6\u5730\u7406\u4f4d\u7f6e\u7684\u529f\u80fd\uff0c\u8be5\u51fd\u6570\u5148\u8c03\u7528wx.getSetting()\u63a5\u53e3\u83b7\u53d6\u6743\u9650\u72b6\u6001\uff0c\u7136\u540e\u8c03\u7528wx.authorize()\u63a5\u53e3\u4fee\u6539\u5730\u7406\u4f4d\u7f6e\u6743\u9650scope.userLocation\u3002location2()\u51fd\u6570\u5b9e\u73b0\u5f55\u97f3\u529f\u80fd\uff0c\u8be5\u51fd\u6570\u5148\u8c03\u7528wx.getSetting()\u63a5\u53e3\u83b7\u53d6\u6743\u9650\u72b6\u6001\uff0c\u7136\u540e\u8c03\u7528wx.openSetting()\u63a5\u53e3\u6253\u5f00\u5f55\u97f3\u6743\u9650\u8bbe\u7f6e\u754c\u9762\u6765\u4fee\u6539\u5f55\u97f3\u6743\u9650\u3002\u4ece\u672c\u4f8b\u53ef\u4ee5\u770b\u51fa\u8bbe\u7f6e\u6743\u9650\u7684\u65f6\u5019\u5e94\u8be5\u5148\u8c03\u7528wx.getSetting()\u63a5\u53e3\u6765\u4fee\u6539\u6743\u9650\u72b6\u6001\uff0c\u5728\u6ca1\u6709\u6743\u9650\u6253\u5f00\u7684\u60c5\u51b5\u4e0b\u53ef\u4ee5\u8c03\u7528wx.authorize()\u63a5\u53e3\u6216\u8005wx.openSetting()\u63a5\u53e3\u6765\u4fee\u6539\u6743\u9650\u72b6\u6001\uff0cwx.authorize()\u63a5\u53e3\u4e0d\u51fa\u73b0\u4fee\u6539\u6743\u9650\u7684\u64cd\u4f5c\u6743\u9650\uff0c\u800cwx.openSetting()\u63a5\u53e3\u4f1a\u51fa\u73b0\u4fee\u6539\u6743\u9650\u7684\u64cd\u4f5c\u754c\u9762\u3002<\/p>\n<p>\u2003\u2003\u6848\u4f8b\u6548\u679c\u5982\u4e0b\uff1a<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/000\/000\/067\/3e8672569aec85d9789ce27fcd88738c-0.png\" class=\"aligncenter\" title=\"\u5f52\u7eb3\u6574\u7406\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u6743\u9650\u63a5\u53e3\u63d2\u56fe1\" alt=\"\u5f52\u7eb3\u6574\u7406\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u6743\u9650\u63a5\u53e3\u63d2\u56fe1\" \/><\/p>\n<p>\u2003\u2003\u70b9\u51fb\u83b7\u53d6\u5730\u7406\u4f4d\u7f6e\uff1a<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/000\/000\/067\/eb4a7a2f987b147511aac63a04ccc927-1.png\" class=\"aligncenter\" title=\"\u5f52\u7eb3\u6574\u7406\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u6743\u9650\u63a5\u53e3\u63d2\u56fe2\" alt=\"\u5f52\u7eb3\u6574\u7406\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u6743\u9650\u63a5\u53e3\u63d2\u56fe2\" \/><\/p>\n<p>\u2003\u2003\u70b9\u51fb\u5141\u8bb8\u4e4b\u540e\u4f1a\u663e\u793a\u5f53\u524d\u6240\u5728\u7684\u7ecf\u7eac\u5ea6\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/000\/000\/067\/eb4a7a2f987b147511aac63a04ccc927-2.png\" class=\"aligncenter\" title=\"\u5f52\u7eb3\u6574\u7406\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u6743\u9650\u63a5\u53e3\u63d2\u56fe3\" alt=\"\u5f52\u7eb3\u6574\u7406\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u6743\u9650\u63a5\u53e3\u63d2\u56fe3\" \/><\/p>\n<p>\u2003\u2003\u70b9\u51fb\u5f00\u59cb\u5f55\u97f3\u6309\u94ae\u51fa\u73b0\u9ea6\u514b\u98ce\u6388\u6743\uff1a<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/000\/000\/067\/eb4a7a2f987b147511aac63a04ccc927-3.png\" class=\"aligncenter\" title=\"\u5f52\u7eb3\u6574\u7406\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u6743\u9650\u63a5\u53e3\u63d2\u56fe4\" alt=\"\u5f52\u7eb3\u6574\u7406\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u6743\u9650\u63a5\u53e3\u63d2\u56fe4\" \/><\/p>\n<p>\u3010\u76f8\u5173\u5b66\u4e60\u63a8\u8350\uff1a\u3011<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5f52\u7eb3\u6574\u7406\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u6743\u9650\u63a5\u53e3\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>\u672c\u7bc7\u6587\u7ae0\u7ed9\u5927\u5bb6\u5e26\u6765\u4e86\u5173\u4e8e\u7684\u76f8\u5173\u95ee\u9898\uff0c\u5176\u4e2d\u4e3b\u8981\u4ecb\u7ecd\u4e86\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u4e2d\u7684\u6743\u9650\u63a5\u53e3\u7684\u76f8\u5173\u5185\u5bb9\uff0c\u5305\u62ec\u4e86\u7528\u6237\u6388\u6743\u63a5\u53e3\u3001\u83b7\u53d6\u7528\u6237\u6743\u9650\u8bbe\u7f6e\u63a5\u53e3\u3001\u6253\u5f00\u7528\u6237\u6743\u9650\u8bbe\u7f6e\u63a5\u53e3\u7b49\u5185\u5bb9\uff0c\u4e0b\u9762\u4e00\u8d77\u6765\u770b\u4e00\u4e0b\uff0c\u5e0c\u671b\u5bf9\u5927\u5bb6\u6709\u5e2e\u52a9\u3002 \u3010\u76f8\u5173\u5b66\u4e60\u63a8\u8350\uff1a\u3011 1\u3001\u6743\u9650\u63a5\u53e3 \u2003\u2003\u90e8\u5206\u63a5\u53e3\u9700\u8981\u7ecf\u8fc7\u7528\u6237\u6388\u6743\u7edf\u4e00\u624d\u80fd\u8c03\u7528\u3002\u6211\u4eec\u628a\u8fd9\u4e9b\u63a5\u53e3\u6309\u4f7f\u7528\u8303\u56f4\u5206\u6210\u591a\u4e2ascope\uff0c\u7528\u6237\u9009\u62e9\u5bf9scope\u8fdb\u884c\u6388\u6743\uff0c\u5f53\u6388\u6743\u7ed9\u4e00\u4e2ascope\u4e4b\u540e\uff0c\u5176\u5bf9\u5e94\u7684\u6240\u6709\u63a5\u53e3\u90fd\u53ef\u4ee5\u76f4\u63a5\u4f7f\u7528\uff0c\u6b64\u7c7b\u63a5\u53e3\u8c03\u7528\u65f6\uff1a \u5982\u679c\u7528\u6237\u672a\u63a5\u53d7\u6216\u62d2\u7edd\u6b64\u6743\u9650\uff0c\u4f1a\u5f39\u7a97\u8be2\u95ee\u7528\u6237\uff0c\u7528\u6237\u5355\u51fb\u7edf\u4e00\u540e\u65b9\u53ef\u8c03\u7528\u63a5\u53e3\u3002 \u5982\u679c\u7528\u6237\u5df2\u6388\u6743\uff0c\u53ef\u4ee5\u76f4\u63a5\u8c03\u7528\u63a5\u53e3\u3002 \u5982\u679c\u7528\u6237\u5df2\u62d2\u7edd\u6388\u6743\uff0c\u5219\u4e0d\u4f1a\u51fa\u73b0\u5f39\u7a97\uff0c\u800c\u4f1a\u76f4\u63a5\u8fdb\u5165\u63a5\u53e3fail\u56de\u8c03\u3002 \u2003\u2003\u6b64\u7c7b\u63a5\u53e3\u518d\u6743\u9650\u4e2d\u7684\u5bf9\u8c61scope\u7684\u5b57\u6bb5\u548c\u63a5\u53e3\u7684\u5bf9\u5e94\u5173\u7cfb\u5982\u4e0b\u8868\u6240\u793a\u3002 scope \u5bf9\u5e94\u63a5\u53e3 \u63cf\u8ff0 scope.userLocation wx.getLocation, wx.chooseLocation, wx.startLocationUpdate \u5730\u7406\u4f4d\u7f6e scope.userLocationBackground wx.startLocationUpdateBackground \u540e\u53f0\u5b9a\u4f4d scope.record wx.startRecord, wx.joinVoIPChat, RecorderManager.start \u9ea6\u514b\u98ce scope.camera camera\u7ec4\u4ef6, wx.createVKSession \u6444\u50cf\u5934 scope.bluetooth wx.openBluetoothAdapter, wx.createBLEPeripheralServer \u84dd\u7259 scope.writePhotosAlbum wx.saveImageToPhotosAlbum, wx.saveVideoToPhotosAlbum \u6dfb\u52a0\u5230\u76f8\u518c scope.addPhoneContact wx.wx.addPhoneContact \u6dfb\u52a0\u5230\u8054\u7cfb\u4eba scope.addPhoneCalendar wx.addPhoneRepeatCalendar, wx.addPhoneCalendar \u6dfb\u52a0\u5230\u65e5\u5386 scope.werun wx.getWeRunData \u5fae\u4fe1\u8fd0\u52a8\u6b65\u6570 scope.address wx.chooseAddress \u901a\u8baf\u5730\u5740\uff08\u5df2\u53d6\u6d88\u6388\u6743\uff0c\u53ef\u4ee5\u76f4\u63a5\u8c03\u7528\u5bf9\u5e94\u63a5\u53e3\uff09 scope.invoiceTitle wx.chooseInvoiceTitle \u53d1\u7968\u62ac\u5934\uff08\u5df2\u53d6\u6d88\u6388\u6743\uff0c\u53ef\u4ee5\u76f4\u63a5\u8c03\u7528\u5bf9\u5e94\u63a5\u53e3\uff09 scope.invoice wx.chooseInvoice \u83b7\u53d6\u53d1\u7968\uff08\u5df2\u53d6\u6d88\u6388\u6743\uff0c\u53ef\u4ee5\u76f4\u63a5\u8c03\u7528\u5bf9\u5e94\u63a5\u53e3\uff09 [&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-34261","post","type-post","status-publish","format-standard","hentry","category-19"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/34261","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=34261"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/34261\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=34261"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=34261"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=34261"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}