Ver Fonte

sqlite功能集成

oyq28 há 16 horas atrás
pai
commit
39a8a1b679

+ 45 - 13
api/login.uts

@@ -1,5 +1,9 @@
 import request from '@/utils/request'
-import sqlite from '@/utils/sqlite'
+import { getToken, removeToken } from '@/utils/auth';
+// #ifdef APP-ANDROID
+import {selectTableData, insertTableData} from '@/utils/sqlite'
+// #endif
+
 
 export function offlineData(data:UTSJSONObject):Promise<UTSJSONObject> {
 	return new Promise((resolve, reject) => {	
@@ -26,10 +30,17 @@ export function login(username:string, password:string, code:string, uuid:string
 	roles:[] as string[]
   } as UTSJSONObject
   
-  // #ifdef APP-ANDROID
-  let result = sqlite.selectTableData('app_user','username',data['username'],'password',data['password']);
-  console.log(result)
+    // #ifdef APP-ANDROID
+    const result = selectTableData('app_user', 'username', username, 'password', password);
+    console.log(result);
+	return result;
+	// #endif
+   
+  // #ifdef H5
+   return offlineData(data2)
   // #endif
+  
+  
   /*
   return request({
     'url': '/login',
@@ -38,18 +49,19 @@ export function login(username:string, password:string, code:string, uuid:string
     },
     'method': 'post',
     'data': data
-  })*/
-  return offlineData(data2)
+  })*/ 
 }
 export type RegForm={
 			username: string,
 			password: string,
+			token: string,
 			confirmPassword: string,
 			code: string,
 			uuid: string
 }
 // 注册方法
 export function register(data:RegForm):Promise<UTSJSONObject> {
+  /*	
   return request({
     url: '/register',
     headers: {
@@ -57,7 +69,20 @@ export function register(data:RegForm):Promise<UTSJSONObject> {
     },
     method: 'post',
     data
-  })
+  }) */
+  // #ifdef APP-ANDROID
+	let condition = 'username,password,token,status,createtime,updatetime'
+	let date = "strftime('%Y-%m-%d %H:%M:%S', 'now')"
+	let dataStr = `'${data.username}','${data.password}','${data.token}',1, ${date}, ${date}`;  
+	console.log(dataStr)
+	const result = insertTableData('app_user', dataStr, condition);
+	console.log(result);
+	return result;
+  // #endif
+  
+  // #ifdef H5
+   return offlineData(data)
+  // #endif  
 }
 
 // 获取用户详细信息
@@ -75,21 +100,28 @@ export function getInfo():Promise<UTSJSONObject> {
 	token: '123456', 
 	roles:[] as string[]
   } as UTSJSONObject
-  
-  // #ifdef APP-ANDROID
-  let result = sqlite.selectTableData('app_user','username',data['username'],'password',data['password']);
-  console.log(result)
+      
+	// #ifdef APP-ANDROID
+	const result = selectTableData('app_user', 'token', getToken(), null, null);
+	console.log(result);
+	return result;
   // #endif
-    
+  // #ifdef H5  
   return offlineData(data)
+  // #endif
 }
 
 // 退出方法
 export function logout(token?:any):Promise<UTSJSONObject> {
+  /*
   return request({
     'url': '/logout',
     'method': 'post'
-  })
+  }) */
+  return new Promise((resolve, reject) => {  
+	 let obj = {} as UTSJSONObject
+  	 resolve(obj)
+  });
 }
 
 // 获取验证码

+ 32 - 0
api/work.uts

@@ -0,0 +1,32 @@
+// #ifdef APP-ANDROID
+import {selectTableData, insertTableData} from '@/utils/sqlite'
+// #endif
+
+export function offlineData(data:UTSJSONObject):Promise<UTSJSONObject> {
+	return new Promise((resolve, reject) => {	
+		let result = JSON.parseObject(JSON.stringify(data)) as UTSJSONObject 
+		resolve(result)
+	});	
+}
+
+
+export async function getList(tableName:string, condition?:string|null, initData?:UTSJSONObject|null):Promise<UTSJSONObject> {
+   
+    // #ifdef APP-ANDROID
+    const result = await selectTableData(tableName, null, null, null, null);
+    console.log(result);
+	return result;
+	// #endif
+   
+  // #ifdef H5
+   return offlineData(initData)
+  // #endif
+}
+
+/*
+export const onload=():Promise<UTSJSONObject>=> {
+  return new Promise((resolve, reject) => {
+	  getInfo().then((res:UTSJSONObject) => {
+	  })
+  })
+}  */

BIN
db/qt_app_800.db


+ 9 - 1
manifest.json

@@ -800,13 +800,21 @@
 				"xxhdpi": "",
 				"xxxhdpi": ""
 			},
-			"minSdkVersion": "26",
+			"minSdkVersion": "22",
 			"targetSdkVersion": "35",
 			"abiFilters": [
 				"armeabi-v7a",
 				"arm64-v8a",
 				"x86",
 				"x86_64"
+			],
+			"permissions": [
+				"<uses-permission android:name=\"android.permission.WRITE_EXTERNAL_STORAGE\"/>",
+				"<uses-permission android:name=\"android.permission.READ_EXTERNAL_STORAGE\"/>",
+				"",
+				"",
+				"",
+				""
 			]
 		}
 	}

+ 7 - 2
pages/login.uvue

@@ -58,7 +58,7 @@
         codeUrl: "" as string,
         captchaEnabled: false as boolean,
         // 用户注册开关
-        register: true as boolean,
+        register: false as boolean,
         globalConfig: getApp().globalData.config as UTSJSONObject,
         loginForm: {
           username: "admin",
@@ -143,7 +143,12 @@
 		  uni.hideLoading();
           this.loginSuccess()
         }).catch((e) => {
-		  console.log(e)	
+		  uni.hideLoading();
+		  uni.showToast({
+		    title: '登录失败',
+		    icon: 'error', 
+		    duration: 2000 
+		  });	
           if (this.captchaEnabled) {
             //this.getCode()
           }

+ 1 - 16
pages/mine/index.uvue

@@ -27,22 +27,7 @@
 
     <view class=" content-section">
       <view class=" mine-actions grid col-4  uni-row">
-        <view class=" action-item my-view" @click="handleJiaoLiuQun">
-          <view class=" text-pink icon text-center my-view"></view>
-          <text class="text text-center my-text">交流群</text>
-        </view>
-        <view class=" action-item my-view" @click="handleBuilding">
-          <view class=" text-blue icon text-center my-view"></view>
-          <text class="text text-center my-text">在线客服</text>
-        </view>
-        <view class=" action-item my-view" @click="handleBuilding">
-          <view class=" text-mauve icon text-center my-view"></view>
-          <text class="text text-center my-text">反馈社区</text>
-        </view>
-        <view class=" action-item my-view" @click="handleBuilding">
-          <view class=" text-green icon text-center my-view"></view>
-          <text class="text text-center my-text">点赞我们</text>
-        </view>
+        
       </view>
 
       <view class=" menu-list">

+ 14 - 2
pages/mine/setting/index.uvue

@@ -7,6 +7,12 @@
           <view class="font-14">修改密码</view>
         </view>
       </view>
+	  <view class=" list-cell list-cell-arrow" @click="handleToRegister" v-if="isAdmin">
+	    <view class=" menu-item-box uni-row">
+	      <view class=" iconfont icon-password menu-icon"></view>
+	      <view class="font-14">创建用户</view>
+	    </view>
+	  </view>
       <view class=" list-cell list-cell-arrow" @click="handleToUpgrade">
         <view class=" menu-item-box  uni-row">
           <view class=" iconfont icon-refresh menu-icon"></view>
@@ -31,10 +37,11 @@
 </template>
 
 <script lang="uts">
-  import {LogOut} from '@/store';
+  import {state,LogOut} from '@/store';
   export default {
     data() {
       return {
+		isAdmin: state.name=='admin'? true: false,  
         windowHeight: uni.getSystemInfoSync().windowHeight
       }
     },
@@ -44,6 +51,11 @@
           url: '/pages/mine/pwd/index'
         });
       },
