index.js 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. const content = {
  2. pageNumber: 1,
  3. pageTotal: 1
  4. },
  5. _Http = getApp().globalData.http;
  6. let sa_brandid = null,
  7. downCount = null;
  8. Component({
  9. options: {
  10. addGlobalClass: true
  11. },
  12. data: {
  13. CustomBar: getApp().globalData.CustomBar,
  14. typeList: [],
  15. list: [],
  16. filtratelist: [],
  17. popupShow: false
  18. },
  19. methods: {
  20. init() {
  21. content.where = {
  22. condition: "",
  23. itemclassid: "",
  24. tradefield: ""
  25. }
  26. this.getBrand();
  27. this.getTradefie();
  28. return true;
  29. },
  30. /* 获取品牌 */
  31. getBrand() {
  32. _Http.basic({
  33. "id": 20220924163702,
  34. content: {
  35. nocache: true,
  36. pageSize: 999,
  37. }
  38. }).then(res => {
  39. console.log("查询品牌", res)
  40. if (res.msg != '成功') return wx.showToast({
  41. title: res.msg,
  42. icon: "none"
  43. });
  44. if (res.data.length != 0) {
  45. sa_brandid = res.data[0].sa_brandid;
  46. this.getTypeList();
  47. } else {
  48. wx.showToast({
  49. title: '未查询到授权品牌',
  50. icon: "none"
  51. })
  52. }
  53. })
  54. },
  55. /* 获取分类 */
  56. getTypeList() {
  57. _Http.basic({
  58. "id": "20220922110403",
  59. pageSize: 1000,
  60. content: {
  61. nocache: true,
  62. sa_brandid: sa_brandid,
  63. where: {
  64. istool: 0,
  65. ishide: 0
  66. }
  67. }
  68. }).then(res => {
  69. console.log("营销类别", res)
  70. if (res.data.length) {
  71. res.data[0].ttemclass.unshift({
  72. itemclassid: "",
  73. itemclassfullname: "全部",
  74. itemclassname: "全部",
  75. subdep: []
  76. })
  77. this.setData({
  78. itemClasss: [res.data[0].ttemclass]
  79. });
  80. try {
  81. this.selectAllComponents('#class0').filter(v => {
  82. v.setData({
  83. active: 0
  84. })
  85. })
  86. } catch {}
  87. }
  88. this.getList(true);
  89. })
  90. },
  91. itemClasssChange(e) {
  92. let detail = e.detail;
  93. content.where.itemclassid = detail.item.itemclassid;
  94. let itemClasss = this.data.itemClasss,
  95. subdep = detail.item.subdep;
  96. itemClasss = itemClasss.slice(0, detail.rowIndex + 1);
  97. /* if (subdep.length) {
  98. subdep.unshift({
  99. itemclassid: detail.item.itemclassid,
  100. itemclassfullname: "全部",
  101. itemclassname: "全部",
  102. subdep: []
  103. })
  104. itemClasss.push(subdep)
  105. this.selectAllComponents('#class' + (detail.rowIndex - 0 + 1)).filter(v => v.setData({
  106. active: 0
  107. }))
  108. } */
  109. this.setData({
  110. itemClasss
  111. })
  112. itemClasss.push(subdep)
  113. this.setData({
  114. itemClasss
  115. })
  116. this.getList(true);
  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 == '成功' && res.data.length > 1) {
  164. res.data.unshift({
  165. rowindex: 0,
  166. subvalues: [],
  167. sys_enterprise_tradefieldid: 0,
  168. tradefield: "全部"
  169. })
  170. this.setData({
  171. tradefieList: res.data
  172. });
  173. }
  174. })
  175. },
  176. /* 设置页面高度 */
  177. setListHeight() {
  178. this.selectComponent("#ListBox").setHeight(".division", this);
  179. },
  180. tradefieChange({
  181. detail
  182. }) {
  183. content.where.tradefield = detail.item.tradefield == '全部' ? '' : detail.item.tradefield
  184. this.getList(true);
  185. this.selectAllComponents('#tradefieList').filter(v => {
  186. v.setData({
  187. active: detail.index
  188. })
  189. })
  190. },
  191. openPopup() {
  192. this.setData({
  193. popupShow: true
  194. })
  195. },
  196. onClose() {
  197. this.setData({
  198. popupShow: false
  199. })
  200. }
  201. }
  202. })