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.
78 lines
2.4 KiB
78 lines
2.4 KiB
// xtends//vip/index.js
|
|
import Scene from '../../index/scene'
|
|
import { getFactoryLicence, getMemberList, buyMemberInfo } from "../../../api/saas"
|
|
import util from '../../../utils/util'
|
|
const event = require('../../../utils/event.js')
|
|
const app = getApp()
|
|
|
|
Scene({
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
factoryName: '',
|
|
expirationTime: null,
|
|
isExpiration: null,
|
|
memberList: [],
|
|
divIndexId: '49606500024333519',
|
|
},
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad: function (options) {
|
|
wx.showLoading({ title: '加载中', mask: true })
|
|
if(util.isEmpty(app.userInfo.expirationTime)){
|
|
getFactoryLicence().then(result => {
|
|
if(!result.data.expirationTime){
|
|
return
|
|
}
|
|
app.userInfo.expirationTime = result.expirationTime.substring(0, 10)
|
|
app.userInfo.isExpiration = result.isExpiration
|
|
this.setData({ expirationTime:app.userInfo.expirationTime, isExpiration: result.isExpiration })
|
|
})
|
|
}
|
|
getMemberList({enable: 1}).then(res => {
|
|
var memberList = res.data.records
|
|
wx.hideLoading()
|
|
this.setData({ factoryName: app.userInfo.factoryName,
|
|
memberList, divIndexId: memberList[0].id,
|
|
expirationTime: app.userInfo.expirationTime,
|
|
isExpiration: app.userInfo.isExpiration
|
|
})
|
|
}).catch(err => {
|
|
wx.hideLoading()
|
|
this.setData({factoryName: app.userInfo.factoryName})
|
|
util.showToast(err)
|
|
})
|
|
event.on('EventMessage', this, this.onEvent)
|
|
},
|
|
onEvent: function(message){
|
|
if (message.what == 300) {
|
|
getFactoryLicence().then(result => {
|
|
if(!result.data.expirationTime){
|
|
return
|
|
}
|
|
app.userInfo.expirationTime = result.data.expirationTime.substring(0, 10)
|
|
app.userInfo.isExpiration = result.data.isExpiration
|
|
this.setData({ expirationTime: app.userInfo.expirationTime, isExpiration: result.data.isExpiration })
|
|
})
|
|
}
|
|
},
|
|
onGridTap:function(e){
|
|
var index = e.currentTarget.dataset.index
|
|
this.setData({ divIndexId: this.data.memberList[index].id })
|
|
},
|
|
vipForm: function(){
|
|
wx.showLoading({ title: '处理中', mask: true })
|
|
buyMemberInfo({ memberExpenseId: this.data.divIndexId }).then(res => {
|
|
wx.hideLoading()
|
|
wx.navigateTo({ url: '/pages/ztbvip/payment/index?type=2&orderId=' + res.data.tradeOrderId })
|
|
}).catch(err => {
|
|
wx.hideLoading()
|
|
util.showToast(err)
|
|
})
|
|
},
|
|
onUnload: function(){
|
|
event.remove('EventMessage', this)
|
|
}
|
|
})
|