{"id":839,"date":"2024-11-07T12:55:50","date_gmt":"2024-11-07T04:55:50","guid":{"rendered":"https:\/\/fwq.ai\/blog\/839\/"},"modified":"2024-11-07T12:55:50","modified_gmt":"2024-11-07T04:55:50","slug":"uniapp-%e4%b8%ad%e5%a6%82%e4%bd%95%e9%99%90%e5%88%b6%e7%94%a8%e6%88%b7%e6%af%8f%e5%a4%a9%e5%88%86%e4%ba%ab%e4%b8%80%e6%ac%a1%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/839\/","title":{"rendered":"UniApp \u4e2d\u5982\u4f55\u9650\u5236\u7528\u6237\u6bcf\u5929\u5206\u4eab\u4e00\u6b21\uff1f"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1067\" src=\"https:\/\/fwq.ai\/blog\/wp-content\/uploads\/2024\/11\/172999063930706.jpg\" width=\"720\" height=\"288\" srcset=\"https:\/\/fwq.ai\/blog\/wp-content\/uploads\/2024\/11\/172999063930706.jpg 720w, https:\/\/fwq.ai\/blog\/wp-content\/uploads\/2024\/11\/172999063930706-300x120.jpg 300w, https:\/\/fwq.ai\/blog\/wp-content\/uploads\/2024\/11\/172999063930706-670x268.jpg 670w\" sizes=\"auto, (max-width: 720px) 100vw, 720px\" title=\"UniApp \u4e2d\u5982\u4f55\u9650\u5236\u7528\u6237\u6bcf\u5929\u5206\u4eab\u4e00\u6b21\uff1f\u63d2\u56fe\" alt=\"UniApp \u4e2d\u5982\u4f55\u9650\u5236\u7528\u6237\u6bcf\u5929\u5206\u4eab\u4e00\u6b21\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5728 uniapp \u4e2d\u9650\u5236\u6bcf\u5929\u5206\u4eab\u4e00\u6b21<\/strong><\/p>\n<p>\u5982\u4f55\u9650\u5236 uniapp \u5e94\u7528\u4e2d\u7684\u5206\u4eab\u529f\u80fd\uff0c\u4f7f\u5176\u5728\u6bcf\u5929\u53ea\u5141\u8bb8\u7528\u6237\u5206\u4eab\u4e00\u6b21\uff1f\u8fd9\u7bc7\u6587\u7ae0\u5c06\u8be6\u7ec6\u89e3\u7b54\u8fd9\u4e00\u95ee\u9898\uff0c\u5e76\u63d0\u4f9b\u53ef\u884c\u89e3\u51b3\u65b9\u6848\u3002<\/p>\n<p><strong>\u89e3\u51b3\u65b9\u6848\uff1a<\/strong><\/p>\n<p>\u91c7\u7528\u6570\u636e\u5e93\u7684\u65b9\u5f0f\u6765\u5b9e\u73b0\u6bcf\u5929\u53ea\u5206\u4eab\u4e00\u6b21\u7684\u9650\u5236\u3002<\/p>\n<ol>\n<li>\n<p><strong>\u521b\u5efa\u4e00\u5f20\u8bb0\u5f55\u5206\u4eab\u4fe1\u606f\u7684\u8868\uff1a<\/strong><\/p>\n<ul>\n<li>\u8868\u4e2d\u5305\u542b\u5b57\u6bb5\uff0c\u4f8b\u5982 user_id\uff08\u7528\u6237 id\uff09\u3001day\uff08\u5206\u4eab\u65e5\u671f\uff09\u548c shared\uff08\u662f\u5426\u5206\u4eab\u8fc7\uff09\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u6bcf\u6b21\u7528\u6237\u5c1d\u8bd5\u5206\u4eab\u65f6\uff1a<\/strong><\/p>\n<ul>\n<li>\u5411\u63a5\u53e3\u53d1\u9001\u8bf7\u6c42\uff0c\u83b7\u53d6\u5f53\u524d\u65e5\u671f\u7684\u5206\u4eab\u72b6\u6001\u3002<\/li>\n<li>\u5982\u679c\u5f53\u524d\u65e5\u671f\u7684 shared \u5b57\u6bb5\u4e3a false\uff0c\u5219\u5141\u8bb8\u7528\u6237\u5206\u4eab\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u7528\u6237\u5206\u4eab\u5b8c\u6210\u540e\uff1a<\/strong><\/p>\n<ul>\n<li>\u66f4\u65b0\u6570\u636e\u5e93\u4e2d\u7684 shared \u5b57\u6bb5\u4e3a true\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u521d\u59cb\u5316\u65f6\uff1a<\/strong><\/p>\n<ul>\n<li>\u4ece\u63a5\u53e3\u83b7\u53d6\u5f53\u524d\u65e5\u671f\u7684\u5206\u4eab\u72b6\u6001\u3002<\/li>\n<li>\u6839\u636e shared \u5b57\u6bb5\u7684\u503c\u6765\u66f4\u65b0\u5206\u4eab\u6309\u94ae\u7684\u72b6\u6001\uff08\u7070\u8272\u6216\u53ef\u7528\uff09\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p><strong>\u4ee3\u7801\u793a\u4f8b\uff1a<\/strong><\/p>\n<pre>\/\/ \u83b7\u53d6\u5206\u4eab\u72b6\u6001\ngetsharestatus() {\n  return this.$http.get(`\/api\/share-status\/${this.userid}\/${this.day}`);\n},\n\n\/\/ \u66f4\u65b0\u5206\u4eab\u72b6\u6001\nupdatesharestatus() {\n  return this.$http.post('\/api\/share-status', {\n    userid: this.userid,\n    day: this.day,\n    shared: true,\n  });\n},<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u4f7f\u7528\u793a\u4f8b\uff1a<\/strong><\/p>\n<p>\u5728 vue \u7ec4\u4ef6\u4e2d\uff1a<\/p>\n<pre>mounted() {\n  this.getShareStatus().then((res) =&gt; {\n    \/\/ \u5224\u65ad\u662f\u5426\u5df2\u5206\u4eab\n    this.shared = res.data.shared;\n  });\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u901a\u8fc7\u4e0a\u8ff0\u65b9\u6cd5\uff0c\u5373\u53ef\u9650\u5236 uniapp \u5e94\u7528\u4e2d\u7684\u5206\u4eab\u529f\u80fd\uff0c\u4f7f\u6bcf\u4e2a\u7528\u6237\u6bcf\u5929\u53ea\u80fd\u5206\u4eab\u4e00\u6b21\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fUniApp \u4e2d\u5982\u4f55\u9650\u5236\u7528\u6237\u6bcf\u5929\u5206\u4eab\u4e00\u6b21\uff1f\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>\u5728 uniapp \u4e2d\u9650\u5236\u6bcf\u5929\u5206\u4eab\u4e00\u6b21 \u5982\u4f55\u9650\u5236 uniapp \u5e94\u7528\u4e2d\u7684\u5206\u4eab\u529f\u80fd\uff0c\u4f7f\u5176\u5728\u6bcf\u5929\u53ea\u5141\u8bb8\u7528\u6237\u5206\u4eab\u4e00\u6b21\uff1f\u8fd9\u7bc7\u6587\u7ae0\u5c06\u8be6\u7ec6\u89e3\u7b54\u8fd9\u4e00\u95ee\u9898\uff0c\u5e76\u63d0\u4f9b\u53ef\u884c\u89e3\u51b3\u65b9\u6848\u3002 \u89e3\u51b3\u65b9\u6848\uff1a \u91c7\u7528\u6570\u636e\u5e93\u7684\u65b9\u5f0f\u6765\u5b9e\u73b0\u6bcf\u5929\u53ea\u5206\u4eab\u4e00\u6b21\u7684\u9650\u5236\u3002 \u521b\u5efa\u4e00\u5f20\u8bb0\u5f55\u5206\u4eab\u4fe1\u606f\u7684\u8868\uff1a \u8868\u4e2d\u5305\u542b\u5b57\u6bb5\uff0c\u4f8b\u5982 user_id\uff08\u7528\u6237 id\uff09\u3001day\uff08\u5206\u4eab\u65e5\u671f\uff09\u548c shared\uff08\u662f\u5426\u5206\u4eab\u8fc7\uff09\u3002 \u6bcf\u6b21\u7528\u6237\u5c1d\u8bd5\u5206\u4eab\u65f6\uff1a \u5411\u63a5\u53e3\u53d1\u9001\u8bf7\u6c42\uff0c\u83b7\u53d6\u5f53\u524d\u65e5\u671f\u7684\u5206\u4eab\u72b6\u6001\u3002 \u5982\u679c\u5f53\u524d\u65e5\u671f\u7684 shared \u5b57\u6bb5\u4e3a false\uff0c\u5219\u5141\u8bb8\u7528\u6237\u5206\u4eab\u3002 \u7528\u6237\u5206\u4eab\u5b8c\u6210\u540e\uff1a \u66f4\u65b0\u6570\u636e\u5e93\u4e2d\u7684 shared \u5b57\u6bb5\u4e3a true\u3002 \u521d\u59cb\u5316\u65f6\uff1a \u4ece\u63a5\u53e3\u83b7\u53d6\u5f53\u524d\u65e5\u671f\u7684\u5206\u4eab\u72b6\u6001\u3002 \u6839\u636e shared \u5b57\u6bb5\u7684\u503c\u6765\u66f4\u65b0\u5206\u4eab\u6309\u94ae\u7684\u72b6\u6001\uff08\u7070\u8272\u6216\u53ef\u7528\uff09\u3002 \u4ee3\u7801\u793a\u4f8b\uff1a \/\/ \u83b7\u53d6\u5206\u4eab\u72b6\u6001 getsharestatus() { return this.$http.get(`\/api\/share-status\/${this.userid}\/${this.day}`); }, \/\/ \u66f4\u65b0\u5206\u4eab\u72b6\u6001 updatesharestatus() { return this.$http.post(&#8216;\/api\/share-status&#8217;, { userid: this.userid, day: this.day, shared: true, }); }, \u767b\u5f55\u540e\u590d\u5236 \u4f7f\u7528\u793a\u4f8b\uff1a \u5728 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-839","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/839","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=839"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/839\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=839"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=839"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=839"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}