初始化
This commit is contained in:
commit
f9b148ca8a
21
app.js
Normal file
21
app.js
Normal file
@ -0,0 +1,21 @@
|
||||
// app.js
|
||||
const request = require('./utils/http.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
|
||||
}
|
||||
})
|
14
app.json
Normal file
14
app.json
Normal file
@ -0,0 +1,14 @@
|
||||
{
|
||||
"pages": [
|
||||
"pages/index/index"
|
||||
],
|
||||
"window": {
|
||||
"navigationBarTextStyle": "black",
|
||||
"navigationBarTitleText": "Weixin",
|
||||
"navigationBarBackgroundColor": "#ffffff"
|
||||
},
|
||||
"style": "v2",
|
||||
"componentFramework": "glass-easel",
|
||||
"sitemapLocation": "sitemap.json",
|
||||
"lazyCodeLoading": "requiredComponents"
|
||||
}
|
10
app.wxss
Normal file
10
app.wxss
Normal file
@ -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;
|
||||
}
|
23
components/empty/empty.js
Normal file
23
components/empty/empty.js
Normal file
@ -0,0 +1,23 @@
|
||||
// components/empty/empty.js
|
||||
Component({
|
||||
/**
|
||||
* 组件的属性列表
|
||||
*/
|
||||
properties: {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 组件的初始数据
|
||||
*/
|
||||
data: {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 组件的方法列表
|
||||
*/
|
||||
methods: {
|
||||
|
||||
}
|
||||
})
|
4
components/empty/empty.json
Normal file
4
components/empty/empty.json
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {}
|
||||
}
|
5
components/empty/empty.wxml
Normal file
5
components/empty/empty.wxml
Normal file
@ -0,0 +1,5 @@
|
||||
<!--components/empty/empty.wxml-->
|
||||
<view class="data-empty">
|
||||
<image src="/images/ic_empty_data.png" mode="scaleToFill"></image>
|
||||
<text class="hint">暂无数据</text>
|
||||
</view>
|
24
components/empty/empty.wxss
Normal file
24
components/empty/empty.wxss
Normal file
@ -0,0 +1,24 @@
|
||||
/* components/empty/empty.wxss */
|
||||
.data-empty {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
text-align: center;
|
||||
align-self: center;
|
||||
|
||||
position: fixed;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translateX(-50%)translateY(-50%);
|
||||
}
|
||||
|
||||
.data-empty image {
|
||||
width: 180rpx;
|
||||
height: 120rpx;
|
||||
}
|
||||
|
||||
.data-empty .hint {
|
||||
margin-top: 30rpx;
|
||||
font-size: 32rpx;
|
||||
}
|
23
components/loading/pageloading.js
Normal file
23
components/loading/pageloading.js
Normal file
@ -0,0 +1,23 @@
|
||||
// components/loading/pageloading.js
|
||||
Component({
|
||||
/**
|
||||
* 组件的属性列表
|
||||
*/
|
||||
properties: {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 组件的初始数据
|
||||
*/
|
||||
data: {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 组件的方法列表
|
||||
*/
|
||||
methods: {
|
||||
|
||||
}
|
||||
})
|
4
components/loading/pageloading.json
Normal file
4
components/loading/pageloading.json
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {}
|
||||
}
|
5
components/loading/pageloading.wxml
Normal file
5
components/loading/pageloading.wxml
Normal file
@ -0,0 +1,5 @@
|
||||
<!--components/loading/pageloading.wxml-->
|
||||
<view class="page-loading-box">
|
||||
<image src="/images/loading-small.gif" mode="scaleToFill"></image>
|
||||
<view class="text">加载中...</view>
|
||||
</view>
|
24
components/loading/pageloading.wxss
Normal file
24
components/loading/pageloading.wxss
Normal file
@ -0,0 +1,24 @@
|
||||
/* components/loading/pageloading.wxss */
|
||||
.page-loading-box {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
/* background: rgba(255, 255, 255, 1); */
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
z-index: 99;
|
||||
}
|
||||
|
||||
.page-loading-box image {
|
||||
width: 128rpx;
|
||||
height: 128rpx;
|
||||
}
|
||||
|
||||
.page-loading-box .text {
|
||||
margin-top: 20rpx;
|
||||
font-size: 28rpx;
|
||||
}
|
30
components/loadmore/loading-more.js
Normal file
30
components/loadmore/loading-more.js
Normal file
@ -0,0 +1,30 @@
|
||||
// components/loadmore/loading-more.js
|
||||
Component({
|
||||
/**
|
||||
* 组件的属性列表
|
||||
*/
|
||||
properties: {
|
||||
isShowloading: true,
|
||||
loadingTxt: "加载中..."
|
||||
},
|
||||
|
||||
/**
|
||||
* 组件的初始数据
|
||||
*/
|
||||
data: {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 组件的方法列表
|
||||
*/
|
||||
methods: {
|
||||
|
||||
},
|
||||
observers: {
|
||||
'isShowloading,loadingTxt': function (ss, sss) {
|
||||
console.log(ss)
|
||||
console.log(sss)
|
||||
}
|
||||
}
|
||||
})
|
4
components/loadmore/loading-more.json
Normal file
4
components/loadmore/loading-more.json
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {}
|
||||
}
|
5
components/loadmore/loading-more.wxml
Normal file
5
components/loadmore/loading-more.wxml
Normal file
@ -0,0 +1,5 @@
|
||||
<!--components/loadmore/loading-more.wxml-->
|
||||
<view class="loading-box">
|
||||
<image src="/images/loading.gif" wx:if="{{isShowloading}}"></image>
|
||||
<view class="loading-content">{{loadingTxt}}</view>
|
||||
</view>
|
20
components/loadmore/loading-more.wxss
Normal file
20
components/loadmore/loading-more.wxss
Normal file
@ -0,0 +1,20 @@
|
||||
/* components/loadmore/loading-more.wxss */
|
||||
|
||||
.loading-box {
|
||||
width: 100%;
|
||||
height: 80rpx;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
font-size: 35rpx;
|
||||
}
|
||||
|
||||
.loading-box image {
|
||||
width: 40rpx;
|
||||
height: 40rpx;
|
||||
}
|
||||
|
||||
.loading-content {
|
||||
margin-left: 20rpx;
|
||||
}
|
56
pages/index/index.js
Normal file
56
pages/index/index.js
Normal file
@ -0,0 +1,56 @@
|
||||
// index.js
|
||||
const defaultAvatarUrl = 'https://mmbiz.qpic.cn/mmbiz/icTdbqWNOwNRna42FI242Lcia07jQodd2FJGIYQfG0LAJGFxM4FbnQP6yfMxBgJ0F3YRqJCJ1aPAK2dQagdusBZg/0'
|
||||
var app = getApp();
|
||||
|
||||
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
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
})
|
4
pages/index/index.json
Normal file
4
pages/index/index.json
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"usingComponents": {
|
||||
}
|
||||
}
|
6
pages/index/index.wxml
Normal file
6
pages/index/index.wxml
Normal file
@ -0,0 +1,6 @@
|
||||
<!--index.wxml-->
|
||||
<scroll-view class="scrollarea" scroll-y type="list">
|
||||
<view class="container">
|
||||
<image src="/imgs/ss.png" />
|
||||
</view>
|
||||
</scroll-view>
|
62
pages/index/index.wxss
Normal file
62
pages/index/index.wxss
Normal file
@ -0,0 +1,62 @@
|
||||
/**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%;
|
||||
}
|
||||
|
||||
.usermotto {
|
||||
margin-top: 200px;
|
||||
}
|
||||
|
||||
.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;
|
||||
}
|
28
project.config.json
Normal file
28
project.config.json
Normal file
@ -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": "wx501e9ce64f25c418"
|
||||
}
|
7
project.private.config.json
Normal file
7
project.private.config.json
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
"description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
|
||||
"projectname": "gov_propagandize",
|
||||
"setting": {
|
||||
"compileHotReLoad": true
|
||||
}
|
||||
}
|
7
sitemap.json
Normal file
7
sitemap.json
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
"desc": "关于本文件的更多信息,请参考文档 https://developers.weixin.qq.com/miniprogram/dev/framework/sitemap.html",
|
||||
"rules": [{
|
||||
"action": "allow",
|
||||
"page": "*"
|
||||
}]
|
||||
}
|
83
utils/api/testapi.js
Normal file
83
utils/api/testapi.js
Normal file
@ -0,0 +1,83 @@
|
||||
// 引入 request 文件
|
||||
import request from '@/utils/request';
|
||||
|
||||
// 以下 api 为示例,实际与项目相匹配
|
||||
|
||||
// 分页查询学习列表
|
||||
export const pageStudyInfo = (params) => {
|
||||
return request({
|
||||
url: '/study/studyInfo/page',
|
||||
method: 'GET',
|
||||
data: params
|
||||
});
|
||||
};
|
||||
|
||||
// 查询学习列表
|
||||
export const listStudyInfo = (params) => {
|
||||
return request({
|
||||
url: '/study/studyInfo/list',
|
||||
method: 'GET',
|
||||
data: params
|
||||
});
|
||||
};
|
||||
|
||||
// 获取学习列表详细信息
|
||||
export const studyInfoById = (id) => {
|
||||
return request({
|
||||
url: `/study/studyInfo/${id}`,
|
||||
method: 'GET',
|
||||
});
|
||||
};
|
||||
|
||||
// 增加学习列表
|
||||
export const saveStudyInfo = (params) => {
|
||||
return request({
|
||||
url: '/study/studyInfo',
|
||||
method: 'POST',
|
||||
data: params
|
||||
});
|
||||
};
|
||||
|
||||
// 修改学习列表
|
||||
export const updateStudyInfo = (params) => {
|
||||
return request({
|
||||
url: '/study/studyInfo',
|
||||
method: 'PUT',
|
||||
data: params
|
||||
});
|
||||
};
|
||||
|
||||
// 删除学习列表
|
||||
export const deleteStudyInfo = (id) => {
|
||||
return request({
|
||||
url: `/study/studyInfo/delete?id=${id}`,
|
||||
method: 'DELETE',
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Page({
|
||||
// data: {
|
||||
// studyList: []
|
||||
// },
|
||||
|
||||
// onLoad: function () {
|
||||
// this.getStudyList();
|
||||
// },
|
||||
|
||||
// getStudyList: async function () {
|
||||
// try {
|
||||
// const res = await pageStudyInfo(this.data.queryParams);
|
||||
// console.log(res.data.records);
|
||||
// this.setData({
|
||||
// studyList: res.data.records
|
||||
// });
|
||||
// } catch (error) {
|
||||
// console.error(error);
|
||||
// }
|
||||
// }
|
||||
// });
|
86
utils/http.js
Normal file
86
utils/http.js
Normal file
@ -0,0 +1,86 @@
|
||||
// 全局请求封装
|
||||
const base_url = 'http://localhost:996';
|
||||
|
||||
export default (params) => {
|
||||
let url = params.url;
|
||||
let method = params.method || "GET";
|
||||
let data = params.data || {};
|
||||
let header = {};
|
||||
|
||||
if (method == "POST") {
|
||||
header = {
|
||||
'content-type': 'application/json'
|
||||
};
|
||||
}
|
||||
|
||||
// 获取本地token
|
||||
const token = wx.getStorageSync("token");
|
||||
if (token) {
|
||||
header['Authorization'] = 'Bearer ' + token;
|
||||
}
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
wx.request({
|
||||
url: base_url + url,
|
||||
method: method,
|
||||
header: header,
|
||||
data: data,
|
||||
success(response) {
|
||||
const res = response.data;
|
||||
if (res.statusCode == 200) {
|
||||
resolve(res);
|
||||
} else {
|
||||
wx.clearStorageSync();
|
||||
switch (res.statusCode) {
|
||||
case 401:
|
||||
wx.showModal({
|
||||
title: "提示",
|
||||
content: "请登录",
|
||||
showCancel: false,
|
||||
success(res) {
|
||||
setTimeout(() => {
|
||||
wx.navigateTo({
|
||||
url: "/pages/login/index",
|
||||
});
|
||||
}, 1000);
|
||||
},
|
||||
});
|
||||
break;
|
||||
case 404:
|
||||
wx.showToast({
|
||||
title: '请求地址不存在...',
|
||||
duration: 2000,
|
||||
});
|
||||
break;
|
||||
default:
|
||||
wx.showToast({
|
||||
title: '请重试...',
|
||||
duration: 2000,
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
},
|
||||
fail(err) {
|
||||
console.log(err);
|
||||
if (err.errMsg.indexOf('request:fail') !== -1) {
|
||||
wx.showToast({
|
||||
title: '网络异常',
|
||||
icon: "error",
|
||||
duration: 2000
|
||||
});
|
||||
} else {
|
||||
wx.showToast({
|
||||
title: '未知异常',
|
||||
duration: 2000
|
||||
});
|
||||
}
|
||||
reject(err);
|
||||
},
|
||||
complete() {
|
||||
wx.hideLoading();
|
||||
wx.hideToast();
|
||||
}
|
||||
});
|
||||
}).catch((e) => {});
|
||||
};
|
32
utils/util.js
Normal file
32
utils/util.js
Normal file
@ -0,0 +1,32 @@
|
||||
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(':')
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {*} date
|
||||
*/
|
||||
const formatDate = date => {
|
||||
const year = date.getFullYear()
|
||||
const month = date.getMonth() + 1
|
||||
const day = date.getDate()
|
||||
|
||||
return [year, month, day].map(formatNumber).join('-')
|
||||
}
|
||||
|
||||
const formatNumber = n => {
|
||||
n = n.toString()
|
||||
return n[1] ? n : '0' + n
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
formatTime: formatTime,
|
||||
formatDate: formatDate
|
||||
}
|
Loading…
Reference in New Issue
Block a user