c49a1142 by 杨炀

Merge commit '023f830b'

2 parents c579d87a 023f830b
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
8 let loginUrl=['pages/index/login', 'pages/index/register']
9 let firstload = false
10 export default {
11 onLaunch: function(options) {
12 console.log('App Launch', options);
13 firstload = true
6 14
7 let firstload = false 15 this.globalData.baseUrl_api = config.baseUrl_api;
8 export default { 16
9 onLaunch: function() { 17 if(loginUrl.indexOf( options.path)==-1){
10 console.log('App Launch'); 18 let userName = uni.getStorageSync('userName')
11 firstload = true 19 if (userName) {
12 this.globalData.baseUrl = config.baseUrl; 20 h5Login(userName)
13 this.globalData.baseUrl_api = config.baseUrl_api; 21 .then(() => {
14 this.globalData.fileUrl = config.fileUrl; 22 this.globalData.isLogin = true;
15 23 let firstLoadCallback = getApp().firstLoadCallback;
16 new Promise((resolve, reject) => { 24 if (firstLoadCallback) {
17 uni.checkSession({ 25 firstLoadCallback();
18 success: res => { 26 }
19 loginServer 27 })
20 .getCurrUser(true) 28 .catch(() => {
21 .catch(() => { 29 uni.redirectTo({
22 return loginServer.pcLogin(); 30 url: '/pages/index/login'
23 }) 31 })
24 .then(user => { 32 })
25 resolve(user); 33 } else {
26 }); 34 this.globalData.isLogin = false;
27 }, 35 uni.redirectTo({
28 fail: res => { 36 url: '/pages/index/login'
29 loginServer 37 })
30 .wxLogin() 38 }
31 .then(loginRes => { 39 }
32 return loginServer.pcLogin(loginRes.code); 40 },
33 }) 41 onShow: function() {
34 .then(user => { 42 console.log('App Show');
35 resolve(user); 43 },
36 }); 44 onHide: function() {
37 } 45 console.log('App Hide');
38 }); 46 }
39 }) 47 };
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
62 // this.globalData.venue = ven;
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
68 // this.globalData.venueConfig = {
69 // normalOverDay: ven.resSiteConfig?.normalOrderNum,
70 // normalPeriodStart: ven.resSiteConfig?.normalOrderPeriod.split(',')[0],
71 // normalPeriodEnd: ven.resSiteConfig?.normalOrderPeriod.split(',')[1]
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(() => {
81 this.globalData.isLogin = true;
82 let firstLoadCallback = getApp().firstLoadCallback;
83 if (firstLoadCallback) {
84 firstLoadCallback();
85 }
86 });
87 },
88 onShow: function() {
89 console.log('App Show');
90 // loginServer.getNowOpenId()
91 if (!firstload) {
92 loginServer.getCurrUser(true)
93 .catch(() => {
94 return loginServer.pcLogin().then(() => {
95 uni.redirectTo({
96 url: getCurrentPages()[getCurrentPages().length - 1].$page.fullPath
97 })
98 });
99 })
100 }
101 },
102 onHide: function() {
103 console.log('App Hide');
104 }
105 };
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() {
11 return new Promise((resolve, reject) => { 11 return new Promise((resolve, reject) => {
12 uni.login({ 12 uni.login({
13 provider: 'weixin', 13 provider: 'weixin',
14 success: (res) => { 14 success: (res) => {
15 // console.log(res.code); 15 // console.log(res.code);
16 resolve(res) 16 resolve(res)
17 }, 17 },
18 fail: (res) => { 18 fail: (res) => {
19 reject(res) 19 reject(res)
20 } 20 }
21 }) 21 })
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) => { 33 })
34 return pcLoginByCode(loginRes.code)
35 })
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 42 }
47 } 43 }).then((res) => {
48 }).then((res) => { 44 uni.setStorageSync('token', 'Bearer ' + res.data.token)
49 let user = res.data; 45 })
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 })
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 55 })
68 } 56 }
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 })
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) {
103 console.log(infoRes) 81 console.log(infoRes)
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,
111 userId: currUser.id, 89 userId: currUser.id,
112 encryptedData: infoRes.encryptedData, 90 encryptedData: infoRes.encryptedData,
113 errMsg: infoRes.errMsg, 91 errMsg: infoRes.errMsg,
114 iv: infoRes.iv, 92 iv: infoRes.iv,
115 rawData: infoRes.rawData, 93 rawData: infoRes.rawData,
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 })
125 }, 103 },
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,
145 encryptedData: phoneRes.encryptedData, 123 encryptedData: phoneRes.encryptedData,
146 errMsg: phoneRes.errMsg, 124 errMsg: phoneRes.errMsg,
147 iv: phoneRes.iv, 125 iv: phoneRes.iv,
148 rawData: phoneRes.rawData, 126 rawData: phoneRes.rawData,
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 }
159 137
160 function checkUserAuth(path) { 138 function checkUserAuth(path) {
161 const currUser = uni.getStorageSync('currUser') 139 const currUser = uni.getStorageSync('currUser')
162 if (currUser.phonenumber) { 140 if (currUser.phonenumber) {
163 // if (currUser.nickName) { 141 // if (currUser.nickName) {
164 return true 142 return true
165 } else { 143 } else {
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
173 function getNowOpenId() { 151 function getNowOpenId() {
174 console.log('getNowOpenId') 152 console.log('getNowOpenId')
175 return request({ 153 return request({
176 url: `/system/user/getMyOpenId/${appId}`, 154 url: `/system/user/getMyOpenId/${appId}`,
177 method: 'get' 155 method: 'get'
178 }).then((res) => { 156 }).then((res) => {
179 uni.setStorageSync('nowOpenId', res.msg) 157 uni.setStorageSync('nowOpenId', res.msg)
180 }) 158 })
181 } 159 }
182 160
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 {
224 getNowOpenId,
225 wxLogin,
226 pcLogin,
227 getCurrUser,
228 getWxUser,
229 getWxUserPhone,
230 checkUserAuth,
231 initData
232 }
...\ No newline at end of file ...\ No newline at end of file
209 getNowOpenId,
210 wxLogin,
211 pcLogin,
212 getCurrUser,
213 getWxUser,
214 getWxUserPhone,
215 checkUserAuth,
216 initData,
217 getCodeImg,
218 h5Login,
219 h5LoginAuto
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 {
17 return '' 15 return ''
18 } 16 }
19 } catch (e) { 17 } catch (e) {
20 console.log(e) 18 console.log(e)
21 } 19 }
22 } 20 }
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
45 // if (req.method == 'POST' && !req.hideLoding) { 43 // if (req.method == 'POST' && !req.hideLoding) {
46 // uni.showLoading({ 44 // uni.showLoading({
47 // title: '提交中...' 45 // title: '提交中...'
48 // }) 46 // })
49 // } 47 // }
50 48
51 return new Promise((resolve, reject) => { 49 return new Promise((resolve, reject) => {
52 uni.request({ 50 uni.request({
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 //登录超时 62 if (!excludeUrls.includes(req.url)) {
65 if (data.code == 60002 || data.code == 60001) { 63 uni.showToast({
66 if (req.url != '/system/wx/getUserInfo') { 64 title: data.msg,
67 reLogin(); 65 icon: 'none',
68 } 66 duration: 3000
69 } 67 })
70 else if (data.code == 401 && req.url != '/system/wx/getUserInfo') { 68 }
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)) {
87 uni.showToast({
88 title: data.msg,
89 icon: 'none',
90 duration: 3000
91 })
92 }
93 }
94 reject(res)
95 }
96 break
97 default:
98 reject(res)
99 }
100 }).catch(res => {
101 reject(res)
102 }).finally(() => {
103 // if (req.method == 'POST' && !req.hideLoding) {
104 // uni.hideLoading()
105 // }
106 })
107 })
108 }
109
110 function reLogin() {
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 69
120 uni.showToast({ 70 // 登录超时
121 title: '一走神把您的操作遗漏了,请重试', 71 if (data.code === 60002 || data.code === 60001) {
122 icon: 'none' 72 uni.redirectTo({
123 }) 73 url: '/pages/index/login'
124 }).catch(() => { 74 })
125 uni.showToast({ 75 } else if (data.code === 401) {
126 title: '服务异常,请稍后重试', 76 h5LoginAuto()
127 icon: 'none' 77 .then(() => {
128 }) 78 uni.hideLoading()
129 }) 79 uni.redirectTo({
130 } 80 url: getCurrentPages()[getCurrentPages()
81 .length - 1].$page.fullPath
82 })
83 })
84 .catch(() => {
85 uni.showToast({
86 title: '服务异常,请稍后重试',
87 icon: 'none'
88 })
89 })
90 }
91
92 reject(res)
93 }
94 break
95 default:
96 reject(res)
97 }
98 }).catch(res => {
99 reject(res)
100 }).finally(() => {
101 // if (req.method == 'POST' && !req.hideLoding) {
102 // uni.hideLoading()
103 // }
104 })
105 })
131 } 106 }
132 107
133 function pcLoginByOpenId(appId, openId) { 108 export default request
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> 2 <view class="page-bg">
3 <view class="page-bg"> 3 <image class="ren1" src="@/static/login/ren1.png" />
4 <image class="ren1" src="@/static/login/ren1.png"/> 4 <!-- 登录 -->
5 <!-- 登录 --> 5 <view class="retop">
6 <view class="retop"> 6 <image class="logotop" src="@/static/login/logo@2x.png"></image>
7 <image class="logotop" src="@/static/login/logo@2x.png"></image> 7 <view class="loginbox">
8 <view class="loginbox"> 8 <view class="loginNav">
9 <view class="loginNav"> 9 <view class="n1" :class="isActive==0?'active':''" @click="changeActive(0)">密码登录</view>
10 <view class="n1" :class="isActive==0?'active':''" @click="changeActive(0)">密码登录</view> 10 <view class="n2" :class="isActive==1?'active':''" @click="changeActive(1)">短信登录</view>
11 <view class="n2" :class="isActive==1?'active':''" @click="changeActive(1)">短信登录</view> 11 </view>
12 </view> 12 <!-- 密码登录 -->
13 <!-- 密码登录 --> 13 <view class="formbox">
14 <view class="formbox"> 14 <form v-if="isActive==0">
15 <form v-if="isActive==0"> 15 <view class="round-input-item">
16 <view class="round-input-item"> 16 <image class="icon" src="@/static/login/tag01@2x.png"></image>
17 <image class="icon" src="@/static/login/tag01@2x.png"></image> 17 <uni-easyinput placeholder="账号" v-model="form.username" />
18 <input placeholder="账号"/> 18 </view>
19 </view> 19 <view class="round-input-item">
20 <view class="round-input-item"> 20 <image class="icon" src="@/static/login/tag02@2x.png"></image>
21 <image class="icon" src="@/static/login/tag02@2x.png"></image> 21 <uni-easyinput placeholder="密码" v-model="form.password" type="password" />
22 <input placeholder="密码"/> 22 </view>
23 </view> 23 <view class="round-input-item">
24 <view class="round-input-item"> 24 <image class="icon" src="@/static/login/tag03@2x.png"></image>
25 <image class="icon" src="@/static/login/tag03@2x.png"></image> 25 <uni-easyinput placeholder="图形验证码" v-model="form.code" />
26 <input placeholder="图形验证码"/> 26 <image :src="codeUrl" @click="getCode" />
27 <image/> 27 </view>
28 </view> 28
29 29 </form>
30 </form> 30 <!-- 短信登录 -->
31 <!-- 短信登录 --> 31 <form v-if="isActive==1">
32 <form v-if="isActive==1"> 32 <view class="round-input-item">
33 <view class="round-input-item"> 33 <image class="icon" src="@/static/login/tag01@2x.png"></image>
34 <image class="icon" src="@/static/login/tag01@2x.png"></image> 34 <input placeholder="请输入手机号" />
35 <input placeholder="请输入手机号"/> 35 </view>
36 </view> 36 <view class="round-input-item">
37 <view class="round-input-item"> 37 <image class="icon" src="@/static/login/tag02@2x.png"></image>
38 <image class="icon" src="@/static/login/tag02@2x.png"></image> 38 <input placeholder="图形验证码" />
39 <input placeholder="图形验证码"/> 39 <image />
40 <image/> 40 </view>
41 </view> 41 <view class="round-input-item">
42 <view class="round-input-item"> 42 <image class="icon" src="@/static/login/tag04@2x.png"></image>
43 <image class="icon" src="@/static/login/tag04@2x.png"></image> 43 <input placeholder="短信验证码" />
44 <input placeholder="短信验证码"/> 44 <text>获取验证码</text>
45 <text>获取验证码</text> 45 </view>
46 </view> 46
47 47 </form>
48 </form> 48
49 49 <view class="flex-item">
50 <view class="flex-item"> 50 <!-- <view class="member" @click="changeAgree(isRember)">
51 <view class="member" @click="changeAgree(isRember)"> 51 <image v-if="isRember" src="@/static/login/xz_dwn@2x.png" />
52 <image v-if="isRember" src="@/static/login/xz_dwn@2x.png"/> 52 <image v-else src="@/static/login/xz@2x.png" />
53 <image v-else src="@/static/login/xz@2x.png"/> 53 记住密码
54 记住密码 54 </view>
55 </view> 55 <view class="text-red">忘记密码</view> -->
56 <view class="text-red">忘记密码</view> 56 </view>
57 </view> 57 <view class="center-item">
58 <view class="center-item"> 58 <button @click="login" class="btn-red">登录</button>
59 <button @click="login" class="btn-red">登录</button> 59 </view>
60 </view> 60 <view class="center-item">
61 <view class="center-item"> 61 <text class="text-red" @click="goRegister">没有账号,去注册</text>
62 <text class="text-red" @click="goRegister">没有账号,去注册</text> 62 </view>
63 </view> 63
64 64 </view>
65 </view> 65
66 66
67 67 </view>
68 </view> 68 </view>
69 </view> 69 <image class="ren2" src="@/static/login/ren2.png" />
70 <image class="ren2" src="@/static/login/ren2.png"/> 70 <view class="fixedagree">
71 <view class="fixedagree"> 71 <image @click="changeAgree(agree)" v-if="agree" src="@/static/login/xz_dwn@2x.png"></image>
72 <image @click="changeAgree(agree)" v-if="agree" src="@/static/login/xz_dwn@2x.png"></image> 72 <image v-else src="@/static/login/xz2@2x.png"></image>
73 <image v-else src="@/static/login/xz2@2x.png"></image> 73 <view>登录即代表您同意<text>《用户协议》</text><text>《隐私策略》</text></view>
74 <view>登录即代表您同意<text>《用户协议》</text><text>《隐私策略》</text></view> 74 </view>
75 </view> 75 </view>
76 </view> 76 </template>
77 </view> 77
78 </template> 78 <script setup>
79 79 import {
80 <script setup> 80 onMounted,
81 import { ref } from 'vue' 81 ref
82 const isActive = ref(0) 82 } from 'vue'
83 const agree = ref(false) 83
84 const isRember = ref(true) 84 import {
85 85 getCodeImg,
86 function changeActive(n){ 86 pcLogin
87 isActive.value = n 87 } from '@/common/login.js'
88 } 88
89 function changeAgree(item){ 89 const isActive = ref(0)
90 item = !item 90 const agree = ref(false)
91 } 91 const isRember = ref(true)
92 function login(){ 92 const codeUrl = ref(null)
93 let path = '/pages/index/index'; 93 const form = ref({
94 uni.navigateTo({ 94 username: null,
95 url: path 95 password: null,
96 }); 96 code: null,
97 } 97 uuid: null
98 function goRegister(){ 98 })
99 let path = '/pages/index/register'; 99
100 uni.navigateTo({ 100 const app = getApp()
101 url: path 101
102 }); 102 onMounted(() => {
103 } 103 getCode()
104 </script> 104 })
105 105
106 <style scoped lang="scss"> 106 function changeActive(n) {
107 .logotop{width: 510rpx;height: 215rpx;margin:5vh auto 40rpx;display: block;} 107 isActive.value = n
108 .ren1{width: 300rpx;height: 560rpx;position: absolute;right: 0;top: 0;} 108 }
109 .ren2{width: 456rpx;height:600rpx;position: relative;top: 20rpx;} 109
110 .retop{position: relative;z-index: 1;} 110
111 .page-bg{background: url('@/static/login/bg.png') no-repeat center; 111 function changeAgree(item) {
112 background-size: cover; 112 item = !item
113 height: 100vh;overflow: hidden;position: relative; 113 }
114 } 114
115 .loginbox{ 115 function login() {
116 .loginNav{width: 700rpx;margin:0 auto -53rpx;height: 133rpx;overflow: hidden;position: relative; 116 pcLogin(form.value)
117 view{text-align: center;height: 133rpx;box-sizing: border-box;padding: 26rpx 0 0;} 117 .then(() => {
118 .n1{background: url('@/static/login/tab1.png') no-repeat top left;background-size:contain;opacity: 0.7; 118 app.globalData.isLogin = true
119 width: 407rpx;position: absolute;left: 0;} 119 uni.redirectTo({
120 .n2{background: url('@/static/login/tab2.png') no-repeat top right;background-size:contain;opacity: 0.7; 120 url: '/pages/index/index'
121 width: 399rpx;position: absolute;right: 0;} 121 })
122 .active{color: #AD181F;opacity: 1; 122 })
123 &::after{content: '';position: absolute;width: 25rpx;height: 4rpx;background: #AD181F;border-radius: 2rpx; 123 .catch(getCode)
124 left: 0;right: 0;margin: auto;bottom: 50rpx; 124 }
125 } 125
126 } 126 function goRegister() {
127 } 127 const path = '/pages/index/register'
128 } 128 uni.navigateTo({
129 .formbox{background: #fff;width: 700rpx;padding: 50rpx;margin: auto;border-radius: 20rpx;} 129 url: path
130 .flex-item{display: flex;justify-content: space-between;margin:30rpx 0; 130 })
131 font-size: 28rpx; 131 }
132 image{width: 30rpx;height: 30rpx;margin-right:16rpx;} 132
133 } 133 function getCode() {
134 .member{color: #4C5359;display: flex;align-items: center;} 134 getCodeImg().then((res) => {
135 .center-item{text-align: center;margin: 30rpx 0 0;font-size: 30rpx; 135 codeUrl.value = 'data:image/gif;base64,' + res.data.img
136 .btn-red{border-radius: 40rpx;width: 600rpx;line-height: 80rpx;font-size: 36rpx;} 136 form.value.uuid = res.data.uuid
137 } 137 })
138 .btn-red{background: #AD181F;color: #fff;} 138 }
139 .text-red{color: #AD181F;} 139 </script>
140 .round-input-item{overflow: hidden;background: RGBA(247, 247, 248, 1);border-radius: 40rpx; 140
141 padding: 0 0 0 30rpx; 141 <style scoped lang="scss">
142 height: 80rpx;margin-bottom: 30rpx;display: flex;align-items: center; 142 .logotop {
143 image{width: 180rpx;height: 80rpx; 143 width: 510rpx;
144 &.icon{width: 30rpx;height: 30rpx;margin-right:16rpx;} 144 height: 215rpx;
145 } 145 margin: 5vh auto 40rpx;
146 input{border-left: 1rpx solid RGBA(214, 216, 219, 1);padding: 0 0 0 20rpx;font-size: 30rpx; 146 display: block;
147 } 147 }
148 input::-webkit-input-placeholder{color:RGBA(158, 166, 174, 1);font-size: 30rpx;} 148
149 input::placeholder{color:RGBA(158, 166, 174, 1);font-size: 30rpx;} 149 .ren1 {
150 input::-moz-placeholder{color:RGBA(158, 166, 174, 1);font-size: 30rpx;} 150 width: 300rpx;
151 151 height: 560rpx;
152 text{font-size: 28rpx;color: #014A9F;} 152 position: absolute;
153 } 153 right: 0;
154 154 top: 0;
155 .fixedagree{position: fixed;bottom: 5vh;color: rgba(255, 255, 255, 0.7);display: flex; 155 }
156 font-size: 24rpx;width: 100vw;justify-content: center; 156
157 image{width: 40rpx;height: 40rpx;margin-right: 20rpx;} 157 .ren2 {
158 } 158 width: 456rpx;
159 </style> 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;
171 background-size: cover;
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;
208 }
209
210 .active {
211 color: #AD181F;
212 opacity: 1;
213
214 &::after {
215 content: '';
216 position: absolute;
217 width: 25rpx;
218 height: 4rpx;
219 background: #AD181F;
220 border-radius: 2rpx;
221 left: 0;
222 right: 0;
223 margin: auto;
224 bottom: 50rpx;
225 }
226 }
227 }
228 }
229
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;
242 font-size: 28rpx;
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;
267 }
268 }
269
270 .btn-red {
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;
283 padding: 0 0 0 30rpx;
284 height: 80rpx;
285 margin-bottom: 30rpx;
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 }
298 }
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;
309 }
310
311 input::placeholder {
312 color: RGBA(158, 166, 174, 1);
313 font-size: 30rpx;
314 }
315
316 input::-moz-placeholder {
317 color: RGBA(158, 166, 174, 1);
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 }
341 }
342 </style>
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -85,7 +85,7 @@ ...@@ -85,7 +85,7 @@
85 85
86 const app = getApp(); 86 const app = getApp();
87 const projectList = ref([]); 87 const projectList = ref([]);
88 const priceTable = ref([]); 88 const priceTable = ref([]);
89 const czList = ref([]); 89 const czList = ref([]);
90 const isActive = ref(0); 90 const isActive = ref(0);
91 const popup = ref(null); 91 const popup = ref(null);
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!