import services from "../../services/index" import { queryImageConfigs, queryNotice, getGZMemberInfo } from "../../services/api/common/index" import { homeData } from "../../services/api/orders/index" import { loginid, loginQuery, userid } from "../../services/utils" import { hideLoading, showLoading } from "../../utils/message/index" import { appConfig } from "../../config/index" Page({ /** * 页面的初始数据 */ data: { /// 底部安全区域 safeBottom: getApp().globalData.safeBottom, /// 窗口高度 windowHeight: getApp().globalData.windowHeight, /// banner轮播图 banners: [''], /// 功能菜单 menus: [{id: 1, icon: appConfig.imgUrl+'home-gpdt', title: '挂牌大厅', path: '/pages/trade/index'}, {id: 2, icon: appConfig.imgUrl+'home-ss', title: '钻石首饰', path: '/mHome/pages/jewelry/list/index'}, {id: 3, icon: appConfig.imgUrl+'home-cjjc', title: '出境检测', path: '/mHome/pages/inspection/list/index'}, {id: 4, icon: appConfig.imgUrl+'home-bsfw', title: '保税服务', path: '/mHome/pages/bond/list/index'}, {id: 5, icon: appConfig.imgUrl+'home-bscyw', title: '保税仓业务', path: ''}, {id: 6, icon: appConfig.imgUrl+'home-zsss', title: '钻石搜索', path: '/mHome/pages/search/index'}, {id: 7, icon: appConfig.imgUrl+'home-jsq', title: '钻石计算器', path: '/mHome/pages/calculator/index'}, {id: 8, icon: appConfig.imgUrl+'home-zscx', title: '证书查询', path: '/mHome/pages/cerserach/index'}, {id: 9, icon: appConfig.imgUrl+'home-jjjy', title: '竞价交易', path: ''}, {id: 10, icon: appConfig.imgUrl+'home-cnys', title: '产能预售', path: ''}, {id: 11, icon: appConfig.imgUrl+'home-jcjy', title: '集采交易', path: ''}], /// 统计 statistics: { top: [{id: 1, title: '出售中', value: 0, class: ''}], rate: '' }, /// tabs tabs:[{id: 1, title: '公告'}, {id: 2, title: '消息'}], /// 公告消息 notice: {}, /// 公告系XO msgs: [{}], /// 会员信息 members: [{}], /// 是否为空 isEmpty: true }, /** * 获取首页轮播图数据 */ queryImageConfigs() { /// 获取首页轮播图数据 queryImageConfigs({ data: { imageType: 1 }, success:(res) => { /// 数据设置 this.setData({ banners: res.data.map(item => { return (services.config.openApiUrl+item.imagepath).replace('./uploadFile', '/uploadFile') }) }) } }) }, /** * 获取首页数据信息 */ homeData() { /// 获取新闻首页数据 homeData({ data: { userid: userid() }, success:(res) => { /// 数据设置 this.setData({ statistics: { top:[ { id: 1, title: '出售中', value: res.data.transactionssold, class: 'transactionssold' }, { id: 2, title: '求购中', value: res.data.transactioninpurchase, class: 'transactioninpurchase' }, { id: 3, title: '已购买', value: res.data.purchasedtransactions, class: 'purchasedtransactions' }, { id: 4, title: '已出售', value: res.data.transactionsonsale, class: 'transactionsonsale' }], rate: '今日汇率 '+loginQuery().exchangeRateConfigs[0].exchangerate.toString() } }) } }) }, /** * 查询通知公告消息 */ queryNotice(type: number){ /// loading showLoading(()=>{ /// 发送查询请求 queryNotice({ data: { loginID: loginid(), msgType: type }, success:(res) => { /// 数据为空 if (res.code != 200) { hideLoading(()=>{}, '请求失败,原因:'+res.msg) return } hideLoading(()=>{ /// 加载成功 数据复制 this.setData({ notice: res.data[0], msgs: res.data, }) }) }, fail: (emsg) => { /// 加载失败 hideLoading(()=>{}, emsg) } }) }) }, /** * 获取会员风采表 */ queryGZMemberInfo(){ /// loading showLoading(()=>{ /// 发送查询请求 getGZMemberInfo({ success:(res) => { /// 数据为空 if (res.code != 200) { hideLoading(()=>{}, '会员信息请求失败,原因:'+res.msg) return } hideLoading(()=>{ /// 加载成功 数据复制 this.setData({ members: res.data.map(itm => { var obj = itm obj.imageurl = (services.config.openApiUrl+itm.imageurl).replace('./uploadFile', '/uploadFile') return obj }), isEmpty: res.data.length === 0 }) }) }, fail: (emsg) => { /// 加载失败 hideLoading(()=>{}, emsg) } }) }) }, /** * 跳转公告消息页面方法 */ goToMsg() { wx.navigateTo({ url: '/mHome/pages/msg/msglist/index' }) }, /** * 计算器跳转 */ goToCalculator() { wx.navigateTo({ url: '/mHome/pages/calculator/index' }) }, /** * 证书查询 */ goToCerserach() { wx.navigateTo({ url: '/mHome/pages/cerserach/index' }) }, /// 进入公告消息详情页 goToMsgDetail(r: any) { let jsonStr = JSON.stringify(this.data.msgs[r.currentTarget.id]) wx.navigateTo({ url: '/mHome/pages/msg/msgdetail/index?id='+jsonStr }) }, /// onGirdClick onGirdClick(e: any) { switch (e.currentTarget.id) { case "1": wx.switchTab({ url: e.currentTarget.dataset.url }) break; default: /// 其他页面跳转 wx.navigateTo({ url: e.currentTarget.dataset.url }) break; } }, /** * 生命周期函数--监听页面加载 */ onLoad() { /// 获取新闻首页数据 this.homeData() /// 查询新闻资讯 this.queryNotice(1) /// 查询轮播图数据 this.queryImageConfigs() /// 查询会员信息 this.queryGZMemberInfo() }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() { }, /** * 生命周期函数--监听页面显示 */ onShow() { this.getTabBar().init() }, /** * 生命周期函数--监听页面隐藏 */ onHide() { }, /** * 生命周期函数--监听页面卸载 */ onUnload() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom() { }, /** * 用户点击右上角分享 */ onShareAppMessage() { } })