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.
73 lines
2.0 KiB
73 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 = '打包厂'
|
|
this.submitForm()
|
|
}
|
|
if (this.data.bidType == 2) {
|
|
this.data.identityTag = '废品站'
|
|
this.submitForm()
|
|
}
|
|
if (this.data.bidType == 3) {
|
|
this.data.identityTag = '废纸厂'
|
|
this.submitForm()
|
|
}
|
|
},
|
|
submitForm: function () {
|
|
this.setData({ requesting: true})
|
|
updateUserInfo({ identityTag: this.data.identityTag }).then(result => {
|
|
this.setData({ requesting: false})
|
|
app.globalData.userInfo.identityTag = this.data.identityTag
|
|
setTimeout(() => this.toNextTab(), 200)
|
|
}).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 })
|
|
}
|
|
})
|
|
}
|
|
|
|
})
|