|
@@ -13,14 +13,17 @@ Page({
|
|
|
|
|
|
onShow() {
|
|
onShow() {
|
|
// 检查登录状态
|
|
// 检查登录状态
|
|
- // app.checkLoginStatus();
|
|
|
|
|
|
+ app.checkLoginStatus();
|
|
},
|
|
},
|
|
|
|
|
|
onLoad() {
|
|
onLoad() {
|
|
|
|
+ // 获取轮播图数据
|
|
|
|
+ this.getBanner();
|
|
|
|
+ // 获取图片
|
|
const fileIDs = [
|
|
const fileIDs = [
|
|
- 'cloud://cloud1-6g98iw7i28b01747.636c-cloud1-6g98iw7i28b01747-1367995226/images/banner/carousel_1.jpg',
|
|
|
|
- 'cloud://cloud1-6g98iw7i28b01747.636c-cloud1-6g98iw7i28b01747-1367995226/images/banner/carousel_2.jpg',
|
|
|
|
- 'cloud://cloud1-6g98iw7i28b01747.636c-cloud1-6g98iw7i28b01747-1367995226/images/banner/carousel_3.jpg',
|
|
|
|
|
|
+ // 'cloud://cloud1-6g98iw7i28b01747.636c-cloud1-6g98iw7i28b01747-1367995226/images/banner/carousel_1.jpg',
|
|
|
|
+ // 'cloud://cloud1-6g98iw7i28b01747.636c-cloud1-6g98iw7i28b01747-1367995226/images/banner/carousel_2.jpg',
|
|
|
|
+ // 'cloud://cloud1-6g98iw7i28b01747.636c-cloud1-6g98iw7i28b01747-1367995226/images/banner/carousel_3.jpg',
|
|
'cloud://cloud1-6g98iw7i28b01747.636c-cloud1-6g98iw7i28b01747-1367995226/images/homepage/homepage_8.png',
|
|
'cloud://cloud1-6g98iw7i28b01747.636c-cloud1-6g98iw7i28b01747-1367995226/images/homepage/homepage_8.png',
|
|
'cloud://cloud1-6g98iw7i28b01747.636c-cloud1-6g98iw7i28b01747-1367995226/images/homepage/homepage_9.png',
|
|
'cloud://cloud1-6g98iw7i28b01747.636c-cloud1-6g98iw7i28b01747-1367995226/images/homepage/homepage_9.png',
|
|
'cloud://cloud1-6g98iw7i28b01747.636c-cloud1-6g98iw7i28b01747-1367995226/images/icon/sou.png',
|
|
'cloud://cloud1-6g98iw7i28b01747.636c-cloud1-6g98iw7i28b01747-1367995226/images/icon/sou.png',
|
|
@@ -34,16 +37,34 @@ Page({
|
|
const tempFilePaths = results.map(r => r.tempFilePath);
|
|
const tempFilePaths = results.map(r => r.tempFilePath);
|
|
console.log('全部下载成功:', tempFilePaths);
|
|
console.log('全部下载成功:', tempFilePaths);
|
|
this.setData({
|
|
this.setData({
|
|
- carousellist: tempFilePaths.slice(0, 2),
|
|
|
|
- homepage_8: tempFilePaths[3],
|
|
|
|
- homepage_9: tempFilePaths[4],
|
|
|
|
- souimg: tempFilePaths[5]
|
|
|
|
|
|
+ // carousellist: tempFilePaths.slice(0, 2),
|
|
|
|
+ homepage_8: tempFilePaths[0],
|
|
|
|
+ homepage_9: tempFilePaths[1],
|
|
|
|
+ souimg: tempFilePaths[2]
|
|
});
|
|
});
|
|
}).catch(err => {
|
|
}).catch(err => {
|
|
console.error('有文件下载失败:', err);
|
|
console.error('有文件下载失败:', err);
|
|
});
|
|
});
|
|
},
|
|
},
|
|
|
|
|
|
|
|
+ // 轮播数据
|
|
|
|
+ async getBanner() {
|
|
|
|
+ const { data } = await models.banner.list({
|
|
|
|
+ filter: {
|
|
|
|
+ where: {
|
|
|
|
+ position: 0
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ // envType: pre 体验环境, prod 正式环境
|
|
|
|
+ envType: "prod",
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ // 返回查询到的数据
|
|
|
|
+ this.setData({
|
|
|
|
+ carousellist: data.records
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+
|
|
// 页面跳转 二级页面
|
|
// 页面跳转 二级页面
|
|
selectGroupOption(e) {
|
|
selectGroupOption(e) {
|
|
const option = e.currentTarget.dataset.option;
|
|
const option = e.currentTarget.dataset.option;
|
|
@@ -71,8 +92,80 @@ Page({
|
|
});
|
|
});
|
|
},
|
|
},
|
|
|
|
|
|
|
|
+ // 上传轮播图 存储轮播图图片地址 和展示位置 后续需要存一个上传的图片名字
|
|
|
|
+ // async getData() {
|
|
|
|
+ // try {
|
|
|
|
+ // // 上传文件到云存储
|
|
|
|
+ // const uploadRes = await wx.cloud.uploadFile({
|
|
|
|
+ // cloudPath: "imgs/banner/carousel_3.jpg", // 上传至云端的路径
|
|
|
|
+ // filePath: "image/imgs/carousel_3.jpg" // 小程序临时文件路径
|
|
|
|
+ // });
|
|
|
|
+
|
|
|
|
+ // // 获取上传文件的 fileID
|
|
|
|
+ // const fileID = uploadRes.fileID;
|
|
|
|
+ // console.log("文件 ID:", fileID);
|
|
|
|
+
|
|
|
|
+ // // 将文件路径存入 banner 表
|
|
|
|
+ // const { data } = await models.banner.create({
|
|
|
|
+ // data: {
|
|
|
|
+ // remark: "", // 备注
|
|
|
|
+ // position: 4, // 展示位置
|
|
|
|
+ // describe: "", // 描述
|
|
|
|
+ // url: fileID, // 路径
|
|
|
|
+ // },
|
|
|
|
+ // envType: "prod", // 正式环境
|
|
|
|
+ // });
|
|
|
|
+
|
|
|
|
+ // // 返回创建的数据 id
|
|
|
|
+ // console.log("创建的数据:", data);
|
|
|
|
+ // } catch (error) {
|
|
|
|
+ // console.error("操作失败:", error);
|
|
|
|
+ // wx.showToast({
|
|
|
|
+ // title: '操作失败,请稍后再试',
|
|
|
|
+ // icon: 'none',
|
|
|
|
+ // });
|
|
|
|
+ // }
|
|
|
|
+ // }
|
|
|
|
+
|
|
// async
|
|
// async
|
|
- getData() {
|
|
|
|
|
|
+ // async getData() {
|
|
|
|
+
|
|
|
|
+ // wx.cloud
|
|
|
|
+ // .uploadFile({
|
|
|
|
+ // cloudPath: "imgs/banner/carousel_1.jpg", // 上传至云端的路径
|
|
|
|
+ // filePath: "image/imgs/carousel_1.jpg" // 小程序临时文件路径,需结合小程序相关 API 获取
|
|
|
|
+ // })
|
|
|
|
+ // .then((res) => {
|
|
|
|
+ // // 返回文件 ID
|
|
|
|
+ // const fileID = res.fileID;
|
|
|
|
+ // console.log("文件 ID:", fileID);
|
|
|
|
+
|
|
|
|
+ // // 下载文件
|
|
|
|
+ // wx.cloud.downloadFile({
|
|
|
|
+ // fileID: fileID,
|
|
|
|
+ // })
|
|
|
|
+ // .then((res) => {
|
|
|
|
+ // const tempFilePath = res.tempFilePath;
|
|
|
|
+ // console.log("临时文件路径:", tempFilePath);
|
|
|
|
+
|
|
|
|
+ // // 获取文件大小
|
|
|
|
+ // wx.getFileInfo({
|
|
|
|
+ // filePath: tempFilePath,
|
|
|
|
+ // })
|
|
|
|
+ // .then((info) => {
|
|
|
|
+ // console.log("文件大小:", info.size, "字节");
|
|
|
|
+ // const fileSizeInBytes = info.size; // 文件大小(字节)
|
|
|
|
+ // const fileSizeInMB = fileSizeInBytes / (1024 * 1024); // 转换为 MB
|
|
|
|
+ // console.log("文件大小:", fileSizeInMB.toFixed(2), "MB");
|
|
|
|
+ // })
|
|
|
|
+ // .catch((err) => {
|
|
|
|
+ // console.error("获取文件大小失败:", err);
|
|
|
|
+ // });
|
|
|
|
+ // })
|
|
|
|
+ // .catch((err) => {
|
|
|
|
+ // console.error("文件下载失败:", err);
|
|
|
|
+ // });
|
|
|
|
+ // });
|
|
// const { data } = await models.login.list({
|
|
// const { data } = await models.login.list({
|
|
// filter: {
|
|
// filter: {
|
|
// where: {}
|
|
// where: {}
|
|
@@ -86,21 +179,31 @@ Page({
|
|
|
|
|
|
// // 返回查询到的数据列表 records 和 总数 total
|
|
// // 返回查询到的数据列表 records 和 总数 total
|
|
// console.log(data);
|
|
// console.log(data);
|
|
- // const { data } = await models.login.create({
|
|
|
|
- // data: {
|
|
|
|
- // name: "王五", // 名字
|
|
|
|
- // },
|
|
|
|
|
|
+
|
|
|
|
+ // const { data } = await models.file_manage.get({
|
|
|
|
+ // filter: {
|
|
|
|
+ // where: {
|
|
|
|
+ // $and: [
|
|
|
|
+ // {
|
|
|
|
+ // _id: {
|
|
|
|
+ // $eq: 'BT7HKJ5Z2Y', // 推荐传入_id数据标识进行操作
|
|
|
|
+ // },
|
|
|
|
+ // },
|
|
|
|
+ // ]
|
|
|
|
+ // }
|
|
|
|
+ // },
|
|
// // envType: pre 体验环境, prod 正式环境
|
|
// // envType: pre 体验环境, prod 正式环境
|
|
// envType: "prod",
|
|
// envType: "prod",
|
|
// });
|
|
// });
|
|
|
|
|
|
// // 返回创建的数据 id
|
|
// // 返回创建的数据 id
|
|
// console.log(data);
|
|
// console.log(data);
|
|
|
|
+ // { id: "7d8ff72c665eb6c30243b6313aa8539e"}
|
|
|
|
|
|
// db.collection("homelist").get().then(res => {
|
|
// db.collection("homelist").get().then(res => {
|
|
// console.log(res);
|
|
// console.log(res);
|
|
// }).catch(err => {
|
|
// }).catch(err => {
|
|
// console.log(err);
|
|
// console.log(err);
|
|
// })
|
|
// })
|
|
- },
|
|
|
|
|
|
+ // },
|
|
})
|
|
})
|