Merge remote-tracking branch 'origin/master'

master
fjc 5 months ago
commit b057396406

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

@ -15,4 +15,4 @@ app.use("/api",router);
app.listen(3001,() =>{
console.log("服务器运行在3001端口上");
})
})//123

@ -1,5 +1,5 @@
/**
* 存储接口地址
* 定义存储接口地址
*/
module.exports = {
baseUrl:"http://iwenwiki.com:3001", // 公共地址

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

@ -1,7 +1,7 @@
// components/goods-list/goods-list.js
Component({
/**
* 组件的属性列表
* 212206213邓泽玉组件的属性列表
*/
properties: {
goodsData:{
@ -11,15 +11,17 @@ Component({
},
/**
* 组件的初始数据
*/
data: {
* 组件的初始数据212206213邓泽玉
*
21212313/
data: {
},
/**
* 组件的方法列表
*/
* 组件的方法列表212206213邓泽玉
132131*/
methods: {
}

@ -3,6 +3,9 @@
padding: 5px;
box-sizing: border-box;
}
/**
* 列表的样式212206213邓泽玉
*/
.list .item {
width: 48%;
@ -12,11 +15,11 @@
background: #fff;
margin: 2px 1%;
}
/**列表项目的样式**/
.list .item .goods_img image {
width: 100%;
}
/**货物信息名字**/
.list .item .goods_info .goods_name {
font-size: 14px;
text-align: left;
@ -29,7 +32,7 @@
display: -webkit-box;
word-break: break-all;
}
/**货物价格**/
.list .item .goods_info .goods_price {
font-style: normal;
font-family: JDZH-Regular, sans-serif;
@ -38,7 +41,7 @@
line-height: 1.5rem;
color: #ff4142;
}
/**新货物的信息**/
.list .item .goods_info .goods_price text{
font-size: 1rem;
}

@ -1,46 +1,52 @@
const { getCart,delGoodsCart } = require("../../api/index.js")
// 引入获取购物车和删除购物车商品的API方法
const { getCart, delGoodsCart } = require("../../api/index.js");
// 定义小程序页面对象
Page({
/**
* 页面的初始数据
*/
// 页面数据对象初始时cartData为空数组
data: {
cartData: []
},
/**
* 每次打开页面都会执行
*/
// 页面显示时触发的方法调用http方法获取购物车数据
onShow() {
this.http()
this.http();
},
// 跳转到商品详情页的方法根据传入的商品ID进行跳转
goDetail(e) {
const id = e.currentTarget.dataset.id; // 获取当前点击元素的数据集中的id值
wx.navigateTo({
url: `/pages/goodsDetails/goodsDetails?id=${id}` // 跳转到商品详情页并传递商品ID参数
});
},
// 根源
// 删除购物车商品的方法根据传入的商品ID进行删除操作
delCartHandle(e) {
console.log(e.currentTarget.dataset.id);
/**
* 这里有两个ID
* 1. currentID:商品ID同一个商品加入购物车多次的时候会一次性全删除
* 2. id:每条数据的唯一索引(推荐)课程中选择的方式
*/
console.log("删除按钮被点击"); // 打印日志,表示删除按钮被点击
console.log(e.currentTarget.dataset.id); // 打印当前点击元素的数据集中的id值
// 调用删除购物车商品的API方法传入当前商品ID
delGoodsCart({ currentID: e.currentTarget.dataset.id }).then(res => {
if(res.data.status === 200){
wx.showToast({
if (res.data.status === 200) { // 如果API返回的状态码为200表示删除成功
wx.showToast({ // 显示成功提示框
title: '删除成功',
})
this.http()
}else{
wx.showToast({
});
this.http(); // 刷新购物车数据
} else { // 如果API返回的状态码不是200表示删除失败
wx.showToast({ // 显示失败提示框
title: '删除失败',
})
});
}
})
});
},
// 获取购物车数据的方法
http() {
getCart().then(res =>{
console.log(res.data.data);
this.setData({
getCart().then(res => { // 调用获取购物车数据的API方法
console.log(res.data.data); // 打印API返回的购物车数据
this.setData({ // 更新页面数据对象中的cartData属性
cartData: res.data.data
})
})
});
});
}
})
});

@ -1,5 +1,7 @@
const { getBanner,getGoods } = require("../../api/index.js")
/**
邓泽玉212206213
**/
Page({
data: {
value: "",

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

@ -1,5 +1,5 @@
const { getLogin } = require("../../api/index.js")
//1231344
Page({
data: {
userInfo: {},

Loading…
Cancel
Save