- 1 需要开启 renren-api
- 2 需要开启nginx服务
index.vue页面代码
<template>
<view>
<view class="search-container">
<image src="../../static/img/logo-small.jpg" class="logo"></image>
<view class="search-bar">
<icon type="search" size="16" class="search-icon"></icon>
<input type="text" placeholder="请输入关键字" class="search" confirm-type="search" v-model="keyword" @confirm="handleSearch" />
</view>
</view>
<swiper :indicator-dots="false" :autoplay="true" :interval="5000"
:duration="1000" class="swiper-container">
<swiper-item v-for="one in swiper" :key="one.id"
@tap="toCurriculum" :data-id="one.id">
<image :src="one.banner" class="swiper-image"></image></swiper-item>
</swiper>
</view>
</template>
<script>
export default {
data() {
return {
keyword: null,
swiper: []
};
},
methods: {
handleSearch: function() {
console.log(this.keyword);
},
onShow: function() {
console.log('onShow==55======');
//let token=wx.getStorageSync("token");
let token = uni.getStorageSync('token');
let ref = this;
uni.request({
url: ref.url.curriculum_swiper,
header: {
token: token
},
success: function(resp) {
console.log(resp);
//清空
ref.swiper.length = 0;
for (let one of resp.data.data) {
ref.swiper.push({
id: one.id,
banner: `${ref.url.image_server}/${one.banner}`
});
}
console.log(ref.swiper);
}
});
},
toCurriculum: function(e) {
let id = e.currentTarget.dataset.id;
uni.navigateTo({
url: '../curriculum/curriculum?id=' + id
});
}
}
};
</script>
<style lang="less">
@import url('index.less');
</style>