index.js 4.8 KB

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