{"id":1524,"date":"2023-03-25T15:06:09","date_gmt":"2023-03-25T07:06:09","guid":{"rendered":"https:\/\/www.appblog.cn\/?p=1524"},"modified":"2023-04-27T21:44:58","modified_gmt":"2023-04-27T13:44:58","slug":"wechat-mini-program-pull-down-refresh-and-pull-up-loading","status":"publish","type":"post","link":"https:\/\/www.appblog.cn\/index.php\/2023\/03\/25\/wechat-mini-program-pull-down-refresh-and-pull-up-loading\/","title":{"rendered":"\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u4e0b\u62c9\u5237\u65b0\u53ca\u4e0a\u62c9\u52a0\u8f7d"},"content":{"rendered":"<h3>\u53c2\u8003\u6587\u6863<\/h3>\n<p>\u9875\u9762\u914d\u7f6e\uff1a<a target=\"_blank\" rel=\"noopener\" href=\"https:\/\/mp.weixin.qq.com\/debug\/wxadoc\/dev\/framework\/config.html\">https:\/\/mp.weixin.qq.com\/debug\/wxadoc\/dev\/framework\/config.html<\/a><br \/>\n\u9875\u9762\u4e8b\u4ef6\uff1a<a target=\"_blank\" rel=\"noopener\" href=\"https:\/\/mp.weixin.qq.com\/debug\/wxadoc\/dev\/framework\/app-service\/page.html\">https:\/\/mp.weixin.qq.com\/debug\/wxadoc\/dev\/framework\/app-service\/page.html<\/a><br \/>\nAPI\uff1a<a target=\"_blank\" rel=\"noopener\" href=\"https:\/\/mp.weixin.qq.com\/debug\/wxadoc\/dev\/api\/pulldown.html\">https:\/\/mp.weixin.qq.com\/debug\/wxadoc\/dev\/api\/pulldown.html<\/a><\/p>\n<p><!-- more --><\/p>\n<h3>\u4e0b\u62c9\u5237\u65b0<\/h3>\n<p>\u914d\u7f6e\uff1apages\/index\/index.json<\/p>\n<pre><code class=\"language-json\">{\n  &quot;navigationBarTitleText&quot;: &quot;\u8ba2\u5355\u5217\u8868&quot;,\n  &quot;enablePullDownRefresh&quot;: true,\n  &quot;backgroundTextStyle&quot;: &quot;dark&quot;\n}<\/code><\/pre>\n<p>\u4e8b\u4ef6\uff1apages\/index\/index.js<\/p>\n<pre><code class=\"language-javascript\">const app = getApp()\nconst server = require('..\/..\/http\/HttpServer');\n\nPage({\n  data: {\n    user: {},\n    orderList: [],\n    refresh: false\n  }\n\n  \/**\n   * \u751f\u547d\u5468\u671f\u51fd\u6570--\u76d1\u542c\u9875\u9762\u52a0\u8f7d\n   *\/\n  onLoad: function (options) {\n    this.data.user = app.globalData.user\n  },\n\n  \/**\n   * \u751f\u547d\u5468\u671f\u51fd\u6570--\u76d1\u542c\u9875\u9762\u663e\u793a\n   *\/\n  onShow: function () {\n    this.getOrderList()\n  },\n\n  \/**\n   * \u9875\u9762\u76f8\u5173\u4e8b\u4ef6\u5904\u7406\u51fd\u6570--\u76d1\u542c\u7528\u6237\u4e0b\u62c9\u52a8\u4f5c\n   *\/\n  onPullDownRefresh: function () {\n    this.data.refresh = true\n    this.getOrderList()\n  },\n\n  getOrderList() {\n    var _this = this\n    \/\/\u83b7\u53d6\u8ba2\u5355\u8be6\u60c5\n    wx.request({\n      url: server.ORDER_LIST_URL,  \/\/\u83b7\u53d6\u8ba2\u5355\u8be6\u60c5\n      header: {\n        'content-type': 'application\/json', \/\/ \u9ed8\u8ba4\u503c\n        'Authorization': _this.data.user.token\n      },\n      success: function (res) {\n        console.log(res.data)\n        var data = res.data\n        if (res.statusCode == 403) {\n          wx.navigateTo({\n            url: '\/pages\/login\/index?id=1'\n          })\n        } else if (res.statusCode == 200 && res.data.code == 0) {\n          if (_this.data.refresh) {\n            wx.stopPullDownRefresh()\n            _this.data.refresh = false\n          }\n          var orderList = res.data.orderList\n          _this.setData({\n            orderList: orderList\n          })\n        }\n      }\n    })\n  },\n\n })<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u53c2\u8003\u6587\u6863 \u9875\u9762\u914d\u7f6e\uff1ahttps:\/\/mp.weixin.qq.com\/debug\/wxadoc\/dev\/fra [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[46],"tags":[],"class_list":["post-1524","post","type-post","status-publish","format-standard","hentry","category-wechat-mini-program"],"_links":{"self":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/1524","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/comments?post=1524"}],"version-history":[{"count":0,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/1524\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/media?parent=1524"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/categories?post=1524"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/tags?post=1524"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}