货物列表1

master
dengzeyu 8 months ago
commit fc918a3114

@ -20,6 +20,7 @@ SET FOREIGN_KEY_CHECKS = 0;
-- ---------------------------- -- ----------------------------
-- Table structure for banner -- Table structure for banner
-- ---------------------------- -- ----------------------------
----
DROP TABLE IF EXISTS `banner`; DROP TABLE IF EXISTS `banner`;
CREATE TABLE `banner` ( CREATE TABLE `banner` (
`id` int(11) NOT NULL AUTO_INCREMENT, `id` int(11) NOT NULL AUTO_INCREMENT,

@ -1,12 +1,12 @@
// app.js // app.js
App({ App({
onLaunch() { onLaunch() {
// 展示本地存储能力 6 // 展示本地存储能力
const logs = wx.getStorageSync('logs') || [] const logs = wx.getStorageSync('logs') || []
logs.unshift(Date.now()) logs.unshift(Date.now())
wx.setStorageSync('logs', logs) wx.setStorageSync('logs', logs)
// 登录 // 定义登录
wx.login({ wx.login({
success: res => { success: res => {
// 发送 res.code 到后台换取 openId, sessionKey, unionId // 发送 res.code 到后台换取 openId, sessionKey, unionId

@ -12,14 +12,16 @@ Component({
/** /**
* 组件的初始数据212206213邓泽玉 * 组件的初始数据212206213邓泽玉
*/ *
data: {
21212313/
data: {
}, },
/** /**
* 组件的方法列表212206213邓泽玉 * 组件的方法列表212206213邓泽玉
*/ 132131*/
methods: { methods: {
} }

@ -2,7 +2,7 @@ const { getHotSearch,getSearch } = require("../../api/index.js")
Page({ Page({
/** /**
* 页面的初始数据 * 页面的初始数据1
*/ */
data: { data: {
search:"", search:"",
@ -11,52 +11,52 @@ Page({
goodsData:[] goodsData:[]
}, },
/** /**
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载2
*/ */
onLoad(options) { onLoad(options) {
getHotSearch().then(res =>{ getHotSearch().then(res =>{//获取热点搜索函数
this.setData({ this.setData({
hotSearch:res.data.data.result hotSearch:res.data.data.result//搜索数据结果
}) })
}) })
}, },
// 内容改变 // 内容改变3
onChange(e){ onChange(e){//内容展示函数
this.setData({ this.setData({
value:e.detail value:e.detail//获取值
}) })
}, },
/** /**
* 展示搜索数据在goods页面展示 * 展示搜索数据在goods页面展示4
* 1. 在搜索页面通过网络请求获取数据传递到goods页面显示 * 1. 在搜索页面通过网络请求获取数据传递到goods页面显示5
* 2. 在搜索页面将搜索的关键字传递到goods页面在goods页面做网络请求 * 2. 在搜索页面将搜索的关键字传递到goods页面在goods页面做网络请求6
*/ */
// 实现搜索 // 实现搜索7
onSearch(){ onSearch(){//搜索函数
this.http(this.data.value) this.http(this.data.value)//10
}, },
onSearchCliclk(){ onSearchCliclk(){//搜索点击函数
this.http(this.data.value) this.http(this.data.value)//11
}, },
/** /**
* 获取热门关键字 * 获取热门关键字8
*/ */
clickGetKeyWords(e){ clickGetKeyWords(e){
this.http(e.currentTarget.dataset.hotkey) this.http(e.currentTarget.dataset.hotkey)//使用this
}, },
http(search){ http(search){
getSearch({search}).then(res =>{ getSearch({search}).then(res =>{
if(!res.data.msg){ if(!res.data.msg){
// 序列化 // 序列化9
let goods = JSON.stringify(res.data.data) let goods = JSON.stringify(res.data.data)
wx.navigateTo({ wx.navigateTo({
url: '/pages/goods/goods?goodsData=' + goods, url: '/pages/goods/goods?goodsData=' + goods,//给出跳转网址
}) })
}else{ }else{
wx.showToast({ wx.showToast({
title: res.data.msg, title: res.data.msg,//获取记录搜索结果总数
}) })
} }
}) })

Loading…
Cancel
Save