choiseAddress.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. // pages/order/custommanage/custommanage.js
  2. let util = require('../../../utils/util.js');
  3. let pyutil = require('../../../utils/pinyin.js');
  4. var that
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. customs: [],
  11. jumpNum: '',
  12. tel: ''
  13. },
  14. settel(e) {
  15. this.setData({
  16. tel: e.detail.value
  17. })
  18. },
  19. select(e) {
  20. var u = e.currentTarget.dataset
  21. let pages = getCurrentPages()
  22. let prevPage = pages[pages.length - 2]
  23. prevPage.setData({
  24. addressname: u.name,
  25. customerid: u.cuid,
  26. customeronlyid: u.cuonlyid,
  27. addressid: u.id,
  28. addressonlyid: u.onlyid
  29. })
  30. prevPage.updatelast(u.cuid)
  31. wx.navigateBack({
  32. delta: 1
  33. })
  34. },
  35. todetail(e) {
  36. wx.navigateTo({
  37. url: '/pages/order/customdetail/customdetail?id=' + e.currentTarget.dataset.id,
  38. })
  39. },
  40. toadd() {
  41. wx.navigateTo({
  42. url: '/pages/order/addcustom/addcustom',
  43. })
  44. },
  45. /**
  46. * 生命周期函数--监听页面加载
  47. */
  48. onLoad: function(options) {
  49. that = this
  50. //pyutil.getPinYinFirstCharacter('?吧#:&')
  51. this.getAllCustom()
  52. },
  53. getAllCustom() {
  54. util.query('customeraddress/wxapi/listpage', {
  55. pageNo: 1,
  56. pageSize: 9999,
  57. name: this.data.tel
  58. }, function(res) {
  59. if (res.code === 10000) {
  60. var da = res.data.content
  61. var pys = []
  62. for (var i in da) {
  63. var py = pyutil.getPinYinFirstCharacter(da[i].name).toUpperCase().substr(0, 1)
  64. py = util.checkABC(py) ? py : '其他'
  65. var isfind = false
  66. for (var j in pys) {
  67. if (pys[j].py === py) {
  68. isfind = true
  69. pys[j].data.push(da[i])
  70. }
  71. }
  72. if (!isfind) {
  73. pys.push({
  74. py: py,
  75. data: [da[i]]
  76. })
  77. }
  78. }
  79. // pys = Object.keys(pys).sort(function(a, b) {
  80. // return pys[b].py - pys[a].py;
  81. // });
  82. // var sorted_keys_array = Object.keys(pys).sort((a, b) => {
  83. // return datas[b].py - datas[a].py;
  84. // });
  85. pys = pys.sort(function(a, b) {
  86. return a.py.charCodeAt() - b.py.charCodeAt()
  87. })
  88. that.setData({
  89. customs: pys
  90. })
  91. } else {
  92. that.setData({
  93. customs: []
  94. })
  95. }
  96. })
  97. },
  98. setjumpNum(e) {
  99. this.setData({
  100. jumpNum: e.currentTarget.dataset.index
  101. })
  102. },
  103. /**
  104. * 生命周期函数--监听页面初次渲染完成
  105. */
  106. onReady: function() {
  107. },
  108. /**
  109. * 生命周期函数--监听页面显示
  110. */
  111. onShow: function() {
  112. },
  113. /**
  114. * 生命周期函数--监听页面隐藏
  115. */
  116. onHide: function() {
  117. },
  118. /**
  119. * 生命周期函数--监听页面卸载
  120. */
  121. onUnload: function() {
  122. },
  123. /**
  124. * 页面相关事件处理函数--监听用户下拉动作
  125. */
  126. onPullDownRefresh: function() {
  127. },
  128. /**
  129. * 页面上拉触底事件的处理函数
  130. */
  131. onReachBottom: function() {
  132. },
  133. /**
  134. * 用户点击右上角分享
  135. */
  136. onShareAppMessage: function() {
  137. }
  138. })