project init
This commit is contained in:
10
app.js
Normal file
10
app.js
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
// app.js
|
||||||
|
import api from './utils/api.js';
|
||||||
|
App({
|
||||||
|
onLaunch() {
|
||||||
|
},
|
||||||
|
|
||||||
|
globalData: {
|
||||||
|
},
|
||||||
|
$api: api,
|
||||||
|
})
|
||||||
15
app.json
Normal file
15
app.json
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
"pages": [
|
||||||
|
"pages/task/index"
|
||||||
|
],
|
||||||
|
"usingComponents": {
|
||||||
|
},
|
||||||
|
"window": {
|
||||||
|
"backgroundTextStyle": "light",
|
||||||
|
"navigationBarBackgroundColor": "#fff",
|
||||||
|
"navigationBarTitleText": "奎因记账",
|
||||||
|
"navigationBarTextStyle": "black"
|
||||||
|
},
|
||||||
|
"style": "v2",
|
||||||
|
"sitemapLocation": "sitemap.json"
|
||||||
|
}
|
||||||
10
app.wxss
Normal file
10
app.wxss
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
/**app.wxss**/
|
||||||
|
.container {
|
||||||
|
height: 100%;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
padding: 200rpx 0;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
21
package-lock.json
generated
Normal file
21
package-lock.json
generated
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
{
|
||||||
|
"name": "quinn-accounts",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"lockfileVersion": 1,
|
||||||
|
"requires": true,
|
||||||
|
"dependencies": {
|
||||||
|
"dayjs": {
|
||||||
|
"version": "1.11.7",
|
||||||
|
"resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.7.tgz",
|
||||||
|
"integrity": "sha512-+Yw9U6YO5TQohxLcIkrXBeY73WP3ejHWVvx8XCk3gxvQDCTEmS48ZrSZCKciI7Bhl/uCMyxYtE9UqRILmFphkQ=="
|
||||||
|
},
|
||||||
|
"tdesign-miniprogram": {
|
||||||
|
"version": "0.33.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/tdesign-miniprogram/-/tdesign-miniprogram-0.33.0.tgz",
|
||||||
|
"integrity": "sha512-dNerln9UN7YdYCZvWRCstvH2hEkmXtwboOGVKPY5ZXYgC8cG2eH4/buJ7j8l4Ci+jJLLSPQrGCj9e55Y83sw7g==",
|
||||||
|
"requires": {
|
||||||
|
"dayjs": "^1.10.7"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
22
package.json
Normal file
22
package.json
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
{
|
||||||
|
"name": "quinn-accounts",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "奎因清单",
|
||||||
|
"main": "app.js",
|
||||||
|
"scripts": {
|
||||||
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git+https://github.com/jiuzheyangyuan/quinn-accounts.git"
|
||||||
|
},
|
||||||
|
"author": "",
|
||||||
|
"license": "ISC",
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/jiuzheyangyuan/quinn-accounts/issues"
|
||||||
|
},
|
||||||
|
"homepage": "https://github.com/jiuzheyangyuan/quinn-accounts#readme",
|
||||||
|
"dependencies": {
|
||||||
|
"tdesign-miniprogram": "^0.33.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
50
project.config.json
Normal file
50
project.config.json
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
{
|
||||||
|
"description": "项目配置文件",
|
||||||
|
"packOptions": {
|
||||||
|
"ignore": [],
|
||||||
|
"include": []
|
||||||
|
},
|
||||||
|
"setting": {
|
||||||
|
"urlCheck": true,
|
||||||
|
"es6": true,
|
||||||
|
"enhance": true,
|
||||||
|
"postcss": true,
|
||||||
|
"preloadBackgroundData": false,
|
||||||
|
"minified": true,
|
||||||
|
"newFeature": false,
|
||||||
|
"coverView": true,
|
||||||
|
"nodeModules": true,
|
||||||
|
"autoAudits": false,
|
||||||
|
"showShadowRootInWxmlPanel": true,
|
||||||
|
"scopeDataCheck": false,
|
||||||
|
"uglifyFileName": false,
|
||||||
|
"checkInvalidKey": true,
|
||||||
|
"checkSiteMap": true,
|
||||||
|
"uploadWithSourceMap": true,
|
||||||
|
"compileHotReLoad": false,
|
||||||
|
"lazyloadPlaceholderEnable": false,
|
||||||
|
"useMultiFrameRuntime": true,
|
||||||
|
"useApiHook": true,
|
||||||
|
"useApiHostProcess": true,
|
||||||
|
"babelSetting": {
|
||||||
|
"ignore": [],
|
||||||
|
"disablePlugins": [],
|
||||||
|
"outputPath": ""
|
||||||
|
},
|
||||||
|
"useIsolateContext": true,
|
||||||
|
"userConfirmedBundleSwitch": false,
|
||||||
|
"packNpmManually": false,
|
||||||
|
"packNpmRelationList": [],
|
||||||
|
"minifyWXSS": true,
|
||||||
|
"showES6CompileOption": false
|
||||||
|
},
|
||||||
|
"compileType": "miniprogram",
|
||||||
|
"libVersion": "2.28.1",
|
||||||
|
"appid": "wxb1f499f0a173865b",
|
||||||
|
"projectname": "quinn-accounts",
|
||||||
|
"editorSetting": {
|
||||||
|
"tabIndent": "insertSpaces",
|
||||||
|
"tabSize": 4
|
||||||
|
},
|
||||||
|
"condition": {}
|
||||||
|
}
|
||||||
7
sitemap.json
Normal file
7
sitemap.json
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"desc": "关于本文件的更多信息,请参考文档 https://developers.weixin.qq.com/miniprogram/dev/framework/sitemap.html",
|
||||||
|
"rules": [{
|
||||||
|
"action": "allow",
|
||||||
|
"page": "*"
|
||||||
|
}]
|
||||||
|
}
|
||||||
237
utils/api.js
Normal file
237
utils/api.js
Normal file
@@ -0,0 +1,237 @@
|
|||||||
|
//testURL
|
||||||
|
const BASE_URL = 'http://192.168.73.1:10393/mock/68a4cea5-9a96-4c33-b7b9-0f32269ef34f/test?apipost_id=872f12';
|
||||||
|
//prodURL
|
||||||
|
// const BASE_URL = 'https://api.hongyutiyu.top';
|
||||||
|
|
||||||
|
function buildURL(url, needToken) {
|
||||||
|
let token = wx.getStorageSync('accessToken');
|
||||||
|
|
||||||
|
if (!needToken) {
|
||||||
|
return token ? url + (url.indexOf('?') >= 0 ? '&' : '?') + "access_token=" + token : url
|
||||||
|
}
|
||||||
|
return url + (url.indexOf('?') >= 0 ? '&' : '?');
|
||||||
|
}
|
||||||
|
|
||||||
|
export function fetchPost(url, params, needToken, multiple) {
|
||||||
|
url = buildURL(url, needToken);
|
||||||
|
|
||||||
|
// 如果url不存在,返回错误 TODO
|
||||||
|
// if (!url) {
|
||||||
|
// return new Promise((resolve, reject) => {
|
||||||
|
// reject();
|
||||||
|
// })
|
||||||
|
// }
|
||||||
|
|
||||||
|
console.log("网络请求", BASE_URL + url, params);
|
||||||
|
|
||||||
|
// 如果上传图片
|
||||||
|
if (multiple) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
wx.uploadFile({
|
||||||
|
url: BASE_URL + url,
|
||||||
|
filePath: params.filePath,
|
||||||
|
name: 'image',
|
||||||
|
formData: {},
|
||||||
|
success: function(response) {
|
||||||
|
console.log(response.data);
|
||||||
|
let res = JSON.parse(response.data);
|
||||||
|
console.log(res);
|
||||||
|
if (response.statusCode == 200) {
|
||||||
|
if (res.err_code == 0) {
|
||||||
|
// wx.hideLoading();
|
||||||
|
resolve(res);
|
||||||
|
} else {
|
||||||
|
if (res.err_code == 10003 || res.err_code == 10006 || res.err_code == 20006) {
|
||||||
|
// wx.removeStorageSync('accessToken');
|
||||||
|
// wx.redirectTo({
|
||||||
|
// url: '/pages/login/index',
|
||||||
|
// })
|
||||||
|
isUnLogin();
|
||||||
|
reject(res);
|
||||||
|
return;
|
||||||
|
} else if (res.err_code == 20005) {
|
||||||
|
wx.removeStorageSync('accessToken');
|
||||||
|
wx.removeStorageSync('history');
|
||||||
|
wx.hideLoading();
|
||||||
|
wx.showToast({
|
||||||
|
title: res.err_msg,
|
||||||
|
icon: 'none',
|
||||||
|
duration: 2000
|
||||||
|
})
|
||||||
|
reject(res);
|
||||||
|
} else {
|
||||||
|
wx.hideLoading();
|
||||||
|
wx.showToast({
|
||||||
|
title: res.err_msg,
|
||||||
|
icon: 'none',
|
||||||
|
duration: 2000
|
||||||
|
})
|
||||||
|
reject(res);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
wx.hideLoading();
|
||||||
|
wx.showToast({
|
||||||
|
title: '网络错误',
|
||||||
|
icon: 'none',
|
||||||
|
})
|
||||||
|
reject(response);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
fail: function(err) {
|
||||||
|
console.log(err);
|
||||||
|
wx.hideLoading();
|
||||||
|
wx.showToast({
|
||||||
|
title: '网络错误',
|
||||||
|
icon: 'none',
|
||||||
|
})
|
||||||
|
reject(response);
|
||||||
|
},
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取POST数据
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
wx.request({
|
||||||
|
url: BASE_URL + url,
|
||||||
|
data: params,
|
||||||
|
header: {
|
||||||
|
'content-type': 'application/x-www-form-urlencoded'
|
||||||
|
},
|
||||||
|
method: 'POST',
|
||||||
|
success: function(res) {
|
||||||
|
console.log("POST返回数据", url,res);
|
||||||
|
if (res.data.err_code == 0) {
|
||||||
|
wx.hideLoading();
|
||||||
|
resolve(res.data);
|
||||||
|
} else {
|
||||||
|
if (res.data.err_code == 10003 || res.data.err_code == 10006 || res.data.err_code == 20006) {
|
||||||
|
// wx.removeStorageSync('accessToken');
|
||||||
|
// wx.redirectTo({
|
||||||
|
// url: '/pages/login/index',
|
||||||
|
// })
|
||||||
|
reject(res);
|
||||||
|
return;
|
||||||
|
} else if (res.data.err_code == 30022) {
|
||||||
|
reject(res);
|
||||||
|
} else if (res.data.err_code == 20005) {
|
||||||
|
wx.removeStorageSync('accessToken');
|
||||||
|
wx.removeStorageSync('history');
|
||||||
|
wx.hideLoading();
|
||||||
|
wx.showToast({
|
||||||
|
title: res.data.err_msg,
|
||||||
|
icon: 'none',
|
||||||
|
duration: 2000
|
||||||
|
})
|
||||||
|
reject(res);
|
||||||
|
} else {
|
||||||
|
wx.hideLoading();
|
||||||
|
wx.showToast({
|
||||||
|
title: res.data.err_msg,
|
||||||
|
icon: 'none',
|
||||||
|
duration: 2000
|
||||||
|
})
|
||||||
|
reject(res);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
},
|
||||||
|
fail: function(res) {
|
||||||
|
wx.hideLoading();
|
||||||
|
wx.showToast({
|
||||||
|
title: '网络错误',
|
||||||
|
icon: 'none',
|
||||||
|
duration: 2000
|
||||||
|
})
|
||||||
|
reject(res);
|
||||||
|
|
||||||
|
},
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// get请求
|
||||||
|
export function fetchGet(url, params, needToken) {
|
||||||
|
url = buildURL(url, needToken);
|
||||||
|
// 如果url不存在,返回错误 TODO
|
||||||
|
// if (!url) {
|
||||||
|
// return new Promise((resolve, reject) => {
|
||||||
|
// reject();
|
||||||
|
// })
|
||||||
|
// }
|
||||||
|
|
||||||
|
console.log("网络请求", BASE_URL + url, params);
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
wx.request({
|
||||||
|
url: BASE_URL + url,
|
||||||
|
data: params,
|
||||||
|
method: 'GET',
|
||||||
|
success: function(res) {
|
||||||
|
console.log("GET返回数据", url, res);
|
||||||
|
if (res.statusCode == 200) {
|
||||||
|
if (res.data.err_code == 0) {
|
||||||
|
wx.hideLoading();
|
||||||
|
resolve(res.data);
|
||||||
|
} else {
|
||||||
|
if (res.data.err_code == 10003 || res.data.err_code == 10006 || res.data.err_code == 20006) {
|
||||||
|
// isUnLogin();
|
||||||
|
reject(res);
|
||||||
|
return;
|
||||||
|
} else if (res.data.err_code == 20005) {
|
||||||
|
wx.removeStorageSync('accessToken');
|
||||||
|
wx.removeStorageSync('history');
|
||||||
|
wx.hideLoading();
|
||||||
|
wx.showToast({
|
||||||
|
title: res.data.err_msg,
|
||||||
|
icon: 'none',
|
||||||
|
duration: 2000
|
||||||
|
})
|
||||||
|
reject(res);
|
||||||
|
} else {
|
||||||
|
wx.hideLoading();
|
||||||
|
wx.showToast({
|
||||||
|
title: res.data.err_msg,
|
||||||
|
icon: 'none',
|
||||||
|
duration: 2000
|
||||||
|
})
|
||||||
|
reject(res);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
wx.hideLoading();
|
||||||
|
reject(res)
|
||||||
|
wx.showToast({
|
||||||
|
title: '网络错误',
|
||||||
|
icon: 'none',
|
||||||
|
duration: 2000
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
fail: function(res) {
|
||||||
|
wx.hideLoading();
|
||||||
|
reject(res)
|
||||||
|
wx.showToast({
|
||||||
|
title: '网络错误',
|
||||||
|
icon: 'none',
|
||||||
|
duration: 2000
|
||||||
|
})
|
||||||
|
},
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 暴露接口
|
||||||
|
export default {
|
||||||
|
/**
|
||||||
|
* 任务清单
|
||||||
|
*/
|
||||||
|
taskList(params) {
|
||||||
|
return new Promise(x => {
|
||||||
|
let job = {data:{over:true}};
|
||||||
|
x(job)
|
||||||
|
console.log(x + '请求成功');
|
||||||
|
})
|
||||||
|
// return fetchGet('', params, false);
|
||||||
|
},
|
||||||
|
}
|
||||||
19
utils/util.js
Normal file
19
utils/util.js
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
const formatTime = date => {
|
||||||
|
const year = date.getFullYear()
|
||||||
|
const month = date.getMonth() + 1
|
||||||
|
const day = date.getDate()
|
||||||
|
const hour = date.getHours()
|
||||||
|
const minute = date.getMinutes()
|
||||||
|
const second = date.getSeconds()
|
||||||
|
|
||||||
|
return `${[year, month, day].map(formatNumber).join('/')} ${[hour, minute, second].map(formatNumber).join(':')}`
|
||||||
|
}
|
||||||
|
|
||||||
|
const formatNumber = n => {
|
||||||
|
n = n.toString()
|
||||||
|
return n[1] ? n : `0${n}`
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
formatTime
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user