2024年最新国庆节,一天开发一个小程序+Web系统。2

      let imgSrc = this.data.defaultImageUrl;
      if (item.fileIds) {
        let fileId = JSON.parse(item.fileIds)[0];
        imgSrc = 'http://localhost:8888/files/download/' + fileId;
      }
      item.url = imgSrc;
    })
    this.setData({
      cart: cartList,
      totalNum: totalNum,
      totalPrice: totalPrice.toFixed(2)
    })
    console.log(this.data.cart)
  }
})

},
// 菜品数量的编辑功能
handleItemNumEdit(e) {
// 1 获取传递过来的参数
const { operation, id } = e.currentTarget.dataset;
// 2 获取购物车数组
let cart = this.data.cart;
// 3 找到需要修改的菜品的索引
const index = cart.findIndex(v => v.id === id);
// 4 判断是否要执行删除
if (cart[index].count === 1 && operation === -1) {
// 4.1 弹窗提示
wx.showModal({
content: ‘您是否要删除?’,
success: (res) => {
if (res.confirm) {
let user = wx.getStorageSync(“user”);
request({url: ‘/cartInfo/goods/’ + user.id + ‘/’ + id, method: ‘DELETE’}).then(res => {
if (res.code === ‘0’) {
let cart = this.data.cart;
cart.splice(index, 1);
let totalPrice = 0;
let totalNum = 0;
cart.forEach(item => {
totalNum += item.count;
totalPrice += item.count * item.price * item.discount;
})
this.setData({
cart: cart,
totalPrice: totalPrice.toFixed(2),
totalNum: totalNum
})
} else {
wx.showToast({
title: res.msg,
icon: ‘error’
})
}
})
}
}
})
} else {
// 4 进行修改数量
let cart = this.data.cart;
cart[index].count += operation;
// 重新计算一下总价
let totalPrice = 0;
let totalNum = 0;
cart.forEach(item => {
totalNum += item.count;
totalPrice += item.count * item.price * item.discount;
})
this.setData({
cart: cart,
totalPrice: totalPrice.toFixed(2),
totalNum: totalNum
})
}
},





