const app = getApp(); import apiAddr from '../../api/base'; import { setData } from '../../utils/index'; import { doNavigateWithUser } from '../../utils/helper'; import { postUrl, img_url, } from '../../utils/util'; import apiArr from '../../api/water_filter'; Page({ /** * 页面的初始数据 */ data: { order_List: [ { image: "https://zhsq.hshuishang.com/Public/img/common/order12.png", name: "物业账单", type: "h5", url: "", }, { image: "https://zhsq.hshuishang.com/Public/img/common/order04.png", name: "社区服务", type: "h5", url: "/packages/doorToDoor/pages/doorToDoor/doorToDoor", }, { image: "https://zhsq.hshuishang.com/Public/img/common/order11.png", name: "商家优惠", type: "h5", url: "", }, { image: "https://zhsq.hshuishang.com/Public/img/common/order08.png", name: "积分商城", type: "h5", url: "", }, { image: "https://wechat-img-file.oss-cn-beijing.aliyuncs.com/User/_assets/orderIcon_1.png", name: "社区健康", type: "h5", url: "", }, { image: "https://wechat-img-file.oss-cn-beijing.aliyuncs.com/User/_assets/orderIcon_2.png", name: "生活缴费", type: "h5", url: "", }, { image: "https://wechat-img-file.oss-cn-beijing.aliyuncs.com/User/_assets/orderIcon_3.png", name: "社区商城", type: "h5", url: "", }, { image: "https://wechat-img-file.oss-cn-beijing.aliyuncs.com/User/_assets/orderIcon_4.png", name: "周边商超", type: "h5", url: "", }, ], functional_List: [{ "image": "https://wechat-img-file.oss-cn-beijing.aliyuncs.com/person/Group_25.png", "name": "生活缴费", "url": "", "type": "h5" }, { "image": "https://wechat-img-file.oss-cn-beijing.aliyuncs.com/person/Group_26.png", "name": "优惠卡券", // "url": "/packages/user/coupon/index", "type": "h5" }, { "image": "https://wechat-img-file.oss-cn-beijing.aliyuncs.com/person/Group_35.png", "name": "我的卡券", "url": "", "type": "h5" }, { "image": "https://wechat-img-file.oss-cn-beijing.aliyuncs.com/person/Group_30.png", "name": "营销推广", "url": "/packages/user/marketing/index", "type": "h5" }, { "image": "https://wechat-img-file.oss-cn-beijing.aliyuncs.com/person/Group_27.png", "name": "个人设置", "url": "/packages/user/userInfo/index", "type": "h5" }, { "image": "https://wechat-img-file.oss-cn-beijing.aliyuncs.com/person/Group_29.png", "name": "平台客服", "url": "/packages/WaterPurifier/pages/Addfriend/Addfriend", "type": "h5" }, { "image": "https://wechat-img-file.oss-cn-beijing.aliyuncs.com/repairList.png", "name": "报修列表", "url": "/packages/OneRepair/pages/OwnerRepairList/OwnerRepairList", "type": "h5" }, ], shopServer: [ { image: "https://wechat-img-file.oss-cn-beijing.aliyuncs.com/Group_774.png", name: "订单核销", type: "", url: "/packages/indexSubcontract/write/write", }, { image: "https://wechat-img-file.oss-cn-beijing.aliyuncs.com/Group_774.png", name: "核销列表", type: "", url: "/packages/indexSubcontract/writeList/writeList", }, ], userInfo: {}, isShop: false, }, community(){ const ctoken = wx.getStorageSync('ctoken'); if(!ctoken){ wx.redirectTo({ url: '/pages/login/login', }) return } wx.navigateTo({ url: '/packages/community/communityList/index', }) }, /** * 生命周期函数--监听页面加载 */ onLoad: function () { // this.getOrderNav(); this.getFootNav(); const isShop = wx.getStorageSync('is_shop'); this.setData({ isShop }) }, handleMeApplyClick() { const ctoken = wx.getStorageSync('ctoken'); if (ctoken) { wx.navigateTo({ url: '/packages/community/OwnerList/OwnerList' }) return; } wx.redirectTo({ url: '/pages/login/login', }) }, toLogin() { const ctoken = wx.getStorageSync('ctoken'); if (ctoken) { wx.navigateTo({ url: '/packages/user/userInfo/index', }) return; } wx.redirectTo({ url: '/pages/login/login', }) }, getUserInfo() { const isCtoken = wx.getStorageSync('ctoken'); if (!isCtoken) return; postUrl(apiArr.loginInfo, {}, res => { console.log('loginInfo 接口结果', res); const newUserInfo = { ...res, userPic: res.img ? `${img_url}${res.img}` : 'https://wechat-img-file.oss-cn-beijing.aliyuncs.com/person/Group_309.png' } this.setData({ userInfo: newUserInfo }) }) }, handlePointsClick() { const ctoken = wx.getStorageSync('ctoken'); if (!ctoken) { this.goLogin(); return; } doNavigateWithUser({ url: '/packages/user/points/detail' }); }, handleSignClick() { const ctoken = wx.getStorageSync('ctoken'); if (!ctoken) { this.goLogin(); return; } doNavigateWithUser({ url: '/packages/user/points/sign' }); }, handleCommunityClick() { const ctoken = wx.getStorageSync('ctoken'); if (!ctoken) { this.goLogin(); return; } this.NotOpen(); return; doNavigateWithUser({ url: '/packages/user/community/list' }); }, handleCommunityClick2(){ const ctoken = wx.getStorageSync('ctoken'); if (!ctoken) { this.goLogin(); return; } wx.navigateTo({ url: '/packages/community/communityList/index?types=2', }) }, headerGridItemClick(event) { const ctoken = wx.getStorageSync('ctoken'); const { url } = event.currentTarget.dataset; console.log('123123', url); if (ctoken) { if (url) { doNavigateWithUser({ url }); } else { this.NotOpen(); } return; } // 如果点击为平台客服则允许跳转 if (url === '/packages/WaterPurifier/pages/Addfriend/Addfriend') { doNavigateWithUser({ url }); return; } this.goLogin(); }, headerOrderClick(event) { const { url } = event.currentTarget.dataset; if (!url) { this.NotOpen() }else{ if(!wx.getStorageSync('city')){ wx.showModal({ title: '提示', content: '请先选择您的城市', confirmText:"去选择", complete: (res) => { if (res.cancel) { } if (res.confirm) { wx.navigateTo({ url: '/pages/index/shopcity', }) } } }) return } wx.navigateTo({ url: url, }) } }, NotOpen() { wx.showModal({ title: '提示', content: '此功能暂未开通!', showCancel: false, complete: (res) => { if (res.cancel) { } } }) return }, // 订单导航 getOrderNav() { let _that = this; wx.request({ url: apiAddr.order_module, method: "post", header: { 'Content-type': 'application/x-www-form-urlencoded' }, data: {}, dataType: 'json', success: (result) => { setData(_that, 'order_List', result.data.contentBar); }, }) }, // 底部导航栏 getFootNav() { let _that = this; wx.request({ url: apiAddr.footer_nav_list, method: 'post', header: { 'Content-type': 'application/x-www-form-urlencoded' }, data: {}, dataType: 'json', success: (result) => { setData(_that, 'nav_list', result.data); setData(_that, 'foot_width', (100 / result.data.length).toFixed(2) + '%'); }, }); }, goLogin() { wx.redirectTo({ url: '/pages/login/login', }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() { }, /** * 生命周期函数--监听页面显示 */ onShow() { this.getUserInfo(); }, /** * 生命周期函数--监听页面隐藏 */ onHide() { }, /** * 生命周期函数--监听页面卸载 */ onUnload() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom() { }, // 监听下滑事件 onPageScroll(e) { let scrollTop = e.scrollTop; let tasktop = this.data.tasktop; if (scrollTop > tasktop && tasktop != 0) { this.setData({ fixedNavStyle: `position: fixed;top: 0;`, // 动态绑定样式 NavValueStyle: `padding-top:110rpx`, }); } else { this.setData({ fixedNavStyle: '', // 动态绑定样式 NavValueStyle: '' }); } }, /** * 用户点击右上角分享 */ onShareAppMessage(e) { console.log('分享触发2'); let { user_id } = app.getLocalUserInfo(); return { title: this.data.share_title, path: `/pages/index/community`, imageUrl: this.data.share_pic, success: (res) => { // console.log("转发成功"); }, fail: (res) => { // console.log("转发失败"); } } } })