From afb8eec8f371c855645fbb3308960981f6f6ad59 Mon Sep 17 00:00:00 2001 From: guoweilong Date: Fri, 27 Oct 2023 17:14:57 +0800 Subject: [PATCH] feat: 增加登录 --- .gitignore | 1 + api/auth.js | 4 ++-- api/infoMarketInformation.js | 2 +- api/organize.js | 24 ++++++++++++------------ common/config.js | 2 +- manifest.json | 6 +++--- pages.json | 7 +++++-- pages/login/mobile.vue | 293 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------------------------------------------------------------------------------------------------------------------------------------- pages/market/index.vue | 80 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------- pages/market/insight.vue | 10 +++++----- static/images/empty/gas-logo.png | Bin 0 -> 54920 bytes static/images/empty/login-out.png | Bin 0 -> 7762 bytes store/mudules/user.js | 13 +++++++------ utils/request/requestInterceptors.js | 2 +- vue.config.js | 32 ++++++++++++++++++++++++-------- 15 files changed, 279 insertions(+), 197 deletions(-) create mode 100644 static/images/empty/gas-logo.png create mode 100644 static/images/empty/login-out.png diff --git a/.gitignore b/.gitignore index 5823d47..45f0edf 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ /.idea/* /.hbuilderx/ /.vscode/ +/unpackage/dist.zip diff --git a/api/auth.js b/api/auth.js index a2b04e8..b6902c7 100644 --- a/api/auth.js +++ b/api/auth.js @@ -2,7 +2,7 @@ const { http } = uni.$u //使用手机 + 密码登录 -export const passwordLogin = data => http.post('/member/auth/login', data) +export const passwordLogin = data => http.post('/auth/login', data) //发送手机验证码 export const sendSmsCode = data => http.post('/member/auth/send-sms-code', data) //使用手机 + 验证码登录 @@ -12,4 +12,4 @@ export const weixinMiniAppLogin = data => http.post('/member/auth/weixin-mini-ap //刷新令牌 export const refreshToken = data => http.post('/member/auth/refresh-token', {data}) //退出登录 -export const logout = data => http.post('/member/auth/logout', data) +export const logout = data => http.delete('/auth/logout', data) diff --git a/api/infoMarketInformation.js b/api/infoMarketInformation.js index 8e6fee7..2404467 100644 --- a/api/infoMarketInformation.js +++ b/api/infoMarketInformation.js @@ -1,4 +1,4 @@ const { http } = uni.$u // 列表和条件筛选 -export const getInfoMarketInformationlist = params => http.get('/infoMarketInformation/list', { params }) +export const getInfoMarketInformationlist = params => http.get('/insight/infoMarketInformation/list', { params }) diff --git a/api/organize.js b/api/organize.js index 38c6ecd..63683a6 100644 --- a/api/organize.js +++ b/api/organize.js @@ -1,43 +1,43 @@ const { http } = uni.$u // 列表和条件筛选 -export const getOrganizelist = params => http.get('/organize/list', { params }) +export const getOrganizelist = params => http.get('/insight/organize/list', { params }) //居民用户 -export const getPoolResidentlist = params => http.get('/poolResident/list', { params }) +export const getPoolResidentlist = params => http.get('/insight/poolResident/list', { params }) //商业用户 -export const getPoolCommercelist = params => http.get('/poolCommerce/list', { params }) +export const getPoolCommercelist = params => http.get('/insight/poolCommerce/list', { params }) //工业用户 -export const getPoolIndustrylist = params => http.get('/poolIndustry/list', { params }) +export const getPoolIndustrylist = params => http.get('/insight/poolIndustry/list', { params }) /*报告详情*/ //报告详情-组织实施落实 1 -export const getOrganize = params => http.get('/organize/' + params ) +export const getOrganize = params => http.get('/insight/organize/' + params ) //报告详情-天然气市场总体概况主表 2 -export const getGeneralOverview = params => http.get('/generalOverview/'+ params) +export const getGeneralOverview = params => http.get('/insight/generalOverview/'+ params) //报告详情-天然气市场总体概况附表 3 -export const getGeneralOverviewAttach = params => http.get('/generalOverviewAttach/'+ params) +export const getGeneralOverviewAttach = params => http.get('/insight/generalOverviewAttach/'+ params) //报告详情-告详情-重点市场业务分析 4 -export const getBusinessAnalyze = params => http.get('/businessAnalyze/'+ params) +export const getBusinessAnalyze = params => http.get('/insight/businessAnalyze/'+ params) //报告详情-预计2021财年-2022财年已签约且在2023财年安装确认项目 5 -export const getNewBuildingInfo = params => http.get('/newBuildingInfo/'+ params) +export const getNewBuildingInfo = params => http.get('/insight/newBuildingInfo/'+ params) //报告详情-预计2023-2025财年安装确认项目 6 -export const getNewBuildingItem = params => http.get('/newBuildingItem/'+ params) +export const getNewBuildingItem = params => http.get('/insight/newBuildingItem/'+ params) //报告详情-未来发展规划,所需资源配置 7 -export const getDevelopmentPlan = params => http.get('/developmentPlan/'+ params) +export const getDevelopmentPlan = params => http.get('/insight/developmentPlan/'+ params) //报告详情-目标思路建议 8 -export const getTargetSuggestion = params => http.get('/targetSuggestion/'+ params) +export const getTargetSuggestion = params => http.get('/insight/targetSuggestion/'+ params) diff --git a/common/config.js b/common/config.js index ebe5e3a..8f6e9d0 100644 --- a/common/config.js +++ b/common/config.js @@ -1,7 +1,7 @@ module.exports = { //后端接口地址 baseUrl: 'http://10.11.38.240:9001', //内网开发环境 - // baseUrl: 'http://127.0.0.1:48080/app-api', + // baseUrl: 'http://172.17.56.37:18082/api', // baseUrl: 'http://api-dashboard.yudao.iocoder.cn/app-api', // 超时 timeout: 30000, diff --git a/manifest.json b/manifest.json index f140b58..0fa6851 100644 --- a/manifest.json +++ b/manifest.json @@ -71,11 +71,11 @@ "vueVersion" : "2", "h5" : { "router" : { - "mode" : "history", - "base" : "h5" + "mode" : "hash", + "base" : "./" }, "devServer" : { - "https" : true + "https" : false } } } diff --git a/pages.json b/pages.json index 1e8b76f..4b835d3 100644 --- a/pages.json +++ b/pages.json @@ -1,6 +1,9 @@ { "pages": [ //pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages { + "path": "pages/login/mobile" + }, + { "path": "pages/market/index", "style": { "enablePullDownRefresh": true @@ -85,8 +88,8 @@ "globalStyle": { "navigationStyle": "custom", "navigationBarTextStyle": "black", - "navigationBarTitleText": "yudao-ui-app", + "navigationBarTitleText": "gas-market-h5", "navigationBarBackgroundColor": "#ffffff", "backgroundColor": "#ffffff" } -} \ No newline at end of file +} diff --git a/pages/login/mobile.vue b/pages/login/mobile.vue index e58e652..6f3081f 100644 --- a/pages/login/mobile.vue +++ b/pages/login/mobile.vue @@ -1,43 +1,45 @@ diff --git a/pages/market/index.vue b/pages/market/index.vue index 032d4eb..8fb021d 100644 --- a/pages/market/index.vue +++ b/pages/market/index.vue @@ -1,14 +1,28 @@ @@ -31,7 +45,7 @@ return { keyword: "", current: 0, - status:"loadmore", + status: "loadmore", total: null, queryParameter: { pageNum: 1, @@ -53,6 +67,8 @@ name: "国际能源", }], NewsList: [], + loginOutShow: false, + loginOutTitle: "退出登录" } }, computed: { @@ -87,7 +103,7 @@ initData() { this.updateList() }, - resetQuery(){ + resetQuery() { this.NewsList = []; this.queryParameter = { pageNum: 1, @@ -98,9 +114,9 @@ this.resetQuery(); this.updateList() }, - checkTotal(){ + checkTotal() { let allTotal = this.queryParameter.pageNum * this.queryParameter.pageSize - if(this.total < allTotal){ + if (this.total < allTotal) { this.status = "nomore" } }, @@ -128,9 +144,9 @@ getInfoMarketInformationlist(Params).then(res => { // console.log(res); if (res.code === 200) { - if(this.queryParameter.pageSize > 1){ - this.NewsList = [...this.NewsList,...res.rows] - }else{ + if (this.queryParameter.pageSize > 1) { + this.NewsList = [...this.NewsList, ...res.rows] + } else { this.NewsList = res.rows } this.total = res.total; @@ -145,11 +161,57 @@ this.current = e.index console.log(this.current); this.updateList() + }, + loginOutMethod() { + this.loginOutShow = true + }, + loginOut() { + // this.$modal.confirm('确定注销并退出系统吗?').then(() => { + this.$store.dispatch('Logout').then((res) => { + this.loginOutShow = false; + uni.reLaunch({ + url:'/pages/login/mobile' + }) + }) + // }) } } } diff --git a/pages/market/insight.vue b/pages/market/insight.vue index 72e9463..a0c1f42 100644 --- a/pages/market/insight.vue +++ b/pages/market/insight.vue @@ -204,11 +204,11 @@ }, updateList1() { let Params - if (this.keyword && this.current1 !== -1 && this.fiscalYear != "") { + if (this.keyword && this.current1 !== -1 && this.fiscalYear !== "") { Params = { - fiscalYear: this.fiscalYear, reportName: this.keyword, - statusCode: this.current1 + statusCode: this.current1, + fiscalYear: this.fiscalYear, } } else if (this.keyword !== "") { Params = { @@ -218,11 +218,12 @@ Params = { statusCode: this.current1 - 1 } - } else if (this.fiscalYear != "") { + } else if (this.fiscalYear !== "") { Params = { fiscalYear: this.fiscalYear } } + console.log(Params); Params = { ...this.queryParameter, ...Params @@ -339,7 +340,6 @@ this.fiscalYearShow = false; console.log(this.fiscalYear); this.resetQuery(); - this.updateList1(); }) }, resetDate() { diff --git a/static/images/empty/gas-logo.png b/static/images/empty/gas-logo.png new file mode 100644 index 0000000..ec25157 Binary files /dev/null and b/static/images/empty/gas-logo.png differ diff --git a/static/images/empty/login-out.png b/static/images/empty/login-out.png new file mode 100644 index 0000000..7e81565 Binary files /dev/null and b/static/images/empty/login-out.png differ diff --git a/store/mudules/user.js b/store/mudules/user.js index 5784dfd..a15c989 100644 --- a/store/mudules/user.js +++ b/store/mudules/user.js @@ -24,14 +24,15 @@ const user = { // 更新令牌 SET_TOKEN(state, data) { // 设置令牌 - const { accessToken, refreshToken } = data - state.accessToken = accessToken - state.refreshToken = refreshToken - uni.setStorageSync(AccessTokenKey, accessToken) - uni.setStorageSync(RefreshTokenKey, refreshToken) + console.log(111,data); + const { access_token, refresh_token } = data + state.accessToken = access_token + state.refreshToken = refresh_token + uni.setStorageSync(AccessTokenKey, access_token) + uni.setStorageSync(RefreshTokenKey, refresh_token) // 加载用户信息 - this.dispatch('ObtainUserInfo') + // this.dispatch('ObtainUserInfo') }, // 更新用户信息 SET_USER_INFO(state, data) { diff --git a/utils/request/requestInterceptors.js b/utils/request/requestInterceptors.js index afd1137..b74081b 100644 --- a/utils/request/requestInterceptors.js +++ b/utils/request/requestInterceptors.js @@ -9,7 +9,7 @@ module.exports = vm => { // 初始化请求拦截器时,会执行此方法,此时data为undefined,赋予默认{} config.data = config.data || {} if (vm.$store.getters.hasLogin) { - config.header.Authorization = 'Bearer ' + vm.$store.getters.accessToken + config.header.Authorization = vm.$store.getters.accessToken } return config }, diff --git a/vue.config.js b/vue.config.js index 64a3fe5..7de3715 100644 --- a/vue.config.js +++ b/vue.config.js @@ -1,10 +1,26 @@ module.exports = { - // 配置路径别名 - configureWebpack: { - devServer: { - // 调试时允许内网穿透,让外网的人访问到本地调试的H5页面 - disableHostCheck: true - } - } - // productionSourceMap: false, + // 配置路径别名 + configureWebpack: { + devServer: { + // 调试时允许内网穿透,让外网的人访问到本地调试的H5页面 + disableHostCheck: true, + // /本地调试时打开 + port: '8081', //代理端口,不固定8222,可以是其他的 + open: false, //项目启动时是否自动打开浏览器 + proxy: { + '/api': { + target: 'http://172.17.56.37/api', //接口地址 + // ws:true, //允许ws跨域 + secure:true, //类型:https=false http=true + changeOrigin: true, //是否跨域 + pathRewrite:{ // 重写路径 + '^/api':'' + } + } + }, + + // /本地调试时打开 + } + }, + productionSourceMap: false, } -- libgit2 0.21.2