growthMore.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. // import course from "../../../../../pages/data/course.js"
  2. var app=getApp();
  3. var util = require("../../../../../utils/util.js")
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. value: [],
  10. totalCount: 0,
  11. totalPage: 0,
  12. nodata: util.nodata(),
  13. scrollTop: 0,
  14. scrollHeight: 0,
  15. imgbg:'',
  16. parm: {
  17. page:'1',
  18. limit:'10',
  19. city: null,
  20. category: null,
  21. name:null,
  22. totalCount:0,
  23. price:'',
  24. },
  25. index: 0,
  26. produindex: 0,
  27. produindexone:0,
  28. array: [{ itemcode: '', itemname: '全部分类' }],
  29. arraylist: [{ id: '', name: '全部' }, { id: '2', name: '价格最高' },{ id: '1', name: '价格最低' }],
  30. },
  31. /**
  32. * 生命周期函数--监听页面加载
  33. */
  34. onLoad: function (options) {
  35. wx.setNavigationBarTitle({ title: '在线课堂' });
  36. let _this = this;
  37. _this.loadDatas();
  38. _this.loadData();
  39. _this.loadDic();
  40. },
  41. //分类
  42. bindPickerChanger: function (e) {
  43. this.data.value = [];
  44. this.setData({
  45. 'parm.page':1,
  46. produindexone: parseInt(e.detail.value)
  47. })
  48. let code = this.data.array[parseInt(e.detail.value)].itemcode
  49. if (code) {
  50. this.data.parm.category = code + "";
  51. } else {
  52. this.data.parm.category = null;
  53. }
  54. this.loadData();
  55. },
  56. //价格
  57. bindPicker: function (e) {
  58. console.log(e)
  59. this.setData({
  60. index: e.detail.value
  61. })
  62. this.data.value = [];
  63. this.setData({
  64. 'parm.page':1,
  65. produindex: parseInt(e.detail.value)
  66. })
  67. if (this.data.arraylist[parseInt(e.detail.value)].id) {
  68. this.data.parm.price = this.data.arraylist[parseInt(e.detail.value)].id
  69. } else {
  70. this.data.parm.price = null;
  71. }
  72. this.loadData();
  73. },
  74. scroll: function (event) {
  75. //该方法绑定了页面滚动时的事件,我这里记录了当前的position.y的值,为了请求数据之后把页面定位到这里来。
  76. let _this = this;
  77. _this.setData({
  78. scrollTop: event.detail.scrollTop
  79. });
  80. },
  81. seeDetails: function (e) {
  82. console.log(e)
  83. if (e.currentTarget.dataset.id) {
  84. wx.navigateTo({
  85. // ../../../index/courseDetail/courseDetail
  86. url: '../../courseDetail/courseDetail?id=' + e.currentTarget.dataset.id,
  87. })
  88. }
  89. },
  90. loadDatas:function(){
  91. wx.showLoading({
  92. title: '努力加载中...',
  93. })
  94. let _this = this;
  95. var data = {
  96. cityEnjoyCategory:'03'
  97. }
  98. app._post_form('/bizcatelog/apiSelectBizcatelog/cityEnjoyCategory', "application/json", JSON.stringify(data),function(res){
  99. if(res.code == 0){
  100. res.dictList.map((item) => {
  101. if(item.itemcode == '03'){
  102. _this.setData({
  103. imgbg:item.attribute3
  104. })
  105. }
  106. })
  107. }
  108. })
  109. },
  110. loadData:function(){
  111. wx.showLoading({
  112. title: '努力加载中...',
  113. })
  114. let _this = this;
  115. _this.data.parm.page = _this.data.parm.page + "";
  116. app._post_form('cou/list', "application/json", JSON.stringify(_this.data.parm),function(res){
  117. console.log(res)
  118. // _this.setData(res.data);
  119. if (res.code === 0) {
  120. _this.data.totalPage = res.data.totalPage;
  121. let d = _this.data.value;
  122. if (res.data.list.length) {
  123. d.push(...res.data.list);
  124. } else {
  125. d = [];
  126. }
  127. _this.setData({
  128. list: d,
  129. totalPage: res.data.totalPage,
  130. totalCount: res.data.totalCount,
  131. currPage: res.data.currPage
  132. })
  133. wx.hideLoading();
  134. }
  135. })
  136. },
  137. loadDic:function(){
  138. let _this = this;
  139. app._post_form('bizcatelog/apiSelectBizcatelog/courseCategory', '', null, function (res) {
  140. console.log(res)
  141. if (res.code === 0) {
  142. _this.data.array.push(...res.dictList);
  143. _this.setData({
  144. array: _this.data.array
  145. })
  146. }
  147. })
  148. },
  149. /**
  150. * 生命周期函数--监听页面初次渲染完成
  151. */
  152. onReady: function () {
  153. },
  154. /**
  155. * 生命周期函数--监听页面显示
  156. */
  157. onShow: function () {
  158. },
  159. /**
  160. * 生命周期函数--监听页面隐藏
  161. */
  162. onHide: function () {
  163. },
  164. /**
  165. * 生命周期函数--监听页面卸载
  166. */
  167. onUnload: function () {
  168. },
  169. /**
  170. * 页面相关事件处理函数--监听用户下拉动作
  171. */
  172. onPullDownRefresh: function () {
  173. },
  174. /**
  175. * 页面上拉触底事件的处理函数
  176. */
  177. onReachBottom: function () {
  178. if (this.data.parm.page < this.data.totalPage) {
  179. this.data.parm.page++;
  180. this.loadData();
  181. }
  182. },
  183. /**
  184. * 用户点击右上角分享
  185. */
  186. onShareAppMessage: function () {
  187. }
  188. })