uniapp用户端初始化

This commit is contained in:
linfeng 2022-07-26 17:52:37 +08:00
parent 24cad5313d
commit 3669d616f7
23 changed files with 606 additions and 1 deletions

3
.gitignore vendored
View File

@ -41,3 +41,6 @@ selenium-debug.log
*.ntvs*
*.njsproj
*.sln
node_modules/
unpackage/

View File

@ -0,0 +1,11 @@
{ // launch.json configurations app-plus/h5/mp-weixin/mp-baidu/mp-alipay/mp-qq/mp-toutiao/mp-360/
// launchtypelocalremote, localremote
"version": "0.0",
"configurations": [{
"type": "uniCloud",
"default": {
"launchtype": "local"
}
}
]
}

View File

@ -0,0 +1,19 @@
<script>
export default {
onLaunch: function() {
console.log('App Launch')
},
onShow: function() {
console.log('App Show')
},
onHide: function() {
console.log('App Hide')
}
}
</script>
<style lang="scss">
/* 注意要写在第一行同时给style标签加入lang="scss"属性 */
@import "uview-ui/index.scss";
@import "static/css/iconfont.css";
</style>

View File

@ -0,0 +1,20 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<script>
var coverSupport = 'CSS' in window && typeof CSS.supports === 'function' && (CSS.supports('top: env(a)') ||
CSS.supports('top: constant(a)'))
document.write(
'<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0' +
(coverSupport ? ', viewport-fit=cover' : '') + '" />')
</script>
<title></title>
<!--preload-links-->
<!--app-context-->
</head>
<body>
<div id="app"><!--app-html--></div>
<script type="module" src="/main.js"></script>
</body>
</html>

View File

@ -0,0 +1,33 @@
import App from './App'
import store from "./store"
import uView from "uview-ui";
import config from './utils/config.js';
import request from './utils/request.js';
Vue.use(uView);
// 挂载Vuex
Vue.prototype.$store = store;
// 配置文件
Vue.prototype.$c = config;
// http请求
Vue.prototype.$H = request;
// #ifndef VUE3
import Vue from 'vue'
Vue.config.productionTip = false
App.mpType = 'app'
const app = new Vue({
...App
})
app.$mount()
// #endif
// #ifdef VUE3
import { createSSRApp } from 'vue'
export function createApp() {
const app = createSSRApp(App)
return {
app
}
}
// #endif

View File

@ -0,0 +1,72 @@
{
"name" : "linfeng-community-uniapp-ky",
"appid" : "__UNI__A0400CB",
"description" : "",
"versionName" : "1.0.0",
"versionCode" : "100",
"transformPx" : false,
/* 5+App */
"app-plus" : {
"usingComponents" : true,
"nvueStyleCompiler" : "uni-app",
"compilerVersion" : 3,
"splashscreen" : {
"alwaysShowBeforeRender" : true,
"waiting" : true,
"autoclose" : true,
"delay" : 0
},
/* */
"modules" : {},
/* */
"distribute" : {
/* android */
"android" : {
"permissions" : [
"<uses-permission android:name=\"android.permission.CHANGE_NETWORK_STATE\"/>",
"<uses-permission android:name=\"android.permission.MOUNT_UNMOUNT_FILESYSTEMS\"/>",
"<uses-permission android:name=\"android.permission.VIBRATE\"/>",
"<uses-permission android:name=\"android.permission.READ_LOGS\"/>",
"<uses-permission android:name=\"android.permission.ACCESS_WIFI_STATE\"/>",
"<uses-feature android:name=\"android.hardware.camera.autofocus\"/>",
"<uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\"/>",
"<uses-permission android:name=\"android.permission.CAMERA\"/>",
"<uses-permission android:name=\"android.permission.GET_ACCOUNTS\"/>",
"<uses-permission android:name=\"android.permission.READ_PHONE_STATE\"/>",
"<uses-permission android:name=\"android.permission.CHANGE_WIFI_STATE\"/>",
"<uses-permission android:name=\"android.permission.WAKE_LOCK\"/>",
"<uses-permission android:name=\"android.permission.FLASHLIGHT\"/>",
"<uses-feature android:name=\"android.hardware.camera\"/>",
"<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>"
]
},
/* ios */
"ios" : {},
/* SDK */
"sdkConfigs" : {}
}
},
/* */
"quickapp" : {},
/* */
"mp-weixin" : {
"appid" : "",
"setting" : {
"urlCheck" : false
},
"usingComponents" : true
},
"mp-alipay" : {
"usingComponents" : true
},
"mp-baidu" : {
"usingComponents" : true
},
"mp-toutiao" : {
"usingComponents" : true
},
"uniStatistics" : {
"enable" : false
},
"vueVersion" : "2"
}

View File

@ -0,0 +1,13 @@
{
"name": "linfeng-community-uniapp-ky",
"version": "1.0.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"uview-ui": {
"version": "1.8.4",
"resolved": "https://registry.npmmirror.com/uview-ui/-/uview-ui-1.8.4.tgz",
"integrity": "sha512-Zr+D5dFdNy6CdHQLBEXeGq/w0LkjxzBtsgaaDwLl0P58g67H7fBBDvy6AzWK/k0c7dwPYMBiK7I4Tr9p92+0DA=="
}
}
}

