myaddress.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. const app = getApp()
  2. Page({
  3. data: {
  4. datatype: '',
  5. chose: '',
  6. addressList: [],
  7. indicatorDots: true,
  8. autoplay: true,
  9. interval: 5000,
  10. duration: 2000,
  11. loaddisplay: true,
  12. userInfo: {},
  13. hasUserInfo: false,
  14. canIUse: wx.canIUse('button.open-type.getUserInfo')
  15. },
  16. //事件处理函数
  17. bindViewTap: function() {
  18. wx.navigateTo({
  19. url: '../logs/logs'
  20. })
  21. },
  22. onLoad: function(options) {
  23. if (JSON.stringify(options) != "{}") {
  24. this.setData({
  25. datatype: options.type,
  26. chose: 'chose'
  27. })
  28. }
  29. var that = this
  30. wx.request({
  31. url: app.globalData.url + '/getWXUserAddress',
  32. method: 'get',
  33. data: {
  34. xu_openid: app.globalData.openid
  35. },
  36. success: function(res) {
  37. that.setData({
  38. addressList: res.data,
  39. loaddisplay: 'none'
  40. })
  41. },
  42. fail() {
  43. app.timeOut()
  44. }
  45. })
  46. let _this = this;
  47. _this.setData({
  48. navH: app.globalData.navHeight
  49. })
  50. },
  51. getUserInfo: function(e) {
  52. app.globalData.userInfo = e.detail.userInfo
  53. this.setData({
  54. userInfo: e.detail.userInfo,
  55. hasUserInfo: true
  56. })
  57. },
  58. // hrefCl: function(e) {
  59. // wx.navigateTo({
  60. // url: '/pages/consultant/consultant'
  61. // })
  62. // },
  63. // hrefPm: function(e) {
  64. // wx.navigateTo({
  65. // url: '/pages/promotion/promotion'
  66. // })
  67. // },
  68. // hrefEq: function(e) {
  69. // wx.navigateTo({
  70. // url: '/pages/equipment/equipment'
  71. // })
  72. // },
  73. radioChange: function(e) {
  74. var that = this
  75. wx.request({
  76. url: app.globalData.url + '/updateWXUserDefAddress',
  77. method: 'get',
  78. data: {
  79. id: e.detail.value
  80. },
  81. success: function(res) {
  82. wx.showToast({
  83. title: '设置成功!',
  84. icon: 'none',
  85. duration: 1000
  86. })
  87. wx.request({
  88. url: app.globalData.url + '/getWXUserAddress',
  89. method: 'get',
  90. data: {
  91. xu_openid: app.globalData.openid
  92. },
  93. success: function(res) {
  94. that.setData({
  95. addressList: res.data
  96. })
  97. }
  98. })
  99. }
  100. })
  101. },
  102. hrefCreateAddress: function() {
  103. if (this.data.chose == "chose") {
  104. wx.navigateTo({
  105. url: '/pages/mine/myaddress/createaddress/createaddress?type=chose'
  106. });
  107. } else {
  108. wx.navigateTo({
  109. url: '/pages/mine/myaddress/createaddress/createaddress'
  110. });
  111. }
  112. },
  113. hrefCreateedit: function(e) {
  114. wx.navigateTo({
  115. url: '/pages/mine/myaddress/createaddress/createaddress?datatype=update&id=' + e.currentTarget.dataset.id +
  116. '&consignee=' + e.currentTarget.dataset.consignee + '&city=' + e.currentTarget.dataset.city + '&county=' + e.currentTarget
  117. .dataset.county + '&phone=' + e.currentTarget.dataset.phone + '&address=' + e.currentTarget.dataset.address
  118. });
  119. },
  120. hrefCreatedel: function(e) {
  121. var that = this
  122. wx.request({
  123. url: app.globalData.url + '/deleteWXUserDefAddress',
  124. method: 'get',
  125. data: {
  126. id: e.currentTarget.dataset.id
  127. },
  128. success: function(res) {
  129. wx.showToast({
  130. title: '删除成功!',
  131. icon: 'none',
  132. duration: 1000
  133. })
  134. wx.request({
  135. url: app.globalData.url + '/getWXUserAddress',
  136. method: 'get',
  137. data: {
  138. xu_openid: app.globalData.openid
  139. },
  140. success: function(res) {
  141. that.setData({
  142. addressList: res.data
  143. })
  144. },
  145. fail() {
  146. app.timeOut()
  147. }
  148. })
  149. },
  150. fail() {
  151. app.timeOut()
  152. }
  153. })
  154. },
  155. chose: function(e) {
  156. var pages = getCurrentPages();
  157. var currPage = pages[pages.length - 1];
  158. var prevPage = pages[pages.length - 2];
  159. prevPage.setData({
  160. xa_consignee: e.currentTarget.dataset.consignee,
  161. xa_city: e.currentTarget.dataset.city,
  162. xa_county: e.currentTarget.dataset.county,
  163. xa_address: e.currentTarget.dataset.address,
  164. xa_phone: e.currentTarget.dataset.phone,
  165. })
  166. wx.navigateBack({
  167. delta: 1
  168. })
  169. }
  170. })