204 lines
4.1 KiB
JavaScript
204 lines
4.1 KiB
JavaScript
// pages/my/my_data/my_data.js
|
|
const app = getApp();
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
name:"",
|
|
phone:"",
|
|
company: '',//公司名
|
|
companyId: '',//公司id
|
|
showModal: false,//公司弹窗
|
|
infoName: '',//搜索
|
|
dataList: [],//公司列表
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad: function (options) {
|
|
//个人信息
|
|
wx.showLoading({
|
|
title: '加载中..',
|
|
})
|
|
wx.request({
|
|
url: app.globalData.ip + '/wisdommining/api/user/getTwoGoodsType',
|
|
method: 'GET',
|
|
header: {
|
|
"content-type": "application/x-www-form-urlencoded",
|
|
},
|
|
data: {
|
|
userId: app.globalData.userId
|
|
},
|
|
success: res => {
|
|
wx.hideLoading()
|
|
console.log(res.data)
|
|
if (res.data.code == 1) {
|
|
this.setData({
|
|
user: res.data.value,
|
|
name: res.data.value.userName,
|
|
phone: res.data.value.userPhone,
|
|
company: res.data.value.companyName,
|
|
companyId:res.data.value.companyId
|
|
})
|
|
} else {
|
|
wx.showModal({
|
|
title: '提示!',
|
|
content: res.data.message,
|
|
showCancel: false,
|
|
})
|
|
}
|
|
}
|
|
})
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
onReady: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
onHide: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面卸载
|
|
*/
|
|
onUnload: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom: function () {
|
|
|
|
},
|
|
//点击选择公司出现弹框
|
|
show() {
|
|
this.setData({
|
|
infoName: '',
|
|
showModal: true,
|
|
})
|
|
this.dataList()
|
|
},
|
|
confirm() {
|
|
this.setData({
|
|
showModal: false,
|
|
})
|
|
},
|
|
searchGs() {
|
|
this.dataList()
|
|
},
|
|
//选择公司
|
|
select: function (e) {
|
|
let index = e.currentTarget.dataset.index;
|
|
let id = e.currentTarget.dataset.id;
|
|
let dataList = this.data.dataList;
|
|
for (let i = 0; i < dataList.length; i++) {
|
|
dataList[i].select = false;
|
|
}
|
|
dataList[index].select = true;
|
|
this.setData({
|
|
dataList: dataList,
|
|
showModal: false,
|
|
company: dataList[index].companyName,
|
|
companyId: id,
|
|
infoName:''
|
|
})
|
|
},
|
|
takname(e){
|
|
this.setData({
|
|
name:e.detail.value
|
|
})
|
|
},
|
|
takphone(e){
|
|
this.setData({
|
|
phone:e.detail.value
|
|
})
|
|
},
|
|
dataList: function (options) {
|
|
wx.showLoading({
|
|
title: '加载中..',
|
|
})
|
|
wx.request({
|
|
url: app.globalData.ip + '/wisdommining/api/user/getCompany',
|
|
method: 'GET',
|
|
header: {
|
|
"content-type": "application/x-www-form-urlencoded",
|
|
},
|
|
data: {
|
|
conpanyName: this.data.infoName
|
|
},
|
|
success: res => {
|
|
wx.hideLoading()
|
|
console.log(res)
|
|
if (res.data.code == 1) {
|
|
this.setData({
|
|
dataList: res.data.value
|
|
})
|
|
} else {
|
|
wx.showModal({
|
|
title: '提示!',
|
|
content: res.data.message,
|
|
showCancel: false,
|
|
})
|
|
}
|
|
}
|
|
})
|
|
},
|
|
taksubmit(){
|
|
wx.showLoading({
|
|
title: '加载中..',
|
|
})
|
|
wx.request({
|
|
url: app.globalData.ip + '/wisdommining/api/user/updateInfo',
|
|
method: 'PUT',
|
|
header: {
|
|
"content-type": "application/x-www-form-urlencoded",
|
|
},
|
|
data: {
|
|
companyId: this.data.companyId,
|
|
phone: this.data.phone,
|
|
userId: app.globalData.userId,
|
|
userName: this.data.name,
|
|
},
|
|
success: res => {
|
|
wx.hideLoading()
|
|
console.log(res)
|
|
if (res.data.code == 1) {
|
|
wx.showToast({
|
|
title: '修改成功!',
|
|
})
|
|
} else {
|
|
wx.showModal({
|
|
title: '提示!',
|
|
content: res.data.message,
|
|
showCancel: false,
|
|
})
|
|
}
|
|
}
|
|
})
|
|
}
|
|
}) |