index.js 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  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. if (res.msg != '成功') return wx.showToast({
  130. title: res.msg,
  131. icon: "none"
  132. })
  133. this.selectComponent('#ListBox').RefreshToComplete();
  134. content.pageNumber = res.pageNumber + 1;
  135. content.pageTotal = res.pageTotal;
  136. this.setData({
  137. list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data)
  138. })
  139. this.setListHeight()
  140. })
  141. },
  142. /* 开始搜索 */
  143. onSearch({
  144. detail
  145. }) {
  146. content.where.condition = detail;
  147. this.getList(true)
  148. },
  149. /* 获取领域 */
  150. getTradefie() {
  151. _Http.basic({
  152. "id": 20221223141802,
  153. content: {
  154. nocache: true,
  155. pageNumber: 1,
  156. pageSize: 9999,
  157. where: {
  158. condition: ""
  159. }
  160. }
  161. }, false).then(res => {
  162. console.log("获取领域", res)
  163. if (res.msg == '成功') {
  164. res.data.unshift({
  165. rowindex: 0,
  166. subvalues: [],
  167. sys_enterprise_tradefieldid: 0,
  168. tradefield: "全部"
  169. })
  170. this.setData({
  171. 'filtratelist[0].list': res.data
  172. });
  173. }
  174. })
  175. },
  176. /* 设置页面高度 */
  177. setListHeight() {
  178. this.selectComponent("#ListBox").setHeight(".division", this);
  179. },
  180. handleFiltrate({
  181. detail
  182. }) {
  183. clearTimeout(downCount);
  184. if (detail.tradefield) content.where.tradefield = detail.tradefield == '全部' ? "" : detail.tradefield;
  185. content.where.itemclassid = detail.temporaryId || detail.temporaryId == '' ? detail.temporaryId : content.where.itemclassid;
  186. downCount = setTimeout(() => {
  187. this.getList(true);
  188. }, 300);
  189. }
  190. }
  191. })