123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187 |
- const app = getApp();
- Page({
-
- data: {
- hotsearch:"在家兼职",
- hotsearchList:[],
- searchValue:"",
- searchRecordList:[],
- isSearch:false,
- searchResList:[]
- },
-
- clickRes(e){
- console.log("1")
- wx.navigateTo({
- url: '../../commodity-detail/commodity-detail?id=' + e.currentTarget.dataset.id,
- })
- },
-
- clearValue(e){
- this.setData({
- searchValue: ""
- });
- },
-
- input(e){
- this.setData({
- searchValue: e.detail.value
- });
- },
-
- prepend(arr, item) {
- return [item].concat(arr);
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- },
-
- deleteRecord(e){
- this.setData({
- searchRecordList: []
- });
- wx.setStorage({
- key: "searchRecordList",
- data: []
- })
- },
-
- search(e){
- var _this = this
- wx.request({
- url: app.globalData.baseURL + '/job/search',
- method: 'GET',
- data: {
- "key": _this.data.searchValue
- },
- success(res) {
- _this.setData({
- searchResList: res.data.data,
- });
-
- if (!_this.data.isSearch){
- _this.setData({
- isSearch: !_this.data.isSearch
- });
- }
- console.log(res.data.data)
- }
- })
- },
-
- clickHot(e){
-
- var value = this.data.hotsearchList[e.currentTarget.dataset.index].message
-
- var item = { message: value}
- this.setData({
- searchValue: value,
- searchRecordList: this.prepend(this.data.searchRecordList, item)
- });
- wx.setStorage({
- key: "searchRecordList",
- data: this.data.searchRecordList
- })
-
- },
-
- clickRecord(e){
-
- this.setData({
- searchValue: this.data.searchRecordList[e.currentTarget.dataset.index].message
- });
- },
-
- onLoad: function (options) {
- var _this = this
- wx.request({
- url: app.globalData.baseURL + '/job/hot',
- method: 'GET',
- success(res) {
- _this.setData({
- hotsearchList: res.data.data
- });
- }
- })
- },
-
- onShow: function () {
- try {
- var value = wx.getStorageSync('searchRecordList')
- if (value) {
-
- this.setData({
- searchRecordList: value,
- });
- }
- } catch (e) {
-
- }
- },
-
- onHide: function () {
- },
-
- onUnload: function () {
- },
-
- onPullDownRefresh: function () {
- },
-
- onReachBottom: function () {
- },
-
- onShareAppMessage: function () {
- }
- })
|