all.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. // pages/Mall/sortCommodity/sortCommodity.js
  2. // 获取应用实例
  3. const {API} = require('../../service/api.js');
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. ipInfoList:[
  10. {ipName:'全部',ipId:''}
  11. ],
  12. filterIndex1:-1,
  13. filterIndex2:-1,
  14. filterObj:{}, //筛选条件
  15. showAddCartModal:false,
  16. currentProduct:null
  17. },
  18. // 监听筛选
  19. selectFilter(e){
  20. let {index,index2,item} = e.currentTarget.dataset;
  21. let filterObj = this.data.filterObj;
  22. if(index === 0) filterObj.ipId = item.ipId;
  23. if(index === 1) filterObj.prodClassId = item.prodClassId;
  24. filterObj.pageNum = 1;
  25. this.setData({
  26. [index === 0?'filterIndex1':'filterIndex2']:index2,
  27. filterObj
  28. })
  29. },
  30. // 获取IP分类
  31. getIpList(){
  32. API.getIpInfos().then(res=>{
  33. if(res){
  34. res.ipInfoList.push({ipName:"全部",ipId:''})
  35. this.setData({
  36. ipInfoList:res.ipInfoList
  37. })
  38. };
  39. })
  40. },
  41. // 获取商品分类
  42. getProdClasses(){
  43. API.getProdClasses().then(res=>{
  44. if(res){
  45. res.prodClassList.push({className:"全部",prodClassId:''})
  46. this.setData({
  47. prodClassList:res.prodClassList
  48. })
  49. };
  50. })
  51. },
  52. // 显示商品属性模态框
  53. showAddCartModal(e) {
  54. const product = e.detail;
  55. this.setData({
  56. showAddCartModal: true,
  57. currentProduct:product
  58. });
  59. },
  60. // 关闭属性选择模态框
  61. handleCloseAddCartModal(){
  62. this.setData({
  63. showAddCartModal:false
  64. })
  65. },
  66. /**
  67. * 生命周期函数--监听页面加载
  68. */
  69. onLoad(options) {
  70. this.getProdClasses();
  71. this.getIpList();
  72. },
  73. /**
  74. * 生命周期函数--监听页面初次渲染完成
  75. */
  76. onReady() {
  77. },
  78. /**
  79. * 生命周期函数--监听页面显示
  80. */
  81. onShow(options) {
  82. },
  83. /**
  84. * 生命周期函数--监听页面隐藏
  85. */
  86. onHide() {
  87. },
  88. /**
  89. * 生命周期函数--监听页面卸载
  90. */
  91. onUnload() {
  92. },
  93. /**
  94. * 页面相关事件处理函数--监听用户下拉动作
  95. */
  96. onPullDownRefresh() {
  97. },
  98. /**
  99. * 页面上拉触底事件的处理函数
  100. */
  101. onReachBottom() {
  102. },
  103. /**
  104. * 用户点击右上角分享
  105. */
  106. onShareAppMessage() {
  107. }
  108. })