import { ApiModel } from "../../../utils/api"; const _Http = new ApiModel(); const handleList = require("../../../utils/processingData"); const analyze = require("../../../components/My_TwoDimensionalCode/analyze"); let shareTime = null; Page({ /** * 页面的初始数据 */ data: { productList: [], //供需列表 //轮播图列表 swiperBannerList: [], portal_middle_1: '', /* 宫格列表 */ gridList: [{ text: '参展入口', icon: '/static/home-grid/icon-05.png' }, { text: '数据查询', icon: '/static/home-grid/icon-01.png' }, { text: '我要直播', icon: '/static/home-grid/icon-02.png' }, { text: '通知公告', icon: '/static/home-grid/icon-03.png' }], /* 圆角按钮tabs列表 */ codeMsg: {}, //二维码信息 MyModelShow: false, //二维码二次确认 MyModelText: "", //提示框文本 shareObj: null, //分享数据 /* 分页 */ pageNumber: 1, pageTotal: 1, ftype: "", condition: "" }, /* 宫格区跳转 */ gridJumpPage(e) { const { name } = e.target.dataset; if (name == '供需广场') { wx.switchTab({ url: '/pages/tabbar-pages/supplyAndDemand/index', }) } else if (name == '我要直播') { wx.navigateTo({ url: '/pages/liveStreaming/index', }) } else if (name == '通知公告') { wx.navigateTo({ url: '/pages/annunciate/index', }) } else if (name == '数据查询') { wx.navigateTo({ url: '/pages/tabbar-pages/home/analysis/index', }) } else if (name == '参展入口') { const data = this.data.portal_middle_1; if (data.length == 0) return wx.showToast({ title: '暂无展会活动', icon: "none" }) wx.navigateTo({ url: '/pages/scanQRCodes/register?id=' + data[0].fdataid, }) } else { wx.showToast({ title: '功能开发中', icon: "none" }) } }, /* 获取最新供需列表 */ supplyanddemandList() { if (this.data.pageNumber > this.data.pageTotal) return; _Http.basic({ "classname": "publicmethod.homepage.homepage", "method": "query_supplyanddemandList", "content": { "getdatafromdbanyway": true, "pageNumber": this.data.pageNumber, "pageSize": this.data.pageNumber == 1 ? 10 : 20, "siteid": "BWJ", "where": { "ftype": this.data.ftype, "condition": this.data.condition, "fissupply": "0", "fstatus": "待对接" } } }).then(res => { console.log('供需列表', res) if (res.msg != '成功') return wx.showToast({ title: res.data, icon: "none" }); if (res.data.length >= 1) { let data = handleList.getYTD(res.data), productList = null; res.pageNumber == 1 ? productList = data : productList = this.data.productList.concat(data); this.setData({ productList, pageTotal: res.pageTotal }); } }); }, /** * 生命周期函数--监听页面加载 */ onLoad: function (query) { const that = this; // 获取到二维码原始链接内容 if (query.q) { this.ifQrCodeType(analyze.setDataUrl(decodeURIComponent(query.q))); } else if (wx.getStorageSync('qrCodeMsg')) { this.ifQrCodeType(wx.getStorageSync('qrCodeMsg')); }; /* 获取最新供需列表 */ this.supplyanddemandList(); /* 获取轮播图 */ const getBan = setInterval(() => { if (wx.getStorageSync('bannerDataList')) { const bannerList = wx.getStorageSync('bannerDataList').filter(value => value.flocation == 'home_head'), portal_middle_1 = wx.getStorageSync('bannerDataList').filter(value => value.flocation == 'portal_middle_1'); this.setData({ swiperBannerList: bannerList[0].banner, portal_middle_1: portal_middle_1[0].banner }); clearInterval(getBan) } }, 300); //获取信息数量 this.selectComponent("#gxshuju").unReadMessageCount(); setTimeout(() => { that.getTabBar().setData({ 'tabbarList[3].fcount': getApp().globalData.msgFcount }) }, 500) //判断是否有门户直播登录 if (wx.getStorageSync('liveUrl')) { wx.navigateTo({ url: '/pages/webView/index?url=' + wx.getStorageSync('liveUrl'), }) wx.removeStorage({ key: 'liveUrl', }) } }, /* 二维码操作 */ ifQrCodeType(data) { if (!wx.getStorageSync('userData')) return; let MyModelText = '', tagentsid = wx.getStorageSync('userData').tagentsid; if (data.id == tagentsid) { wx.removeStorageSync('qrCodeMsg'); return wx.showToast({ title: "您已经加入该团队", icon: "none" }) } if (data.type == 'partner') { //申请合作 MyModelText = '是否向“' + data.name + '”发送合作申请'; } else if (data.type == 'shop') { //申请加入团队 MyModelText = '申请加入“' + data.name + '”团队'; }; this.setData({ MyModelText, codeMsg: data, MyModelShow: true }) wx.removeStorageSync('qrCodeMsg'); }, /* 首页模态框回调 */ MyShowModelCallBack({ detail }) { if (detail == 'true') { if (this.data.codeMsg.type == 'partner') { //申请合作 _Http.basic({ "accesstoken": wx.getStorageSync('userData').token, "classname": "customer.tagents.tagents", "method": "apply_cooperation", "content": { "tcooperationagentsid": this.data.codeMsg.id } }).then(res => { if (res.msg != '成功') return wx.showToast({ title: res.data, icon: "none" }); wx.showToast({ title: "合作申请成功", }); }); } else if (this.data.codeMsg.type == 'shop') { //申请加入团队 _Http.basic({ "classname": "publicmethod.users.Users", "method": "entryTeamApply", "content": { "userid": wx.getStorageSync('userData').userid, "tagentsid": this.data.codeMsg.id } }).then(res => { if (res.data != '成功') return wx.showToast({ title: res.data, icon: "none" }); wx.showToast({ title: "申请成功", icon: "none" }); }) } } else { this.setData({ MyModelShow: false, codeMsg: '' }); } }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { this.getTabBar().init(); this.getTabBar().setData({ 'tabbarList[3].fcount': getApp().globalData.msgFcount }) }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { this.setData({ pageNumber: this.data.pageNumber + 1 }) this.supplyanddemandList() }, /* 回调 */ shareCallBack({ detail }) { this.setData({ shareObj: detail }) }, /** * 用户点击右上角分享 */ /* */ onShareAppMessage: function (e) { const that = this; if (e.from == 'button') { const promise = new Promise(resolve => { shareTime = setInterval(() => { if (that.data.shareObj != null) { let str = JSON.stringify(that.data.shareObj), obj = JSON.parse(str); that.setData({ shareObj: null }) clearInterval(shareTime); resolve({ title: obj.ftitle, path: '/pages/tabbar-pages/home/sdDetalis?item=' + str, imageUrl: obj.attinfos.length >= 1 ? obj.attinfos[0].fobsurl : '', success: function (res) { if (res.errMsg == 'shareAppMessage:ok') { wx.showToast({ title: '分享成功', }) } }, }) } }, 300) }) return { title: '自定义转发标题', path: '/page/user?id=123', promise } /* */ } else { console.log('页面分享') } } })