|
@@ -1,9 +1,16 @@
|
|
|
+import {
|
|
|
+ ApiModel
|
|
|
+} from "../../../utils/api";
|
|
|
+const _Http = new ApiModel();
|
|
|
Page({
|
|
|
-
|
|
|
/**
|
|
|
* 页面的初始数据
|
|
|
*/
|
|
|
data: {
|
|
|
+ searchFocus: false, //我的需求搜索框焦点
|
|
|
+ searchText: "", //我的需求搜索内容
|
|
|
+ pageNumber: 1, //获取第几页
|
|
|
+ pageTotal: 2, //全部分页数量
|
|
|
active: 0, //tabs 选中下标
|
|
|
swiperBannerList: [{
|
|
|
id: "001",
|
|
@@ -56,6 +63,7 @@ Page({
|
|
|
onLoad: function (options) {
|
|
|
|
|
|
},
|
|
|
+ /* 宫格区点击事件 */
|
|
|
gridJumpPage(even) {
|
|
|
const {
|
|
|
name
|
|
@@ -74,6 +82,104 @@ Page({
|
|
|
*/
|
|
|
onShow: function () {
|
|
|
this.getTabBar().init();
|
|
|
+ //获取所有信息
|
|
|
+ this.getSupplyAndDemand();
|
|
|
+ },
|
|
|
+ /* 获取供需列表 */
|
|
|
+ getSupplyAndDemand() {
|
|
|
+ let ftype = "",
|
|
|
+ condition = ""
|
|
|
+ _Http.basic({
|
|
|
+ "accesstoken": wx.getStorageSync('userData').token,
|
|
|
+ "classname": "customer.supplyanddemand.supplyanddemand",
|
|
|
+ "method": "query_supplyanddemandList",
|
|
|
+ "content": {
|
|
|
+ "getdatafromdbanyway": true,
|
|
|
+ "pageNumber": 1,
|
|
|
+ "pageSize": 20,
|
|
|
+ "where": {
|
|
|
+ "condition": condition, //模糊搜索
|
|
|
+ "ftype": ftype, //数据类型
|
|
|
+ "fissupply": "" // 0需 1供
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }).then(res => {
|
|
|
+ console.log(res)
|
|
|
+ })
|
|
|
+ },
|
|
|
+ /* tabs切换 */
|
|
|
+ tabsChange(even) {
|
|
|
+ const {
|
|
|
+ title
|
|
|
+ } = even.detail;
|
|
|
+ this.setData({
|
|
|
+ active: even.detail.index
|
|
|
+ })
|
|
|
+ /* 初始化分页 */
|
|
|
+ this.InitializeDataPaging();
|
|
|
+ if (title == '我的需求') return this.myNeed();
|
|
|
+ },
|
|
|
+ /* 我的需求 */
|
|
|
+ myNeed() {
|
|
|
+ //全部加载完成退出请求
|
|
|
+ if (this.data.pageTotal < this.data.pageNumber) return;
|
|
|
+ _Http.basic({
|
|
|
+ "accesstoken": wx.getStorageSync('userData').token,
|
|
|
+ "classname": "customer.supplyanddemand.supplyanddemand",
|
|
|
+ "method": "query_mysupplyanddemandList",
|
|
|
+ "content": {
|
|
|
+ "getdatafromdbanyway": true,
|
|
|
+ "pageNumber": this.data.pageNumber,
|
|
|
+ "pageSize": 20,
|
|
|
+ "where": {
|
|
|
+ "condition": this.data.searchText,
|
|
|
+ "ftype": "",
|
|
|
+ "fissupply": "0"
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }).then(res => {
|
|
|
+ console.log(res);
|
|
|
+ this.PageDemanding(res.pageTotal)
|
|
|
+ })
|
|
|
+ },
|
|
|
+ /* 我的需求搜索框获得焦点 */
|
|
|
+ needSearchFocus() {
|
|
|
+ this.setData({
|
|
|
+ searchFocus: true
|
|
|
+ })
|
|
|
+ },
|
|
|
+ /* 我的需求搜索框失去焦点 */
|
|
|
+ needSearchBlur(e) {
|
|
|
+ const {
|
|
|
+ value
|
|
|
+ } = e.detail;
|
|
|
+ //数据比较,防止重复查询
|
|
|
+ if (value == this.data.searchText) return this.setData({
|
|
|
+ searchFocus: false,
|
|
|
+ });
|
|
|
+ let searchText = "";
|
|
|
+ if (value != "") searchText = value;
|
|
|
+ this.setData({
|
|
|
+ searchFocus: false,
|
|
|
+ searchText
|
|
|
+ })
|
|
|
+ this.InitializeDataPaging();
|
|
|
+ this.myNeed();
|
|
|
+ },
|
|
|
+ /* 初始化分页数据 */
|
|
|
+ InitializeDataPaging() {
|
|
|
+ this.setData({
|
|
|
+ pageTotal: 2,
|
|
|
+ pageNumber: 1
|
|
|
+ })
|
|
|
+ },
|
|
|
+ /* 分页 */
|
|
|
+ PageDemanding(pageTotal) {
|
|
|
+ let pageNumber = this.data.pageNumber + 1;
|
|
|
+ this.setData({
|
|
|
+ pageTotal,
|
|
|
+ pageNumber
|
|
|
+ })
|
|
|
},
|
|
|
|
|
|
/**
|
|
@@ -101,7 +207,7 @@ Page({
|
|
|
* 页面上拉触底事件的处理函数
|
|
|
*/
|
|
|
onReachBottom: function () {
|
|
|
-
|
|
|
+ if (this.data.active == 2) this.myNeed(); //我的需求
|
|
|
},
|
|
|
|
|
|
/**
|