index.js 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  1. const api = require('../../../utils/api.js');
  2. const login = require('../../../utils/index.js');
  3. const app = getApp(), {
  4. globalData: {
  5. util: {
  6. regeneratorRuntime,
  7. navigate_auth_native,
  8. getWeatherInfo
  9. }
  10. }
  11. } = app;
  12. Page({
  13. /**
  14. * 页面的初始数据
  15. */
  16. data: {
  17. district: "洛龙"
  18. },
  19. navigateTo: function (e) {
  20. let that = this
  21. let getUserInfo = login.default.getUserInfo();
  22. getUserInfo.then((resolve) => {
  23. that.data.userInfo = resolve
  24. if (!that.data.userInfo.id) {
  25. return false
  26. } else {
  27. if (that.data.userInfo.isRealname != 1) {
  28. wx.showToast({
  29. title: '请先完善用户信息',
  30. icon: 'none'
  31. })
  32. return false
  33. }
  34. switch (that.flag) {
  35. case '1':
  36. if (!that.data.userInfo) {
  37. login.default.auth()
  38. return false
  39. } else if (that.data.userInfo.identity != 0) {
  40. wx.showToast({
  41. title: '企业身份不能办理个人事项',
  42. icon: 'none'
  43. })
  44. return false
  45. }
  46. break;
  47. case '2':
  48. if (!that.data.userInfo) {
  49. login.default.auth()
  50. return false
  51. } else if (that.data.userInfo.identity != 1) {
  52. wx.showToast({
  53. title: '个人身份不能办理企业事项',
  54. icon: 'none'
  55. })
  56. return false
  57. }
  58. break
  59. }
  60. getApp().globalData.util.navigate_auth_native(e);
  61. }
  62. })
  63. },
  64. nav(e) {
  65. let that = this
  66. switch (that.flag) {
  67. case '1':
  68. if (!that.data.userInfo) {
  69. login.default.auth()
  70. return false
  71. } else if (that.data.userInfo.identity != 0) {
  72. wx.showToast({
  73. title: '请切换到个人',
  74. icon: 'none'
  75. })
  76. return false
  77. }
  78. break;
  79. case '2':
  80. if (!that.data.userInfo) {
  81. login.default.auth()
  82. return false
  83. } else if (that.data.userInfo.identity != 1) {
  84. wx.showToast({
  85. title: '请切换到法人',
  86. icon: 'none'
  87. })
  88. return false
  89. }
  90. break
  91. }
  92. if (that.data.userInfo.isRealname != 1) {
  93. wx.showToast({
  94. title: '请先实名',
  95. icon: 'none'
  96. })
  97. return false
  98. }
  99. getApp().globalData.util.navigate_auth_native(e);
  100. },
  101. inText: function (e) {
  102. let that = this
  103. let arr = []
  104. if (that.data.params) {
  105. that.data.param = that.data.params
  106. } else {
  107. that.data.params = that.data.param
  108. }
  109. for (var i = 0; i < that.data.param.length; i++) {
  110. if (String(that.data.param[i].serviceName).indexOf(String(e.detail.value).trim()) != -1) {
  111. arr.push(that.data.param[i])
  112. }
  113. }
  114. that.setData({
  115. param: arr
  116. })
  117. },
  118. nullText: function (e) {
  119. let that = this
  120. if (!String(e.detail.value).trim()) {
  121. that.setData({
  122. param: that.data.params ? that.data.params : that.data.param
  123. })
  124. }
  125. },
  126. /**
  127. * 生命周期函数--监听页面加载
  128. */
  129. async onLoad({
  130. id,
  131. scene = "",
  132. flag,
  133. preService,
  134. code,
  135. unid,
  136. titleName
  137. }) {
  138. let that = this
  139. wx.setNavigationBarTitle({
  140. title: titleName,
  141. })
  142. let options = {}
  143. options.flag = flag
  144. options.preService = preService
  145. options.code = code
  146. options.unid = unid
  147. let [pid = id, cid = 0] = scene.match(/\d{1,}/g) || []
  148. this.data = {
  149. pid,
  150. cid
  151. }
  152. that.req(options)
  153. this.setData({ weather: await getWeatherInfo() })
  154. },
  155. req: function (options) {
  156. let that = this
  157. that.flag = options.flag
  158. wx.showLoading({
  159. title: '正在加载',
  160. })
  161. wx.setStorageSync('flag', options.flag)
  162. var requestData = ''
  163. if (options.preService == 'PERSON_ZT' & options.flag == 1) {
  164. requestData = 'personZt'
  165. } else if (options.preService == 'PERSON_RSSJ' & options.flag == 1) {
  166. requestData = 'personRssj'
  167. } else if (options.preService == 'PERSON_TDRQ' & options.flag == 1) {
  168. requestData = 'personTdrq'
  169. } else if (options.preService == 'ENTERPRISE_ZT' & options.flag == 2) {
  170. requestData = 'enterpriseZt'
  171. } else if (options.preService == 'ENTERPRISE_TDDX' & options.flag == 2) {
  172. requestData = 'enterpriseTddx'
  173. } else if (options.preService == 'ENTERPRISE_JYHD' & options.flag == 2) {
  174. requestData = 'enterpriseJyhd'
  175. }
  176. if (options.unid) {
  177. wx.request({
  178. url: api.handles,
  179. data: {
  180. 'flag': options.flag,
  181. deptUnid: options.unid
  182. },
  183. method: 'GET',
  184. success(res) {
  185. wx.hideLoading()
  186. that.data.param = res.data.data
  187. that.setData({
  188. param: res.data.data,
  189. flag: options.flag
  190. })
  191. }
  192. })
  193. return false
  194. } else {
  195. wx.request({
  196. url: api.handles,
  197. data: {
  198. [requestData]: options.code,
  199. 'flag': options.flag
  200. },
  201. method: 'GET',
  202. success(res) {
  203. wx.hideLoading()
  204. that.data.param = res.data.data
  205. that.setData({
  206. param: res.data.data,
  207. flag: options.flag
  208. })
  209. }
  210. })
  211. }
  212. },
  213. nav: function (e) {
  214. wx.navigateTo({
  215. url: e.currentTarget.dataset.url,
  216. })
  217. },
  218. /**
  219. * 生命周期函数--监听页面显示
  220. */
  221. onShow() {
  222. },
  223. /**
  224. * 生命周期函数--监听页面隐藏
  225. */
  226. onHide: function () {
  227. },
  228. /**
  229. * 生命周期函数--监听页面卸载
  230. */
  231. onUnload: function () {
  232. },
  233. /**
  234. * 页面相关事件处理函数--监听用户下拉动作
  235. */
  236. onPullDownRefresh: function () {
  237. this.setData({
  238. param: this.data.params,
  239. searchValue: ''
  240. })
  241. wx.stopPullDownRefresh()
  242. },
  243. /**
  244. * 页面上拉触底事件的处理函数
  245. */
  246. onReachBottom: function () {
  247. },
  248. /**
  249. * 用户点击右上角分享
  250. */
  251. onShareAppMessage: function ({
  252. from,
  253. target
  254. }) {
  255. let cid = 0;
  256. if (from == 'button') {
  257. ({
  258. dataset: {
  259. cid
  260. }
  261. } = target)
  262. }
  263. return {
  264. title: '弹出分享时显示的分享标题',
  265. //imageUrl: '',
  266. path: `pages/handle/details/index?scene=${this.data.pid}_${cid}`
  267. }
  268. },
  269. setcur({
  270. target: {
  271. dataset: {
  272. sindex,
  273. url,
  274. docCount
  275. }
  276. }
  277. }) {
  278. sindex && this.setData({
  279. cur: sindex
  280. })
  281. },
  282. navigate_auth_native,
  283. })