1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- // component/look/look.js
- import httpRequestApi from '../../utils/APIRequest';
- export const lookInit = (that) => {
- that.setData({
- lookData: {
- nav: ['看动画', '学知识', '育儿经'],
- lookInd: 0,
- lookList: [],
- }
- })
- //点击更改数据
- that.lookChoice = ({ currentTarget }) => {
- that.data.lookData.lookInd = currentTarget.dataset.index;
- that.setData({
- lookData: that.data.lookData
- })
- //数据请求
- that.httpList(detail.current + 1)
- }
- //滑动更改数据
- that.lookSlide = ({ detail }) => {
- that.data.lookData.lookInd = detail.current;
- // console.log(detail.current);
- that.setData({
- lookData: that.data.lookData
- })
- 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.lookData.lookList = res.data.data.list;
- that.setData({
- lookData: that.data.lookData
- })
- })
- }
- //初始数据
- that.httpList(1)
- }
|