address.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. var businessT = require('../../../../tool/business-tool.js')
  2. var url = require('../../../../constant/url.js')
  3. import Net from '../../../../tool/net.js'
  4. var net = new Net()
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. isLoading: true,
  11. data: null
  12. },
  13. reloadData: function (data) {
  14. this.data.data = data
  15. this.setData({
  16. data: this.data.data
  17. })
  18. },
  19. addAction: businessT.action(function (sender) {
  20. wx.navigateTo({
  21. url: '../edit-address/edit-address?type=add'
  22. })
  23. }),
  24. editAction: businessT.action(function (sender) {
  25. wx.navigateTo({
  26. url: '../edit-address/edit-address?type=edit'
  27. })
  28. }),
  29. deleteAction: businessT.action(function (sender) {
  30. var that = this
  31. wx.showModal({
  32. title: '删除后将无法恢复',
  33. content: '是否删除该信息',
  34. confirmText: '删除',
  35. cancelText: '取消',
  36. confirmColor: '#3296FB',
  37. cancelColor: '#3296FB',
  38. success: function (res) {
  39. if (res.confirm) {
  40. that.deleteAddress()
  41. }
  42. }
  43. })
  44. }),
  45. deleteAddress: function() {
  46. net.connectNeedLogin({
  47. url: url.app_host + url.deleteMailingAddress,
  48. data: {},
  49. success: (err, res) => {
  50. this.data.data = null
  51. this.setData({
  52. data: this.data.data
  53. })
  54. },
  55. fail: (err, res) => {
  56. businessT.showFailTips(err, '加载失败')
  57. }
  58. })
  59. },
  60. getData: function () {
  61. wx.showLoading({
  62. title: '加载中',
  63. mask: true
  64. })
  65. net.connectNeedLogin({
  66. url: url.app_host + url.getMailingAddress,
  67. data: {},
  68. success: (err, res) => {
  69. if (res.data) {
  70. this.data.data = res.data
  71. } else {
  72. }
  73. this.data.isLoading = false
  74. this.setData({
  75. isLoading: this.data.isLoading,
  76. data: this.data.data
  77. })
  78. wx.hideLoading()
  79. },
  80. fail: (err, res) => {
  81. wx.hideLoading()
  82. businessT.showFailTips(err, '加载失败')
  83. setTimeout(function () {
  84. wx.navigateBack({
  85. })
  86. }.bind(this), 1000)
  87. }
  88. })
  89. },
  90. /**
  91. * 生命周期函数--监听页面加载
  92. */
  93. onLoad: function (options) {
  94. this.getData()
  95. },
  96. /**
  97. * 生命周期函数--监听页面初次渲染完成
  98. */
  99. onReady: function () {
  100. },
  101. /**
  102. * 生命周期函数--监听页面显示
  103. */
  104. onShow: function () {
  105. },
  106. /**
  107. * 生命周期函数--监听页面隐藏
  108. */
  109. onHide: function () {
  110. },
  111. /**
  112. * 生命周期函数--监听页面卸载
  113. */
  114. onUnload: function () {
  115. },
  116. /**
  117. * 页面相关事件处理函数--监听用户下拉动作
  118. */
  119. onPullDownRefresh: function () {
  120. },
  121. /**
  122. * 页面上拉触底事件的处理函数
  123. */
  124. onReachBottom: function () {
  125. },
  126. /**
  127. * 用户点击右上角分享
  128. */
  129. onShareAppMessage: function () {
  130. return {
  131. path: '/page/home/index',
  132. imageUrl: '../../../../icon/public/share_img.png',
  133. title: '自助缴社保公积金,覆盖200多个城市,专业团队操作'
  134. }
  135. }
  136. })