You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

195 lines
4.1 KiB

// pages/list/six/index.js
let app = getApp()
import commonApi from "../../../utils/https/common"
import util from "../../../utils/util"
Page({
/**
* 页面的初始数据
*/
data: {
types:[],
areaIndex:0,
areas:[],
typeIndex:0,
total:1,
list:[],
keywords:""
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
// 获取地区
commonApi._post("act/get_suzhou_areas",{}).then(res=>{
let areaIndex = 0;
res.data.map((item,index)=>{
if(options.area && item.area_key==options.area && areaIndex==0){
areaIndex = index;
}
})
this.setData({
areas:res.data,
areaIndex:areaIndex
})
this.getTypes()
})
},
gotoUrl: function(e) {
let url = e.currentTarget.dataset.url;
app.globalData.weburl = url;
wx.navigateTo({
// url: '/pages/pbService/web/index?weburl='+encodeURIComponent('https://m.cloud.sz-trip.com/Cloudperform2022'),
url: '/pages/pbService/web/index?weburl=' + encodeURIComponent(url),
})
},
gotoPath:function(e){
console.log(e);
if(e.currentTarget.dataset.event.area_key == 'taicang'){
wx.navigateToMiniProgram({
appId: 'wx8853b0d93cbca75e',
path: 'pages/home/home'
})
}else if(e.currentTarget.dataset.event.area_key == 'gongyeyuanqu'){
wx.navigateToMiniProgram({
appId: 'wxd323e63a10aa6865',
path: 'pages/home/index'
})
}else if (e.currentTarget.dataset.event.area_key == 'kunshan') {
wx.navigateToMiniProgram({
appId: 'wx8888a3fd0862b4c8',
path: 'pages/index/index'
})
}else if (e.currentTarget.dataset.event.area_key == 'changshu') {
wx.navigateToMiniProgram({
appId: 'wx4df5fd9a6a5ea123',
path: 'pages/index'
})
}
},
goH5(e){
let url = e.currentTarget.dataset.url;
app.globalData.weburl = url;
console.log(app.globalData.weburl);
wx.navigateTo({
url: "/pages/pbService/web/index"
})
},
getTypes:function(){
// 获取苏城六纪下面的分类
commonApi._post("act/get_type_by_area",{
area_id:this.data.areas[this.data.areaIndex].area_id,
tag_id:16
}).then(res=>{
res.data.unshift({
type_name:"全部",
type_id:""
})
this.setData({
types:res.data,
typeIndex:0
})
this.getList();
})
},
changeArea:function(e){
this.setData({
areaIndex:e.detail.value,
list:[],
total:1
})
this.getTypes();
},
changeType:function(e){
this.setData({
typeIndex:e.detail.value,
list:[],
total:1
})
this.getList()
},
search:function(e){
this.setData({
keywords:e.detail.keywords,
list:[],
total:1
})
this.getList()
},
getList:function(){
let list = this.data.list;
if(list.length>=this.data.total) return;
if(!this.data.types[this.data.typeIndex]) return;
commonApi._post('product/get_product_by_tag',{
areas_id:this.data.areas[this.data.areaIndex].area_id,
type_id:this.data.types[this.data.typeIndex].type_id,
tag_id:16,
offset:list.length,
limit:10,
sort:"weight",
order:"desc",
title:this.data.keywords
}).then(res=>{
this.setData({
list:list.concat(res.data.list),
total:res.data.total
})
})
},
gotoDetail:function(e){
let item = e.currentTarget.dataset.item;
console.log(item)
util.gotoDetail(item);
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
this.getList();
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})