123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388 |
- import {
- ApiModel
- } from "../../../utils/api";
- const _Http = new ApiModel();
- const handleList = require("../../../utils/processingData");
- const analyze = require("../../../components/My_TwoDimensionalCode/analyze");
- import queryLogin from '../../../utils/isLogin';
- let shareTime = null;
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- productList: [], //供需列表
- //轮播图列表
- swiperBannerList: [],
- portal_middle_1: '',
- /* 宫格列表 */
- gridList: [{
- text: '参展入口',
- icon: 'https://bwj.obs.cn-east-2.myhuaweicloud.com/resources/WeChat/home-grid/icon-05.png'
- }, {
- text: '数据查询',
- icon: 'https://bwj.obs.cn-east-2.myhuaweicloud.com/resources/WeChat/home-grid/icon-01.png'
- }, {
- text: '我要直播',
- icon: 'https://bwj.obs.cn-east-2.myhuaweicloud.com/resources/WeChat/home-grid/icon-02.png'
- }, {
- text: '通知公告',
- icon: 'https://bwj.obs.cn-east-2.myhuaweicloud.com/resources/WeChat/home-grid/icon-03.png'
- }],
- /* 圆角按钮tabs列表 */
- codeMsg: {}, //二维码信息
- MyModelShow: false, //二维码二次确认
- MyModelText: "", //提示框文本
- shareObj: null, //分享数据
- /* 分页 */
- pageNumber: 1,
- pageTotal: 1,
- ftype: "全部",
- condition: "",
- typePopShow: false,
- },
- /* 搜索内容 */
- searchContent({
- detail
- }) {
- if (this.data.condition == detail) return;
- this.setData({
- pageNumber: 1,
- pageTotal: 1,
- condition: detail
- })
- this.supplyanddemandList()
- },
- toRelease() {
- if (!queryLogin()) return;
- wx.navigateTo({
- url: '/pages/tabbar-pages/home/release/index',
- })
- },
- /* 宫格区跳转 */
- gridJumpPage(e) {
- if (!queryLogin()) return;
- 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 == '全部') ? "" : 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
- });
- } else {
- wx.showToast({
- title: '未搜索到相关内容',
- icon: "none"
- })
- }
- });
- },
- /**
- * 生命周期函数--监听页面加载
- */
- 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: ''
- });
- }
- },
- backGetList() {
- console.log('被调佣')
- this.setData({
- pageNumber: 1,
- pageTotal: 1,
- ftype: "全部",
- condition: "",
- })
- this.supplyanddemandList();
- },
- /* 选择分类 */
- typeCallBack({
- detail
- }) {
- if (detail == this.data.ftype || detail == '') return this.typePopChange()
- this.setData({
- pageNumber: 1,
- condition: '',
- ftype: detail,
- typePopShow: false
- })
- this.supplyanddemandList();
- },
- /* 弹出层控制 */
- typePopChange() {
- this.setData({
- typePopShow: !this.data.typePopShow
- })
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- 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('页面分享')
- }
- }
- })
|