<view>
<recycle-view batch="{{batchSetRecycleData}}" id="recycleId">
<view slot="before">长列表前面的内容</view>
<view class="item-content" wx:for="{{jobData}}" wx:key="id" class="item {{item.idx}}">
<text>{{item.title}}</text>
</view>
<view slot="after">长列表后面的内容</view>
</recycle-view>
</view>
import {isLogin} from '../../utils/auth'
import {jobRecommend} from '../../api/position'
import {userRecord} from '../../api/user'
import {getBanner,getCitysCode} from '../../api/public'
const createRecycleContext = require('miniprogram-recycle-view')
let newList = new Array(500).fill(0)
let count = 0
let page=1
for (let i = 0; i < newList.length; i++) {
newList[i] = {
idx: i,
title: `${i}我是标题标题标题哈哈`,
}
}
const rpx2px = (rpx) => (rpx / 750) * wx.getSystemInfoSync().windowWidth
var QQMapWX = require('../../assets/js/qqmap-wx-jssdk.min')
var qqmapsdk
var app = getApp()
Page({
onShow() {
if (typeof this.getTabBar === 'function' && this.getTabBar()) {
this.getTabBar().setData({
selected: 0
})
}
// 登录与否
console.log(app.globalData.userExpectInfo?.expected_position,'我是用户期望数据')
// this.getUserRecord()
// 没有位置信息在获取位置
if(this.data.cityData.length === 0){
this.getUserPosition()
}
this.setData({
isLogin:!isLogin()
})
// 获取banner
this.getBannerFn()
},
onReady(){
this.ctx = createRecycleContext({
id: 'recycleId',
dataKey: 'jobData',
page:this,
itemSize: {
height: rpx2px(488),
width: '100%'
}
})
this.ctx.append(newList) // 就是这句代码 导致得报错腾讯这些垃圾程序员你们他妈的得文档能不能写清除一点
},
data: {
isLogin:false,
swiperList:[],
expectList:[
{
id:1,
title:'呼吸外科'
},
{
id:2,
title:'内科医生'
},
{
id:3,
title:'神经外科'
},
{
id:4,
title:'神经内科'
},
{
id:5,
title:'心血管内科456'
},
],
activeView:'itemView1',
searchPosition:{
order:0
},
cityData:[], // 城市筛选信息
jobScreen:[] //职位的筛选信息
},
hideLogin:function(){
this.setData({
isLogin:false
})
},
showLogin:function(){
this.setData({
isLogin:true
})
},
async getBannerFn(){
const {data,code} = await getBanner()
if(code === 200){
const imgs = data.filter(item=> item.img_url??false ).map(el=>el.img_url)
this.setData({
swiperList:imgs
})
}
},
getJobRecommend:function(){
// 获取职位推荐
},
getUserRecord: async function(){
const data = await userRecord()
},
handlerSwiperItem:function(){
// 广告跳转
console.log('广告跳转')
},
onTabsChange:function(){
},
onTabsClick:function(){
},
// 切换岗位
handlerExpect:function(e){
const {dataset:{id}} = e.currentTarget
this.setData({
activeView:'itemView'+id
})
},
// 切换order
handlerOrder:function(e){
const {dataset:{order}} = e.currentTarget
this.setData({
'searchPosition.order':order
})
},
// 切换城市
handlerRegion:function(){
wx.navigateTo({
url:'/pages/city-five/index',
success:(res)=>{
res.eventChannel.emit('cityData',{ cityData: this.data.cityData })
}
})
},
// 职位筛选
handlerJobScreen(){
wx.navigateTo({
url:'/pages/job-screen/index',
success:(res)=>{
res.eventChannel.emit('jobScreen',{ jobScreen: this.data.jobScreen })
}
})
},
goToDesire:function(){
wx.navigateTo({
url:'/pages/desire/desire'
})
},
// 获取用户地理位置信息
getUserPosition(){
const {cityData} = this.data
const that = this
qqmapsdk = new QQMapWX({
key: 'IJOBZ-HSS3M-4SJ6J-6YGBD-QULOO-NHBZK'
})
qqmapsdk.reverseGeocoder({
async success(res) {
const {result:{address_component:{city}}} = res
// 根据城市名获取系统对应的code
const {data:{city:cityCode,province}} = await getCitysCode({city:city})
const userPosition = {
label:city,
code:cityCode
}
that.setData({
cityData:cityData.concat([userPosition])
})
},
fail(err) {
console.log(err,'操')
wx.showToast('获取城市失败')
},
})
}
})
报错信息
Error: the recycle-view correspond to this context is detached, pls create another RecycleContext
挖坟的 解决了吗
对了傲 那个加上 <recycle-item wx:for="{{jobData}}" wx:key="id" class="item {{item.idx}}">
<view class="item-content">
<text>{{item.title}}</text>
</view>
</recycle-item>
这个一个一个吊样什么玩意儿?