{"id":32402,"date":"2024-11-25T16:46:31","date_gmt":"2024-11-25T08:46:31","guid":{"rendered":"https:\/\/fwq.ai\/blog\/32402\/"},"modified":"2024-11-25T16:46:31","modified_gmt":"2024-11-25T08:46:31","slug":"%e5%b0%8f%e7%a8%8b%e5%ba%8f%e4%b8%ad%e5%a6%82%e4%bd%95%e5%ae%9e%e7%8e%b0%e5%88%86%e4%ba%ab%e5%8a%9f%e8%83%bd-%ef%bc%88%e4%bb%a3%e7%a0%81%e7%a4%ba%e4%be%8b%ef%bc%89","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/32402\/","title":{"rendered":"\u5c0f\u7a0b\u5e8f\u4e2d\u5982\u4f55\u5b9e\u73b0\u5206\u4eab\u529f\u80fd \uff08\u4ee3\u7801\u793a\u4f8b\uff09"},"content":{"rendered":"<p>\u672c\u7bc7\u6587\u7ae0\u7ed9\u5927\u5bb6\u5e26\u6765\u7684\u5185\u5bb9\u662f\u5173\u4e8e\u5c0f\u7a0b\u5e8f\u4e2d\u5982\u4f55\u5b9e\u73b0\u5206\u4eab\u529f\u80fd \uff08\u4ee3\u7801\u793a\u4f8b\uff09\uff0c\u6709\u4e00\u5b9a\u7684\u53c2\u8003\u4ef7\u503c\uff0c\u6709\u9700\u8981\u7684\u670b\u53cb\u53ef\u4ee5\u53c2\u8003\u4e00\u4e0b\uff0c\u5e0c\u671b\u5bf9\u4f60\u6709\u6240\u5e2e\u52a9\u3002<\/p>\n<p>\u56e0\u4e3a\u5c0f\u7a0b\u5e8f\u4e2d\u591a\u4e2a\u9875\u9762\u90fd\u4f1a\u4f7f\u7528\u5206\u4eab\uff0c\u9700\u8981\u6211\u4eec\u628a\u5206\u4eab\u529f\u80fd\uff0c\u5355\u72ec\u5199\u5728\u4e00\u4e2a\u516c\u7528\u7684\u6587\u4ef6\u4e2d\u3002util.js \u6587\u4ef6\u4e2d\u3002<br \/>\/\/\u5206\u4eab\u529f\u80fd<\/p>\n<pre>const shareEvent = (option, obj) =&gt; {\n  let shareObj = {\n    title: obj.title,\n    path: obj.path,\n    imgUrl: obj.imgUrl,\n    success(res){\n      \/\/ \u8f6c\u53d1\u6210\u529f\u4e4b\u540e\u7684\u56de\u8c03\n\u3000\u3000\u3000 if (res.errMsg == 'shareAppMessage:ok') {}\n    }, \n    fail(res){\n       \/\/ \u8f6c\u53d1\u5931\u8d25\u4e4b\u540e\u7684\u56de\u8c03\n\u3000\u3000\u3000 if (res.errMsg == 'shareAppMessage:fail cancel') {\n\u3000\u3000\u3000 \/\/ \u7528\u6237\u53d6\u6d88\u8f6c\u53d1\n\u3000\u3000\u3000  } else if (res.errMsg == 'shareAppMessage:fail') {\n\u3000\u3000\u3000  \/\/ \u8f6c\u53d1\u5931\u8d25\uff0c\u5176\u4e2d detail message \u4e3a\u8be6\u7ec6\u5931\u8d25\u4fe1\u606f\n\u3000\u3000\u3000\u3000}\n    },\n    complete(){\n        \/\/ \u8f6c\u53d1\u7ed3\u675f\u4e4b\u540e\u7684\u56de\u8c03\uff08\u8f6c\u53d1\u6210\u4e0d\u6210\u529f\u90fd\u4f1a\u6267\u884c\uff09\n    }\n  };\n  if (option.from === 'button') {\n    \/\/ \u6765\u81ea\u9875\u9762\u5185\u8f6c\u53d1\u6309\u94ae\n    console.log(option.target)\n  }\n  return shareObj;\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5728\u4f7f\u7528\u5206\u4eab\u7684\u9875\u9762\u4e2d\u5f15\u5165util.js<\/p>\n<pre>const util = require('.\/utils\/util.js');<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<pre>\/**\n\u7528\u6237\u70b9\u51fb\u53f3\u4e0a\u89d2\u5206\u4eab\n*\/\nonShareAppMessage: function(option){\n    console.log(option);\n    let obj = {\n      title: '\u6211\u7684\u8001\u7a9d',\n      path: 'pages\/index\/index',\n      imageUrl: ''\n    };\n    return util.shareEvent(option, obj);\n  }<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5907\u6ce8\uff1a\u8bb0\u5f97\u8981\u5728\u8c03\u7528\u7684\u65f6\u5019\u4f7f\u7528\uff0creturn\u3002<\/p>\n<p>\u76f8\u5173\u63a8\u8350\uff1a<\/p>\n<p><\/p>\n<p><\/p>\n<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5c0f\u7a0b\u5e8f\u4e2d\u5982\u4f55\u5b9e\u73b0\u5206\u4eab\u529f\u80fd \uff08\u4ee3\u7801\u793a\u4f8b\uff09\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\u7684\u5185\u5bb9\u662f\u5173\u4e8e\u5c0f\u7a0b\u5e8f\u4e2d\u5982\u4f55\u5b9e\u73b0\u5206\u4eab\u529f\u80fd \uff08\u4ee3\u7801\u793a\u4f8b\uff09\uff0c\u6709\u4e00\u5b9a\u7684\u53c2\u8003\u4ef7\u503c\uff0c\u6709\u9700\u8981\u7684\u670b\u53cb\u53ef\u4ee5\u53c2\u8003\u4e00\u4e0b\uff0c\u5e0c\u671b\u5bf9\u4f60\u6709\u6240\u5e2e\u52a9\u3002 \u56e0\u4e3a\u5c0f\u7a0b\u5e8f\u4e2d\u591a\u4e2a\u9875\u9762\u90fd\u4f1a\u4f7f\u7528\u5206\u4eab\uff0c\u9700\u8981\u6211\u4eec\u628a\u5206\u4eab\u529f\u80fd\uff0c\u5355\u72ec\u5199\u5728\u4e00\u4e2a\u516c\u7528\u7684\u6587\u4ef6\u4e2d\u3002util.js \u6587\u4ef6\u4e2d\u3002\/\/\u5206\u4eab\u529f\u80fd const shareEvent = (option, obj) =&gt; { let shareObj = { title: obj.title, path: obj.path, imgUrl: obj.imgUrl, success(res){ \/\/ \u8f6c\u53d1\u6210\u529f\u4e4b\u540e\u7684\u56de\u8c03 \u3000\u3000\u3000 if (res.errMsg == &#8216;shareAppMessage:ok&#8217;) {} }, fail(res){ \/\/ \u8f6c\u53d1\u5931\u8d25\u4e4b\u540e\u7684\u56de\u8c03 \u3000\u3000\u3000 if (res.errMsg == &#8216;shareAppMessage:fail cancel&#8217;) { \u3000\u3000\u3000 \/\/ \u7528\u6237\u53d6\u6d88\u8f6c\u53d1 \u3000\u3000\u3000 } else if (res.errMsg == &#8216;shareAppMessage:fail&#8217;) { \u3000\u3000\u3000 \/\/ \u8f6c\u53d1\u5931\u8d25\uff0c\u5176\u4e2d [&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-32402","post","type-post","status-publish","format-standard","hentry","category-19"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/32402","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=32402"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/32402\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=32402"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=32402"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=32402"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}