diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 0000000..115cc02 --- /dev/null +++ b/.eslintrc.js @@ -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: {}, +} diff --git a/5.png b/5.png new file mode 100644 index 0000000..073fc71 Binary files /dev/null and b/5.png differ diff --git a/README.md b/README.md index 501c445..55c1469 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,2 @@ # zuoye5 - +![](./5.png) diff --git a/app.js b/app.js new file mode 100644 index 0000000..1ed57c4 --- /dev/null +++ b/app.js @@ -0,0 +1,19 @@ +// app.js +App({ + onLaunch() { + // 展示本地存储能力 + const logs = wx.getStorageSync('logs') || [] + logs.unshift(Date.now()) + wx.setStorageSync('logs', logs) + + // 登录 + wx.login({ + success: res => { + // 发送 res.code 到后台换取 openId, sessionKey, unionId + } + }) + }, + globalData: { + userInfo: null + } +}) diff --git a/app.json b/app.json new file mode 100644 index 0000000..2bdaeaa --- /dev/null +++ b/app.json @@ -0,0 +1,14 @@ +{ + "pages": [ + "page/shoplist/shoplist" + ], + "window": { + "navigationBarTextStyle": "black", + "navigationBarTitleText": "Weixin", + "navigationBarBackgroundColor": "#ffffff" + }, + "style": "v2", + "componentFramework": "glass-easel", + "sitemapLocation": "sitemap.json", + "lazyCodeLoading": "requiredComponents" +} diff --git a/app.wxss b/app.wxss new file mode 100644 index 0000000..06c6fc9 --- /dev/null +++ b/app.wxss @@ -0,0 +1,10 @@ +/**app.wxss**/ +.container { + height: 100%; + display: flex; + flex-direction: column; + align-items: center; + justify-content: space-between; + padding: 200rpx 0; + box-sizing: border-box; +} diff --git a/page/shoplist/shoplist.js b/page/shoplist/shoplist.js new file mode 100644 index 0000000..4d27aad --- /dev/null +++ b/page/shoplist/shoplist.js @@ -0,0 +1,122 @@ +// page/shoplist/shoplist.js +Page({ + + /** + * 页面的初始数据 + */ + data: { + shopList:[], + }, + + listData:{ + page:1, + pageSize:10, + total:0 + }, + + onLoad:function(){ + this.getShopList() + }, + + isLoading:false, + + getShopList:function(cb){ + this.isLoading=true + wx.showLoading({ + title: '数据加载中', + }) + wx.request({ + url: 'http://127.0.0.1:3000/data', + method:'GET', + data:{ + page:1,//this.listData.page, + pageSize:10//this.listData.pageSize + }, + success:res=>{ + console.log(res) + this.setData({ + shopList:[...this.data.shopList,...res.data], + }) + this.listData.total=res.header['X-Total-Count']-0 + }, + complete:()=>{ + wx.hideLoading() + this.isLoading=false + cb&&cb() + } + }) + }, + +/** + * 生命周期函数--监听页面加载 + */ + + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady() { + + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow() { + + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide() { + + }, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload() { + + }, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh:function() { + this.setData({ + shopList:[] + }) + this.listData.page=1 + this.listData.total=0 + this.getShopList(()=>{ + wx.stopPullDownRefresh() + }) + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom() { + if(this.listData.page*this.listData.pageSize>=this.listData.total){ + return wx.showToast({ + title: '数据加载完毕!', + icon:'none' + }) + } + if(this.isLoading){ + return + } + ++this.listData.page + this.getShopList(()=>{ + wx.stopPullDownRefresh() + }) + }, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage() { + + } +}) \ No newline at end of file diff --git a/page/shoplist/shoplist.json b/page/shoplist/shoplist.json new file mode 100644 index 0000000..99fce1e --- /dev/null +++ b/page/shoplist/shoplist.json @@ -0,0 +1,7 @@ +{ + "navigationBarTitleText": "美食", + "onReachBottomDistance": 200, + "enablePullDownRefresh": true, + "backgroundColor": "#efefef", + "backgroundTextStyle":"dark" +} \ No newline at end of file diff --git a/page/shoplist/shoplist.wxml b/page/shoplist/shoplist.wxml new file mode 100644 index 0000000..cfb29e4 --- /dev/null +++ b/page/shoplist/shoplist.wxml @@ -0,0 +1,14 @@ + + + + + + + + {{item.name}} + 电话:{{tools.splitPhone(item.phone)}} + 地址:{{item.address}} + 营业时间:{{item.businessHours}} + + + \ No newline at end of file diff --git a/page/shoplist/shoplist.wxss b/page/shoplist/shoplist.wxss new file mode 100644 index 0000000..6aa8197 --- /dev/null +++ b/page/shoplist/shoplist.wxss @@ -0,0 +1,27 @@ +/* pages/shoplist/shoplist.wxss */ +.shop-item { + display: flex; + padding: 15rpx; + border: 1rpx solid #efefef; + border-radius: 8rpx; + margin: 15rpx; + box-shadow: 1rpx 1rpx 15rpx #ddd; +} + +.thumb image { + width: 250rpx; + height: 250rpx; + display: block; + margin-right: 15rpx; +} + +.info { + display: flex; + flex-direction: column; + justify-content: space-around; + font-size: 24rpx; +} + +.shop-title { + font-weight: bold; +} \ No newline at end of file diff --git a/project.config.json b/project.config.json new file mode 100644 index 0000000..bbeb17d --- /dev/null +++ b/project.config.json @@ -0,0 +1,28 @@ +{ + "compileType": "miniprogram", + "libVersion": "trial", + "packOptions": { + "ignore": [], + "include": [] + }, + "setting": { + "coverView": true, + "es6": true, + "postcss": true, + "minified": true, + "enhance": true, + "showShadowRootInWxmlPanel": true, + "packNpmRelationList": [], + "babelSetting": { + "ignore": [], + "disablePlugins": [], + "outputPath": "" + } + }, + "condition": {}, + "editorSetting": { + "tabIndent": "auto", + "tabSize": 2 + }, + "appid": "wx88d20e697c125c57" +} \ No newline at end of file diff --git a/project.private.config.json b/project.private.config.json new file mode 100644 index 0000000..08d4fb3 --- /dev/null +++ b/project.private.config.json @@ -0,0 +1,8 @@ +{ + "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html", + "projectname": "program5", + "setting": { + "compileHotReLoad": true, + "urlCheck": false + } +} \ No newline at end of file diff --git a/sitemap.json b/sitemap.json new file mode 100644 index 0000000..ca02add --- /dev/null +++ b/sitemap.json @@ -0,0 +1,7 @@ +{ + "desc": "关于本文件的更多信息,请参考文档 https://developers.weixin.qq.com/miniprogram/dev/framework/sitemap.html", + "rules": [{ + "action": "allow", + "page": "*" + }] +} \ No newline at end of file diff --git a/utils/tools.wxs b/utils/tools.wxs new file mode 100644 index 0000000..12e0e0e --- /dev/null +++ b/utils/tools.wxs @@ -0,0 +1,12 @@ +function splitPhone(str){ + if(str.length!==11){ + return str + } + var arr=str.split('') + arr.splice(3,0,'-') + arr.splice(8,0,'-') + return arr.join('') +} +module.exports={ + splitPhone:splitPhone +} \ No newline at end of file diff --git a/utils/util.js b/utils/util.js new file mode 100644 index 0000000..764bc2c --- /dev/null +++ b/utils/util.js @@ -0,0 +1,19 @@ +const formatTime = date => { + const year = date.getFullYear() + const month = date.getMonth() + 1 + const day = date.getDate() + const hour = date.getHours() + const minute = date.getMinutes() + const second = date.getSeconds() + + return `${[year, month, day].map(formatNumber).join('/')} ${[hour, minute, second].map(formatNumber).join(':')}` +} + +const formatNumber = n => { + n = n.toString() + return n[1] ? n : `0${n}` +} + +module.exports = { + formatTime +}