index.js 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  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. }
  66. }
  67. }).then(res => {
  68. console.log("营销类别", res)
  69. if (res.data.length) {
  70. res.data[0].ttemclass.unshift({
  71. itemclassid: "",
  72. itemclassfullname: "全部",
  73. itemclassname: "全部",
  74. subdep: []
  75. })
  76. this.setData({
  77. itemClasss: [res.data[0].ttemclass]
  78. });
  79. }
  80. this.getList(true);
  81. })
  82. },
  83. itemClasssChange(e) {
  84. let detail = e.detail;
  85. content.where.itemclassid = detail.item.itemclassid;
  86. let itemClasss = this.data.itemClasss,
  87. subdep = detail.item.subdep;
  88. itemClasss = itemClasss.slice(0, detail.rowIndex + 1);
  89. if (subdep.length) {
  90. subdep.unshift({
  91. itemclassid: detail.item.itemclassid,
  92. itemclassfullname: "全部",
  93. itemclassname: "全部",
  94. subdep: []
  95. })
  96. itemClasss.push(subdep)
  97. this.selectAllComponents('#class' + (detail.rowIndex - 0 + 1)).filter(v => v.setData({
  98. active: 0
  99. }))
  100. }
  101. this.setData({
  102. itemClasss
  103. })
  104. this.selectAllComponents('#' + e.target.id).filter(v => {
  105. v.setData({
  106. active: detail.index
  107. })
  108. })
  109. this.getList(true);
  110. },
  111. /* 获取产品 */
  112. getList(init = false) {
  113. if (init.detail != undefined) init = init.detail;
  114. if (init) content.pageNumber = 1;
  115. if (content.pageNumber > content.pageTotal) return;
  116. content.brandids = [sa_brandid];
  117. _Http.basic({
  118. "id": 20220926142203,
  119. content
  120. }).then(res => {
  121. console.log("商品列表", res)
  122. if (res.msg != '成功') return wx.showToast({
  123. title: res.msg,
  124. icon: "none"
  125. })
  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 == '成功' && res.data.length > 1) {
  157. res.data.unshift({
  158. rowindex: 0,
  159. subvalues: [],
  160. sys_enterprise_tradefieldid: 0,
  161. tradefield: "全部"
  162. })
  163. this.setData({
  164. tradefieList: res.data
  165. });
  166. }
  167. })
  168. },
  169. /* 设置页面高度 */
  170. setListHeight() {
  171. this.selectComponent("#ListBox").setHeight(".division", this);
  172. },
  173. tradefieChange({
  174. detail
  175. }) {
  176. content.where.tradefield = detail.item.tradefield == '全部' ? '' : detail.item.tradefield
  177. this.getList(true);
  178. this.selectAllComponents('#tradefieList').filter(v => {
  179. v.setData({
  180. active: detail.index
  181. })
  182. })
  183. },
  184. openPopup() {
  185. this.setData({
  186. popupShow: true
  187. })
  188. },
  189. onClose() {
  190. this.setData({
  191. popupShow: false
  192. })
  193. }
  194. }
  195. })