|
|
@@ -2,11 +2,13 @@ import {
|
|
|
ApiModel
|
|
|
} from "../../../utils/api";
|
|
|
const _Http = new ApiModel();
|
|
|
+const handleList = require("../../../utils/processingData");
|
|
|
Page({
|
|
|
/**
|
|
|
* 页面的初始数据
|
|
|
*/
|
|
|
data: {
|
|
|
+ isOnShow: true, //是否触发onshow中的刷新列表
|
|
|
searchFocus: false, //我的需求搜索框焦点
|
|
|
searchText: "", //我的需求搜索内容
|
|
|
pageNumber: 1, //获取第几页
|
|
|
@@ -14,6 +16,7 @@ Page({
|
|
|
active: 0, //tabs 选中下标
|
|
|
ftypeList: [], //分类列表
|
|
|
ftype: "", //当前查询分类
|
|
|
+ ifShowCommunicationOfNumber: false,
|
|
|
/* 供需列表 */
|
|
|
productList: [],
|
|
|
//轮播图列表
|
|
|
@@ -30,36 +33,6 @@ Page({
|
|
|
url: "/static/userImage.png",
|
|
|
src: ''
|
|
|
}],
|
|
|
- /* 宫格列表 */
|
|
|
- gridList: [{
|
|
|
- id: '001',
|
|
|
- text: '寻找面料',
|
|
|
- icon: '/static/login/Phone.png'
|
|
|
- }, {
|
|
|
- id: '002',
|
|
|
- text: '面料设计',
|
|
|
- icon: '/static/login/identity.png'
|
|
|
- }, {
|
|
|
- id: '003',
|
|
|
- text: '平面设计',
|
|
|
- icon: '/static/login/username.png'
|
|
|
- }, {
|
|
|
- id: '004',
|
|
|
- text: '产品策划',
|
|
|
- icon: '/static/login/verificationcode.png'
|
|
|
- }, {
|
|
|
- id: '005',
|
|
|
- text: '寻找主播',
|
|
|
- icon: '/static/login/verificationcode.png'
|
|
|
- }, {
|
|
|
- id: '006',
|
|
|
- text: '摄影摄像',
|
|
|
- icon: '/static/login/identity.png'
|
|
|
- }, {
|
|
|
- id: '007',
|
|
|
- text: '商业培训',
|
|
|
- icon: '/static/login/username.png'
|
|
|
- }],
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
@@ -78,13 +51,19 @@ Page({
|
|
|
ftypeList: res.data
|
|
|
})
|
|
|
})
|
|
|
-
|
|
|
+ },
|
|
|
+ /* tabs切换接口 */
|
|
|
+ getList() {
|
|
|
+ if (this.data.active == 0) return this.getSupplyAndDemand();
|
|
|
+ if (this.data.active == 1) return this.getSupplyAndDemand(true);
|
|
|
+ if (this.data.active == 2) return this.myNeed();
|
|
|
},
|
|
|
/* 宫格区点击事件 */
|
|
|
switchScreenType(even) {
|
|
|
let {
|
|
|
type
|
|
|
} = even.currentTarget.dataset;
|
|
|
+ this.InitializeDataPaging();
|
|
|
/* 第二次触发同一个,查询全部 */
|
|
|
if (type == this.data.ftype) type = "";
|
|
|
this.setData({
|
|
|
@@ -98,48 +77,71 @@ Page({
|
|
|
onReady: function () {
|
|
|
|
|
|
},
|
|
|
-
|
|
|
/**
|
|
|
* 生命周期函数--监听页面显示
|
|
|
*/
|
|
|
onShow: function () {
|
|
|
this.getTabBar().init();
|
|
|
//获取列表
|
|
|
- this.getList();
|
|
|
+ if (this.data.isOnShow) {
|
|
|
+ this.getList();
|
|
|
+ } else {
|
|
|
+ this.setData({
|
|
|
+ isOnShow: true
|
|
|
+ })
|
|
|
+ }
|
|
|
},
|
|
|
- /* tabs切换接口 */
|
|
|
- getList() {
|
|
|
- if (this.data.active == 0) return this.getSupplyAndDemand();
|
|
|
- if (this.data.active == 2) return this.myNeed();
|
|
|
+ /* 显示沟通数量 */
|
|
|
+ showCommunicationOfNumber() {
|
|
|
+ this.setData({
|
|
|
+ ifShowCommunicationOfNumber: !this.data.ifShowCommunicationOfNumber
|
|
|
+ })
|
|
|
+ },
|
|
|
+ /* 阻止冒泡 */
|
|
|
+ stop() {
|
|
|
+
|
|
|
+ },
|
|
|
+ /* 一键联系 */
|
|
|
+ contact() {
|
|
|
+ console.log('一键联系')
|
|
|
},
|
|
|
/* 供需下架 */
|
|
|
soldOut(e) {
|
|
|
+ const that = this;
|
|
|
const {
|
|
|
index
|
|
|
- } = e.target.dataset
|
|
|
- console.log(index)
|
|
|
- _Http.basic({
|
|
|
- "accesstoken": wx.getStorageSync('userData').token,
|
|
|
- "classname": "customer.supplyanddemand.supplyanddemand",
|
|
|
- "method": "deletesupplyanddemand",
|
|
|
- "content": {
|
|
|
- "tsupplyanddemandid": this.data.productList[index].tsupplyanddemandid
|
|
|
- }
|
|
|
- }).then(res => {
|
|
|
- console.log(res)
|
|
|
- if (res.msg != "成功") {
|
|
|
- wx.showToast({
|
|
|
- title: res.data,
|
|
|
- icon: "error"
|
|
|
- })
|
|
|
- } else {
|
|
|
- console.log("删除产品")
|
|
|
+ } = e.target.dataset;
|
|
|
+ wx.showModal({
|
|
|
+ title: '提示',
|
|
|
+ content: '是否确定下架该需求',
|
|
|
+ success: function (res) {
|
|
|
+ if (res.confirm) {
|
|
|
+ _Http.basic({
|
|
|
+ "accesstoken": wx.getStorageSync('userData').token,
|
|
|
+ "classname": "customer.supplyanddemand.supplyanddemand",
|
|
|
+ "method": "updatesupplyanddemandstatus",
|
|
|
+ "content": {
|
|
|
+ "tsupplyanddemandid": that.data.productList[index].tsupplyanddemandid,
|
|
|
+ "fstatus": "已解决"
|
|
|
+ }
|
|
|
+ }).then(res => {
|
|
|
+ console.log(res)
|
|
|
+ if (res.msg != "成功") return;
|
|
|
+ let productList = that.data.productList;
|
|
|
+ productList[index].fstatus = "已解决"
|
|
|
+ that.setData({
|
|
|
+ productList
|
|
|
+ })
|
|
|
+ wx.showToast({
|
|
|
+ title: "下架成功"
|
|
|
+ })
|
|
|
+ })
|
|
|
+ }
|
|
|
}
|
|
|
- })
|
|
|
+ });
|
|
|
},
|
|
|
/* 获取供需列表 */
|
|
|
getSupplyAndDemand(fstatus) {
|
|
|
- if (this.data.pageNumber > this.data.pageTotal) return;
|
|
|
let condition = "";
|
|
|
let where = {
|
|
|
"condition": condition, //模糊搜索
|
|
|
@@ -151,7 +153,7 @@ Page({
|
|
|
"condition": condition, //模糊搜索
|
|
|
"ftype": this.data.ftype, //数据类型
|
|
|
"fissupply": 0, // 0需 1供
|
|
|
- "fstatus": "对接中"
|
|
|
+ "fstatus": "正在对接"
|
|
|
}
|
|
|
};
|
|
|
_Http.basic({
|
|
|
@@ -165,24 +167,8 @@ Page({
|
|
|
"where": where
|
|
|
}
|
|
|
}).then(res => {
|
|
|
- console.log(res)
|
|
|
if (res.msg != "成功") return;
|
|
|
- //替换或拼接
|
|
|
- if (res.pageNumber == 1) {
|
|
|
- this.InitializeDataPaging()
|
|
|
- //第一页直接替换list
|
|
|
- this.setData({
|
|
|
- productList: res.data,
|
|
|
- pageTotal: res.pageTotal
|
|
|
- });
|
|
|
- } else {
|
|
|
- //第二页开始拼接列表
|
|
|
- let productList = this.data.productList.concat(res.data);
|
|
|
- this.setData({
|
|
|
- productList
|
|
|
- })
|
|
|
- };
|
|
|
- this.PageDemanding()
|
|
|
+ this.returnList(res);
|
|
|
})
|
|
|
},
|
|
|
/* tabs */
|
|
|
@@ -194,10 +180,19 @@ Page({
|
|
|
this.InitializeDataPaging();
|
|
|
this.getList();
|
|
|
},
|
|
|
+ /* 跳转商品详情页 */
|
|
|
+ jumpForDetails(e) {
|
|
|
+ const {
|
|
|
+ index
|
|
|
+ } = e.currentTarget.dataset,
|
|
|
+ id = this.data.productList[index].tsupplyanddemandid;
|
|
|
+ wx.navigateTo({
|
|
|
+ url: '/pages/tabbar-pages/supplyAndDemand/particulars?tsupplyanddemandid=' + id + '&type=' + this.data.active,
|
|
|
+ })
|
|
|
+ },
|
|
|
/* 我的需求 */
|
|
|
myNeed() {
|
|
|
//全部加载完成退出请求
|
|
|
- if (this.data.pageTotal < this.data.pageNumber) return;
|
|
|
_Http.basic({
|
|
|
"accesstoken": wx.getStorageSync('userData').token,
|
|
|
"classname": "customer.supplyanddemand.supplyanddemand",
|
|
|
@@ -213,26 +208,33 @@ Page({
|
|
|
}
|
|
|
}
|
|
|
}).then(res => {
|
|
|
- console.log(res);
|
|
|
if (res.msg != "成功") return;
|
|
|
- //替换或拼接
|
|
|
- if (res.pageNumber == 1) {
|
|
|
- //第一页直接替换list
|
|
|
- this.setData({
|
|
|
- productList: res.data
|
|
|
- })
|
|
|
- this.InitializeDataPaging()
|
|
|
- } else {
|
|
|
- //第二页开始拼接列表
|
|
|
- let productList = this.data.productList.concat(res.data);
|
|
|
- this.setData({
|
|
|
- productList
|
|
|
- })
|
|
|
- console.log(321651)
|
|
|
- }
|
|
|
- this.PageDemanding()
|
|
|
+ this.returnList(res);
|
|
|
})
|
|
|
},
|
|
|
+ /* 返回列表 */
|
|
|
+ returnList(res) {
|
|
|
+ const data = handleList.checkdate(res.data)
|
|
|
+ const productList = handleList.listOrdering(data);
|
|
|
+ let pageNumber = this.data.pageNumber + 1;
|
|
|
+ //替换或拼接
|
|
|
+ if (res.pageNumber == 1) {
|
|
|
+ this.InitializeDataPaging()
|
|
|
+ //第一页直接替换list
|
|
|
+ this.setData({
|
|
|
+ productList,
|
|
|
+ pageTotal: res.pageTotal,
|
|
|
+ pageNumber
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ //第二页开始拼接列表
|
|
|
+ let list = this.data.productList.concat(productList);
|
|
|
+ this.setData({
|
|
|
+ productList: list,
|
|
|
+ pageNumber
|
|
|
+ })
|
|
|
+ };
|
|
|
+ },
|
|
|
/* 我的需求编辑按钮跳转 */
|
|
|
productEdit(e) {
|
|
|
console.log(e)
|
|
|
@@ -275,19 +277,19 @@ Page({
|
|
|
pageNumber: 1
|
|
|
})
|
|
|
},
|
|
|
- /* 分页 */
|
|
|
- PageDemanding() {
|
|
|
- let pageNumber = this.data.pageNumber + 1;
|
|
|
- this.setData({
|
|
|
- pageNumber
|
|
|
- })
|
|
|
- },
|
|
|
-
|
|
|
/**
|
|
|
* 生命周期函数--监听页面隐藏
|
|
|
*/
|
|
|
onHide: function () {
|
|
|
-
|
|
|
+ this.setData({
|
|
|
+ isOnShow: true
|
|
|
+ })
|
|
|
+ },
|
|
|
+ /* 阻止刷新列表 */
|
|
|
+ stopOnShow() {
|
|
|
+ this.setData({
|
|
|
+ isOnShow: false
|
|
|
+ })
|
|
|
},
|
|
|
|
|
|
/**
|