index.js 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. const api = require('../../utils/api.js');
  2. Page({
  3. /**
  4. * 页面的初始数据
  5. */
  6. data: {
  7. tab: {
  8. 'content': ['主题分类', '人生事件', '特定对象', '部门分类'],
  9. 'content1': ['主题分类', '对象分类', '经营活动', '部门分类'], },
  10. indexOf: 0,
  11. current: 0,
  12. tabindex: 0,
  13. sxType:1//区分是个人还是法人办事
  14. },
  15. search:function(){
  16. wx.navigateTo({
  17. url: '/pages/handle/search/search',
  18. })
  19. },
  20. tab: function (e) {
  21. let that = this;
  22. if(e.currentTarget.dataset.index==0){
  23. that.data.sxType=1
  24. // wx.setNavigationBarTitle({
  25. // title: '个人办事',
  26. // })
  27. }else{
  28. that.data.sxType=2
  29. that.req('ENTERPRISE_ZT')
  30. // wx.setNavigationBarTitle({
  31. // title: '法人办事',
  32. // })
  33. }
  34. console.log(that.data.PERSON_ZT)
  35. that.setData({
  36. tabindex: e.currentTarget.dataset.index,
  37. current: 0,
  38. index: 0,
  39. fileNme: that.data.sxType == 1 ? 'PERSON_ZT' :'ENTERPRISE_ZT',
  40. sxType:that.data.sxType
  41. })
  42. },
  43. change: function (e) {
  44. let that=this
  45. if (e.detail.current == 0 && this.data.sxType == 1){
  46. if (!that.data.PERSON_ZT){
  47. this.req('PERSON_ZT');
  48. that.setData({
  49. fileNme: 'PERSON_ZT',
  50. indexOf: e.detail.current
  51. })
  52. }else{
  53. that.setData({
  54. fileNme: 'PERSON_ZT',
  55. indexOf: e.detail.current
  56. })
  57. }
  58. } else if (e.detail.current == 1 && this.data.sxType == 1){
  59. if (!that.data.PERSON_RSSJ) {
  60. this.req('PERSON_RSSJ');
  61. that.setData({
  62. fileNme: 'PERSON_RSSJ',
  63. indexOf: e.detail.current
  64. })
  65. } else {
  66. that.setData({
  67. fileNme: 'PERSON_RSSJ',
  68. indexOf: e.detail.current
  69. })
  70. }
  71. } else if (e.detail.current == 2 && this.data.sxType == 1){
  72. if (!that.data.PERSON_TDRQ) {
  73. this.req('PERSON_TDRQ');
  74. that.setData({
  75. fileNme: 'PERSON_TDRQ',
  76. indexOf: e.detail.current
  77. })
  78. } else {
  79. that.setData({
  80. fileNme: 'PERSON_TDRQ',
  81. indexOf: e.detail.current
  82. })
  83. }
  84. } else if (e.detail.current == 0 && this.data.sxType == 2) {
  85. if (!that.data.ENTERPRISE_ZT) {
  86. this.req('ENTERPRISE_ZT');
  87. that.setData({
  88. fileNme: 'ENTERPRISE_ZT',
  89. indexOf: e.detail.current
  90. })
  91. } else {
  92. that.setData({
  93. fileNme: 'ENTERPRISE_ZT',
  94. indexOf: e.detail.current
  95. })
  96. }
  97. } else if (e.detail.current == 1 && this.data.sxType == 2) {
  98. if (!that.data.ENTERPRISE_TDDX) {
  99. this.req('ENTERPRISE_TDDX');
  100. that.setData({
  101. fileNme: 'ENTERPRISE_TDDX',
  102. indexOf: e.detail.current
  103. })
  104. } else {
  105. that.setData({
  106. fileNme: 'ENTERPRISE_TDDX',
  107. indexOf: e.detail.current
  108. })
  109. }
  110. } else if (e.detail.current == 2 && this.data.sxType == 2) {
  111. if (!that.data.ENTERPRISE_JYHD) {
  112. this.req('ENTERPRISE_JYHD');
  113. that.setData({
  114. fileNme: 'ENTERPRISE_JYHD',
  115. indexOf: e.detail.current
  116. })
  117. } else {
  118. that.setData({
  119. fileNme: 'ENTERPRISE_JYHD',
  120. indexOf: e.detail.current
  121. })
  122. }
  123. }
  124. if (e.detail.current == 3){
  125. that.setData({
  126. indexOf: e.detail.current
  127. })
  128. }
  129. },
  130. tabClick: function (e) {
  131. this.setData({
  132. current: e.currentTarget.dataset.index,
  133. indexOf: e.currentTarget.dataset.index
  134. })
  135. },
  136. details: function (e) {
  137. let that=this
  138. wx.navigateTo({
  139. url: '/pages/handle/details/index?unid=' + e.currentTarget.dataset.id + '&flag=' + that.data.sxType
  140. })
  141. },
  142. /**
  143. * 生命周期函数--监听页面加载
  144. */
  145. onLoad: function (options) {
  146. var that = this
  147. // wx.setStorageSync('userId', 92)
  148. var query = wx.createSelectorQuery();
  149. //选择id
  150. query.select('.top').boundingClientRect();
  151. query.select('.t').boundingClientRect();
  152. query.exec(function (res) {
  153. that.data.topHeight = res[0].height
  154. that.data.tabHeight = res[1].height
  155. wx.getSystemInfo({
  156. success: function (res) {
  157. that.setData({
  158. clientHeight: res.windowHeight - that.data.topHeight - that.data.tabHeight
  159. });
  160. }
  161. })
  162. })
  163. },
  164. req:function(type){
  165. wx.showLoading({
  166. title: '正在加载',
  167. })
  168. let that = this
  169. wx.request({
  170. url: api.server,
  171. data: { 'code': type },
  172. header: {},
  173. method: 'GET',
  174. dataType: 'json',
  175. responseType: 'text',
  176. success: function (res) {
  177. wx.hideLoading()
  178. var arr=[]
  179. for(var i=0;i<res.data.data.length;i++){
  180. res.data.data[i].imgurl = '../../images/' + type + '/' + res.data.data[i].dictValueCode+'.png'
  181. arr.push(res.data.data[i])
  182. }
  183. that.setData({
  184. [type]: res.data.data,
  185. fileNme: type
  186. })
  187. },
  188. fail: function (res) { },
  189. complete: function (res) { },
  190. })
  191. },
  192. /**
  193. * 生命周期函数--监听页面初次渲染完成
  194. */
  195. onReady: function () {
  196. var that=this
  197. this.req('PERSON_ZT');
  198. wx.request({
  199. url: api.Level,
  200. data:{page:0,rows:100},
  201. success(res){
  202. that.setData({
  203. list:res.data.data
  204. })
  205. }
  206. })
  207. },
  208. /**
  209. * 生命周期函数--监听页面显示
  210. */
  211. onShow: function () {
  212. },
  213. /**
  214. * 生命周期函数--监听页面隐藏
  215. */
  216. onHide: function () {
  217. },
  218. /**
  219. * 生命周期函数--监听页面卸载
  220. */
  221. onUnload: function () {
  222. },
  223. /**
  224. * 页面相关事件处理函数--监听用户下拉动作
  225. */
  226. onPullDownRefresh: function () {
  227. },
  228. /**
  229. * 页面上拉触底事件的处理函数
  230. */
  231. onReachBottom: function () {
  232. },
  233. /**
  234. * 用户点击右上角分享
  235. */
  236. onShareAppMessage: function () {
  237. }
  238. })