本次修改内容

main
fengxue 6 months ago
parent 97b3e9979f
commit 9f9905a1db

@ -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: {},
}

@ -1,2 +1,3 @@
# personal-formation7
![截图](./screen.png)

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

@ -0,0 +1,14 @@
{
"pages": [
"pages/shoplist/shoplist"
],
"window": {
"navigationBarTextStyle": "black",
"navigationBarTitleText": "Weixin",
"navigationBarBackgroundColor": "#ffffff"
},
"style": "v2",
"componentFramework": "glass-easel",
"sitemapLocation": "sitemap.json",
"lazyCodeLoading": "requiredComponents"
}

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

@ -0,0 +1,68 @@
// pages/shoplist/shoplist.js
Page({
/**
* 页面的初始数据
*/
data: {
shopList: [],
},
listDate: {
page: 1,
pageSize: 10,
total: 0
},
getShopList: function (cb) {
this.isLoading = true
wx.showLoading({
title: '数据加载中...'
})
wx.request({
url: 'http://127.0.0.1:3000/data',
method: 'GET',
data: {
page: this.listDate.page,
pageSize: this.listDate.pageSize
},
success: res => {
console.log(res)
this.setData({
shopList: [...this.data.shopList, ...res.data],
})
this.listDate.total = res.header['X-Total-Count'] - 0
},
complete: () => {
wx.hideLoading()
this.isLoading = false
cb && cb()
}
})
},
onLoad: function () {
this.getShopList()
},
onReachBottom: function () {
if (this.listDate.page * this.listDate.pageSize >= this.listDate.total){
return wx.showToast({
title: '数据加载完毕!',
icon: 'none'
})
}
if (this.isLoading) {
return
}
++this.listData.page
this.getShopList()
},
isLoading: false,
onPullDownRefresh: function () {
this.setData({
shopList: []
})
this.listData.page = 1
this.listData.total = 0
this.getShopList(() => {
wx.stopPullDownRefresh()
})
}
})

@ -0,0 +1,8 @@
{
"navigationBarTitleText": "美食",
"onReachBottomDistance": 200,
"enablePullDownRefresh": true,
"backgroundColor": "#efefef",
"backgroundTextStyle": "dark"
}

@ -0,0 +1,12 @@
<view class="shop-item" wx:for="{{ shopList }}" wx:key="id">
<view class="thumb">
<image src="{{ item.image }}" />
</view>
<view class="info">
<text class="shop-title">{{ item.name }}</text>
<text>电话:{{ tools.splitPhone(item.phone) }}</text>
<text>地址:{{ item.address }}</text>
<text>营业时间:{{ item.businessHours }}</text>
</view>
</view>
<wxs src="../../utils/tools.wxs" module="tools"></wxs>

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

@ -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": "wxbd7d6bca05128b6b"
}

@ -0,0 +1,8 @@
{
"description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
"projectname": "program3-3",
"setting": {
"compileHotReLoad": true,
"urlCheck": false
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 381 KiB

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

@ -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
}
Loading…
Cancel
Save