index.js 4.7 KB

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