yuminge-app/yun-min-program-plugin-master/packageG/cps/cpsSearchPage/cpsSearchPage.js

130 lines
2.6 KiB
JavaScript

// packageG/cps/cpsSearchPage/cpsSearchPage.js
var cpsApi = require("../component/cpsApi");
Page({
behaviors: [cpsApi],
/**
* 页面的初始数据
*/
data: {
searchActive: 'pdd',
searchKey: '',
channel_type: "",
channel_type_name: "商品列表",
options: {}
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
if (options.channel_type_name) {
options.channel_type_name = decodeURIComponent(options.channel_type_name);
}
console.log(options);
this.setData({
options: options,
searchActive: options.status || 'pdd'
});
if (options.channel_type) {
this.setData({
channel_type: options.channel_type,
});
}
if (options.keyword) {
this.setData({
searchKey: decodeURIComponent(options.keyword),
});
}
this.getCPSLogin('list');
},
onChange(e) {
this.setData({
searchKey: e.detail,
});
},
onSearch(e) {
this.setData({
page: 1,
isLoadMore: true,
goodsData: [],
searchActive: e.detail.name || this.data.searchActive
});
this.searchCPSGood();
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
this.searchCPSGood();
},
/**
* 用户点击右上角分享
*/
onShareTimeline() {
var value = wx.getStorageSync("yz_uid");
var mid = "";
if (value) {
mid = value;
}
return {
title: this.data.channel_type_name,
query: `status=${this.data.searchActive}&channel_type=${this.data.channel_type}&channel_type_name=${this.data.options.channel_type_name}&mid=${mid}`,
};
},
onShareAppMessage: function () {
var value = wx.getStorageSync('yz_uid');
let mid = '';
if (value) {
mid = value;
}
let url = `/packageG/cps/cpsSearchPage/cpsSearchPage?status=${this.data.searchActive}`;
if (this.data.channel_type) {
url = url + `&channel_type=${this.data.channel_type}&channel_type_name=${this.data.options.channel_type_name}`;
}
return {
title: this.data.channel_type_name,
path: url + `&mid=${mid}`,
};
}
});