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.

112 lines
2.0 KiB

1 year ago
  1. // pages/config/config.js
  2. const app=getApp()
  3. const WXAPI = require('../../utils/request')
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. radio: '',
  10. list:[]
  11. },
  12. /**
  13. * 生命周期函数--监听页面加载
  14. */
  15. onLoad: function (options) {
  16. var userinfo = wx.getStorageSync('userInfo')
  17. var tenantId = userinfo.tenantId.split(',')
  18. var arr = []
  19. this.setData({
  20. radio:wx.getStorageSync('tenantId')
  21. })
  22. WXAPI.getConfig('').then(res => {
  23. if (res.success) {
  24. if(userinfo.type===0){
  25. arr=res.data.list
  26. }else{
  27. tenantId.map(lt => {
  28. var obj = res.data.list.filter(item => {return item.value==lt})[0]
  29. if(obj){
  30. arr.push(obj)
  31. }
  32. })
  33. }
  34. this.setData({
  35. list:arr
  36. })
  37. // localStorage.setItem('selectoption',JSON.stringify(arr))
  38. } else {
  39. this.$message.error("获取失败")
  40. }
  41. })
  42. },
  43. onChange(event) {
  44. var that=this
  45. wx.showModal({
  46. content: '是否切换数据源',
  47. success (res) {
  48. if (res.confirm) {
  49. that.setData({
  50. radio: event.detail,
  51. });
  52. wx.setStorageSync('tenantId', event.detail)
  53. WXAPI.setTenantId(event.detail)
  54. wx.reLaunch({
  55. url:"/pages/index/index"
  56. })
  57. } else if (res.cancel) {
  58. }
  59. }
  60. })
  61. },
  62. /**
  63. * 生命周期函数--监听页面初次渲染完成
  64. */
  65. onReady: function () {
  66. },
  67. /**
  68. * 生命周期函数--监听页面显示
  69. */
  70. onShow: function () {
  71. },
  72. /**
  73. * 生命周期函数--监听页面隐藏
  74. */
  75. onHide: function () {
  76. },
  77. /**
  78. * 生命周期函数--监听页面卸载
  79. */
  80. onUnload: function () {
  81. },
  82. /**
  83. * 页面相关事件处理函数--监听用户下拉动作
  84. */
  85. onPullDownRefresh: function () {
  86. },
  87. /**
  88. * 页面上拉触底事件的处理函数
  89. */
  90. onReachBottom: function () {
  91. },
  92. /**
  93. * 用户点击右上角分享
  94. */
  95. onShareAppMessage: function () {
  96. }
  97. })