index.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. const content = {
  2. pageNumber: 1,
  3. pageTotal: 1,
  4. where: {
  5. condition: "",
  6. itemclassid: "",
  7. tradefield: ""
  8. }
  9. },
  10. _Http = getApp().globalData.http;
  11. let sa_brandid = null,
  12. downCount = null;
  13. Component({
  14. options: {
  15. addGlobalClass: true
  16. },
  17. data: {
  18. CustomBar: getApp().globalData.CustomBar,
  19. typeList: [],
  20. filtratelist: [{
  21. label: "领域",
  22. index: 0,
  23. showName: "tradefield", //显示字段
  24. valueKey: "tradefield", //返回Key
  25. selectKey: "tradefield", //传参 代表选着字段 不传参返回整个选择对象
  26. value: "", //选中值
  27. list: [{
  28. rowindex: 0,
  29. subvalues: [],
  30. sys_enterprise_tradefieldid: 0,
  31. tradefield: "全部"
  32. }]
  33. }, {
  34. label: "营销分类",
  35. index: 0,
  36. type: "multilevelClass",
  37. showName: "itemclassname", //显示字段
  38. valueKey: "itemclassid", //返回Key
  39. selectKey: "itemclassid", //传参 代表选着字段 不传参返回整个选择对象
  40. value: "", //选中值
  41. list: []
  42. }]
  43. },
  44. methods: {
  45. init() {
  46. this.getBrand();
  47. this.getTradefie();
  48. return true;
  49. },
  50. showModal(e) {
  51. this.setData({
  52. modalName: e.currentTarget.dataset.target
  53. })
  54. },
  55. hideModal(e) {
  56. this.setData({
  57. modalName: null
  58. })
  59. },
  60. /* 获取品牌 */
  61. getBrand() {
  62. getApp().globalData.setTemporaryId = this.handleFiltrate.bind(this);
  63. _Http.basic({
  64. "id": 20220924163702,
  65. content: {
  66. nocache: true,
  67. pageSize: 999,
  68. }
  69. }).then(res => {
  70. console.log("查询品牌", res)
  71. if (res.msg != '成功') return wx.showToast({
  72. title: res.msg,
  73. icon: "none"
  74. });
  75. if (res.data.length != 0) {
  76. sa_brandid = res.data[0].sa_brandid;
  77. this.getTypeList();
  78. } else {
  79. wx.showToast({
  80. title: '未查询到授权品牌',
  81. icon: "none"
  82. })
  83. }
  84. })
  85. },
  86. /* 获取分类 */
  87. getTypeList() {
  88. _Http.basic({
  89. "id": "20220922110403",
  90. pageSize: 1000,
  91. content: {
  92. nocache: true,
  93. sa_brandid: sa_brandid,
  94. where: {
  95. istool: 0,
  96. }
  97. }
  98. }).then(res => {
  99. console.log("营销类别", res)
  100. if (res.data[0].ttemclass) {
  101. res.data[0].ttemclass.unshift({
  102. itemclassid: "",
  103. itemclassfullname: "全部",
  104. itemclassname: "全部",
  105. subdep: []
  106. })
  107. this.setData({
  108. ['filtratelist[1].list']: res.data[0].ttemclass
  109. });
  110. }
  111. this.getList(true);
  112. })
  113. },
  114. /* 获取产品 */
  115. getList(init = false) {
  116. if (init.detail != undefined) init = init.detail;
  117. if (init) content.pageNumber = 1;
  118. if (content.pageNumber > content.pageTotal) return;
  119. content.brandids = [sa_brandid];
  120. _Http.basic({
  121. "id": 20220926142203,
  122. content
  123. }).then(res => {
  124. console.log("商品列表", res)
  125. this.selectComponent('#ListBox').RefreshToComplete();
  126. content.pageNumber = res.pageNumber + 1;
  127. content.pageTotal = res.pageTotal;
  128. this.setData({
  129. list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data)
  130. })
  131. this.setListHeight()
  132. })
  133. },
  134. /* 开始搜索 */
  135. onSearch({
  136. detail
  137. }) {
  138. content.where.condition = detail;
  139. this.getList(true)
  140. },
  141. /* 获取领域 */
  142. getTradefie() {
  143. _Http.basic({
  144. "id": 20221223141802,
  145. content: {
  146. nocache: true,
  147. pageNumber: 1,
  148. pageSize: 9999,
  149. where: {
  150. condition: ""
  151. }
  152. }
  153. }, false).then(res => {
  154. console.log("获取领域", res)
  155. if (res.msg == '成功') {
  156. res.data.unshift({
  157. rowindex: 0,
  158. subvalues: [],
  159. sys_enterprise_tradefieldid: 0,
  160. tradefield: "全部"
  161. })
  162. this.setData({
  163. 'filtratelist[0].list': res.data
  164. });
  165. }
  166. })
  167. },
  168. /* 设置页面高度 */
  169. setListHeight() {
  170. this.selectComponent("#ListBox").setHeight(".division", this);
  171. },
  172. handleFiltrate({
  173. detail
  174. }) {
  175. clearTimeout(downCount);
  176. if (detail.tradefield) content.where.tradefield = detail.tradefield == '全部' ? "" : detail.tradefield;
  177. content.where.itemclassid = detail.temporaryId || detail.temporaryId == '' ? detail.temporaryId : content.where.itemclassid;
  178. downCount = setTimeout(() => {
  179. this.getList(true);
  180. }, 300);
  181. }
  182. }
  183. })