├── .gitignore
├── Deployment.md
├── Picture
├── 1.jpg
├── 2.jpg
├── 3.jpg
├── 4.jpg
└── 5.jpg
├── README.md
├── cloudfunctions
└── getOpenId
│ ├── config.json
│ ├── index.js
│ └── package.json
├── miniprogram
├── app.js
├── app.json
├── app.wxss
├── components
│ └── chatroom
│ │ ├── chatroom.js
│ │ ├── chatroom.json
│ │ ├── chatroom.wxml
│ │ ├── chatroom.wxss
│ │ ├── dots.gif
│ │ └── photo.png
├── images
│ ├── dagou.png
│ ├── doc.png
│ ├── exl.png
│ ├── guanzhu-gray.png
│ ├── guanzhu.png
│ ├── jiantou.png
│ ├── pdf.png
│ ├── ppt.png
│ ├── rar.png
│ ├── search.png
│ ├── shangchuan-gray.png
│ ├── shangchuan.png
│ ├── sousuo-gray.png
│ ├── sousuo.png
│ ├── tiwen-gray.png
│ ├── tiwen.png
│ ├── touxiang.jpg
│ ├── user-unlogin.png
│ ├── weizhi.png
│ ├── wenda-gray.png
│ ├── wenda.png
│ ├── wenhao.png
│ ├── wode-gray.png
│ ├── wode.png
│ ├── xuexiao.png
│ └── xueyuan.png
├── pages
│ ├── Info
│ │ ├── Info.js
│ │ ├── Info.json
│ │ ├── Info.wxml
│ │ └── Info.wxss
│ ├── answer
│ │ ├── answer.js
│ │ ├── answer.json
│ │ ├── answer.wxml
│ │ └── answer.wxss
│ ├── ask
│ │ ├── ask.js
│ │ ├── ask.json
│ │ ├── ask.wxml
│ │ └── ask.wxss
│ ├── downfile
│ │ ├── downfile.js
│ │ ├── downfile.json
│ │ ├── downfile.wxml
│ │ └── downfile.wxss
│ ├── load
│ │ ├── load.js
│ │ ├── load.json
│ │ ├── load.wxml
│ │ └── load.wxss
│ ├── main
│ │ ├── main.js
│ │ ├── main.json
│ │ ├── main.wxml
│ │ └── main.wxss
│ ├── mine
│ │ ├── mine.js
│ │ ├── mine.json
│ │ ├── mine.wxml
│ │ └── mine.wxss
│ ├── myFile
│ │ ├── myFile.js
│ │ ├── myFile.json
│ │ ├── myFile.wxml
│ │ └── myFile.wxss
│ ├── myQes
│ │ ├── myQes.js
│ │ ├── myQes.json
│ │ ├── myQes.wxml
│ │ └── myQes.wxss
│ ├── qesUpfile
│ │ ├── qesUpfile.js
│ │ ├── qesUpfile.json
│ │ ├── qesUpfile.wxml
│ │ └── qesUpfile.wxss
│ ├── search
│ │ ├── search.js
│ │ ├── search.json
│ │ ├── search.wxml
│ │ └── search.wxss
│ └── upfile
│ │ ├── upfile.js
│ │ ├── upfile.json
│ │ ├── upfile.wxml
│ │ └── upfile.wxss
├── sitemap.json
└── utils
│ └── common.wxs
└── project.config.json
/.gitignore:
--------------------------------------------------------------------------------
1 | # Windows
2 | [Dd]esktop.ini
3 | Thumbs.db
4 | $RECYCLE.BIN/
5 |
6 | # macOS
7 | .DS_Store
8 | .fseventsd
9 | .Spotlight-V100
10 | .TemporaryItems
11 | .Trashes
12 |
13 | # Node.js
14 | node_modules/
15 |
--------------------------------------------------------------------------------
/Deployment.md:
--------------------------------------------------------------------------------
1 |
2 | ## 部署说明
3 |
4 | 复制链接:https://github.com/mushroomCerys/File-sharing.git 打开浏览器粘贴浏览
5 |
6 | 点击绿色的Code->Download ZIP 下载压缩包保存至桌面并解压
7 |
8 | 打开微信开发者工具->文件->导入项目
9 |
10 | 填写项目名称、选择目录(下载的该项目文件夹)、填写AppID(自己的)之后点击导入
11 |
12 | 点击cloudfunctions文件夹->右键getOpenId->创建并部署:云端安装依赖
13 |
14 | 上传成功之后点击云开发->数据库,创建三个集合,分别命名为:File-Info、Qes-Info、User-Info
15 |
16 | 分别修改三个集合的权限:点击权限设置,修改自定义安全规则(如果没有该选项请下载最新的微信开发者工具),
17 | 将read和write都改为true
18 |
19 | 到此部署完毕!
20 |
21 | (其他调试如有错误请自行百度或者加微信:wxr-O_O- )
22 |
--------------------------------------------------------------------------------
/Picture/1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mushroomCerys/File-sharing/4382f011f53ee8632c6a8971f3451afd921934e2/Picture/1.jpg
--------------------------------------------------------------------------------
/Picture/2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mushroomCerys/File-sharing/4382f011f53ee8632c6a8971f3451afd921934e2/Picture/2.jpg
--------------------------------------------------------------------------------
/Picture/3.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mushroomCerys/File-sharing/4382f011f53ee8632c6a8971f3451afd921934e2/Picture/3.jpg
--------------------------------------------------------------------------------
/Picture/4.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mushroomCerys/File-sharing/4382f011f53ee8632c6a8971f3451afd921934e2/Picture/4.jpg
--------------------------------------------------------------------------------
/Picture/5.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mushroomCerys/File-sharing/4382f011f53ee8632c6a8971f3451afd921934e2/Picture/5.jpg
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # File-sharing
2 | ## 大学生资源共享平台(2020微信小程序云开发比赛的作品)
3 |
4 | **如果要Clone源码,麻烦Star一下呀亲~**
5 |
6 | 项目简介:
7 | 该小程序面向全体大学生,旨为大学生们提供一个良好的资源共享平台,创新性地以各地学校、学院作为分类标准,划分所有问题以及资源,以供同校甚至同学院的大学生交流、共享学校或学院的特定资源,有针对性地服务各类大学生。该小程序具有提问功能,上传、下载功能,关键字搜索以及按学校、学院、有用量、下载量筛选的功能,能很大程度上满足大学生对资源共享的需求。
8 |
9 | 项目效果截图:
10 | 
11 | 
12 | 
13 | 
14 | 
15 |
16 | **该小程序尚未正式发布**
17 |
--------------------------------------------------------------------------------
/cloudfunctions/getOpenId/config.json:
--------------------------------------------------------------------------------
1 | {
2 | "permissions": {
3 | "openapi": [
4 | ]
5 | }
6 | }
--------------------------------------------------------------------------------
/cloudfunctions/getOpenId/index.js:
--------------------------------------------------------------------------------
1 | // 云函数入口文件
2 | const cloud = require('wx-server-sdk')
3 |
4 | cloud.init()
5 |
6 | // 云函数入口函数
7 | exports.main = async (event, context) => {
8 | const wxContext = cloud.getWXContext()
9 |
10 | return {
11 | event,
12 | openid: wxContext.OPENID,
13 | appid: wxContext.APPID,
14 | unionid: wxContext.UNIONID,
15 | }
16 | }
--------------------------------------------------------------------------------
/cloudfunctions/getOpenId/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "getOpenId_",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1"
8 | },
9 | "author": "",
10 | "license": "ISC",
11 | "dependencies": {
12 | "wx-server-sdk": "~2.1.2"
13 | }
14 | }
--------------------------------------------------------------------------------
/miniprogram/app.js:
--------------------------------------------------------------------------------
1 | //app.js
2 | wx.cloud.init()
3 | const db = wx.cloud.database();
4 | App({
5 | onLaunch: function () {
6 |
7 | if (!wx.cloud) {
8 | console.error('请使用 2.2.3 或以上的基础库以使用云能力')
9 | } else {
10 | wx.cloud.init({
11 | // env 参数说明:
12 | // env 参数决定接下来小程序发起的云开发调用(wx.cloud.xxx)会默认请求到哪个云环境的资源
13 | // 此处请填入环境 ID, 环境 ID 可打开云控制台查看
14 | // 如不填则使用默认环境(第一个创建的环境)
15 | // env: 'my-env-id',
16 | traceUser: true,
17 | })
18 | }
19 |
20 | this.globalData = {
21 | userInfo: {
22 | openid: null,
23 | avatarUrl: null,
24 | nickName: null,
25 | userSchool:'',
26 | userFaculty:''
27 | }, //微信获取用户信息
28 | isMyFile:false,
29 | isMyQes:false
30 | }
31 | },
32 |
33 | // 获取用户openid
34 | getOpenid() {
35 | let that = this;
36 | wx.cloud.callFunction({
37 | name: 'getOpenId',
38 | complete: res => {
39 | //console.log('appid: ', res.result.appid)
40 | that.globalData.userInfo.openid = res.result.openid
41 | //console.log('openid: ', that.globalData.userInfo.openid)
42 |
43 | db.collection('User-Info').where({
44 | _openid: res.result.openid,
45 | }).get({
46 | success: res => {
47 | that.globalData.userInfo.userSchool=res.data[0].school,
48 | that.globalData.userInfo.userFaculty=res.data[0].faculty
49 | //console.log(that.globalData.userInfo.userSchool)
50 | },
51 | fail: err => {
52 | console.error(err)
53 | }
54 | })
55 | }
56 | })
57 |
58 | },
59 |
60 | })
--------------------------------------------------------------------------------
/miniprogram/app.json:
--------------------------------------------------------------------------------
1 | {
2 | "pages": [
3 | "pages/main/main",
4 | "pages/load/load",
5 | "pages/Info/Info",
6 |
7 | "pages/ask/ask",
8 | "pages/search/search",
9 | "pages/upfile/upfile",
10 | "pages/downfile/downfile",
11 | "pages/mine/mine",
12 | "pages/myFile/myFile",
13 | "pages/answer/answer",
14 | "pages/qesUpfile/qesUpfile",
15 | "pages/myQes/myQes"
16 | ],
17 | "window": {
18 | "backgroundColor": "#F6F6F6",
19 | "backgroundTextStyle": "light",
20 | "navigationBarBackgroundColor": "#5EAAA8",
21 | "navigationBarTitleText": "云开发 QuickStart",
22 | "navigationBarTextStyle": "black"
23 | },
24 | "tabBar": {
25 | "backgroundColor": "white",
26 | "color": "#CDCDCD",
27 | "selectedColor": "#39458F",
28 | "list": [
29 | {
30 | "pagePath": "pages/main/main",
31 | "text": "问答",
32 | "iconPath": "images/wenda-gray.png",
33 | "selectedIconPath": "images/wenda.png"
34 | },
35 | {
36 | "pagePath": "pages/ask/ask",
37 | "text": "提问",
38 | "iconPath": "images/tiwen-gray.png",
39 | "selectedIconPath": "images/tiwen.png"
40 | },
41 | {
42 | "pagePath": "pages/search/search",
43 | "text": "搜索",
44 | "iconPath": "images/sousuo-gray.png",
45 | "selectedIconPath": "images/sousuo.png"
46 | },
47 | {
48 | "pagePath": "pages/upfile/upfile",
49 | "text": "上传",
50 | "iconPath": "images/shangchuan-gray.png",
51 | "selectedIconPath": "images/shangchuan.png"
52 | },
53 | {
54 | "pagePath": "pages/mine/mine",
55 | "text": "我的",
56 | "iconPath": "images/wode-gray.png",
57 | "selectedIconPath": "images/wode.png"
58 | }
59 | ]
60 | },
61 | "sitemapLocation": "sitemap.json"
62 | }
--------------------------------------------------------------------------------
/miniprogram/app.wxss:
--------------------------------------------------------------------------------
1 | /**app.wxss**/
2 | .container {
3 | display: flex;
4 | flex-direction: column;
5 | align-items: center;
6 | box-sizing: border-box;
7 | }
8 |
9 | button {
10 | background: initial;
11 | }
12 |
13 | button:focus{
14 | outline: 0;
15 | }
16 |
17 | button::after{
18 | border: none;
19 | }
20 |
21 |
22 | page {
23 | background: #f6f6f6;
24 | display: flex;
25 | flex-direction: column;
26 | justify-content: flex-start;
27 | }
28 |
29 | .userinfo, .uploader, .tunnel {
30 | margin-top: 40rpx;
31 | height: 140rpx;
32 | width: 100%;
33 | background: #fff;
34 | border: 1px solid rgba(0, 0, 0, 0.1);
35 | border-left: none;
36 | border-right: none;
37 | display: flex;
38 | flex-direction: row;
39 | align-items: center;
40 | transition: all 300ms ease;
41 | }
42 |
43 | .userinfo-avatar {
44 | width: 100rpx;
45 | height: 100rpx;
46 | margin: 20rpx;
47 | border-radius: 50%;
48 | background-size: cover;
49 | background-color: white;
50 | }
51 |
52 | .userinfo-avatar:after {
53 | border: none;
54 | }
55 |
56 | .userinfo-nickname {
57 | font-size: 32rpx;
58 | color: #007aff;
59 | background-color: white;
60 | background-size: cover;
61 | }
62 |
63 | .userinfo-nickname::after {
64 | border: none;
65 | }
66 |
67 | .uploader, .tunnel {
68 | height: auto;
69 | padding: 0 0 0 40rpx;
70 | flex-direction: column;
71 | align-items: flex-start;
72 | box-sizing: border-box;
73 | }
74 |
75 | .uploader-text, .tunnel-text {
76 | width: 100%;
77 | line-height: 52px;
78 | font-size: 34rpx;
79 | color: #007aff;
80 | }
81 |
82 | .uploader-container {
83 | width: 100%;
84 | height: 400rpx;
85 | padding: 20rpx 20rpx 20rpx 0;
86 | display: flex;
87 | align-content: center;
88 | justify-content: center;
89 | box-sizing: border-box;
90 | border-top: 1px solid rgba(0, 0, 0, 0.1);
91 | }
92 |
93 | .uploader-image {
94 | width: 100%;
95 | height: 360rpx;
96 | }
97 |
98 | .tunnel {
99 | padding: 0 0 0 40rpx;
100 | }
101 |
102 | .tunnel-text {
103 | position: relative;
104 | color: #222;
105 | display: flex;
106 | flex-direction: row;
107 | align-content: center;
108 | justify-content: space-between;
109 | box-sizing: border-box;
110 | border-top: 1px solid rgba(0, 0, 0, 0.1);
111 | }
112 |
113 | .tunnel-text:first-child {
114 | border-top: none;
115 | }
116 |
117 | .tunnel-switch {
118 | position: absolute;
119 | right: 20rpx;
120 | top: -2rpx;
121 | }
122 |
123 | .disable {
124 | color: #888;
125 | }
126 |
127 | .service {
128 | position: fixed;
129 | right: 40rpx;
130 | bottom: 40rpx;
131 | width: 140rpx;
132 | height: 140rpx;
133 | border-radius: 50%;
134 | background: linear-gradient(#007aff, #0063ce);
135 | box-shadow: 0 5px 10px rgba(0, 0, 0, 0.3);
136 | display: flex;
137 | align-content: center;
138 | justify-content: center;
139 | transition: all 300ms ease;
140 | }
141 |
142 | .service-button {
143 | position: absolute;
144 | top: 40rpx;
145 | }
146 |
147 | .service:active {
148 | box-shadow: none;
149 | }
150 |
151 | .request-text {
152 | padding: 20rpx 0;
153 | font-size: 24rpx;
154 | line-height: 36rpx;
155 | word-break: break-all;
156 | }
157 |
--------------------------------------------------------------------------------
/miniprogram/components/chatroom/chatroom.js:
--------------------------------------------------------------------------------
1 | const FATAL_REBUILD_TOLERANCE = 10
2 | const SETDATA_SCROLL_TO_BOTTOM = {
3 | scrollTop: 100000,
4 | scrollWithAnimation: true,
5 | }
6 |
7 | Component({
8 | properties: {
9 | envId: String,
10 | collection: String,
11 | groupId: String,
12 | groupName: String,
13 | userInfo: Object,
14 | onGetUserInfo: {
15 | type: Function,
16 | },
17 | getOpenID: {
18 | type: Function,
19 | },
20 | },
21 |
22 | data: {
23 | chats: [],
24 | textInputValue: '',
25 | openId: '',
26 | scrollTop: 0,
27 | scrollToMessage: '',
28 | hasKeyboard: false,
29 | },
30 |
31 | methods: {
32 | onGetUserInfo(e) {
33 | this.properties.onGetUserInfo(e)
34 | },
35 |
36 | getOpenID() {
37 | return this.properties.getOpenID()
38 | },
39 |
40 | mergeCommonCriteria(criteria) {
41 | return {
42 | groupId: this.data.groupId,
43 | ...criteria,
44 | }
45 | },
46 |
47 | async initRoom() {
48 | this.try(async () => {
49 | await this.initOpenID()
50 |
51 | const { envId, collection } = this.properties
52 | const db = this.db = wx.cloud.database({
53 | env: envId,
54 | })
55 | const _ = db.command
56 |
57 | const { data: initList } = await db.collection(collection).where(this.mergeCommonCriteria()).orderBy('sendTimeTS', 'desc').get()
58 |
59 | console.log('init query chats', initList)
60 |
61 | this.setData({
62 | chats: initList.reverse(),
63 | scrollTop: 10000,
64 | })
65 |
66 | this.initWatch(initList.length ? {
67 | sendTimeTS: _.gt(initList[initList.length - 1].sendTimeTS),
68 | } : {})
69 | }, '初始化失败')
70 | },
71 |
72 | async initOpenID() {
73 | return this.try(async () => {
74 | const openId = await this.getOpenID()
75 |
76 | this.setData({
77 | openId,
78 | })
79 | }, '初始化 openId 失败')
80 | },
81 |
82 | async initWatch(criteria) {
83 | this.try(() => {
84 | const { collection } = this.properties
85 | const db = this.db
86 | const _ = db.command
87 |
88 | console.warn(`开始监听`, criteria)
89 | this.messageListener = db.collection(collection).where(this.mergeCommonCriteria(criteria)).watch({
90 | onChange: this.onRealtimeMessageSnapshot.bind(this),
91 | onError: e => {
92 | if (!this.inited || this.fatalRebuildCount >= FATAL_REBUILD_TOLERANCE) {
93 | this.showError(this.inited ? '监听错误,已断开' : '初始化监听失败', e, '重连', () => {
94 | this.initWatch(this.data.chats.length ? {
95 | sendTimeTS: _.gt(this.data.chats[this.data.chats.length - 1].sendTimeTS),
96 | } : {})
97 | })
98 | } else {
99 | this.initWatch(this.data.chats.length ? {
100 | sendTimeTS: _.gt(this.data.chats[this.data.chats.length - 1].sendTimeTS),
101 | } : {})
102 | }
103 | },
104 | })
105 | }, '初始化监听失败')
106 | },
107 |
108 | onRealtimeMessageSnapshot(snapshot) {
109 | console.warn(`收到消息`, snapshot)
110 |
111 | if (snapshot.type === 'init') {
112 | this.setData({
113 | chats: [
114 | ...this.data.chats,
115 | ...[...snapshot.docs].sort((x, y) => x.sendTimeTS - y.sendTimeTS),
116 | ],
117 | })
118 | this.scrollToBottom()
119 | this.inited = true
120 | } else {
121 | let hasNewMessage = false
122 | let hasOthersMessage = false
123 | const chats = [...this.data.chats]
124 | for (const docChange of snapshot.docChanges) {
125 | switch (docChange.queueType) {
126 | case 'enqueue': {
127 | hasOthersMessage = docChange.doc._openid !== this.data.openId
128 | const ind = chats.findIndex(chat => chat._id === docChange.doc._id)
129 | if (ind > -1) {
130 | if (chats[ind].msgType === 'image' && chats[ind].tempFilePath) {
131 | chats.splice(ind, 1, {
132 | ...docChange.doc,
133 | tempFilePath: chats[ind].tempFilePath,
134 | })
135 | } else chats.splice(ind, 1, docChange.doc)
136 | } else {
137 | hasNewMessage = true
138 | chats.push(docChange.doc)
139 | }
140 | break
141 | }
142 | }
143 | }
144 | this.setData({
145 | chats: chats.sort((x, y) => x.sendTimeTS - y.sendTimeTS),
146 | })
147 | if (hasOthersMessage || hasNewMessage) {
148 | this.scrollToBottom()
149 | }
150 | }
151 | },
152 |
153 | async onConfirmSendText(e) {
154 | this.try(async () => {
155 | if (!e.detail.value) {
156 | return
157 | }
158 |
159 | const { collection } = this.properties
160 | const db = this.db
161 | const _ = db.command
162 |
163 | const doc = {
164 | _id: `${Math.random()}_${Date.now()}`,
165 | groupId: this.data.groupId,
166 | avatar: this.data.userInfo.avatarUrl,
167 | nickName: this.data.userInfo.nickName,
168 | msgType: 'text',
169 | textContent: e.detail.value,
170 | sendTime: new Date(),
171 | sendTimeTS: Date.now(), // fallback
172 | }
173 |
174 | this.setData({
175 | textInputValue: '',
176 | chats: [
177 | ...this.data.chats,
178 | {
179 | ...doc,
180 | _openid: this.data.openId,
181 | writeStatus: 'pending',
182 | },
183 | ],
184 | })
185 | this.scrollToBottom(true)
186 |
187 | await db.collection(collection).add({
188 | data: doc,
189 | })
190 |
191 | this.setData({
192 | chats: this.data.chats.map(chat => {
193 | if (chat._id === doc._id) {
194 | return {
195 | ...chat,
196 | writeStatus: 'written',
197 | }
198 | } else return chat
199 | }),
200 | })
201 | }, '发送文字失败')
202 | },
203 |
204 | async onChooseImage(e) {
205 | wx.chooseImage({
206 | count: 1,
207 | sourceType: ['album', 'camera'],
208 | success: async res => {
209 | const { envId, collection } = this.properties
210 | const doc = {
211 | _id: `${Math.random()}_${Date.now()}`,
212 | groupId: this.data.groupId,
213 | avatar: this.data.userInfo.avatarUrl,
214 | nickName: this.data.userInfo.nickName,
215 | msgType: 'image',
216 | sendTime: new Date(),
217 | sendTimeTS: Date.now(), // fallback
218 | }
219 |
220 | this.setData({
221 | chats: [
222 | ...this.data.chats,
223 | {
224 | ...doc,
225 | _openid: this.data.openId,
226 | tempFilePath: res.tempFilePaths[0],
227 | writeStatus: 0,
228 | },
229 | ]
230 | })
231 | this.scrollToBottom(true)
232 |
233 | const uploadTask = wx.cloud.uploadFile({
234 | cloudPath: `${this.data.openId}/${Math.random()}_${Date.now()}.${res.tempFilePaths[0].match(/\.(\w+)$/)[1]}`,
235 | filePath: res.tempFilePaths[0],
236 | config: {
237 | env: envId,
238 | },
239 | success: res => {
240 | this.try(async () => {
241 | await this.db.collection(collection).add({
242 | data: {
243 | ...doc,
244 | imgFileID: res.fileID,
245 | },
246 | })
247 | }, '发送图片失败')
248 | },
249 | fail: e => {
250 | this.showError('发送图片失败', e)
251 | },
252 | })
253 |
254 | uploadTask.onProgressUpdate(({ progress }) => {
255 | this.setData({
256 | chats: this.data.chats.map(chat => {
257 | if (chat._id === doc._id) {
258 | return {
259 | ...chat,
260 | writeStatus: progress,
261 | }
262 | } else return chat
263 | })
264 | })
265 | })
266 | },
267 | })
268 | },
269 |
270 | onMessageImageTap(e) {
271 | wx.previewImage({
272 | urls: [e.target.dataset.fileid],
273 | })
274 | },
275 |
276 | scrollToBottom(force) {
277 | if (force) {
278 | console.log('force scroll to bottom')
279 | this.setData(SETDATA_SCROLL_TO_BOTTOM)
280 | return
281 | }
282 |
283 | this.createSelectorQuery().select('.body').boundingClientRect(bodyRect => {
284 | this.createSelectorQuery().select(`.body`).scrollOffset(scroll => {
285 | if (scroll.scrollTop + bodyRect.height * 3 > scroll.scrollHeight) {
286 | console.log('should scroll to bottom')
287 | this.setData(SETDATA_SCROLL_TO_BOTTOM)
288 | }
289 | }).exec()
290 | }).exec()
291 | },
292 |
293 | async onScrollToUpper() {
294 | if (this.db && this.data.chats.length) {
295 | const { collection } = this.properties
296 | const _ = this.db.command
297 | const { data } = await this.db.collection(collection).where(this.mergeCommonCriteria({
298 | sendTimeTS: _.lt(this.data.chats[0].sendTimeTS),
299 | })).orderBy('sendTimeTS', 'desc').get()
300 | this.data.chats.unshift(...data.reverse())
301 | this.setData({
302 | chats: this.data.chats,
303 | scrollToMessage: `item-${data.length}`,
304 | scrollWithAnimation: false,
305 | })
306 | }
307 | },
308 |
309 | async try(fn, title) {
310 | try {
311 | await fn()
312 | } catch (e) {
313 | this.showError(title, e)
314 | }
315 | },
316 |
317 | showError(title, content, confirmText, confirmCallback) {
318 | console.error(title, content)
319 | wx.showModal({
320 | title,
321 | content: content.toString(),
322 | showCancel: confirmText ? true : false,
323 | confirmText,
324 | success: res => {
325 | res.confirm && confirmCallback()
326 | },
327 | })
328 | },
329 | },
330 |
331 | ready() {
332 | global.chatroom = this
333 | this.initRoom()
334 | this.fatalRebuildCount = 0
335 | },
336 | })
337 |
--------------------------------------------------------------------------------
/miniprogram/components/chatroom/chatroom.json:
--------------------------------------------------------------------------------
1 | {
2 | "component": true,
3 | "usingComponents": {}
4 | }
--------------------------------------------------------------------------------
/miniprogram/components/chatroom/chatroom.wxml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
12 |
20 |
26 |
31 |
32 | {{item.nickName}}
33 |
34 |
35 | {{item.writeStatus}}%
36 |
43 |
44 |
45 |
46 |
47 | ···
48 | {{item.textContent}}
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
83 |
84 |
85 |
86 |
--------------------------------------------------------------------------------
/miniprogram/components/chatroom/chatroom.wxss:
--------------------------------------------------------------------------------
1 | .chatroom {
2 | width: 100%;
3 | height: 100%;
4 | display: flex;
5 | flex-direction: column;
6 | }
7 |
8 | .chatroom .header {
9 | flex-basis: fit-content;
10 | display: flex;
11 | flex-direction: row;
12 | border-bottom: 1px solid #ddd;
13 | padding: 20rpx 0 30rpx;
14 | font-size: 30rpx;
15 | /* background: rgb(34, 187, 47);
16 | color: rgba(255, 255, 255, 1) */
17 | /* font-family: 'Microsoft YaHei' */
18 | }
19 |
20 | .chatroom .header .left {
21 | flex: 1;
22 | }
23 |
24 | .chatroom .header .middle {
25 | flex: 2;
26 | text-align: center;
27 | }
28 |
29 | .chatroom .header .right {
30 | flex: 1;
31 | }
32 |
33 | .chatroom .body {
34 | flex: 2;
35 | display: flex;
36 | flex-direction: column;
37 | background: rgb(237,237,237);
38 | padding-bottom: 16rpx;
39 | }
40 |
41 | .body .message {
42 | display: flex;
43 | flex-direction: row;
44 | position: relative;
45 | margin: 12rpx 0;
46 | }
47 |
48 | .body .message.message__self {
49 | flex-direction: row-reverse;
50 | }
51 |
52 | .body .message .avatar {
53 | position: relative;
54 | top: 5rpx;
55 | width: 60rpx;
56 | height: 60rpx;
57 | border-radius: 5rpx;
58 | margin: 15rpx;
59 | }
60 |
61 | .body .message .main {
62 | flex: 1;
63 | display: flex;
64 | flex-direction: column;
65 | align-items: flex-start;
66 | }
67 |
68 | .body .message.message__self .main {
69 | align-items: flex-end;
70 | }
71 |
72 | .body .message .nickname {
73 | font-size: 24rpx;
74 | color: #444;
75 | }
76 |
77 | .body .message .text-content {
78 | border: 1px solid transparent;
79 | border-radius: 3px;
80 | background-color: #fff;
81 | margin: 2px 0 0 0;
82 | padding: 4px 10px;
83 | font-size: 30rpx;
84 | display: inline-block;
85 | }
86 |
87 | .body .message.message__self .text-content {
88 | background-color: paleturquoise;
89 | }
90 |
91 | .body .message .text-wrapper {
92 | display: flex;
93 | flex-direction: row;
94 | align-items: center;
95 | max-width: 80%;
96 | }
97 |
98 | .body .message.message__self .text-wrapper .loading{
99 | font-size: 16rpx;
100 | margin-right: 18rpx;
101 | }
102 |
103 | .body .message .image-wrapper {
104 | display: flex;
105 | flex-direction: row;
106 | align-items: center;
107 | }
108 |
109 | .body .message .image-content {
110 | max-width: 240rpx;
111 | max-height: 240rpx;
112 | }
113 |
114 | .body .message.message__self .image-wrapper .loading {
115 | font-size: 20rpx;
116 | margin-right: 18rpx;
117 | }
118 |
119 | .chatroom .footer {
120 | flex-basis: fit-content;
121 | display: flex;
122 | flex-direction: row;
123 | border-top: 1px solid #ddd;
124 | font-size: 10rpx;
125 | padding: 20rpx 30rpx;
126 | background: rgb(246,246,246);
127 | }
128 |
129 | .chatroom .footer .message-sender {
130 | flex: 1;
131 | display: flex;
132 | flex-direction: row;
133 | }
134 |
135 | .message-sender .text-input {
136 | flex: 1;
137 | font-size: 16px;
138 | border: 1px solid transparent;
139 | border-radius: 5px;
140 | padding: 3px 6px;
141 | margin: 0 10px 0 5px;
142 | background: #fff;
143 | }
144 |
145 | .message-sender .btn-send-image {
146 | width: 50rpx;
147 | height: 50rpx;
148 | align-self: center;
149 | }
150 |
151 | button {
152 | font-size: 30rpx;
153 | }
154 |
155 | button.userinfo {
156 | background: darkturquoise;
157 | color: aliceblue;
158 | padding: 0 100rpx;
159 | border: 1px solid #ddd;
160 | border-radius: 20px;
161 | }
162 |
--------------------------------------------------------------------------------
/miniprogram/components/chatroom/dots.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mushroomCerys/File-sharing/4382f011f53ee8632c6a8971f3451afd921934e2/miniprogram/components/chatroom/dots.gif
--------------------------------------------------------------------------------
/miniprogram/components/chatroom/photo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mushroomCerys/File-sharing/4382f011f53ee8632c6a8971f3451afd921934e2/miniprogram/components/chatroom/photo.png
--------------------------------------------------------------------------------
/miniprogram/images/dagou.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mushroomCerys/File-sharing/4382f011f53ee8632c6a8971f3451afd921934e2/miniprogram/images/dagou.png
--------------------------------------------------------------------------------
/miniprogram/images/doc.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mushroomCerys/File-sharing/4382f011f53ee8632c6a8971f3451afd921934e2/miniprogram/images/doc.png
--------------------------------------------------------------------------------
/miniprogram/images/exl.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mushroomCerys/File-sharing/4382f011f53ee8632c6a8971f3451afd921934e2/miniprogram/images/exl.png
--------------------------------------------------------------------------------
/miniprogram/images/guanzhu-gray.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mushroomCerys/File-sharing/4382f011f53ee8632c6a8971f3451afd921934e2/miniprogram/images/guanzhu-gray.png
--------------------------------------------------------------------------------
/miniprogram/images/guanzhu.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mushroomCerys/File-sharing/4382f011f53ee8632c6a8971f3451afd921934e2/miniprogram/images/guanzhu.png
--------------------------------------------------------------------------------
/miniprogram/images/jiantou.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mushroomCerys/File-sharing/4382f011f53ee8632c6a8971f3451afd921934e2/miniprogram/images/jiantou.png
--------------------------------------------------------------------------------
/miniprogram/images/pdf.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mushroomCerys/File-sharing/4382f011f53ee8632c6a8971f3451afd921934e2/miniprogram/images/pdf.png
--------------------------------------------------------------------------------
/miniprogram/images/ppt.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mushroomCerys/File-sharing/4382f011f53ee8632c6a8971f3451afd921934e2/miniprogram/images/ppt.png
--------------------------------------------------------------------------------
/miniprogram/images/rar.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mushroomCerys/File-sharing/4382f011f53ee8632c6a8971f3451afd921934e2/miniprogram/images/rar.png
--------------------------------------------------------------------------------
/miniprogram/images/search.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mushroomCerys/File-sharing/4382f011f53ee8632c6a8971f3451afd921934e2/miniprogram/images/search.png
--------------------------------------------------------------------------------
/miniprogram/images/shangchuan-gray.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mushroomCerys/File-sharing/4382f011f53ee8632c6a8971f3451afd921934e2/miniprogram/images/shangchuan-gray.png
--------------------------------------------------------------------------------
/miniprogram/images/shangchuan.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mushroomCerys/File-sharing/4382f011f53ee8632c6a8971f3451afd921934e2/miniprogram/images/shangchuan.png
--------------------------------------------------------------------------------
/miniprogram/images/sousuo-gray.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mushroomCerys/File-sharing/4382f011f53ee8632c6a8971f3451afd921934e2/miniprogram/images/sousuo-gray.png
--------------------------------------------------------------------------------
/miniprogram/images/sousuo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mushroomCerys/File-sharing/4382f011f53ee8632c6a8971f3451afd921934e2/miniprogram/images/sousuo.png
--------------------------------------------------------------------------------
/miniprogram/images/tiwen-gray.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mushroomCerys/File-sharing/4382f011f53ee8632c6a8971f3451afd921934e2/miniprogram/images/tiwen-gray.png
--------------------------------------------------------------------------------
/miniprogram/images/tiwen.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mushroomCerys/File-sharing/4382f011f53ee8632c6a8971f3451afd921934e2/miniprogram/images/tiwen.png
--------------------------------------------------------------------------------
/miniprogram/images/touxiang.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mushroomCerys/File-sharing/4382f011f53ee8632c6a8971f3451afd921934e2/miniprogram/images/touxiang.jpg
--------------------------------------------------------------------------------
/miniprogram/images/user-unlogin.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mushroomCerys/File-sharing/4382f011f53ee8632c6a8971f3451afd921934e2/miniprogram/images/user-unlogin.png
--------------------------------------------------------------------------------
/miniprogram/images/weizhi.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mushroomCerys/File-sharing/4382f011f53ee8632c6a8971f3451afd921934e2/miniprogram/images/weizhi.png
--------------------------------------------------------------------------------
/miniprogram/images/wenda-gray.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mushroomCerys/File-sharing/4382f011f53ee8632c6a8971f3451afd921934e2/miniprogram/images/wenda-gray.png
--------------------------------------------------------------------------------
/miniprogram/images/wenda.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mushroomCerys/File-sharing/4382f011f53ee8632c6a8971f3451afd921934e2/miniprogram/images/wenda.png
--------------------------------------------------------------------------------
/miniprogram/images/wenhao.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mushroomCerys/File-sharing/4382f011f53ee8632c6a8971f3451afd921934e2/miniprogram/images/wenhao.png
--------------------------------------------------------------------------------
/miniprogram/images/wode-gray.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mushroomCerys/File-sharing/4382f011f53ee8632c6a8971f3451afd921934e2/miniprogram/images/wode-gray.png
--------------------------------------------------------------------------------
/miniprogram/images/wode.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mushroomCerys/File-sharing/4382f011f53ee8632c6a8971f3451afd921934e2/miniprogram/images/wode.png
--------------------------------------------------------------------------------
/miniprogram/images/xuexiao.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mushroomCerys/File-sharing/4382f011f53ee8632c6a8971f3451afd921934e2/miniprogram/images/xuexiao.png
--------------------------------------------------------------------------------
/miniprogram/images/xueyuan.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mushroomCerys/File-sharing/4382f011f53ee8632c6a8971f3451afd921934e2/miniprogram/images/xueyuan.png
--------------------------------------------------------------------------------
/miniprogram/pages/Info/Info.js:
--------------------------------------------------------------------------------
1 | // pages/Info/Info.js
2 | const db = wx.cloud.database();
3 | const userInfo = db.collection('User-Info');
4 | Page({
5 |
6 | /**
7 | * 页面的初始数据
8 | */
9 | data: {
10 |
11 | },
12 |
13 |
14 | //用户信息表单提交
15 | onSubmit: function (event) {
16 | //console.log(event.detail.value)
17 |
18 | //将用户填写的学校学院信息存入全局变量
19 | getApp().globalData.userInfo.userSchool = event.detail.value.school,
20 | getApp().globalData.userInfo.userFaculty = event.detail.value.faculty
21 |
22 | //将用户填写的用户信息存入云数据库
23 | if (event.detail.value.school == "" || event.detail.value.faculty == "") {
24 | wx.showModal({
25 | title: '温馨提示',
26 | content: '您还未完善信息哦~',
27 | showCancel: false,
28 | success(res) {}
29 | })
30 | } else {
31 | userInfo.add({
32 | data: {
33 | picture: getApp().globalData.userInfo.avatarUrl,
34 | name: getApp().globalData.userInfo.nickName,
35 | school: event.detail.value.school,
36 | faculty: event.detail.value.faculty,
37 | follow: []
38 | }
39 | }).then(res => {
40 | //console.log('点击完成的返回值:', res)
41 | wx.showToast({
42 | title: '提交成功',
43 | icon: 'success'
44 | })
45 | })
46 |
47 | setTimeout(function () {
48 | wx.navigateBack({
49 | delta: 2,
50 | })
51 | }, 2000)
52 |
53 | }
54 |
55 | },
56 |
57 | })
--------------------------------------------------------------------------------
/miniprogram/pages/Info/Info.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarTitleText": "完善信息"
3 | }
--------------------------------------------------------------------------------
/miniprogram/pages/Info/Info.wxml:
--------------------------------------------------------------------------------
1 |
2 | 用户信息
3 |
--------------------------------------------------------------------------------
/miniprogram/pages/Info/Info.wxss:
--------------------------------------------------------------------------------
1 | /* pages/Info/Info.wxss */
2 | .title {
3 | margin-top: 2%;
4 | margin-left: 2%;
5 | margin-right: 2%;
6 | background-color:#A3D2CA;
7 | height: 100rpx;
8 | font-size: 40rpx;
9 | /*实现容器内的文字居中*/
10 | display: flex;
11 | align-items: center;
12 | justify-content: center;
13 | border-top-left-radius: 40rpx;
14 | border-top-right-radius: 40rpx;
15 | }
16 |
17 | .info{
18 | margin: auto;
19 | background-color: white;
20 | margin-left: 2%;
21 | margin-right: 2%;
22 | padding-top: 40rpx;
23 | border-bottom-left-radius: 40rpx;
24 | border-bottom-right-radius: 40rpx;
25 | }
26 |
27 | .tip{
28 | width: 90%;
29 | margin: auto;
30 | margin-bottom: 20rpx;
31 | color: #EC808D;
32 | font-size: 28rpx;
33 | }
34 |
35 | .enter{
36 | width: 90%;
37 | height: 90rpx;
38 | margin: auto;
39 | margin-bottom: 20rpx;
40 | font-size: 40rpx;
41 | padding-left: 15rpx;
42 | border: 2px solid #dfdfdf;
43 | border-radius: 15rpx;
44 | }
45 |
46 | .success-btn{
47 | background-color: #A3D2CA;
48 | margin-top: 40rpx;
49 | height: 100rpx;
50 | border-radius: 0rpx;
51 | font-size: 40rpx;
52 | border-bottom-left-radius: 40rpx;
53 | border-bottom-right-radius: 40rpx;
54 | }
--------------------------------------------------------------------------------
/miniprogram/pages/answer/answer.js:
--------------------------------------------------------------------------------
1 | // pages/answer/answer.js
2 | const db = wx.cloud.database();
3 | const fileInfo = db.collection('File-Info');
4 | const qesInfo = db.collection('Qes-Info');
5 | const userInfo = db.collection('User-Info')
6 |
7 | Page({
8 |
9 | /**
10 | * 页面的初始数据
11 | */
12 | data: {
13 | fileCollection: [],
14 | qesInfo: {},
15 | qesId: null,
16 | hidden: false,
17 | isMy:false
18 | },
19 |
20 | /**
21 | * 生命周期函数--监听页面加载
22 | */
23 | onLoad: function (options) {
24 | //从我的问题进去关注和回答图标隐藏
25 | if(getApp().globalData.isMyQes||getApp().globalData.userInfo.userSchool == ''){
26 | getApp().globalData.isMyQes = false
27 | this.setData({
28 | isMy:true,
29 | qesId:options.id
30 | })
31 | }
32 |
33 | var that = this
34 | //查找该问题用户是否曾经关注过
35 | userInfo.where({
36 | _openid: getApp().globalData.userInfo.openid,
37 | follow:options.id
38 | }).get().then(res => {
39 | if(res.data.length==0){
40 | that.setData({
41 | hidden:false
42 | })
43 | }else{
44 | that.setData({
45 | hidden:true
46 | })
47 | }
48 | })
49 |
50 | qesInfo.doc(options.id).get().then(res => {
51 | //console.log(res)
52 | this.setData({
53 | qesInfo: res.data,
54 | qesId: options.id
55 | })
56 | //循环显示该问题的回答文件
57 | var fileCollection = that.data.fileCollection
58 | var fileLength = that.data.qesInfo.fileId.length
59 | if (fileLength > 10) fileLength = 10
60 | for (var i = 0; i < fileLength; i++) {
61 | fileInfo.where({
62 | _id: that.data.qesInfo.fileId[i],
63 | }).get({
64 | success: res => {
65 | console.log(res)
66 | fileCollection.push(res.data[0])
67 | that.setData({
68 | fileCollection
69 | })
70 | }
71 | })
72 | }
73 |
74 | })
75 |
76 | },
77 |
78 |
79 | onShow: function () {
80 | var that = this
81 | if (that.data.qesId) {
82 | qesInfo.doc(that.data.qesId).get().then(res => {
83 | //console.log(res)
84 | this.setData({
85 | qesInfo: res.data,
86 | fileCollection: [],
87 | })
88 | //循环显示该问题的回答文件
89 | var fileCollection = that.data.fileCollection
90 | var fileLength = that.data.qesInfo.fileId.length
91 | if (fileLength > 10) fileLength = 10
92 | for (var i = 0; i < fileLength; i++) {
93 | fileInfo.where({
94 | _id: that.data.qesInfo.fileId[i],
95 | }).get({
96 | success: res => {
97 | //console.log(res)
98 | fileCollection.push(res.data[0])
99 | that.setData({
100 | fileCollection
101 | })
102 | }
103 | })
104 | }
105 | that.pageData.skip = 10
106 | })
107 | }
108 |
109 | },
110 |
111 | //下拉刷新
112 | onReachBottom: function () {
113 | wx.showLoading({
114 | title: '数据加载中',
115 | })
116 | var that = this;
117 | var fileCollection = that.data.fileCollection
118 | var fileLength = that.data.qesInfo.fileId.length
119 | if (fileLength > that.pageData.skip + 10) fileLength = that.pageData.skip + 10
120 | for (var i = that.pageData.skip; i < fileLength; i++) {
121 | fileInfo.where({
122 | _id: that.data.qesInfo.fileId[i],
123 | }).get({
124 | success: res => {
125 | //console.log(res)
126 | fileCollection.push(res.data[0])
127 | that.setData({
128 | fileCollection
129 | })
130 | }
131 | })
132 | }
133 | that.pageData.skip = that.pageData.skip + 10
134 | setTimeout(function () {
135 | wx.hideLoading()
136 | }, 1000)
137 |
138 | },
139 | //存放触底刷新跳过的页面数
140 | pageData: {
141 | skip: 10
142 | },
143 |
144 | //关注
145 | follow: function () {
146 | var that = this
147 | //将问题id上传至用户集合
148 | userInfo.where({
149 | _openid: getApp().globalData.userInfo.openid
150 | }).update({
151 | data: {
152 | follow: db.command.unshift([that.data.qesId])
153 | }
154 | }).then(res => {
155 | that.setData({
156 | hidden: true
157 | })
158 | wx.showToast({
159 | title: '关注成功',
160 | icon: 'success'
161 | })
162 | })
163 |
164 | //更新问题信息的关注量
165 | var set = 'qesInfo.follow'
166 | qesInfo.where({
167 | _id:that.data.qesId
168 | }).update({
169 | data:{
170 | follow:db.command.inc(1)
171 | }
172 | }).then(res => {
173 | that.setData({
174 | [set]: that.data.qesInfo.follow + 1
175 | })
176 | })
177 |
178 | },
179 |
180 | //取消关注
181 | nofollow: function () {
182 | var that = this
183 | //将问题id上传至用户集合
184 | userInfo.where({
185 | _openid: getApp().globalData.userInfo.openid
186 | }).update({
187 | data: {
188 | follow: db.command.pull(that.data.qesId)
189 | }
190 | }).then(res => {
191 | //console.log(res)
192 | that.setData({
193 | hidden: false
194 | })
195 | wx.showToast({
196 | title: '取消关注',
197 | icon: 'success'
198 | })
199 | })
200 |
201 | //更新问题信息的关注量
202 | var set = 'qesInfo.follow'
203 | qesInfo.where({
204 | _id: that.data.qesId
205 | }).update({
206 | data: {
207 | follow: db.command.inc(-1)
208 | }
209 | }).then(res => {
210 | that.setData({
211 | [set]: that.data.qesInfo.follow - 1
212 | })
213 | })
214 | }
215 |
216 | })
--------------------------------------------------------------------------------
/miniprogram/pages/answer/answer.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarTitleText": "问题详情"
3 | }
--------------------------------------------------------------------------------
/miniprogram/pages/answer/answer.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 | {{qesInfo.userSchool}}
13 | {{qesInfo.userFaculty}}
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 | {{qesInfo.details}}
25 |
26 |
27 |
28 | {{common.TimeToDate(qesInfo.qesTime,'YYYY-MM-DD')}}
29 | 关注 {{qesInfo.follow}}
30 |
31 |
32 | 回答 {{qesInfo.fileId.length}}
33 |
34 |
35 |
36 | {{item.userSchool}}
37 | {{item.userFaculty}}
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 | {{item.fileName}}
63 | {{item.fileSize}} KB
64 |
65 |
66 |
67 |
68 | {{common.TimeToDate(item.fileTime,'YYYY-MM-DD')}}
69 | 有用 {{item.good}}
70 | 下载 {{item.downLoad}}
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
--------------------------------------------------------------------------------
/miniprogram/pages/answer/answer.wxss:
--------------------------------------------------------------------------------
1 | /* pages/answer/answer.wxss */
2 | image {
3 | width: 45rpx;
4 | height: 45rpx;
5 | }
6 |
7 | .title {
8 | background-color: white;
9 | display: flex;
10 | flex-direction: row;
11 | align-items: center;
12 | justify-content: center;
13 | width: 100%;
14 | height: 60rpx;
15 | color: #555555;
16 | font-size: 28rpx;
17 | }
18 |
19 | .school {
20 | width: 40%;
21 | text-align: right;
22 | margin-right: 20rpx;
23 | /*超出容器用省略号*/
24 | white-space: nowrap;
25 | overflow: hidden;
26 | text-overflow: ellipsis;
27 | }
28 |
29 | .faculty {
30 | width: 40%;
31 | text-align: left;
32 | /*超出容器用省略号*/
33 | white-space: nowrap;
34 | overflow: hidden;
35 | text-overflow: ellipsis;
36 | }
37 |
38 | .details {
39 | background-color: white;
40 | width: 100%;
41 | display: flex;
42 | align-items: center;
43 | }
44 |
45 | .txt {
46 | width: 94%;
47 | line-height: 50rpx;
48 | font-size: 35rpx;
49 | margin-left: 3%;
50 | margin-right: 3%;
51 | margin-top: 20rpx;
52 | margin-bottom: 20rpx;
53 | }
54 |
55 | .file-add {
56 | background-color: white;
57 | display: flex;
58 | flex-direction: row;
59 | color: #AAAAAA;
60 | font-size: 25rpx;
61 | height: 40rpx;
62 | }
63 |
64 | .time {
65 | margin-left: 30rpx;
66 | width: 150rpx;
67 | }
68 |
69 | .guanzhu{
70 | width: 150rpx;
71 | text-align: right;
72 | margin-left: 370rpx;
73 | }
74 |
75 | .huida{
76 | width: 100%;
77 | background-color: #A3D2CA;
78 | margin-top: 20rpx;
79 | display: flex;
80 | align-items: center;
81 | justify-content: center;
82 | font-size: 30rpx;
83 | height: 80rpx;
84 | color: #39458F;
85 | }
86 |
87 | .user-info{
88 | background-color: white;
89 | display: flex;
90 | flex-direction: row;
91 | align-items: center;
92 | justify-content: center;
93 | width: 100%;
94 | height: 60rpx;
95 | color: #555555;
96 | font-size: 28rpx;
97 | }
98 |
99 | .school{
100 | width: 40%;
101 | text-align: right;
102 | margin-right: 20rpx;
103 | /*超出容器用省略号*/
104 | white-space: nowrap;
105 | overflow: hidden;
106 | text-overflow: ellipsis;
107 | }
108 |
109 | .faculty{
110 | width: 40%;
111 | text-align: left;
112 | /*超出容器用省略号*/
113 | white-space: nowrap;
114 | overflow: hidden;
115 | text-overflow: ellipsis;
116 | }
117 |
118 | .file-detail {
119 | background-color: white;
120 | width: 100%;
121 | height: 180rpx;
122 | display: flex;
123 | flex-direction: row;
124 | }
125 |
126 | .img-container {
127 | height: 180rpx;
128 | width: 180rpx;
129 | }
130 |
131 | .file-icon {
132 | height: 180rpx;
133 | width: 180rpx;
134 | }
135 |
136 | .namesize {
137 | display: flex;
138 | flex-direction: column;
139 | margin-top: 20rpx;
140 | }
141 |
142 | .name {
143 | width: 560rpx;
144 | font-size: 38rpx;
145 | white-space: nowrap;
146 | overflow: hidden;
147 | text-overflow: ellipsis;
148 | }
149 |
150 | .size {
151 | width: 200rpx;
152 | color: #AAAAAA;
153 | margin-top: 10rpx;
154 | margin-left: 10rpx;
155 | font-size: 25rpx;
156 | }
157 |
158 | .file-add {
159 | background-color: white;
160 | display: flex;
161 | flex-direction: row;
162 | color: #AAAAAA;
163 | font-size: 25rpx;
164 | height: 40rpx;
165 | margin-bottom: 10rpx;
166 | }
167 |
168 | .time {
169 | margin-left: 35rpx;
170 | width: 150rpx;
171 | }
172 |
173 | .download {
174 | width: 150rpx;
175 | text-align: left;
176 | margin-left: 20rpx;
177 | }
178 |
179 | .useful {
180 | width: 150rpx;
181 | text-align: right;
182 | margin-left: 270rpx;
183 | }
184 |
185 | .down{
186 | width: 100%;
187 | height: 120rpx;
188 | background-color: #A3D2CA;
189 | position: fixed;
190 | bottom: 0px;
191 | border-radius: 0rpx;
192 | font-size: 44rpx;
193 | display: flex;
194 | flex-direction: row;
195 | align-items: center;
196 | justify-content: center;
197 | }
198 |
199 | .file-display{
200 | position:relative;
201 | width: 100%;
202 | margin-bottom: 120rpx;
203 | }
204 |
205 | .file-display-change{
206 | margin-bottom: 0rpx;
207 | }
--------------------------------------------------------------------------------
/miniprogram/pages/ask/ask.js:
--------------------------------------------------------------------------------
1 | // pages/ask/ask.js
2 | const db = wx.cloud.database();
3 | const qesInfo = db.collection('Qes-Info');
4 | Page({
5 |
6 | /**
7 | * 页面的初始数据
8 | */
9 | data: {
10 | input: null,
11 | //问题信息
12 | userSchool: null,
13 | userFaculty: null,
14 | details: null,
15 | },
16 |
17 | /**
18 | * 生命周期函数--监听页面显示
19 | */
20 | onShow: function () {
21 | this.setData({
22 | userSchool: getApp().globalData.userInfo.userSchool,
23 | userFaculty: getApp().globalData.userInfo.userFaculty
24 | })
25 | },
26 |
27 | question: function (e) {
28 | this.setData({
29 | details: e.detail.value
30 | })
31 |
32 | },
33 |
34 | qesSubmit: function () {
35 | var that = this
36 | //获取当前时间戳
37 | var timestamp = Date.parse(new Date());
38 | timestamp = timestamp / 1000;
39 | if (getApp().globalData.userInfo.userSchool == '') {
40 | wx.navigateTo({
41 | url: '../load/load',
42 | })
43 | } else {
44 | if (that.data.details == null||that.data.details=="") {
45 | wx.showModal({
46 | title: '温馨提示',
47 | content: '您还未填写问题哦~',
48 | showCancel: false,
49 | success(res) {}
50 | })
51 | } else {
52 | qesInfo.add({
53 | data: {
54 | userSchool: that.data.userSchool,
55 | userFaculty: that.data.userFaculty,
56 | details: that.data.details,
57 | fileId: [],
58 | follow: 0,
59 | qesTime: timestamp
60 | }
61 | }).then(res => {
62 | //console.log('点击发布的返回值:', res)
63 | wx.showToast({
64 | title: '发布成功',
65 | icon: 'success'
66 | })
67 | that.setData({
68 | input: '',
69 | details: null
70 | })
71 | })
72 | }
73 | }
74 |
75 | }
76 | })
--------------------------------------------------------------------------------
/miniprogram/pages/ask/ask.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarTitleText": "提问"
3 | }
--------------------------------------------------------------------------------
/miniprogram/pages/ask/ask.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/miniprogram/pages/ask/ask.wxss:
--------------------------------------------------------------------------------
1 | /* pages/ask/ask.wxss */
2 | .ask{
3 | background-color: white;
4 | height: 500rpx;
5 | width: 85%;
6 | margin: auto;
7 | margin-top: 50rpx;
8 | box-shadow: 5rpx 5rpx 20rpx rgba(85, 85, 85, 0.10);
9 | border-radius: 6rpx;
10 | }
11 |
12 | .input{
13 | width: 90%;
14 | height: 460rpx;
15 | margin: auto;
16 | margin-top: 20rpx;
17 | }
18 |
19 | .submit{
20 | width: 85%;
21 | height: 100rpx;
22 | background-color: #A3D2CA;
23 | border-radius: 0rpx;
24 | margin-top: 50rpx;
25 | font-size: 40rpx;
26 | display: flex;
27 | flex-direction: row;
28 | align-items: center;
29 | justify-content: center;
30 | border: 1rpx solid #D7D7D7;
31 | border-radius: 6rpx;
32 | }
--------------------------------------------------------------------------------
/miniprogram/pages/downfile/downfile.js:
--------------------------------------------------------------------------------
1 | // pages/downfile/downfile.js
2 | const db = wx.cloud.database();
3 | const fileInfo = db.collection('File-Info');
4 |
5 | Page({
6 |
7 | /* 页面的初始数据*/
8 | data: {
9 | //文件信息
10 | fileInfo: {},
11 | imgSrc: null,
12 | hidden: false,
13 | isMy: false
14 | },
15 |
16 | /* 生命周期函数--监听页面加载*/
17 | onLoad: function (options) {
18 | fileInfo.doc(options.id).get().then(res => {
19 | //console.log(res)
20 | this.setData({
21 | fileInfo: res.data
22 | })
23 | })
24 |
25 | if (getApp().globalData.isMyFile||getApp().globalData.userInfo.userSchool == '') {
26 | this.setData({
27 | isMy: true
28 | })
29 | getApp().globalData.isMyFile = false
30 | }
31 |
32 | },
33 |
34 | //缓存并预览文件
35 | openfile: function () {
36 | var that = this
37 | if(getApp().globalData.userInfo.userSchool == ''){
38 | wx.navigateTo({
39 | url: '../load/load',
40 | })
41 | }else{
42 | wx.showLoading({
43 | title: '加载中...',
44 | })
45 | //根据https路径可以获得http格式的路径(指定文件下载后缓存的路径 (本地路径)),根据这个路径可以预览
46 | wx.downloadFile({
47 | url: that.data.fileInfo.fileUrl,
48 | success: (res) => {
49 | //console.log(res)
50 | that.setData({
51 | httpfile: res.tempFilePath
52 | })
53 | //预览文件
54 | wx.openDocument({
55 | filePath: that.data.httpfile,
56 | showMenu: true,
57 | success: res => {
58 | wx.hideLoading()
59 | //console.log(res)
60 | },
61 | fail: err => {
62 | console.log(err);
63 | wx.hideLoading()
64 | wx.showModal({
65 | title: '温馨提示',
66 | content: '文件格式不支持预览',
67 | showCancel: false,
68 | success(res) {}
69 | })
70 | }
71 | })
72 | },
73 | fail: (err) => {
74 | console.log('读取失败', err)
75 | }
76 | })
77 | }
78 |
79 | },
80 |
81 | //复制文件路径并在浏览器打开下载
82 | savefile: function () {
83 | var that = this
84 |
85 | if(getApp().globalData.userInfo.userSchool == ''){
86 | wx.navigateTo({
87 | url: '../load/load',
88 | })
89 | }else{//复制下载链接到剪切板
90 | wx.setClipboardData({
91 | data: that.data.fileInfo.fileUrl,
92 | success: res => {
93 | //console.log(that.data.fileInfo.fileUrl)
94 | wx.showToast({
95 | title: '复制成功',
96 | icon: 'success'
97 | })
98 | }
99 | })
100 | }
101 |
102 | //更新文章下载量
103 | var set = 'fileInfo.downLoad'
104 | fileInfo.where({
105 | _id: that.data.fileInfo._id
106 | }).update({
107 | data: {
108 | downLoad: db.command.inc(1)
109 | }
110 | }).then(res => {
111 | that.setData({
112 | [set]: that.data.fileInfo.downLoad + 1
113 | })
114 | })
115 | },
116 |
117 | //点赞有用
118 | good: function () {
119 | var that = this
120 | var set = 'fileInfo.good'
121 | fileInfo.where({
122 | _id: that.data.fileInfo._id
123 | }).update({
124 | data: {
125 | good: db.command.inc(1)
126 | }
127 | }).then(res => {
128 | that.setData({
129 | [set]: that.data.fileInfo.good + 1,
130 | hidden: true
131 | })
132 | })
133 | },
134 |
135 | //取消有用
136 | noGood: function () {
137 | var that = this
138 | var set = 'fileInfo.good'
139 | fileInfo.where({
140 | _id: that.data.fileInfo._id
141 | }).update({
142 | data: {
143 | good: db.command.inc(-1)
144 | }
145 | }).then(res => {
146 | that.setData({
147 | [set]: that.data.fileInfo.good - 1,
148 | hidden: false
149 | })
150 | })
151 | }
152 |
153 | })
--------------------------------------------------------------------------------
/miniprogram/pages/downfile/downfile.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarTitleText": "下载"
3 | }
--------------------------------------------------------------------------------
/miniprogram/pages/downfile/downfile.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {{fileInfo.userSchool}}
6 | {{fileInfo.userFaculty}}
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 | {{fileInfo.fileName}}
31 | {{fileInfo.fileSize}} KB
32 |
33 |
34 |
35 |
36 |
37 | {{common.TimeToDate(fileInfo.fileTime,'YYYY-MM-DD')}}
38 | 有用 {{fileInfo.good}}
39 | 下载 {{fileInfo.downLoad}}
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 | 文件信息
49 |
50 | 作者:{{fileInfo.author}}
51 | 备注:{{fileInfo.need}} {{fileInfo.remark}}
52 |
53 |
54 |
55 |
--------------------------------------------------------------------------------
/miniprogram/pages/downfile/downfile.wxss:
--------------------------------------------------------------------------------
1 | /* pages/downfile/downfile.wxss */
2 | .user-info{
3 | background-color: white;
4 | display: flex;
5 | flex-direction: row;
6 | align-items: center;
7 | justify-content: center;
8 | width: 100%;
9 | height: 60rpx;
10 | color: #555555;
11 | font-size: 28rpx;
12 | }
13 |
14 | .school{
15 | width: 40%;
16 | text-align: right;
17 | margin-right: 20rpx;
18 | /*超出容器用省略号*/
19 | white-space: nowrap;
20 | overflow: hidden;
21 | text-overflow: ellipsis;
22 | }
23 |
24 | .faculty{
25 | width: 40%;
26 | text-align: left;
27 | /*超出容器用省略号*/
28 | white-space: nowrap;
29 | overflow: hidden;
30 | text-overflow: ellipsis;
31 | }
32 |
33 | .file-detail {
34 | background-color: white;
35 | width: 100%;
36 | height: 180rpx;
37 | display: flex;
38 | flex-direction: row;
39 | }
40 |
41 | .img-container {
42 | height: 180rpx;
43 | width: 180rpx;
44 | }
45 |
46 | .file-icon {
47 | height: 180rpx;
48 | width: 180rpx;
49 | }
50 |
51 | .namesize {
52 | display: flex;
53 | flex-direction: column;
54 | margin-top: 20rpx;
55 | }
56 |
57 | .name {
58 | width: 560rpx;
59 | font-size: 38rpx;
60 | white-space: nowrap;
61 | overflow: hidden;
62 | text-overflow: ellipsis;
63 | }
64 |
65 | .size {
66 | width: 200rpx;
67 | color: #AAAAAA;
68 | margin-top: 10rpx;
69 | margin-left: 10rpx;
70 | font-size: 25rpx;
71 | }
72 |
73 | .file-add {
74 | background-color: white;
75 | display: flex;
76 | flex-direction: row;
77 | color: #AAAAAA;
78 | font-size: 25rpx;
79 | margin-bottom: 20rpx;
80 | height: 40rpx
81 | }
82 |
83 | .time {
84 | margin-left: 35rpx;
85 | width: 150rpx;
86 | }
87 |
88 | .useful {
89 | width: 150rpx;
90 | text-align: right;
91 | margin-left: 270rpx;
92 | }
93 |
94 | .download {
95 | width: 150rpx;
96 | text-align: left;
97 | margin-left: 20rpx;
98 | }
99 |
100 | .file-info{
101 | height: 500rpx;
102 | background-color: white;
103 | display: flex;
104 | flex-direction: column;
105 | margin-top: 10rpx;
106 | margin-left: 2%;
107 | margin-right: 2%;
108 | border-radius: 40rpx;
109 | box-shadow: 5rpx 5rpx 20rpx rgba(85, 85, 85, 0.10);
110 | }
111 |
112 | .title {
113 | background-color: #A3D2CA;
114 | height: 100rpx;
115 | font-size: 40rpx;
116 | /*实现容器内的文字居中*/
117 | display: flex;
118 | align-items: center;
119 | justify-content: center;
120 | border-top-left-radius: 40rpx;
121 | border-top-right-radius: 40rpx;
122 | }
123 |
124 | .all{
125 | height: 300rpx;
126 | width: 90%;
127 | margin: auto;
128 | margin-top: 50rpx;
129 | display: flex;
130 | flex-direction: column;
131 | color: #555555;
132 | word-break: break-all;
133 | }
134 |
135 | .zuozhe{
136 | margin-bottom: 20rpx;
137 | }
138 |
139 | .down{
140 | width: 100%;
141 | height: 120rpx;
142 | background-color: #A3D2CA;
143 | position: fixed;
144 | bottom: 0px;
145 | border-radius: 0rpx;
146 | font-size: 44rpx;
147 | display: flex;
148 | flex-direction: row;
149 | align-items: center;
150 | justify-content: center;
151 | }
152 |
153 | .tishi{
154 | font-size: 28rpx;
155 | color:grey;
156 | }
157 |
158 | .good-btn{
159 | background-color: #6DB4D3;
160 | margin-top: 20rpx;
161 | margin-bottom: 30rpx;
162 | border-radius:50rpx;
163 | width: 300rpx;
164 | box-shadow: 5rpx 5rpx 20rpx rgba(85, 85, 85, 0.10);
165 | text-align: center;
166 | font-size: 35rpx;
167 | }
168 |
169 | .red{
170 | background-color: #EC808D;
171 | }
--------------------------------------------------------------------------------
/miniprogram/pages/load/load.js:
--------------------------------------------------------------------------------
1 | // pages/load/load.js
2 | const db = wx.cloud.database();
3 | Page({
4 |
5 | /**
6 | * 页面的初始数据
7 | */
8 | data: {
9 | canIUse: wx.canIUse('button.open-type.getUserInfo') //判断用户微信版本有无授权功能
10 | },
11 |
12 | /**
13 | * 生命周期函数--监听页面加载
14 | */
15 | onLoad: function (options) {
16 | //加载中
17 | wx.showLoading({
18 | title: '加载中',
19 | })
20 |
21 | //计时器
22 | setTimeout(function () {
23 | wx.hideLoading()
24 | }, 500)
25 |
26 | },
27 |
28 | //用户第一次登陆授权弹窗
29 | bindGetUserInfo(e) {
30 | //console.log('用户信息', e.detail.userInfo)
31 | if (e.detail.userInfo) {
32 | //获取用户的openid并存入全局变量
33 | getApp().getOpenid();
34 |
35 | getApp().globalData.userInfo.avatarUrl = e.detail.userInfo.avatarUrl,
36 | getApp().globalData.userInfo.nickName = e.detail.userInfo.nickName
37 | wx.redirectTo({
38 | url: '/pages/Info/Info',
39 | })
40 | }
41 | },
42 |
43 | })
--------------------------------------------------------------------------------
/miniprogram/pages/load/load.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarTitleText": "授权"
3 | }
--------------------------------------------------------------------------------
/miniprogram/pages/load/load.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | —————— • ——————
6 | 欢迎使用小程序,我们需要一些您的公开信息,包括微信昵称、头像等。请放心,我们会妥善保管您的信息~
7 |
8 | 请升级微信版本
--------------------------------------------------------------------------------
/miniprogram/pages/load/load.wxss:
--------------------------------------------------------------------------------
1 | /* pages/load/load.wxss */
2 | .btn-container{
3 | width: 80%;
4 | margin-left: 10%;
5 | margin-right: 10%;
6 | height: 300rpx;
7 | margin-top: 350rpx;
8 | }
9 |
10 | .btn{
11 | background-color: #A3D2CA;
12 | width: 70%;
13 | }
14 |
15 | .divider{
16 | color: #7F7F7F;
17 | text-align: center;
18 | }
19 |
20 | .text{
21 | color: #7F7F7F;
22 | font-size: 28rpx;
23 | font-weight: 10rpx;
24 | width: 89%;
25 | margin-top: 15rpx;
26 | margin: auto;
27 | }
--------------------------------------------------------------------------------
/miniprogram/pages/main/main.js:
--------------------------------------------------------------------------------
1 | // pages/main/main.js
2 | const db = wx.cloud.database();
3 | const qesInfo = db.collection('Qes-Info');
4 | Page({
5 |
6 | /**
7 | * 页面的初始数据
8 | */
9 | data: {
10 | fileCollection: [],
11 | userSchool: null,
12 | userFaculty: null,
13 | filterVal: null,
14 | searchVal: null,
15 | total: 0
16 |
17 | },
18 |
19 | /* 生命周期函数--监听页面显示*/
20 | onLoad: function () {
21 | var that = this;
22 |
23 | that.pageData.skip = 20
24 |
25 | //加载中
26 | wx.showLoading({
27 | title: '加载中',
28 | })
29 |
30 | wx.login({
31 | success(res) {
32 | //console.log(res)
33 | if (res.code) {
34 | // 查看是否授权
35 | wx.getSetting({
36 | success(res) {
37 | //console.log(res)
38 | if (res.authSetting['scope.userInfo']) {
39 | getApp().getOpenid() //获取用户的openid并存入全局变量
40 | // 已经授权,可以直接调用 getUserInfo 获取头像昵称
41 | wx.getUserInfo({
42 | success: function (res) {
43 | console.log('用户信息', res.userInfo)
44 | getApp().globalData.userInfo.avatarUrl = res.userInfo.avatarUrl,
45 | getApp().globalData.userInfo.nickName = res.userInfo.nickName
46 | //console.log(getApp().globalData.userInfo.avatarUrl)
47 | }
48 | })
49 | }
50 | }
51 |
52 | })
53 | } else {
54 | console.log('登录失败!' + res.errMsg)
55 | }
56 |
57 | }
58 | })
59 |
60 | that.setData({
61 | filterVal: null
62 | })
63 |
64 | //计时器
65 | setTimeout(function () {
66 | wx.hideLoading()
67 | }, 1000)
68 |
69 | //获取问题信息集合总数
70 | qesInfo.count({
71 | success: res => {
72 | that.setData({
73 | total: res.total
74 | })
75 | }
76 | })
77 |
78 | //在云数据库qesInfo中查找问题信息集合
79 | qesInfo.orderBy('qesTime', 'desc').get({
80 | success: res => {
81 | //console.log(res)
82 | that.setData({
83 | fileCollection: res.data
84 | })
85 | },
86 | fail: err => {
87 | console.error(err)
88 | }
89 | })
90 | },
91 |
92 | /* 生命周期函数--监听页面显示*/
93 | onShow: function () {
94 | this.onLoad()
95 | },
96 |
97 | /**筛选 */
98 | //本学校
99 | mySchool: function () {
100 |
101 | var that = this
102 | if (getApp().globalData.userInfo.userSchool == '') {
103 | wx.navigateTo({
104 | url: '../load/load',
105 | })
106 | } else {
107 | that.setData({
108 | filterVal: 1,
109 | userSchool: getApp().globalData.userInfo.userSchool,
110 | userFaculty: getApp().globalData.userInfo.userFaculty,
111 | })
112 | wx.showLoading({
113 | title: '加载中...',
114 | })
115 | if (that.data.searchVal) { //搜索+本学校
116 |
117 | //获取问题信息集合总数
118 | qesInfo.where({
119 | userSchool: that.data.userSchool,
120 | details: db.RegExp({
121 | regexp: that.data.searchVal,
122 | options: 'i'
123 | })
124 | }).count({
125 | success: res => {
126 | that.setData({
127 | total: res.total
128 | })
129 | }
130 | })
131 |
132 | qesInfo.where({
133 | userSchool: that.data.userSchool,
134 | details: db.RegExp({
135 | regexp: that.data.searchVal,
136 | options: 'i'
137 | })
138 | }).orderBy('qesTime', 'desc').get({
139 | success: res => {
140 | wx.hideLoading()
141 | that.setData({
142 | fileCollection: res.data
143 | })
144 | that.pageData.skip = 20
145 | //console.log(res, that.data.filterVal)
146 | }
147 | })
148 | } else { //本学校
149 |
150 | //获取问题信息集合总数
151 | qesInfo.where({
152 | userSchool: that.data.userSchool,
153 | }).count({
154 | success: res => {
155 | that.setData({
156 | total: res.total
157 | })
158 | }
159 | })
160 |
161 | qesInfo.where({
162 | userSchool: that.data.userSchool,
163 | }).orderBy('qesTime', 'desc').get({
164 | success: res => {
165 | wx.hideLoading()
166 | that.setData({
167 | fileCollection: res.data
168 | })
169 | that.pageData.skip = 20
170 | //console.log(res, that.data.filterVal)
171 | }
172 | })
173 | }
174 | }
175 |
176 |
177 | },
178 |
179 | //本学院
180 | myFaculty: function () {
181 | var that = this
182 | if (getApp().globalData.userInfo.userSchool == '') {
183 | wx.navigateTo({
184 | url: '../load/load',
185 | })
186 | } else {
187 | this.setData({
188 | filterVal: 2,
189 | userSchool: getApp().globalData.userInfo.userSchool,
190 | userFaculty: getApp().globalData.userInfo.userFaculty,
191 | })
192 | wx.showLoading({
193 | title: '加载中...',
194 | })
195 | if (that.data.searchVal) { //搜索+本学校+本学院
196 |
197 | //获取问题信息集合总数
198 | qesInfo.where({
199 | userSchool: that.data.userSchool,
200 | userFaculty: that.data.userFaculty,
201 | details: db.RegExp({
202 | regexp: that.data.searchVal,
203 | options: 'i'
204 | })
205 | }).count({
206 | success: res => {
207 | that.setData({
208 | total: res.total
209 | })
210 | }
211 | })
212 |
213 | qesInfo.where({
214 | userSchool: that.data.userSchool,
215 | userFaculty: that.data.userFaculty,
216 | details: db.RegExp({
217 | regexp: that.data.searchVal,
218 | options: 'i'
219 | })
220 | }).orderBy('qesTime', 'desc').get({
221 | success: res => {
222 | wx.hideLoading()
223 | that.setData({
224 | fileCollection: res.data
225 | })
226 | that.pageData.skip = 20
227 | //console.log(res, that.data.filterVal)
228 | }
229 | })
230 | } else { //本学校+本学院
231 |
232 | //获取问题信息集合总数
233 | qesInfo.where({
234 | userSchool: that.data.userSchool,
235 | userFaculty: that.data.userFaculty,
236 | }).count({
237 | success: res => {
238 | that.setData({
239 | total: res.total
240 | })
241 | }
242 | })
243 |
244 | qesInfo.where({
245 | userSchool: that.data.userSchool,
246 | userFaculty: that.data.userFaculty,
247 | }).orderBy('qesTime', 'desc').get({
248 | success: res => {
249 | wx.hideLoading()
250 | that.setData({
251 | fileCollection: res.data
252 | })
253 | that.pageData.skip = 20
254 | //console.log(res, that.data.filterVal)
255 | }
256 | })
257 | }
258 | }
259 |
260 |
261 | },
262 |
263 | //已解决
264 | solved: function () {
265 | var that = this
266 |
267 |
268 | this.setData({
269 | filterVal: 3,
270 | })
271 | wx.showLoading({
272 |
273 | title: '加载中...',
274 | })
275 | if (that.data.searchVal) { //搜索+已解决
276 |
277 | //获取问题信息集合总数
278 | qesInfo.where({
279 | fileId: db.command.not(db.command.size(0)),
280 | details: db.RegExp({
281 | regexp: that.data.searchVal,
282 | options: 'i'
283 | })
284 | }).count({
285 | success: res => {
286 | that.setData({
287 | total: res.total
288 | })
289 | }
290 | })
291 |
292 | qesInfo.where({
293 | fileId: db.command.not(db.command.size(0)),
294 | details: db.RegExp({
295 | regexp: that.data.searchVal,
296 | options: 'i'
297 | })
298 | }).orderBy('qesTime', 'desc').get({
299 | success: res => {
300 | wx.hideLoading()
301 | that.setData({
302 | fileCollection: res.data
303 | })
304 | that.pageData.skip = 20
305 | //console.log(res, that.data.filterVal)
306 | }
307 | })
308 | } else { //已解决
309 |
310 | //获取问题信息集合总数
311 | qesInfo.where({
312 | fileId: db.command.not(db.command.size(0)),
313 | }).count({
314 | success: res => {
315 | that.setData({
316 | total: res.total
317 | })
318 | }
319 | })
320 |
321 | qesInfo.where({
322 | fileId: db.command.not(db.command.size(0)), //数组长度不为0
323 | }).orderBy('qesTime', 'desc').get({
324 | success: res => {
325 | wx.hideLoading()
326 | that.setData({
327 | fileCollection: res.data
328 | })
329 | that.pageData.skip = 20
330 | //console.log(res, that.data.filterVal)
331 | }
332 | })
333 | }
334 |
335 |
336 | },
337 |
338 |
339 | //未解决
340 | unSolved: function () {
341 | var that = this
342 |
343 | this.setData({
344 | filterVal: 4,
345 | })
346 | wx.showLoading({
347 |
348 | title: '加载中...',
349 | })
350 | if (that.data.searchVal) { //搜索+未解决
351 |
352 | //获取问题信息集合总数
353 | qesInfo.where({
354 | fileId: [],
355 | details: db.RegExp({
356 | regexp: that.data.searchVal,
357 | options: 'i'
358 | })
359 | }).count({
360 | success: res => {
361 | that.setData({
362 | total: res.total
363 | })
364 | }
365 | })
366 |
367 | qesInfo.where({
368 | fileId: [],
369 | details: db.RegExp({
370 | regexp: that.data.searchVal,
371 | options: 'i'
372 | })
373 | }).orderBy('qesTime', 'desc').get({
374 | success: res => {
375 | wx.hideLoading()
376 | that.setData({
377 | fileCollection: res.data
378 | })
379 | that.pageData.skip = 20
380 | //console.log(res, that.data.filterVal)
381 | }
382 | })
383 | } else { //未解决
384 |
385 | //获取问题信息集合总数
386 | qesInfo.where({
387 | fileId: []
388 | }).count({
389 | success: res => {
390 | that.setData({
391 | total: res.total
392 | })
393 | }
394 | })
395 |
396 | qesInfo.where({
397 | fileId: [],
398 | }).orderBy('qesTime', 'desc').get({
399 | success: res => {
400 | wx.hideLoading()
401 | that.setData({
402 | fileCollection: res.data
403 | })
404 | that.pageData.skip = 20
405 | //console.log(res, that.data.filterVal)
406 | }
407 | })
408 | }
409 |
410 |
411 | },
412 |
413 | //全部
414 | all: function () {
415 | var that = this
416 |
417 | wx.showLoading({
418 | title: '加载中...',
419 | })
420 | if (that.data.searchVal) {
421 |
422 | //获取问题信息集合总数
423 | qesInfo.where({
424 | details: db.RegExp({
425 | regexp: that.data.searchVal,
426 | options: 'i'
427 | })
428 | }).count({
429 | success: res => {
430 | that.setData({
431 | total: res.total
432 | })
433 | }
434 | })
435 |
436 | qesInfo.where({
437 | details: db.RegExp({
438 | regexp: that.data.searchVal,
439 | options: 'i'
440 | })
441 | }).orderBy('qesTime', 'desc').get({
442 | success: res => {
443 | wx.hideLoading()
444 | that.setData({
445 | fileCollection: res.data,
446 | filterVal: null
447 | })
448 | //console.log(res, that.data.searchVal)
449 | that.pageData.skip = 20
450 | }
451 | })
452 | } else {
453 | //获取问题信息集合总数
454 | qesInfo.count({
455 | success: res => {
456 | that.setData({
457 | total: res.total
458 | })
459 | }
460 | })
461 |
462 | qesInfo.orderBy('qesTime', 'desc').get({
463 | success: res => {
464 | wx.hideLoading()
465 | console.log(res)
466 | that.setData({
467 | fileCollection: res.data,
468 | filterVal: null
469 | })
470 | that.pageData.skip = 20
471 | },
472 | fail: err => {
473 | console.error(err)
474 | }
475 | })
476 | }
477 |
478 |
479 | },
480 |
481 |
482 | /*关键字搜索*/
483 | input: function (e) {
484 | this.setData({
485 | searchVal: e.detail.value
486 | })
487 | },
488 |
489 | search: function () {
490 | var that = this
491 |
492 | //获取问题信息集合总数
493 | qesInfo.where({
494 | details: db.RegExp({
495 | regexp: that.data.searchVal,
496 | options: 'i'
497 | })
498 | }).count({
499 | success: res => {
500 | that.setData({
501 | total: res.total
502 | })
503 | }
504 | })
505 |
506 | wx.showLoading({
507 | title: '加载中...',
508 | })
509 | qesInfo.where({
510 | details: db.RegExp({
511 | regexp: that.data.searchVal,
512 | options: 'i'
513 | })
514 | }).orderBy('qesTime', 'desc').get({
515 | success: res => {
516 | wx.hideLoading()
517 | that.setData({
518 | fileCollection: res.data,
519 | filterVal: null
520 | })
521 | that.pageData.skip = 20
522 | //console.log(res, that.data.searchVal)
523 | }
524 | })
525 | },
526 |
527 | /*下拉刷新*/
528 | onReachBottom: function () {
529 | var that = this;
530 | wx.showLoading({
531 | title: '数据加载中',
532 | })
533 | if (that.data.searchVal) { //用户搜索结果下拉刷新
534 | if (that.data.filterVal == 1) { //本学校筛选
535 | qesInfo.where({
536 | userSchool: that.data.userSchool,
537 | detail: db.RegExp({
538 | regexp: that.data.searchVal,
539 | options: 'i'
540 | })
541 | }).skip(that.pageData.skip).orderBy('qesTime', 'desc').get({
542 | success: res => {
543 | //console.log(res)
544 | wx.hideLoading()
545 | let oldData = that.data.fileCollection
546 | that.setData({
547 | fileCollection: oldData.concat(res.data)
548 | })
549 | that.pageData.skip = that.pageData.skip + 20;
550 | },
551 | fail: err => {
552 | console.error(err)
553 | }
554 | })
555 | } else if (that.data.filterVal == 2) { //本学院筛选
556 | qesInfo.where({
557 | userSchool: that.data.userSchool,
558 | userFaculty: that.data.userFaculty,
559 | details: db.RegExp({
560 | regexp: that.data.searchVal,
561 | options: 'i'
562 | })
563 | }).skip(that.pageData.skip).orderBy('qesTime', 'desc').get({
564 | success: res => {
565 | //console.log(res)
566 | wx.hideLoading()
567 | let oldData = that.data.fileCollection
568 | that.setData({
569 | fileCollection: oldData.concat(res.data)
570 | })
571 | that.pageData.skip = that.pageData.skip + 20;
572 | },
573 | fail: err => {
574 | console.error(err)
575 | }
576 | })
577 | } else if (that.data.filterVal == 3) { //已解决筛选
578 | qesInfo.where({
579 | fileId: db.command.not(db.command.size(0)), //数组长度不为0
580 | details: db.RegExp({
581 | regexp: that.data.searchVal,
582 | options: 'i'
583 | })
584 | }).skip(that.pageData.skip).orderBy('qesTime', 'desc').get({
585 | success: res => {
586 | //console.log(res)
587 | wx.hideLoading()
588 | let oldData = that.data.fileCollection
589 | that.setData({
590 | fileCollection: oldData.concat(res.data)
591 | })
592 | that.pageData.skip = that.pageData.skip + 20;
593 | },
594 | fail: err => {
595 | console.error(err)
596 | }
597 | })
598 | } else if (that.data.filterVal == 4) { //未解决筛选
599 | qesInfo.where({
600 | fileId: [],
601 | details: db.RegExp({
602 | regexp: that.data.searchVal,
603 | options: 'i'
604 | })
605 | }).skip(that.pageData.skip).orderBy('qesTime', 'desc').get({
606 | success: res => {
607 | //console.log(res)
608 | wx.hideLoading()
609 | let oldData = that.data.fileCollection
610 | that.setData({
611 | fileCollection: oldData.concat(res.data)
612 | })
613 | that.pageData.skip = that.pageData.skip + 20;
614 | },
615 | fail: err => {
616 | console.error(err)
617 | }
618 | })
619 | } else { //纯搜索无筛选
620 | qesInfo.where({
621 | details: db.RegExp({
622 | regexp: that.data.searchVal,
623 | options: 'i'
624 | })
625 | }).skip(that.pageData.skip).orderBy('qesTime', 'desc').get({
626 | success: res => {
627 | //console.log(res)
628 | wx.hideLoading()
629 | let oldData = that.data.fileCollection
630 | that.setData({
631 | fileCollection: oldData.concat(res.data)
632 | })
633 | that.pageData.skip = that.pageData.skip + 20;
634 | },
635 | fail: err => {
636 | console.error(err)
637 | }
638 | })
639 | }
640 |
641 | } else { //所有资源下拉刷新
642 | if (that.data.filterVal == 1) { //本学校筛选
643 | qesInfo.where({
644 | userSchool: that.data.userSchool,
645 | }).skip(that.pageData.skip).orderBy('qesTime', 'desc').get({
646 | success: res => {
647 | //console.log(res)
648 | wx.hideLoading()
649 | let oldData = that.data.fileCollection
650 | that.setData({
651 | fileCollection: oldData.concat(res.data)
652 | })
653 | that.pageData.skip = that.pageData.skip + 20;
654 | },
655 | fail: err => {
656 | console.error(err)
657 | }
658 | })
659 | } else if (that.data.filterVal == 2) { //本学院筛选
660 | qesInfo.where({
661 | userSchool: that.data.userSchool,
662 | userFaculty: that.data.userFaculty,
663 | }).skip(that.pageData.skip).orderBy('qesTime', 'desc').get({
664 | success: res => {
665 | //console.log(res)
666 | wx.hideLoading()
667 | let oldData = that.data.fileCollection
668 | that.setData({
669 | fileCollection: oldData.concat(res.data)
670 | })
671 | that.pageData.skip = that.pageData.skip + 20;
672 | },
673 | fail: err => {
674 | console.error(err)
675 | }
676 | })
677 | } else if (that.data.filterVal == 3) { //已解决筛选
678 | qesInfo.where({
679 | fileId: db.command.not(db.command.size(0)), //数组长度不为0
680 | }).skip(that.pageData.skip).orderBy('qesTime', 'desc').get({
681 | success: res => {
682 | //console.log(res)
683 | wx.hideLoading()
684 | let oldData = that.data.fileCollection
685 | that.setData({
686 | fileCollection: oldData.concat(res.data)
687 | })
688 | that.pageData.skip = that.pageData.skip + 20;
689 | },
690 | fail: err => {
691 | console.error(err)
692 | }
693 | })
694 | } else if (that.data.filterVal == 4) { //未解决筛选
695 | qesInfo.where({
696 | fileId: [],
697 | }).skip(that.pageData.skip).orderBy('qesTime', 'desc').get({
698 | success: res => {
699 | //console.log(res)
700 | wx.hideLoading()
701 | let oldData = that.data.fileCollection
702 | that.setData({
703 | fileCollection: oldData.concat(res.data)
704 | })
705 | that.pageData.skip = that.pageData.skip + 20;
706 | },
707 | fail: err => {
708 | console.error(err)
709 | }
710 | })
711 | } else { //无筛选
712 | qesInfo.skip(that.pageData.skip).orderBy('qesTime', 'desc').get({
713 | success: res => {
714 | //console.log(res)
715 | wx.hideLoading()
716 | let oldData = that.data.fileCollection
717 | that.setData({
718 | fileCollection: oldData.concat(res.data)
719 | })
720 | that.pageData.skip = that.pageData.skip + 20;
721 | },
722 | fail: err => {
723 | console.error(err)
724 | }
725 | })
726 | }
727 | }
728 |
729 | },
730 | //存放触底刷新跳过的页面数
731 | pageData: {
732 | skip: 20
733 | }
734 | })
--------------------------------------------------------------------------------
/miniprogram/pages/main/main.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarTitleText": "问答"
3 | }
--------------------------------------------------------------------------------
/miniprogram/pages/main/main.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 | 全部
13 | 本学校
14 | 本学院
15 | 已解决
16 | 未解决
17 | 共 {{total}} 项
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 | {{item.userSchool}}
30 | {{item.userFaculty}}
31 |
32 |
33 |
34 | {{item.details}}
35 |
36 |
37 |
38 | {{common.TimeToDate(item.qesTime,'YYYY-MM-DD')}}
39 | 回答 {{item.fileId.length}}
40 | 关注 {{item.follow}}
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/miniprogram/pages/main/main.wxss:
--------------------------------------------------------------------------------
1 | /* pages/main/main.wxss */
2 |
3 | .hover {
4 | color: #000080;
5 | }
6 |
7 | .search {
8 | background-color: white;
9 | width: 80%;
10 | margin: auto;
11 | height: 80rpx;
12 | display: flex;
13 | flex-direction: row;
14 | align-items: center;
15 | border: 1rpx solid #AAAAAA;
16 | border-radius: 10rpx;
17 | margin-top: 20rpx;
18 | padding-left: 20rpx;
19 | }
20 |
21 | .enter {
22 | width: 520rpx;
23 | }
24 |
25 | image {
26 | width: 45rpx;
27 | height: 45rpx;
28 | }
29 |
30 | .search-icon {
31 | width: 50rpx;
32 | height: 50rpx;
33 | margin-left: 20rpx;
34 | }
35 |
36 | .filter {
37 | background-color: #A3D2CA;
38 | color: #555;
39 | font-size: 32rpx;
40 | width: 100%;
41 | height: 80rpx;
42 | display: flex;
43 | flex-direction: row;
44 | align-items: center;
45 | margin-top: 30rpx;
46 | }
47 |
48 | .manage {
49 | margin-left: 20rpx;
50 | display: flex;
51 | flex-direction: row;
52 | align-items: center;
53 | justify-content: center;
54 | height: 100%;
55 | }
56 |
57 | .total {
58 | width: 170rpx;
59 | margin-left: 20rpx;
60 | font-size: 24rpx;
61 | text-align: right;
62 | }
63 |
64 | .title {
65 | background-color:white;
66 | display: flex;
67 | flex-direction: row;
68 | align-items: center;
69 | justify-content: center;
70 | width: 100%;
71 | height: 60rpx;
72 | color: #555555;
73 | font-size: 28rpx;
74 | }
75 |
76 | .school {
77 | width: 40%;
78 | text-align: right;
79 | margin-right: 20rpx;
80 | /*超出容器用省略号*/
81 | white-space: nowrap;
82 | overflow: hidden;
83 | text-overflow: ellipsis;
84 | }
85 |
86 | .faculty {
87 | width: 40%;
88 | text-align: left;
89 | /*超出容器用省略号*/
90 | white-space: nowrap;
91 | overflow: hidden;
92 | text-overflow: ellipsis;
93 | }
94 |
95 | .details {
96 | background-color: white;
97 | width: 100%;
98 | height: 140rpx;
99 | display: flex;
100 | align-items: center;
101 | }
102 |
103 | .txt {
104 | width: 94%;
105 | height: 100rpx;
106 | line-height: 50rpx;
107 | font-size: 35rpx;
108 | margin-left: 3%;
109 | margin-right: 3%;
110 | /*文本显示两行,超出容器用省略号表示*/
111 | overflow: hidden;
112 | text-overflow: ellipsis;
113 | display: -webkit-box;
114 | -webkit-line-clamp: 2;
115 | -webkit-box-orient: vertical;
116 | }
117 |
118 | .file-add {
119 | background-color: white;
120 | display: flex;
121 | flex-direction: row;
122 | color: #AAAAAA;
123 | font-size: 25rpx;
124 | height: 40rpx;
125 | margin-bottom: 10rpx;
126 | }
127 |
128 | .time {
129 | margin-left: 35rpx;
130 | width: 150rpx;
131 | }
132 |
133 | .useful {
134 | width: 150rpx;
135 | text-align: right;
136 | margin-left: 270rpx;
137 | }
138 |
139 | .download {
140 | width: 150rpx;
141 | text-align: left;
142 | margin-left: 20rpx;
143 | }
--------------------------------------------------------------------------------
/miniprogram/pages/mine/mine.js:
--------------------------------------------------------------------------------
1 | // pages/mine/mine.js
2 | const db = wx.cloud.database()
3 | const userInfo = db.collection('User-Info')
4 | Page({
5 |
6 | /**
7 | * 页面的初始数据
8 | */
9 | data: {
10 | userImg: null,
11 | userName: "点击登录",
12 | userOpenid: null,
13 | userSchool: '',
14 | userFaculty: '',
15 | showModal: false,
16 | change: false,
17 | info_hidden: true,
18 | },
19 |
20 | /**
21 | * 生命周期函数--监听页面加载
22 | */
23 | onLoad: function (options) {
24 |
25 | var app = getApp()
26 | var that = this
27 | app.globalData.isMyFile = false
28 | app.globalData.isMyQes = false
29 | console.log(app.globalData.userInfo.userSchool)
30 | setTimeout(function () {
31 | if (app.globalData.userInfo.userSchool != '') {
32 | that.setData({
33 | userImg: app.globalData.userInfo.avatarUrl,
34 | userName: app.globalData.userInfo.nickName,
35 | userOpenid: app.globalData.userInfo.openid,
36 | userSchool: app.globalData.userInfo.userSchool,
37 | userFaculty: app.globalData.userInfo.userFaculty,
38 | info_hidden: false
39 | })
40 | } else {
41 | that.setData({
42 | info_hidden: true,
43 | })
44 | }
45 | }, 1000)
46 |
47 |
48 | },
49 |
50 | onShow: function () {
51 | this.onLoad()
52 | //getApp().globalData.isMyFile = false
53 | //getApp().globalData.isMyQes = false
54 | },
55 |
56 | //点击头像授权登录
57 | authorize: function () {
58 | if(getApp().globalData.userInfo.userSchool == ''){
59 | wx.navigateTo({
60 | url: '../load/load',
61 | })
62 | }
63 | },
64 |
65 | //修改信息
66 | change: function () {
67 | this.setData({
68 | showModal: true
69 | })
70 | },
71 |
72 | close: function () {
73 | this.setData({
74 | showModal: false
75 | })
76 | },
77 |
78 | preventTouchMove: function () {},
79 |
80 | school: function (e) {
81 | this.setData({
82 | userSchool: e.detail.value,
83 | change: true
84 | })
85 | //console.log(this.data.userSchool)
86 | },
87 |
88 | faculty: function (e) {
89 | this.setData({
90 | userFaculty: e.detail.value,
91 | change: true
92 | })
93 | //console.log(this.data.userFaculty)
94 | },
95 |
96 | infoSubmit: function () {
97 | var that = this
98 | var app = getApp()
99 | if (that.data.change == true) {
100 | userInfo.where({
101 | _openid: that.data.userOpenid
102 | }).update({
103 | data: {
104 | school: that.data.userSchool,
105 | faculty: that.data.userFaculty
106 | },
107 | success: res => {
108 | app.globalData.userInfo.userSchool = that.data.userSchool,
109 | app.globalData.userInfo.userFaculty = that.data.userFaculty
110 | wx.showToast({
111 | title: '更改成功',
112 | icon: 'success'
113 | })
114 | that.setData({
115 | showModal: false,
116 | change: false
117 | })
118 | }
119 | })
120 | } else {
121 | wx.showModal({
122 | title: '温馨提示',
123 | content: '您还未填写信息哦~',
124 | showCancel: false,
125 | success(res) {}
126 | })
127 | }
128 |
129 | }
130 |
131 |
132 | })
--------------------------------------------------------------------------------
/miniprogram/pages/mine/mine.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarTitleText": "我的"
3 | }
--------------------------------------------------------------------------------
/miniprogram/pages/mine/mine.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 | {{userName}}
14 |
15 |
16 |
17 |
18 |
19 |
20 | {{userSchool}}
21 |
22 |
23 |
24 |
25 |
26 | {{userFaculty}}
27 |
28 |
29 |
30 |
31 |
32 | 我的资源
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 | 我的问题
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 | 更改信息
49 |
50 |
51 |
52 |
53 |
54 | 确定
55 | 取消
56 |
57 |
58 |
--------------------------------------------------------------------------------
/miniprogram/pages/mine/mine.wxss:
--------------------------------------------------------------------------------
1 | /* pages/mine/mine.wxss */
2 | .user-info {
3 | background-color: white;
4 | display: flex;
5 | flex-direction: row;
6 | width: 100%;
7 | height: 180rpx;
8 | }
9 |
10 | .info-one {
11 | width: 50%;
12 | height: 100%;
13 | display: flex;
14 | flex-direction: row;
15 | }
16 |
17 | .pic {
18 | margin-top: 15rpx;
19 | margin-left: 12rpx;
20 | width: 150rpx;
21 | height: 150rpx;
22 | border-radius: 50%;
23 | }
24 |
25 | .name {
26 | font-size: 30rpx;
27 | margin: auto;
28 | margin-left: 15rpx;
29 | /*超出容器用省略号*/
30 | white-space: nowrap;
31 | overflow: hidden;
32 | text-overflow: ellipsis;
33 | }
34 |
35 | .info-two {
36 | font-size: 30rpx;
37 | width: 50%;
38 | height: 100%;
39 | padding-left: 50rpx;
40 | padding-top: 30rpx;
41 | padding-right: 12rpx;
42 | display: flex;
43 | flex-direction: column;
44 | }
45 |
46 | .icon {
47 | margin-right: 10rpx;
48 | width: 50rpx;
49 | height: 50rpx;
50 | }
51 |
52 | .school {
53 | margin-bottom: 10rpx;
54 | display: flex;
55 | flex-direction: row;
56 | }
57 |
58 | .text {
59 | width: 250rpx;
60 | white-space: nowrap;
61 | overflow: hidden;
62 | text-overflow: ellipsis;
63 | }
64 |
65 | .mine {
66 | padding-left: 20rpx;
67 | border-radius: 15rpx;
68 | margin-top: 30rpx;
69 | background-color: white;
70 |
71 | height: 100rpx;
72 | display: flex;
73 | flex-direction: row;
74 | align-items: center;
75 | }
76 |
77 | .title {
78 | margin-right: 540rpx;
79 | font-size: 30rpx;
80 | }
81 |
82 | .img-container{
83 | width: 50rpx;
84 | height: 50rpx;
85 | }
86 |
87 | .jiantou {
88 | width: 50rpx;
89 | height: 50rpx;
90 | }
91 |
92 | .unique{
93 | margin-top: 3rpx;
94 | }
95 |
96 | /*蒙版*/
97 | .mask {
98 | width: 100%;
99 | height: 100%;
100 | position: fixed;
101 | top: 0;
102 | left: 0;
103 | background: #000;
104 | z-index: 9000;
105 | opacity: 0.7;/*透明度*/
106 | }
107 |
108 | .modalDlg {
109 | width: 580rpx;
110 | height: 450rpx;
111 | position: fixed;
112 | top: 50%;
113 | left: 0;
114 | z-index: 9999;
115 | margin: -370rpx 85rpx;
116 | background-color: #fff;
117 | border-radius: 36rpx;
118 | }
119 |
120 | .ch-title{
121 | background-color: #A3D2CA;
122 | width: 100%;
123 | height: 80rpx;
124 | font-size: 36rpx;
125 | display: flex;
126 | flex-direction: row;
127 | align-items: center;
128 | justify-content: center;
129 | border-top-right-radius: 36rpx;
130 | border-top-left-radius: 36rpx;
131 | }
132 |
133 | .ch-info{
134 | width: 90%;
135 | height: 260rpx;
136 | margin: auto;
137 | display: flex;
138 | flex-direction: column;
139 | align-items: center;
140 | }
141 |
142 | .ch-input{
143 | background-color: white;
144 | width: 90%;
145 | height: 80rpx;
146 | font-size: 35rpx;
147 | padding-left: 15rpx;
148 | margin-top: 30rpx;
149 | border: 1rpx solid #D7D7D7;
150 | border-radius: 10rpx;
151 | }
152 |
153 | .ch-btn{
154 | width: 90%;
155 | height: 110rpx;
156 | margin: auto;
157 | display: flex;
158 | flex-direction: row;
159 | justify-content: center;
160 | }
161 |
162 | .same{
163 | width: 47%;
164 | height: 80rpx;
165 | display: flex;
166 | align-items: center;
167 | justify-content: center;
168 | font-size: 37rpx;
169 | }
170 |
171 | .ok{
172 | background-color: #EC808D;
173 | border-top-left-radius: 10rpx;
174 | border-bottom-left-radius: 10rpx;
175 | }
176 |
177 | .cancel{
178 | background-color: #6DB4D3;
179 | border-top-right-radius: 10rpx;
180 | border-bottom-right-radius: 10rpx;
181 | }
--------------------------------------------------------------------------------
/miniprogram/pages/myFile/myFile.js:
--------------------------------------------------------------------------------
1 | // pages/myFile/myFile.js
2 | const db = wx.cloud.database();
3 | const fileInfo = db.collection('File-Info');
4 | Page({
5 | /* 页面的初始数据*/
6 | data: {
7 | fileCollection: [],
8 | searchVal: null,
9 | total: 0
10 | },
11 |
12 | /* 生命周期函数--监听页面加载*/
13 | onLoad: function (options) {
14 | var that = this;
15 | getApp().globalData.isMyFile = true
16 |
17 | //获取集合总数
18 | fileInfo.where({
19 | _openid: getApp().globalData.userInfo.openid
20 | }).count({
21 | success: res => {
22 | that.setData({
23 | total: res.total
24 | })
25 | }
26 | })
27 |
28 | //在云数据库fileInfo中根据用户openid查找文件信息集合
29 | fileInfo.where({
30 | _openid: getApp().globalData.userInfo.openid
31 | }).orderBy('fileTime', 'desc').get({
32 | success: res => {
33 | //console.log(res)
34 | that.setData({
35 | fileCollection: res.data
36 | })
37 | },
38 | fail: err => {
39 | console.error(err)
40 | }
41 | })
42 | },
43 |
44 | onShow:function(){
45 | getApp().globalData.isMyFile = true
46 | },
47 |
48 | //关键字搜索
49 | input: function (e) {
50 | this.setData({
51 | searchVal: e.detail.value
52 | })
53 | },
54 |
55 | search: function () {
56 | var that = this
57 | wx.showLoading({
58 | title: '加载中...',
59 | })
60 |
61 | //获取集合总数
62 | fileInfo.where({
63 | _openid: getApp().globalData.userInfo.openid,
64 | fileName: db.RegExp({
65 | regexp: that.data.searchVal,
66 | options: 'i'
67 | })
68 | }).count({
69 | success: res => {
70 | that.setData({
71 | total: res.total
72 | })
73 | }
74 | })
75 |
76 |
77 | fileInfo.where({
78 | _openid: getApp().globalData.userInfo.openid,
79 | fileName: db.RegExp({
80 | regexp: that.data.searchVal,
81 | options: 'i'
82 | })
83 | }).orderBy('fileTime', 'desc').get({
84 | success: res => {
85 | wx.hideLoading()
86 | that.setData({
87 | fileCollection: res.data
88 | })
89 | that.pageData.skip = 20
90 | //console.log(res, that.data.searchVal)
91 | }
92 | })
93 | },
94 |
95 | //下拉刷新
96 | onReachBottom: function () {
97 | var that = this;
98 | wx.showLoading({
99 | title: '数据加载中',
100 | })
101 | if (that.data.searchVal) { //用户搜索结果下拉刷新
102 | fileInfo.where({
103 | _openid: getApp().globalData.userInfo.openid,
104 | fileName: db.RegExp({
105 | regexp: that.data.searchVal,
106 | options: 'i'
107 | })
108 | }).skip(that.pageData.skip).orderBy('fileTime', 'desc').get({
109 | success: res => {
110 | //console.log(res)
111 | wx.hideLoading()
112 | let oldData = that.data.fileCollection
113 | that.setData({
114 | fileCollection: oldData.concat(res.data)
115 | })
116 | that.pageData.skip = that.pageData.skip + 20;
117 | },
118 | fail: err => {
119 | console.error(err)
120 | }
121 | })
122 | } else { //所有资源下拉刷新
123 | fileInfo.where({
124 | _openid: getApp().globalData.userInfo.openid
125 | }).skip(that.pageData.skip).orderBy('fileTime', 'desc').get({
126 | success: res => {
127 | //console.log(res)
128 | wx.hideLoading()
129 | let oldData = that.data.fileCollection
130 | that.setData({
131 | fileCollection: oldData.concat(res.data)
132 | })
133 | that.pageData.skip = that.pageData.skip + 20;
134 | },
135 | fail: err => {
136 | console.error(err)
137 | }
138 | })
139 |
140 | }
141 |
142 | },
143 | //存放触底刷新跳过的页面数
144 | pageData: {
145 | skip: 20
146 | }
147 |
148 | })
--------------------------------------------------------------------------------
/miniprogram/pages/myFile/myFile.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarTitleText": "我的资源"
3 | }
--------------------------------------------------------------------------------
/miniprogram/pages/myFile/myFile.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 | 共 {{total}} 项
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 | {{item.fileName}}
40 | {{item.fileSize}} KB
41 |
42 |
43 |
44 |
45 | {{common.TimeToDate(item.fileTime,'YYYY-MM-DD')}}
46 | 有用 {{item.good}}
47 | 下载 {{item.downLoad}}
48 |
49 |
50 |
51 |
--------------------------------------------------------------------------------
/miniprogram/pages/myFile/myFile.wxss:
--------------------------------------------------------------------------------
1 | /* pages/myFile/myFile.wxss */
2 | .search {
3 | background-color: white;
4 | width: 80%;
5 | margin: auto;
6 | height: 80rpx;
7 | display: flex;
8 | flex-direction: row;
9 | align-items: center;
10 | border: 1rpx solid #D7D7D7;
11 | border-radius: 10rpx;
12 | margin-top: 20rpx;
13 | padding-left: 20rpx;
14 | }
15 |
16 | .enter {
17 | width: 520rpx;
18 | }
19 |
20 | image {
21 | width: 45rpx;
22 | height: 45rpx;
23 | }
24 |
25 | .search-icon {
26 | width: 50rpx;
27 | height: 50rpx;
28 | margin-left: 20rpx;
29 | }
30 |
31 | .filter {
32 | background-color: #A3D2CA;
33 | border: 1rpx solid #D7D7D7;
34 | width: 100%;
35 | height: 80rpx;
36 | display: flex;
37 | flex-direction: row;
38 | align-items: center;
39 | margin-top: 30rpx;
40 | }
41 |
42 | .manage {
43 | width: 100rpx;
44 | margin-left: 20rpx;
45 | font-size: 28rpx;
46 | }
47 |
48 | .total {
49 | width: 200rpx;
50 | margin-left: 500rpx;
51 | font-size: 24rpx;
52 | text-align: right;
53 | }
54 |
55 | .file-detail {
56 | background-color: white;
57 | width: 100%;
58 | height: 180rpx;
59 | display: flex;
60 | flex-direction: row;
61 | }
62 |
63 | .img-container {
64 | height: 180rpx;
65 | width: 180rpx;
66 | }
67 |
68 | .file-icon {
69 | height: 180rpx;
70 | width: 180rpx;
71 | }
72 |
73 | .namesize {
74 | display: flex;
75 | flex-direction: column;
76 | margin-top: 20rpx;
77 | }
78 |
79 | .name {
80 | width: 560rpx;
81 | font-size: 38rpx;
82 | white-space: nowrap;
83 | overflow: hidden;
84 | text-overflow: ellipsis;
85 | }
86 |
87 | .size {
88 | width: 200rpx;
89 | color: #AAAAAA;
90 | margin-top: 10rpx;
91 | margin-left: 10rpx;
92 | font-size: 25rpx;
93 | }
94 |
95 | .file-add {
96 | background-color: white;
97 | display: flex;
98 | flex-direction: row;
99 | color: #AAAAAA;
100 | font-size: 25rpx;
101 | margin-bottom: 10rpx;
102 | height: 40rpx
103 | }
104 |
105 | .time {
106 | margin-left: 35rpx;
107 | width: 150rpx;
108 | }
109 |
110 | .useful {
111 | width: 150rpx;
112 | text-align: right;
113 | margin-left: 270rpx;
114 | }
115 |
116 | .download {
117 | width: 150rpx;
118 | text-align: left;
119 | margin-left: 20rpx;
120 | }
--------------------------------------------------------------------------------
/miniprogram/pages/myQes/myQes.js:
--------------------------------------------------------------------------------
1 | // pages/myQes/myQes.js
2 | const db = wx.cloud.database();
3 | const qesInfo = db.collection('Qes-Info');
4 | const userInfo = db.collection('User-Info')
5 | Page({
6 |
7 | /**
8 | * 页面的初始数据
9 | */
10 | data: {
11 | fileCollection: [],
12 | searchVal: null,
13 | total: 0,
14 | filterVal: null,
15 | userOpenid: null,
16 | userInfo: {}
17 | },
18 |
19 | /**
20 | * 生命周期函数--监听页面加载
21 | */
22 | onLoad: function (options) {
23 | var that = this;
24 | getApp().globalData.isMyQes = true
25 |
26 | //获取集合总数
27 | qesInfo.where({
28 | _openid: getApp().globalData.userInfo.openid
29 | }).count({
30 | success: res => {
31 | that.setData({
32 | total: res.total,
33 | userOpenid: getApp().globalData.userInfo.openid
34 | })
35 | }
36 | })
37 |
38 | //在云数据库qesInfo中根据用户openid查找问题信息集合
39 | qesInfo.where({
40 | _openid: getApp().globalData.userInfo.openid
41 | }).orderBy('qesTime', 'desc').get({
42 | success: res => {
43 | //console.log(res)
44 | that.setData({
45 | fileCollection: res.data
46 | })
47 | },
48 | fail: err => {
49 | console.error(err)
50 | }
51 | })
52 |
53 | },
54 |
55 | onShow:function(){
56 | getApp().globalData.isMyQes = true
57 | this.setData({
58 | filterVal: null,
59 | })
60 | this.onLoad()
61 | },
62 |
63 | /**筛选 */
64 | //我的提问
65 | ask: function () {
66 | var that = this
67 | that.setData({
68 | fileCollection: []
69 | })
70 | wx.showLoading({
71 | title: '加载中...',
72 | })
73 | if (that.data.searchVal) {
74 |
75 | //获取问题信息集合总数
76 | qesInfo.where({
77 | _openid: getApp().globalData.userInfo.openid,
78 | details: db.RegExp({
79 | regexp: that.data.searchVal,
80 | options: 'i'
81 | })
82 | }).count({
83 | success: res => {
84 | that.setData({
85 | total: res.total
86 | })
87 | }
88 | })
89 |
90 | qesInfo.where({
91 | _openid: getApp().globalData.userInfo.openid,
92 | details: db.RegExp({
93 | regexp: that.data.searchVal,
94 | options: 'i'
95 | })
96 | }).orderBy('qesTime', 'desc').get({
97 | success: res => {
98 | wx.hideLoading()
99 | that.setData({
100 | fileCollection: res.data,
101 | filterVal: null
102 | })
103 | //console.log(res, that.data.searchVal)
104 | that.pageData.skip = 20
105 | }
106 | })
107 | } else {
108 | //获取问题信息集合总数
109 | qesInfo.where({
110 | _openid: getApp().globalData.userInfo.openid,
111 | }).count({
112 | success: res => {
113 | that.setData({
114 | total: res.total
115 | })
116 | }
117 | })
118 |
119 | qesInfo.orderBy('qesTime', 'desc').where({
120 | _openid: getApp().globalData.userInfo.openid,
121 | }).get({
122 | success: res => {
123 | wx.hideLoading()
124 | //console.log(res)
125 | that.setData({
126 | fileCollection: res.data,
127 | filterVal: null
128 | })
129 | that.pageData.skip = 20
130 | },
131 | fail: err => {
132 | console.error(err)
133 | }
134 | })
135 | }
136 | },
137 |
138 | //我的关注
139 | follow: function () {
140 | var that = this
141 | this.setData({
142 | filterVal: 1,
143 | fileCollection: [],
144 | })
145 | wx.showLoading({
146 | title: '加载中...',
147 | })
148 | if (that.data.searchVal) { //搜索+我的关注
149 | userInfo.where({
150 | _openid: getApp().globalData.userInfo.openid
151 | }).get().then(res => {
152 | //console.log(res)
153 | this.setData({
154 | userInfo: res.data[0],
155 | })
156 | //循环显示该问题的回答文件
157 | var length = 0
158 | var fileCollection = that.data.fileCollection
159 | var fileLength = that.data.userInfo.follow.length
160 | if (fileLength > 10) fileLength = 10
161 | for (var i = 0; i < fileLength; i++) {
162 | qesInfo.where({
163 | _id: that.data.userInfo.follow[i],
164 | details: db.RegExp({
165 | regexp: that.data.searchVal,
166 | options: 'i'
167 | })
168 | }).get({
169 | success: res => {
170 | if (res.data.length != 0) {
171 | length = length + 1
172 | //console.log(res.data[0])
173 | fileCollection.push(res.data[0])
174 | that.setData({
175 | fileCollection
176 | })
177 | }
178 | }
179 | })
180 | }
181 | that.pageData.skip = 10
182 | wx.hideLoading()
183 | setTimeout(function () {
184 | that.setData({
185 | total: length
186 | })
187 | }, 1000)
188 |
189 | })
190 | } else { //我的关注
191 | userInfo.where({
192 | _openid: getApp().globalData.userInfo.openid
193 | }).get().then(res => {
194 | //console.log(res.data[0])
195 | that.setData({
196 | userInfo: res.data[0],
197 | })
198 | //循环显示该问题的回答文件
199 | var fileCollection = that.data.fileCollection
200 | var fileLength = that.data.userInfo.follow.length
201 | if (fileLength > 10) fileLength = 10
202 | for (var i = 0; i < fileLength; i++) {
203 | qesInfo.where({
204 | _id: that.data.userInfo.follow[i],
205 | }).get({
206 | success: res => {
207 | //console.log(res)
208 | fileCollection.push(res.data[0])
209 | that.setData({
210 | fileCollection
211 | })
212 | //console.log(that.data.fileCollection)
213 | }
214 | })
215 | }
216 | setTimeout(function () {
217 | that.setData({
218 | total: that.data.userInfo.follow.length
219 | })
220 | }, 500)
221 | that.pageData.skip = 10
222 | wx.hideLoading()
223 | })
224 |
225 | }
226 | },
227 |
228 | //关键字搜索
229 | input: function (e) {
230 | this.setData({
231 | searchVal: e.detail.value
232 | })
233 | },
234 |
235 | search: function () {
236 | var that = this
237 | wx.showLoading({
238 | title: '加载中...',
239 | })
240 |
241 | //获取集合总数
242 | qesInfo.where({
243 | _openid: getApp().globalData.userInfo.openid,
244 | details: db.RegExp({
245 | regexp: that.data.searchVal,
246 | options: 'i'
247 | })
248 | }).count({
249 | success: res => {
250 | that.setData({
251 | total: res.total
252 | })
253 | }
254 | })
255 |
256 |
257 | qesInfo.where({
258 | _openid: getApp().globalData.userInfo.openid,
259 | details: db.RegExp({
260 | regexp: that.data.searchVal,
261 | options: 'i'
262 | })
263 | }).orderBy('qesTime', 'desc').get({
264 | success: res => {
265 | wx.hideLoading()
266 | that.setData({
267 | fileCollection: res.data,
268 | filterVal: null
269 | })
270 | that.pageData.skip = 20
271 | //console.log(res, that.data.searchVal)
272 | }
273 | })
274 | },
275 |
276 | //下拉刷新
277 | onReachBottom: function () {
278 | var that = this;
279 | wx.showLoading({
280 | title: '数据加载中',
281 | })
282 | if (that.data.searchVal) { //用户搜索结果下拉刷新
283 | if (that.data.filterVal == 1) { //我的关注
284 | var length=that.data.total
285 | var fileCollection = that.data.fileCollection
286 | var fileLength = that.data.userInfo.follow.length
287 | if (fileLength > that.pageData.skip + 10) fileLength = that.pageData.skip + 10
288 | for (var i = that.pageData.skip; i < fileLength; i++) {
289 | qesInfo.where({
290 | _id: that.data.userInfo.follow[i],
291 | details: db.RegExp({
292 | regexp: that.data.searchVal,
293 | options: 'i'
294 | })
295 | }).get({
296 | success: res => {
297 | if (res.data.length != 0) {
298 | length = length + 1
299 | //console.log(res.data[0])
300 | fileCollection.push(res.data[0])
301 | that.setData({
302 | fileCollection
303 | })
304 | }
305 | }
306 | })
307 | }
308 | that.pageData.skip = that.pageData.skip + 10
309 | setTimeout(function () {
310 | that.setData({
311 | total: length
312 | })
313 | wx.hideLoading()
314 | }, 1000)
315 | } else { //我的提问
316 | qesInfo.where({
317 | _openid: getApp().globalData.userInfo.openid,
318 | details: db.RegExp({
319 | regexp: that.data.searchVal,
320 | options: 'i'
321 | })
322 | }).skip(that.pageData.skip).orderBy('qesTime', 'desc').get({
323 | success: res => {
324 | //console.log(res)
325 | wx.hideLoading()
326 | let oldData = that.data.fileCollection
327 | that.setData({
328 | fileCollection: oldData.concat(res.data)
329 | })
330 | that.pageData.skip = that.pageData.skip + 20;
331 | },
332 | fail: err => {
333 | console.error(err)
334 | }
335 | })
336 | }
337 |
338 | } else { //所有资源下拉刷新
339 | if (that.data.filterVal == 1) { //我的关注
340 | var that = this;
341 | var fileCollection = that.data.fileCollection
342 | var fileLength = that.data.userInfo.follow.length
343 | if (fileLength > that.pageData.skip + 10) fileLength = that.pageData.skip + 10
344 | for (var i = that.pageData.skip; i < fileLength; i++) {
345 | qesInfo.where({
346 | _id: that.data.userInfo.follow[i],
347 | }).get({
348 | success: res => {
349 | //console.log(res)
350 | fileCollection.push(res.data[0])
351 | that.setData({
352 | fileCollection
353 | })
354 | console.log(that.data.fileCollection)
355 | }
356 | })
357 | }
358 | that.pageData.skip = that.pageData.skip + 10
359 | setTimeout(function () {
360 | wx.hideLoading()
361 | }, 1000)
362 |
363 | } else { //我的提问
364 | qesInfo.where({
365 | _openid: getApp().globalData.userInfo.openid
366 | }).skip(that.pageData.skip).orderBy('qesTime', 'desc').get({
367 | success: res => {
368 | //console.log(res)
369 | wx.hideLoading()
370 | let oldData = that.data.fileCollection
371 | that.setData({
372 | fileCollection: oldData.concat(res.data)
373 | })
374 | that.pageData.skip = that.pageData.skip + 20;
375 | },
376 | fail: err => {
377 | console.error(err)
378 | }
379 | })
380 | }
381 |
382 | }
383 |
384 | },
385 | //存放触底刷新跳过的页面数
386 | pageData: {
387 | skip: 20
388 | }
389 |
390 |
391 | })
--------------------------------------------------------------------------------
/miniprogram/pages/myQes/myQes.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarTitleText": "我的问题"
3 | }
--------------------------------------------------------------------------------
/miniprogram/pages/myQes/myQes.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 | 我的提问
13 | 我的关注
14 | 共 {{total}} 项
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 | {{item.userSchool}}
27 | {{item.userFaculty}}
28 |
29 |
30 |
31 | {{item.details}}
32 |
33 |
34 |
35 | {{common.TimeToDate(item.qesTime,'YYYY-MM-DD')}}
36 | 回答 {{item.fileId.length}}
37 | 关注 {{item.follow}}
38 |
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/miniprogram/pages/myQes/myQes.wxss:
--------------------------------------------------------------------------------
1 | /* pages/myQes/myQes.wxss */
2 | .hover {
3 | color: #000080;
4 | }
5 |
6 | .search {
7 | background-color: white;
8 | width: 80%;
9 | margin: auto;
10 | height: 80rpx;
11 | display: flex;
12 | flex-direction: row;
13 | align-items: center;
14 | border: 1rpx solid #D7D7D7;
15 | border-radius: 10rpx;
16 | margin-top: 20rpx;
17 | padding-left: 20rpx;
18 | }
19 |
20 | .enter {
21 | width: 520rpx;
22 | }
23 |
24 | image {
25 | width: 45rpx;
26 | height: 45rpx;
27 | }
28 |
29 | .search-icon {
30 | width: 50rpx;
31 | height: 50rpx;
32 | margin-left: 20rpx;
33 | }
34 |
35 | .filter {
36 | background-color: #A3D2CA;
37 | border: 1rpx solid #D7D7D7;
38 | width: 100%;
39 | height: 80rpx;
40 | display: flex;
41 | flex-direction: row;
42 | align-items: center;
43 | margin-top: 30rpx;
44 | }
45 |
46 | .manage {
47 | width: 120rpx;
48 | font-size: 28rpx;
49 | margin-left: 20rpx;
50 | }
51 |
52 | .total {
53 | width: 200rpx;
54 | margin-left: 250rpx;
55 | font-size: 24rpx;
56 | text-align: right;
57 | }
58 |
59 | .title {
60 | background-color: white;
61 | display: flex;
62 | flex-direction: row;
63 | align-items: center;
64 | justify-content: center;
65 | width: 100%;
66 | height: 60rpx;
67 | color: #555555;
68 | font-size: 28rpx;
69 | }
70 |
71 | .school {
72 | width: 40%;
73 | text-align: right;
74 | margin-right: 20rpx;
75 | /*超出容器用省略号*/
76 | white-space: nowrap;
77 | overflow: hidden;
78 | text-overflow: ellipsis;
79 | }
80 |
81 | .faculty {
82 | width: 40%;
83 | text-align: left;
84 | /*超出容器用省略号*/
85 | white-space: nowrap;
86 | overflow: hidden;
87 | text-overflow: ellipsis;
88 | }
89 |
90 | .details {
91 | background-color: white;
92 | width: 100%;
93 | height: 140rpx;
94 | display: flex;
95 | align-items: center;
96 | }
97 |
98 | .txt {
99 | width: 94%;
100 | height: 100rpx;
101 | line-height: 50rpx;
102 | font-size: 35rpx;
103 | margin-left: 3%;
104 | margin-right: 3%;
105 | /*文本显示两行,超出容器用省略号表示*/
106 | overflow: hidden;
107 | text-overflow: ellipsis;
108 | display: -webkit-box;
109 | -webkit-line-clamp: 2;
110 | -webkit-box-orient: vertical;
111 | }
112 |
113 | .file-add {
114 | background-color: white;
115 | display: flex;
116 | flex-direction: row;
117 | color: #AAAAAA;
118 | font-size: 25rpx;
119 | height: 40rpx;
120 | margin-bottom: 10rpx;
121 | }
122 |
123 | .time {
124 | margin-left: 35rpx;
125 | width: 150rpx;
126 | }
127 |
128 | .useful {
129 | width: 150rpx;
130 | text-align: right;
131 | margin-left: 270rpx;
132 | }
133 |
134 | .download {
135 | width: 150rpx;
136 | text-align: left;
137 | margin-left: 20rpx;
138 | }
--------------------------------------------------------------------------------
/miniprogram/pages/qesUpfile/qesUpfile.js:
--------------------------------------------------------------------------------
1 | // pages/qesUpfile/qesUpfile.js
2 |
3 | const db = wx.cloud.database();
4 | const fileInfo = db.collection('File-Info');
5 | const qesInfo = db.collection('Qes-Info');
6 |
7 | Page({
8 | /**
9 | * 页面的初始数据
10 | */
11 | data: {
12 | hiddenOne: true,
13 | hiddenTwo: true,
14 | fileHidden: true,
15 | checked: false,
16 | input: null, //input组件的value值
17 |
18 | //文件信息
19 | fileUrl: null,
20 | fileName: '',
21 | fileTime: 0,
22 | fileSize: 0,
23 | fileSuffix: null,
24 | userSchool: null,
25 | userFaculty: null,
26 |
27 | qesId: null
28 | },
29 |
30 | /**
31 | * 生命周期函数--监听页面加载
32 | */
33 | onLoad: function (options) {
34 | //console.log(options.id)
35 | this.setData({
36 | userSchool:getApp().globalData.userInfo.userSchool,
37 | userFaculty:getApp().globalData.userInfo.userFaculty,
38 | qesId:options.id
39 | })
40 | },
41 |
42 | //隐藏和显示信息
43 | clickOne: function (e) {
44 | this.setData({
45 | hiddenOne: false,
46 | hiddenTwo: true
47 | })
48 | },
49 | clickTwo: function (e) {
50 | this.setData({
51 | hiddenOne: true,
52 | hiddenTwo: false
53 | })
54 | },
55 |
56 | //文件信息表单提交
57 | onSubmit: function (event) {
58 | var that = this
59 | //console.log('表单数据:'+event.detail.value)
60 | if (!that.data.fileUrl) {
61 | wx.showModal({
62 | title: '温馨提示',
63 | content: '您还未上传文件哦~',
64 | showCancel: false,
65 | success(res) {}
66 | })
67 | } else {
68 | //将表单数据上传至云数据库
69 | fileInfo.add({
70 | data: {
71 | need: event.detail.value.need,
72 | author: event.detail.value.author,
73 | remark: event.detail.value.remark,
74 | fileUrl: that.data.fileUrl,
75 | fileName: that.data.fileName,
76 | fileTime: that.data.fileTime,
77 | fileSize: that.data.fileSize,
78 | fileSuffix: that.data.fileSuffix,
79 | userSchool: that.data.userSchool,
80 | userFaculty: that.data.userFaculty,
81 | good:0,
82 | downLoad:0
83 | }
84 | }).then(res => {
85 | //console.log('点击完成的返回值:', res)
86 | wx.showToast({
87 | title: '上传成功',
88 | icon: 'success'
89 | })
90 |
91 | //将文件id上传至问题集合
92 | qesInfo.where({
93 | _id: that.data.qesId
94 | }).update({
95 | data: {
96 | fileId: db.command.unshift([res._id])
97 | }
98 | }).then(res=>{
99 | console.log(res)
100 | })
101 |
102 | })
103 |
104 | //上传以后返回问题详情页面
105 | setTimeout(function () {
106 | wx.navigateBack({
107 | delta: 1,
108 | })
109 | }, 2000)
110 |
111 | }
112 |
113 | },
114 |
115 | //文件上传
116 | selectFile: function (e) {
117 | var that = this
118 | wx.chooseMessageFile({ //选择文件
119 | count: 1, //最多上传一个文件
120 | type: 'file', //可以选择除了图片和视频之外的其它的文件
121 |
122 | success: function (res) {
123 | //console.log('选择文件的返回值:', res)
124 | wx.showLoading({
125 | title: '上传中...',
126 | })
127 |
128 | const tempFilePaths = res.tempFiles[0].path //临时文件路径
129 | const houzhui = tempFilePaths.match(/\.[^.]+?$/)[0]; //文件后缀,不知道这串代码什么意思
130 | //console.log(houzhui)
131 | const fileName = new Date().getTime() + res.tempFiles[0].name; //返回1970 年 1 月 1 日到现在的毫秒数
132 | //获取当前时间戳
133 | var timestamp = Date.parse(new Date());
134 | timestamp = timestamp / 1000;
135 | //console.log(t)
136 |
137 | that.setData({
138 | fileName: res.tempFiles[0].name,
139 | fileSize: (res.tempFiles[0].size / 1000).toFixed(1), //文件大小统一保存为XXX.X kb格式
140 | fileTime: timestamp,
141 | fileSuffix: houzhui
142 | })
143 | //console.log(that.data.fileSize)
144 |
145 | wx.cloud.uploadFile({ //上传文件
146 | cloudPath: fileName, //云存储文件名称
147 | filePath: tempFilePaths, //上传的文件路径,采用临时文件路径
148 | success: res => {
149 | //console.log('上传文件的返回值:', res)
150 | wx.cloud.getTempFileURL({
151 | fileList: [res.fileID],
152 | success: res => {
153 | //console.log(res)
154 | wx.hideLoading()
155 | that.setData({
156 | //res.fileList[0].tempFileURL是https格式的路径,可以根据这个路径在浏览器上下载
157 | fileUrl: res.fileList[0].tempFileURL,
158 | fileHidden: false
159 | })
160 | }
161 | })
162 |
163 | },
164 | fail: err => {
165 | console.log(err)
166 | }
167 | })
168 | }
169 | })
170 | },
171 |
172 | })
--------------------------------------------------------------------------------
/miniprogram/pages/qesUpfile/qesUpfile.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarTitleText": "文件上传"
3 | }
--------------------------------------------------------------------------------
/miniprogram/pages/qesUpfile/qesUpfile.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 文件信息
5 |
6 | 课程相关(试卷、复习资料、电子书籍等)
7 | 其他(考研、考公、考证等)
8 |
9 |
10 |
11 |
12 |
54 |
55 |
56 |
57 |
58 |
100 |
101 |
102 |
103 |
--------------------------------------------------------------------------------
/miniprogram/pages/qesUpfile/qesUpfile.wxss:
--------------------------------------------------------------------------------
1 | /* pages/qesUpfile/qesUpfile.wxss */
2 |
3 | .title {
4 | margin-left: -10rpx;
5 | margin-right: -10rpx;
6 | background-color: #A3D2CA;
7 | height: 100rpx;
8 | font-size: 40rpx;
9 | /*实现容器内的文字居中*/
10 | display: flex;
11 | align-items: center;
12 | justify-content: center;
13 | border-top-left-radius: 40rpx;
14 | border-top-right-radius: 40rpx;
15 | }
16 |
17 | .file {
18 | background-color: white;
19 | margin-top: 3%;
20 | margin-left: 2%;
21 | margin-right: 2%;
22 | padding-left: 10rpx;
23 | padding-right: 10rpx;
24 | border-radius: 40rpx;
25 | box-shadow: 5rpx 5rpx 20rpx rgba(85, 85, 85, 0.10);
26 | }
27 |
28 | .options {
29 | display: flex;
30 | flex-direction: column;
31 | justify-content: start;
32 | margin-bottom: 20rpx;
33 | }
34 |
35 | .opt {
36 | margin-top: 10rpx;
37 | margin-bottom: 10rpx;
38 | }
39 |
40 | radio .wx-radio-input.wx-radio-input-checked{
41 | border-color:#39458F;
42 | background-color: #39458F;
43 | }
44 |
45 | .file-info{
46 | font-size: 28rpx;
47 | margin-top: 20rpx;
48 | }
49 |
50 | .file-input{
51 | margin-top: 10rpx;
52 | margin-bottom: 30rpx;
53 | border: 1px solid #D7D7D7;
54 | border-radius: 8rpx;
55 | padding-left: 10rpx;
56 | height: 60rpx;
57 | }
58 |
59 | .remind{
60 | display: block;
61 | margin-top: -20rpx;
62 | margin-bottom: 20rpx;
63 | font-size: 25rpx;
64 | color: #797979;
65 | margin-left: 10rpx;
66 | }
67 |
68 | .upFile{
69 | background-color:#F2F2F2 ;
70 | border: 1rpx solid #D7D7D7;
71 | color: #7F7F7F;
72 | height: 180rpx;
73 | margin-top: 40rpx;
74 | margin-bottom: 40rpx;
75 | border-radius: 8rpx;
76 | }
77 |
78 | .uptext{
79 | font-size: 60rpx;
80 | margin-left: 240rpx;
81 | margin-top: 45rpx;
82 | }
83 |
84 | .success-btn{
85 | margin-left: -10rpx;
86 | margin-right: -10rpx;
87 | background-color: #A3D2CA;
88 | height: 100rpx;
89 | border-radius: 0rpx;
90 | font-size: 40rpx;
91 | border-bottom-left-radius: 40rpx;
92 | border-bottom-right-radius: 40rpx;
93 | }
94 |
95 | .file-detail {
96 | width: 100%;
97 | height: 180rpx;
98 | display: flex;
99 | flex-direction: row;
100 | }
101 |
102 | .img-container {
103 | height: 180rpx;
104 | width: 180rpx;
105 | }
106 |
107 | .file-icon {
108 | height: 180rpx;
109 | width: 180rpx;
110 | }
111 |
112 | .namesize {
113 | display: flex;
114 | flex-direction: column;
115 | margin-top: 20rpx;
116 | }
117 |
118 | .name {
119 | width: 520rpx;
120 | font-size: 38rpx;
121 | white-space: nowrap;
122 | overflow: hidden;
123 | text-overflow: ellipsis;
124 | }
125 |
126 | .size {
127 | width: 200rpx;
128 | color: #AAAAAA;
129 | margin-top: 10rpx;
130 | margin-left: 10rpx;
131 | font-size: 25rpx;
132 | }
--------------------------------------------------------------------------------
/miniprogram/pages/search/search.js:
--------------------------------------------------------------------------------
1 | // pages/search/search.js
2 | const db = wx.cloud.database();
3 | const fileInfo = db.collection('File-Info');
4 |
5 | Page({
6 |
7 | /* 页面的初始数据 */
8 | data: {
9 | fileCollection: [],
10 | searchVal: null,
11 | userSchool: null, //筛选要用
12 | userFaculty: null,
13 | filterVal: null,
14 | total: 0
15 | },
16 |
17 | /* 生命周期函数--监听页面显示*/
18 | onLoad: function () {
19 | var that = this;
20 |
21 | that.pageData.skip = 20
22 |
23 | this.setData({
24 | userSchool: getApp().globalData.userInfo.userSchool,
25 | userFaculty: getApp().globalData.userInfo.userFaculty,
26 | filterVal: null
27 | })
28 |
29 | //获取集合总数
30 | fileInfo.count({
31 | success: res => {
32 | that.setData({
33 | total: res.total
34 | })
35 | }
36 | })
37 |
38 | //在云数据库fileInfo中查找文件信息集合
39 | fileInfo.orderBy('fileTime', 'desc').get({
40 | success: res => {
41 | console.log(res)
42 | that.setData({
43 | fileCollection: res.data
44 | })
45 | },
46 | fail: err => {
47 | console.error(err)
48 | }
49 | })
50 | },
51 |
52 | /* 生命周期函数--监听页面显示*/
53 | onShow: function () {
54 | this.onLoad()
55 | },
56 |
57 | /**筛选 */
58 | //本学校
59 | mySchool: function () {
60 | var that = this
61 | if (getApp().globalData.userInfo.userSchool == '') {
62 | wx.navigateTo({
63 | url: '../load/load',
64 | })
65 | } else {
66 | this.setData({
67 | filterVal: 1
68 | })
69 | wx.showLoading({
70 | title: '加载中...',
71 | })
72 | if (that.data.searchVal) { //搜索+本学校
73 |
74 | //获取集合总数
75 | fileInfo.where({
76 | userSchool: that.data.userSchool,
77 | fileName: db.RegExp({
78 | regexp: that.data.searchVal,
79 | options: 'i'
80 | })
81 | }).count({
82 | success: res => {
83 | that.setData({
84 | total: res.total
85 | })
86 | }
87 | })
88 |
89 | fileInfo.where({
90 | userSchool: that.data.userSchool,
91 | fileName: db.RegExp({
92 | regexp: that.data.searchVal,
93 | options: 'i'
94 | })
95 | }).orderBy('fileTime', 'desc').get({
96 | success: res => {
97 | wx.hideLoading()
98 | that.setData({
99 | fileCollection: res.data
100 | })
101 | that.pageData.skip = 20
102 | //console.log(res, that.data.filterVal)
103 | }
104 | })
105 | } else { //本学校
106 |
107 | //获取集合总数
108 | fileInfo.where({
109 | userSchool: that.data.userSchool,
110 | }).count({
111 | success: res => {
112 | that.setData({
113 | total: res.total
114 | })
115 | }
116 | })
117 |
118 | fileInfo.where({
119 | userSchool: that.data.userSchool,
120 | }).orderBy('fileTime', 'desc').get({
121 | success: res => {
122 | wx.hideLoading()
123 | that.setData({
124 | fileCollection: res.data
125 | })
126 | that.pageData.skip = 20
127 | //console.log(res, that.data.filterVal)
128 | }
129 | })
130 | }
131 | }
132 |
133 |
134 | },
135 |
136 | //本学院
137 | myFaculty: function () {
138 | var that = this
139 | if (getApp().globalData.userInfo.userSchool == '') {
140 | wx.navigateTo({
141 | url: '../load/load',
142 | })
143 | } else {
144 | this.setData({
145 | filterVal: 2
146 | })
147 | wx.showLoading({
148 | title: '加载中...',
149 | })
150 | if (that.data.searchVal) { //搜索+本学校+本学院
151 |
152 | //获取集合总数
153 | fileInfo.where({
154 | userSchool: that.data.userSchool,
155 | userFaculty: that.data.userFaculty,
156 | fileName: db.RegExp({
157 | regexp: that.data.searchVal,
158 | options: 'i'
159 | })
160 | }).count({
161 | success: res => {
162 | that.setData({
163 | total: res.total
164 | })
165 | }
166 | })
167 |
168 | fileInfo.where({
169 | userSchool: that.data.userSchool,
170 | userFaculty: that.data.userFaculty,
171 | fileName: db.RegExp({
172 | regexp: that.data.searchVal,
173 | options: 'i'
174 | })
175 | }).orderBy('fileTime', 'desc').get({
176 | success: res => {
177 | wx.hideLoading()
178 | that.setData({
179 | fileCollection: res.data
180 | })
181 | that.pageData.skip = 20
182 | //console.log(res, that.data.filterVal)
183 | }
184 | })
185 | } else { //本学校+本学院
186 |
187 | //获取集合总数
188 | fileInfo.where({
189 | userSchool: that.data.userSchool,
190 | userFaculty: that.data.userFaculty,
191 | }).count({
192 | success: res => {
193 | that.setData({
194 | total: res.total
195 | })
196 | }
197 | })
198 |
199 | fileInfo.where({
200 | userSchool: that.data.userSchool,
201 | userFaculty: that.data.userFaculty,
202 | }).orderBy('fileTime', 'desc').get({
203 | success: res => {
204 | wx.hideLoading()
205 | that.setData({
206 | fileCollection: res.data
207 | })
208 | that.pageData.skip = 20
209 | //console.log(res, that.data.filterVal)
210 | }
211 | })
212 | }
213 | }
214 |
215 |
216 | },
217 |
218 | //有用
219 | good: function () {
220 | var that = this
221 | this.setData({
222 | filterVal: 3
223 | })
224 | wx.showLoading({
225 | title: '加载中...',
226 | })
227 | if (that.data.searchVal) { //搜索+有用
228 |
229 | //获取集合总数
230 | fileInfo.where({
231 | fileName: db.RegExp({
232 | regexp: that.data.searchVal,
233 | options: 'i'
234 | })
235 | }).count({
236 | success: res => {
237 | that.setData({
238 | total: res.total
239 | })
240 | }
241 | })
242 |
243 | fileInfo.where({
244 | fileName: db.RegExp({
245 | regexp: that.data.searchVal,
246 | options: 'i'
247 | })
248 | }).orderBy('good', 'desc').get({
249 | success: res => {
250 | wx.hideLoading()
251 | that.setData({
252 | fileCollection: res.data
253 | })
254 | that.pageData.skip = 20
255 | //console.log(res, that.data.filterVal)
256 | }
257 | })
258 | } else { //有用
259 |
260 | //获取集合总数
261 | fileInfo.count({
262 | success: res => {
263 | that.setData({
264 | total: res.total
265 | })
266 | }
267 | })
268 |
269 | fileInfo.orderBy('good', 'desc').get({
270 | success: res => {
271 | wx.hideLoading()
272 | that.setData({
273 | fileCollection: res.data
274 | })
275 | that.pageData.skip = 20
276 | //console.log(res, that.data.filterVal)
277 | }
278 | })
279 | }
280 | },
281 |
282 | //下载量
283 | downLoad: function () {
284 | var that = this
285 | this.setData({
286 | filterVal: 4
287 | })
288 | wx.showLoading({
289 | title: '加载中...',
290 | })
291 | if (that.data.searchVal) { //搜索+下载量
292 |
293 | //获取集合总数
294 | fileInfo.where({
295 | fileName: db.RegExp({
296 | regexp: that.data.searchVal,
297 | options: 'i'
298 | })
299 | }).count({
300 | success: res => {
301 | that.setData({
302 | total: res.total
303 | })
304 | }
305 | })
306 |
307 | fileInfo.where({
308 | fileName: db.RegExp({
309 | regexp: that.data.searchVal,
310 | options: 'i'
311 | })
312 | }).orderBy('downLoad', 'desc').get({
313 | success: res => {
314 | wx.hideLoading()
315 | that.setData({
316 | fileCollection: res.data
317 | })
318 | that.pageData.skip = 20
319 | //console.log(res, that.data.filterVal)
320 | }
321 | })
322 | } else { //下载量
323 |
324 | //获取集合总数
325 | fileInfo.count({
326 | success: res => {
327 | that.setData({
328 | total: res.total
329 | })
330 | }
331 | })
332 |
333 | fileInfo.orderBy('downLoad', 'desc').get({
334 | success: res => {
335 | wx.hideLoading()
336 | that.setData({
337 | fileCollection: res.data
338 | })
339 | that.pageData.skip = 20
340 | //console.log(res, that.data.filterVal)
341 | }
342 | })
343 | }
344 | },
345 |
346 | //全部
347 | all: function () {
348 | var that = this
349 | wx.showLoading({
350 | title: '加载中...',
351 | })
352 | if (that.data.searchVal) {
353 |
354 | //获取集合总数
355 | fileInfo.where({
356 | fileName: db.RegExp({
357 | regexp: that.data.searchVal,
358 | options: 'i'
359 | })
360 | }).count({
361 | success: res => {
362 | that.setData({
363 | total: res.total
364 | })
365 | }
366 | })
367 |
368 | fileInfo.where({
369 | fileName: db.RegExp({
370 | regexp: that.data.searchVal,
371 | options: 'i'
372 | })
373 | }).orderBy('fileTime', 'desc').get({
374 | success: res => {
375 | wx.hideLoading()
376 | that.setData({
377 | fileCollection: res.data,
378 | filterVal: null
379 | })
380 | //console.log(res, that.data.searchVal)
381 | that.pageData.skip = 20
382 | }
383 | })
384 | } else {
385 |
386 | //获取集合总数
387 | fileInfo.count({
388 | success: res => {
389 | that.setData({
390 | total: res.total
391 | })
392 | }
393 | })
394 |
395 | fileInfo.orderBy('fileTime', 'desc').get({
396 | success: res => {
397 | wx.hideLoading()
398 | //console.log(res)
399 | that.setData({
400 | fileCollection: res.data,
401 | filterVal: null
402 | })
403 | that.pageData.skip = 20
404 | },
405 | fail: err => {
406 | console.error(err)
407 | }
408 | })
409 | }
410 | },
411 |
412 |
413 | /*关键字搜索*/
414 | input: function (e) {
415 | this.setData({
416 | searchVal: e.detail.value
417 | })
418 | },
419 |
420 | search: function () {
421 | var that = this
422 |
423 | //获取集合总数
424 | fileInfo.where({
425 | fileName: db.RegExp({
426 | regexp: that.data.searchVal,
427 | options: 'i'
428 | })
429 | }).count({
430 | success: res => {
431 | that.setData({
432 | total: res.total
433 | })
434 | }
435 | })
436 |
437 | wx.showLoading({
438 | title: '加载中...',
439 | })
440 | fileInfo.where({
441 | fileName: db.RegExp({
442 | regexp: that.data.searchVal,
443 | options: 'i'
444 | })
445 | }).orderBy('fileTime', 'desc').get({
446 | success: res => {
447 | wx.hideLoading()
448 | that.setData({
449 | fileCollection: res.data,
450 | filterVal: null
451 | })
452 | that.pageData.skip = 20
453 | //console.log(res, that.data.searchVal)
454 | }
455 | })
456 | },
457 |
458 | /*下拉刷新*/
459 | onReachBottom: function () {
460 | var that = this;
461 | wx.showLoading({
462 | title: '数据加载中',
463 | })
464 | if (that.data.searchVal) { //用户搜索结果下拉刷新
465 | if (that.data.filterVal == 1) { //本学校筛选
466 | fileInfo.where({
467 | userSchool: that.data.userSchool,
468 | fileName: db.RegExp({
469 | regexp: that.data.searchVal,
470 | options: 'i'
471 | })
472 | }).skip(that.pageData.skip).orderBy('fileTime', 'desc').get({
473 | success: res => {
474 | //console.log(res)
475 | wx.hideLoading()
476 | let oldData = that.data.fileCollection
477 | that.setData({
478 | fileCollection: oldData.concat(res.data)
479 | })
480 | that.pageData.skip = that.pageData.skip + 20;
481 | },
482 | fail: err => {
483 | console.error(err)
484 | }
485 | })
486 | } else if (that.data.filterVal == 2) { //本学院筛选
487 | fileInfo.where({
488 | userSchool: that.data.userSchool,
489 | userFaculty: that.data.userFaculty,
490 | fileName: db.RegExp({
491 | regexp: that.data.searchVal,
492 | options: 'i'
493 | })
494 | }).skip(that.pageData.skip).orderBy('fileTime', 'desc').get({
495 | success: res => {
496 | //console.log(res)
497 | wx.hideLoading()
498 | let oldData = that.data.fileCollection
499 | that.setData({
500 | fileCollection: oldData.concat(res.data)
501 | })
502 | that.pageData.skip = that.pageData.skip + 20;
503 | },
504 | fail: err => {
505 | console.error(err)
506 | }
507 | })
508 | } else if (that.data.filterVal == 3) { //有用筛选
509 | fileInfo.where({
510 | fileName: db.RegExp({
511 | regexp: that.data.searchVal,
512 | options: 'i'
513 | })
514 | }).skip(that.pageData.skip).orderBy('good', 'desc').get({
515 | success: res => {
516 | //console.log(res)
517 | wx.hideLoading()
518 | let oldData = that.data.fileCollection
519 | that.setData({
520 | fileCollection: oldData.concat(res.data)
521 | })
522 | that.pageData.skip = that.pageData.skip + 20;
523 | },
524 | fail: err => {
525 | console.error(err)
526 | }
527 | })
528 | } else if (that.data.filterVal == 4) { //下载量筛选
529 | fileInfo.where({
530 | fileName: db.RegExp({
531 | regexp: that.data.searchVal,
532 | options: 'i'
533 | })
534 | }).skip(that.pageData.skip).orderBy('downLoad', 'desc').get({
535 | success: res => {
536 | //console.log(res)
537 | wx.hideLoading()
538 | let oldData = that.data.fileCollection
539 | that.setData({
540 | fileCollection: oldData.concat(res.data)
541 | })
542 | that.pageData.skip = that.pageData.skip + 20;
543 | },
544 | fail: err => {
545 | console.error(err)
546 | }
547 | })
548 | } else { //纯搜索无筛选
549 | fileInfo.where({
550 | fileName: db.RegExp({
551 | regexp: that.data.searchVal,
552 | options: 'i'
553 | })
554 | }).skip(that.pageData.skip).orderBy('fileTime', 'desc').get({
555 | success: res => {
556 | //console.log(res)
557 | wx.hideLoading()
558 | let oldData = that.data.fileCollection
559 | that.setData({
560 | fileCollection: oldData.concat(res.data)
561 | })
562 | that.pageData.skip = that.pageData.skip + 20;
563 | },
564 | fail: err => {
565 | console.error(err)
566 | }
567 | })
568 | }
569 |
570 | } else { //所有资源下拉刷新
571 | if (that.data.filterVal == 1) { //本学校筛选
572 | fileInfo.where({
573 | userSchool: that.data.userSchool,
574 | }).skip(that.pageData.skip).orderBy('fileTime', 'desc').get({
575 | success: res => {
576 | //console.log(res)
577 | wx.hideLoading()
578 | let oldData = that.data.fileCollection
579 | that.setData({
580 | fileCollection: oldData.concat(res.data)
581 | })
582 | that.pageData.skip = that.pageData.skip + 20;
583 | },
584 | fail: err => {
585 | console.error(err)
586 | }
587 | })
588 | } else if (that.data.filterVal == 2) { //本学院筛选
589 | fileInfo.where({
590 | userSchool: that.data.userSchool,
591 | userFaculty: that.data.userFaculty,
592 | }).skip(that.pageData.skip).orderBy('fileTime', 'desc').get({
593 | success: res => {
594 | //console.log(res)
595 | wx.hideLoading()
596 | let oldData = that.data.fileCollection
597 | that.setData({
598 | fileCollection: oldData.concat(res.data)
599 | })
600 | that.pageData.skip = that.pageData.skip + 20;
601 | },
602 | fail: err => {
603 | console.error(err)
604 | }
605 | })
606 | } else if (that.data.filterVal == 3) { //有用筛选
607 | fileInfo.skip(that.pageData.skip).orderBy('good', 'desc').get({
608 | success: res => {
609 | //console.log(res)
610 | wx.hideLoading()
611 | let oldData = that.data.fileCollection
612 | that.setData({
613 | fileCollection: oldData.concat(res.data)
614 | })
615 | that.pageData.skip = that.pageData.skip + 20;
616 | },
617 | fail: err => {
618 | console.error(err)
619 | }
620 | })
621 | } else if (that.data.filterVal == 4) { //下载量筛选
622 | fileInfo.skip(that.pageData.skip).orderBy('downLoad', 'desc').get({
623 | success: res => {
624 | //console.log(res)
625 | wx.hideLoading()
626 | let oldData = that.data.fileCollection
627 | that.setData({
628 | fileCollection: oldData.concat(res.data)
629 | })
630 | that.pageData.skip = that.pageData.skip + 20;
631 | },
632 | fail: err => {
633 | console.error(err)
634 | }
635 | })
636 | } else { //无筛选
637 | fileInfo.skip(that.pageData.skip).orderBy('fileTime', 'desc').get({
638 | success: res => {
639 | console.log(res)
640 | wx.hideLoading()
641 | let oldData = that.data.fileCollection
642 | that.setData({
643 | fileCollection: oldData.concat(res.data)
644 | })
645 | that.pageData.skip = that.pageData.skip + 20;
646 | },
647 | fail: err => {
648 | console.error(err)
649 | }
650 | })
651 | }
652 | }
653 |
654 | },
655 | //存放触底刷新跳过的页面数
656 | pageData: {
657 | skip: 20
658 | }
659 |
660 | })
--------------------------------------------------------------------------------
/miniprogram/pages/search/search.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarTitleText": "搜索"
3 | }
--------------------------------------------------------------------------------
/miniprogram/pages/search/search.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 | 全部
13 | 本学校
14 | 本学院
15 | 有用
16 | 下载量
17 | 共 {{total}} 项
18 |
19 |
20 |
21 |
22 |
23 | {{item.userSchool}}
24 | {{item.userFaculty}}
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 | {{item.fileName}}
50 | {{item.fileSize}} KB
51 |
52 |
53 |
54 |
55 | {{common.TimeToDate(item.fileTime,'YYYY-MM-DD')}}
56 | 有用 {{item.good}}
57 | 下载 {{item.downLoad}}
58 |
59 |
60 |
61 |
--------------------------------------------------------------------------------
/miniprogram/pages/search/search.wxss:
--------------------------------------------------------------------------------
1 | /* pages/search/search.wxss */
2 | .hover{
3 | color: #000080;
4 | }
5 |
6 | .search {
7 | background-color: white;
8 | width: 80%;
9 | margin: auto;
10 | height: 80rpx;
11 | display: flex;
12 | flex-direction: row;
13 | align-items: center;
14 | border: 1rpx solid #D7D7D7;
15 | border-radius: 10rpx;
16 | margin-top: 20rpx;
17 | padding-left: 20rpx;
18 | }
19 |
20 | .enter {
21 | width: 520rpx;
22 | }
23 |
24 | image {
25 | width: 45rpx;
26 | height: 45rpx;
27 | }
28 |
29 | .search-icon {
30 | width: 50rpx;
31 | height: 50rpx;
32 | margin-left: 20rpx;
33 | }
34 |
35 | .filter {
36 | background-color: #A3D2CA;
37 | border: 1rpx solid #D7D7D7;
38 | width: 100%;
39 | height: 80rpx;
40 | display: flex;
41 | flex-direction: row;
42 | align-items: center;
43 | margin-top: 30rpx;
44 | }
45 |
46 | .manage {
47 | margin-left: 30rpx;
48 | display: flex;
49 | flex-direction: row;
50 | align-items: center;
51 | justify-content: center;
52 | font-size: 28rpx;
53 | height: 100%;
54 | }
55 |
56 | .total {
57 | width: 200rpx;
58 | margin-left: 20rpx;
59 | font-size: 24rpx;
60 | text-align: right;
61 | }
62 |
63 | .user-info{
64 | background-color: white;
65 | display: flex;
66 | flex-direction: row;
67 | align-items: center;
68 | justify-content: center;
69 | width: 100%;
70 | height: 60rpx;
71 | color: #555555;
72 | font-size: 28rpx;
73 | }
74 |
75 | .school{
76 | width: 40%;
77 | text-align: right;
78 | margin-right: 20rpx;
79 | /*超出容器用省略号*/
80 | white-space: nowrap;
81 | overflow: hidden;
82 | text-overflow: ellipsis;
83 | }
84 |
85 | .faculty{
86 | width: 40%;
87 | text-align: left;
88 | /*超出容器用省略号*/
89 | white-space: nowrap;
90 | overflow: hidden;
91 | text-overflow: ellipsis;
92 | }
93 |
94 | .file-detail {
95 | background-color: white;
96 | width: 100%;
97 | height: 180rpx;
98 | display: flex;
99 | flex-direction: row;
100 | }
101 |
102 | .img-container {
103 | height: 180rpx;
104 | width: 180rpx;
105 | }
106 |
107 | .file-icon {
108 | height: 180rpx;
109 | width: 180rpx;
110 | }
111 |
112 | .namesize {
113 | display: flex;
114 | flex-direction: column;
115 | margin-top: 20rpx;
116 | }
117 |
118 | .name {
119 | width: 560rpx;
120 | font-size: 38rpx;
121 | white-space: nowrap;
122 | overflow: hidden;
123 | text-overflow: ellipsis;
124 | }
125 |
126 | .size {
127 | width: 200rpx;
128 | color: #AAAAAA;
129 | margin-top: 10rpx;
130 | margin-left: 10rpx;
131 | font-size: 25rpx;
132 | }
133 |
134 | .file-add {
135 | background-color: white;
136 | display: flex;
137 | flex-direction: row;
138 | color: #AAAAAA;
139 | font-size: 25rpx;
140 | height: 40rpx;
141 | margin-bottom: 10rpx;
142 | }
143 |
144 | .time {
145 | margin-left: 35rpx;
146 | width: 150rpx;
147 | }
148 |
149 | .useful {
150 | width: 150rpx;
151 | text-align: right;
152 | margin-left: 270rpx;
153 | }
154 |
155 | .download {
156 | width: 150rpx;
157 | text-align: left;
158 | margin-left: 20rpx;
159 | }
--------------------------------------------------------------------------------
/miniprogram/pages/upfile/upfile.js:
--------------------------------------------------------------------------------
1 | // pages/upfile/upfile.js
2 |
3 | const db = wx.cloud.database();
4 | const fileInfo = db.collection('File-Info');
5 |
6 | Page({
7 | /**
8 | * 页面的初始数据
9 | */
10 | data: {
11 | hiddenOne: true,
12 | hiddenTwo: true,
13 | fileHidden: true,
14 | checked: false,
15 | input: null, //input组件的value值
16 |
17 | //文件信息
18 | fileUrl: null,
19 | fileName: '',
20 | fileTime: 0,
21 | fileSize: 0,
22 | fileSuffix: null,
23 | userSchool:null,
24 | userFaculty:null
25 | },
26 |
27 | /**
28 | * 生命周期函数--监听页面加载
29 | */
30 | onShow: function () {
31 |
32 | this.setData({
33 | userSchool:getApp().globalData.userInfo.userSchool,
34 | userFaculty:getApp().globalData.userInfo.userFaculty
35 | })
36 |
37 | },
38 |
39 |
40 |
41 | //隐藏和显示信息
42 | clickOne: function (e) {
43 | this.setData({
44 | hiddenOne: false,
45 | hiddenTwo: true
46 | })
47 | },
48 | clickTwo: function (e) {
49 | this.setData({
50 | hiddenOne: true,
51 | hiddenTwo: false
52 | })
53 | },
54 |
55 | //文件信息表单提交
56 | onSubmit: function (event) {
57 | var that = this
58 | //console.log('表单数据:'+event.detail.value)
59 | if (!that.data.fileUrl) {
60 | wx.showModal({
61 | title: '温馨提示',
62 | content: '您还未上传文件哦~',
63 | showCancel: false,
64 | success(res) {}
65 | })
66 | } else {
67 | //将表单数据上传至云数据库
68 | fileInfo.add({
69 | data: {
70 | need: event.detail.value.need,
71 | author: event.detail.value.author,
72 | remark: event.detail.value.remark,
73 | fileUrl: that.data.fileUrl,
74 | fileName: that.data.fileName,
75 | fileTime: that.data.fileTime,
76 | fileSize: that.data.fileSize,
77 | fileSuffix: that.data.fileSuffix,
78 | userSchool:that.data.userSchool,
79 | userFaculty:that.data.userFaculty,
80 | good:0,
81 | downLoad:0
82 | }
83 | }).then(res => {
84 | // console.log('点击完成的返回值:', res)
85 | wx.showToast({
86 | title: '上传成功',
87 | icon: 'success'
88 | })
89 | })
90 |
91 | //上传以后页面数据全部初始化
92 | setTimeout(function () {
93 | that.setData({
94 | hiddenOne: true,
95 | hiddenTwo: true,
96 | fileHidden: true,
97 | fileUrl: null,
98 | fileName: '',
99 | fileTime: 0,
100 | fileSize: 0,
101 | fileSuffix: null,
102 | input: '',
103 | checked: false
104 | })
105 | }, 2000)
106 | }
107 |
108 | },
109 |
110 | //文件上传
111 | selectFile: function (e) {
112 | var that = this
113 | if(getApp().globalData.userInfo.userSchool == ''){
114 | wx.navigateTo({
115 | url: '../load/load',
116 | })
117 | }else{
118 | wx.chooseMessageFile({ //选择文件
119 | count: 1, //最多上传一个文件
120 | type: 'file', //可以选择除了图片和视频之外的其它的文件
121 |
122 | success: function (res) {
123 | console.log('选择文件的返回值:', res)
124 | wx.showLoading({
125 | title: '上传中...',
126 | })
127 |
128 | const tempFilePaths = res.tempFiles[0].path //临时文件路径
129 | const houzhui = tempFilePaths.match(/\.[^.]+?$/)[0]; //文件后缀,不知道这串代码什么意思
130 | //console.log(houzhui)
131 | const fileName = new Date().getTime()+res.tempFiles[0].name; //返回1970 年 1 月 1 日到现在的毫秒数
132 | //获取当前时间戳
133 | var timestamp = Date.parse(new Date());
134 | timestamp = timestamp / 1000;
135 | //console.log(t)
136 |
137 | that.setData({
138 | fileName: res.tempFiles[0].name,
139 | fileSize: (res.tempFiles[0].size / 1000).toFixed(1), //文件大小统一保存为XXX.X kb格式
140 | fileTime: timestamp,
141 | fileSuffix: houzhui
142 | })
143 | //console.log(that.data.fileSize)
144 |
145 | wx.cloud.uploadFile({ //上传文件
146 | cloudPath: fileName, //云存储文件名称
147 | filePath: tempFilePaths, //上传的文件路径,采用临时文件路径
148 | success: res => {
149 | console.log('上传文件的返回值:', res)
150 | wx.cloud.getTempFileURL({
151 | fileList: [res.fileID],
152 | success: res => {
153 | console.log(res)
154 | wx.hideLoading()
155 | that.setData({
156 | //res.fileList[0].tempFileURL是https格式的路径,可以根据这个路径在浏览器上下载
157 | fileUrl: res.fileList[0].tempFileURL,
158 | fileHidden: false
159 | })
160 | }
161 | })
162 |
163 | },
164 | fail: err => {
165 | wx.hideLoading()
166 | wx.showModal({
167 | title: '温馨提示',
168 | content: '上传失败!',
169 | showCancel: false,
170 | success(res) {}
171 | })
172 | console.log(err)
173 | }
174 | })
175 | }
176 | })
177 | }
178 |
179 | },
180 |
181 | })
--------------------------------------------------------------------------------
/miniprogram/pages/upfile/upfile.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarTitleText": "上传"
3 | }
--------------------------------------------------------------------------------
/miniprogram/pages/upfile/upfile.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 文件信息
5 |
6 | 课程相关(试卷、复习资料、电子书籍等)
7 | 其他(考研、考公、考证等)
8 |
9 |
10 |
11 |
12 |
54 |
55 |
56 |
57 |
58 |
100 |
101 |
102 |
--------------------------------------------------------------------------------
/miniprogram/pages/upfile/upfile.wxss:
--------------------------------------------------------------------------------
1 | /* pages/upfile/upfile.wxss */
2 |
3 | .title {
4 | margin-left: -10rpx;
5 | margin-right: -10rpx;
6 | background-color: #A3D2CA;
7 | height: 100rpx;
8 | font-size: 40rpx;
9 | /*实现容器内的文字居中*/
10 | display: flex;
11 | align-items: center;
12 | justify-content: center;
13 | border-top-left-radius: 40rpx;
14 | border-top-right-radius: 40rpx;
15 | }
16 |
17 | .file {
18 | background-color: white;
19 | margin-top: 3%;
20 | margin-left: 2%;
21 | margin-right: 2%;
22 | padding-left: 10rpx;
23 | padding-right: 10rpx;
24 | border-radius: 40rpx;
25 | box-shadow: 5rpx 5rpx 20rpx rgba(85, 85, 85, 0.10);
26 | }
27 |
28 | .options {
29 | display: flex;
30 | flex-direction: column;
31 | justify-content: start;
32 | margin-bottom: 20rpx;
33 | }
34 |
35 | .opt {
36 | margin-top: 10rpx;
37 | margin-bottom: 10rpx;
38 | }
39 |
40 | radio .wx-radio-input.wx-radio-input-checked{
41 | border-color:#39458F;
42 | background-color: #39458F;
43 | }
44 |
45 | .file-info{
46 | font-size: 28rpx;
47 | margin-top: 20rpx;
48 | }
49 |
50 | .file-input{
51 | margin-top: 10rpx;
52 | margin-bottom: 30rpx;
53 | border: 1px solid #D7D7D7;
54 | border-radius: 8rpx;
55 | padding-left: 10rpx;
56 | height: 60rpx;
57 | }
58 |
59 | .remind{
60 | display: block;
61 | margin-top: -20rpx;
62 | margin-bottom: 20rpx;
63 | font-size: 25rpx;
64 | color: #797979;
65 | margin-left: 10rpx;
66 | }
67 |
68 | .upFile{
69 | background-color:#F2F2F2 ;
70 | border: 1rpx solid #D7D7D7;
71 | color: #7F7F7F;
72 | height: 180rpx;
73 | margin-top: 40rpx;
74 | margin-bottom: 40rpx;
75 | border-radius: 8rpx;
76 | }
77 |
78 | .uptext{
79 | font-size: 60rpx;
80 | margin-left: 240rpx;
81 | margin-top: 45rpx;
82 | }
83 |
84 | .success-btn{
85 | margin-left: -10rpx;
86 | margin-right: -10rpx;
87 | background-color: #A3D2CA;
88 | height: 100rpx;
89 | border-radius: 0rpx;
90 | font-size: 40rpx;
91 | border-bottom-left-radius: 40rpx;
92 | border-bottom-right-radius: 40rpx;
93 | }
94 |
95 | .file-detail {
96 | width: 100%;
97 | height: 180rpx;
98 | display: flex;
99 | flex-direction: row;
100 | }
101 |
102 | .img-container {
103 | height: 180rpx;
104 | width: 180rpx;
105 | }
106 |
107 | .file-icon {
108 | height: 180rpx;
109 | width: 180rpx;
110 | }
111 |
112 | .namesize {
113 | display: flex;
114 | flex-direction: column;
115 | margin-top: 20rpx;
116 | }
117 |
118 | .name {
119 | width: 520rpx;
120 | font-size: 38rpx;
121 | white-space: nowrap;
122 | overflow: hidden;
123 | text-overflow: ellipsis;
124 | }
125 |
126 | .size {
127 | width: 200rpx;
128 | color: #AAAAAA;
129 | margin-top: 10rpx;
130 | margin-left: 10rpx;
131 | font-size: 25rpx;
132 | }
--------------------------------------------------------------------------------
/miniprogram/sitemap.json:
--------------------------------------------------------------------------------
1 | {
2 | "desc": "关于本文件的更多信息,请参考文档 https://developers.weixin.qq.com/miniprogram/dev/framework/sitemap.html",
3 | "rules": [{
4 | "action": "allow",
5 | "page": "*"
6 | }]
7 | }
--------------------------------------------------------------------------------
/miniprogram/utils/common.wxs:
--------------------------------------------------------------------------------
1 | var time = {
2 | TimeToDate: function (date, format) {
3 | format = format || 'YYYY-MM-DD hh:mm:ss';
4 | var dateTest = (getRegExp('^(-)?\d{1,10}$').test(date) || getRegExp('^(-)?\d{1,13}$').test(date));
5 | if (getRegExp('^[1-9]*[1-9][0-9]*$').test(date) && dateTest) {
6 | var vdate = parseInt(date);
7 | if (getRegExp('^(-)?\d{1,10}$').test(vdate)) {
8 | vdate = vdate * 1000;
9 | } else if (getRegExp('^(-)?\d{1,13}$').test(vdate)) {
10 | vdate = vdate * 1000;
11 | } else if (getRegExp('^(-)?\d{1,14}$').test(vdate)) {
12 | vdate = vdate * 100;
13 | } else {
14 | alert("时间戳格式不正确");
15 | return;
16 | }
17 | var setdate = getDate(vdate);
18 | return parse({ YYYY: setdate.getFullYear(), MM: digit(setdate.getMonth() + 1), DD: digit(setdate.getDate()), hh: digit(setdate.getHours()), mm: digit(setdate.getMinutes()), ss: digit(setdate.getSeconds()) }, format);
19 | } else {
20 | //将日期转换成时间戳
21 | re = getRegExp('(\d{4})(?:\D?(\d{1,2})(?:\D?(\d{1,2}))?[^\d\s]?)?(?:\s+(\d{1,2})\D?(\d{1,2})\D?(\d{1,2}))?').exec(date);
22 | return getDate(re[1], (re[2] || 1) - 1, re[3] || 1, re[4] || 0, re[5] || 0, re[6] || 0).getTime() / 1000;
23 | }
24 |
25 | function parse(ymdhms, format) {
26 | var regymdzz = "YYYY|MM|DD|hh|mm|ss|zz";
27 | return format.replace(getRegExp(regymdzz, "g"), function (str, index) {
28 | return str == "zz" ? "00" : digit(ymdhms[str]);
29 | })
30 | }
31 | function digit(num) {
32 | return num < 10 ? "0" + (num | 0) : num;
33 | }
34 | }
35 | }
36 | module.exports = {
37 | TimeToDate: time.TimeToDate,
38 | }
--------------------------------------------------------------------------------
/project.config.json:
--------------------------------------------------------------------------------
1 | {
2 | "miniprogramRoot": "miniprogram/",
3 | "cloudfunctionRoot": "cloudfunctions/",
4 | "setting": {
5 | "urlCheck": true,
6 | "es6": true,
7 | "enhance": true,
8 | "postcss": true,
9 | "minified": true,
10 | "newFeature": true,
11 | "coverView": true,
12 | "autoAudits": false,
13 | "showShadowRootInWxmlPanel": true,
14 | "scopeDataCheck": false,
15 | "checkInvalidKey": true,
16 | "checkSiteMap": true,
17 | "uploadWithSourceMap": true,
18 | "compileHotReLoad": false,
19 | "babelSetting": {
20 | "ignore": [],
21 | "disablePlugins": [],
22 | "outputPath": ""
23 | },
24 | "useIsolateContext": true,
25 | "useCompilerModule": false,
26 | "userConfirmedUseCompilerModuleSwitch": false
27 | },
28 | "appid": "wx4d4fe22efa535c1d",
29 | "projectname": "%E5%AE%9E%E6%88%981.0",
30 | "libVersion": "2.12.0",
31 | "simulatorType": "wechat",
32 | "simulatorPluginLibVersion": {},
33 | "cloudfunctionTemplateRoot": "cloudfunctionTemplate",
34 | "condition": {
35 | "search": {
36 | "current": -1,
37 | "list": []
38 | },
39 | "conversation": {
40 | "current": -1,
41 | "list": []
42 | },
43 | "plugin": {
44 | "current": -1,
45 | "list": []
46 | },
47 | "game": {
48 | "list": []
49 | },
50 | "gamePlugin": {
51 | "current": -1,
52 | "list": []
53 | },
54 | "miniprogram": {
55 | "current": 0,
56 | "list": [
57 | {
58 | "id": -1,
59 | "name": "db guide",
60 | "pathName": "pages/databaseGuide/databaseGuide",
61 | "query": ""
62 | },
63 | {
64 | "id": -1,
65 | "name": "upfile",
66 | "pathName": "pages/upfile/upfile",
67 | "query": "",
68 | "scene": null
69 | },
70 | {
71 | "id": -1,
72 | "name": "search",
73 | "pathName": "pages/search/search",
74 | "query": "",
75 | "scene": null
76 | },
77 | {
78 | "id": -1,
79 | "name": "load",
80 | "pathName": "pages/load/load",
81 | "query": "",
82 | "scene": null
83 | },
84 | {
85 | "id": -1,
86 | "name": "Info",
87 | "pathName": "pages/Info/Info",
88 | "query": "",
89 | "scene": null
90 | },
91 | {
92 | "id": -1,
93 | "name": "mine",
94 | "pathName": "pages/mine/mine",
95 | "query": "",
96 | "scene": null
97 | },
98 | {
99 | "id": -1,
100 | "name": "myFile",
101 | "pathName": "pages/myFile/myFile",
102 | "query": "",
103 | "scene": null
104 | },
105 | {
106 | "id": -1,
107 | "name": "downfile",
108 | "pathName": "pages/downfile/downfile",
109 | "query": "id=abd27dd45f2a81df001320ef32f68002",
110 | "scene": null
111 | },
112 | {
113 | "id": -1,
114 | "name": "search",
115 | "pathName": "pages/search/search",
116 | "query": "",
117 | "scene": null
118 | },
119 | {
120 | "id": -1,
121 | "name": "ask",
122 | "pathName": "pages/ask/ask",
123 | "query": "",
124 | "scene": null
125 | },
126 | {
127 | "id": -1,
128 | "name": "answer",
129 | "pathName": "pages/answer/answer",
130 | "query": "id=b1cb7d3a5f30c2440055ecd322d24017",
131 | "scene": null
132 | },
133 | {
134 | "id": -1,
135 | "name": "myQes",
136 | "pathName": "pages/myQes/myQes",
137 | "scene": null
138 | }
139 | ]
140 | }
141 | }
142 | }
--------------------------------------------------------------------------------