index.js 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. import {
  2. ApiModel
  3. } from "../../utils/api";
  4. const _Http = new ApiModel();
  5. Component({
  6. /**
  7. * 组件的属性列表
  8. */
  9. properties: {
  10. fisadministrator: {
  11. type: Number
  12. }
  13. },
  14. /**
  15. * 组件的初始数据
  16. */
  17. data: {
  18. productList: [], //产品列表
  19. tabsActive: 0, //tabs 下标
  20. pageNumber: 1, //获取页码
  21. },
  22. pageLifetimes: {
  23. show: function () {
  24. // 页面被展示
  25. this.tabsChange({
  26. detail: {
  27. index: this.data.tabsActive
  28. }
  29. })
  30. },
  31. },
  32. /**
  33. * 组件的方法列表
  34. */
  35. methods: {
  36. //tabs切换
  37. tabsChange(e) {
  38. console.log(e)
  39. this.setData({
  40. tabsActive: e.detail.index,
  41. pageNumber: 1
  42. })
  43. if (e.detail.index == 0) {
  44. console.log("全部")
  45. this.queryProduct()
  46. } else if (e.detail.index == 1) {
  47. console.log("上架中")
  48. this.queryProduct({
  49. "fisonsale": 1
  50. })
  51. } else if (e.detail.index == 2) {
  52. console.log("已下架")
  53. this.queryProduct({
  54. "fisonsale": 0
  55. })
  56. }
  57. },
  58. //搜索
  59. searchChange(e) {
  60. let text = e.detail.trim();
  61. console.log(text)
  62. },
  63. //查询商品
  64. queryProduct(where) {
  65. _Http.basic({
  66. "accesstoken": wx.getStorageSync('token'),
  67. "classname": "customer.products.products",
  68. "method": "query_productsList",
  69. "content": {
  70. "getdatafromdbanyway": true,
  71. "pageNumber": this.data.pageNumber,
  72. "pageSize": 20,
  73. "where": where
  74. }
  75. }).then(s => {
  76. console.log(s)
  77. if (s.msg != "成功") return;
  78. //返回列表,页码加1
  79. this.setData({
  80. productList: s.data,
  81. pageNumber: this.data.pageNumber + 1
  82. })
  83. })
  84. },
  85. //新增或修改
  86. newAdd() {
  87. wx.navigateTo({
  88. url: '/pages/group&product/change?type=product',
  89. })
  90. }
  91. }
  92. })