Page({
data: {
defaultImageUrl: ‘…/…/imgs/default.png’,
// 左侧的菜单数据
leftMenuList: [],
// 右侧的菜品数据
rightContent: [],
goodsInfoList: [],
// 被点击的左侧的菜单
currentIndex: 1,
// 右侧内容的滚动条距离顶部的距离
scrollTop: 0
},
// 接口的返回数据
Cates: [],

onLoad: function (options) {
    this.getSwiperList();
    this.getCates();
    this.getGoodsList(1);
},
// 获取分类数据
getCates() {
    request({url: '/typeInfo/page/all'}).then(res => {
        if (res.code === '0') {
            this.setData({
                leftMenuList: res.data.list
            })
        }
    })
},
getGoodsList(goodId) {
    request({url: '/goodsInfo/findByType/' + goodId}).then(res => {
        if (res.code === '0') {
            let list = res.data;
            list.forEach((item, index) => {
                let imgSrc = this.data.defaultImageUrl;
                if (item.fileIds) {
                    let fileId = JSON.parse(item.fileIds)[0];
                    imgSrc = 'http://localhost:8888/files/download/' + fileId;
                }
                item.imgSrc = imgSrc;
            })
            this.setData({
                rightContent: list
            })
        }
    })
},
getSwiperList() {
    request({url: '/goodsInfoCarousel/page/all'}).then(res => {
        if (res.code === '0') {
            let swiperList = res.data.list;
            if (!swiperList && swiperList.length === 0) {
                swiperList.push({imgSrc: this.data.defaultImageUrl});
                swiperList.push({imgSrc: this.data.defaultImageUrl});
            } else {
                if (swiperList && swiperList.length > 3) {
                    swiperList = swiperList.slice(0, 3);
                }
                swiperList.forEach(item => {
                    if (!item.fileIds || item.fileIds === '[]') {
                        item.url = this.data.defaultImageUrl;
                    } else {
                        let fileArr = JSON.parse(item.fileIds);
                        item.url = 'http://localhost:8888/files/download/' + fileArr[0];
                    }
                });
            }
            this.setData({
                goodsInfoList: swiperList
            })
        } else {
            wx.showToast({
                title: res.msg,
                icon: 'none'
            })
        }
    })
},




//小孟开发,技术交流V:kaifazixun
@RestController
public class AccountController {

@Resource
private UserInfoService userInfoService;

@GetMapping("/logout")
public Result logout(HttpServletRequest request) {
    request.getSession().setAttribute("user", null);
    return Result.success();
}

@GetMapping("/auth")
public Result getAuth(HttpServletRequest request) {
    Object user = request.getSession().getAttribute("user");
    if(user == null) {
        return Result.error("401", "未登录");
    }
    return Result.success((UserInfo)user);
}

/**
 * 注册
 */
@PostMapping("/register")
public Result<UserInfo> register(@RequestBody UserInfo userInfo, HttpServletRequest request) {
    if (StrUtil.isBlank(userInfo.getName()) || StrUtil.isBlank(userInfo.getPassword())) {
        throw new CustomException(ResultCode.PARAM_ERROR);
    }
    UserInfo register = userInfoService.add(userInfo);
    HttpSession session = request.getSession();
    session.setAttribute("user", register);
    session.setMaxInactiveInterval(120 * 60);
    return Result.success(register);
}

/**
 * 登录
 */
@PostMapping("/login")
public Result<UserInfo> login(@RequestBody UserInfo userInfo, HttpServletRequest request) {
    if (StrUtil.isBlank(userInfo.getName()) || StrUtil.isBlank(userInfo.getPassword())) {
        throw new CustomException(ResultCode.USER_ACCOUNT_ERROR);
    }
    UserInfo login = userInfoService.login(userInfo.getName(), userInfo.getPassword());
    HttpSession session = request.getSession();
    session.setAttribute("user", login);
    session.setMaxInactiveInterval(120 * 60);
    return Result.success(login);
}


## 四,系统数据库介绍




SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;


– Table structure for cart_info


DROP TABLE IF EXISTS cart_info;
CREATE TABLE cart_info (
id bigint(0) NOT NULL AUTO_INCREMENT COMMENT ‘自增id’,
count int(0) NOT NULL DEFAULT 0 COMMENT ‘数量’,
goodsId bigint(0) NOT NULL DEFAULT 0 COMMENT ‘所属商品’,
userId bigint(0) NOT NULL DEFAULT 0 COMMENT ‘所属用户’,
level int(0) NULL DEFAULT NULL COMMENT ‘用户等级’,
createTime varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT ‘’ COMMENT ‘创建时间’,
PRIMARY KEY (id) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 9 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = ‘购物车信息表’ ROW_FORMAT = Dynamic;


– Records of cart_info


INSERT INTO cart_info VALUES (4, 1, 2, 3, NULL, ‘2021-04-14 20:12:38’);
INSERT INTO cart_info VALUES (6, 1, 3, 7, NULL, ‘2021-04-14 17:08:53’);
INSERT INTO cart_info VALUES (7, 1, 1, 10, NULL, ‘2021-04-14 17:22:18’);
INSERT INTO cart_info VALUES (11, 1, 2, 21, NULL, ‘2021-04-14 15:50:01’);


– Table structure for comment_info


DROP TABLE IF EXISTS comment_info;
CREATE TABLE comment_info (
id bigint(0) NOT NULL AUTO_INCREMENT COMMENT ‘自增id’,
content varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT ‘’ COMMENT ‘评价内容’,
goodsId bigint(0) NOT NULL DEFAULT 0 COMMENT ‘所属商品’,
userId bigint(0) NOT NULL DEFAULT 0 COMMENT ‘评价人id’,
level int(0) NULL DEFAULT NULL COMMENT ‘用户等级’,
createTime varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT ‘’ COMMENT ‘创建时间’,
PRIMARY KEY (id) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = ‘商品评价表’ ROW_FORMAT = Dynamic;


– Records of comment_info



– Table structure for goods_info


DROP TABLE IF EXISTS goods_info;
CREATE TABLE goods_info (
id bigint(0) NOT NULL AUTO_INCREMENT COMMENT ‘自增id’,
name varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT ‘’ COMMENT ‘商品名称’,
description varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT ‘’ COMMENT ‘商品描述’,
price double(10, 2) NOT NULL DEFAULT 0.00 COMMENT ‘商品价格’,
discount double(10, 2) NULL DEFAULT 1.00 COMMENT ‘商品折扣’,
sales int(0) NOT NULL DEFAULT 0 COMMENT ‘商品销量’,
hot int(0) NOT NULL DEFAULT 0 COMMENT ‘商品点赞数’,
recommend varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT ‘否’ COMMENT ‘是否是推荐’,
count int(0) NOT NULL DEFAULT 0 COMMENT ‘商品库存’,
typeId bigint(0) NOT NULL DEFAULT 0 COMMENT ‘所属类别’,
fileIds varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT ‘’ COMMENT ‘商品图片id,用英文逗号隔开’,
userId bigint(0) NOT NULL DEFAULT 0 COMMENT ‘评价人id’,
level int(0) NULL DEFAULT NULL COMMENT ‘用户等级’,
PRIMARY KEY (id) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 6 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = ‘商品详情表’ ROW_FORMAT = Dynamic;


– Records of goods_info


INSERT INTO goods_info VALUES (1, ‘空心菜’, ‘空心菜’, 12.00, 0.80, 36, 256, ‘是’, 394, 1, ‘[21]’, 1, NULL);
INSERT INTO goods_info VALUES (2, ‘生菜’, ‘生菜,就是好吃’, 299.00, 0.80, 17, 2048, ‘是’, 193, 1, ‘[22]’, 1, NULL);
INSERT INTO goods_info VALUES (3, ‘土鸡蛋’, ‘土鸡蛋,值得拥有,营养丰富’, 399.00, 0.80, 29, 512, ‘是’, 191, 2, ‘[23]’, 1, NULL);
INSERT INTO goods_info VALUES (4, ‘马铃薯’, ‘还好啦’, 3999.00, 0.90, 0, 0, ‘否’, 200, 1, ‘[19]’, 1, NULL);
INSERT INTO goods_info VALUES (5, ‘瘦肉’, ‘瘦肉’, 20.00, 0.80, 0, 0, ‘否’, 3, 3, ‘[20]’, 1, NULL);


– Table structure for nx_system_file_info


DROP TABLE IF EXISTS nx_system_file_info;
CREATE TABLE nx_system_file_info (
id bigint(0) NOT NULL AUTO_INCREMENT COMMENT ‘ID’,
originName varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT ‘原始文件名’,
fileName varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT ‘存储文件名’,
PRIMARY KEY (id) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 21 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = ‘文件信息表’ ROW_FORMAT = Dynamic;


– Records of nx_system_file_info


INSERT INTO nx_system_file_info VALUES (12, ‘iphone12.jpg’, ‘iphone121606791180182.jpg’);
INSERT INTO nx_system_file_info VALUES (13, ‘牛仔外套.jpg’, ‘牛仔外套1606791664516.jpg’);
INSERT INTO nx_system_file_info VALUES (14, ‘女装.jpg’, ‘女装1606791689058.jpg’);
INSERT INTO nx_system_file_info VALUES (15, ‘华为Meta30.jpg’, ‘华为Meta301606791754239.jpg’);
INSERT INTO nx_system_file_info VALUES (16, ‘30950.jpg’, ‘309501608444761955.jpg’);
INSERT INTO nx_system_file_info VALUES (17, ‘u=2669303306,338188050&fm=26&gp=0.jpg’, ‘u=2669303306,338188050&fm=26&gp=01608454963850.jpg’);
INSERT INTO nx_system_file_info VALUES (18, ‘u=1646342622,2222263206&fm=26&gp=0.jpg’, ‘u=1646342622,2222263206&fm=26&gp=01608454991319.jpg’);
INSERT INTO nx_system_file_info VALUES (19, ‘timg.jpg’, ‘timg1608455054164.jpg’);
INSERT INTO nx_system_file_info VALUES (20, ‘1799.gif’, ‘17991608457607178.gif’);
INSERT INTO nx_system_file_info VALUES (21, ‘u=3337100505,326999387&fm=26&gp=0.jpg’, ‘u=3337100505,326999387&fm=26&gp=01618384992043.jpg’);
INSERT INTO nx_system_file_info VALUES (22, ‘u=252972411,229433572&fm=26&gp=0.jpg’, ‘u=252972411,229433572&fm=26&gp=01618385236566.jpg’);
文末有福利领取哦~

👉一、Python所有方向的学习路线

Python所有方向的技术点做的整理,形成各个领域的知识点汇总,它的用处就在于,你可以按照上面的知识点去找对应的学习资源,保证自己学得较为全面。img

👉二、Python必备开发工具

img
👉三、Python视频合集

观看零基础学习视频,看视频学习是最快捷也是最有效果的方式,跟着视频中老师的思路,从基础到深入,还是很容易入门的。
img

👉 四、实战案例

光学理论是没用的,要学会跟着一起敲,要动手实操,才能将自己的所学运用到实际当中去,这时候可以搞点实战案例来学习。(文末领读者福利)
img

👉五、Python练习题

检查学习结果。
img

👉六、面试资料

我们学习Python必然是为了找到高薪的工作,下面这些面试题是来自阿里、腾讯、字节等一线互联网大厂最新的面试资料,并且有阿里大佬给出了权威的解答,刷完这一套面试资料相信大家都能找到满意的工作。
img

img

👉因篇幅有限,仅展示部分资料,这份完整版的Python全套学习资料已经上传

网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。

需要这份系统化学习资料的朋友,可以戳这里无偿获取

一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值