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.
108 lines
3.4 KiB
108 lines
3.4 KiB
import { getMemberExpenseList, getMemberInfo, buyMemberInfo } from "../../api/ztb"
|
|
const util = require('../../utils/util')
|
|
const event = require('../../utils/event.js')
|
|
const tdsdk = require('../../libs/tdweapp.js')
|
|
const app = getApp()
|
|
|
|
Page({
|
|
data: {
|
|
userInfo: null,
|
|
userName: null,
|
|
avatarUrl: '../../assets/image/ygImg.png',
|
|
iconList: [],
|
|
safeBottom: app.globalData.safeBottom,
|
|
divIndex:null,
|
|
vipInfo: null,
|
|
visible: false
|
|
},
|
|
onLoad: function (options) {
|
|
this.setData({ safeBottom: app.globalData.safeBottom, userInfo: app.globalData.userInfo })
|
|
getMemberExpenseList().then(res => {
|
|
this.setData({ iconList: res.data, divIndex:res.data[0].id })
|
|
}).catch(err => { })
|
|
event.on('EventMessage', this, this.onEvent)
|
|
this.wuxDialog = this.wuxDialog || this.selectComponent('#wux-dialog')
|
|
},
|
|
onShow: function () {
|
|
tdsdk.Page.onShow()
|
|
if(!app.globalData.userInfo){
|
|
return
|
|
}
|
|
wx.showLoading({ title: '处理中', mask: true })
|
|
getMemberInfo().then(res => {
|
|
var nickname = ''
|
|
if (app.globalData.userInfo.isAuth) {
|
|
nickname = app.globalData.userInfo.realName.substring(0, 14)
|
|
} else if(!util.isEmpty(app.globalData.userInfo.nickname)) {
|
|
nickname =app.globalData.userInfo.nickname.substring(0, 14)
|
|
} else if(!util.isEmpty(app.globalData.userInfo.realName)) {
|
|
nickname = app.globalData.userInfo.realName.substring(0, 14)
|
|
}
|
|
var avatarUrl = util.isEmpty(app.globalData.userInfo.avatarUrl) ? '/assets/image/ygImg.png' : app.globalData.userInfo.avatarUrl
|
|
this.setData({ vipInfo: res.data, avatarUrl, userInfo: app.globalData.userInfo, userName: nickname })
|
|
wx.hideLoading()
|
|
}).catch(err => {
|
|
wx.hideLoading()
|
|
})
|
|
},
|
|
onEvent: function (message) {
|
|
if(message.what == 200){
|
|
this.setData({ visible: true })
|
|
}
|
|
},
|
|
onClose: function(){
|
|
this.setData({ visible: false })
|
|
},
|
|
onImageClick: function(){
|
|
wx.navigateBack()
|
|
},
|
|
toAuthor: function(){
|
|
if(this.data.userInfo && !this.data.userInfo.isAuth){
|
|
util.navigateTo('/pages/home/idcard/index')
|
|
}
|
|
},
|
|
onGridTap:function(e){
|
|
var divIndexId=e.currentTarget.dataset.index
|
|
this.setData({ divIndex:this.data.iconList[divIndexId].id })
|
|
},
|
|
openVip:function(){
|
|
if(!app.globalData.userInfo){
|
|
wx.navigateTo({ url: '/pages/login/index' })
|
|
return
|
|
}
|
|
if(!app.globalData.userInfo.isAuth){
|
|
this.wuxDialog.open({
|
|
resetOnClose: true,
|
|
title: '温馨提示',
|
|
content: '您还没有进行个人信息认证,无法购买会员,现在去进行个人信息认证?',
|
|
buttons: [{
|
|
text: '确定',
|
|
type: 'primary',
|
|
onTap(e) {
|
|
util.navigateTo('/pages/home/idcard/index')
|
|
}
|
|
}]
|
|
})
|
|
return
|
|
}
|
|
wx.showLoading({ title: '处理中', mask: true })
|
|
buyMemberInfo({ memberExpenseId: this.data.divIndex }).then(res => {
|
|
wx.hideLoading()
|
|
if(res.data.isNeedPay && res.data.orderId){
|
|
wx.navigateTo({ url: '/pages/withdrawal/payment/index?type=2&orderId=' + res.data.orderId })
|
|
} else {
|
|
app.globalData.userInfo.isVIP = 1
|
|
event.emit('EventMessage', { what: 200, desc: 'Vip' })
|
|
}
|
|
}).catch((e) => {
|
|
wx.hideLoading()
|
|
})
|
|
},
|
|
onHide: function(){
|
|
tdsdk.Page.onHide()
|
|
},
|
|
onUnload: function(){
|
|
tdsdk.Page.onUnload()
|
|
event.remove('EventMessage', this)
|
|
}
|
|
})
|