+	  handleToRegister() {
+		 uni.navigateTo({
+		   url: '/pages/register'
+		 }); 
+	  },
       handleToUpgrade() {
         uni.showToast({
           title: '模块建设中~',
@@ -64,7 +76,7 @@
             if (res.confirm) {
               LogOut().then(() => {
                 uni.reLaunch({
-                  url: '/'
+                  url: '/pages/login'
                 });
               });
             }

+ 15 - 4
pages/register.uvue

@@ -19,6 +19,10 @@
         <view class=" iconfont icon-password icon"></view>
         <input v-model="registerForm.confirmPassword" type="password" class="input" placeholder="请输入重复密码" maxlength="20" />
       </view>
+	  <view class=" input-item flex align-center uni-row">
+	    <view class=" iconfont icon"></view>
+	    <input v-model="registerForm.token" type="input" class="input" placeholder="请输入token" maxlength="20" />
+	  </view>
 	  <!--
       <view class=" input-item flex align-center" style="width: 60%;margin: 0px;" v-if="captchaEnabled">
         <view class=" iconfont icon-code icon"></view>
@@ -31,7 +35,7 @@
         <button @click="handleRegister()" class="register-btn block bg-blue lg round">注册</button>
       </view>
     </view>
-    <view class=" xieyi text-center">
+    <view class=" xieyi text-center" v-if="login">
       <text @click="handleUserLogin" class="text-blue">使用已有账号登录</text>
     </view>
   </view>
@@ -46,11 +50,13 @@ import { getCodeImg, register, RegForm} from '@/api/login'
     data() {
       return {
         codeUrl: "" as string,
-        captchaEnabled: true as boolean,
+        captchaEnabled: false as boolean,
+		login: false as boolean,
         globalConfig: getApp().globalData.config as UTSJSONObject,
         registerForm: {
           username: "",
           password: "",
+		  token: "",
           confirmPassword: "",
           code: "",
           uuid: ''
@@ -99,7 +105,12 @@ import { getCodeImg, register, RegForm} from '@/api/login'
             title: '两次输入的密码不一致',
             icon: 'error'
           });
-        } 
+        } else if (this.registerForm.token == "") {
+          uni.showToast({
+            title: '请输入您的token',
+            icon: 'error'
+          });
+        }
 		/*else if (this.registerForm.code == "" && this.captchaEnabled) {
           uni.showToast({
             title: '请输入验证码',
@@ -122,7 +133,7 @@ import { getCodeImg, register, RegForm} from '@/api/login'
           	content: "恭喜你,您的账号 " + this.registerForm.username + " 注册成功!",
           	success: function (res:UniShowModalResult) {
           		if (res.confirm) {
-                uni.redirectTo({ url: `/pages/login` });
+					uni.redirectTo({ url: `/pages/login` });
           		}
           	}
           })

+ 70 - 44
pages/work/download/DownloadList.uvue

@@ -46,9 +46,9 @@
 			<view class="info-row">
 				<text class="label">进度:</text>
 				<text class="process-value" :class="{
-					'bg-green': item.state === 'done',
-					'bg-yellow': item.state === 'doing',
-					'bg-black': item.state === 'waiting'
+					'bg-green': item.status === 3,
+					'bg-yellow': item.status === 2,
+					'bg-black': item.status === 1
 				  }">{{ item.progress }}</text>
 			</view>
 		</view>
@@ -61,6 +61,8 @@
 	import {
 		ref
 	} from 'vue'
+	import { getList } from '@/api/work';
+		
 	type Download = {
 		pdid : number,
 		workorder : string,
@@ -72,47 +74,71 @@
 		ver : string,
 		updatetime : string,
 		progress : string,
-		state : string
-	}
-
-	const downloads = [{
-		pdid: 1,
-		workorder: "632-P-01",
-		invname: "箱间段",
-		productno: "1CFA1040-00#S",
-		graphid: "HBJ0100-00",
-		cardno: "LK20230707070012",
-		processno: "Pb/XXX-E11",
-		ver: "A.1",
-		updatetime: "2025-06-23",
-		progress: "3/3",
-		state: "done"
-
-	}, {
-		pdid: 2,
-		workorder: "712-SY-10-6",
-		invname: "级间架",
-		productno: "1XA1020-00A",
-		graphid: "1XC002-00",
-		cardno: "LK20250215003",
-		processno: "Pb/XXX-E11",
-		ver: "B.1",
-		updatetime: "2025-08-25",
-		progress: "2/4",
-		state: "doing"
-	}, {
-		pdid: 3,
-		workorder: "712-SY-10-6",
-		invname: "级间架",
-		productno: "1XA1020-00A",
-		graphid: "1XC002-00",
-		cardno: "LK20250215003",
-		processno: "Pb/XXX-E11",
-		ver: "B.1",
-		updatetime: "2025-08-25",
-		progress: "0/4",
-		state: "waiting"
-	}] as Download[];
+		status : number
+	}
+	var initDownloads = [] as Download[]
+	var downloads = ref<Download[]>([]);
+	
+	// #ifdef APP-ANDROID	 
+	 getList('app_product', null, null).then((res:UTSJSONObject) => {
+	  		console.log(res)
+			let dataList = res?.['data'] as UTSJSONObject[] ?? Array<UTSJSONObject>()
+			if(dataList!=null && dataList.length>0){
+				dataList.forEach(item =>{
+					if(item!=null){
+						let download = JSON.parse<Download>(item.toJSONString());
+						if(download!=null){
+							initDownloads.push(download)
+						}
+					}
+				});
+			}
+			console.log(initDownloads)
+			downloads.value = initDownloads
+	  })		
+	// #endif
+		
+		// #ifdef H5
+		const downloads = [{
+			pdid: 1,
+			workorder: "632-P-01",
+			invname: "箱间段",
+			productno: "1CFA1040-00#S",
+			graphid: "HBJ0100-00",
+			cardno: "LK20230707070012",
+			processno: "Pb/XXX-E11",
+			ver: "A.1",
+			updatetime: "2025-06-23",
+			progress: "3/3",
+			status: 3
+		
+		}, {
+			pdid: 2,
+			workorder: "712-SY-10-6",
+			invname: "级间架",
+			productno: "1XA1020-00A",
+			graphid: "1XC002-00",
+			cardno: "LK20250215003",
+			processno: "Pb/XXX-E11",
+			ver: "B.1",
+			updatetime: "2025-08-25",
+			progress: "2/4",
+			status: 2
+		}, {
+			pdid: 3,
+			workorder: "712-SY-10-6",
+			invname: "级间架",
+			productno: "1XA1020-00A",
+			graphid: "1XC002-00",
+			cardno: "LK20250215003",
+			processno: "Pb/XXX-E11",
+			ver: "B.1",
+			updatetime: "2025-08-25",
+			progress: "0/4",
+			status: 1
+		}] as Download[];
+		// #endif
+	
 
 	const download = (e : any) => {
 		console.log("开始下载...")

+ 1 - 1
pages/work/index.uvue

@@ -51,7 +51,7 @@
     data() { 
       return {
 		items: [
-		      {colorClass: 'blue', iconType: "person-filled", text: "用户管理",path:"" },
+		      {colorClass: 'blue', iconType: "person-filled", text: "用户管理",path:"/pages/mine/index" },
 			  {colorClass: 'blue', iconType: "download", text: "数据下载",path:"/pages/work/download/DownloadList" },
 			  {colorClass: 'blue', iconType: "list", text: "任务管理",path:"/pages/work/task/TaskList" },
 			  {colorClass: 'orange', iconType: "mic", text: "声像记录", path:"/pages/work/record/InfoList"},

+ 1 - 1
pages/work/record/InfoDetail.uvue

@@ -90,7 +90,7 @@
 	];
 
 	onLoad((options) => {
-		//const downloadId = options?.id ?? ""
+		const downloadId = options?.id ?? ""
 		// 模拟数据加载,建议替换为后端接口请求
 
 	})

+ 35 - 8
pages/work/record/InfoList.uvue

@@ -38,9 +38,9 @@
 			<view class="info-row">
 				<text class="label">进度:</text>
 				<text class="process-value" :class="{
-					'bg-green': item.state === 'done',
-					'bg-yellow': item.state === 'doing',
-					'bg-black': item.state === 'waiting'
+					'bg-green': item.status === 3,
+					'bg-yellow': item.status === 2,
+					'bg-black': item.status === 1
 				  }">{{ item.progress }}</text>
 			</view>
 		</view>
@@ -53,6 +53,8 @@
 	import {
 		ref
 	} from 'vue'
+	import { getList } from '@/api/work';
+	
 	type Download = {
 		pdid : number,
 		workorder : string,
@@ -62,9 +64,32 @@
 		processno : string,
 		updatetime : string,
 		progress : string,
-		state : string
+		status : number 
 	}
-
+	
+	var initDownloads = [] as Download[]
+	var downloads = ref<Download[]>([]);
+	
+	// #ifdef APP-ANDROID
+	 getList('app_media_info', null, null).then((res:UTSJSONObject) => {
+	  		console.log(res)
+			let dataList = res?.['data'] as UTSJSONObject[] ?? Array<UTSJSONObject>()
+			if(dataList!=null && dataList.length>0){
+				dataList.forEach(item =>{
+					if(item!=null){
+						let download = JSON.parse<Download>(item.toJSONString());
+						if(download!=null){
+							initDownloads.push(download)
+						}
+					}
+				});
+			}
+			console.log(initDownloads)
+			downloads.value = initDownloads
+	  })		
+	// #endif
+
+   // #ifdef H5
 	const downloads = [{
 		pdid: 1,
 		workorder: "632-P-01",
@@ -74,7 +99,7 @@
 		processno: "Pb/XXX-E11",
 		updatetime: "2025-06-23",
 		progress: "3/3",
-		state: "done"
+		status: 3
 
 	}, {
 		pdid: 2,
@@ -85,7 +110,7 @@
 		processno: "Pb/XXX-E11",
 		updatetime: "2025-08-25",
 		progress: "2/4",
-		state: "doing"
+		status: 2
 	}, {
 		pdid: 3,
 		workorder: "712-SY-10-6",
@@ -95,9 +120,11 @@
 		processno: "Pb/XXX-E11",
 		updatetime: "2025-08-25",
 		progress: "0/4",
-		state: "waiting"
+		status: 1
 	}] as Download[];
 
+    // #endif
+
 	const download = (e : any) => {
 		console.log("开始下载...")
 	}

+ 38 - 6
pages/work/record/RecordList.uvue

@@ -24,7 +24,7 @@
 
 			<view class="info-row">
 				<text class="label">产品码:</text>
-				<text class="value">{{ item.productNo }}</text>
+				<text class="value">{{ item.productno }}</text>
 			</view>
 
 			<view class="info-row">
@@ -95,11 +95,12 @@
 	import {
 		ref
 	} from 'vue'
+	import { getList } from '@/api/work';
 	type Record = {
 		sxid : number,
 		senum : string,
 		photoitem : number,
-		productNo : string,
+		productno : string,
 		part : string,
 		descb : string,
 		date : string,
@@ -114,12 +115,39 @@
 	var maxcount = 5
 	var current = ref(1)
 	var records = ref<Record[]>([]);
-	var closeTags = ref([true, true, true, true, true, true, true])
+	var closeTags = ref([true, true, true, true, true, true, true])	
+	var initRecords = [] as Record[]
+	// #ifdef APP-ANDROID
+	   getList('app_media_record', null, null).then((res:UTSJSONObject) => {
+	    		let dataList = res?.['data'] as UTSJSONObject[] ?? Array<UTSJSONObject>()
+	   			if(dataList!=null && dataList.length>0){
+	   				dataList.forEach(item =>{
+	   					if(item!=null){
+							const imgnameStr = item['imgname'] as string
+							const urlpdtStr = item['urlpdt'] as string
+							const imgnameArr = imgnameStr.split(",")
+							const urlpdtArr = urlpdtStr.split(",")
+							item['imgname'] = imgnameArr
+							item['urlpdt'] = urlpdtArr
+	   						let record = JSON.parse<Record>(item.toJSONString());
+	   						if(record!=null){
+	   							initRecords.push(record)
+	   						}
+	   					}
+	   				});
+	   			}
+	   		console.log(initRecords)
+			records.value = initRecords.filter(item => item['photoitem'] == current.value)
+	    });
+	
+	// #endif
+	
+	// #ifdef H5
 	const initRecords = [{
 		sxid: 1,
 		senum: '1',
 		photoitem: 1,
-		productNo: 'YH0001',
+		productno: 'YH0001',
 		part: '角焊缝',
 		descb: '角片角焊缝',
 		date: '2025-06-05',
@@ -134,7 +162,7 @@
 		sxid: 2,
 		senum: '2',
 		photoitem: 2,
-		productNo: 'YH0002',
+		productno: 'YH0002',
 		part: '角焊缝',
 		descb: '角片角焊缝',
 		date: '2025-06-05',
@@ -145,8 +173,10 @@
 		imgname: ['1.jpg', '2.jpg', '3.jpg'],
 		urlpdt: ['/static/images/demo.png', '/static/images/demo.png', '/static/images/demo.png']
 	}] as Record[];
-
 	records.value = initRecords.filter(item => item['photoitem'] == current.value)
+	// #endif
+
+	
 	const tabsClick = (obj : number) => {
 		current.value = obj
 		records.value = initRecords.filter(item => item['photoitem'] == current.value)
@@ -160,6 +190,8 @@
 			url: `/pages/work/record/Camera?id=${id}`
 		})
 	}
+	
+		
 </script>
 
 <style scoped>

BIN
static/db/QT800.db


+ 2 - 1
static/scss/colorui.css

@@ -688,7 +688,7 @@ radio.white.checked .uni-radio-input {
 	transform: translate(0rpx, 0rpx);
 }
 
-
+/* #ifndef APP-ANDROID */
 .cu-btn::after {
 	display: none;
 }
@@ -730,6 +730,7 @@ radio.white.checked .uni-radio-input {
 .cu-btn[class*="bg-"]::after {
 	display: none;
 }
+/* #endif */
 
 .cu-btn.sm {
 	padding: 0 20rpx;

+ 24 - 19
store/index.uts

@@ -5,8 +5,6 @@ import { login, logout, getInfo } from '@/api/login';
 import { getToken, setToken, removeToken } from '@/utils/auth';
 import profileImg from '@/static/images/profile.jpg';
 
-
-
 type State = {
   token: string,
   name: string,
@@ -48,6 +46,10 @@ export const SetName=(name: string)=>{
 	storage.set(constant.name, name);
 }
 
+export const cleanAll=()=>{
+	uni.removeStorageSync('storage_data')
+}
+
 export const SetAvatar=(avatar: string)=> {
 	state.avatar = avatar;
 	storage.set(constant.avatar, avatar);
@@ -70,18 +72,19 @@ export const Login=(userInfo:UTSJSONObject):Promise<void>=> {
     const uuid:string = userInfo.getString("uuid") as string;
 			
 	return new Promise((resolve, reject) => {
-		/*
+		
 	  login(username, password, code, uuid).then((res:UTSJSONObject) => {
-	    SetToken(res.getString("token") as string);
-	    resolve()
-	  }).catch((error:any) => {
-	    reject(error)
-	  }) */
-	  // #ifdef APP
-	     const token:string = state?.token as string ?? ''
-	     SetToken(token);
-	  // #endif
-	  resolve()
+	    //SetToken(res.getString("token") as string);
+		console.log(res)
+		let msg = res.getString("errMsg")
+		let data = res.getArray("data") as UTSJSONObject[]
+		if(msg == 'ok' && data.length>0){
+			SetToken(data[0].getString("token") as string)
+			resolve()
+		}else{
+			reject('登录失败')
+		}	    
+	  })
 	})
   }
 
@@ -92,15 +95,16 @@ export const GetInfo=():Promise<UTSJSONObject>=> {
 	  let avatar:string=profileImg as string
 	  let username:string="" as string
 	  const resMap=res.toMap() as Map<string,any>
-	   if(resMap.has("user")){
-		   const user:UTSJSONObject|null = res.getJSON("user");
-		   if(user!=null){
+	   if(resMap.has("data")){
+		   const data:UTSJSONObject[]|null = resMap?.get("data") as UTSJSONObject[] ?? null;
+		   if(data!=null && data.length>0){
+			const user = data?.[0] as UTSJSONObject   
 			const userMap=user.toMap() as Map<string,any>
 			if(userMap.has("avatar")&&user.getString("avatar")!=null&&user.getString("avatar")!=""){
 				avatar=globalConfig.baseUrl + user.getString("avatar") as string
 			}
-			if(userMap.has("userName")&&user.getString("userName")!=null&&user.getString("userName")!=""){
-				username= user.getString("userName") as string
+			if(userMap.has("username")&&user.getString("username")!=null&&user.getString("username")!=""){
+				username= user.getString("username") as string
 			}
 		   }
 	   }
@@ -126,12 +130,13 @@ export const GetInfo=():Promise<UTSJSONObject>=> {
   // 退出系统
   export const LogOut=():Promise<UTSJSONObject>=> {
 	return new Promise<UTSJSONObject>((resolve, reject) => {
+	  console.log(state.token)
 	  logout(state.token).then(() => {
 	    SetToken('');
 		SetRoles([]);
 		SetPermissions([]);   
 		removeToken();
-		//storage.clean?.();
+		cleanAll();
 	    resolve({});
 	  })
 	})

+ 57 - 42
uni_modules/uni-sqlContext/utssdk/app-android/index.uts

@@ -1,29 +1,38 @@
 import Cursor from 'android.database.Cursor';
 import SQLiteDatabase from 'android.database.sqlite.SQLiteDatabase';
 import SQLiteOpenHelper from 'android.database.sqlite.SQLiteOpenHelper';
+import Environment from 'android.os.Environment';
 
-import { createSQLiteContextOptions, executeSqlOptions, selectSqlOptions, executeSqlOptionsResult, selectSqlOptionsResult, CreateSQLiteContext, transactionOptions, transactionResult } from '../interface.uts';
+import { createSQLiteContextOptions, executeSqlOptions, selectSqlOptions, executeSqlOptionsResult, selectSqlOptionsResult, CreateSQLiteContext, transactionOptions, transactionResult, ICreateSQLiteContextError } from '../interface.uts';
+//import { createSQLiteContextOptions, executeSqlOptions, selectSqlOptions, transactionOptions } from '../interface.uts';
 import { createSQLiteContextFailImpl } from '../unierror.uts';
 
 class SQLiteContext extends SQLiteOpenHelper {
   private dbName: string | null;
-
+  
   constructor(name: string) {
-    let version = 1;
-    super(UTSAndroid.getAppContext()!, name, null, version.toInt());	
-    this.dbName = name;
+    console.log(UTSAndroid.getResourcePath("/static/db/"+name))	
+	super(UTSAndroid.getAppContext(), UTSAndroid.getResourcePath("/static/db/"+name), null, 1);
+	this.dbName = name;
+  }
+  
+    
+  override onCreate(db: SQLiteDatabase):void {
+	  
+  }
+  
+  override onUpgrade(db: SQLiteDatabase, oldVersion:Int, newVersion:Int):void {
+  	 
   }
 
   public executeSql(options: executeSqlOptions) {
-    const database: SQLiteDatabase = this.getReadableDatabase();
+    const database: SQLiteDatabase = this.getWritableDatabase();
     const SqlArray = options.sql.split(';');
     let result: executeSqlOptionsResult = {
 		data: [] as boolean[],
-		errMsg: 'executeSql:ok',
-		errSubject: '',
-		errCode: 0,
-		cause: null
+		errMsg: 'ok'
 	}
+		
     try {
       for (let i = 0; i < SqlArray.length; i++) {
         if (SqlArray[i].length > 0) {
@@ -31,16 +40,15 @@ class SQLiteContext extends SQLiteOpenHelper {
           try {
             database.execSQL(sql);
             result.data.push(true);
-          } catch {
+          } catch(e:Error) {
             result.data.push(false);
           }
         }
       }
       options.success?.(result);
-    } catch (e) {
-      const data = result.data;
-      result = new createSQLiteContextFailImpl(1000002);
-      result.data = data;
+    } catch (e) {      
+      const err = new createSQLiteContextFailImpl(1000002);
+      result.errMsg = err.errMsg;
       options.fail?.(result);
     }
     options.complete?.(result);
@@ -51,12 +59,10 @@ class SQLiteContext extends SQLiteOpenHelper {
     const database: SQLiteDatabase = this.getReadableDatabase();
     const SqlArray = options.sql.split(';');
     let result: selectSqlOptionsResult = {
-		data: [] as string[],
-		errMsg: 'selectSql:ok',
-		errCode: 0,
-		errSubject: '',
-		cause: null
+		data: [] as UTSJSONObject[],
+		errMsg: 'ok',		
 	}
+		
     try {
       for (let i = 0; i < SqlArray.length; i++) {
         if (SqlArray[i].length > 0) {
@@ -67,39 +73,43 @@ class SQLiteContext extends SQLiteOpenHelper {
             if (cursor.moveToFirst()) {
               do {
                 const row = cursor.getColumnCount();
-                //const rowArray = [] as string[];
-                for (let j = 0; j < row; j++) {
-                  result.data.push(cursor.getString(j));
+                const utsJsonObject = {} as UTSJSONObject;
+                for (let j:Int = 0; j < row; j++) {
+                  //rowArray.push(cursor.getString(j)!=null? cursor.getString(j):'');
+				  //let obj = {cursor.getColumnName(j):cursor.getString(j)!=null? cursor.getString(j):''}
+				  //rowArray.push(obj)
+				  utsJsonObject.set(cursor.getColumnName(j).toString(), cursor.getString(j)!=null? cursor.getString(j):'')
                 }
-                //result.data.push(rowArray);
+                result.data.push(utsJsonObject);
               } while (cursor.moveToNext());
             }
             cursor.close();
-          } catch {
-            result.data.push("");
+          } catch(e:Error) {
+			console.log(e)			
+            result.data.push({});
           }
         }
       }
       options.success?.(result);
-    } catch (e) {
-      const data = result.data;
-      result = new createSQLiteContextFailImpl(1000003);
-      result.data = data;
+    } catch (e) {      
+      const err = new createSQLiteContextFailImpl(1000003);
+      result.errMsg = err.errMsg;
       options.fail?.(result);
     }
     options.complete?.(result);
     return result;
   }
+  /*
+  public close(){
+	  const database: SQLiteDatabase = this.getReadableDatabase();
+	  database.close();
+  } */
 
   public transaction(options: transactionOptions) {
     const database: SQLiteDatabase = this.getReadableDatabase();
     const transaction = options.operation;
     let result: transactionResult = {
 		errMsg: 'transaction:ok',
-		data: [],
-		errCode: 0,
-		errSubject: '',
-		cause: null
 	}
     try {
       if (transaction == 'begin') {
@@ -122,15 +132,20 @@ class SQLiteContext extends SQLiteOpenHelper {
       } else if (transaction == 'rollback') {
         errCode = 1000006;
       }
-      result = new createSQLiteContextFailImpl(errCode);
-      options.fail?.(result);
-    }
-    options.complete?.(result);
-    return result;
+      const err = new createSQLiteContextFailImpl(errCode);
+	  const errInfo = {errMsg:err.errMsg } as  transactionResult ;	
+      options.fail?.(errInfo);
+    }    
+	let ret = {		
+		errMsg: result.errMsg as string
+	} as UTSJSONObject
+	options.complete?.(result);
+    return ret;
   }
 }
 
-export const createSQLiteContext: CreateSQLiteContext = function (options: createSQLiteContextOptions) {
-  const name = options.name + '.db';
+export const createSQLiteContext = function (dbName: string): SQLiteContext {
+  const name = dbName + '.db';
   return new SQLiteContext(name);
-}
+}
+

+ 25 - 13
uni_modules/uni-sqlContext/utssdk/interface.uts

@@ -55,17 +55,21 @@ export type executeSqlOptionsCompleteCallback = (res: executeSqlOptionsResult) =
  * @param errMsg 返回的错误信息
  * @param data 返回的数据
  */
-export interface executeSqlOptionsResultInterface extends ICreateSQLiteContextError {
+export interface executeSqlOptionsResultInterface {
   /**
    * 返回的错误信息
    */
   errMsg: string,
   /**
    * 返回的数据
-   */
-  data: boolean[],
+  */ 
+  data: boolean[],  
+}
+//export type executeSqlOptionsResult = executeSqlOptionsResultInterface
+export type executeSqlOptionsResult = {
+	errMsg: string,
+	data: boolean[],
 }
-export type executeSqlOptionsResult = executeSqlOptionsResultInterface
 
 /**
  * 执行查询操作的SQL语句的相关配置
@@ -109,17 +113,23 @@ export type selectSqlOptionsCompleteCallback = (res: selectSqlOptionsResult) =>
  * @param errMsg 返回的错误信息
  * @param data 返回的数据
  */
-export interface selectSqlOptionsResultInterface extends ICreateSQLiteContextError {
+export interface selectSqlOptionsResultInterface {
   /**
    * 返回的错误信息
    */
-  errMsg: string,
+  errMsg: string, 
   /**
    * 返回的数据
-   */
-  data: string[],
+  */ 
+  data: string[],  
 }
-export type selectSqlOptionsResult = selectSqlOptionsResultInterface
+//export type selectSqlOptionsResult = selectSqlOptionsResultInterface
+
+export type selectSqlOptionsResult = {
+	errMsg: string,
+	data: UTSJSONObject[],
+}
+
 
 /**
  * uni.createSQLiteContext失败回调参数
@@ -194,10 +204,12 @@ export type transactionCompleteCallback = (res: transactionResult) => void
 /**
  * 事务执行的返回结果
  */
-export interface transactionResultInterface extends ICreateSQLiteContextError {
+export interface transactionResultInterface {
   /**
    * 返回的错误信息
-   */
-  errMsg: string,
+  */ 
+  errMsg: string, 
 }
-export type transactionResult = transactionResultInterface
+export type transactionResult = {
+  errMsg: string, 
+}

+ 1 - 1
uni_modules/uni-sqlContext/utssdk/unierror.uts

@@ -52,6 +52,6 @@ export class createSQLiteContextFailImpl extends UniError implements ICreateSQLi
     super()
     this.errSubject = UniErrorSubject
     this.errCode = errCode
-    this.errMsg = UniErrors[errCode] ?? ''
+    this.errMsg = UniErrors[errCode] ?? ''	
   }
 }

+ 217 - 324
utils/sqlite.uts

@@ -1,184 +1,15 @@
-//import plus from '@dcloudio/uni-app-plus'
+import {createSQLiteContext} from '@/uni_modules/uni-sqlContext'
+import {selectSqlOptions,executeSqlOptions, executeSqlOptionsResult,selectSqlOptionsResult,transactionResult, ICreateSQLiteContextError } from '@/uni_modules/uni-sqlContext/utssdk/interface.uts'
+
+
 
 // 数据库名称
-const dbName = 'qt_app_800'
+const dbName = 'QT800'
 
 // 数据库地址,推荐以下划线为开头   _doc/xxx.db
 // 如果路径不为_downloads/xxx.db,在手机中会找不到文件夹(强烈建议:不要修改路径)
-const dbPath = '/db/qt_app_800.db'
-
-const sqlite = uni.createSQLiteContext({
-  name: dbPath,
-});
-
-/**
- * 数据库地址
- * @type {String} 推荐以下划线为开头   _doc/xxx.db
- * @description 开发环境中数据库所在地址:文件管理/Android/data/io.dcloud.HBuilder/downloads/salary.db
- * @description 打包安装后数据库所在地址:文件管理/Android/data/uni.UNI4312312(以UNI开头接数字)/downloads/salary.db
- */
-
-
-
-// 判断数据库是否打开(箭头函数)
-const isOpen = () => {
-  // 数据库打开了就返回 true,否则返回 false  
-  var open = sqlite.isOpenDatabase({
-    name: dbName, // 数据库名称
-    path: dbPath, // 数据库地址
-  })
-  return open
-}
-
-// 创建数据库 或 有该数据库就打开(普通函数)
-const openSqlite = () => {
-  return new Promise((resolve, reject) => {
-    // 打开数据库
-    sqlite.openDatabase({
-      name: dbName,
-      path: dbPath,
-      success(e) {
-        resolve(e) // 成功回调
-      },
-      fail(e) {
-        reject(e) // 失败回调
-      },
-    })
-  })
-}
-
-// 关闭数据库(箭头函数)
-const closeSqlite = () => {
-  return new Promise((resolve, reject) => {
-    sqlite.closeDatabase({
-      name: dbName,
-      success(e) {
-        resolve(e)
-      },
-      fail(e) {
-        reject(e)
-      },
-    })
-  })
-}
-
-// 普通函数
-// 数据库建表 sql:'CREATE TABLE IF NOT EXISTS dbTable("id" varchar(50),"name" TEXT)
-// 创建 CREATE TABLE IF NOT EXISTS 、 dbTable 是表名,不能用数字开头、括号里是表格的表头
-// @param {Object} dbTable:表名
-// @param {Object} data : 表结构
-const createTable = function (dbTable: string, data: string) {
-  return new Promise((resolve, reject) => {
-    // executeSql: 执行增删改等操作的SQL语句
-    sqlite.executeSql({
-      name: dbName,
-      sql: `CREATE TABLE IF NOT EXISTS ${dbTable}(${data})`,
-      success(e) {
-        resolve(e)
-      },
-      fail(e) {
-        reject(e)
-      },
-    })
-  })
-}
-
-// 数据库删表 sql:'DROP TABLE dbTable'(箭头函数)
-// @param {Object} dbTable:表名
-const dropTable = (dbTable: string) => {
-  return new Promise((resolve, reject) => {
-    sqlite.executeSql({
-      name: dbName,
-      sql: `DROP TABLE ${dbTable}`,
-      success(e) {
-        resolve(e)
-      },
-      fail(e) {
-        reject(e)
-      },
-    })
-  })
-}
-
-// 普通函数
-// 向表格里添加数据 sql:'INSERT INTO dbTable VALUES('x','x','x')'   对应新增
-// 或者 sql:'INSERT INTO dbTable ('x','x','x') VALUES('x','x','x')'   具体新增
-// 插入 INSERT INTO  、 dbTable 是表名、根据表头列名插入列值
-// @param {Object} dbTable:表名
-// @param {Object} data : 插入表中的值结构
-// @param {Object} condition : 插入表中对应的列的属性名称结构
-const insertTableData = function (dbTable: string, data: string, condition?: string) {
-  // 判断有没有传参
-  if (dbTable !== undefined && data !== undefined) {
-    // 判断传的参是否有值
-    var bol = JSON.stringify(data) == '{}'
-    if (!bol) {
-      if (condition == undefined) {
-        var sql = `INSERT INTO ${dbTable} VALUES (${data})`
-      } else {
-        var sql = `INSERT INTO ${dbTable} (${condition}) VALUES(${data})`
-      }
-      console.log(sql)
-      // console.log(sql);
-      return new Promise((resolve, reject) => {
-        // 表格添加数据
-        sqlite.executeSql({
-          name: dbName,
-          sql: sql,
-          success(e) {
-            resolve(e)
-          },
-          fail(e) {
-            reject(e)
-          },
-        })
-      })
-    } else {
-      return new Promise((resolve, reject) => {
-        reject('错误添加')
-      })
-    }
-  } else {
-    return new Promise((resolve, reject) => {
-      reject('错误添加')
-    })
-  }
-}
+const dbPath = '/www/static/db/qt_app_800'
 
-// 箭头函数
-// 根据条件向表格里添加数据  有数据更新、无数据插入
-// (建表时需要设置主键) 例如 --- "roomid" varchar(50) PRIMARY KEY
-// @param {Object} dbTable:表名
-// @param {Object} data : 插入表中的值结构
-// @param {Object} condition : 插入表中对应的列的属性名称结构
-const insertOrReplaceData = (dbTable: string, data: string, condition?: string) => {
-  // 判断有没有传参
-  if (dbTable !== undefined && data !== undefined) {
-    if (condition == undefined) {
-      var sql = `INSERT OR REPLACE INTO ${dbTable} VALUES(${data})`
-    } else {
-      var sql = `INSERT OR REPLACE INTO ${dbTable} (${condition}) VALUES(${data})`
-    }
-    // console.log(sql);
-    return new Promise((resolve, reject) => {
-      // 表格添加数据
-      sqlite.executeSql({
-        name: dbName,
-        sql: sql,
-        success(e) {
-          resolve(e)
-        },
-        fail(e) {
-          reject(e)
-        },
-      })
-    })
-  } else {
-    return new Promise((resolve, reject) => {
-      reject('错误添加')
-    })
-  }
-}
 
 // 普通函数
 // 查询获取数据库里的数据 sql:'SELECT * FROM dbTable WHERE lname = 'lvalue''
@@ -186,176 +17,238 @@ const insertOrReplaceData = (dbTable: string, data: string, condition?: string)
 // @param {Object} dbTable:表名
 // @param {Object} lname:列名
 // @param {Object} lvalue:列中的属性值
-const selectTableData = function (
+export function selectTableData (
   dbTable: string,
   lname?: string,
   lvalue?: string,
   cc?: string,
   dd?: string,
-) {
-  if (dbTable !== undefined) {
+):Promise<UTSJSONObject>
+{
+  if (dbTable !== null) {
     // 第一个是表单名称,后两个参数是列表名,用来检索
-    if (lname !== undefined && cc !== undefined) {
+	var sql = '';
+    if (lname !== null && cc !== null) {
       // 两个检索条件
-      var sql = `SELECT * FROM ${dbTable} WHERE ${lname} = '${lvalue}' AND ${cc} = '${dd}'`
+      sql = `SELECT * FROM ${dbTable} WHERE ${lname} = '${lvalue}' AND ${cc} = '${dd}'`
     }
-    if (lname !== undefined && cc == undefined) {
+    if (lname !== null && cc == null) {
       // 一个检索条件
-      var sql = `SELECT * FROM ${dbTable} WHERE ${lname} = '${lvalue}'`
+       sql = `SELECT * FROM ${dbTable} WHERE ${lname} = '${lvalue}'`
       // console.log(sql);
     }
-    if (lname == undefined) {
-      var sql = `SELECT * FROM ${dbTable}`
+    if (lname == null) {
+       sql = `SELECT * FROM ${dbTable}`
     }
-    return new Promise((resolve, reject) => {
-      // 表格查询数据  执行查询的SQL语句
-      sqlite.selectSql({
-        name: dbName,
-        sql: sql,
-        success(e) {
-          resolve(e)
-        },
-        fail(e) {
-          reject(e)
-        },
-      })
-    })
+	const sqlite = createSQLiteContext(dbName);
+	
+	return new Promise<UTSJSONObject>((resolve, reject) => {
+	  const selectSqlOptions ={		
+		  sql: sql,
+		  success: (e: selectSqlOptionsResult) => {
+		    console.log(e)
+			
+		  },
+		  fail: (e: selectSqlOptionsResult) => {
+		    console.error(e)
+		  }		
+	  } as selectSqlOptions
+	
+	  const info = sqlite.selectSql(selectSqlOptions) as selectSqlOptionsResult
+	  
+	  console.log(info)	
+	  const ret = {
+		  errMsg: info?.errMsg ?? '',
+		  data: info?.data ?? ['']
+	  } as UTSJSONObject
+	  resolve(ret)
+	});	
+		
   } else {
-    return new Promise((resolve, reject) => {
-      reject('错误查询')
+    return new Promise<UTSJSONObject>((resolve, reject) => {
+		const ret = {
+			  errMsg: '错误查询',
+			  data : ['表名不存在']
+		} as UTSJSONObject
+        resolve(ret);		
     })
   }
-}
-
-// 箭头函数
-// 删除表里的数据 sql:'DELETE FROM dbTable WHERE lname = 'lvalue''
-// 删除 DELETE FROM 、 dbTable 是表名、 WHERE 查找条件 lname,lvalue 是查询条件的列名和列值
-// @param {Object} dbTable:表名
-// @param {Object} lname:列名
-// @param {Object} lvalue:列中的属性值
-const deleteTableData = (
-  dbTable: string,
-  lname?: string,
-  lvalue?: string,
-  ww?: string,
-  ee?: string,
-) => {
-  if (dbTable !== undefined) {
-    if (lname == undefined) {
-      var sql = `DELETE FROM ${dbTable}`
+ } 
+  // 箭头函数
+  // 根据条件向表格里添加数据  有数据更新、无数据插入
+  // (建表时需要设置主键) 例如 --- "roomid" varchar(50) PRIMARY KEY
+  // @param {Object} dbTable:表名
+  // @param {Object} data : 插入表中的值结构
+  // @param {Object} condition : 插入表中对应的列的属性名称结构
+  export function insertOrReplaceData(dbTable: string, data: string, condition?: string): Promise<UTSJSONObject> {
+    // 判断有没有传参
+    if (dbTable !== null && data !== null) {
+      if (condition == null) {
+        var sql = `INSERT OR REPLACE INTO ${dbTable} VALUES(${data})`
+      } else {
+        var sql = `INSERT OR REPLACE INTO ${dbTable} (${condition}) VALUES(${data})`
+      }
+	  const sqlite = createSQLiteContext(dbName);
+      // console.log(sql);
+      return new Promise((resolve, reject) => {		
+		const executeSqlOptions ={
+				  sql: sql,
+				  success: (e: executeSqlOptionsResult) => {
+				    console.log(e)
+					
+				  },
+				  fail: (e: executeSqlOptionsResult) => {
+				    console.error(e)
+				  }		
+		} as executeSqlOptions
+		
+		const info = sqlite.executeSql(executeSqlOptions) as executeSqlOptionsResult
+		console.log(info)
+		const ret = {
+			errMsg: info?.errMsg ?? '',
+			data: info?.data ?? ['']
+		} as UTSJSONObject
+		resolve(ret)
+      })
     } else {
-      if (ww !== undefined) {
-        // 两个检索条件
-        var sql = `DELETE FROM ${dbTable} WHERE ${lname} = '${lvalue}' AND ${ww} = '${ee}'`
+      return new Promise((resolve, reject) => {
+        reject('错误添加')
+      })
+    }
+  }
+  
+  // 普通函数
+  // 向表格里添加数据 sql:'INSERT INTO dbTable VALUES('x','x','x')'   对应新增
+  // 或者 sql:'INSERT INTO dbTable ('x','x','x') VALUES('x','x','x')'   具体新增
+  // 插入 INSERT INTO  、 dbTable 是表名、根据表头列名插入列值
+  // @param {Object} dbTable:表名
+  // @param {Object} data : 插入表中的值结构
+  // @param {Object} condition : 插入表中对应的列的属性名称结构
+  export function insertTableData(dbTable: string, data: string, condition?: string) : Promise<UTSJSONObject>{
+    // 判断有没有传参
+    if (dbTable !== null && data !== null) {
+      // 判断传的参是否有值
+      var bol = JSON.stringify(data) == '{}'
+      if (!bol) {
+		var sql = ''  
+        if (condition == null) {
+          sql = `INSERT INTO ${dbTable} VALUES (${data})`
+        } else {
+          sql = `INSERT INTO ${dbTable} (${condition}) VALUES(${data})`
+        }
+        console.log(sql)
+        const sqlite = createSQLiteContext(dbName);
+        return new Promise((resolve, reject) => {
+           const executeSqlOptions ={
+           		  sql: sql,
+           		  success: (e: executeSqlOptionsResult) => {
+           		    console.log(e)
+           			
+           		  },
+           		  fail: (e: executeSqlOptionsResult) => {
+           		    console.error(e)
+           		  }		
+           } as executeSqlOptions
+		   
+		   const info = sqlite.executeSql(executeSqlOptions) as executeSqlOptionsResult
+		   console.log(info)
+		   const ret = {
+		   	errMsg: info?.errMsg ?? '',
+		   	data: info?.data ?? ['']
+		   } as UTSJSONObject
+		   sqlite.close();
+		   resolve(ret)
+        })
       } else {
-        // 一个检索条件
-        var sql = `DELETE FROM ${dbTable} WHERE ${lname} = '${lvalue}'`
+        return new Promise((resolve, reject) => {
+          reject('错误添加')
+        })
       }
+    } else {
+      return new Promise((resolve, reject) => {
+        reject('错误添加')
+      })
+    }
+  }
+  
+  // 普通函数
+  // 修改数据表里的数据 sql:"UPDATE dbTable SET 列名 = '列值',列名 = '列值' WHERE lname = 'lvalue'"
+  // 修改 UPDATE 、 dbTable 是表名, data: 要修改的列名=修改后列值, lname,lvalue 是查询条件的列名和列值
+  // @param {Object} dbTable:表名
+  // @param {Object} data : 修改表中的值结构
+  // @param {Object} lname:列名
+  // @param {Object} lvalue:列中的属性值
+  export function updateTableData(dbTable: string, data: string, lname?: string, lvalue?: string) : Promise<UTSJSONObject> {
+    var sql = ''
+	if (lname == null) {
+      sql = `UPDATE ${dbTable} SET ${data}`
+    } else {
+      sql = `UPDATE ${dbTable} SET ${data} WHERE ${lname} = '${lvalue}'`
     }
+	const sqlite = createSQLiteContext(dbName);
+    // WHERE 前面是要修改的列名、列值,后面是条件的列名、列值
     return new Promise((resolve, reject) => {
-      // 删除表数据
-      sqlite.executeSql({
-        name: dbName,
-        sql: sql,
-        success(e) {
-          resolve(e)
-        },
-        fail(e) {
-          reject(e)
-        },
-      })
+      const executeSqlOptions ={
+      		  sql: sql,
+      		  success: (e: executeSqlOptionsResult) => {
+      		    console.log(e)
+      			
+      		  },
+      		  fail: (e: executeSqlOptionsResult) => {
+      		    console.error(e)
+      		  }		
+      } as executeSqlOptions
+	  
+	  const info = sqlite.executeSql(executeSqlOptions) as executeSqlOptionsResult
+	  console.log(info)
+	  const ret = {
+	  	errMsg: info?.errMsg ?? '',
+	  	data: info?.data ?? ['']
+	  } as UTSJSONObject
+	  sqlite.close();
+	  resolve(ret)
+	  
     })
-  } else {
+  }
+  
+  // 箭头函数
+  // 获取指定数据条数  sql:"SELECT * FROM dbTable ORDER BY 'id' DESC LIMIT 15 OFFSET 'num'"
+  // dbTable 表名, ORDER BY 代表排序默认正序, id 是排序的条件 DESC 代表倒序,从最后一条数据开始拿
+  // LIMIT 15 OFFSET '${num}',这句的意思是跳过 num 条拿 15 条数据, num 为跳过多少条数据是动态值
+  // 例 初始num设为0,就从最后的数据开始拿15条,下次不拿刚获取的数据,所以可以让num为15,这样就能一步一步的拿完所有的数据
+  // @param {Object} dbTable:表名
+  // @param {Object} id:数据id
+  /**
+   * @param {Object} num 例子如下:
+   * select * from boot limit 10 offset 0;
+   * select * from boot limit 10 offset 10;
+   * select * from boot limit 10 offset 20;
+   * select * from boot limit 10 offset 30;
+   * 比如说每页数量为 10 条,然后我们分别获区第1、2、3、4页的数据
+   *
+   */
+  export function pullSQL(dbTable: string, id: string, num: number) : Promise<UTSJSONObject> {
+	var sql = `SELECT * FROM ${dbTable} ORDER BY '${id}' DESC LIMIT 15 OFFSET '${num}'` 
+	const sqlite = createSQLiteContext(dbName); 
     return new Promise((resolve, reject) => {
-      reject('错误删除')
+      const selectSqlOptions ={
+      		  sql: sql,
+      		  success: (e: selectSqlOptionsResult) => {
+      		    console.log(e)
+      			
+      		  },
+      		  fail: (e: selectSqlOptionsResult) => {
+      		    console.error(e)
+      		  }		
+      } as selectSqlOptions
+      	
+      const info = sqlite.selectSql(selectSqlOptions) as selectSqlOptionsResult
+      
+      console.log(info)	
+      const ret = {
+      		  errMsg: info?.errMsg ?? '',
+      		  data: info?.data ?? ['']
+      } as UTSJSONObject
+      resolve(ret)
     })
   }
-}
-
-// 普通函数
-// 修改数据表里的数据 sql:"UPDATE dbTable SET 列名 = '列值',列名 = '列值' WHERE lname = 'lvalue'"
-// 修改 UPDATE 、 dbTable 是表名, data: 要修改的列名=修改后列值, lname,lvalue 是查询条件的列名和列值
-// @param {Object} dbTable:表名
-// @param {Object} data : 修改表中的值结构
-// @param {Object} lname:列名
-// @param {Object} lvalue:列中的属性值
-const updateTableData = function (dbTable: string, data: string, lname?: string, lvalue?: string) {
-  if (lname == undefined) {
-    var sql = `UPDATE ${dbTable} SET ${data}`
-  } else {
-    var sql = `UPDATE ${dbTable} SET ${data} WHERE ${lname} = '${lvalue}'`
-  }
-  // WHERE 前面是要修改的列名、列值,后面是条件的列名、列值
-  return new Promise((resolve, reject) => {
-    // 修改表数据
-    sqlite.executeSql({
-      name: dbName,
-      sql: sql,
-      success(e) {
-        resolve(e)
-      },
-      fail(e) {
-        reject(e)
-      },
-    })
-  })
-}
-
-// 箭头函数
-// 获取指定数据条数  sql:"SELECT * FROM dbTable ORDER BY 'id' DESC LIMIT 15 OFFSET 'num'"
-// dbTable 表名, ORDER BY 代表排序默认正序, id 是排序的条件 DESC 代表倒序,从最后一条数据开始拿
-// LIMIT 15 OFFSET '${num}',这句的意思是跳过 num 条拿 15 条数据, num 为跳过多少条数据是动态值
-// 例 初始num设为0,就从最后的数据开始拿15条,下次不拿刚获取的数据,所以可以让num为15,这样就能一步一步的拿完所有的数据
-// @param {Object} dbTable:表名
-// @param {Object} id:数据id
-/**
- * @param {Object} num 例子如下:
- * select * from boot limit 10 offset 0;
- * select * from boot limit 10 offset 10;
- * select * from boot limit 10 offset 20;
- * select * from boot limit 10 offset 30;
- * 比如说每页数量为 10 条,然后我们分别获区第1、2、3、4页的数据
- *
- */
-const pullSQL = (dbTable: string, id: string, num: number) => {
-  return new Promise((resolve, reject) => {
-    sqlite.selectSql({
-      name: dbName,
-      sql: `SELECT * FROM ${dbTable} ORDER BY '${id}' DESC LIMIT 15 OFFSET '${num}'`,
-
-      success(e) {
-        resolve(e)
-      },
-
-      fail(e) {
-        reject(e)
-      },
-    })
-  })
-}
-
-// 导出方法
-export default {
-  // 查询数据库是否打开
-  isOpen,
-  // 创建/开启数据库
-  openSqlite,
-  // 关闭数据库
-  closeSqlite,
-  // 数据库建表
-  createTable,
-  // 数据库删表
-  dropTable,
-  // 表里新增/插入数据
-  insertTableData,
-  // 根据条件向表里插入数据、更新或覆盖
-  insertOrReplaceData,
-  // 表里查询数据
-  selectTableData,
-  // 表里删除数据
-  deleteTableData,
-  // 表里修改数据
-  updateTableData,
-  // 倒叙查询数据
-  pullSQL,
-}

+ 3 - 3
utils/storage.uts

@@ -25,6 +25,9 @@ const storage = {
 	}else{
 		return null
 	}
+  },  
+  cleanAll: function():void {	  
+    uni.removeStorageSync(storageKey)
   },
   remove: function(key:string):void {
     let storageData:UTSJSONObject|null = uni.getStorageSync(storageKey) as UTSJSONObject|null
@@ -35,9 +38,6 @@ const storage = {
 		uni.setStorageSync(storageKey, storageData)
 	}
     
-  },
-  clean: function():void {
-    uni.removeStorageSync(storageKey)
   }
 }