123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171 |
- // pages/search/search.js
- const apiServer = require('../../api/request');
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- list: [],
- inputValue: null,
- resultList:[
- // {
- // title:'AppL',
- // subtitle:"APPL INC",
- // Increase:"1.22",
- // digital:"33",
- // data:[52,56,355,444]
- // },
- // {
- // title:'AppL',
- // subtitle:"APPL INC",
- // Increase:"1.22",
- // digital:"33",
- // data:[52,56,355,44554]
- // },
- ]
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- this.get
- var _this = this;
- wx.getStorage({
- key: 'historySearch',
- success(res) {
- _this.setData({
- list: res.data
- })
- }
- })
- },
- blur: function (e) {
- this.setData({
- inputValue: e.detail.value
- })
- this.search();
- },
- search:function(){
- let data ={
- search:this.data.inputValue
- };
- apiServer.getSearch(data).then((res) =>{
- if(res.statusCode == 200){
- console.log(res.data);
- }else{
- wx.showToast({
- title: '搜索失败',
- icon: 'none'
- })
- }
-
- })
- },
- save: function () {
- var list = this.data.list;
- if (list.indexOf(this.data.inputValue) == -1 & this.data.inputValue != '') {
- list.push(this.data.inputValue);
- }
- this.setData({
- list: list
- })
- wx.setStorage({
- key: 'historySearch',
- data: list
- })
- },
- searchName: function (e) {
- this.setData({
- inputValue: e.currentTarget.dataset.value
- })
- this.search();
- },
- remove: function () {
- var _this = this;
- wx.showModal({
- title: '提示',
- content: '确认清空所有记录?',
- success(res) {
- if (res.confirm) {
- wx.removeStorage({
- key: 'historySearch',
- success() {
- _this.setData({
- list: []
- })
- }
- })
- } else if (res.cancel) {
- console.log('用户点击取消')
- }
- }
- })
- },
- clean:function(){
- var _this=this
- setTimeout(function () {
- _this.setData({
- inputValue: '',
- })
- },100)
- },
- detail:function(e){
- this.save();
- wx.navigateTo({
- url: '../item/item'
- });
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- },
-
- })
|