C端小程序
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.

130 line
3.0 KiB

  1. const app = getApp()
  2. const config = require("../../config/config");
  3. const Http = require("../../utils/HttpBasics");
  4. Component({
  5. properties: {
  6. background: {
  7. type: String,
  8. value: '#F4F5F9'
  9. },
  10. color: {
  11. type: String,
  12. value: '#000'
  13. },
  14. text: {
  15. type: String,
  16. value: 'Wechat'
  17. },
  18. showLocationIf: {
  19. type: Boolean,
  20. value: false
  21. },
  22. back: {
  23. type: Boolean,
  24. value: false
  25. },
  26. home: {
  27. type: Boolean,
  28. value: false
  29. }
  30. },
  31. data: {
  32. tenantData: JSON.parse(wx.getStorageSync('tenantData')),
  33. groupIf: wx.getStorageSync('groupIf'),
  34. tenantId: wx.getStorageSync('tenantId'),
  35. array: [],
  36. index: 1,
  37. statusBarHeight: app.statusBarHeight + 'px',
  38. navigationBarHeight: (app.statusBarHeight + 44) + 'px'
  39. },
  40. methods: {
  41. backHome: function () {
  42. wx.switchTab({
  43. url: '/index/index',
  44. })
  45. },
  46. bindPickerChange: function (e) {
  47. console.log('picker发送选择改变,携带值为', e.detail.value)
  48. this.setData({
  49. index: e.detail.value
  50. })
  51. let groupIf = false;
  52. let selectIndex = 0;
  53. this.data.tenantData.map((item, index) => {
  54. if (e.detail.value == item.parentTenantId) {
  55. groupIf = true;
  56. }
  57. if (e.detail.value == item.tenantId) {
  58. selectIndex = index;
  59. wx.setStorageSync('tenantId', item.tenantId)
  60. }
  61. })
  62. let param = {
  63. tenantId: this.data.tenantData[selectIndex].parentTenantId,
  64. subTenantId: this.data.tenantData[e.detail.value].tenantId
  65. }
  66. if (groupIf) {
  67. wx.setStorageSync('groupIf', true)
  68. } else {
  69. wx.setStorageSync('groupIf', false)
  70. }
  71. this.checkAble = true;
  72. Http.post({
  73. url: config.api.selectMall,
  74. data: param
  75. }).then(res => {
  76. wx.showModal({
  77. title: '提示',
  78. content: '切换成功!',
  79. })
  80. })
  81. .catch(err => {
  82. wx.showModal({
  83. title: '提示',
  84. content: err.message,
  85. showCancel: false,
  86. success: function (res) {
  87. // 如果游戏下架或者找不到,重启首页
  88. if (res.confirm) {
  89. // wx.reLaunch({
  90. // url: '/pages/index/index',
  91. // })
  92. }
  93. }
  94. })
  95. this.alphaClick();
  96. })
  97. },
  98. back: function () {
  99. wx.navigateBack({
  100. delta: 1
  101. })
  102. }
  103. },
  104. attached: function(){
  105. console.log(JSON.parse(wx.getStorageSync('tenantData')),11111)
  106. let list = [];
  107. let tindex = 0;
  108. this.data.tenantData.map((item,index)=>{
  109. list.push(item.name)
  110. if(item.tenantId == this.data.tenantId){
  111. tindex = index
  112. }
  113. })
  114. console.log(list,9999)
  115. this.setData({
  116. array:list,
  117. index: tindex
  118. })
  119. let pages = getCurrentPages();
  120. if (pages.length <= 1) {
  121. this.setData({
  122. back: false
  123. })
  124. }
  125. }
  126. })