index.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. const _Http = getApp().globalData.http;
  2. Page({
  3. data: {
  4. brand: {}, //当前品牌
  5. brandList: [], //品牌列表
  6. typeList: [],
  7. cType: {},
  8. loading: true,
  9. "content": {
  10. "pageNumber": 1,
  11. "pageTotal": 1,
  12. "where": {
  13. "condition": ""
  14. },
  15. sort: []
  16. },
  17. filter: [{
  18. label: "标准",
  19. index: null,
  20. showName: "value", //显示字段
  21. valueKey: "name", //返回Key
  22. selectKey: "value", //传参 代表选着字段 不传参返回整个选择对象
  23. value: "", //选中值
  24. list: []
  25. }]
  26. },
  27. onLoad(options) {
  28. this.getBrand()
  29. this.getNum();
  30. this.getOptionTypeSelect();
  31. },
  32. /* 获取系统分类 */
  33. getOptionTypeSelect() {
  34. _Http.basic({
  35. "classname": "sysmanage.develop.optiontype.optiontype",
  36. "method": "optiontypeselect",
  37. "content": {
  38. "pageNumber": 1,
  39. "pageSize": 999,
  40. "typename": "itemstandards",
  41. "parameter": {
  42. "siteid": wx.getStorageSync('userMsg').siteid
  43. }
  44. }
  45. }, false).then(res => {
  46. console.log("系统标准列表", res)
  47. if (res.msg == '成功') this.setData({
  48. "filter[0].list": res.data
  49. })
  50. })
  51. },
  52. /* 处理筛选 */
  53. handleFilter({detail}){
  54. console.log(detail)
  55. },
  56. /* 切换分类 */
  57. typeChange({
  58. detail
  59. }) {
  60. let typeList = this.data.typeList;
  61. if (typeList.length - 1 != detail.rowIndex) typeList = typeList.slice(0, detail.rowIndex + 1);
  62. typeList[detail.rowIndex].active = detail.index
  63. if (detail.item.subdep.length) typeList.push({
  64. active: -1,
  65. list: detail.item.subdep
  66. })
  67. this.setData({
  68. cType: detail.item,
  69. typeList
  70. });
  71. this.getList(true);
  72. },
  73. /* 获取品牌 */
  74. getBrand() {
  75. _Http.basic({
  76. "id": 20220924163702,
  77. "content": {
  78. "pageSize": 999,
  79. }
  80. }).then(res => {
  81. console.log("查询品牌", res)
  82. if (res.data.length) this.setData({
  83. brandList: res.data,
  84. brand: res.data[0],
  85. });
  86. this.getTypeList();
  87. })
  88. },
  89. /* 获取分类 */
  90. getTypeList() {
  91. _Http.basic({
  92. "id": "20220922110403",
  93. "content": {
  94. "sa_brandid": this.data.brand.sa_brandid
  95. }
  96. }).then(res => {
  97. console.log("营销类别", res)
  98. if (res.data[0].ttemclass) this.setData({
  99. ['typeList[0]']: {
  100. active: 0,
  101. list: res.data[0].ttemclass
  102. },
  103. "cType": res.data[0].ttemclass[0]
  104. });
  105. this.getList(true);
  106. })
  107. },
  108. /* 获取产品 */
  109. getList(init = false) {
  110. if (init.detail != undefined) init = init.detail;
  111. let content = this.data.content;
  112. if (init) content.pageNumber = 1;
  113. if (content.pageNumber > content.pageTotal) return;
  114. content.brandids = [this.data.brand.sa_brandid];
  115. content.where.itemclassid = this.data.cType.itemclassid;
  116. _Http.basic({
  117. "id": 20220926142203,
  118. content
  119. }).then(res => {
  120. console.log("商品列表", res)
  121. this.selectComponent('#ListBox').RefreshToComplete();
  122. this.setData({
  123. list: res.data,
  124. "content.pageNumber": res.pageNumber + 1,
  125. "content.pageTotal": res.pageTotal,
  126. "content.sort": res.sort,
  127. loading: false
  128. })
  129. this.setListHeight()
  130. })
  131. },
  132. startFiltration() {
  133. /* _Http.basic().then(res => {
  134. console.log("获取领域", res)
  135. }) */
  136. },
  137. /* 搜索 */
  138. onSearch({
  139. detail
  140. }) {
  141. this.setData({
  142. "content.where.condition": detail
  143. });
  144. this.getList(true)
  145. },
  146. onReady() {
  147. this.setListHeight()
  148. },
  149. /* 设置页面高度 */
  150. setListHeight() {
  151. this.selectComponent("#ListBox").setHeight(".division", this);
  152. },
  153. /* 获取购物车数量 */
  154. getNum() {
  155. _Http.basic({
  156. "id": 20220927093202,
  157. "content": {}
  158. }).then(res => {
  159. console.log("购物车数量", res)
  160. getApp().globalData.num = res.data.num;
  161. this.selectComponent("#Float").setNum(res.data.num)
  162. });
  163. },
  164. onShow() {
  165. if (getApp().globalData.num) this.selectComponent("#Float").setNum(getApp().globalData.num)
  166. }
  167. })