第一次提交

main
xuan 1 month ago
parent 21220c56b2
commit 672164d1fe

@ -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,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,16 @@
{
"pages": [
"pages/index/index",
"pages/home_page/home_page",
"pages/logs/logs"
],
"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,124 @@
// pages/home_page/home_page.js
Page({
/**
* 页面的初始数据
*/
data: {
course: [
{name: "数据结构",num: 1},
{name: "操作系统",num: 2},
{name: "本质结构",num: 3},
],
},
add_classes(e){
const course = this.data.course
console.log(e)
wx.showModal({
title: '添加',
editable: true,
placeholderText: "班级名称",
complete: (res) => {
if (res.cancel) {
}
if (res.confirm) {
if(res.content != ""){
let len = course.length
let new_num = course[len-1]['num']+1
course.push({name: res.content,num: new_num})
}
console.log(course)
this.setData({
course: course
})
}
}
})
},
del_classes(e){
const course = this.data.course
wx.showModal({
title: '删除',
editable: true,
placeholderText: "班级编号",
complete: (res) => {
if (res.cancel) {
}
if (res.confirm) {
for(let i=0,ILen=course.length;i<ILen;i++){
if(course[i]['num'] == res.content){
course.splice(i,1)
ILen--
i--
}
}
console.log(course)
this.setData({
course: course
})
}
}
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})

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

@ -0,0 +1,59 @@
<!--pages/home_page/home_page.wxml-->
<view class="container1">
<view class="title-block">我的创建</view>
<view class="controlBtn-layout">
<view>
<button class="add-btn" bindtap="del_classes">删除</button>
</view>
<view>
<button class="add-btn" bindtap="add_classes">添加</button>
</view>
</view>
<scroll-view class="middle-block" scroll-y="true">
<block wx:for="{{course}}" wx:key="id">
<view class="up-composition">
<image class="picture-style" src="./img/3.jpg" mode="aspectFill"/>
<label class="name-text">{{item.name}} | {{item.num}}</label>
<view class="classBtn-layout">
<button class="class-btn">上课</button>
<button class="class-btn">导入</button>
</view>
</view>
<view class="down-composition">
<view>
<button class="arrow-btn">修改</button>
</view>
<view>
<image class="arrow-icon" src="./img/箭头.png" mode="aspectFill"/>
</view>
</view>
</block>
</scroll-view>
<view class="tip-block">
<view>
<button class="icon-layout">
<view>
<image class="icon" src="./img/创建.png" mode="aspectFill"/>
<label class="icon-text">创建</label>
</view>
</button>
</view>
<view class="tip-line"></view>
<view>
<button class="icon-layout">
<view>
<image class="icon" src="./img/个人中心.png" mode="aspectFill"/>
<label class="icon-text">个人</label>
</view>
</button>
</view>
</view>
</view>

@ -0,0 +1,153 @@
/* pages/home_page/home_page.wxss */
.container1{
display: flex;
flex-direction: column;
align-items: center;
justify-content: space-around;
}
.title-block{
/* 设置尺寸色块 */
height: 50px;
width: 100%;
background-color: lightskyblue;
/* 制作文本样式 */
line-height: 50px;
text-align: center;
font-size: x-large;
font-weight: 600;
color: white;
letter-spacing: 3px;
/* 编辑位置样式 */
margin-top: 0px;
top: 0px;
/* position: fixed; */ /*如果固定页面则不算在布局里面*/
}
.controlBtn-layout{
width: 100%;
display: flex;
flex-direction: row;
justify-content: space-between;
}
.middle-block{
width: 80%;
height: 540px;
display: flex;
flex-direction: column;
align-items: center;
}
.up-composition{
width: 100%;
height: 50px;
border-radius: 15px;
background-color: lightblue;
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
margin: 5px;
}
.down-composition{
width: 100%;
display: flex;
flex-direction: row;
justify-content: flex-end;
align-items: center;
}
.arrow-icon{
height: 10px;
width: 10px;
}
.arrow-btn{
width: 30px !important;
padding: 1px;
background-color: white;
font-size: small;
}
.picture-style{
height: 30px;
width: 30px;
margin-right: 20px;
border: 1px solid gray;
margin-left: 25px;
}
.name-text{
font-size: large;
font-weight: 600;
color: white;
/* margin-right: 60px; */
}
.classBtn-layout{
height: 80%;
display: flex;
flex-direction: column;
align-items: center;
margin-right: 25px;
}
.class-btn{
width: 60px !important;
height: 30px;
display: flex;
justify-content: center;
align-items: center;
line-height: 0px;
padding: 1px 1px 1px 10px; /*文本左边要有padding,与letter-spacing抵消*/
text-align: center;
margin: 2px;
font-size: 11px;
letter-spacing: 10px;
}
.add-btn{
width: 110px !important;
line-height: 50px;
text-align: center;
font-size: x-large;
font-weight: 600;
letter-spacing: 6px;
background-color: white;
/* position: fixed; */
}
.tip-block{
width: 100%;
height: 90px;
background-color: lightskyblue;
line-height: 90px;
display: flex;
flex-direction: row;
justify-content: space-around;
/* align-items: center; */
/* margin-top: 700px; */
bottom: 0px; /*置于底部之前需要设置一个标尺先这里的标尺线是line-height*/
position: fixed;
}
.icon-layout{
height: 80px;
width: 90px !important;
background-color: lightskyblue;
display: flex;
flex-direction: column;
align-items: center;
}
.icon{
height: 35px;
width: 35px;
}
.icon-text{
height: 30px;
line-height: 30px;
color: black;
letter-spacing: 2px;
}
.tip-line{
height: 80%;
width: 0.5px;
background-color: gray;
margin-top: 5px;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.5 KiB

@ -0,0 +1,58 @@
// index.js
const defaultAvatarUrl = 'https://mmbiz.qpic.cn/mmbiz/icTdbqWNOwNRna42FI242Lcia07jQodd2FJGIYQfG0LAJGFxM4FbnQP6yfMxBgJ0F3YRqJCJ1aPAK2dQagdusBZg/0'
Page({
data: {
motto: 'Hello World',
userInfo: {
avatarUrl: defaultAvatarUrl,
nickName: '',
},
hasUserInfo: false,
canIUseGetUserProfile: wx.canIUse('getUserProfile'),
canIUseNicknameComp: wx.canIUse('input.type.nickname'),
},
bindViewTap() {
wx.navigateTo({
url: '../logs/logs'
})
},
onChooseAvatar(e) {
const { avatarUrl } = e.detail
const { nickName } = this.data.userInfo
this.setData({
"userInfo.avatarUrl": avatarUrl,
hasUserInfo: nickName && avatarUrl && avatarUrl !== defaultAvatarUrl,
})
},
onInputChange(e) {
const nickName = e.detail.value
const { avatarUrl } = this.data.userInfo
this.setData({
"userInfo.nickName": nickName,
hasUserInfo: nickName && avatarUrl && avatarUrl !== defaultAvatarUrl,
})
},
getUserProfile(e) {
// 推荐使用wx.getUserProfile获取用户信息开发者每次通过该接口获取用户个人信息均需用户确认开发者妥善保管用户快速填写的头像昵称避免重复弹窗
wx.getUserProfile({
desc: '展示用户信息', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
success: (res) => {
console.log(res)
this.setData({
userInfo: res.userInfo,
hasUserInfo: true
})
}
})
},
TapLoginButton(e){
if(this.data.hasUserInfo)
{
this.pageRouter.navigateTo({
url: '../home_page/home_page'
})
}
},
})

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

@ -0,0 +1,28 @@
<!--index.wxml-->
<scroll-view class="scrollarea" scroll-y type="list">
<view class="container">
<view class="userinfo">
<block wx:if="{{canIUseNicknameComp && !hasUserInfo}}">
<button class="avatar-wrapper" open-type="chooseAvatar" bind:chooseavatar="onChooseAvatar">
<!--open-type="chooseAvatar" 点击button后会开始获取用户头像信息 -->
<image class="avatar" src="{{userInfo.avatarUrl}}"></image>
</button>
<view class="nickname-wrapper">
<text class="nickname-label">昵称</text>
<input type="nickname" class="nickname-input" placeholder="请输入昵称" bind:change="onInputChange" />
</view>
</block>
<block wx:elif="{{!hasUserInfo}}">
<button wx:if="{{canIUseGetUserProfile}}" bindtap="getUserProfile"> 获取头像昵称 </button>
<view wx:else> 请使用2.10.4及以上版本基础库 </view>
</block>
<block wx:else>
<image bindtap="bindViewTap" class="userinfo-avatar" src="{{userInfo.avatarUrl}}" mode="cover"></image>
<text class="userinfo-nickname">{{userInfo.nickName}}</text>
</block>
</view>
<view class="usermotto">
<button type="primary" bindtap="TapLoginButton">登录</button>
</view>
</view>
</scroll-view>

@ -0,0 +1,67 @@
/**index.wxss**/
page {
height: 100vh;
display: flex;
flex-direction: column;
}
.scrollarea {
flex: 1;
overflow-y: hidden;
}
.userinfo {
display: flex;
flex-direction: column;
align-items: center;
color: #aaa;
width: 80%;
}
.userinfo-avatar {
overflow: hidden;
width: 128rpx;
height: 128rpx;
margin: 20rpx;
border-radius: 50%;
}
.userinfo-nickname{
margin-top: 0px;
font-size: x-large;
}
.usermotto {
margin-bottom: 100px;
}
.avatar-wrapper {
padding: 0;
width: 56px !important;
border-radius: 8px;
margin-top: 40px;
margin-bottom: 40px;
}
.avatar {
display: block;
width: 56px;
height: 56px;
}
.nickname-wrapper {
display: flex;
width: 100%;
padding: 16px;
box-sizing: border-box;
border-top: .5px solid rgba(0, 0, 0, 0.1);
border-bottom: .5px solid rgba(0, 0, 0, 0.1);
color: black;
}
.nickname-label {
width: 105px;
}
.nickname-input {
flex: 1;
}

@ -0,0 +1,18 @@
// logs.js
const util = require('../../utils/util.js')
Page({
data: {
logs: []
},
onLoad() {
this.setData({
logs: (wx.getStorageSync('logs') || []).map(log => {
return {
date: util.formatTime(new Date(log)),
timeStamp: log
}
})
})
}
})

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

@ -0,0 +1,6 @@
<!--logs.wxml-->
<scroll-view class="scrollarea" scroll-y type="list">
<block wx:for="{{logs}}" wx:key="timeStamp" wx:for-item="log">
<view class="log-item">{{index + 1}}. {{log.date}}</view>
</block>
</scroll-view>

@ -0,0 +1,16 @@
page {
height: 100vh;
display: flex;
flex-direction: column;
}
.scrollarea {
flex: 1;
overflow-y: hidden;
}
.log-item {
margin-top: 20rpx;
text-align: center;
}
.log-item:last-child {
padding-bottom: env(safe-area-inset-bottom);
}

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

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

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

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