diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8c45c81 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +node_modules/ +.project +unpackage/ +.DS_Store \ No newline at end of file diff --git a/.hbuilderx/launch.json b/.hbuilderx/launch.json new file mode 100644 index 0000000..582561b --- /dev/null +++ b/.hbuilderx/launch.json @@ -0,0 +1,16 @@ +{ // launch.json 配置了启动调试时相关设置,configurations下节点名称可为 app-plus/h5/mp-weixin/mp-baidu/mp-alipay/mp-qq/mp-toutiao/mp-360/ + // launchtype项可配置值为local或remote, local代表前端连本地云函数,remote代表前端连云端云函数 + "version": "0.0", + "configurations": [{ + "app-plus" : + { + "launchtype" : "local" + }, + "default" : + { + "launchtype" : "local" + }, + "type" : "uniCloud" + } + ] +} diff --git a/common/style/layout.css b/common/style/layout.css index 434def5..19096a6 100644 --- a/common/style/layout.css +++ b/common/style/layout.css @@ -14,15 +14,53 @@ uni-button:after { /** iconfont */ @font-face { font-family: 'iconfont'; - src: url('@/static/iconfont/iconfont.woff2?t=1665454521636') format('woff2'), - url('@/static/iconfont/iconfont.woff?t=1665454521636') format('woff'), - url('@/static/iconfont/iconfont.ttf?t=1665454521636') format('truetype'); + src: url('@/static/iconfont/iconfont.woff2') format('woff2'), + url('@/static/iconfont/iconfont.woff') format('woff'), + url('@/static/iconfont/iconfont.ttf') format('truetype'); } .iconfont { font-family: "iconfont" !important; - font-size: 50rpx; - color: #000; font-style: normal; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; +} +.delete_icon { + width: 40rpx; + height: 40rpx; + font-size: 40rpx; + line-height: 40rpx; + color: #bbb; +} +.delete_icon::after { + content: '\e632'; +} +.eye_colse_icon { + width: 40rpx; + height: 40rpx; + font-size: 40rpx; + line-height: 40rpx; + color: #bbb; +} +.eye_colse_icon::after { + content: '\e7b2'; +} +.eye_open_icon { + width: 40rpx; + height: 40rpx; + font-size: 40rpx; + line-height: 40rpx; + color: #bbb; +} +.eye_open_icon::after { + content: '\e7b2'; +} +.scan_icon { + width: 80rpx; + height: 80rpx; + font-size: 70rpx; + line-height: 80rpx; + color: #D7592F; +} +.scan_icon::after { + content: '\e607'; } \ No newline at end of file diff --git a/common/style/mixin.styl b/common/style/mixin.styl index f564d40..14140bc 100644 --- a/common/style/mixin.styl +++ b/common/style/mixin.styl @@ -38,7 +38,8 @@ _fj(x=space-between,y=center,r=row,n=nowrap) flex-wrap: n // 背景图片地址和大小 -_bis(url,w,h=auto,x=center,y=center) +_bis(c=transparent,url,w,h=auto,x=center,y=center) + background-color: c background-position: x y background-size: w h background-image: url(url) diff --git a/main.js b/main.js index 365eb09..46ab224 100644 --- a/main.js +++ b/main.js @@ -1,11 +1,13 @@ import App from './App' +import store from '@/vuex/store.js' // #ifndef VUE3 import Vue from 'vue' Vue.config.productionTip = false App.mpType = 'app' const app = new Vue({ - ...App + ...App, + store }) app.$mount() // #endif @@ -15,7 +17,8 @@ import { createSSRApp } from 'vue' export function createApp() { const app = createSSRApp(App) return { - app + app, + store } } // #endif \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..515be96 --- /dev/null +++ b/package.json @@ -0,0 +1,5 @@ +{ + "dependencies": { + "jsencrypt": "^3.3.2" + } +} diff --git a/pages.json b/pages.json index d79623c..125fad2 100644 --- a/pages.json +++ b/pages.json @@ -1,10 +1,16 @@ { "pages": [ //pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages { - "path": "pages/index/index", - "style": { - "navigationBarTitleText": "uni-app" + "path": "pages/login/login", + "style": { + "navigationStyle": "custom" } + }, + { + "path": "pages/home/home", + "style": { + "navigationStyle": "custom" + } } ], "globalStyle": { diff --git a/pages/home/home.vue b/pages/home/home.vue new file mode 100644 index 0000000..52f89e2 --- /dev/null +++ b/pages/home/home.vue @@ -0,0 +1,110 @@ + + + + + diff --git a/pages/index/index.vue b/pages/index/index.vue deleted file mode 100644 index 4ca2b92..0000000 --- a/pages/index/index.vue +++ /dev/null @@ -1,52 +0,0 @@ - - - - - diff --git a/pages/login/login.vue b/pages/login/login.vue new file mode 100644 index 0000000..7a6023f --- /dev/null +++ b/pages/login/login.vue @@ -0,0 +1,215 @@ + + + + + diff --git a/static/.DS_Store b/static/.DS_Store index b312c91..6603367 100644 Binary files a/static/.DS_Store and b/static/.DS_Store differ diff --git a/static/iconfont/iconfont.ttf b/static/iconfont/iconfont.ttf index 4ee5e5b..9cb8c81 100644 Binary files a/static/iconfont/iconfont.ttf and b/static/iconfont/iconfont.ttf differ diff --git a/static/iconfont/iconfont.woff b/static/iconfont/iconfont.woff index ad3eb79..f8f3232 100644 Binary files a/static/iconfont/iconfont.woff and b/static/iconfont/iconfont.woff differ diff --git a/static/iconfont/iconfont.woff2 b/static/iconfont/iconfont.woff2 index b169259..86a8359 100644 Binary files a/static/iconfont/iconfont.woff2 and b/static/iconfont/iconfont.woff2 differ diff --git a/static/images/bg_01.png b/static/images/bg_01.png new file mode 100644 index 0000000..3034463 Binary files /dev/null and b/static/images/bg_01.png differ diff --git a/utils/getData1.js b/utils/getData1.js new file mode 100644 index 0000000..e69de29 diff --git a/utils/getData2.js b/utils/getData2.js new file mode 100644 index 0000000..6cae85c --- /dev/null +++ b/utils/getData2.js @@ -0,0 +1,10 @@ +import request from './request.js' + +// 登录 +export const handLogin = (user, password) => request({ + url:'mobile/auth/login', + data: { + username: user, + password: password + } +}) \ No newline at end of file diff --git a/utils/jsencrypt.js b/utils/jsencrypt.js new file mode 100644 index 0000000..29008d4 --- /dev/null +++ b/utils/jsencrypt.js @@ -0,0 +1,12 @@ +import JSEncrypt from '../node_modules/jsencrypt/bin/jsencrypt.js' +let publicKey = 'MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBANL378k3RiZHWx5AfJqdH9xRNBmD9wGD\n' + + '2iRe41HdTNF8RUhNnHit5NpMNtGL0NPTSSpPjjI1kJfVorRvaQerUgkCAwEAAQ=='; +function RSAencrypt(pas){ + //实例化jsEncrypt对象 + let jse = new JSEncrypt(); + //设置公钥 + jse.setPublicKey(publicKey); + return jse.encrypt(pas); +} + +export {RSAencrypt} \ No newline at end of file diff --git a/utils/request.js b/utils/request.js new file mode 100644 index 0000000..c5b01e0 --- /dev/null +++ b/utils/request.js @@ -0,0 +1,127 @@ +// import qs from 'qs' // 处理data +import store from '@/vuex/store' +const request = (params) => { + let _self = this; + let url = params.url; + let method = params.method || 'POST'; + let data = params.data || {}; + // data.token = "default-access_token" + // if (!params.token) { + // let token = uni.getStorageSync('token'); + // if (!token) { + // uni.navigateTo({ + // url: '/pages/login/login' + // }); + // } else { + // data.token = '179509245-9c91827e0224bdc18d0b118b8be1b5af'; + // } + // } + let token = '' + if (store.getters.saveToken !== '') { + token = store.getters.saveToken + } + let defaultOpot = { + // 'Content-Type': 'application/x-www-form-urlencoded', + 'Terminal-Type': 'innerH5', + 'Content-Type': 'application/json;charset=UTF-8', + } + let header = {} + method = method.toUpperCase() + if (method == 'POST') { + header = { + 'Content-Type': 'application/json;charset=UTF-8', + 'Authorization': token + } + // data = qs.stringify(data) + } + const requestUrl = `${store.getters.baseUrl}/` + url; + uni.showLoading({ + title: '加载中...' + }); + return new Promise((resolve, reject) => { + uni.request({ + url: requestUrl, + method: method, + header: Object.assign({}, defaultOpot, header), + data: data, + dataType: 'json', + }) + .then(res => { // 成功 + if (res.length === 1) { + uni.showModal({ + content: 'request:fail', + showCancel: false + }) + reject('request:fail') + } else if (res[1] && res[1].statusCode === 400) { + uni.showModal({ + content: res[1].data.message, + showCancel: false + }) + reject(res[1].data.message) + } else if (res[1] && res[1].statusCode === 401) { + uni.showModal({ + content: res[1].data.message, + showCancel: false + }) + store.dispatch('delUserInfo') + uni.redirectTo({ + url: '/pages/login/login' + }) + } else if (res[1] && res[1].statusCode === 200) { + let { + data: dataType + } = res[1] + resolve(dataType) + // switch (dataType.code * 1) { // 拦截返回参数 + // case 0: + // resolve(dataType) + // break; + // case 1003: + // uni.showModal({ + // title: '登录已过期', + // content: '很抱歉,登录已过期,请重新登录', + // confirmText: '重新登录', + // success: function(res) { + // if (res.confirm) { + // uni.navigateTo({ + // // 切记这儿需要哈pages.json保持一致;不能有.vue后缀 + // url: '/pages/login/login' + // }); + // } else if (res.cancel) { + // console.log('用户点击取消'); + // } + // } + // }) + // break; + // case -1: + // uni.showModal({ + // title: '请求数据失败', + // content: '获取数据失败!', + // confirmText: '确定', + // showCancel: false, + // success: function(res) { + // if (res.confirm) {} else if (res.cancel) { + // console.log('用户点击取消'); + // } + // } + // }) + // break + // } + }else { + uni.showModal({ + content: res[1].data.message, + showCancel: false + }) + reject(res[1].data.message) + } + }) + .catch(err => { // 错误 + reject(err) + }) + .finally(() => { + uni.hideLoading(); + }) + }) +} +export default request \ No newline at end of file diff --git a/vuex/modules/user.js b/vuex/modules/user.js new file mode 100644 index 0000000..a193d18 --- /dev/null +++ b/vuex/modules/user.js @@ -0,0 +1,77 @@ +import * as types from '../types' + +const baseUrl = process.env.NODE_ENV === 'development' ? 'http://192.168.81.252:8010' : 'http://192.168.81.252:8010' +const imgBaseUrl = process.env.NODE_ENV === 'development' ? 'http://192.168.81.252:8010' : 'http://192.168.81.252:8010' +const state = { + baseUrl: uni.getStorageSync('baseUrl') || baseUrl, + imgBaseUrl: uni.getStorageSync('imgBaseUrl') || imgBaseUrl, + setTime: uni.getStorageSync('setTime') || 5000, + loginName: uni.getStorageSync('loginName') ? uni.getStorageSync('loginName') : '', + userInfo: uni.getStorageSync('userInfo') ? uni.getStorageSync('userInfo') : '', + saveToken: uni.getStorageSync('saveToken') || '' +} +const getters = { + baseUrl: state => state.baseUrl, + imgBaseUrl: state => state.imgBaseUrl, + setTime: state => state.setTime, + loginName: state => state.loginName, + userInfo: state => state.userInfo, + saveToken: state => state.saveToken +} +const actions = { + setConfig ({commit}, res) { + uni.setStorageSync('baseUrl', res.baseUrl) + uni.setStorageSync('imgBaseUrl', res.imgBaseUrl) + // uni.setStorageSync('setTime', res.setTime) + commit(types.COM_CONFIG, res) + }, + saveLoginName({commit}, res) { + uni.setStorageSync('loginName', res) + commit(types.SAVE_LOGIN_NAME, res) + }, + delLoginName({commit}, res) { + uni.clearStorageSync('loginName') + commit(types.DEL_LOGIN_NAME, res) + }, + saveUserInfo({commit}, res) { + uni.setStorageSync('userInfo', res) + commit(types.SAVE_USER_INFO, res) + }, + delUserInfo({commit}, res) { + uni.clearStorageSync('userInfo') + commit(types.DEL_USER_INFO, res) + }, + saveToken({commit}, res) { + uni.setStorageSync('saveToken', res) + commit(types.SAVE_TOKEN, res) + } +} +const mutations = { + [types.COM_CONFIG] (state, res) { + state.baseUrl = res.baseUrl + state.imgBaseUrl = res.imgBaseUrl + // state.setTime = res.setTime + }, + [types.SAVE_LOGIN_NAME] (state, res) { + state.loginName = res + }, + [types.DEL_LOGIN_NAME] (state, res) { + state.loginName = res + }, + [types.SAVE_USER_INFO] (state, res) { + state.userInfo = res + }, + [types.DEL_USER_INFO] (state, res) { + state.userInfo = res + }, + [types.SAVE_TOKEN] (state, res) { + state.saveToken = res + } +} + +export default { + state, + getters, + actions, + mutations +} \ No newline at end of file diff --git a/vuex/store.js b/vuex/store.js new file mode 100644 index 0000000..095161f --- /dev/null +++ b/vuex/store.js @@ -0,0 +1,12 @@ +import Vue from 'vue' +import Vuex from 'vuex' + +import user from './modules/user' + +Vue.use(Vuex) + +export default new Vuex.Store({ + modules: { + user + } +}) diff --git a/vuex/types.js b/vuex/types.js new file mode 100644 index 0000000..96dad99 --- /dev/null +++ b/vuex/types.js @@ -0,0 +1,8 @@ +/** + * user + */ +export const SAVE_LOGIN_NAME = 'SAVE_LOGIN_NAME' +export const DEL_LOGIN_NAME = 'DEL_LOGIN_NAME' +export const COM_CONFIG = 'COM_CONFIG' +export const SAVE_USER_INFO = 'SAVE_USER_INFO' +export const DEL_USER_INFO = 'DEL_USER_INFO' \ No newline at end of file diff --git a/yarn.lock b/yarn.lock new file mode 100644 index 0000000..b8db10e --- /dev/null +++ b/yarn.lock @@ -0,0 +1,8 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + +jsencrypt@^3.3.2: + version "3.3.2" + resolved "https://registry.yarnpkg.com/jsencrypt/-/jsencrypt-3.3.2.tgz#b0f1a2278810c7ba1cb8957af11195354622df7c" + integrity sha512-arQR1R1ESGdAxY7ZheWr12wCaF2yF47v5qpB76TtV64H1pyGudk9Hvw8Y9tb/FiTIaaTRUyaSnm5T/Y53Ghm/A==