View File

@ -0,0 +1,15 @@
{
"name": "linfeng-community-uniapp-ky",
"version": "1.0.0",
"description": "",
"main": "main.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"uview-ui": "^1.8.4"
}
}

View File

@ -0,0 +1,63 @@
{
"easycom": {
"^u-(.*)": "uview-ui/components/u-$1/u-$1.vue"
},
"pages": [ //pageshttps://uniapp.dcloud.io/collocation/pages
{
"path": "pages/index/index",
"style": {
"navigationBarTitleText": "uni-app"
}
}
,{
"path" : "pages/message/message",
"style" :
{
"navigationBarTitleText": "",
"enablePullDownRefresh": false
}
}
,{
"path" : "pages/user/user",
"style" :
{
"navigationBarTitleText": "",
"enablePullDownRefresh": false
}
}
],
"globalStyle": {
"navigationBarTextStyle": "black",
"navigationBarTitleText": "林风论坛",
"navigationBarBackgroundColor": "#FFFFFF",
"backgroundColor": "#FFFFFF"
},
"tabBar": {
"color": "#7A7E83",
"selectedColor": "#2c2c2c",
"borderStyle": "white",
"backgroundColor": "#ffffff",
"list": [{
"pagePath": "pages/index/index",
"iconPath": "static/tabbar/home-1.png",
"selectedIconPath": "static/tabbar/home.png",
"text": "主页"
},
{
"pagePath": "pages/message/message",
"iconPath": "static/tabbar/msg-1.png",
"selectedIconPath": "static/tabbar/msg.png",
"text": "消息"
},
{
"pagePath": "pages/user/user",
"iconPath": "static/tabbar/my-1.png",
"selectedIconPath": "static/tabbar/my.png",
"text": "我的"
}
]
}
}

View File

@ -0,0 +1,25 @@
<template>
<view>
<u-icon name="photo"></u-icon>
</view>
</template>
<script>
export default {
data() {
return {
}
},
onLoad() {
},
methods: {
}
}
</script>
<style>
</style>

View File

@ -0,0 +1,22 @@
<template>
<view>
消息页
</view>
</template>
<script>
export default {
data() {
return {
}
},
methods: {
}
}
</script>
<style>
</style>

View File

@ -0,0 +1,22 @@
<template>
<view>
我的
</view>
</template>
<script>
export default {
data() {
return {
}
},
methods: {
}
}
</script>
<style>
</style>

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.5 KiB

View File

@ -0,0 +1,24 @@
import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)
const store = new Vuex.Store({
state: {
hasLogin: uni.getStorageSync("hasLogin"),
sessionKey: uni.getStorageSync("sessionKey"),
messegeNum:[],
},
mutations: {
login(state, userInfo) {
state.hasLogin = uni.getStorageSync("hasLogin");
state.sessionKey = uni.getStorageSync("sessionKey");
},
logout(state) {
state.hasLogin = false;
state.sessionKey = null;
}
}
})
export default store

View File

@ -0,0 +1 @@
@import 'uview-ui/theme.scss';

View File

@ -0,0 +1,19 @@
const miniappName = "林风社交论坛"; //分享时的标题
const shareH5Url = "https://www.linfeng.tech/#/"; //H5分享路径
//本地环境配置
// const baseUrl = "localhost:8080";
// const domain = 'http://' + baseUrl + "/app/";
//线上环境配置
const baseUrl = "wxapi.linfeng.tech";
const domain = 'https://' + baseUrl + "/app/";
export default {
baseUrl: baseUrl,
domain: domain,
miniappName: miniappName,
shareH5Url: shareH5Url
}

View File

@ -0,0 +1,67 @@
import config from './config.js';
export default {
request(options = {}) {
return new Promise((resolve, reject) => {
let url = options.url;
if (url.indexOf("http://") == -1 && url.indexOf("https://") == -1) {
options.url = config.domain + url;
}
options.header.token = uni.getStorageSync("token");
options.complete = (response) => {
if (response.statusCode == 200 || response.statusCode == 0) {
if (response.data.code == 401 || response.data.code == 420) {
// #ifdef MP-WEIXIN
uni.navigateTo({
url: "/pages/login/weixin"
})
// #endif
// #ifdef H5
uni.navigateTo({
url: "/pages/login/login"
})
// #endif
}
if (response.data.code == 500) {
uni.showToast({
title: response.data.msg,
icon: "none",
duration: 2000
});
}
resolve(response.data)
} else {
uni.showToast({
title: '请求异常!',
icon: "none"
});
}
}
uni.request(options)
})
},
post(url, data = {}, header = {}) {
let options = {
url: url,
data: data,
header: header,
method: "POST"
}
return this.request(options);
},
get(url, data = {}, header = {}) {
let options = {
url: url,
data: data,
header: header
}
return this.request(options);
}
};