123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320 |
- import {
- ApiModel
- } from "../../../utils/api";
- const _Http = new ApiModel();
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- searchFocus: false, //我的需求搜索框焦点
- searchText: "", //我的需求搜索内容
- pageNumber: 1, //获取第几页
- pageTotal: 2, //全部分页数量
- active: 0, //tabs 选中下标
- ftypeList: [], //分类列表
- ftype: "", //当前查询分类
- /* 供需列表 */
- productList: [],
- //轮播图列表
- swiperBannerList: [{
- id: "001",
- url: "/static/userImage.png",
- src: ''
- }, {
- id: "002",
- url: "/static/userImage.png",
- src: ''
- }, {
- id: "003",
- 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'
- }],
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- /* 获取所有信息分类 */
- _Http.basic({
- "accesstoken": wx.getStorageSync('userData').token,
- "classname": "enterprise.system.supplyanddemand",
- "method": "query_typeselectList",
- "content": {}
- }).then(res => {
- if (res.msg != '成功') return;
- this.setData({
- ftypeList: res.data
- })
- })
- },
- /* 宫格区点击事件 */
- switchScreenType(even) {
- let {
- type
- } = even.currentTarget.dataset;
- /* 第二次触发同一个,查询全部 */
- if (type == this.data.ftype) type = "";
- this.setData({
- ftype: type
- });
- this.getSupplyAndDemand()
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- this.getTabBar().init();
- //获取列表
- this.getList();
- },
- /* tabs切换接口 */
- getList() {
- if (this.data.active == 0) return this.getSupplyAndDemand();
- if (this.data.active == 2) return this.myNeed();
- },
- /* 供需下架 */
- soldOut(e) {
- 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("删除产品")
- }
- })
- },
- /* 获取供需列表 */
- getSupplyAndDemand(fstatus) {
- if (this.data.pageNumber > this.data.pageTotal) return;
- let condition = "";
- let where = {
- "condition": condition, //模糊搜索
- "ftype": this.data.ftype, //数据类型
- "fissupply": "" // 0需 1供
- };
- if (fstatus) {
- where = {
- "condition": condition, //模糊搜索
- "ftype": this.data.ftype, //数据类型
- "fissupply": 0, // 0需 1供
- "fstatus": "对接中"
- }
- };
- _Http.basic({
- "accesstoken": wx.getStorageSync('userData').token,
- "classname": "customer.supplyanddemand.supplyanddemand",
- "method": "query_supplyanddemandList",
- "content": {
- "getdatafromdbanyway": true,
- "pageNumber": this.data.pageNumber,
- "pageSize": 20,
- "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()
- })
- },
- /* tabs */
- tabsChange(even) {
- this.setData({
- active: even.detail.index
- })
- /* 初始化分页 */
- this.InitializeDataPaging();
- this.getList();
- },
- /* 我的需求 */
- 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);
- 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()
- })
- },
- /* 我的需求编辑按钮跳转 */
- productEdit(e) {
- console.log(e)
- const {
- index
- } = e.currentTarget.dataset
- const data = JSON.stringify(this.data.productList[index])
- wx.navigateTo({
- url: '/pages/announceDemand/index?data=' + data,
- })
- },
- /* 我的需求搜索框获得焦点 */
- 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() {
- let pageNumber = this.data.pageNumber + 1;
- this.setData({
- pageNumber
- })
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- this.getList();
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- }
- })
|