纸通宝小程序
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.
 

74 lines
2.0 KiB

// pages/home/tab1/index.js
import { updateUserInfo, getBaseInfo } from '../../../api/ztb'
const util = require('../../../utils/util')
const app = getApp()
Page({
/**
* 页面的初始数据
*/
data: {
safeBottom: app.globalData.safeBottom,
bidType: 0,
identityTag: ''
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.setData({ safeBottom: app.globalData.safeBottom })
this.getUerInfoFct()
},
toNextTab: function () {
wx.redirectTo({ url: '/pages/home/tab2/index' })
},
onTabChangeTop: function (e) {
if (this.data.bidType == Number(e.currentTarget.dataset.index)) {
return
}
var tabIndex = Number(e.currentTarget.dataset.index)
this.data.firstCategoryId = ''
this.setData({ ['bidType']: tabIndex })
if (this.data.bidType == 1) {
this.data.identityTag = '打包厂'
}
if (this.data.bidType == 2) {
this.data.identityTag = '废品站'
}
if (this.data.bidType == 3) {
this.data.identityTag = '废纸厂'
}
},
submitForm: function () {
if(util.isEmpty(this.data.identityTag)){
util.showToast('请输入你的身份')
return
}
this.setData({ requesting: true})
updateUserInfo({ identityTag: this.data.identityTag }).then(result => {
this.setData({ requesting: false})
app.globalData.userInfo.identityTag = this.data.identityTag
wx.navigateBack()
}).catch(err => {
util.showToast(err)
this.setData({ requesting: false})
})
},
onInput: function (e) {
this.data.identityTag = e.detail.value
},
getUerInfoFct: function () {
getBaseInfo().then(res => {
if (res.data.identityTag == '打包厂') {
this.setData({ bidType: 1 })
} else if (res.data.identityTag == '废品站') {
this.setData({ bidType: 2 })
} else if (res.data.identityTag == '造纸厂') {
this.setData({ bidType: 3 })
} else {
this.setData({ bidType: 4, identityTag: res.data.identityTag })
}
})
}
})