Showing
8 changed files
with
78 additions
and
39 deletions
| @@ -5,18 +5,18 @@ export const API_CONST = { | @@ -5,18 +5,18 @@ export const API_CONST = { | ||
| 5 | url: `/qx-api/qx-apaas-auth/server/auth/login`, | 5 | url: `/qx-api/qx-apaas-auth/server/auth/login`, |
| 6 | method: "POST" | 6 | method: "POST" |
| 7 | }, | 7 | }, |
| 8 | - loginSecurity:{ | ||
| 9 | - url:`/qx-api/qx-unified-user/login/securityImg`, | ||
| 10 | - method:"GET" | 8 | + loginSecurity: { |
| 9 | + url: `/qx-api/qx-unified-user/login/securityImg`, | ||
| 10 | + method: "GET" | ||
| 11 | }, | 11 | }, |
| 12 | - userSecurity:{ | ||
| 13 | - url:`/qx-api/qx-apaas-uc/user/securityImg`, | ||
| 14 | - method:"GET" | 12 | + userSecurity: { |
| 13 | + url: `/qx-api/qx-apaas-uc/user/securityImg`, | ||
| 14 | + method: "GET" | ||
| 15 | }, | 15 | }, |
| 16 | 16 | ||
| 17 | - logout:{ | ||
| 18 | - url:`/qx-api/qx-apaas-auth/server/auth/mobile/logout`, | ||
| 19 | - method:"POST" | 17 | + logout: { |
| 18 | + url: `/qx-api/qx-apaas-auth/server/auth/mobile/logout`, | ||
| 19 | + method: "POST" | ||
| 20 | } | 20 | } |
| 21 | 21 | ||
| 22 | }, // 获取用户手机号并进行注册登录 | 22 | }, // 获取用户手机号并进行注册登录 |
| @@ -30,7 +30,10 @@ export const API_CONST = { | @@ -30,7 +30,10 @@ export const API_CONST = { | ||
| 30 | getDate: { | 30 | getDate: { |
| 31 | url: `/open/qx-apaas-custom/hczd/getDate`, | 31 | url: `/open/qx-apaas-custom/hczd/getDate`, |
| 32 | method: "POST"//参数 | 32 | method: "POST"//参数 |
| 33 | - | 33 | + }, |
| 34 | + userInfoDetail: { | ||
| 35 | + url: `/qx-api/qx-apaas-uc/user/mobile/detail`, | ||
| 36 | + method: "GET" | ||
| 34 | } | 37 | } |
| 35 | } | 38 | } |
| 36 | 39 |
| @@ -8,14 +8,19 @@ Page({ | @@ -8,14 +8,19 @@ Page({ | ||
| 8 | * 页面的初始数据 | 8 | * 页面的初始数据 |
| 9 | */ | 9 | */ |
| 10 | data: { | 10 | data: { |
| 11 | - | 11 | + optionsObj: {} |
| 12 | }, | 12 | }, |
| 13 | 13 | ||
| 14 | /** | 14 | /** |
| 15 | * 生命周期函数--监听页面加载 | 15 | * 生命周期函数--监听页面加载 |
| 16 | */ | 16 | */ |
| 17 | - onLoad() { | 17 | + onLoad(option: any) { |
| 18 | + console.log(option, 'options') | ||
| 18 | 19 | ||
| 20 | + this.setData({ | ||
| 21 | + optionsObj : JSON.parse(option.userInfoStr) | ||
| 22 | + }) | ||
| 23 | + | ||
| 19 | }, | 24 | }, |
| 20 | 25 | ||
| 21 | /** | 26 | /** |
| @@ -70,15 +75,16 @@ Page({ | @@ -70,15 +75,16 @@ Page({ | ||
| 70 | wx.navigateBack() | 75 | wx.navigateBack() |
| 71 | }, | 76 | }, |
| 72 | 77 | ||
| 73 | - __mobilelogoutEvent(){ | 78 | + __mobilelogoutEvent() { |
| 74 | HTTP.POST({ | 79 | HTTP.POST({ |
| 75 | ...API_CONST.login.logout, | 80 | ...API_CONST.login.logout, |
| 76 | - payload:{ | ||
| 77 | - | 81 | + payload: { |
| 82 | + cookieFlag: true | ||
| 78 | } | 83 | } |
| 79 | }).then((data: any) => { | 84 | }).then((data: any) => { |
| 80 | - if(data.success){ | ||
| 81 | - wx.navigateTo({url:"/pages/login/login"}) | 85 | + wx.clearStorageSync() |
| 86 | + if (data.success) { | ||
| 87 | + wx.navigateTo({ url: "/pages/login/login" }) | ||
| 82 | } | 88 | } |
| 83 | }) | 89 | }) |
| 84 | }, | 90 | }, |
| @@ -90,7 +96,7 @@ Page({ | @@ -90,7 +96,7 @@ Page({ | ||
| 90 | .then(() => { | 96 | .then(() => { |
| 91 | // on confirm | 97 | // on confirm |
| 92 | this.__mobilelogoutEvent() | 98 | this.__mobilelogoutEvent() |
| 93 | - | 99 | + |
| 94 | }) | 100 | }) |
| 95 | .catch(() => { | 101 | .catch(() => { |
| 96 | // on cancel | 102 | // on cancel |
| @@ -5,9 +5,9 @@ | @@ -5,9 +5,9 @@ | ||
| 5 | </view> | 5 | </view> |
| 6 | <view class="acount_info"> | 6 | <view class="acount_info"> |
| 7 | <van-cell-group> | 7 | <van-cell-group> |
| 8 | - <van-cell title="姓名" value="内容" /> | ||
| 9 | - <van-cell title="手机号" value="内容" /> | ||
| 10 | - <van-cell title="邮箱" value="内容" /> | 8 | + <van-cell title="姓名" value="{{optionsObj.name || '未设置'}}" /> |
| 9 | + <van-cell title="手机号" value="{{optionsObj.mobile || '未设置'}}" /> | ||
| 10 | + <van-cell title="邮箱" value="{{optionsObj.email || '未设置'}}" /> | ||
| 11 | </van-cell-group> | 11 | </van-cell-group> |
| 12 | </view> | 12 | </view> |
| 13 | </view> | 13 | </view> |
| @@ -2,15 +2,16 @@ | @@ -2,15 +2,16 @@ | ||
| 2 | import { HTTPService as HTTP } from "../../services/HTTPService"; | 2 | import { HTTPService as HTTP } from "../../services/HTTPService"; |
| 3 | // 获取应用实例 | 3 | // 获取应用实例 |
| 4 | import minaEnv from "../../utils/minaEnv"; | 4 | import minaEnv from "../../utils/minaEnv"; |
| 5 | -import { getShareInfo } from "../../utils/wxUtil"; | 5 | +import { API_CONST } from "./../../api/smartElectric"; |
| 6 | // @ts-ignore | 6 | // @ts-ignore |
| 7 | const app = getApp<IAppOption>(); | 7 | const app = getApp<IAppOption>(); |
| 8 | Page({ | 8 | Page({ |
| 9 | data: { | 9 | data: { |
| 10 | url: "", | 10 | url: "", |
| 11 | + userInfoObj: {} | ||
| 11 | }, | 12 | }, |
| 12 | onLoad() { | 13 | onLoad() { |
| 13 | - | 14 | + this.__getUserInfoDetail() |
| 14 | }, | 15 | }, |
| 15 | handleGetMessage(e: any) { | 16 | handleGetMessage(e: any) { |
| 16 | console.log(e, 'handleGetMessagehandleGetMessage') | 17 | console.log(e, 'handleGetMessagehandleGetMessage') |
| @@ -23,7 +24,32 @@ Page({ | @@ -23,7 +24,32 @@ Page({ | ||
| 23 | // console.log(pages) | 24 | // console.log(pages) |
| 24 | }, | 25 | }, |
| 25 | gotoAcount() { | 26 | gotoAcount() { |
| 26 | - wx.navigateTo({ url: "/pages/acount/acount" }) | 27 | + const userInfoStr = JSON.stringify(this.data.userInfoObj) |
| 28 | + wx.navigateTo({ url: `/pages/acount/acount?userInfoStr=${userInfoStr}` }) | ||
| 27 | }, | 29 | }, |
| 28 | onReady() { }, | 30 | onReady() { }, |
| 31 | + __getUserInfoDetail() { | ||
| 32 | + HTTP.GET({ | ||
| 33 | + ...API_CONST.home.userInfoDetail, | ||
| 34 | + payload: { | ||
| 35 | + corpCode: "default", | ||
| 36 | + cookieFlag: true | ||
| 37 | + } | ||
| 38 | + }).then((res: any) => { | ||
| 39 | + console.log(res, 'rrreeesss') | ||
| 40 | + const arr = res.data.dataTitle.split("") | ||
| 41 | + const lastName = arr[arr.length-1] | ||
| 42 | + console.log(arr,'pppppparrr') | ||
| 43 | + if (res.success) { | ||
| 44 | + this.setData({ | ||
| 45 | + userInfoObj: {...res.data,lastName} | ||
| 46 | + }) | ||
| 47 | + }else { | ||
| 48 | + this.setData({ | ||
| 49 | + userInfoObj: {} | ||
| 50 | + }) | ||
| 51 | + } | ||
| 52 | + }) | ||
| 53 | + }, | ||
| 54 | + | ||
| 29 | }); | 55 | }); |
| 1 | <view class="home_main"> | 1 | <view class="home_main"> |
| 2 | <view class="home-info"> | 2 | <view class="home-info"> |
| 3 | <view class="home-info-avatar"> | 3 | <view class="home-info-avatar"> |
| 4 | - 铨 | 4 | + {{userInfoObj.lastName}} |
| 5 | </view> | 5 | </view> |
| 6 | <view class="mine-info"> | 6 | <view class="mine-info"> |
| 7 | <view class="mine-info-basic"> | 7 | <view class="mine-info-basic"> |
| 8 | - 周铨 | 8 | + {{userInfoObj.dataTitle}} |
| 9 | </view> | 9 | </view> |
| 10 | <view class="mine-company"> | 10 | <view class="mine-company"> |
| 11 | <!-- <image src="" class="image_view" mode=""/> --> | 11 | <!-- <image src="" class="image_view" mode=""/> --> |
| 12 | - <view class="mine-company-info">青谷科技</view> | 12 | + <view class="mine-company-info">{{userInfoObj.corpName}}</view> |
| 13 | </view> | 13 | </view> |
| 14 | </view> | 14 | </view> |
| 15 | </view> | 15 | </view> |
| @@ -9,11 +9,11 @@ Page({ | @@ -9,11 +9,11 @@ Page({ | ||
| 9 | data: { | 9 | data: { |
| 10 | logoUrl: "./../../img/qixiao.png", | 10 | logoUrl: "./../../img/qixiao.png", |
| 11 | checkFlag: true, | 11 | checkFlag: true, |
| 12 | - username: "",// 用户名 | ||
| 13 | - password: "",//密码 | 12 | + username: "15556367216",// 用户名 |
| 13 | + password: "efault",//密码 | ||
| 14 | hideFlag: true,//是否隐藏 | 14 | hideFlag: true,//是否隐藏 |
| 15 | keyStr: "",// key值 | 15 | keyStr: "",// key值 |
| 16 | - imgUrl:"",//显示验证码的图片地址 | 16 | + imgUrl: "",//显示验证码的图片地址 |
| 17 | codeKey: ""//验证码 | 17 | codeKey: ""//验证码 |
| 18 | }, | 18 | }, |
| 19 | 19 | ||
| @@ -79,8 +79,8 @@ Page({ | @@ -79,8 +79,8 @@ Page({ | ||
| 79 | // console.log(e.detail.errMsg) // 回调信息(成功失败都会返回) | 79 | // console.log(e.detail.errMsg) // 回调信息(成功失败都会返回) |
| 80 | // console.log(e.detail.errno) // 错误码(失败时返回) | 80 | // console.log(e.detail.errno) // 错误码(失败时返回) |
| 81 | }, | 81 | }, |
| 82 | - loginEvent() :any{ | ||
| 83 | - if(!this.data.username|| !this.data.password){ | 82 | + loginEvent(): any { |
| 83 | + if (!this.data.username || !this.data.password) { | ||
| 84 | wx.showToast({ | 84 | wx.showToast({ |
| 85 | title: "请将信息填写完整", | 85 | title: "请将信息填写完整", |
| 86 | icon: 'none', | 86 | icon: 'none', |
| @@ -92,7 +92,11 @@ Page({ | @@ -92,7 +92,11 @@ Page({ | ||
| 92 | ...API_CONST.login.wxLogin, | 92 | ...API_CONST.login.wxLogin, |
| 93 | payload: this.getLoginParams() | 93 | payload: this.getLoginParams() |
| 94 | }).then((data: any) => { | 94 | }).then((data: any) => { |
| 95 | + console.log(data, '登录参数') | ||
| 95 | if (data.success) { | 96 | if (data.success) { |
| 97 | + //登录请求回来之后,读取res的header的cookie | ||
| 98 | + //cookie是个唯一标识 | ||
| 99 | + wx.setStorageSync("cookie", data.data) | ||
| 96 | wx.switchTab({ | 100 | wx.switchTab({ |
| 97 | url: "/pages/monitor/monitor" | 101 | url: "/pages/monitor/monitor" |
| 98 | }) | 102 | }) |
| @@ -153,7 +157,7 @@ Page({ | @@ -153,7 +157,7 @@ Page({ | ||
| 153 | hideFlag: res.data.hide,//是否隐藏 | 157 | hideFlag: res.data.hide,//是否隐藏 |
| 154 | keyStr: res.data.key,// key值 | 158 | keyStr: res.data.key,// key值 |
| 155 | }) | 159 | }) |
| 156 | - if(res.data.hide === false){ | 160 | + if (res.data.hide === false) { |
| 157 | this.__getUserSecurityImg() | 161 | this.__getUserSecurityImg() |
| 158 | } | 162 | } |
| 159 | } | 163 | } |
| @@ -165,15 +169,15 @@ Page({ | @@ -165,15 +169,15 @@ Page({ | ||
| 165 | ...API_CONST.login.userSecurity, | 169 | ...API_CONST.login.userSecurity, |
| 166 | payload: { | 170 | payload: { |
| 167 | corpCode: "default", | 171 | corpCode: "default", |
| 168 | - key:this.data.keyStr | 172 | + key: this.data.keyStr |
| 169 | } | 173 | } |
| 170 | }).then((res: any) => { | 174 | }).then((res: any) => { |
| 171 | - console.log(res,'res------') | 175 | + console.log(res, 'res------') |
| 172 | if (res.success) { | 176 | if (res.success) { |
| 173 | this.setData({ | 177 | this.setData({ |
| 174 | hideFlag: res.data.hide,//是否隐藏 | 178 | hideFlag: res.data.hide,//是否隐藏 |
| 175 | keyStr: res.data.key,// key值 | 179 | keyStr: res.data.key,// key值 |
| 176 | - imgUrl:res.data.img.replace(/[\r\n]/g, '') | 180 | + imgUrl: res.data.img |
| 177 | }) | 181 | }) |
| 178 | } | 182 | } |
| 179 | }) | 183 | }) |
| @@ -6,7 +6,7 @@ | @@ -6,7 +6,7 @@ | ||
| 6 | <view class="login_form"> | 6 | <view class="login_form"> |
| 7 | <van-cell-group> | 7 | <van-cell-group> |
| 8 | <van-field label="用户名" title-width="50" value="{{ username }}" bind:change="userEvent" required clearable placeholder="请输入手机号" bind:click-icon="onClickIcon" /> | 8 | <van-field label="用户名" title-width="50" value="{{ username }}" bind:change="userEvent" required clearable placeholder="请输入手机号" bind:click-icon="onClickIcon" /> |
| 9 | - <van-field label="密码" title-width="50" value="{{ password }}" bind:change="passEvent" type="{{checkFlag?'':'password'}}" bind:click-icon="changeIconEvent" icon="{{checkFlag?'eye-o':'closed-eye'}}" placeholder="请输入密码" required /> | 9 | + <van-field label="密码" title-width="50" value="{{ password }}" bind:change="passEvent" type="{{checkFlag?'password':''}}" bind:click-icon="changeIconEvent" icon="{{!checkFlag?'eye-o':'closed-eye'}}" placeholder="请输入密码" required /> |
| 10 | 10 | ||
| 11 | <van-field wx:if="{{!hideFlag&& imgUrl}}" title-width="50" label="验证码" value="{{ codeKey }}" bind:change="imgKeyEvent" placeholder="请输入验证码" required /> | 11 | <van-field wx:if="{{!hideFlag&& imgUrl}}" title-width="50" label="验证码" value="{{ codeKey }}" bind:change="imgKeyEvent" placeholder="请输入验证码" required /> |
| 12 | <image src="{{imgUrl}}" wx:if="{{ imgUrl}}" class="code-img" /> | 12 | <image src="{{imgUrl}}" wx:if="{{ imgUrl}}" class="code-img" /> |
| @@ -99,7 +99,7 @@ class HTTPService { | @@ -99,7 +99,7 @@ class HTTPService { | ||
| 99 | payload = { | 99 | payload = { |
| 100 | ...payload | 100 | ...payload |
| 101 | } | 101 | } |
| 102 | - | 102 | + const cookieVal:any = wx.getStorageSync("cookie") |
| 103 | return new Promise((resolve, reject) => { | 103 | return new Promise((resolve, reject) => { |
| 104 | wx.request({ | 104 | wx.request({ |
| 105 | url: rootUrlProduce + url, | 105 | url: rootUrlProduce + url, |
| @@ -109,7 +109,7 @@ class HTTPService { | @@ -109,7 +109,7 @@ class HTTPService { | ||
| 109 | method, | 109 | method, |
| 110 | header: { | 110 | header: { |
| 111 | "Content-Type": "application/json", | 111 | "Content-Type": "application/json", |
| 112 | - Authorization: payload.Authorization || '' | 112 | + Authorization: payload.cookieFlag? cookieVal : '' |
| 113 | }, | 113 | }, |
| 114 | dataType: "json", | 114 | dataType: "json", |
| 115 | success: responseJSON => { | 115 | success: responseJSON => { |