xy 1 年之前
父節點
當前提交
3cd14e30fe

+ 73 - 0
xs-app/config/config.ts

@@ -0,0 +1,73 @@
+export class config {
+	/**
+	 * 平台
+	 */
+	public static Platform = {
+		WEIXIN :"WEIXIN",
+		TOUTIAO: "TOUTIAO",
+		H5:"H5"
+	}
+	/**
+	 * 日志开关
+	 */
+	public static LOG_OPEN:boolean = true
+	
+	/**
+	 * 测试开关
+	 */
+	public static isTest:boolean = true
+	
+	/**
+	 * 缓存数据的key
+	 */
+	public static stores_key = {
+		USER_DATA: "USER_DATA",
+	}
+	
+	/**
+	 * 测试域名
+	 */
+	private static URL_DEBUG = {
+		Dynamic:"http://",
+		Static:"http://"
+	}
+	
+	
+	/**
+	 * 正式域名
+	 */
+	private static URL_RELEASE = {
+		Dynamic:"http://",
+		Static:"http://"
+	}
+	
+	
+	/**
+	 * 域名
+	 */
+	public static url_addr= {
+		Dynamic:config.isTest?config.URL_DEBUG.Dynamic:config.URL_RELEASE.Dynamic, //动态接口
+		Static:config.isTest?config.URL_DEBUG.Static:config.URL_RELEASE.Static     //静态接口
+	}
+	
+	
+	/**
+	 * 接口
+	 */
+	public static url_confg = {
+		/**
+		 * 动态
+		 */
+		Dynamic:{
+			
+		},
+		
+		
+		/**
+		 * 静态
+		 */
+		Static:{
+			
+		}
+	}
+}

+ 6 - 0
xs-app/data/data.ts

@@ -0,0 +1,6 @@
+
+export class user_data{
+	user_name:string;
+	user_id:string;
+	token:string;
+}

+ 42 - 0
xs-app/framework/http.ts

@@ -0,0 +1,42 @@
+import { config } from "../config/config";
+import { UserData } from "../stores/userDataManager";
+export class http {
+	//动态请求
+	public static DynamicRequest(api:string,post_data:any,call_back:Function,isPost:boolean=true){
+		uni.request({
+		    url: config.url_addr.Dynamic + api, 
+		    data:post_data,
+			method:isPost?"POST":"GET",
+		    header: {
+		        'token': UserData().getUserToken() //自定义请求头信息
+		    },
+		    success: (res) => {
+				if(call_back!=null){
+					call_back(null,res)
+				}
+		    },
+			fail(res) {
+				if(call_back!=null){
+					call_back(res,null)
+				}
+			}
+		});
+	}
+	//静态请求
+	public static StaticRequest(api:string,call_back:Function){
+		uni.request({
+		    url: api, 
+			method:"GET",
+		    success: (res) => {
+				if(call_back!=null){
+					call_back(null,res)
+				}
+		    },
+			fail(res) {
+				if(call_back!=null){
+					call_back(res,null)
+				}
+			}
+		});
+	}
+}

+ 20 - 0
xs-app/framework/log.ts

@@ -0,0 +1,20 @@
+import { config } from '../config/config'
+export class log {
+	public static Debug(msg:any,...other){
+		if(config.LOG_OPEN){
+			console.log(msg,other?other:"")
+		}
+	}
+	
+	public static Error(msg:any,...other){
+		if(config.LOG_OPEN){
+			console.error(msg,other?other:"")
+		}
+	}
+	
+	public static Info(msg:any,...other){
+		if(config.LOG_OPEN){
+			console.info(msg,other?other:"")
+		}
+	}
+}

+ 0 - 0
xs-app/framework/sdkUtil.ts


+ 17 - 0
xs-app/framework/tools.ts

