pointRank.js 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. // pages/pointRank/pointRank.js
  2. var BASEURL = require('../../utils/wxconstant.js')
  3. var baseUrl = BASEURL.BaseUrl()
  4. var baseutils = require('../../utils/baseUtils.js')
  5. var netUtil = require('../../utils/network.js')
  6. var pageSize = 1
  7. Page({
  8. /**
  9. * 页面的初始数据
  10. */
  11. data: {
  12. lastTypeId:'',
  13. firstType:'请选择标准',
  14. secondType:'请选择规范',
  15. pointData:[],
  16. CotegoryArray: [],
  17. Cotegory: [],
  18. CotegoryArray2:[],
  19. Cotegory2:[]
  20. },
  21. /**
  22. * 生命周期函数--监听页面加载
  23. */
  24. onLoad: function (options) {
  25. var that = this
  26. // that.getRankData()
  27. // return
  28. that.getCotegory()//获得分类列表
  29. },
  30. getCotegory: function () {
  31. var that = this
  32. var data = { parentId: 0 }
  33. var url = baseUrl + BASEURL.getUrl.getCotegory
  34. netUtil.requestLoading(url, data, '正在加载数据...', 'GET', function (res) {
  35. if (res.data.success && res.data.data) {
  36. that.setData({
  37. Cotegory: res.data.data
  38. })
  39. var array = []
  40. for (var i = 0; i < res.data.data.length; i++) {
  41. array[i] = res.data.data[i].categoryName
  42. if (i == res.data.data.length - 1) {
  43. console.log('array', array)
  44. that.setData({
  45. CotegoryArray: array
  46. })
  47. }
  48. }
  49. }
  50. }, function (res) {
  51. wx.showToast({
  52. title: '加载数据失败',
  53. icon: 'none',
  54. duration: 2000
  55. })
  56. })
  57. },
  58. bindPickerChange: function (e) {
  59. var that = this
  60. console.log('picker发送选择改变,携带值为', e.detail)
  61. var categoryId = that.data.Cotegory[e.detail.value].categoryId
  62. var categoryName = that.data.Cotegory[e.detail.value].categoryName
  63. if (categoryName && categoryId) {
  64. that.setData({
  65. firstType: categoryName,
  66. CotegoryArray2: [],
  67. Cotegory2: [],
  68. secondType:'请选择规范',
  69. lastTypeId: categoryId,
  70. pointData: [],
  71. })
  72. that.getSecondType(categoryId)
  73. that.getRankData(categoryId)
  74. }
  75. },
  76. bindPickerChange2: function (e) {
  77. var that = this
  78. console.log('picker发送选择改变,携带值为', e.detail)
  79. var lastTypeId
  80. var secondTypeItem
  81. if (that.data.Cotegory2[e.detail.value].typedata.addnorm){
  82. secondTypeItem = that.data.Cotegory2[e.detail.value].typedata.addnorm[0]
  83. } else if (that.data.Cotegory2[e.detail.value].typedata.minus){
  84. secondTypeItem = that.data.Cotegory2[e.detail.value].typedata.minus[0]
  85. }else {
  86. return
  87. }
  88. lastTypeId = secondTypeItem.categoryId
  89. var categoryName = that.data.Cotegory[e.detail.value].categoryName
  90. if (categoryName && lastTypeId) {
  91. that.setData({
  92. lastTypeId: lastTypeId,
  93. secondType: categoryName,
  94. pointData: [],
  95. })
  96. that.getRankData(lastTypeId)
  97. }
  98. },
  99. getSecondType: function (id){
  100. var that = this
  101. var data = { parentId: id }
  102. var url = baseUrl + BASEURL.getUrl.getNormByCategoryId
  103. netUtil.requestLoading(url, data, '正在加载数据...', 'GET', function (res) {
  104. // console.log('res='+JSON.stringify(res))
  105. if (res.data.success && res.data.data) {
  106. var array = []
  107. for (var i = 0; i < res.data.data.length; i++) {
  108. array[i] = res.data.data[i].typeName
  109. if (i == res.data.data.length - 1) {
  110. console.log('array', array)
  111. that.setData({
  112. CotegoryArray2: array,
  113. Cotegory2:res.data.data
  114. })
  115. }
  116. }
  117. }
  118. }, function (res) {
  119. wx.showToast({
  120. title: '加载数据失败',
  121. icon: 'none',
  122. duration: 2000
  123. })
  124. })
  125. },
  126. getRankData:function(id){
  127. var that = this
  128. var data = { categoryId: id, pageCount: 20, pageSize: pageSize}
  129. var url = baseUrl + BASEURL.getUrl.getByNormRank
  130. netUtil.requestLoading(url, data, '正在加载数据...', 'GET', function (res) {
  131. if (res.data.success && res.data.data) {
  132. that.setData({
  133. pointData: res.data.data
  134. })
  135. }
  136. }, function (res) {
  137. wx.showToast({
  138. title: '加载数据失败',
  139. icon: 'none',
  140. duration: 2000
  141. })
  142. })
  143. },
  144. /**
  145. * 生命周期函数--监听页面初次渲染完成
  146. */
  147. onReady: function () {
  148. },
  149. /**
  150. * 生命周期函数--监听页面显示
  151. */
  152. onShow: function () {
  153. },
  154. /**
  155. * 生命周期函数--监听页面隐藏
  156. */
  157. onHide: function () {
  158. },
  159. /**
  160. * 生命周期函数--监听页面卸载
  161. */
  162. onUnload: function () {
  163. },
  164. /**
  165. * 页面相关事件处理函数--监听用户下拉动作
  166. */
  167. onPullDownRefresh: function () {
  168. },
  169. /**
  170. * 页面上拉触底事件的处理函数
  171. */
  172. onReachBottom: function () {
  173. },
  174. /**
  175. * 用户点击右上角分享
  176. */
  177. onShareAppMessage: function () {
  178. }
  179. })