master
wbb 2 years ago
parent 679202168e
commit 353225e8ea

@ -0,0 +1,31 @@
/*
* Eslint config file
* Documentation: https://eslint.org/docs/user-guide/configuring/
* Install the Eslint extension before using this feature.
*/
module.exports = {
env: {
es6: true,
browser: true,
node: true,
},
ecmaFeatures: {
modules: true,
},
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module',
},
globals: {
wx: true,
App: true,
Page: true,
getCurrentPages: true,
getApp: true,
Component: true,
requirePlugin: true,
requireMiniProgram: true,
},
// extends: 'eslint:recommended',
rules: {},
}

@ -0,0 +1,12 @@
# 云开发 quickstart
这是云开发的快速启动指引,其中演示了如何上手使用云开发的三大基础能力:
- 数据库:一个既可在小程序前端操作,也能在云函数中读写的 JSON 文档型数据库
- 文件存储:在小程序前端直接上传/下载云端文件,在云开发控制台可视化管理
- 云函数:在云端运行的代码,微信私有协议天然鉴权,开发者只需编写业务逻辑代码
## 参考文档
- [云开发文档](https://developers.weixin.qq.com/miniprogram/dev/wxcloud/basis/getting-started.html)

@ -0,0 +1,20 @@
// app.js
App({
onLaunch: function () {
if (!wx.cloud) {
console.error('请使用 2.2.3 或以上的基础库以使用云能力');
} else {
wx.cloud.init({
// env 参数说明:
// env 参数决定接下来小程序发起的云开发调用wx.cloud.xxx会默认请求到哪个云环境的资源
// 此处请填入环境 ID, 环境 ID 可打开云控制台查看
// 如不填则使用默认环境(第一个创建的环境)
// env: 'my-env-id',
traceUser: true,
});
}
this.globalData = {};
}
});

@ -0,0 +1,52 @@
{
"pages": [
"pages/index/index",
"pages/fourm/fourm",
"pages/cart/cart",
"pages/usercenter/usercenter",
"pages/detail/detail"
],
"tabBar": {
"custom": true,
"backgroundColor": "#ffffff",
"borderStyle": "black",
"list": [
{
"pagePath": "pages/index/index",
"text": "首页",
"iconPath": "/images/home.png",
"selectedIconPath": "/images/home-active.png"
},
{
"pagePath": "pages/fourm/fourm",
"text": "论坛",
"iconPath": "/images/message.png",
"selectedIconPath": "/images/message-active.png"
},
{
"pagePath": "pages/cart/cart",
"text": "购物车",
"iconPath": "/images/message.png",
"selectedIconPath": "/images/message-active.png"
},
{
"pagePath": "pages/usercenter/usercenter",
"text": "我的",
"iconPath": "/images/message.png",
"selectedIconPath": "/images/message-active.png"
}
]
},
"window": {
"backgroundColor": "#F6F6F6",
"backgroundTextStyle": "light",
"navigationBarBackgroundColor": "#F6F6F6",
"navigationBarTitleText": "节时不节食",
"navigationBarTextStyle": "black"
},
"sitemapLocation": "sitemap.json",
"style": "v2"
}

@ -0,0 +1,30 @@
/**app.wxss**/
.container {
height: 100%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: space-between;
padding: 200rpx 0;
box-sizing: border-box;
}
button {
background: initial;
}
button:focus{
outline: 0;
}
button::after{
border: none;
}
page {
background: #f6f6f6;
display: flex;
flex-direction: column;
justify-content: flex-start;
}

@ -0,0 +1,45 @@
Component({
data: {
selected: 0,
color: "#7A7E83",
selectedColor: "#3cc51f",
"list": [
{
"pagePath": "/pages/index/index",
"text": "首页",
"iconPath": "/images/home.png",
"selectedIconPath": "/images/home-active.png"
},
{
"pagePath": "/pages/fourm/fourm",
"text": "论坛",
"iconPath": "/images/message.png",
"selectedIconPath": "/images/message-active.png"
},
{"pagePath": "/pages/cart/cart",
"text": "购物车",
"iconPath": "/images/message.png",
"selectedIconPath": "/images/message-active.png"
},
{
"pagePath": "/pages/usercenter/usercenter",
"text": "我的",
"iconPath": "/images/message.png",
"selectedIconPath": "/images/message-active.png"
}
]
},
attached() {
},
methods: {
switchTab(e) {
const data = e.currentTarget.dataset
const url = data.path
wx.switchTab({url})
this.setData({
selected: data.index
})
}
}
})

@ -0,0 +1,3 @@
{
"component": true
}

@ -0,0 +1,8 @@
<!--miniprogram/custom-tab-bar/index.wxml-->
<cover-view class="tab-bar">
<cover-view class="tab-bar-border"></cover-view>
<cover-view wx:for="{{list}}" wx:key="index" class="tab-bar-item" data-path="{{item.pagePath}}" data-index="{{index}}" bindtap="switchTab">
<cover-image src="{{selected === index ? item.selectedIconPath : item.iconPath}}"></cover-image>
<cover-view style="color: {{selected === index ? selectedColor : color}}">{{item.text}}</cover-view>
</cover-view>
</cover-view>

@ -0,0 +1,38 @@
.tab-bar {
position: fixed;
bottom: 0;
left: 0;
right: 0;
height: 48px;
background: white;
display: flex;
padding-bottom: env(safe-area-inset-bottom);
}
.tab-bar-border {
background-color: rgba(0, 0, 0, 0.33);
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 1px;
transform: scaleY(0.5);
}
.tab-bar-item {
flex: 1;
text-align: center;
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
}
.tab-bar-item cover-image {
width: 27px;
height: 27px;
}
.tab-bar-item cover-view {
font-size: 10px;
}

@ -0,0 +1,6 @@
const envList = [{"envId":"cloud1-8g5wmepxce8a3b8a","alias":"cloud1"}]
const isMac = false
module.exports = {
envList,
isMac
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 KiB

@ -0,0 +1,66 @@
// pages/cart/cart.js
Page({
/**
* 页面的初始数据
*/
data: {
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})

@ -0,0 +1,3 @@
{
"usingComponents": {}
}

@ -0,0 +1,2 @@
<!--pages/cart/cart.wxml-->
<text>pages/cart/cart.wxml</text>

@ -0,0 +1 @@
/* pages/cart/cart.wxss */

@ -0,0 +1,106 @@
// pages/detail/detail.js
const db = wx.cloud.database({});
const cont = db.collection('food');
Page({
/**
* 页面的初始数据
*/
data: {
detailObj: {},
index: null,
list:[],
clockresult:[],
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.clockData()
let id =options.id
cont.doc(id).get()
.then(res => {
console.log('22')
console.log('食物详情页', res)
this.setData({
detailObj: res.data
})
})
},
// 渲染数据
clockData() {
var _this = this
wx.request({
url:'/pages/index/index'+ this.data.index, //url this.data.index是id
method: 'GET', //请求方式
header: {
'content-type': 'application/json'
}, // 设置请求的 header
success: function (res) {
let list = [];
let box = (res.data.obj.assignDates === null) ? [] : res.data.obj.assignDates.substring(0, res.data.obj.assignDates.length - 1).replace(/,/g, " ")
//这里的效果跟上面的是一样的效果就是不用foeEach循环了就是另一种方法这个较麻烦一点
list.push((box.length <= 0) ? [] : box.split(' '))
_this.setData({
list,
clockresult: res.data.obj,
})
},
fail: function () {
app.consoleLog("请求数据失败");
},
complete: function () {
}
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})

@ -0,0 +1,3 @@
{
"usingComponents": {}
}

@ -0,0 +1,3 @@
<view class="container">
<view>{{clockresult.food_name}}</view>
</view>

@ -0,0 +1 @@
/* pages/detail/detail.wxss */

@ -0,0 +1,66 @@
// pages/fourm/fourm.js
Page({
/**
* 页面的初始数据
*/
data: {
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})

@ -0,0 +1,3 @@
{
"usingComponents": {}
}

@ -0,0 +1,2 @@
<!--pages/fourm/fourm.wxml-->
<text>pages/fourm/fourm.wxml</text>

@ -0,0 +1 @@
/* pages/fourm/fourm.wxss */

@ -0,0 +1,120 @@
const db = wx.cloud.database({});
const cont = db.collection('food');
const $ = db.command.aggregate
Page({
/**
* 页面的初始数据
*/
data: {
foodlist:[],
tabs: ['主食', '甜品', '小吃','吃得快','辣','甜','清淡'],
cateList:[]
},
tabSelect:function(e){
var current = e.currentTarget.dataset.id
this.setData({
current:current
})
},
//分类
geCateListe(){
db.collection('food').aggregate()
.group({
_id: '$tab'
})
.end()
.then(res => {
console.log('食物列表', res)
this.setData({
foodList: res.list
})
})
},
//跳转详情页
toDetail: function (event) {
// 获取 event 事件对象
// 获取点击对应的下标
const index = event.currentTarget.dataset.id
console.log(event)
//抓取id进行赋
//wx.navigateTo 会触发页面隐藏onHide
console.log('11111')
wx.navigateTo({
url:'/pages/detail/detail?id='+ index,
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
var _this = this;
const db = wx.cloud.database({
//这个是环境ID不是环境名称
env: 'cloud1-8g5wmepxce8a3b8a'
})
//2、开始查询数据了 news对应的是集合的名称
db.collection('food').get({
//如果查询成功的话
success: res => {
console.log(res.data)
//这一步很重要给ne赋值没有这一步的话前台就不会显示值
this.setData({
foodlist: res.data
})
}
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})

@ -0,0 +1,5 @@
{
"usingComponents": {
}
}

@ -0,0 +1,38 @@
<view class="imagesize">
<image src=" /images/logo.jpg" style="width:350px" class="in-select2" mode="widthFix">
</image>
</view>
<navigator class="imagesize">
<image src="/images/perfer.jpg" style="width:440px" class="in-select" mode="widthFix"></image>
</navigator>
<navigator class="imagesize">
<image src="/images/zhuanpang.jpg" style="width:440px" class="in-select" mode="widthFix"></image>
</navigator>
<view class="divLine"></view>
<!-- 导航栏 -->
<scroll-view class="navbar" scroll-x="true" scroll-left="{{tabs}}" >
<view class="nav-item" wx:for="{{tabs}}" wx:key="id" bindtap="tabSelect" >
<view class="nav-text {{item==tabCur?'tab-on':''}}">{{item}}</view>
</view>
</scroll-view>
<view class="foodlist">
<view class='a' wx:for="{{foodlist}}"><!--wx:for是微信数据绑定的一种方式该数组有多少数据就显示多少个view-->
<!--item就相当于数组名+下标的结合体,适用于调用数组所有数据-->
<view bindtap="toDetail" id="{{item.id}}">
<view class='img'>
<image src="{{item.url}}" ></image>
</view>
<view class='info'>
<view class='title'>{{item.food_name}}</view>
<view class='price'>{{item.price}}</view>
<view class='num'>{{item.food_shop}}</view>
</view>
</view>
<view class='clear'></view>
</view>
</view>

@ -0,0 +1,162 @@
page {
background: #ffffff;
width: 100%;
height: 100%;
}
/*分割线样式*/
.divLine{
background: #E0E3DA;
width: 100%;
height: 5rpx;
}
.navbar {
width: 100%;
height: 90rpx;
/* 文本不换行 */
white-space: nowrap;
display: flex;
box-sizing: border-box;
border-bottom: 1rpx solid #eee;
background: #fff;
align-items: center;
/* 固定在顶部 */
}
.nav-item {
line-height: 60rpx;
background-color: #f7f7f7;
padding-left: 25rpx;
padding-right: 25rpx;
height: 100%;
display: inline-table;
/* 普通文字大小 */
font-size: 28rpx;
}
.nav-text {
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
letter-spacing: 4rpx;
box-sizing: border-box;
}
.tab-on {
color: #000080;
/* 选中放大 */
font-size: 38rpx !important;
font-weight: 600;
border-bottom: 4rpx solid #000080 !important;
}
.P_input {
position: relative;
}
.P_input input {
background: white;
border-radius: 40rpx;
width: 90%;
padding: 10rpx 0;
padding-left: 40rpx;
margin: 40rpx 0 5% 20rpx;
}
.P_input image {
position: absolute;
z-index: 999999;
width: 36rpx;
height: 36rpx;
padding: 6rpx 20rpx;
right: 20rpx;
top: 12rpx;
}
.imagesize {
display: flex;
justify-content: center;
align-items: center;
width: 650rpx;
margin-left: 50rpx;
margin-right: 50rpx;
}
.imagesize select {
height: 50rpx;
width: 350rpx;
}
.imagesize select2 {
height: 180rpx;
width: 350rpx;
}
.foodist{
margin-top:10px;
}
.foodlist .a .img{
float:left;
width:40%;
height:100%;
}
.foodlist .a .img image{
width:200rpx;
height:200rpx;
}
.foodlist .a .info{
width:59%;
float:right;
height:100px;
position:relative;
}
.foodlist .a .info .title{
color:#333;
margin-left:10px;
font-size: 15px;
}
.foodlist .a .info .price{
color:#FF2727;
margin-left:10px;
margin-top:10px;
font-size:15px;
}
.foodlist .a .info .num{
position: absolute;
left:0px;
bottom:10px;
color:#747474;
margin-left:10px;
font-size:15px;
}
.clear{
clear: both;
overflow: hidden;
}
navigator{
display:inline;
}
.nav {
position: fixed;
background: white;
color: #353535;
z-index: 999999;
max-height: 94rpx;
width: 100%;
}
.scroll-view-containner{
display: flex;
text-align: center;
}

@ -0,0 +1,66 @@
// pages/usercenter/usercenter.js
Page({
/**
* 页面的初始数据
*/
data: {
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})

@ -0,0 +1,3 @@
{
"usingComponents": {}
}

@ -0,0 +1,2 @@
<!--pages/usercenter/usercenter.wxml-->
<text>pages/usercenter/usercenter.wxml</text>

@ -0,0 +1 @@
/* pages/usercenter/usercenter.wxss */

@ -0,0 +1,79 @@
{
"miniprogramRoot": "",
"cloudfunctionRoot": "cloudfunctions/",
"setting": {
"urlCheck": true,
"es6": true,
"enhance": true,
"postcss": true,
"preloadBackgroundData": false,
"minified": true,
"newFeature": true,
"coverView": true,
"nodeModules": false,
"autoAudits": false,
"showShadowRootInWxmlPanel": true,
"scopeDataCheck": false,
"uglifyFileName": false,
"checkInvalidKey": true,
"checkSiteMap": true,
"uploadWithSourceMap": true,
"compileHotReLoad": false,
"lazyloadPlaceholderEnable": false,
"useMultiFrameRuntime": true,
"useApiHook": true,
"useApiHostProcess": true,
"babelSetting": {
"ignore": [],
"disablePlugins": [],
"outputPath": ""
},
"enableEngineNative": false,
"useIsolateContext": true,
"userConfirmedBundleSwitch": false,
"packNpmManually": false,
"packNpmRelationList": [],
"minifyWXSS": true,
"disableUseStrict": false,
"showES6CompileOption": false,
"useCompilerPlugins": false,
"minifyWXML": true
},
"appid": "wxcc745ea897810e52",
"projectname": "quickstart-wx-cloud",
"libVersion": "2.14.1",
"cloudfunctionTemplateRoot": "cloudfunctionTemplate/",
"condition": {
"search": {
"list": []
},
"conversation": {
"list": []
},
"plugin": {
"list": []
},
"game": {
"list": []
},
"miniprogram": {
"list": [
{
"id": -1,
"name": "db guide",
"pathName": "pages/databaseGuide/databaseGuide"
}
]
}
},
"srcMiniprogramRoot": "miniprogram/",
"compileType": "miniprogram",
"packOptions": {
"ignore": [],
"include": []
},
"editorSetting": {
"tabIndent": "insertSpaces",
"tabSize": 2
}
}

@ -0,0 +1,60 @@
{
"setting": {
"compileHotReLoad": true
},
"condition": {
"miniprogram": {
"list": [
{
"name": "db guide",
"pathName": "pages/databaseGuide/databaseGuide",
"query": ""
},
{
"name": "pages/getOpenId/index",
"pathName": "pages/getOpenId/index",
"query": "",
"scene": null
},
{
"name": "pages/deployService/index",
"pathName": "pages/deployService/index",
"query": "",
"scene": null
},
{
"name": "pages/selectRecord/index",
"pathName": "pages/selectRecord/index",
"query": "",
"scene": null
},
{
"name": "pages/sumRecordResult/index",
"pathName": "pages/sumRecordResult/index",
"query": "",
"scene": null
},
{
"name": "pages/updateRecord/index",
"pathName": "pages/updateRecord/index",
"query": "",
"scene": null
},
{
"name": "pages/updateRecordResult/index",
"pathName": "pages/updateRecordResult/index",
"query": "",
"scene": null
},
{
"name": "pages/updateRecordSuccess/index",
"pathName": "pages/updateRecordSuccess/index",
"query": "",
"scene": null
}
]
}
},
"description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
"projectname": "food"
}

@ -0,0 +1,7 @@
{
"desc": "关于本文件的更多信息,请参考文档 https://developers.weixin.qq.com/miniprogram/dev/framework/sitemap.html",
"rules": [{
"action": "allow",
"page": "*"
}]
}

@ -0,0 +1 @@
"D:\小程序\微信web开发者工具\cli.bat" cloud functions deploy --e cloud1-8g5wmepxce8a3b8a --n quickstartFunctions --r --project "D:\桌面\大三\软工课设\food" --report_first --report
Loading…
Cancel
Save