index.js 4.7 KB

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