@@ -0,0 +1,17 @@
+import { config } from "../config/config";
+
+export class tools {
+	public static platform:string = config.Platform.H5
+	public static initPlatform(){
+		// #ifdef   MP-WEIXIN
+			tools.platform = config.Platform.WEIXIN
+		// #endif
+		
+		// #ifdef   MP-TOUTIAO
+			tools.platform = config.Platform.WEIXIN
+		// #endif
+	}
+	public static getCurPlatform(){
+		return tools.platform
+	}
+}

+ 49 - 0
xs-app/framework/util.ts

@@ -0,0 +1,49 @@
+import { log } from "./log"
+export class util {
+	/**
+	 * 获取本地数据
+	 */
+	public static getStorage(key:string){
+		let d = uni.getStorageSync(key)
+		if(util.isNull(d)){
+			return null
+		}
+		return d
+	}
+	
+	/**
+	 * 设置本地数据
+	 */
+	public static setStorage(key:string,value:string){
+		uni.setStorageSync(key,value)
+	}
+	
+	
+	/**
+	 * 清除本地key数据
+	 */
+	public static clearStorageForKey(key:string){
+		let d = util.getStorage(key)
+		if(util.isNull(d)){
+			log.Error(`${key} is null!`);
+		}else{
+			util.setStorage(key,null)
+		}
+	}
+	
+	/**
+	 * 清除本地数据
+	 */
+	public static clearAllStorage(){
+		uni.clearStorageSync()
+	}
+	
+	public static isNull(v:any){
+		if(v==null||v==undefined||v==""){
+			return true
+		}
+		return false
+	}
+	
+	
+}

+ 9 - 3
xs-app/main.js

@@ -2,7 +2,7 @@ import App from './App'
 
 // #ifndef VUE3
 import Vue from 'vue'
