023f830b by 华明祺

登录

1 parent 79cf495e
1 <script> 1 <script>
2 import * as loginServer from '@/common/login.js'; 2 import {
3 import * as api from '@/common/api.js'; 3 h5Login
4 import config from '@/config.js'; 4 } from '@/common/login.js';
5 import * as api from '@/common/api.js';
6 import config from '@/config.js';
5 7
6 8 let loginUrl=['pages/index/login', 'pages/index/register']
7 let firstload = false 9 let firstload = false
8 export default { 10 export default {
9 onLaunch: function() { 11 onLaunch: function(options) {
10 console.log('App Launch'); 12 console.log('App Launch', options);
11 firstload = true 13 firstload = true
12 this.globalData.baseUrl = config.baseUrl;
13 this.globalData.baseUrl_api = config.baseUrl_api;
14 this.globalData.fileUrl = config.fileUrl;
15
16 new Promise((resolve, reject) => {
17 uni.checkSession({
18 success: res => {
19 loginServer
20 .getCurrUser(true)
21 .catch(() => {
22 return loginServer.pcLogin();
23 })
24 .then(user => {
25 resolve(user);
26 });
27 },
28 fail: res => {
29 loginServer
30 .wxLogin()
31 .then(loginRes => {
32 return loginServer.pcLogin(loginRes.code);
33 })
34 .then(user => {
35 resolve(user);
36 });
37 }
38 });
39 })
40 .then(()=>{
41 return loginServer.getNowOpenId()
42 })
43 .then(() => {
44 return loginServer.initData()
45 // console.log(22222222)
46 // const currUser = uni.getStorageSync('currUser');
47 // // console.log(currUser)
48 // return Promise.all([api.getVenue(), api.getOwnMemberInfo()]).then(res => {
49 // let ven = res[0].data;
50 // let men = res[1]?.data;
51
52 // if (ven.venuePic) {
53 // ven.venuePicArr = ven.venuePic.split(',');
54 // }
55 // if (ven.businessPeriod) {
56 // ven.startBus = ven.businessPeriod.split(',')[0];
57 // ven.endBus = ven.businessPeriod.split(',')[1];
58 // }
59 // ven.latitude = ven.lal.split(',')[0];
60 // ven.longitude = ven.lal.split(',')[1];
61 14
62 // this.globalData.venue = ven; 15 this.globalData.baseUrl_api = config.baseUrl_api;
63 // this.globalData.isVip = men?.isVip;
64 // // this.globalData.relateProjectId = men.info.relateProjectId;
65 // this.globalData.relateProjectIdList = men?.info?.relateProjectIdList;
66 // this.globalData.relateVenueProjectIdList = men?.info?.relateVenueProjectIdList;
67 16
68 // this.globalData.venueConfig = { 17 if(loginUrl.indexOf( options.path)==-1){
69 // normalOverDay: ven.resSiteConfig?.normalOrderNum, 18 let userName = uni.getStorageSync('userName')
70 // normalPeriodStart: ven.resSiteConfig?.normalOrderPeriod.split(',')[0], 19 if (userName) {
71 // normalPeriodEnd: ven.resSiteConfig?.normalOrderPeriod.split(',')[1] 20 h5Login(userName)
72 // };
73 // if (men?.isVip) {
74 // this.globalData.venueConfig.memberOverDay = ven.resSiteConfig?.memberOrderNum;
75 // this.globalData.venueConfig.memberPeriodStart = ven.resSiteConfig?.memberOrderPeriod.split(',')[0];
76 // this.globalData.venueConfig.memberPeriodEnd = ven.resSiteConfig?.memberOrderPeriod.split(',')[1];
77 // }
78 // });
79 })
80 .then(() => { 21 .then(() => {
81 this.globalData.isLogin = true; 22 this.globalData.isLogin = true;
82 let firstLoadCallback = getApp().firstLoadCallback; 23 let firstLoadCallback = getApp().firstLoadCallback;
83 if (firstLoadCallback) { 24 if (firstLoadCallback) {
84 firstLoadCallback(); 25 firstLoadCallback();
85 } 26 }
86 }); 27 })
87 },
88 onShow: function() {
89 console.log('App Show');
90 // loginServer.getNowOpenId()
91 if (!firstload) {
92 loginServer.getCurrUser(true)
93 .catch(() => { 28 .catch(() => {
94 return loginServer.pcLogin().then(() => {
95 uni.redirectTo({ 29 uni.redirectTo({
96 url: getCurrentPages()[getCurrentPages().length - 1].$page.fullPath 30 url: '/pages/index/login'
97 }) 31 })
98 });
99 }) 32 })
33 } else {
34 this.globalData.isLogin = false;
35 uni.redirectTo({
36 url: '/pages/index/login'
37 })
38 }
100 } 39 }
101 }, 40 },
41 onShow: function() {
42 console.log('App Show');
43 },
102 onHide: function() { 44 onHide: function() {
103 console.log('App Hide'); 45 console.log('App Hide');
104 } 46 }
105 }; 47 };
106 </script> 48 </script>
107 49
108 <style lang="scss"> 50 <style lang="scss">
......
1 import request from './request' 1 import request from './request'
2 import * as api from '@/common/api.js'; 2 import * as api from '@/common/api.js'
3 3
4 let appId = '' 4 let appId = ''
5 // #ifdef MP 5 // #ifdef MP
6 const accountInfo = uni.getAccountInfoSync() 6 const accountInfo = uni.getAccountInfoSync()
7 const appId = accountInfo.miniProgram.appId; 7 appId = accountInfo.miniProgram.appId
8 // #endif 8 // #endif
9 9
10 function wxLogin() { 10 function wxLogin() {
...@@ -22,81 +22,59 @@ function wxLogin() { ...@@ -22,81 +22,59 @@ function wxLogin() {
22 }) 22 })
23 } 23 }
24 24
25 function pcLogin(code) { 25 function pcLogin(data) {
26 if (code) { 26 return request({
27 return pcLoginByCode(code) 27 url: '/login',
28 } else { 28 method: 'post',
29 const currUser = uni.getStorageSync('currUser') || {} 29 params: data
30 if (currUser.openId) { 30 }).then((res) => {
31 return pcLoginByOpenId(currUser.openId); 31 uni.setStorageSync('userName', data.username)
32 } else { 32 uni.setStorageSync('token', 'Bearer ' + res.data.token)
33 return wxLogin().then((loginRes) => {
34 return pcLoginByCode(loginRes.code)
35 }) 33 })
36 }
37 }
38 } 34 }
39 35
40 function pcLoginByOpenId(openId) { 36 function h5Login(userName) {
41 return request({ 37 return request({
42 url: "/system/wx/loginByOpenId", 38 url: `/h5Login`,
43 method: "POST", 39 method: 'post',
44 params: { 40 params: {
45 appId: appId, 41 username: userName
46 openId: openId
47 } 42 }
48 }).then((res) => { 43 }).then((res) => {
49 let user = res.data; 44 uni.setStorageSync('token', 'Bearer ' + res.data.token)
50 // console.log("openId " + openId, user)
51
52 uni.setStorageSync('token', 'Bearer ' + user.token);
53 uni.setStorageSync('currUser', user);
54 return user;
55 }).catch(() => {
56 uni.removeStorageSync('currUser')
57 }) 45 })
58 } 46 }
59 47
60 function pcLoginByCode(code) { 48 function h5LoginAuto() {
61 return request({ 49 const userName = uni.getStorageSync('userName')
62 // url: "/weixin/api/login", 50 if (userName) {
63 url: "/system/wx/loginByJsCode", 51 return h5Login(userName)
64 method: "POST", 52 } else {
65 params: { 53 uni.redirectTo({
66 appId: appId, 54 url: '/pages/index/login'
67 jsCode: code
68 }
69 }).then((res) => {
70 let user = res.data
71 // console.log("code: " + code, user)
72 // getNowOpenId()
73 uni.setStorageSync('token', 'Bearer ' + user.token);
74 uni.setStorageSync('currUser', user);
75 return user;
76 }).catch((err) => {
77 uni.removeStorageSync('currUser')
78 }) 55 })
56 }
79 } 57 }
80 58
81 function getCurrUser(isAuto) { 59 function getCurrUser(isAuto) {
82 return request({ 60 return request({
83 url: "/system/wx/getUserInfo", 61 url: '/system/wx/getUserInfo',
84 method: "GET", 62 method: 'GET',
85 opts: { 63 opts: {
86 isAuto: isAuto 64 isAuto: isAuto
87 } 65 }
88 }).then((res) => { 66 }).then((res) => {
89 let user = res.data; 67 const user = res.data
90 uni.setStorageSync('currUser', user); 68 uni.setStorageSync('currUser', user)
91 return user 69 return user
92 }) 70 })
93 } 71 }
94 72
95 function getWxUser() { 73 function getWxUser() {
96 return new Promise((resolve, reject) => { 74 return new Promise((resolve, reject) => {
97 const currUser = uni.getStorageSync('currUser'); 75 const currUser = uni.getStorageSync('currUser')
98 // getNowOpenId() 76 // getNowOpenId()
99 const nowOpenId = uni.getStorageSync('nowOpenId'); 77 const nowOpenId = uni.getStorageSync('nowOpenId')
100 uni.getUserProfile({ 78 uni.getUserProfile({
101 desc: '用于完善用户信息', 79 desc: '用于完善用户信息',
102 success: function(infoRes) { 80 success: function(infoRes) {
...@@ -104,7 +82,7 @@ function getWxUser() { ...@@ -104,7 +82,7 @@ function getWxUser() {
104 82
105 request({ 83 request({
106 url: `/system/wx/updateWxUser?openId=${nowOpenId}`, 84 url: `/system/wx/updateWxUser?openId=${nowOpenId}`,
107 method: "POST", 85 method: 'POST',
108 params: { 86 params: {
109 appId: appId, 87 appId: appId,
110 openId: nowOpenId, 88 openId: nowOpenId,
...@@ -116,9 +94,9 @@ function getWxUser() { ...@@ -116,9 +94,9 @@ function getWxUser() {
116 signature: infoRes.signature 94 signature: infoRes.signature
117 } 95 }
118 }).then((res) => { 96 }).then((res) => {
119 let user = res.data; 97 const user = res.data
120 uni.setStorageSync('currUser', user); 98 uni.setStorageSync('currUser', user)
121 resolve(user); 99 resolve(user)
122 }).catch(() => { 100 }).catch(() => {
123 reject() 101 reject()
124 }) 102 })
...@@ -126,19 +104,19 @@ function getWxUser() { ...@@ -126,19 +104,19 @@ function getWxUser() {
126 fail: (res) => { 104 fail: (res) => {
127 reject(res) 105 reject(res)
128 } 106 }
129 }); 107 })
130 }); 108 })
131 } 109 }
132 110
133 function getWxUserPhone(phoneRes) { 111 function getWxUserPhone(phoneRes) {
134 // console.log(phoneRes) 112 // console.log(phoneRes)
135 113
136 const currUser = uni.getStorageSync('currUser'); 114 const currUser = uni.getStorageSync('currUser')
137 // getNowOpenId() 115 // getNowOpenId()
138 const nowOpenId = uni.getStorageSync('nowOpenId'); 116 const nowOpenId = uni.getStorageSync('nowOpenId')
139 return request({ 117 return request({
140 url: `/system/wx/updateMobile?openId=${nowOpenId}`, 118 url: `/system/wx/updateMobile?openId=${nowOpenId}`,
141 method: "POST", 119 method: 'POST',
142 params: { 120 params: {
143 appId: appId, 121 appId: appId,
144 userId: currUser.id, 122 userId: currUser.id,
...@@ -149,10 +127,10 @@ function getWxUserPhone(phoneRes) { ...@@ -149,10 +127,10 @@ function getWxUserPhone(phoneRes) {
149 signature: phoneRes.signature 127 signature: phoneRes.signature
150 } 128 }
151 }).then((res) => { 129 }).then((res) => {
152 let user = res.data; 130 const user = res.data
153 // uni.setStorageSync('token', 'Bearer '+ user.token); 131 // uni.setStorageSync('token', 'Bearer '+ user.token);
154 uni.setStorageSync('token', user.token); 132 uni.setStorageSync('token', user.token)
155 uni.setStorageSync('currUser', user); 133 uni.setStorageSync('currUser', user)
156 return user 134 return user
157 }) 135 })
158 } 136 }
...@@ -166,7 +144,7 @@ function checkUserAuth(path) { ...@@ -166,7 +144,7 @@ function checkUserAuth(path) {
166 uni.navigateTo({ 144 uni.navigateTo({
167 url: '/pages/index/start?path=' + encodeURIComponent(path) 145 url: '/pages/index/start?path=' + encodeURIComponent(path)
168 }) 146 })
169 return false; 147 return false
170 } 148 }
171 } 149 }
172 150
...@@ -183,41 +161,48 @@ function getNowOpenId() { ...@@ -183,41 +161,48 @@ function getNowOpenId() {
183 function initData() { 161 function initData() {
184 console.log('initData') 162 console.log('initData')
185 163
186 const currUser = uni.getStorageSync('currUser'); 164 // const currUser = uni.getStorageSync('currUser')
187 // console.log(currUser) 165 // console.log(currUser)
188 return Promise.all([api.getVenue(), api.getOwnMemberInfo()]).then(res => { 166 return Promise.all([api.getVenue(), api.getOwnMemberInfo()]).then(res => {
189 let ven = res[0].data; 167 const ven = res[0].data
190 let men = res[1]?.data; 168 const men = res[1]?.data
191 169
192 const app = getApp(); 170 const app = getApp()
193 171
194 if (ven.venuePic) { 172 if (ven.venuePic) {
195 ven.venuePicArr = ven.venuePic.split(','); 173 ven.venuePicArr = ven.venuePic.split(',')
196 } 174 }
197 if (ven.businessPeriod) { 175 if (ven.businessPeriod) {
198 ven.startBus = ven.businessPeriod.split(',')[0]; 176 ven.startBus = ven.businessPeriod.split(',')[0]
199 ven.endBus = ven.businessPeriod.split(',')[1]; 177 ven.endBus = ven.businessPeriod.split(',')[1]
200 } 178 }
201 ven.latitude = ven.lal.split(',')[0]; 179 ven.latitude = ven.lal.split(',')[0]
202 ven.longitude = ven.lal.split(',')[1]; 180 ven.longitude = ven.lal.split(',')[1]
203 181
204 app.globalData.venue = ven; 182 app.globalData.venue = ven
205 app.globalData.isVip = men?.isVip; 183 app.globalData.isVip = men?.isVip
206 // app.globalData.relateProjectId = men.info.relateProjectId; 184 // app.globalData.relateProjectId = men.info.relateProjectId;
207 app.globalData.relateProjectIdList = men?.info?.relateProjectIdList; 185 app.globalData.relateProjectIdList = men?.info?.relateProjectIdList
208 app.globalData.relateVenueProjectIdList = men?.info?.relateVenueProjectIdList; 186 app.globalData.relateVenueProjectIdList = men?.info?.relateVenueProjectIdList
209 187
210 app.globalData.venueConfig = { 188 app.globalData.venueConfig = {
211 normalOverDay: ven.resSiteConfig?.normalOrderNum, 189 normalOverDay: ven.resSiteConfig?.normalOrderNum,
212 normalPeriodStart: ven.resSiteConfig?.normalOrderPeriod.split(',')[0], 190 normalPeriodStart: ven.resSiteConfig?.normalOrderPeriod.split(',')[0],
213 normalPeriodEnd: ven.resSiteConfig?.normalOrderPeriod.split(',')[1] 191 normalPeriodEnd: ven.resSiteConfig?.normalOrderPeriod.split(',')[1]
214 }; 192 }
215 if (men?.isVip) { 193 if (men?.isVip) {
216 app.globalData.venueConfig.memberOverDay = ven.resSiteConfig?.memberOrderNum; 194 app.globalData.venueConfig.memberOverDay = ven.resSiteConfig?.memberOrderNum
217 app.globalData.venueConfig.memberPeriodStart = ven.resSiteConfig?.memberOrderPeriod.split(',')[0]; 195 app.globalData.venueConfig.memberPeriodStart = ven.resSiteConfig?.memberOrderPeriod.split(',')[0]
218 app.globalData.venueConfig.memberPeriodEnd = ven.resSiteConfig?.memberOrderPeriod.split(',')[1]; 196 app.globalData.venueConfig.memberPeriodEnd = ven.resSiteConfig?.memberOrderPeriod.split(',')[1]
219 } 197 }
220 }); 198 })
199 }
200
201 function getCodeImg() {
202 return request({
203 url: '/captchaImage',
204 method: 'get'
205 })
221 } 206 }
222 207
223 export { 208 export {
...@@ -228,5 +213,8 @@ export { ...@@ -228,5 +213,8 @@ export {
228 getWxUser, 213 getWxUser,
229 getWxUserPhone, 214 getWxUserPhone,
230 checkUserAuth, 215 checkUserAuth,
231 initData 216 initData,
217 getCodeImg,
218 h5Login,
219 h5LoginAuto
232 } 220 }
......
1 import config from '@/config.js' 1 import config from '@/config.js'
2 import { 2 import {
3 pcLogin, 3 h5LoginAuto
4 getNowOpenId,
5 initData
6 } from './login' 4 } from './login'
7 5
8 const excludeUrls = ['/system/wx/getUserInfo'] 6 const excludeUrls = ['pages/index/login', 'pages/index/register']
9 7
10 // 获取Token 8 // 获取Token
11 function getToken() { 9 function getToken() {
12 try { 10 try {
13 const token = uni.getStorageSync('token'); 11 const token = uni.getStorageSync('token')
14 if (token) { 12 if (token) {
15 return token 13 return token
16 } else { 14 } else {
...@@ -23,22 +21,22 @@ function getToken() { ...@@ -23,22 +21,22 @@ function getToken() {
23 21
24 // 获取请求头 22 // 获取请求头
25 function getHeaders() { 23 function getHeaders() {
26 let token = getToken() 24 const token = getToken()
27 let header = { 25 const header = {
28 "Authorization": token, 26 'Authorization': token,
29 "Content-Type": "application/json", //根据自己的数据类型 27 'Content-Type': 'application/json' // 根据自己的数据类型
30 // "Content-Type":"application/x-www-form-urlencoded", 28 // "Content-Type":"application/x-www-form-urlencoded",
31 } 29 }
32 return header 30 return header
33 } 31 }
34 32
35 let request = function(req) { 33 const request = function(req) {
36 req.method = req.method.toUpperCase() 34 req.method = req.method.toUpperCase()
37 if (!['GET', 'POST','PUT', 'DELETE'].includes(req.method)) { 35 if (!['GET', 'POST', 'PUT', 'DELETE'].includes(req.method)) {
38 uni.showToast({ 36 uni.showToast({
39 title: `暂不支持的请求方式: ${req.method}`, 37 title: `暂不支持的请求方式: ${req.method}`,
40 icon: 'none' 38 icon: 'none'
41 }); 39 })
42 return 40 return
43 } 41 }
44 42
...@@ -53,36 +51,14 @@ let request = function(req) { ...@@ -53,36 +51,14 @@ let request = function(req) {
53 url: config.baseUrl_api + req.url, 51 url: config.baseUrl_api + req.url,
54 method: req.method, 52 method: req.method,
55 data: req.params, 53 data: req.params,
56 header: getHeaders(), 54 header: getHeaders()
57 }).then(res => { 55 }).then(res => {
58 switch (res.statusCode) { 56 switch (res.statusCode) {
59 case 200: 57 case 200:
60 const data = res.data || {}; 58 const data = res.data || {}
61 if (data.code == 200) { 59 if (data.code === 200) {
62 resolve(data) 60 resolve(data)
63 } else { 61 } else {
64 //登录超时
65 if (data.code == 60002 || data.code == 60001) {
66 if (req.url != '/system/wx/getUserInfo') {
67 reLogin();
68 }
69 }
70 else if (data.code == 401 && req.url != '/system/wx/getUserInfo') {
71 pcLogin()
72 .then(()=>{
73 return getNowOpenId()
74 })
75 .then(()=>{
76 return initData()
77 })
78 .then(()=>{
79 uni.hideLoading();
80 uni.redirectTo({
81 url:getCurrentPages()[getCurrentPages().length-1].$page.fullPath
82 })
83 })
84 }
85 else {
86 if (!excludeUrls.includes(req.url)) { 62 if (!excludeUrls.includes(req.url)) {
87 uni.showToast({ 63 uni.showToast({
88 title: data.msg, 64 title: data.msg,
...@@ -90,7 +66,29 @@ let request = function(req) { ...@@ -90,7 +66,29 @@ let request = function(req) {
90 duration: 3000 66 duration: 3000
91 }) 67 })
92 } 68 }
69
70 // 登录超时
71 if (data.code === 60002 || data.code === 60001) {
72 uni.redirectTo({
73 url: '/pages/index/login'
74 })
75 } else if (data.code === 401) {
76 h5LoginAuto()
77 .then(() => {
78 uni.hideLoading()
79 uni.redirectTo({
80 url: getCurrentPages()[getCurrentPages()
81 .length - 1].$page.fullPath
82 })
83 })
84 .catch(() => {
85 uni.showToast({
86 title: '服务异常,请稍后重试',
87 icon: 'none'
88 })
89 })
93 } 90 }
91
94 reject(res) 92 reject(res)
95 } 93 }
96 break 94 break
...@@ -107,39 +105,4 @@ let request = function(req) { ...@@ -107,39 +105,4 @@ let request = function(req) {
107 }) 105 })
108 } 106 }
109 107
110 function reLogin() { 108 export default request
111 const currUser = uni.getStorageSync('currUser') || {}
112 if (currUser.openId) {
113 const accountInfo = uni.getAccountInfoSync()
114 pcLoginByOpenId(accountInfo.miniProgram.appId, currUser.openId)
115 .then((res) => {
116 let user = res.data;
117 uni.setStorageSync('token', 'Bearer ' + user.token);
118 uni.setStorageSync('currUser', user);
119
120 uni.showToast({
121 title: '一走神把您的操作遗漏了,请重试',
122 icon: 'none'
123 })
124 }).catch(() => {
125 uni.showToast({
126 title: '服务异常,请稍后重试',
127 icon: 'none'
128 })
129 })
130 }
131 }
132
133 function pcLoginByOpenId(appId, openId) {
134 return request({
135 url: "/system/wx/loginByOpenId",
136 method: "POST",
137 params: {
138 appId: appId,
139 openId: openId
140 }
141 })
142 }
143
144
145 export default request;
......
1 // prod 1 // prod
2 // const baseUrl = 'https://research.wtwuxicenter.com/'; 2 // const baseUrl_api = 'https://research.wtwuxicenter.com/';
3 // const baseUrl_api=`${baseUrl}/prod-api`;
4 3
5 // uat
6 // const baseUrl = 'https://jxt.itechtop.cn';
7 const baseUrl = 'https://jxt.wtwuxicenter.com';
8 const baseUrl_api = `${baseUrl}/prod-api`;
9 4
10 // staging 5 // staging
11 // const baseUrl = 'https://5q5re1d432g2.ngrok2.xiaomiqiu123.top'; 6 const baseUrl_api = "http://192.168.1.96:8787";
12
13 // const baseUrl = "http://192.168.1.118:8081";
14 // const baseUrl_api = `${baseUrl}`;
15
16 const fileUrl = "http://r.itechtop.cn";
17 7
18 export default { 8 export default {
19 baseUrl: baseUrl, 9 baseUrl_api
20 fileUrl: fileUrl,
21 baseUrl_api: baseUrl_api,
22 }; 10 };
...\ No newline at end of file ...\ No newline at end of file
......
1 <template> 1 <template>
2 <view>
3 <view class="page-bg"> 2 <view class="page-bg">
4 <image class="ren1" src="@/static/login/ren1.png"/> 3 <image class="ren1" src="@/static/login/ren1.png" />
5 <!-- 登录 --> 4 <!-- 登录 -->
6 <view class="retop"> 5 <view class="retop">
7 <image class="logotop" src="@/static/login/logo@2x.png"></image> 6 <image class="logotop" src="@/static/login/logo@2x.png"></image>
...@@ -15,16 +14,16 @@ ...@@ -15,16 +14,16 @@
15 <form v-if="isActive==0"> 14 <form v-if="isActive==0">
16 <view class="round-input-item"> 15 <view class="round-input-item">
17 <image class="icon" src="@/static/login/tag01@2x.png"></image> 16 <image class="icon" src="@/static/login/tag01@2x.png"></image>
18 <input placeholder="账号"/> 17 <uni-easyinput placeholder="账号" v-model="form.username" />
19 </view> 18 </view>
20 <view class="round-input-item"> 19 <view class="round-input-item">
21 <image class="icon" src="@/static/login/tag02@2x.png"></image> 20 <image class="icon" src="@/static/login/tag02@2x.png"></image>
22 <input placeholder="密码"/> 21 <uni-easyinput placeholder="密码" v-model="form.password" type="password" />
23 </view> 22 </view>
24 <view class="round-input-item"> 23 <view class="round-input-item">
25 <image class="icon" src="@/static/login/tag03@2x.png"></image> 24 <image class="icon" src="@/static/login/tag03@2x.png"></image>
26 <input placeholder="图形验证码"/> 25 <uni-easyinput placeholder="图形验证码" v-model="form.code" />
27 <image/> 26 <image :src="codeUrl" @click="getCode" />
28 </view> 27 </view>
29 28
30 </form> 29 </form>
...@@ -32,28 +31,28 @@ ...@@ -32,28 +31,28 @@
32 <form v-if="isActive==1"> 31 <form v-if="isActive==1">
33 <view class="round-input-item"> 32 <view class="round-input-item">
34 <image class="icon" src="@/static/login/tag01@2x.png"></image> 33 <image class="icon" src="@/static/login/tag01@2x.png"></image>
35 <input placeholder="请输入手机号"/> 34 <input placeholder="请输入手机号" />
36 </view> 35 </view>
37 <view class="round-input-item"> 36 <view class="round-input-item">
38 <image class="icon" src="@/static/login/tag02@2x.png"></image> 37 <image class="icon" src="@/static/login/tag02@2x.png"></image>
39 <input placeholder="图形验证码"/> 38 <input placeholder="图形验证码" />
40 <image/> 39 <image />
41 </view> 40 </view>
42 <view class="round-input-item"> 41 <view class="round-input-item">
43 <image class="icon" src="@/static/login/tag04@2x.png"></image> 42 <image class="icon" src="@/static/login/tag04@2x.png"></image>
44 <input placeholder="短信验证码"/> 43 <input placeholder="短信验证码" />
45 <text>获取验证码</text> 44 <text>获取验证码</text>
46 </view> 45 </view>
47 46
48 </form> 47 </form>
49 48
50 <view class="flex-item"> 49 <view class="flex-item">
51 <view class="member" @click="changeAgree(isRember)"> 50 <!-- <view class="member" @click="changeAgree(isRember)">
52 <image v-if="isRember" src="@/static/login/xz_dwn@2x.png"/> 51 <image v-if="isRember" src="@/static/login/xz_dwn@2x.png" />
53 <image v-else src="@/static/login/xz@2x.png"/> 52 <image v-else src="@/static/login/xz@2x.png" />
54 记住密码 53 记住密码
55 </view> 54 </view>
56 <view class="text-red">忘记密码</view> 55 <view class="text-red">忘记密码</view> -->
57 </view> 56 </view>
58 <view class="center-item"> 57 <view class="center-item">
59 <button @click="login" class="btn-red">登录</button> 58 <button @click="login" class="btn-red">登录</button>
...@@ -67,93 +66,277 @@ ...@@ -67,93 +66,277 @@
67 66
68 </view> 67 </view>
69 </view> 68 </view>
70 <image class="ren2" src="@/static/login/ren2.png"/> 69 <image class="ren2" src="@/static/login/ren2.png" />
71 <view class="fixedagree"> 70 <view class="fixedagree">
72 <image @click="changeAgree(agree)" v-if="agree" src="@/static/login/xz_dwn@2x.png"></image> 71 <image @click="changeAgree(agree)" v-if="agree" src="@/static/login/xz_dwn@2x.png"></image>
73 <image v-else src="@/static/login/xz2@2x.png"></image> 72 <image v-else src="@/static/login/xz2@2x.png"></image>
74 <view>登录即代表您同意<text>《用户协议》</text><text>《隐私策略》</text></view> 73 <view>登录即代表您同意<text>《用户协议》</text><text>《隐私策略》</text></view>
75 </view> 74 </view>
76 </view> 75 </view>
77 </view>
78 </template> 76 </template>
79 77
80 <script setup> 78 <script setup>
81 import { ref } from 'vue' 79 import {
82 const isActive = ref(0) 80 onMounted,
83 const agree = ref(false) 81 ref
84 const isRember = ref(true) 82 } from 'vue'
83
84 import {
85 getCodeImg,
86 pcLogin
87 } from '@/common/login.js'
88
89 const isActive = ref(0)
90 const agree = ref(false)
91 const isRember = ref(true)
92 const codeUrl = ref(null)
93 const form = ref({
94 username: null,
95 password: null,
96 code: null,
97 uuid: null
98 })
99
100 const app = getApp()
85 101
86 function changeActive(n){ 102 onMounted(() => {
103 getCode()
104 })
105
106 function changeActive(n) {
87 isActive.value = n 107 isActive.value = n
88 } 108 }
89 function changeAgree(item){ 109
110
111 function changeAgree(item) {
90 item = !item 112 item = !item
91 } 113 }
92 function login(){ 114
93 let path = '/pages/index/index'; 115 function login() {
94 uni.navigateTo({ 116 pcLogin(form.value)
95 url: path 117 .then(() => {
96 }); 118 app.globalData.isLogin = true
97 } 119 uni.redirectTo({
98 function goRegister(){ 120 url: '/pages/index/index'
99 let path = '/pages/index/register'; 121 })
122 })
123 .catch(getCode)
124 }
125
126 function goRegister() {
127 const path = '/pages/index/register'
100 uni.navigateTo({ 128 uni.navigateTo({
101 url: path 129 url: path
102 }); 130 })
103 } 131 }
132
133 function getCode() {
134 getCodeImg().then((res) => {
135 codeUrl.value = 'data:image/gif;base64,' + res.data.img
136 form.value.uuid = res.data.uuid
137 })
138 }
104 </script> 139 </script>
105 140
106 <style scoped lang="scss"> 141 <style scoped lang="scss">
107 .logotop{width: 510rpx;height: 215rpx;margin:5vh auto 40rpx;display: block;} 142 .logotop {
108 .ren1{width: 300rpx;height: 560rpx;position: absolute;right: 0;top: 0;} 143 width: 510rpx;
109 .ren2{width: 456rpx;height:600rpx;position: relative;top: 20rpx;} 144 height: 215rpx;
110 .retop{position: relative;z-index: 1;} 145 margin: 5vh auto 40rpx;
111 .page-bg{background: url('@/static/login/bg.png') no-repeat center; 146 display: block;
147 }
148
149 .ren1 {
150 width: 300rpx;
151 height: 560rpx;
152 position: absolute;
153 right: 0;
154 top: 0;
155 }
156
157 .ren2 {
158 width: 456rpx;
159 height: 600rpx;
160 position: relative;
161 top: 20rpx;
162 }
163
164 .retop {
165 position: relative;
166 z-index: 1;
167 }
168
169 .page-bg {
170 background: url('@/static/login/bg.png') no-repeat center;
112 background-size: cover; 171 background-size: cover;
113 height: 100vh;overflow: hidden;position: relative; 172 height: 100vh;
173 overflow: hidden;
174 position: relative;
175 }
176
177 .loginbox {
178 .loginNav {
179 width: 700rpx;
180 margin: 0 auto -53rpx;
181 height: 133rpx;
182 overflow: hidden;
183 position: relative;
184
185 view {
186 text-align: center;
187 height: 133rpx;
188 box-sizing: border-box;
189 padding: 26rpx 0 0;
190 }
191
192 .n1 {
193 background: url('@/static/login/tab1.png') no-repeat top left;
194 background-size: contain;
195 opacity: 0.7;
196 width: 407rpx;
197 position: absolute;
198 left: 0;
199 }
200
201 .n2 {
202 background: url('@/static/login/tab2.png') no-repeat top right;
203 background-size: contain;
204 opacity: 0.7;
205 width: 399rpx;
206 position: absolute;
207 right: 0;
114 } 208 }
115 .loginbox{ 209
116 .loginNav{width: 700rpx;margin:0 auto -53rpx;height: 133rpx;overflow: hidden;position: relative; 210 .active {
117 view{text-align: center;height: 133rpx;box-sizing: border-box;padding: 26rpx 0 0;} 211 color: #AD181F;
118 .n1{background: url('@/static/login/tab1.png') no-repeat top left;background-size:contain;opacity: 0.7; 212 opacity: 1;
119 width: 407rpx;position: absolute;left: 0;} 213
120 .n2{background: url('@/static/login/tab2.png') no-repeat top right;background-size:contain;opacity: 0.7; 214 &::after {
121 width: 399rpx;position: absolute;right: 0;} 215 content: '';
122 .active{color: #AD181F;opacity: 1; 216 position: absolute;
123 &::after{content: '';position: absolute;width: 25rpx;height: 4rpx;background: #AD181F;border-radius: 2rpx; 217 width: 25rpx;
124 left: 0;right: 0;margin: auto;bottom: 50rpx; 218 height: 4rpx;
219 background: #AD181F;
220 border-radius: 2rpx;
221 left: 0;
222 right: 0;
223 margin: auto;
224 bottom: 50rpx;
125 } 225 }
126 } 226 }
127 } 227 }
128 } 228 }
129 .formbox{background: #fff;width: 700rpx;padding: 50rpx;margin: auto;border-radius: 20rpx;} 229
130 .flex-item{display: flex;justify-content: space-between;margin:30rpx 0; 230 .formbox {
231 background: #fff;
232 width: 700rpx;
233 padding: 50rpx;
234 margin: auto;
235 border-radius: 20rpx;
236 }
237
238 .flex-item {
239 display: flex;
240 justify-content: space-between;
241 margin: 30rpx 0;
131 font-size: 28rpx; 242 font-size: 28rpx;
132 image{width: 30rpx;height: 30rpx;margin-right:16rpx;} 243
244 image {
245 width: 30rpx;
246 height: 30rpx;
247 margin-right: 16rpx;
248 }
249 }
250
251 .member {
252 color: #4C5359;
253 display: flex;
254 align-items: center;
255 }
256
257 .center-item {
258 text-align: center;
259 margin: 30rpx 0 0;
260 font-size: 30rpx;
261
262 .btn-red {
263 border-radius: 40rpx;
264 width: 600rpx;
265 line-height: 80rpx;
266 font-size: 36rpx;
133 } 267 }
134 .member{color: #4C5359;display: flex;align-items: center;}
135 .center-item{text-align: center;margin: 30rpx 0 0;font-size: 30rpx;
136 .btn-red{border-radius: 40rpx;width: 600rpx;line-height: 80rpx;font-size: 36rpx;}
137 } 268 }
138 .btn-red{background: #AD181F;color: #fff;} 269
139 .text-red{color: #AD181F;} 270 .btn-red {
140 .round-input-item{overflow: hidden;background: RGBA(247, 247, 248, 1);border-radius: 40rpx; 271 background: #AD181F;
272 color: #fff;
273 }
274
275 .text-red {
276 color: #AD181F;
277 }
278
279 .round-input-item {
280 overflow: hidden;
281 background: RGBA(247, 247, 248, 1);
282 border-radius: 40rpx;
141 padding: 0 0 0 30rpx; 283 padding: 0 0 0 30rpx;
142 height: 80rpx;margin-bottom: 30rpx;display: flex;align-items: center; 284 height: 80rpx;
143 image{width: 180rpx;height: 80rpx; 285 margin-bottom: 30rpx;
144 &.icon{width: 30rpx;height: 30rpx;margin-right:16rpx;} 286 display: flex;
287 align-items: center;
288
289 image {
290 width: 180rpx;
291 height: 80rpx;
292
293 &.icon {
294 width: 30rpx;
295 height: 30rpx;
296 margin-right: 16rpx;
297 }
145 } 298 }
146 input{border-left: 1rpx solid RGBA(214, 216, 219, 1);padding: 0 0 0 20rpx;font-size: 30rpx; 299
300 input {
301 border-left: 1rpx solid RGBA(214, 216, 219, 1);
302 padding: 0 0 0 20rpx;
303 font-size: 30rpx;
304 }
305
306 input::-webkit-input-placeholder {
307 color: RGBA(158, 166, 174, 1);
308 font-size: 30rpx;
147 } 309 }
148 input::-webkit-input-placeholder{color:RGBA(158, 166, 174, 1);font-size: 30rpx;}
149 input::placeholder{color:RGBA(158, 166, 174, 1);font-size: 30rpx;}
150 input::-moz-placeholder{color:RGBA(158, 166, 174, 1);font-size: 30rpx;}
151 310
152 text{font-size: 28rpx;color: #014A9F;} 311 input::placeholder {
312 color: RGBA(158, 166, 174, 1);
313 font-size: 30rpx;
153 } 314 }
154 315
155 .fixedagree{position: fixed;bottom: 5vh;color: rgba(255, 255, 255, 0.7);display: flex; 316 input::-moz-placeholder {
156 font-size: 24rpx;width: 100vw;justify-content: center; 317 color: RGBA(158, 166, 174, 1);
157 image{width: 40rpx;height: 40rpx;margin-right: 20rpx;} 318 font-size: 30rpx;
319 }
320
321 text {
322 font-size: 28rpx;
323 color: #014A9F;
324 }
325 }
326
327 .fixedagree {
328 position: fixed;
329 bottom: 5vh;
330 color: rgba(255, 255, 255, 0.7);
331 display: flex;
332 font-size: 24rpx;
333 width: 100vw;
334 justify-content: center;
335
336 image {
337 width: 40rpx;
338 height: 40rpx;
339 margin-right: 20rpx;
340 }
158 } 341 }
159 </style> 342 </style>
...\ No newline at end of file ...\ No newline at end of file
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!