纸通宝小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

60 lines
1.8 KiB

// pages/stock/index.js
import { getBaseInfo, getBalanceInfo } from "../../api/saas"
const util = require('../../../utils/util')
const math = require('../../../utils/math')
const app = getApp()
Component({
options: {
addGlobalClass: true,
multipleSlots: true
},
/**
* 页面的初始数据
*/
data: {
firstShow: false,
token: app.globalData.token,
userInfo: null,
avatarUrl: null,
accountMoney: 0
},
methods: {
onRestart: function () {
this.fetchUserInfo()
this.data.firstShow = true
},
fetchUserInfo: function () {
getBaseInfo().then(result => {
app.globalData.userInfo = result.data
this.setData({
avatarUrl: util.isEmpty(app.globalData.userInfo.avatar) ? '/assets/image/ygImg.png' : app.globalData.userInfo.avatar,
userInfo: app.globalData.userInfo,
userName: util.isEmpty(app.globalData.userInfo.userName) ? '' : app.globalData.userInfo.userName.substring(0, 14)
})
}).catch((e) => {
})
getBalanceInfo().then(res => {
this.setData({ accountMoney: math.minus(res.data.accountMoney, res.data.frozenMoney) })
}).catch(err => {
})
},
checkout: function () {
wx.navigateTo({ url: '/pages/withdrawal/checkout/index' })
},
toUserInfo: function () {
if(app.globalData.userInfo.isAuth != 1 && app.globalData.userInfo.userType == 1){
wx.navigateTo({ url: '/pages/home/pauthory/index' })
} else {
wx.navigateTo({ url: '/pages/home/pinfo/index' })
}
},
toAuthor: function () {
if(app.globalData.userInfo.isAuth != 1 && app.globalData.userInfo.userType == 1){
wx.navigateTo({ url: '/pages/home/pauthory/index' })
} else {
wx.navigateTo({ url: '/pages/home/pinfo/index' })
}
}
}
})