commit
2c70def742
40 changed files with 4767 additions and 0 deletions
@ -0,0 +1,9 @@ |
|||||||
|
root = true |
||||||
|
|
||||||
|
[*] |
||||||
|
indent_style = space |
||||||
|
indent_size = 2 |
||||||
|
end_of_line = lf |
||||||
|
charset = utf-8 |
||||||
|
trim_trailing_whitespace = true |
||||||
|
insert_final_newline = true |
||||||
@ -0,0 +1,6 @@ |
|||||||
|
.svn |
||||||
|
.vscode |
||||||
|
node_modules |
||||||
|
.idea |
||||||
|
.DS_Store |
||||||
|
miniprogram_npm |
||||||
@ -0,0 +1,28 @@ |
|||||||
|
{ |
||||||
|
"$schema": "http://json.schemastore.org/prettierrc", |
||||||
|
"printWidth": 120, |
||||||
|
"tabWidth": 2, |
||||||
|
"useTabs": false, |
||||||
|
"semi": false, |
||||||
|
"singleQuote": true, |
||||||
|
"bracketSpacing": true, |
||||||
|
"trailingComma": "all", |
||||||
|
"arrowParens": "always", |
||||||
|
"endOfLine": "lf", |
||||||
|
"htmlWhitespaceSensitivity": "ignore", |
||||||
|
"singleAttributePerLine": false, |
||||||
|
"overrides": [ |
||||||
|
{ |
||||||
|
"files": "*.wxml", |
||||||
|
"options": { "parser": "html" } |
||||||
|
}, |
||||||
|
{ |
||||||
|
"files": "*.wxss", |
||||||
|
"options": { "parser": "css" } |
||||||
|
}, |
||||||
|
{ |
||||||
|
"files": "*.wxs", |
||||||
|
"options": { "parser": "babel" } |
||||||
|
} |
||||||
|
] |
||||||
|
} |
||||||
@ -0,0 +1,10 @@ |
|||||||
|
{ |
||||||
|
"plugins": [ |
||||||
|
[ |
||||||
|
"@babel/plugin-transform-react-jsx", |
||||||
|
{ |
||||||
|
"runtime": "automatic" |
||||||
|
} |
||||||
|
] |
||||||
|
] |
||||||
|
} |
||||||
@ -0,0 +1,28 @@ |
|||||||
|
import antfu from '@antfu/eslint-config' |
||||||
|
import prettierConfig from 'eslint-config-prettier' |
||||||
|
|
||||||
|
export default antfu( |
||||||
|
{ |
||||||
|
env: { |
||||||
|
es6: true, |
||||||
|
}, |
||||||
|
stylistic: false, |
||||||
|
parserOptions: { project: ['./tsconfig.json'] }, |
||||||
|
globals: { |
||||||
|
wx: true, |
||||||
|
App: true, |
||||||
|
Page: true, |
||||||
|
getCurrentPages: true, |
||||||
|
getApp: true, |
||||||
|
Component: true, |
||||||
|
requirePlugin: true, |
||||||
|
requireMiniProgram: true, |
||||||
|
}, |
||||||
|
rules: { |
||||||
|
'eslint-comments/no-unlimited-disable': 'off', |
||||||
|
'ts/no-require-imports': 'off', |
||||||
|
eqeqeq: 'off', |
||||||
|
}, |
||||||
|
}, |
||||||
|
prettierConfig, |
||||||
|
) |
||||||
@ -0,0 +1,29 @@ |
|||||||
|
{ |
||||||
|
"name": "school-miniprogram", |
||||||
|
"version": "1.0.0", |
||||||
|
"description": "", |
||||||
|
"author": "", |
||||||
|
"license": "", |
||||||
|
"keywords": [], |
||||||
|
"scripts": { |
||||||
|
"beforeCompile": "babel src/pages --out-dir src/pages --only **/*.jsx", |
||||||
|
"lint:fix": "eslint . --fix" |
||||||
|
}, |
||||||
|
"dependencies": { |
||||||
|
"@vant/weapp": "^1.11.2", |
||||||
|
"dayjs": "^1.11.10", |
||||||
|
"miniprogram-licia": "^1.39.2", |
||||||
|
"mp-html": "^2.4.2" |
||||||
|
}, |
||||||
|
"devDependencies": { |
||||||
|
"@antfu/eslint-config": "^3.2.0", |
||||||
|
"@babel/cli": "^7.23.4", |
||||||
|
"@babel/core": "^7.23.6", |
||||||
|
"@babel/plugin-transform-react-jsx": "^7.23.4", |
||||||
|
"eslint": "^9.9.1", |
||||||
|
"eslint-config-prettier": "^9.1.0", |
||||||
|
"miniprogram-api-typings": "^3.12.3", |
||||||
|
"prettier": "^3.3.3", |
||||||
|
"typescript": "^5.8.3" |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,76 @@ |
|||||||
|
{ |
||||||
|
"description": "项目配置文件,详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html", |
||||||
|
"miniprogramRoot": "src/", |
||||||
|
"compileType": "miniprogram", |
||||||
|
"setting": { |
||||||
|
"useCompilerPlugins": [ |
||||||
|
"typescript", |
||||||
|
"sass" |
||||||
|
], |
||||||
|
"urlCheck": true, |
||||||
|
"coverView": true, |
||||||
|
"es6": true, |
||||||
|
"postcss": true, |
||||||
|
"lazyloadPlaceholderEnable": false, |
||||||
|
"preloadBackgroundData": false, |
||||||
|
"minified": true, |
||||||
|
"autoAudits": false, |
||||||
|
"uglifyFileName": false, |
||||||
|
"uploadWithSourceMap": true, |
||||||
|
"enhance": true, |
||||||
|
"useMultiFrameRuntime": true, |
||||||
|
"showShadowRootInWxmlPanel": true, |
||||||
|
"packNpmManually": true, |
||||||
|
"packNpmRelationList": [ |
||||||
|
{ |
||||||
|
"packageJsonPath": "package.json", |
||||||
|
"miniprogramNpmDistDir": "./src" |
||||||
|
} |
||||||
|
], |
||||||
|
"minifyWXSS": true, |
||||||
|
"useStaticServer": true, |
||||||
|
"showES6CompileOption": false, |
||||||
|
"checkInvalidKey": true, |
||||||
|
"babelSetting": { |
||||||
|
"ignore": [], |
||||||
|
"disablePlugins": [], |
||||||
|
"outputPath": "" |
||||||
|
}, |
||||||
|
"disableUseStrict": false, |
||||||
|
"minifyWXML": true, |
||||||
|
"localPlugins": false, |
||||||
|
"condition": false, |
||||||
|
"ignoreUploadUnusedFiles": true, |
||||||
|
"compileWorklet": false, |
||||||
|
"swc": false, |
||||||
|
"disableSWC": true |
||||||
|
}, |
||||||
|
"simulatorType": "wechat", |
||||||
|
"simulatorPluginLibVersion": {}, |
||||||
|
"condition": {}, |
||||||
|
"srcMiniprogramRoot": "src/", |
||||||
|
"editorSetting": { |
||||||
|
"tabIndent": "insertSpaces", |
||||||
|
"tabSize": 2 |
||||||
|
}, |
||||||
|
"packOptions": { |
||||||
|
"ignore": [ |
||||||
|
{ |
||||||
|
"value": "/images/*.*", |
||||||
|
"type": "glob" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"value": "/images/**/*.*", |
||||||
|
"type": "glob" |
||||||
|
} |
||||||
|
], |
||||||
|
"include": [] |
||||||
|
}, |
||||||
|
"appid": "wx2b0bb13edf717c1d", |
||||||
|
"scripts": { |
||||||
|
"beforeCompile": "pnpm run beforeCompile", |
||||||
|
"beforePreview": "pnpm run beforeCompile", |
||||||
|
"beforeUpload": "pnpm run beforeCompile" |
||||||
|
}, |
||||||
|
"libVersion": "3.5.8" |
||||||
|
} |
||||||
@ -0,0 +1,22 @@ |
|||||||
|
{ |
||||||
|
"libVersion": "3.5.8", |
||||||
|
"condition": {}, |
||||||
|
"projectname": "school-miniprogram", |
||||||
|
"setting": { |
||||||
|
"urlCheck": true, |
||||||
|
"coverView": true, |
||||||
|
"lazyloadPlaceholderEnable": false, |
||||||
|
"skylineRenderEnable": false, |
||||||
|
"preloadBackgroundData": false, |
||||||
|
"autoAudits": false, |
||||||
|
"useApiHook": true, |
||||||
|
"showShadowRootInWxmlPanel": true, |
||||||
|
"useStaticServer": true, |
||||||
|
"useLanDebug": false, |
||||||
|
"showES6CompileOption": false, |
||||||
|
"compileHotReLoad": true, |
||||||
|
"checkInvalidKey": true, |
||||||
|
"ignoreDevUnusedFiles": true, |
||||||
|
"bigPackageSizeSupport": false |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,82 @@ |
|||||||
|
interface IGlobalParams { |
||||||
|
gUrl: string |
||||||
|
version?: string |
||||||
|
} |
||||||
|
|
||||||
|
export const request = function ( |
||||||
|
{ gUrl }: IGlobalParams, |
||||||
|
{ |
||||||
|
url, |
||||||
|
method, |
||||||
|
data, |
||||||
|
header, |
||||||
|
showMsg = true, |
||||||
|
loading = false, |
||||||
|
loadingText = '加载中...', |
||||||
|
isJSON = false, |
||||||
|
...options |
||||||
|
}: IAgaxParams, |
||||||
|
): Promise<any> { |
||||||
|
return new Promise((resolve, reject) => { |
||||||
|
if (loading) { |
||||||
|
wx.showLoading({ |
||||||
|
title: loadingText, |
||||||
|
mask: true, |
||||||
|
}) |
||||||
|
} |
||||||
|
wx.request({ |
||||||
|
header: { |
||||||
|
loginState: getApp().globalData.loginState, |
||||||
|
...header, |
||||||
|
}, |
||||||
|
url: gUrl + url, |
||||||
|
method, |
||||||
|
data: { |
||||||
|
loginState: getApp().globalData.loginState, |
||||||
|
...(data as object), |
||||||
|
}, |
||||||
|
...options, |
||||||
|
success(res: any) { |
||||||
|
const { code, data } = res.data |
||||||
|
if (isJSON) { |
||||||
|
resolve(res.data) |
||||||
|
} else if (code === 0) { |
||||||
|
resolve(data) |
||||||
|
} else if (showMsg) { |
||||||
|
const msg = errPicker(res.data) |
||||||
|
if (loading) { |
||||||
|
setTimeout(() => { |
||||||
|
wx.showToast({ |
||||||
|
title: msg, |
||||||
|
icon: 'none', |
||||||
|
}) |
||||||
|
}, 30) |
||||||
|
} else { |
||||||
|
wx.showToast({ |
||||||
|
title: msg, |
||||||
|
icon: 'none', |
||||||
|
}) |
||||||
|
} |
||||||
|
reject(res) |
||||||
|
} else { |
||||||
|
reject(res) |
||||||
|
} |
||||||
|
}, |
||||||
|
fail(err) { |
||||||
|
reject(err) |
||||||
|
}, |
||||||
|
complete() { |
||||||
|
if (loading) { |
||||||
|
wx.hideLoading() |
||||||
|
} |
||||||
|
}, |
||||||
|
}) |
||||||
|
}) |
||||||
|
} |
||||||
|
|
||||||
|
function errPicker(err: any): string { |
||||||
|
if (typeof err === 'string') { |
||||||
|
return err |
||||||
|
} |
||||||
|
return err.data || err.msg || err.errMsg || (err.detail && err.detail.errMsg) || '未知错误' |
||||||
|
} |
||||||
@ -0,0 +1,36 @@ |
|||||||
|
{ |
||||||
|
"pages": [ |
||||||
|
"pages/start/index", |
||||||
|
"pages/index/index", |
||||||
|
"pages/login/index", |
||||||
|
"pages/my/index" |
||||||
|
], |
||||||
|
"window": { |
||||||
|
"backgroundTextStyle": "light", |
||||||
|
"navigationBarBackgroundColor": "#fff", |
||||||
|
"navigationBarTitleText": "校园小程序", |
||||||
|
"navigationBarTextStyle": "black" |
||||||
|
}, |
||||||
|
"tabBar": { |
||||||
|
"custom": true, |
||||||
|
"list": [ |
||||||
|
{ |
||||||
|
"pagePath": "pages/index/index", |
||||||
|
"text": "首页" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"pagePath": "pages/my/index", |
||||||
|
"text": "我的" |
||||||
|
} |
||||||
|
] |
||||||
|
}, |
||||||
|
"sitemapLocation": "sitemap.json", |
||||||
|
"resolveAlias": { |
||||||
|
"@/*": "/*" |
||||||
|
}, |
||||||
|
"usingComponents": { |
||||||
|
"navbar": "/components/navbar/index" |
||||||
|
}, |
||||||
|
"requiredPrivateInfos": [], |
||||||
|
"permission": {} |
||||||
|
} |
||||||
@ -0,0 +1,21 @@ |
|||||||
|
.clearfix:after { |
||||||
|
content: '020'; |
||||||
|
display: block; |
||||||
|
height: 0; |
||||||
|
clear: both; |
||||||
|
visibility: hidden; |
||||||
|
} |
||||||
|
|
||||||
|
.clearfix { |
||||||
|
zoom: 1; |
||||||
|
} |
||||||
|
|
||||||
|
.scroll::-webkit-scrollbar { |
||||||
|
width: 0; |
||||||
|
height: 0; |
||||||
|
color: transparent; |
||||||
|
} |
||||||
|
|
||||||
|
view { |
||||||
|
word-break: break-all; |
||||||
|
} |
||||||
@ -0,0 +1,185 @@ |
|||||||
|
import page from '@/utils/page' |
||||||
|
import { request } from './api/request' |
||||||
|
import { parseScene } from './utils/util' |
||||||
|
|
||||||
|
const dayjs = require('dayjs') |
||||||
|
|
||||||
|
const licia = require('miniprogram-licia') |
||||||
|
require('/utils/dayjs/day-zh-cn.js') |
||||||
|
const relativeTime = require('/utils/dayjs/relativeTime.js') |
||||||
|
dayjs.locale('zh-cn') |
||||||
|
dayjs.extend(relativeTime) |
||||||
|
|
||||||
|
App<IAppOption>({ |
||||||
|
globalData: { |
||||||
|
url: '', |
||||||
|
upFileUrl: '', |
||||||
|
imageUrl: '', |
||||||
|
|
||||||
|
Timestamp: new Date().getTime(), |
||||||
|
|
||||||
|
waitBindDoctorId: '', |
||||||
|
scene: {}, |
||||||
|
|
||||||
|
loginState: '', |
||||||
|
initLoginInfo: {}, |
||||||
|
|
||||||
|
userInfo: {}, |
||||||
|
}, |
||||||
|
onLaunch() { |
||||||
|
this.autoUpdate() |
||||||
|
|
||||||
|
Page = page as WechatMiniprogram.Page.Constructor |
||||||
|
|
||||||
|
wx.ajax = licia.curry(request)({ gUrl: this.globalData.url }) |
||||||
|
}, |
||||||
|
onShow(options: Record<string, any> & { query?: Record<string, string> }) { |
||||||
|
if (options.query?.scene) { |
||||||
|
this.globalData.scene = parseScene(options.query!.scene) as any |
||||||
|
} |
||||||
|
this.startLogin() |
||||||
|
}, |
||||||
|
startLogin(callback?: () => void) { |
||||||
|
wx.login({ |
||||||
|
success: (res) => { |
||||||
|
wx.ajax({ |
||||||
|
method: 'GET', |
||||||
|
url: '?r=wtx/user/init-login', |
||||||
|
data: { |
||||||
|
code: res.code, |
||||||
|
}, |
||||||
|
}).then((res: any) => { |
||||||
|
this.globalData.loginState = res.loginState |
||||||
|
this.globalData.initLoginInfo = res |
||||||
|
if (callback) { |
||||||
|
callback() |
||||||
|
} |
||||||
|
}) |
||||||
|
}, |
||||||
|
}) |
||||||
|
}, |
||||||
|
updateLoginInfo(callback?: () => void) { |
||||||
|
wx.ajax({ |
||||||
|
method: 'GET', |
||||||
|
url: '?r=wtx/user/init-info', |
||||||
|
data: {}, |
||||||
|
}).then((res: any) => { |
||||||
|
this.globalData.initLoginInfo = res |
||||||
|
if (callback) { |
||||||
|
callback() |
||||||
|
} |
||||||
|
}) |
||||||
|
}, |
||||||
|
waitLogin({ type }: { type?: 0 | 1 | 2 | 'any' } = { type: 'any' }) { |
||||||
|
return new Promise<void>((resolve) => { |
||||||
|
const checkLogin = () => { |
||||||
|
if (this.globalData.loginState) { |
||||||
|
if (this.checkLoginType(type ?? 'any')) { |
||||||
|
resolve() |
||||||
|
} |
||||||
|
return |
||||||
|
} |
||||||
|
setTimeout(() => { |
||||||
|
checkLogin() |
||||||
|
}, 500) |
||||||
|
} |
||||||
|
checkLogin() |
||||||
|
}) |
||||||
|
}, |
||||||
|
checkLoginType(type: 0 | 1 | 2 | 'any') { |
||||||
|
const { loginType, isLogin, isReg } = this.globalData.initLoginInfo |
||||||
|
|
||||||
|
if (type === 'any') { |
||||||
|
return true |
||||||
|
} |
||||||
|
|
||||||
|
if (isLogin !== 1) { |
||||||
|
if (type === 0) { |
||||||
|
return true |
||||||
|
} |
||||||
|
wx.reLaunch({ |
||||||
|
url: '/pages/index/index', |
||||||
|
}) |
||||||
|
return false |
||||||
|
} |
||||||
|
|
||||||
|
if (isReg !== 1) { |
||||||
|
const typePageUrl: Record<number, string> = { |
||||||
|
1: '/pages/login/index', |
||||||
|
2: '/pages/login/index', |
||||||
|
} |
||||||
|
wx.reLaunch({ |
||||||
|
url: typePageUrl[loginType as 1 | 2], |
||||||
|
}) |
||||||
|
return false |
||||||
|
} |
||||||
|
|
||||||
|
if (loginType !== type) { |
||||||
|
wx.reLaunch({ |
||||||
|
url: '/pages/index/index', |
||||||
|
}) |
||||||
|
return false |
||||||
|
} |
||||||
|
|
||||||
|
return true |
||||||
|
}, |
||||||
|
getUserInfo(type: 0 | 1 | 2 = 0) { |
||||||
|
const url: Record<number, string> = { |
||||||
|
0: '?r=wtx/user/userinfo', |
||||||
|
1: '?r=wtx/account/info', |
||||||
|
2: '?r=wtx/doctor/account/info', |
||||||
|
} |
||||||
|
return wx.ajax({ |
||||||
|
method: 'GET', |
||||||
|
url: url[type], |
||||||
|
}) |
||||||
|
}, |
||||||
|
autoUpdate() { |
||||||
|
const self = this |
||||||
|
if (wx.canIUse('getUpdateManager')) { |
||||||
|
const updateManager = wx.getUpdateManager() |
||||||
|
updateManager.onCheckForUpdate((res) => { |
||||||
|
if (res.hasUpdate) { |
||||||
|
wx.showModal({ |
||||||
|
title: '更新提示', |
||||||
|
content: '检测到新版本,是否下载新版本并重启小程序?', |
||||||
|
success(res) { |
||||||
|
if (res.confirm) { |
||||||
|
self.downLoadAndUpdate(updateManager) |
||||||
|
} else if (res.cancel) { |
||||||
|
wx.showModal({ |
||||||
|
title: '温馨提示~', |
||||||
|
content: '本次版本更新涉及到新的功能添加,旧版本无法正常访问的哦~', |
||||||
|
showCancel: false, |
||||||
|
confirmText: '确定更新', |
||||||
|
success(res) { |
||||||
|
if (res.confirm) { |
||||||
|
self.downLoadAndUpdate(updateManager) |
||||||
|
} |
||||||
|
}, |
||||||
|
}) |
||||||
|
} |
||||||
|
}, |
||||||
|
}) |
||||||
|
} |
||||||
|
}) |
||||||
|
} else { |
||||||
|
wx.showModal({ |
||||||
|
title: '提示', |
||||||
|
content: '当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试。', |
||||||
|
}) |
||||||
|
} |
||||||
|
}, |
||||||
|
downLoadAndUpdate(updateManager: WechatMiniprogram.UpdateManager) { |
||||||
|
updateManager.onUpdateReady(() => { |
||||||
|
wx.hideLoading() |
||||||
|
updateManager.applyUpdate() |
||||||
|
}) |
||||||
|
updateManager.onUpdateFailed(() => { |
||||||
|
wx.showModal({ |
||||||
|
title: '新版本更新失败', |
||||||
|
content: '您可删除当前小程序,重新打开尝试', |
||||||
|
}) |
||||||
|
}) |
||||||
|
}, |
||||||
|
}) |
||||||
@ -0,0 +1,6 @@ |
|||||||
|
{ |
||||||
|
"component": true, |
||||||
|
"usingComponents": { |
||||||
|
"van-nav-bar": "@vant/weapp/nav-bar/index" |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,42 @@ |
|||||||
|
const app = getApp<IAppOption>() |
||||||
|
|
||||||
|
Component({ |
||||||
|
options: { |
||||||
|
multipleSlots: true, |
||||||
|
}, |
||||||
|
properties: { |
||||||
|
title: String, |
||||||
|
fixed: Boolean, |
||||||
|
placeholder: Boolean, |
||||||
|
leftText: String, |
||||||
|
rightText: String, |
||||||
|
customStyle: String, |
||||||
|
leftArrow: Boolean, |
||||||
|
border: { |
||||||
|
type: Boolean, |
||||||
|
value: false, |
||||||
|
}, |
||||||
|
zIndex: { |
||||||
|
type: Number, |
||||||
|
value: 1, |
||||||
|
}, |
||||||
|
back: { |
||||||
|
type: Boolean, |
||||||
|
value: true, |
||||||
|
}, |
||||||
|
}, |
||||||
|
data: { |
||||||
|
imageUrl: app.globalData.imageUrl, |
||||||
|
Timestamp: app.globalData.Timestamp, |
||||||
|
}, |
||||||
|
methods: { |
||||||
|
onClickLeft() { |
||||||
|
if (this.data.back) { |
||||||
|
this.triggerEvent('clickLeft', {}, {}) |
||||||
|
} |
||||||
|
}, |
||||||
|
onClickRight() { |
||||||
|
this.triggerEvent('clickRight', {}, {}) |
||||||
|
}, |
||||||
|
}, |
||||||
|
}) |
||||||
@ -0,0 +1,17 @@ |
|||||||
|
<van-nav-bar |
||||||
|
title="{{title}}" |
||||||
|
fixed="{{fixed}}" |
||||||
|
placeholder="{{placeholder}}" |
||||||
|
leftText="{{leftText}}" |
||||||
|
rightText="{{rightText}}" |
||||||
|
customStyle="{{customStyle}}" |
||||||
|
leftArrow="{{leftArrow}}" |
||||||
|
border="{{border}}" |
||||||
|
zIndex="{{zIndex}}" |
||||||
|
bind:click-left="onClickLeft" |
||||||
|
bind:click-right="onClickRight" |
||||||
|
> |
||||||
|
<slot name="left" slot="left"></slot> |
||||||
|
<slot name="title" slot="title"></slot> |
||||||
|
<slot name="right" slot="right"></slot> |
||||||
|
</van-nav-bar> |
||||||
@ -0,0 +1,12 @@ |
|||||||
|
const app = getApp<IAppOption>() |
||||||
|
|
||||||
|
Page({ |
||||||
|
data: { |
||||||
|
title: '首页', |
||||||
|
}, |
||||||
|
onLoad() { |
||||||
|
app.waitLogin() |
||||||
|
}, |
||||||
|
}) |
||||||
|
|
||||||
|
export {} |
||||||
@ -0,0 +1,3 @@ |
|||||||
|
<view class="page"> |
||||||
|
<text>{{title}}</text> |
||||||
|
</view> |
||||||
@ -0,0 +1,16 @@ |
|||||||
|
const app = getApp<IAppOption>() |
||||||
|
|
||||||
|
Page({ |
||||||
|
data: {}, |
||||||
|
onLoad() {}, |
||||||
|
handleGetUserInfo() { |
||||||
|
wx.getUserProfile({ |
||||||
|
desc: '用于完善用户资料', |
||||||
|
success: (res) => { |
||||||
|
app.globalData.userInfo = res.userInfo |
||||||
|
}, |
||||||
|
}) |
||||||
|
}, |
||||||
|
}) |
||||||
|
|
||||||
|
export {} |
||||||
@ -0,0 +1,3 @@ |
|||||||
|
<view class="page"> |
||||||
|
<text>登录页</text> |
||||||
|
</view> |
||||||
@ -0,0 +1,17 @@ |
|||||||
|
const app = getApp<IAppOption>() |
||||||
|
|
||||||
|
Page({ |
||||||
|
data: { |
||||||
|
userInfo: {}, |
||||||
|
}, |
||||||
|
onLoad() { |
||||||
|
app.waitLogin() |
||||||
|
}, |
||||||
|
onShow() { |
||||||
|
this.setData({ |
||||||
|
userInfo: app.globalData.userInfo, |
||||||
|
}) |
||||||
|
}, |
||||||
|
}) |
||||||
|
|
||||||
|
export {} |
||||||
@ -0,0 +1,3 @@ |
|||||||
|
<view class="page"> |
||||||
|
<text>我的</text> |
||||||
|
</view> |
||||||
@ -0,0 +1,4 @@ |
|||||||
|
{ |
||||||
|
"navigationStyle": "custom", |
||||||
|
"usingComponents": {} |
||||||
|
} |
||||||
@ -0,0 +1,7 @@ |
|||||||
|
.page { |
||||||
|
width: 100vw; |
||||||
|
height: 100vh; |
||||||
|
display: flex; |
||||||
|
align-items: center; |
||||||
|
justify-content: center; |
||||||
|
} |
||||||
@ -0,0 +1,40 @@ |
|||||||
|
import { parseScene } from '@/utils/util' |
||||||
|
const app = getApp<IAppOption>() |
||||||
|
|
||||||
|
Page({ |
||||||
|
data: {}, |
||||||
|
onLoad(options) { |
||||||
|
if (options.scene) { |
||||||
|
const params = parseScene(options.scene) |
||||||
|
if (params) { |
||||||
|
app.globalData.waitBindDoctorId = (params as any).doctorId |
||||||
|
} |
||||||
|
} |
||||||
|
app.waitLogin().then(() => { |
||||||
|
const initLoginInfo = app.globalData.initLoginInfo || {} |
||||||
|
if (initLoginInfo.isLogin === 0) { |
||||||
|
wx.reLaunch({ |
||||||
|
url: '/pages/index/index', |
||||||
|
}) |
||||||
|
} |
||||||
|
if (initLoginInfo.loginType === 1) { |
||||||
|
if (initLoginInfo.isReg === 1) { |
||||||
|
wx.reLaunch({ |
||||||
|
url: '/pages/index/index', |
||||||
|
}) |
||||||
|
return |
||||||
|
} |
||||||
|
wx.reLaunch({ |
||||||
|
url: '/pages/index/index', |
||||||
|
}) |
||||||
|
} |
||||||
|
if (initLoginInfo.loginType === 2) { |
||||||
|
wx.reLaunch({ |
||||||
|
url: '/pages/index/index', |
||||||
|
}) |
||||||
|
} |
||||||
|
}) |
||||||
|
}, |
||||||
|
}) |
||||||
|
|
||||||
|
export {} |
||||||
@ -0,0 +1,3 @@ |
|||||||
|
<view class="page"> |
||||||
|
<text>启动页</text> |
||||||
|
</view> |
||||||
@ -0,0 +1,9 @@ |
|||||||
|
{ |
||||||
|
"desc": "关于本文件的更多信息,请参考文档 https://developers.weixin.qq.com/miniprogram/dev/framework/sitemap.html", |
||||||
|
"rules": [ |
||||||
|
{ |
||||||
|
"action": "allow", |
||||||
|
"page": "*" |
||||||
|
} |
||||||
|
] |
||||||
|
} |
||||||
@ -0,0 +1,2 @@ |
|||||||
|
|
||||||
|
!function(e,_){"object"==typeof exports&&"undefined"!=typeof module?module.exports=_(require("dayjs")):"function"==typeof define&&define.amd?define(["dayjs"],_):(e="undefined"!=typeof globalThis?globalThis:e||self).dayjs_locale_zh_cn=_(e.dayjs)}(this,(function(e){"use strict";function _(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var t=_(e),d={name:"zh-cn",weekdays:"星期日_星期一_星期二_星期三_星期四_星期五_星期六".split("_"),weekdaysShort:"周日_周一_周二_周三_周四_周五_周六".split("_"),weekdaysMin:"日_一_二_三_四_五_六".split("_"),months:"一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月".split("_"),monthsShort:"1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月".split("_"),ordinal:function(e,_){return"W"===_?e+"周":e+"日"},weekStart:1,yearStart:4,formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"YYYY/MM/DD",LL:"YYYY年M月D日",LLL:"YYYY年M月D日Ah点mm分",LLLL:"YYYY年M月D日ddddAh点mm分",l:"YYYY/M/D",ll:"YYYY年M月D日",lll:"YYYY年M月D日 HH:mm",llll:"YYYY年M月D日dddd HH:mm"},relativeTime:{future:"%s内",past:"%s前",s:"几秒",m:"1 分钟",mm:"%d 分钟",h:"1 小时",hh:"%d 小时",d:"1 天",dd:"%d 天",M:"1 个月",MM:"%d 个月",y:"1 年",yy:"%d 年"},meridiem:function(e,_){var t=100*e+_;return t<600?"凌晨":t<900?"早上":t<1100?"上午":t<1300?"中午":t<1800?"下午":"晚上"}};return t.default.locale(d,null,!0),d})); |
||||||
@ -0,0 +1 @@ |
|||||||
|
!function(r,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(r="undefined"!=typeof globalThis?globalThis:r||self).dayjs_plugin_relativeTime=e()}(this,(function(){"use strict";return function(r,e,t){r=r||{};var n=e.prototype,o={future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"};function i(r,e,t,o){return n.fromToBase(r,e,t,o)}t.en.relativeTime=o,n.fromToBase=function(e,n,i,d,u){for(var f,a,s,l=i.$locale().relativeTime||o,h=r.thresholds||[{l:"s",r:44,d:"second"},{l:"m",r:89},{l:"mm",r:44,d:"minute"},{l:"h",r:89},{l:"hh",r:21,d:"hour"},{l:"d",r:35},{l:"dd",r:25,d:"day"},{l:"M",r:45},{l:"MM",r:10,d:"month"},{l:"y",r:17},{l:"yy",d:"year"}],m=h.length,c=0;c<m;c+=1){var y=h[c];y.d&&(f=d?t(e).diff(i,y.d,!0):i.diff(e,y.d,!0));var p=(r.rounding||Math.round)(Math.abs(f));if(s=f>0,p<=y.r||!y.r){p<=1&&c>0&&(y=h[c-1]);var v=l[y.l];u&&(p=u(""+p)),a="string"==typeof v?v.replace("%d",p):v(p,n,y.l,s);break}}if(n)return a;var M=s?l.future:l.past;return"function"==typeof M?M(a):M.replace("%s",a)},n.to=function(r,e){return i(r,e,this,!0)},n.from=function(r,e){return i(r,e,this)};var d=function(r){return r.$u?t.utc():t()};n.toNow=function(r){return this.to(d(this),r)},n.fromNow=function(r){return this.from(d(this),r)}}})); |
||||||
@ -0,0 +1,89 @@ |
|||||||
|
const originalPage = Page |
||||||
|
|
||||||
|
const noSharePath: string[] = [] |
||||||
|
|
||||||
|
function page(config: WechatMiniprogram.Page.Instance<WechatMiniprogram.IAnyObject, WechatMiniprogram.IAnyObject>) { |
||||||
|
const originalOnLoad = config.onLoad |
||||||
|
config.onLoad = function (options) { |
||||||
|
setImageParams(this) |
||||||
|
setNavBar(this) |
||||||
|
|
||||||
|
if (originalOnLoad) { |
||||||
|
originalOnLoad.call(this, options) |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
const originalOnPageScroll = config.onPageScroll |
||||||
|
config.onPageScroll = function (options): void { |
||||||
|
const scrollTop = options?.scrollTop |
||||||
|
let background = 'transparent' |
||||||
|
if (Number(scrollTop) > 20) { |
||||||
|
background = '#ffffff' |
||||||
|
} |
||||||
|
this.setData({ |
||||||
|
background, |
||||||
|
}) |
||||||
|
if (originalOnPageScroll) { |
||||||
|
originalOnPageScroll.call(this, options) |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
const originalOnShareAppMessage = config.onShareAppMessage |
||||||
|
config.onShareAppMessage = function (options) { |
||||||
|
if (originalOnShareAppMessage) { |
||||||
|
return originalOnShareAppMessage.call(this, options) |
||||||
|
} else { |
||||||
|
const date = new Date() |
||||||
|
const Timestamp = date.getTime() |
||||||
|
|
||||||
|
const pages = getCurrentPages() |
||||||
|
const currentPage = pages[pages.length - 1] |
||||||
|
let url = currentPage.route |
||||||
|
const opts = currentPage.options |
||||||
|
let urlWithArgs = `${url}?` |
||||||
|
for (const key in opts) { |
||||||
|
const value = opts[key] |
||||||
|
urlWithArgs += `${key}=${value}&` |
||||||
|
} |
||||||
|
urlWithArgs = urlWithArgs.substring(0, urlWithArgs.length - 1) |
||||||
|
|
||||||
|
const isNoShare = noSharePath.some((path) => url.includes(path)) |
||||||
|
|
||||||
|
let imageUrl = '' |
||||||
|
if (isNoShare) { |
||||||
|
urlWithArgs = 'pages/start/index' |
||||||
|
imageUrl = `${getApp().globalData.imageUrl}share.png?t=${Timestamp}` |
||||||
|
} |
||||||
|
|
||||||
|
return { |
||||||
|
title: '校园小程序', |
||||||
|
path: urlWithArgs, |
||||||
|
imageUrl, |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
return originalPage(config) |
||||||
|
} |
||||||
|
|
||||||
|
function setImageParams( |
||||||
|
currPage: WechatMiniprogram.Page.Instance<WechatMiniprogram.IAnyObject, WechatMiniprogram.IAnyObject>, |
||||||
|
) { |
||||||
|
const date = new Date() |
||||||
|
const Timestamp = date.getTime() |
||||||
|
currPage.setData({ |
||||||
|
imageUrl: getApp().globalData.imageUrl, |
||||||
|
Timestamp, |
||||||
|
}) |
||||||
|
} |
||||||
|
|
||||||
|
function setNavBar( |
||||||
|
currPage: WechatMiniprogram.Page.Instance<WechatMiniprogram.IAnyObject, WechatMiniprogram.IAnyObject>, |
||||||
|
) { |
||||||
|
currPage.setData({ |
||||||
|
background: 'transparent', |
||||||
|
pageTop: wx.getMenuButtonBoundingClientRect().bottom, |
||||||
|
}) |
||||||
|
} |
||||||
|
|
||||||
|
export default page |
||||||
@ -0,0 +1,26 @@ |
|||||||
|
export const getCurrentPageUrl = function () { |
||||||
|
const pages = getCurrentPages() |
||||||
|
const currentPage = pages[pages.length - 1] |
||||||
|
const url = `/${currentPage.route}` |
||||||
|
return url |
||||||
|
} |
||||||
|
|
||||||
|
export const parseUrlArgsToArray = (urlArgs: string) => { |
||||||
|
const pairs = urlArgs.split('&') |
||||||
|
const results: Record<string, string> = {} |
||||||
|
pairs.forEach((pair) => { |
||||||
|
const [key, value] = pair.split('=') |
||||||
|
if (key && value) { |
||||||
|
results[key] = value |
||||||
|
} |
||||||
|
}) |
||||||
|
return results |
||||||
|
} |
||||||
|
|
||||||
|
export const parseScene = (scene: string) => { |
||||||
|
if (scene) { |
||||||
|
return parseUrlArgsToArray(decodeURIComponent(scene)) |
||||||
|
} else { |
||||||
|
return null |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,35 @@ |
|||||||
|
{ |
||||||
|
"compilerOptions": { |
||||||
|
"target": "ES5", |
||||||
|
"jsx": "react-jsx", |
||||||
|
"lib": ["ESNext"], |
||||||
|
"moduleDetection": "force", |
||||||
|
"experimentalDecorators": true, |
||||||
|
"baseUrl": "", |
||||||
|
"module": "CommonJS", |
||||||
|
"paths": { |
||||||
|
"@vant/weapp/*": ["node_modules/@vant/weapp/dist/*"], |
||||||
|
"@/*": ["src/*"] |
||||||
|
}, |
||||||
|
"typeRoots": ["./typings", "./node_modules"], |
||||||
|
"types": ["miniprogram-api-typings"], |
||||||
|
"allowJs": false, |
||||||
|
"strict": true, |
||||||
|
"strictNullChecks": true, |
||||||
|
"strictPropertyInitialization": true, |
||||||
|
"alwaysStrict": true, |
||||||
|
"noFallthroughCasesInSwitch": true, |
||||||
|
"noImplicitAny": false, |
||||||
|
"noImplicitReturns": true, |
||||||
|
"noImplicitThis": true, |
||||||
|
"noUnusedLocals": true, |
||||||
|
"noUnusedParameters": true, |
||||||
|
"inlineSourceMap": true, |
||||||
|
"inlineSources": true, |
||||||
|
"removeComments": true, |
||||||
|
"allowSyntheticDefaultImports": true, |
||||||
|
"esModuleInterop": true, |
||||||
|
"pretty": true |
||||||
|
}, |
||||||
|
"exclude": ["node_modules", "miniprogram_npm", "src/miniprogram_npm"] |
||||||
|
} |
||||||
@ -0,0 +1,37 @@ |
|||||||
|
interface IAppOption { |
||||||
|
globalData: { |
||||||
|
url?: string |
||||||
|
upFileUrl: string |
||||||
|
imageUrl: string |
||||||
|
|
||||||
|
Timestamp: number |
||||||
|
|
||||||
|
waitBindDoctorId: string |
||||||
|
loginState: string |
||||||
|
initLoginInfo: Partial<{ |
||||||
|
isLogin: 0 | 1 |
||||||
|
isReg: 0 | 1 |
||||||
|
loginType: 1 | 2 |
||||||
|
}> |
||||||
|
|
||||||
|
[propName: string]: any |
||||||
|
} |
||||||
|
getUserInfo: (type?: 0 | 1 | 2) => Promise<any> |
||||||
|
startLogin: (callback?: () => void) => void |
||||||
|
waitLogin: (params?: { type?: 0 | 1 | 2 | 'any' }) => Promise<void> |
||||||
|
checkLoginType: (type: 0 | 1 | 2 | 'any') => boolean |
||||||
|
[propName: string]: any |
||||||
|
} |
||||||
|
|
||||||
|
interface IAgaxParams extends WechatMiniprogram.RequestOption { |
||||||
|
showMsg?: boolean |
||||||
|
loading?: boolean |
||||||
|
loadingText?: string |
||||||
|
isJSON?: boolean |
||||||
|
} |
||||||
|
|
||||||
|
declare namespace WechatMiniprogram { |
||||||
|
export interface Wx { |
||||||
|
ajax: (params: IAgaxParams) => Promise<any> |
||||||
|
} |
||||||
|
} |
||||||
Loading…
Reference in new issue