From 0eef5e57cd28c0b384f295df724599da468d7fe2 Mon Sep 17 00:00:00 2001 From: whycq <you@example.com> Date: 星期日, 30 七月 2023 14:22:30 +0800 Subject: [PATCH] # --- uni.promisify.adaptor.js | 10 pages/login/login.vue | 476 +++++++++++++++++++++++++++++++++++++++ static/logo.png | 0 index.html | 20 + pages.json | 17 + main.js | 22 + pages/login/logOut.vue | 21 + App.vue | 17 + pages/index/index.vue | 52 ++++ uni.scss | 76 ++++++ 10 files changed, 711 insertions(+), 0 deletions(-) diff --git a/App.vue b/App.vue new file mode 100644 index 0000000..8c2b732 --- /dev/null +++ b/App.vue @@ -0,0 +1,17 @@ +<script> + export default { + onLaunch: function() { + console.log('App Launch') + }, + onShow: function() { + console.log('App Show') + }, + onHide: function() { + console.log('App Hide') + } + } +</script> + +<style> + /*姣忎釜椤甸潰鍏叡css */ +</style> diff --git a/index.html b/index.html new file mode 100644 index 0000000..c3ff205 --- /dev/null +++ b/index.html @@ -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> diff --git a/main.js b/main.js new file mode 100644 index 0000000..c1caf36 --- /dev/null +++ b/main.js @@ -0,0 +1,22 @@ +import App from './App' + +// #ifndef VUE3 +import Vue from 'vue' +import './uni.promisify.adaptor' +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 \ No newline at end of file diff --git a/pages.json b/pages.json new file mode 100644 index 0000000..869105d --- /dev/null +++ b/pages.json @@ -0,0 +1,17 @@ +{ + "pages": [ //pages鏁扮粍涓涓�椤硅〃绀哄簲鐢ㄥ惎鍔ㄩ〉锛屽弬鑰冿細https://uniapp.dcloud.io/collocation/pages + { + "path": "pages/index/index", + "style": { + "navigationBarTitleText": "uni-app" + } + } + ], + "globalStyle": { + "navigationBarTextStyle": "black", + "navigationBarTitleText": "uni-app", + "navigationBarBackgroundColor": "#F8F8F8", + "backgroundColor": "#F8F8F8" + }, + "uniIdRouter": {} +} diff --git a/pages/index/index.vue b/pages/index/index.vue new file mode 100644 index 0000000..ec0ec26 --- /dev/null +++ b/pages/index/index.vue @@ -0,0 +1,52 @@ +<template> + <view class="content"> + <image class="logo" src="/static/logo.png"></image> + <view class="text-area"> + <text class="title">{{title}}</text> + </view> + </view> +</template> + +<script> + export default { + data() { + return { + title: 'Hello' + } + }, + onLoad() { + + }, + methods: { + + } + } +</script> + +<style> + .content { + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + } + + .logo { + height: 200rpx; + width: 200rpx; + margin-top: 200rpx; + margin-left: auto; + margin-right: auto; + margin-bottom: 50rpx; + } + + .text-area { + display: flex; + justify-content: center; + } + + .title { + font-size: 36rpx; + color: #8f8f94; + } +</style> diff --git a/pages/login/logOut.vue b/pages/login/logOut.vue new file mode 100644 index 0000000..b2dc7e6 --- /dev/null +++ b/pages/login/logOut.vue @@ -0,0 +1,21 @@ +<template> + <view></view> +</template> +<script> + export default { + mounted() { + uni.showToast({ + title: '娉ㄩ攢鎴愬姛', + duration: 1000 + }) + setTimeout(() => { + uni.removeStorageSync('token'); + uni.reLaunch({ + url:"/pages/login/login" + }); + }, 1000); + }, + + } + +</script> \ No newline at end of file diff --git a/pages/login/login.vue b/pages/login/login.vue new file mode 100644 index 0000000..f552833 --- /dev/null +++ b/pages/login/login.vue @@ -0,0 +1,476 @@ +<template> + <view> + <!-- 璁剧疆 --> + <view class="settings"> + <view class="settings-btn"> + <uni-icons type="gear" size="30" color="#707070" @click="settings"></uni-icons> + </view> + </view> + <!-- logo --> + <view class="logo"> + <view class="logo-box"> + <image src="../../static/img/logo.png" mode="aspectFit"></image> + </view> + </view> + <view class="content"> + <!-- 璐﹀彿 --> + <view class="box shadow-warp"> + <view class="box-icon"> + <uni-icons type="person" size="20" color="#707070"></uni-icons> + </view> + <view class="box-text">璐﹀彿:</view> + <view class="box-input"> + <input type="text" placeholder="璇疯緭鍏ヨ处鍙�" v-model="user.userName" + placeholder-style="font-size:14px;color:#ccc;"> + </view> + <view class="box-show"></view> + </view> + <!-- 瀵嗙爜 --> + <view class="box shadow-warp"> + <view class="box-icon"> + <uni-icons type="locked" size="20" color="#707070"></uni-icons> + </view> + <view class="box-text">瀵嗙爜:</view> + <view class="box-input"> + <input :password="!showPassword" placeholder="璇疯緭鍏ュ瘑鐮�" v-model="user.password" + placeholder-style="font-size:14px;color:#ccc;" > + </view> + <view class="box-show"> + <uni-icons type="eye-filled" size="20" color="#707070" v-if="!showPassword" @click="changePassword"></uni-icons> + <uni-icons type="eye" size="20" color="#707070" v-if="showPassword" @click="changePassword"></uni-icons> + </view> + </view> + <!-- 璁颁綇瀵嗙爜 --> + <view class="check"> + <view class="check-left"> + <view>璁颁綇瀵嗙爜</view> + </view> + <view class="check-right"> + <switch :checked='remberPassword' color="#FFCC33" style="zoom:.5" @change="remberChange"/> + </view> + </view> + </view> + <!-- 鐧诲綍鎸夐挳 --> + <view class="submit"> + <view class="" style="width: 400rpx;"> + <button type="primary" @click="onLogin()" :loading="load.loading">{{load.btnText}}</button> + </view> + + </view> + + <!-- 璁剧疆寮圭獥鍖哄煙 --> + <view> + <uni-popup ref="inputDialog" type="dialog"> + <view class="popup"> + <!-- 鏍囬 --> + <view class="title">閰嶇疆</view> + <view class="popup-item"> + <view class="popup-item-left">IP:</view> + <view class="popup-item-right"><input type="text" v-model="url.ip"></view> + </view> + <view class="popup-item"> + <view class="popup-item-left">绔彛:</view> + <view class="popup-item-right"><input type="text" v-model="url.port"></view> + </view> + <view class="popup-item"> + <view class="popup-item-left">椤圭洰:</view> + <view class="popup-item-right"><input type="text" v-model="url.project"></view> + </view> + <view class="btn"> + <view class="btn-left" @click="close">鍙栨秷</view> + <view class="btn-right" @click="settingConfirm">纭</view> + </view> + </view> + </uni-popup> + </view> + + <view> + <!-- 鎻愮ず绐楃ず渚� --> + <uni-popup ref="upVersion" type="dialog"> + <uni-popup-dialog :type="msgType" title="閫氱煡" :content="dialogContent" @confirm="dialogConfirm" + @close="dialogClose"></uni-popup-dialog> + </uni-popup> + </view> + + <!-- 鐗堟湰鍙� --> + <!-- #ifdef APP-PLUS --> + <view class="version"> + 褰撳墠鐗堟湰:{{version}} + </view> + <!-- #endif --> + </view> +</template> + +<script> + import md5 from '../../static/js/md5.js' + export default { + data() { + return { + version: '', + showPassword: false, + value: '', + remberPassword: true, + url: { + ip: '', + port: '', + project: '' + }, + baseUrl: '', + user: { + userName: '', + password: '', + }, + load: { + loading: false, + btnText: '鐧诲綍' + }, + msgType: 'success', + filename: '', + dialogContent: '' + } + }, + onLoad() { + this.user = uni.getStorageSync('user') + this.url = uni.getStorageSync('url') + this.baseUrl = uni.getStorageSync('baseUrl') + if (!this.user) { + this.user = {userName: '',password: ''} + } + if (!this.url) { + this.url = {ip: '',port: '',project: ''} + } + // this.getVersion() + }, + onShow () { + // 鎵嬫満绔増鏈彿 + // // #ifdef APP-PLUS + // var that = this + // plus.runtime.getProperty(plus.runtime.appid, function(wgtinfo) { + // that.version = wgtinfo.version + // }); + // // #endif + this.getVersion() + }, + methods: { + // 鏄剧ず/闅愯棌瀵嗙爜 + changePassword() { + this.showPassword = !this.showPassword; + }, + remberChange(e) { + this.remberPassword = !this.remberPassword + }, + // 璁剧疆绐楀彛寮�鍚寜閽� + settings() { + this.$refs.inputDialog.open() + }, + // 璁剧疆绐楀彛纭淇敼鎸夐挳 + dialogInputConfirm() { + this.$refs.inputDialog.close() + }, + // 璁剧疆绐楀彛鍏抽棴鎸夐挳 + close() { + this.$refs.inputDialog.close() + }, + // 淇濆瓨ip + settingConfirm() { + this.baseUrl = "http://" + this.url.ip + ':' + this.url.port + '/' + this.url.project + uni.setStorageSync('baseUrl', this.baseUrl); + uni.setStorageSync('url', this.url); + this.$refs.inputDialog.close() + }, + onLogin() { + let that = this + uni.request({ + url: that.baseUrl + '/login.action', + fail(result) { + uni.showToast({ + icon: 'error', + title: '璇锋眰澶辫触' + }) + }, + data: { + username: that.user.userName, + password: md5.hex_md5(that.user.password) + }, + header: { + "content-type": "application/json" + }, + success(result) { + if (result.statusCode === 404) { + uni.showToast({ + title: '鐧诲綍澶辫触', + icon: "error" + }) + return + } + let res = result.data + if (res.code === 200) { + that.load.loading = true; + that.load.btnText = '鐧诲綍涓�'; + uni.setStorageSync('token', res.data.token); + if(that.remberPassword){ + uni.setStorageSync('user', that.user); + }else{ + uni.removeStorageSync('user'); + } + setTimeout(() => { + uni.showToast({ + title: '鐧诲綍鎴愬姛' + }) + setTimeout(() => { + uni.reLaunch({ + url: '../home/home' + }); + }, 300) + }, 700) + } else { + uni.showToast({ + title: res.msg + }) + } + }, + }) + }, + //妫�娴嬪綋鍓嶅钩鍙帮紝濡傛灉鏄畨鍗撳垯鍚姩瀹夊崜鏇存柊 + getVersion() { + let that = this; + uni.getSystemInfo({ + success: (res) => { + if (res.platform == "android") { + that.AndroidCheckUpdate(); + } + } + }) + }, + // 鑾峰彇褰撳墠鐗堟湰鍙� + AndroidCheckUpdate() { + let that = this; + plus.runtime.getProperty(plus.runtime.appid, (wgtinfo) => { + that.version = wgtinfo.version //瀹㈡埛绔増鏈彿 + }) + setTimeout(()=>{ + that.getUpdateVersion() + },100) + }, + // 鏍¢獙鐗堟湰 + getUpdateVersion() { + let that = this + let type = 0 + if (that.baseUrl == 'http://undefined:undefined/undefined') { + return + } + + let url = that.baseUrl + '/appVersion/checkUpdate/' + that.version + '/' + type + uni.request({ + url: url, + method: 'GET', + success(res) { + var res = res.data + if (res.data) { + that.filename = res.data.path + that.dialogContent = '鍙戠幇鏂扮増鏈�:' + res.data.version + ', 鏄惁绔嬪嵆鏇存柊' + that.$refs.upVersion.open() + } + + } + }) + }, + dialogConfirm() { + this.$refs.upVersion.close() + this.downWgt() + }, + dialogClose() { + this.$refs.upVersion.close() + }, + downWgt() { + let that = this; + const downloadUrl = that.baseUrl + "/appVersion/downloadApp/" + that.filename + uni.showLoading({ + title: '鏇存柊涓�︹��' + }) + const downloadTask = uni.downloadFile({ //鎵ц涓嬭浇 + url: downloadUrl, //涓嬭浇鍦板潃 + timeout: 1000 * 30, //30绉掕秴鏃舵椂闂� + success: downloadResult => { //涓嬭浇鎴愬姛 + console.log(downloadResult); + that.showdownLine = false + uni.hideLoading(); + if (downloadResult.statusCode == 200) { + uni.showModal({ + title: '', + content: '鏇存柊鎴愬姛锛岀‘瀹氱幇鍦ㄩ噸鍚悧锛�', + confirmText: '閲嶅惎', + confirmColor: '#EE8F57', + success: function(res) { + if (res.confirm == true) { + plus.runtime.install( //瀹夎 + downloadResult.tempFilePath, { + force: true + }, + function(res) { + utils.showToast('鏇存柊鎴愬姛锛岄噸鍚腑'); + plus.runtime.restart(); + } + ); + } + } + }); + } else { + uni.hideLoading(); + that.showdownLine = false + uni.showToast({ + title:'璇峰厛涓婁紶瀹夎鍖�', + icon: 'error' + }) + } + }, + fail: err => { + uni.hideLoading(); + that.showdownLine = false + that.$u.toast(downloadResult.errMsg) + }, + complete: com => { + + console.log(com) + } + }); + + // 涓嬭浇杩涘害 + downloadTask.onProgressUpdate(res => { + that.downloadNum = res.progress + console.log('涓嬭浇杩涘害' + that.downloadNum); + }); + }, + + } + } +</script> +<style> + @import url('../../static/css/wms.css/wms.css'); + /* 璁剧疆鍖哄煙 */ + .settings { + min-height: 100rpx; + } + .settings-btn { + float: right; + margin-right: 10rpx; + } + .logo { + height: 25%; + width: 100%; + display: flex; + justify-content: center; + } + .logo-box { + margin: auto 0; + } + image { + height: 300rpx; + } + /* 杈撳叆妗嗗尯鍩� */ + .content { + min-height: 250rpx; + /* background-color: coral; */ + width: 100%; + display: flex; + flex-direction: column; + align-items: center; + color: #606266; + } + .box { + width: 80%; + height: 100rpx; + margin-top: 30rpx; + background-color: white; + display: flex; + font-size: 14px; + align-items: center; + + } + .box-icon { + width: 80rpx; + text-align: center; + } + .box-text { + width: 100rpx; + text-align: center; + } + .box-show { + margin-left: auto; + /* margin-right: 10rpx; */ + width: 60rpx; + text-align: center; + } + input { + padding-left: 10rpx; + font-size: 14px; + color: #303133; + } + + .check { + width: 78%; + display: flex; + font-size: 12px; + color: #606266; + margin-top: 10rpx; + } + .check-right { + margin-left: auto; + } + .submit { + display: flex; + justify-content: center; + position: fixed; + width: 100%; + bottom: 100rpx; + } + .version { + position: fixed; + width: 100%; + bottom: 0; + text-align: center; + font-size: 12px; + color: #909399; + } + + + + + + + + + + + + + + + + + /* ------ */ + + .shadow-warp { + position: relative; + box-shadow: 0 0 10upx rgba(0, 0, 0, 0.1); + } + + .shadow-warp:before, + .shadow-warp:after { + position: absolute; + content: ""; + top: 20upx; + bottom: 30upx; + left: 20upx; + width: 50%; + box-shadow: 0 30upx 20upx rgba(0, 0, 0, 0.2); + transform: rotate(-3deg); + z-index: -1; + } + + .shadow-warp:after { + right: 20upx; + left: auto; + transform: rotate(3deg); + } +</style> \ No newline at end of file diff --git a/static/logo.png b/static/logo.png new file mode 100644 index 0000000..b5771e2 --- /dev/null +++ b/static/logo.png Binary files differ diff --git a/uni.promisify.adaptor.js b/uni.promisify.adaptor.js new file mode 100644 index 0000000..47fbce1 --- /dev/null +++ b/uni.promisify.adaptor.js @@ -0,0 +1,10 @@ +uni.addInterceptor({ + returnValue (res) { + if (!(!!res && (typeof res === "object" || typeof res === "function") && typeof res.then === "function")) { + return res; + } + return new Promise((resolve, reject) => { + res.then((res) => res[0] ? reject(res[0]) : resolve(res[1])); + }); + }, +}); \ No newline at end of file diff --git a/uni.scss b/uni.scss new file mode 100644 index 0000000..a05adb4 --- /dev/null +++ b/uni.scss @@ -0,0 +1,76 @@ +/** + * 杩欓噷鏄痷ni-app鍐呯疆鐨勫父鐢ㄦ牱寮忓彉閲� + * + * uni-app 瀹樻柟鎵╁睍鎻掍欢鍙婃彃浠跺競鍦猴紙https://ext.dcloud.net.cn锛変笂寰堝涓夋柟鎻掍欢鍧囦娇鐢ㄤ簡杩欎簺鏍峰紡鍙橀噺 + * 濡傛灉浣犳槸鎻掍欢寮�鍙戣�咃紝寤鸿浣犱娇鐢╯css棰勫鐞嗭紝骞跺湪鎻掍欢浠g爜涓洿鎺ヤ娇鐢ㄨ繖浜涘彉閲忥紙鏃犻渶 import 杩欎釜鏂囦欢锛夛紝鏂逛究鐢ㄦ埛閫氳繃鎼Н鏈ㄧ殑鏂瑰紡寮�鍙戞暣浣撻鏍间竴鑷寸殑App + * + */ + +/** + * 濡傛灉浣犳槸App寮�鍙戣�咃紙鎻掍欢浣跨敤鑰咃級锛屼綘鍙互閫氳繃淇敼杩欎簺鍙橀噺鏉ュ畾鍒惰嚜宸辩殑鎻掍欢涓婚锛屽疄鐜拌嚜瀹氫箟涓婚鍔熻兘 + * + * 濡傛灉浣犵殑椤圭洰鍚屾牱浣跨敤浜唖css棰勫鐞嗭紝浣犱篃鍙互鐩存帴鍦ㄤ綘鐨� scss 浠g爜涓娇鐢ㄥ涓嬪彉閲忥紝鍚屾椂鏃犻渶 import 杩欎釜鏂囦欢 + */ + +/* 棰滆壊鍙橀噺 */ + +/* 琛屼负鐩稿叧棰滆壊 */ +$uni-color-primary: #007aff; +$uni-color-success: #4cd964; +$uni-color-warning: #f0ad4e; +$uni-color-error: #dd524d; + +/* 鏂囧瓧鍩烘湰棰滆壊 */ +$uni-text-color:#333;//鍩烘湰鑹� +$uni-text-color-inverse:#fff;//鍙嶈壊 +$uni-text-color-grey:#999;//杈呭姪鐏拌壊锛屽鍔犺浇鏇村鐨勬彁绀轰俊鎭� +$uni-text-color-placeholder: #808080; +$uni-text-color-disable:#c0c0c0; + +/* 鑳屾櫙棰滆壊 */ +$uni-bg-color:#ffffff; +$uni-bg-color-grey:#f8f8f8; +$uni-bg-color-hover:#f1f1f1;//鐐瑰嚮鐘舵�侀鑹� +$uni-bg-color-mask:rgba(0, 0, 0, 0.4);//閬僵棰滆壊 + +/* 杈规棰滆壊 */ +$uni-border-color:#c8c7cc; + +/* 灏哄鍙橀噺 */ + +/* 鏂囧瓧灏哄 */ +$uni-font-size-sm:12px; +$uni-font-size-base:14px; +$uni-font-size-lg:16; + +/* 鍥剧墖灏哄 */ +$uni-img-size-sm:20px; +$uni-img-size-base:26px; +$uni-img-size-lg:40px; + +/* Border Radius */ +$uni-border-radius-sm: 2px; +$uni-border-radius-base: 3px; +$uni-border-radius-lg: 6px; +$uni-border-radius-circle: 50%; + +/* 姘村钩闂磋窛 */ +$uni-spacing-row-sm: 5px; +$uni-spacing-row-base: 10px; +$uni-spacing-row-lg: 15px; + +/* 鍨傜洿闂磋窛 */ +$uni-spacing-col-sm: 4px; +$uni-spacing-col-base: 8px; +$uni-spacing-col-lg: 12px; + +/* 閫忔槑搴� */ +$uni-opacity-disabled: 0.3; // 缁勪欢绂佺敤鎬佺殑閫忔槑搴� + +/* 鏂囩珷鍦烘櫙鐩稿叧 */ +$uni-color-title: #2C405A; // 鏂囩珷鏍囬棰滆壊 +$uni-font-size-title:20px; +$uni-color-subtitle: #555555; // 浜岀骇鏍囬棰滆壊 +$uni-font-size-subtitle:26px; +$uni-color-paragraph: #3F536E; // 鏂囩珷娈佃惤棰滆壊 +$uni-font-size-paragraph:15px; -- Gitblit v1.9.1