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 -- 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,

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

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

@ -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

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

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

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

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

@ -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,//获取记录搜索结果总数
}) })
} }
}) })

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

Loading…
Cancel
Save