123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358 |
- // pages/userInfo/userInfo.js
- const app = getApp()
- const utils = require('../../utils/util.js')
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- globalUrl: app.globalData.globalUrl,
- userInfo: '', //缓存的用户信息
- user: '', //用户信息
- companyDefault: '', //默认用户企业(企业用户才有)
- sex: ['男', '女'], //性别列表
- sexIndex: '', //当前性别下标
- spreadFlag: false,
- entTypeDict:['一般纳税人','小规模纳税人','起征点以下纳税人'], //企业类型
- entTypeDictIndex:'', //企业类型下标
- deviceTypeDict:['软证书','税控盘','金税盘','税控ukey','税控服务器'], // 开票默认设备
- deviceTypeDictIndex:'',// 开票默认设备下标
- rateList: []
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- this.setData({
- userInfo: utils.getInfo()
- })
- //获取个人信息
- this.getUser()
- //如果是企业用户,获取默认公司信息
- if (this.data.userInfo.roles === 1) {
- this.getCompanyDefault()
- }
- },
- spreadBuyer() {
- this.setData({
- spreadFlag: !this.data.spreadFlag
- })
- },
- /* 公用函数—————————————————————————————————————————————————————————————— */
- //获取用户信息
- getUser() {
- utils.getUser({
- sendBefore: () => {
- wx.showLoading({
- title: '加载中...',
- mask: true
- })
- },
- complete: () => {
- wx.hideLoading()
- }
- }).then(res => {
- if (res.data) {
- if (res.data.sex === 'M') {
- this.setData({
- sexIndex: 0
- })
- } else if (res.data.sex === 'F') {
- this.setData({
- sexIndex: 1
- })
- }
- }
- this.setData({
- user: res.data
- })
- })
- },
- //修改或者上传头像
- uploadAvatar() {
- utils.chooseImage({
- sendBefore: () => {
- wx.showLoading({
- title: '上传中...'
- })
- }
- }).then(res => {
- utils.uploadFile({
- name: 'file',
- url: '/auth/comm/user/avatar/update',
- filePath: res.tempFilePaths[0],
- formData: {
- mobile: this.data.userInfo.mobile,
- reqChannel: 5
- },
- complete: () => {
- wx.hideLoading()
- }
- }).then(res => {
- this.updateSuccess()
- })
- })
- },
- //修改其他字段
- request(params) {
- utils.axios({
- method: 'post',
- url: '/auth/comm/user/personalInfo/save',
- data: params,
- success: res => {
- this.updateSuccess()
- }
- })
- },
- //信息修改成功执行的字段
- updateSuccess() {
- utils.toast('信息修改成功')
- this.selectComponent('#nickName').hideModal()
- this.selectComponent('#intro').hideModal()
- this.getUser()
- },
- //昵称
- showNickName() {
- this.selectComponent('#nickName').showModal()
- },
- getNickName(e) {
- let params = {
- mobile: this.data.userInfo.mobile,
- reqChannel: 5,
- nickName: e.detail
- }
- this.request(params)
- },
- //性别
- setSex(e) {
- let sexList = ['M', 'F']
- let params = {
- mobile: this.data.userInfo.mobile,
- reqChannel: 5,
- sex: sexList[e.detail.value]
- }
- this.request(params)
- },
- //个人简介
- showIntro() {
- this.selectComponent('#intro').showModal()
- },
- getIntro(e) {
- let params = {
- mobile: this.data.userInfo.mobile,
- reqChannel: 5,
- personalProfile: e.detail
- }
- this.request(params)
- },
- /* 企业用户—————————————————————————————————————————————————————————————— */
- //企业用户获取默认企业
- getCompanyDefault() {
- let entInfo=utils.getCurrEntInfo()
- this.setData({
- companyDefault: entInfo,
- entTypeDictIndex: entInfo.entType?entInfo.entType-1:'',
- deviceTypeDictIndex: entInfo.defaultInvoiceDevice?entInfo.defaultInvoiceDevice-1:'',
- })
- // utils.getCompany().then(res => {
- // this.setData({
- // companyDefault: res.data,
- // entTypeDictIndex: res.data.entType?res.data.entType-1:'',
- // deviceTypeDictIndex: res.data.defaultInvoiceDevice?res.data.defaultInvoiceDevice-1:'',
- // })
- // })
- },
- //企业类型
- setEntType(e) {
- let companyDefault = this.data.companyDefault
- companyDefault["entType"] = Number(e.detail.value)+1
- this.requestEntInfo(companyDefault)
- },
- //公司简称
- showEntShortName() {
- this.selectComponent('#entShortName').showModal()
- },
- getEntShortName(e) {
- let companyDefault = this.data.companyDefault
- companyDefault["entShortName"] = e.detail
- this.requestEntInfo(companyDefault)
- },
- //可用税率
- showAvailableTaxes() {
- utils.axios({
- method: 'get',
- url: '/auth/param/getRates',
- success: res => {
- this.setData({
- rateList:res.data
- })
- console.log(this.rateList)
- this.selectComponent('#availableTaxes').showModal()
- }
- })
- },
- getAvailableTaxes(e) {
- let companyDefault = this.data.companyDefault
- companyDefault["availableTaxes"] = e.detail
- this.requestEntInfo(companyDefault)
- },
- //默认开票设备
- setDefaultInvoiceDevice(e) {
- let companyDefault = this.data.companyDefault
- companyDefault["defaultInvoiceDevice"] = Number(e.detail.value)+1
- this.requestEntInfo(companyDefault)
- },
- //收款人
- showPayees() {
- this.selectComponent('#payees').showModal()
- },
- getPayees(e) {
- let companyDefault = this.data.companyDefault
- companyDefault["payees"] = e.detail
- this.requestEntInfo(companyDefault)
- },
- //审核人
- showReviewers() {
- this.selectComponent('#reviewers').showModal()
- },
- getReviewers(e) {
- let companyDefault = this.data.companyDefault
- companyDefault["reviewers"] = e.detail
- this.requestEntInfo(companyDefault)
- },
- //开户行
- showBankName() {
- this.selectComponent('#bankName').showModal()
- },
- getBankName(e) {
- let companyDefault = this.data.companyDefault
- companyDefault["bankName"] = e.detail
- this.requestEntInfo(companyDefault)
- },
- //联系人
- showEntContactPerson() {
- this.selectComponent('#entContactPerson').showModal()
- },
- getEntContactPerson(e) {
- let companyDefault = this.data.companyDefault
- companyDefault["entContactPerson"] = e.detail
- this.requestEntInfo(companyDefault)
- },
- //企业电话
- showEntPhone() {
- this.selectComponent('#entPhone').showModal()
- },
- getEntPhone(e) {
- let companyDefault = this.data.companyDefault
- companyDefault["entPhone"] = e.detail
- this.requestEntInfo(companyDefault)
- },
- //银行账号
- showBankAccountNumber() {
- this.selectComponent('#bankAccountNumber').showModal()
- },
- getbankAccountNumber(e) {
- let companyDefault = this.data.companyDefault
- companyDefault["bankAccountNumber"] = e.detail
- this.requestEntInfo(companyDefault)
- },
- //公司地址
- showEntAddress() {
- this.selectComponent('#entAddress').showModal()
- },
- getEntAddress(e) {
- let companyDefault =this.data.companyDefault
- companyDefault["entAddress"] = e.detail
- this.requestEntInfo(companyDefault)
- },
- //修改企业字段
- requestEntInfo(params) {
- params["userMobile"] = this.data.userInfo.mobile
- params["reqChannel"]=5
- utils.axios({
- method: 'post',
- url: '/sys/entInfo/updateBriefInfo',
- data: params,
- success: res => {
- this.setData({
- companyDefault: params
- })
- utils.toast('信息修改成功')
- this.selectComponent('#entShortName').hideModal()
- this.selectComponent('#availableTaxes').hideModal()
- this.selectComponent('#reviewers').hideModal()
- this.selectComponent('#bankName').hideModal()
- this.selectComponent('#bankAccountNumber').hideModal()
- this.selectComponent('#entContactPerson').hideModal()
- this.selectComponent('#entPhone').hideModal()
- this.selectComponent('#entAddress').hideModal()
- this.getCompanyDefault()
- }
- })
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- return {
- title: '诺信云',
- path: '/pages/index/index'
- }
- }
- })
|