老師,不知道哪里出錯了
movielist下index.js代碼如下:
//?云函數入口文件
const?cloud?=?require('wx-server-sdk')
cloud.init({env:?cloud.DYNAMIC_CURRENT_ENV})
const?axios?=?require('axios')
//?云函數入口函數
exports.main?=?async?(event,?context)?=>?{
????try?{
????????const?{
????????data
????????}?=?await?axios({
????????????url:?`https://frodo.douban.com/api/v2/subject_collection/movie_showing/items?start=${event.start}&count=${event.count}&apiKey=054022eaeae0b00e0fc068c0c0a2102a`,
????????????method:?'get',
????????????headers:?{
????????????"Host":?"frodo.douban.com",
????????????"Connection":?"keep-alive",
????????????'content-type':?'application/json',
????????????'User-Agent':?'Mozilla/5.0?(iPhone;?CPU?iPhone?OS?14_4?like?Mac?OS?X)?AppleWebKit/605.1.15?(KHTML,?like?Gecko)?Mobile/15E148?MicroMessenger/8.0.2(0x18000236)?NetType/WIFI?Language/zh_CN',
????????????'Referer':?'https://servicewechat.com/wx2f9b06c1de1ccfca/81/page-frame.html?'
????????}
????????})
????????????return?data
????????}?catch?(e)?{
????????console.log(e)
????}
}
movie.js代碼如下:
//?pages/movie/movie.js
Page({
??/**
???*?頁面的初始數據
???*/
??data:?{
????movieList:[]
??},
??/**
???*?生命周期函數--監聽頁面加載
???*/
??onLoad(options)?{
??????wx.cloud.callFunction({
????????name:'movielist',
????????data:{
??????????start:this.data.movieList.length,
??????????count:10
????????}
??????}).then(res?=>{
????????console.log(res);
????????this.setData({
??????????movieList:?this.data.movieList.concat(res.result.subject_collection_items)
????????});
????????wx.hideLoading();
??????}).catch(err?=>{
????????console.error(err);
????????wx.hideLoading();
??????});
??},
??
??gotoComment:?function(event)?{
????wx.navigateTo({
??????url:?`../comment/comment?movieid=${event.target.dataset.movieid}`,
????});
??},
??/**
???*?生命周期函數--監聽頁面初次渲染完成
???*/
??onReady()?{
??},
??/**
???*?生命周期函數--監聽頁面顯示
???*/
??onShow()?{
??},
??/**
???*?生命周期函數--監聽頁面隱藏
???*/
??onHide()?{
??},
2023-02-20