1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- export const hotInit = (that) => {
- that.setData({
- hotData: {
- nav: [],
- hotIndex: 0,
- hotList: [],
- left: ''
- }
- })
- //点击更改数据
- that.hotChoice = ({ currentTarget }) => {
- that.data.hotData.hotInd = currentTarget.dataset.index;
- if (that.data.hotData.nav.length > 3 && currentTarget.dataset.index == 2) {
- that.data.hotData.left = currentTarget.dataset.index * 225;
- }
- if (that.data.hotData.nav.length > 3 && currentTarget.dataset.index == 1) {
- that.data.hotData.left = '';
- }
- that.setData({
- hotData: that.data.hotData
- })
- //数据请求
- that.httpList(currentTarget.dataset.index + 1)
- }
- //滑动更改数据
- that.lookSlide = ({ detail }) => {
- that.data.hotData.hotInd = detail.current;
- if (that.data.hotData.nav.length > 3 && detail.current == 2) {
- that.data.hotData.left = detail.current * 225;
- }
- if (that.data.hotData.nav.length > 3 && detail.current == 1) {
- that.data.hotData.left = '';
- }
- // console.log(detail.current);
- that.setData({
- hotData: that.data.hotData
- })
- that.httpList(detail.current + 1)
- }
- //跳转到详情页
- that.details = ({ currentTarget }) => {
- const id = currentTarget.dataset.id;
- wx.navigateTo({
- url: '/pages/details/details?id=' + id
- })
- }
- //请求数据封装
- that.httpList = (ind) => {
- httpRequestApi.getCourse({
- categoryId: ind
- }).success((res)=>{
- console.log('课程列表', res);
- that.data.hotData.hotList = res.data.data.list;
- that.setData({
- hotData: that.data.hotData
- })
- })
- }
- //初始数据
- that.httpList(1)
- }
|