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.
436 lines
12 KiB
436 lines
12 KiB
import {
|
|
zconfig,
|
|
getBaseInfo,
|
|
updateUserInfoZtb
|
|
} from '../../api/ztb'
|
|
import {
|
|
updateUserInfo
|
|
} from '../../api/user'
|
|
const util = require('../../../utils/util')
|
|
const app = getApp()
|
|
|
|
Page({
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
backStatus: true,
|
|
nickName: '', //用户昵称
|
|
avatarUrl: '', //用户头像
|
|
banckCardList: [{
|
|
id: 1,
|
|
name: '个体回收户'
|
|
},
|
|
{
|
|
id: 2,
|
|
name: '打包站'
|
|
},
|
|
{
|
|
id: 3,
|
|
name: '废品站'
|
|
},
|
|
{
|
|
id: 4,
|
|
name: '印刷'
|
|
},
|
|
{
|
|
id: 6,
|
|
name: '包装厂'
|
|
},
|
|
{
|
|
id: 7,
|
|
name: '纸箱纸板厂'
|
|
},
|
|
{
|
|
id: 8,
|
|
name: '后加工'
|
|
},
|
|
{
|
|
id: 5,
|
|
name: '其他'
|
|
}
|
|
],
|
|
cardList: [{
|
|
value: '1',
|
|
text: '个体回收户'
|
|
},
|
|
{
|
|
value: '2',
|
|
text: '打包站'
|
|
},
|
|
{
|
|
value: '3',
|
|
text: '废品站'
|
|
},
|
|
{
|
|
value: '4',
|
|
text: '印刷'
|
|
},
|
|
{
|
|
value: '6',
|
|
text: '包装厂'
|
|
},
|
|
{
|
|
value: '7',
|
|
text: '纸箱纸板厂'
|
|
},
|
|
{
|
|
value: '8',
|
|
text: '后加工'
|
|
},
|
|
{
|
|
value: '5',
|
|
text: '其他'
|
|
}
|
|
],
|
|
userInfo: null,
|
|
userType: 1,
|
|
srcList: null,
|
|
visible: false
|
|
},
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad: function (options) {
|
|
getBaseInfo().then(res => {
|
|
this.setData({
|
|
userInfo: res.data,
|
|
nickName: res.data.realName,
|
|
avatarUrl: res.data.avatarUrl || '/assets/image/ygImg.png',
|
|
linkman: res.data.realName,
|
|
linkPhone: res.data.mobile,
|
|
companyAddress: res.data.fullAddress,
|
|
userType: res.data.userType,
|
|
realName: res.data.realName || res.data.userName,
|
|
})
|
|
})
|
|
this.cascaderView = this.cascaderView || this.selectComponent('#wux-cascader')
|
|
this.pickerView = this.pickerView || this.selectComponent('#picker-view')
|
|
},
|
|
uploadFile: function (path) {
|
|
var that = this
|
|
wx.showLoading({
|
|
title: '上传中',
|
|
mask: true
|
|
})
|
|
var header = {
|
|
...zconfig.header,
|
|
'X-APP-ID': app.xAppId,
|
|
appversion: app.version
|
|
}
|
|
this.task = wx.uploadFile({
|
|
url: zconfig.baseUrl + '/recycle-user-center/file-uploading/upload/image',
|
|
filePath: path,
|
|
name: 'image',
|
|
header,
|
|
success: function (result) {
|
|
var resp = null
|
|
if (!util.isEmpty(result.data)) {
|
|
resp = JSON.parse(result.data)
|
|
}
|
|
if (resp && resp.code === 0) {
|
|
that.updateMemberInfo({
|
|
avatar: resp.data
|
|
})
|
|
} else {
|
|
wx.hideLoading()
|
|
util.showToast('头像上传失败,请重新上传')
|
|
}
|
|
},
|
|
fail: function (res) {
|
|
wx.hideLoading()
|
|
util.showToast('头像上传失败,请重新上传')
|
|
}
|
|
})
|
|
},
|
|
showDialog: function (e1) {
|
|
this.wuxDialog = this.wuxDialog || this.selectComponent('#wux-dialog')
|
|
var that = this
|
|
var placeholderName = ''
|
|
if (e1.currentTarget.dataset.tag == '打包站名') {
|
|
placeholderName = that.data.userInfo.packageFactoryName
|
|
} else if (e1.currentTarget.dataset.tag == '打包站占地面积') {
|
|
placeholderName = that.data.userInfo.packageFactoryArea
|
|
} else if (e1.currentTarget.dataset.tag == '工厂人数') {
|
|
placeholderName = that.data.userInfo.numberOfEmployee
|
|
} else if (e1.currentTarget.dataset.tag == '打包机数') {
|
|
placeholderName = that.data.userInfo.numberOfPackageMachine
|
|
} else if (e1.currentTarget.dataset.tag == '昵称') {
|
|
placeholderName = that.data.userInfo.nickname
|
|
}
|
|
this.wuxDialog.prompt({
|
|
resetOnClose: true,
|
|
title: e1.currentTarget.dataset.tag,
|
|
placeholder: placeholderName || '请输入' + e1.currentTarget.dataset.tag,
|
|
maxlength: 18,
|
|
onConfirm(e, response) {
|
|
//非头像,昵称需要调用ztb修改用户信息接口
|
|
if (util.isEmpty(response)) {
|
|
util.showToast('请输入' + e1.currentTarget.dataset.tag)
|
|
return
|
|
} else
|
|
if (e1.currentTarget.dataset.tag == '打包站名') {
|
|
that.updateUserInfoFct({
|
|
packageFactoryName: response
|
|
})
|
|
} else
|
|
if (e1.currentTarget.dataset.tag == '打包站占地面积') {
|
|
if (parseInt(response)>0 && parseInt(response)==Number(response)) {
|
|
that.updateUserInfoFct({
|
|
packageFactoryArea: response
|
|
})
|
|
} else {
|
|
util.showToast('请输入正整数')
|
|
return
|
|
}
|
|
} else
|
|
if (e1.currentTarget.dataset.tag == '工厂人数') {
|
|
if (parseInt(response)>0 && parseInt(response)==Number(response)) {
|
|
that.updateUserInfoFct({
|
|
numberOfEmployee: response
|
|
})
|
|
} else {
|
|
util.showToast('请输入正整数')
|
|
return
|
|
}
|
|
} else
|
|
if (e1.currentTarget.dataset.tag == '打包机数') {
|
|
if (parseInt(response)>0 && parseInt(response)==Number(response)) {
|
|
that.updateUserInfoFct({
|
|
numberOfPackageMachine: response
|
|
})
|
|
} else {
|
|
util.showToast('请输入正整数')
|
|
return
|
|
}
|
|
} else {
|
|
//修改头像,昵称去UEC(user中的updateMemberInfo)
|
|
that.updateMemberInfo({
|
|
nickname: response
|
|
})
|
|
}
|
|
},
|
|
})
|
|
|
|
|
|
},
|
|
updateUserInfoFct: function (model) {
|
|
if (model) {
|
|
wx.showLoading({
|
|
title: '处理中',
|
|
mask: true
|
|
})
|
|
}
|
|
updateUserInfoZtb(model).then(result => {
|
|
wx.hideLoading()
|
|
if (model.packageFactoryName) {
|
|
this.setData({
|
|
['userInfo.packageFactoryName']: model.packageFactoryName
|
|
})
|
|
} else if (model.packageFactoryArea) {
|
|
this.setData({
|
|
['userInfo.packageFactoryArea']: model.packageFactoryArea
|
|
})
|
|
} else if (model.numberOfEmployee) {
|
|
this.setData({
|
|
['userInfo.numberOfEmployee']: model.numberOfEmployee
|
|
})
|
|
} else if (model.numberOfPackageMachine) {
|
|
this.setData({
|
|
['userInfo.numberOfPackageMachine']: model.numberOfPackageMachine
|
|
})
|
|
}
|
|
}).catch(err => {
|
|
wx.hideLoading()
|
|
})
|
|
},
|
|
updateMemberInfo: function (form) {
|
|
if (form.nickname) {
|
|
wx.showLoading({
|
|
title: '处理中',
|
|
mask: true
|
|
})
|
|
}
|
|
updateUserInfo(form).then(result => {
|
|
wx.hideLoading()
|
|
if (form.nickname) {
|
|
this.setData({
|
|
['userInfo.nickname']: form.nickname
|
|
})
|
|
} else if (form.avatar) {
|
|
this.setData({
|
|
avatarUrl: form.avatar
|
|
})
|
|
}
|
|
}).catch(err => {
|
|
wx.hideLoading()
|
|
util.showToast(err)
|
|
})
|
|
},
|
|
toAuth: function () {
|
|
if (this.data.userInfo && !this.data.userInfo.isAuth) {
|
|
wx.navigateTo({
|
|
url: '/pages/home/idcard/index'
|
|
})
|
|
}
|
|
},
|
|
//通过事件执行更换头像方法比如点击头像执行该方法
|
|
chooseImage: function () {
|
|
var that = this
|
|
wx.chooseImage({
|
|
count: 1, // 默认9
|
|
sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图,默认二者都有
|
|
sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有
|
|
success: function (res) {
|
|
// 返回选定照片的本地文件路径列表,tempFilePath可以作为img标签的src属性显示图片
|
|
// that.uploadFile(res.tempFilePaths[0])
|
|
that.setData({
|
|
visible: true,
|
|
srcList: res.tempFilePaths
|
|
})
|
|
}
|
|
})
|
|
},
|
|
//裁剪图片回调
|
|
onCropback: function (event) {
|
|
this.setData({
|
|
visible: false
|
|
})
|
|
this.uploadFile(event.detail[0])
|
|
},
|
|
//关闭回调
|
|
closeCallback: function () {
|
|
this.setData({
|
|
visible: false
|
|
})
|
|
},
|
|
//通过事件执行更换执照方法比如点击头像执行该方法
|
|
updatalicenseUrl() {
|
|
var that = this;
|
|
wx.chooseImage({
|
|
count: 1, // 默认9
|
|
sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图,默认二者都有
|
|
sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有
|
|
success: function (res) {
|
|
// 返回选定照片的本地文件路径列表,tempFilePath可以作为img标签的src属性显示图片
|
|
var imgPaths = res.tempFilePaths
|
|
that.updataheadservice2(imgPaths[0]);
|
|
}
|
|
})
|
|
},
|
|
//上传执照
|
|
updataheadservice2(imgPaths) {
|
|
var that = this;
|
|
wx.uploadFile({
|
|
header: {
|
|
'user-token': app.globalData.userToken
|
|
},
|
|
url: zconfig.baseUrl + '/recycle-user-center/file-uploading/upload/image', //你的服务器地址
|
|
filePath: imgPaths, //要上传文件资源的路径
|
|
name: 'image', //文件对应的 key,开发者在服务端可以通过这个 key 获取文件的二进制内容
|
|
formData: {
|
|
adminid: app.globalData.adminid //HTTP 请求中其他额外的参数比如 用户id
|
|
},
|
|
success(res) {
|
|
var jsonStr = res.data;
|
|
jsonStr = jsonStr.replace(" ", "");
|
|
if (typeof jsonStr != 'object') {
|
|
jsonStr = jsonStr.replace(/\ufeff/g, ""); //重点
|
|
var jj = JSON.parse(jsonStr);
|
|
res.data = jj;
|
|
}
|
|
that.setData({
|
|
licenseUrl: res.data.data
|
|
})
|
|
that.preservationheadimg2(res.data.data)
|
|
}
|
|
})
|
|
},
|
|
//保存用户执照
|
|
preservationheadimg2(imgUrl) {
|
|
updateUserInfo({
|
|
licenseUrl: this.data.licenseUrl
|
|
}).then(res => {
|
|
if (res.code == 0) {
|
|
util.showToast('修改执照成功!')
|
|
this.getUserInfoData()
|
|
} else {
|
|
util.showToast('执照上传失败')
|
|
}
|
|
})
|
|
},
|
|
showRegion: function () {
|
|
if (this.data.disabled) {
|
|
return
|
|
}
|
|
this.cascaderView.showPicker(this.data.region)
|
|
this.setData({
|
|
picking: true
|
|
})
|
|
},
|
|
onRegionChange: function (e) {
|
|
if (e.detail && e.detail.options) {
|
|
this.setData({
|
|
['form.areaStr']: e.detail.options.map((n) => n.label).join(' '),
|
|
region: e.detail.value
|
|
})
|
|
this.data.form['locProvinceId'] = e.detail.value[0]
|
|
this.data.form['locProvinceName'] = e.detail.options[0].label
|
|
this.data.form['locCityId'] = e.detail.value[1]
|
|
this.data.form['locCityName'] = e.detail.options[1].label
|
|
this.data.form['locDistrictId'] = e.detail.value[2]
|
|
this.data.form['locDistrictName'] = e.detail.options[2].label
|
|
}
|
|
this.setData({
|
|
picking: false
|
|
})
|
|
},
|
|
toBusinessLicense: function () {
|
|
wx.navigateTo({
|
|
url: '/pages/home/businessLicense/index'
|
|
})
|
|
},
|
|
toTab4: function () {
|
|
wx.navigateTo({
|
|
url: '/pages/home/tab4/index'
|
|
})
|
|
},
|
|
|
|
goPersonalInfo: function () {
|
|
wx.navigateTo({
|
|
url: '/pages/home/personal/personal'
|
|
})
|
|
},
|
|
|
|
goEnterpriseInfo: function () {
|
|
wx.navigateTo({
|
|
url: '/pages/home/enterprise/enterprise'
|
|
})
|
|
},
|
|
toTab5: function () {
|
|
wx.navigateTo({
|
|
url: '/pages/home/tab5/index'
|
|
})
|
|
},
|
|
toTab6: function () {
|
|
wx.navigateTo({
|
|
url: '/pages/home/tab6/index'
|
|
})
|
|
},
|
|
toTab3: function () {
|
|
wx.navigateTo({
|
|
url: '/pages/home/tab3/index'
|
|
})
|
|
},
|
|
toTab2: function () {
|
|
wx.navigateTo({
|
|
url: '/pages/home/tab2/index'
|
|
})
|
|
},
|
|
toTab1: function () {
|
|
wx.navigateTo({
|
|
url: '/pages/home/tab1/index'
|
|
})
|
|
},
|
|
|
|
})
|