index.js 3.8 KB

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