index.js 4.7 KB

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