import { appConfig } from '../../config/index'; import Dialog from '../../miniprogram_npm/@vant/weapp/dialog/dialog' import { queryBankAccountSign } from '../../services/api/account/index'; import { accountid, getLoginCode, loginid, loginQuery, setLoginCode, taAccount, userid } from '../../services/utils'; import { hideLoading, showLoading, showToast } from '../../utils/message/index'; Page({ /** * 页面的初始数据 */ data: { /// 图片地址 imgUrl: appConfig.imgUrl, // 功能菜单项 menulists: [{id: 1, title: '我的库存', img: 'mine-wdkc', path: '/mMine/pages/myinventorys/list/index'}, {id: 2, title: "我的订单", img: 'mine-wddd', path: '/mMine/pages/myorders/list/index'}, {id: 3, title: '我的履约', img: 'mine-wdly', path: '/mMine/pages/myperformance/list/index'}, {id: 4, title: '我的出境', img: 'mine-cjjc', path: '/mHome/pages/inspection/list/index'}, {id: 5, title: '我的保税', img: 'mine-bsfw', path: '/mHome/pages/bond/list/index'}], // 列表菜单项 tablelists: [{id: 1, title: '签约账户', iconfont: 'mine-qyzh', path: '/mMine/pages/bank/index'}, {id: 2, title: '收货地址', iconfont: 'mine-shdz', path: '/mMine/pages/address/list/index'}, {id: 3, title: '发票信息', iconfont: 'mine-fpxx', path: '/mMine/pages/invoice/list/index'}, {id: 4, title: '账户安全', iconfont: 'mine-mmxg', path: '/mMine/pages/modifypwd/index'}, {id: 5, title: '关于我们', iconfont: 'mine-gywm', path: '/mMine/pages/about/about/index'}], /// 微信头像 avatarUrl: wx.getStorageSync('avatarUrl'), /// 微信昵称 nickName: '', /// 资金账户信息 ta: ({}), /// 登录账号 loginid: loginid(), /// 是否脱敏显示 isOpenEye: false, /// 签约信息 sign: ({}), /// 状态栏高度 statusBarHeight: getApp().globalData.statusBarHeight, /// 导航栏高度 navHeight: getApp().globalData.navHeight }, onEye() { this.setData({ isOpenEye: !this.data.isOpenEye }) }, /** * 按钮点击响应事件 */ onButtonPressed(e: any) { /// 出入金操作 this.goToInOutGold(e.target.id) }, /// 出入金操作 goToInOutGold(id: string) { if (this.data.sign === undefined) { showToast('当前未查询到签约信息,请先签约!') return } switch (id) { case 'into-gold': /// 充值 wx.navigateTo({ url: '/mMine/pages/inoutgold/index?id=0' }) break; default: /// 提现 wx.navigateTo({ url: '/mMine/pages/inoutgold/index?id=1' }) break; } }, /** * 进入系统设置 */ goToSettings() { wx.navigateTo({ url: '/mMine/pages/settings/settings' }) }, /** * 生命周期函数--监听页面加载 */ onLoad() { this.setData({ /// 设置账户信息 ta: taAccount(accountid()), nickName: loginQuery().userInfo.customername }) /// 查询签约信息 this.queryBankAccountSign() }, /** * 获取用户信息 */ getUserInfo() { /// 如果不为空 if (this.data.avatarUrl != '') { return } wx.getUserProfile({ desc: '获取微信头像', success: (res) => { /// 存储头像 wx.setStorageSync('avatarUrl', res.userInfo.avatarUrl) /// 显示信息 this.setData({ avatarUrl: res.userInfo.avatarUrl }) }, fail: () => { showToast('获取用户头像失败!') } }) }, /** * 查询用户已签约信息 */ queryBankAccountSign() { /// loding..... showLoading(() => { /// 发送请求 queryBankAccountSign({ data: { userid: userid() }, success: (res) => { /// 请求失败 if (res.code != 200) { hideLoading(() => {}, '用户签约信息请求失败,原因:'+res.msg) return } hideLoading(() => { const sign = res.data.filter(obj => { return obj.signstatus === 2 || obj.signstatus === 3 || obj.signstatus === 4 })[0] /// 数据赋值 this.setData({ sign: sign }) }) }, fail: (emsg) => { hideLoading(() => {}, emsg) } }) }) }, /** * 系统登出响应 */ onLoginOut() { Dialog.confirm({ title: '提示', message: '确定要退出系统吗?', }).then(() => { /// 获取上次登录账号 const username = getLoginCode() /// 清楚所有的缓存数据 wx.clearStorage() /// 设置登录账号 setLoginCode(username) /// loding.... showLoading(()=>{ /// 登出 setTimeout(function () { hideLoading(()=>{ // on confirm wx.reLaunch({ url: '/pages/login/index' }) }, '登出成功', 'success') }, 3000) }, '登出中....') }).catch(() => { // on cancel }); }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() { }, /** * 生命周期函数--监听页面显示 */ onShow() { this.getTabBar().init() }, /** * 生命周期函数--监听页面隐藏 */ onHide() { }, /** * 生命周期函数--监听页面卸载 */ onUnload() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom() { }, /** * 用户点击右上角分享 */ onShareAppMessage() { } })