| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201 |
- // pages/pointRank/pointRank.js
- var BASEURL = require('../../utils/wxconstant.js')
- var baseUrl = BASEURL.BaseUrl()
- var baseutils = require('../../utils/baseUtils.js')
- var netUtil = require('../../utils/network.js')
- var pageSize = 1
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- lastTypeId:'',
- firstType:'请选择标准',
- secondType:'请选择规范',
- pointData:[],
- CotegoryArray: [],
- Cotegory: [],
- CotegoryArray2:[],
- Cotegory2:[]
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- var that = this
- // that.getRankData()
- // return
- that.getCotegory()//获得分类列表
- },
- getCotegory: function () {
- var that = this
- var data = { parentId: 0 }
- var url = baseUrl + BASEURL.getUrl.getCotegory
- netUtil.requestLoading(url, data, '正在加载数据...', 'GET', function (res) {
- if (res.data.success && res.data.data) {
- that.setData({
- Cotegory: res.data.data
- })
- var array = []
- for (var i = 0; i < res.data.data.length; i++) {
- array[i] = res.data.data[i].categoryName
- if (i == res.data.data.length - 1) {
- console.log('array', array)
- that.setData({
- CotegoryArray: array
- })
- }
- }
- }
- }, function (res) {
- wx.showToast({
- title: '加载数据失败',
- icon: 'none',
- duration: 2000
- })
- })
- },
- bindPickerChange: function (e) {
- var that = this
- console.log('picker发送选择改变,携带值为', e.detail)
- var categoryId = that.data.Cotegory[e.detail.value].categoryId
- var categoryName = that.data.Cotegory[e.detail.value].categoryName
- if (categoryName && categoryId) {
- that.setData({
- firstType: categoryName,
- CotegoryArray2: [],
- Cotegory2: [],
- secondType:'请选择规范',
- lastTypeId: categoryId,
- pointData: [],
- })
- that.getSecondType(categoryId)
- that.getRankData(categoryId)
- }
- },
- bindPickerChange2: function (e) {
- var that = this
- console.log('picker发送选择改变,携带值为', e.detail)
- var lastTypeId
- var secondTypeItem
- if (that.data.Cotegory2[e.detail.value].typedata.addnorm){
- secondTypeItem = that.data.Cotegory2[e.detail.value].typedata.addnorm[0]
- } else if (that.data.Cotegory2[e.detail.value].typedata.minus){
- secondTypeItem = that.data.Cotegory2[e.detail.value].typedata.minus[0]
- }else {
- return
- }
- lastTypeId = secondTypeItem.categoryId
- var categoryName = that.data.Cotegory[e.detail.value].categoryName
- if (categoryName && lastTypeId) {
- that.setData({
- lastTypeId: lastTypeId,
- secondType: categoryName,
- pointData: [],
- })
- that.getRankData(lastTypeId)
- }
- },
- getSecondType: function (id){
- var that = this
- var data = { parentId: id }
- var url = baseUrl + BASEURL.getUrl.getNormByCategoryId
- netUtil.requestLoading(url, data, '正在加载数据...', 'GET', function (res) {
- // console.log('res='+JSON.stringify(res))
- if (res.data.success && res.data.data) {
-
- var array = []
- for (var i = 0; i < res.data.data.length; i++) {
- array[i] = res.data.data[i].typeName
- if (i == res.data.data.length - 1) {
- console.log('array', array)
- that.setData({
- CotegoryArray2: array,
- Cotegory2:res.data.data
- })
- }
- }
- }
- }, function (res) {
- wx.showToast({
- title: '加载数据失败',
- icon: 'none',
- duration: 2000
- })
- })
- },
- getRankData:function(id){
- var that = this
- var data = { categoryId: id, pageCount: 20, pageSize: pageSize}
- var url = baseUrl + BASEURL.getUrl.getByNormRank
- netUtil.requestLoading(url, data, '正在加载数据...', 'GET', function (res) {
- if (res.data.success && res.data.data) {
- that.setData({
- pointData: res.data.data
- })
- }
- }, function (res) {
- wx.showToast({
- title: '加载数据失败',
- icon: 'none',
- duration: 2000
- })
- })
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- }
- })
|