-import './uni.promisify.adaptor'
+import './uni.promisify.adaptor';
 Vue.config.productionTip = false
 App.mpType = 'app'
 const app = new Vue({
@@ -12,11 +12,17 @@ app.$mount()
 // #endif
 
 // #ifdef VUE3
+import * as Pinia from 'pinia';
 import { createSSRApp } from 'vue'
+import { tools } from './framework/tools';
+
 export function createApp() {
-  const app = createSSRApp(App)
+  const app = createSSRApp(App);
+  app.use(Pinia.createPinia());
+  tools.initPlatform()
   return {
-    app
+    app,
+	Pinia,
   }
 }
 // #endif

+ 49 - 4
xs-app/pages.json

@@ -1,12 +1,57 @@
 {
 	"pages": [ //pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages
 		{
-			"path": "pages/index/index",
-			"style": {
-				"navigationBarTitleText": "uni-app"
+			"path": "pages/bookstore/bookstore",
+			"style": {
+				"navigationStyle": "custom",
+				"app-plus": {
+					"bounce": "none"
+				}
 			}
+		},
+		{
+			"path": "pages/bookshelf/bookshelf",
+			"style": {
+				"navigationStyle": "custom",
+				"app-plus": {
+					"bounce": "none"
+				}
+			}
+		},
+		{
+			"path": "pages/mine/mine",
+			"style": {
+				"navigationStyle": "custom",
+				"app-plus": {
+					"bounce": "none"
+				}
+			}
 		}
-	],
+	],
+	"tabBar": {
+		"list": [
+			{
+				"pagePath": "pages/bookstore/bookstore",
+				"text": "书城",
+				"iconPath": "/static/imgs/tabBar/bookstore_0.png",
+				"selectedIconPath": "/static/imgs/tabBar/bookstore_1.png"
+			},
+			{
+				"pagePath": "pages/bookshelf/bookshelf",
+				"text": "书架",
+				"iconPath": "/static/imgs/tabBar/bookshelf_0.png",
+				"selectedIconPath": "/static/imgs/tabBar/bookshelf_1.png"
+			},
+			{
+				"pagePath": "pages/mine/mine",
+				"text": "我的",
+				"iconPath": "/static/imgs/tabBar/mine_0.png",
+				"selectedIconPath": "/static/imgs/tabBar/mine_1.png"
+			}
+		],
+		"color": "#707070",
+		"selectedColor": "#2979ff"
+	},
 	"globalStyle": {
 		"navigationBarTextStyle": "black",
 		"navigationBarTitleText": "uni-app",

+ 9 - 0
xs-app/pages/bookshelf/bookshelf.vue

@@ -0,0 +1,9 @@
+<template>
+	书架
+</template>
+
+<script>
+</script>
+
+<style>
+</style>

+ 9 - 0
xs-app/pages/bookstore/bookstore.vue

@@ -0,0 +1,9 @@
+<template>
+	<view> 书城 </view>
+</template>
+
+<script>
+</script>
+
+<style>
+</style>

+ 28 - 15
xs-app/pages/index/index.vue

@@ -3,27 +3,40 @@
 		<image class="logo" src="/static/logo.png"></image>
 		<view class="text-area">
 			<text class="title">{{title}}</text>
+		</view>
+		<button @click="cb"> 第1章复仇者
+
+		</button>
+		<view v-for="(v,k,i) in obj" key="k">
+			<text> {{v}}{{i}}</text>
 		</view>
 	</view>
 </template>
 
-<script>
-	export default {
-		data() {
-			return {
-				title: 'Hello'
-			}
-		},
-		onLoad() {
-
-		},
-		methods: {
-
-		}
-	}
+<script setup lang="ts">
+	import { ref,reactive ,onMounted,onUnmounted,watch} from 'vue';
+	let title = ref("123")
+	let obj = reactive({a:"12",b:"123"});
+	let cb = function(){
+		alert("你有点呆呆的!")
+		title.value = "fuck!"
+		obj.a = "world";
+	}
+	onMounted(()=>{
+		
+	})
+	onUnmounted(()=>{
+		alert("我被卸载了")
+	})
+	
+	watch(obj,async (new_v,old_v)=>{
+		alert(`我被改变了${new_v}`)
+		console.log(new_v,old_v)
+	})
+	
 </script>
 
-<style>
+<style scoped>
 	.content {
 		display: flex;
 		flex-direction: column;

+ 9 - 0
xs-app/pages/mine/mine.vue

@@ -0,0 +1,9 @@
+<template>
+	<view> 我的</view>
+</template>
+
+<script>
+</script>
+
+<style>
+</style>

二進制
xs-app/static/imgs/tabBar/bookshelf_0.png


二進制
xs-app/static/imgs/tabBar/bookshelf_1.png


二進制
xs-app/static/imgs/tabBar/bookstore_0.png


二進制
xs-app/static/imgs/tabBar/bookstore_1.png


二進制
xs-app/static/imgs/tabBar/mine_0.png


二進制
xs-app/static/imgs/tabBar/mine_1.png


+ 25 - 0
xs-app/stores/userDataManager.ts

@@ -0,0 +1,25 @@
+import {defineStore} from 'pinia';
+
+
+// export const UserData = defineStore('user-data',{
+// 	state:()=>{
+// 		return {}
+// 	}
+// })
+
+
+import {reactive} from 'vue';
+import { user_data } from '../data/data';
+export const UserData = defineStore('user-data',()=>{
+	let data:user_data = reactive(null)
+	async function updateUserData(d:user_data){
+		data = d;
+	}
+	function getUserToken(){
+		if(data==null){
+			return ""
+		}
+		return data.token
+	}
+	return {data,updateUserData,getUserToken}
+})

+ 8 - 0
xs-app/unpackage/dist/cache/.vite/deps/_metadata.json

@@ -0,0 +1,8 @@
+{
+  "hash": "7aa6f61e",
+  "configHash": "e71f9e36",
+  "lockfileHash": "9e930bf7",
+  "browserHash": "236dade9",
+  "optimized": {},
+  "chunks": {}
+}

+ 3 - 0
xs-app/unpackage/dist/cache/.vite/deps/package.json

@@ -0,0 +1,3 @@
+{
+  "type": "module"
+}