182 lines
5.3 KiB
JavaScript
182 lines
5.3 KiB
JavaScript
// pages/mine/mine.js
|
||
import UserApi from '../../../net/api/userApi'
|
||
import {
|
||
copyrightUrl
|
||
} from '../../../net/http'
|
||
const Utils = require('../../../utils/util')
|
||
const app = getApp()
|
||
const deviceInfo = wx.getDeviceInfo()
|
||
const screenInfo = wx.getWindowInfo();
|
||
const statusBarHeight = screenInfo.statusBarHeight; // 状态栏高度
|
||
const navBarHeight = deviceInfo.platform == 'IOS' ? 48 : 50; // 导航栏高度(iOS 为 44px,Android 为 48px)
|
||
const windowHeight = screenInfo.windowHeight - navBarHeight - statusBarHeight; //可用内容高度
|
||
Page({
|
||
|
||
/**
|
||
* 页面的初始数据
|
||
*/
|
||
data: {
|
||
statusBarHeight: statusBarHeight,
|
||
navBarHeight: navBarHeight,
|
||
totalHeight: navBarHeight, // 导航栏总高度
|
||
contentHeight: windowHeight,
|
||
allCount: 0,
|
||
materialCount: 0,
|
||
accountInfo: {},
|
||
menuList: [{
|
||
"icon": "ic-user",
|
||
"title": "个人信息",
|
||
"path": "/pages/mine/mineAccount/mineInfo/mineInfo"
|
||
}, {
|
||
"icon": "ic-order",
|
||
"title": "我的订单",
|
||
"path": "/pages/mine/mineAccount/mineOrder/mineOrder"
|
||
}, {
|
||
"icon": "ic-invoice",
|
||
"title": "发票管理",
|
||
"path": ""
|
||
}, {
|
||
"icon": "ic-contact",
|
||
"title": "产权联系人",
|
||
"path": "/pages/mine/mineAccount/mineContact/mineContact"
|
||
}],
|
||
buttons: [{
|
||
text: '知道了'
|
||
}],
|
||
hintTxt: '',
|
||
showHint: false,
|
||
showError: false,
|
||
errorHint: '',
|
||
animationData: {}, //刷新动画
|
||
animation: null,
|
||
},
|
||
|
||
/**
|
||
* 生命周期函数--监听页面加载
|
||
*/
|
||
onLoad(options) {
|
||
const _self = this
|
||
_self.getMineAccount()
|
||
_self.getMinePackageCount()
|
||
const h = Utils.pxToRpx(_self.data.contentHeight)
|
||
_self.setData({
|
||
contentHeight: h
|
||
})
|
||
// 创建一个动画实例
|
||
const animation = wx.createAnimation({
|
||
duration: 1000,
|
||
timingFunction: 'ease'
|
||
});
|
||
this.setData({
|
||
animation: animation
|
||
})
|
||
},
|
||
//刷新账户
|
||
doRefresh() {
|
||
const _self = this
|
||
_self.playAnimation()
|
||
_self.getMineAccount() //获取账户信息
|
||
_self.getMinePackageCount() //获取套餐包信息
|
||
},
|
||
//播放刷新动画
|
||
playAnimation() {
|
||
const _self = this
|
||
// 重置动画
|
||
_self.data.animation.scale(1, 1).rotate(0).step({
|
||
duration: 0
|
||
});
|
||
_self.setData({
|
||
animationData: _self.data.animation.export()
|
||
});
|
||
_self.data.animation.scale(0.8, 0.8).rotate(180).step()
|
||
// 定义新的动画
|
||
_self.data.animation.scale(1, 1).rotate(360).step()
|
||
_self.setData({
|
||
animationData: _self.data.animation.export()
|
||
});
|
||
setTimeout(() => {
|
||
_self.setData({
|
||
animationData: {}
|
||
})
|
||
}, 1100);
|
||
},
|
||
onShow(options) {
|
||
this.getMineAccount() //获取账户信息
|
||
this.getMinePackageCount() //获取套餐包信息
|
||
},
|
||
getMineAccount() {
|
||
const _self = this
|
||
UserApi.doGetMineAccount()
|
||
.then(res => {
|
||
_self.setData({
|
||
accountInfo: res
|
||
})
|
||
}, err => {
|
||
console.log(err)
|
||
_self.setData({
|
||
errorHint: err.msg ? err.msg : '网络信号开小差啦,请您稍后再试,给您添麻烦~',
|
||
showError: true
|
||
})
|
||
})
|
||
},
|
||
//获取账户余额
|
||
getMinePackageCount() {
|
||
const _self = this
|
||
UserApi.doGetMinePackageCount()
|
||
.then(res => {
|
||
_self.setData({
|
||
allCount: res.ALL,
|
||
materialCount: res.MATERIAL
|
||
})
|
||
})
|
||
.catch(err => {
|
||
console.log(err)
|
||
_self.setData({
|
||
allCount: 0,
|
||
materialCount: 0
|
||
})
|
||
_self.setData({
|
||
errorHint: err.msg ? err.msg : '网络信号开小差啦,请您稍后再试,给您添麻烦~',
|
||
showError: true
|
||
})
|
||
})
|
||
},
|
||
//优惠卷
|
||
doCoupons() {
|
||
wx.navigateTo({
|
||
url: '/pages/mine/mineAccount/mineCoupons/mineCoupons',
|
||
})
|
||
},
|
||
//跳转充值页面
|
||
doPay() {
|
||
wx.navigateTo({
|
||
url: '/pages/copyright/payment/payment',
|
||
})
|
||
},
|
||
//条目点击
|
||
itemClick(e) {
|
||
const path = e.currentTarget.dataset.path
|
||
if (path == '') {
|
||
this.setData({
|
||
showHint: true,
|
||
hintTxt: `鉴于功能特性,需在电脑端完成操作。请打开浏览器,登录网址${copyrightUrl},进行后续操作。`
|
||
})
|
||
} else {
|
||
wx.navigateTo({
|
||
url: path,
|
||
})
|
||
}
|
||
},
|
||
closeHint(e) {
|
||
this.setData({
|
||
showHint: false,
|
||
hintTxt: ''
|
||
})
|
||
},
|
||
//下拉刷新
|
||
onPullDownRefresh() {
|
||
this.getMineAccount() //获取账户信息
|
||
this.getMinePackageCount() //获取套餐包信息
|
||
wx.stopPullDownRefresh()
|
||
}
|
||
}) |