123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205 |
- // import course from "../../../../../pages/data/course.js"
- var app=getApp();
- var util = require("../../../../../utils/util.js")
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- value: [],
- totalCount: 0,
- totalPage: 0,
- nodata: util.nodata(),
- scrollTop: 0,
- scrollHeight: 0,
- imgbg:'',
- parm: {
- page:'1',
- limit:'10',
- city: null,
- category: null,
- name:null,
- totalCount:0,
- price:'',
- },
- index: 0,
- produindex: 0,
- produindexone:0,
- array: [{ itemcode: '', itemname: '全部分类' }],
- arraylist: [{ id: '', name: '全部' }, { id: '2', name: '价格最高' },{ id: '1', name: '价格最低' }],
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- wx.setNavigationBarTitle({ title: '在线课堂' });
- let _this = this;
- _this.loadDatas();
- _this.loadData();
- _this.loadDic();
- },
- //分类
- bindPickerChanger: function (e) {
- this.data.value = [];
- this.setData({
- 'parm.page':1,
- produindexone: parseInt(e.detail.value)
- })
- let code = this.data.array[parseInt(e.detail.value)].itemcode
- if (code) {
- this.data.parm.category = code + "";
- } else {
- this.data.parm.category = null;
- }
- this.loadData();
- },
- //价格
- bindPicker: function (e) {
- console.log(e)
- this.setData({
- index: e.detail.value
- })
- this.data.value = [];
- this.setData({
- 'parm.page':1,
- produindex: parseInt(e.detail.value)
- })
- if (this.data.arraylist[parseInt(e.detail.value)].id) {
- this.data.parm.price = this.data.arraylist[parseInt(e.detail.value)].id
- } else {
- this.data.parm.price = null;
- }
- this.loadData();
- },
- scroll: function (event) {
- //该方法绑定了页面滚动时的事件,我这里记录了当前的position.y的值,为了请求数据之后把页面定位到这里来。
- let _this = this;
- _this.setData({
- scrollTop: event.detail.scrollTop
- });
- },
- seeDetails: function (e) {
- console.log(e)
- if (e.currentTarget.dataset.id) {
- wx.navigateTo({
- // ../../../index/courseDetail/courseDetail
- url: '../../courseDetail/courseDetail?id=' + e.currentTarget.dataset.id,
- })
- }
- },
- loadDatas:function(){
- wx.showLoading({
- title: '努力加载中...',
- })
- let _this = this;
- var data = {
- cityEnjoyCategory:'03'
- }
- app._post_form('/bizcatelog/apiSelectBizcatelog/cityEnjoyCategory', "application/json", JSON.stringify(data),function(res){
- if(res.code == 0){
- res.dictList.map((item) => {
- if(item.itemcode == '03'){
- _this.setData({
- imgbg:item.attribute3
- })
- }
- })
- }
- })
- },
- loadData:function(){
- wx.showLoading({
- title: '努力加载中...',
- })
- let _this = this;
- _this.data.parm.page = _this.data.parm.page + "";
- app._post_form('cou/list', "application/json", JSON.stringify(_this.data.parm),function(res){
- console.log(res)
- // _this.setData(res.data);
- if (res.code === 0) {
- _this.data.totalPage = res.data.totalPage;
- let d = _this.data.value;
- if (res.data.list.length) {
- d.push(...res.data.list);
- } else {
- d = [];
- }
- _this.setData({
- list: d,
- totalPage: res.data.totalPage,
- totalCount: res.data.totalCount,
- currPage: res.data.currPage
- })
- wx.hideLoading();
- }
- })
- },
- loadDic:function(){
- let _this = this;
- app._post_form('bizcatelog/apiSelectBizcatelog/courseCategory', '', null, function (res) {
- console.log(res)
- if (res.code === 0) {
- _this.data.array.push(...res.dictList);
- _this.setData({
- array: _this.data.array
- })
- }
- })
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- if (this.data.parm.page < this.data.totalPage) {
- this.data.parm.page++;
- this.loadData();
- }
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- }
- })
|