diff --git a/app.js b/app.js index f5e989e..0525b41 100644 --- a/app.js +++ b/app.js @@ -1,45 +1,48 @@ //app.js App({ - onLaunch: function () { - // 展示本地存储能力 - var logs = wx.getStorageSync('logs') || [] - logs.unshift(Date.now()) - wx.setStorageSync('logs', logs) - const systemInfo = wx.getSystemInfoSync(); //获取系统信息 - const menuInfo = wx.getMenuButtonBoundingClientRect(); // 获取胶囊按钮的信息 - this.globalData.menuHeight = menuInfo.height; // 获取胶囊按钮的高 - this.globalData.statusBarHeight = systemInfo.statusBarHeight; // 获取状态栏的高 - this.globalData.menuRight = menuInfo.right; // 获取胶囊按钮的距离屏幕最右边的距离(此处用于设置导航栏左侧距离屏幕的距离) - this.globalData.navBarHeight = (menuInfo.top - systemInfo.statusBarHeight) * 2 + menuInfo.height; // 计算出导航栏的高度 - }, - globalData: { - imageUrl: "https://cdn.sws010.com/wxapp/images", - navBarHeight: 0, // 导航栏高度 - menuHeight: 0, //胶囊按钮 高度 - statusBarHeight: 0, //状态栏高度 - menuRight: 0, //胶囊按钮 距离屏幕右边的距离 - request: function (prarms) { - return new Promise((resolve, reject) => { - wx.request({ - url: 'http://cloud.sws010.com/api/v7.ashx', - data: { - version: "1", - ...prarms - }, - method: 'get', - success: function (res) { - //接口实际返回的内容在res.data中 - if (res.data.Code == 1) { - resolve(res.data.Data); - } else { - reject(res.data) - } - }, - fail: function (err) { - reject(err); - } - }) - }) + onLaunch: function () { + // 展示本地存储能力 + var logs = wx.getStorageSync('logs') || [] + logs.unshift(Date.now()) + wx.setStorageSync('logs', logs) + const systemInfo = wx.getSystemInfoSync(); //获取系统信息 + const menuInfo = wx.getMenuButtonBoundingClientRect(); // 获取胶囊按钮的信息 + this.globalData.menuHeight = menuInfo.height; // 获取胶囊按钮的高 + this.globalData.statusBarHeight = systemInfo.statusBarHeight; // 获取状态栏的高 + this.globalData.menuRight = menuInfo.right; // 获取胶囊按钮的距离屏幕最右边的距离(此处用于设置导航栏左侧距离屏幕的距离) + this.globalData.navBarHeight = (menuInfo.top - systemInfo.statusBarHeight) * 2 + menuInfo.height; // 计算出导航栏的高度 + }, + globalData: { + imageUrl: "https://cdn.sws010.com/wxapp/images", + navBarHeight: 0, // 导航栏高度 + menuHeight: 0, //胶囊按钮 高度 + statusBarHeight: 0, //状态栏高度 + menuRight: 0, //胶囊按钮 距离屏幕右边的距离 + request: function (prarms, callback) { + return new Promise((resolve, reject) => { + wx.request({ + url: 'http://cloud.sws010.com/api/v7.ashx', + data: { + version: "1", + ...prarms + }, + method: 'get', + success: function (res) { + //接口实际返回的内容在res.data中 + if (res.data.Code == 1) { + if (typeof callback === 'function') { + callback(res.data); + } + resolve(res.data.Data); + } else { + reject(res.data) + } + }, + fail: function (err) { + reject(err); + } + }) + }) + } } - } }) \ No newline at end of file diff --git a/pages/detail/index.js b/pages/detail/index.js index 57b6425..c17e02f 100644 --- a/pages/detail/index.js +++ b/pages/detail/index.js @@ -15,7 +15,8 @@ Page({ ssim: "", dataList: [], //放置返回数据的数组 loadMore: false, //"上拉加载"的变量,默认false,隐藏 - loadAll: false //“没有数据”的变量,默认false,隐藏 + loadAll: false, //“没有数据”的变量,默认false,隐藏 + totalNum: 0 }, onLoad() { wx.setNavigationBarTitle({ @@ -46,6 +47,9 @@ Page({ that.getLikeData(); } }, + searchScrollLower() { + this.getLikeData(); + }, getData() { return new Promise((resolve, reject) => { app.globalData.request({ @@ -101,11 +105,15 @@ Page({ loadAll: false //把“没有数据”设为false,隐藏 }) } - app.globalData.request(obj).then(res => { + app.globalData.request(obj, (database) => { + this.setData({ + totalNum: database.totalNum + }) + }).then(res => { if (res && res.length > 0) { iPageIndex++; //把新请求到的数据添加到dataList里 - let list = that.data.dataList.concat(res); + let list = this.data.dataList.concat(res); this.setData({ dataList: list, //获取数据数组 loadMore: false //把"上拉加载"的变量设为false,显示 diff --git a/pages/detail/index.wxml b/pages/detail/index.wxml index c845a24..8ea2317 100644 --- a/pages/detail/index.wxml +++ b/pages/detail/index.wxml @@ -42,7 +42,7 @@ 相似信息 - 共计23条相似数据 + 共计{{totalNum}}条相似数据