index.js 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  1. // pages/taxDisputes/index/index.js
  2. import {
  3. xcxsfsm,
  4. hqdw,
  5. xcxGetCompanyList,
  6. xcxsmbd,
  7. xcxsy
  8. } from "../../../apis/index.js"
  9. import {
  10. getMenu
  11. } from "../../../apis/sfzy"
  12. Page({
  13. /**
  14. * 页面的初始数据
  15. */
  16. data: {
  17. menuList: [],
  18. addressInfo: {},
  19. hall: {},
  20. markers: [],
  21. },
  22. /**
  23. * 生命周期函数--监听页面加载
  24. */
  25. onLoad(options) {
  26. let that = this
  27. },
  28. init() {
  29. let that = this
  30. let authorize = getApp().globalData.authorize()
  31. if (authorize !== 0) {
  32. wx.showModal({
  33. title: '提示',
  34. content: '检测到您当前未实名,请返回首页实名后点击税费争议模块重新办理。',
  35. showCancel: false,
  36. complete: (res) => {
  37. wx.switchTab({
  38. url: '../../index/index',
  39. })
  40. }
  41. })
  42. } else {
  43. that.getLocation()
  44. }
  45. },
  46. getLocation() {
  47. let that = this
  48. wx.getLocation({
  49. type: 'wgs84',
  50. isHighAccuracy: true,
  51. success(result) {
  52. that.getHall(result.latitude, result.longitude)
  53. },
  54. fail: (err) => {
  55. that.hqdw()
  56. }
  57. })
  58. },
  59. hqdw() {
  60. let that = this
  61. hqdw().then(res => {
  62. if (res.code == 200) {
  63. let data = JSON.parse(res.message)
  64. that.getHall(data.result.location.lat, data.result.location.lng)
  65. } else {
  66. wx.showToast({
  67. title: res.msg || res.message,
  68. icon: "none"
  69. })
  70. }
  71. })
  72. },
  73. getHall(lat, lng) {
  74. let that = this
  75. let publicId = wx.getStorageSync('PUBLIC_ID')
  76. let userinfo = wx.getStorageSync('USERINFO')
  77. let form = {
  78. xcxId: publicId.openid,
  79. unionid: publicId.unionid,
  80. longitude: String(lng),
  81. latitude: String(lat),
  82. nsrsbh: userinfo.nsrsbh || "",
  83. swjgdm: userinfo.swjgdm || ""
  84. }
  85. xcxsy(form).then(res => {
  86. if (res.code == 200) {
  87. let halls = res.list.sort((a, b) => {
  88. return a.zxjl - b.zxjl
  89. })
  90. wx.setStorageSync('HALL_LIST', halls)
  91. that.setMyHall(halls)
  92. } else {
  93. wx.showToast({
  94. title: res.msg || res.message,
  95. icon: "none",
  96. duration: 5000
  97. })
  98. }
  99. })
  100. },
  101. setMyHall(e) {
  102. let that = this
  103. let userinfo = wx.getStorageSync('USERINFO')
  104. let myhall = wx.getStorageSync('MY_HALL')
  105. if (myhall) {
  106. let update = false
  107. for (let i = 0; i < e.length; i++) {
  108. if (e[i].bsfwtDm == myhall.bsfwtDm) {
  109. update = true
  110. that.setData({
  111. hall: e[i]
  112. })
  113. that.setMarker(e[i])
  114. wx.setStorageSync('MY_HALL', e[i])
  115. break;
  116. }
  117. }
  118. if (!update) {
  119. that.setData({
  120. hall: myhall
  121. })
  122. that.setMarker(myhall)
  123. }
  124. } else {
  125. if (userinfo.swjgdm) {
  126. let hall = {}
  127. let uswjgdm = userinfo.swjgdm.substring(0, 7)
  128. for (let i = 0; i < e.length; i++) {
  129. let hswjgdm = e[i].ssswjgDm.substring(0, 7)
  130. if (uswjgdm == hswjgdm) {
  131. hall = e[i]
  132. break;
  133. }
  134. }
  135. if (!hall.bsfwtmc) hall = e[0]
  136. that.setData({
  137. hall: hall
  138. })
  139. wx.setStorageSync('MY_HALL', hall)
  140. that.setMarker(hall)
  141. } else {
  142. let hall = e[0]
  143. that.setData({
  144. hall: hall
  145. })
  146. wx.setStorageSync('MY_HALL', hall)
  147. that.setMarker(hall)
  148. }
  149. }
  150. that.getMenu(that.data.hall)
  151. },
  152. getMenu(e) {
  153. wx.showLoading()
  154. let that = this
  155. let form = {
  156. bsfwtDm: e.bsfwtDm
  157. }
  158. getMenu(form).then(res => {
  159. wx.hideLoading()
  160. if (res.code == 200) {
  161. that.setData({
  162. menuList: res.data
  163. })
  164. } else {
  165. wx.showToast({
  166. title: res.msg || res.message,
  167. icon: "none",
  168. duration: 3000
  169. })
  170. that.setData({
  171. menuList: []
  172. })
  173. }
  174. })
  175. },
  176. setMarker(e) {
  177. let that = this
  178. let lat = e.latitude || e.lat
  179. let lng = e.longitude || e.lng
  180. let marker = {
  181. id: 9527,
  182. latitude: lat,
  183. longitude: lng,
  184. title: "",
  185. zIndex: 9,
  186. alpha: 0.9,
  187. iconPath: "../../../icon/address.png",
  188. width: "30rpx",
  189. height: "30rpx",
  190. callout: {
  191. content: "大厅地址",
  192. color: "#313131",
  193. textAlign: "center",
  194. fontSize: 10,
  195. borderRadius: 5,
  196. bgColor: "#ffffff",
  197. padding: 5,
  198. display: "ALWAYS"
  199. }
  200. }
  201. that.setData({
  202. markers: [marker]
  203. })
  204. },
  205. selectHall(e) {
  206. let that = this
  207. let type = e.currentTarget.dataset.type
  208. wx.navigateTo({
  209. url: '../../indexPages/selectHall/selectHall?type=' + type,
  210. })
  211. },
  212. menuTap(e) {
  213. let item = e.currentTarget.dataset.item
  214. if (item.yxbz == 'Y') {
  215. wx.navigateTo({
  216. url: item.tzUrl,
  217. })
  218. } else {
  219. wx.showToast({
  220. title: '当前大厅禁用此项功能',
  221. icon: "none"
  222. })
  223. }
  224. },
  225. /**
  226. * 生命周期函数--监听页面初次渲染完成
  227. */
  228. onReady() {
  229. },
  230. /**
  231. * 生命周期函数--监听页面显示
  232. */
  233. onShow() {
  234. let that = this
  235. that.init()
  236. },
  237. /**
  238. * 生命周期函数--监听页面隐藏
  239. */
  240. onHide() {
  241. },
  242. /**
  243. * 生命周期函数--监听页面卸载
  244. */
  245. onUnload() {
  246. },
  247. /**
  248. * 页面相关事件处理函数--监听用户下拉动作
  249. */
  250. onPullDownRefresh() {
  251. },
  252. /**
  253. * 页面上拉触底事件的处理函数
  254. */
  255. onReachBottom() {
  256. },
  257. /**
  258. * 用户点击右上角分享
  259. */
  260. onShareAppMessage() {
  261. }
  262. })