Commit 6ab4cd79 by LJM

js

parent 34888d11
Showing with 138 additions and 55 deletions
...@@ -49,16 +49,16 @@ ...@@ -49,16 +49,16 @@
<!-- 普通登录 --> <!-- 普通登录 -->
<template v-else> <template v-else>
<view class="input-box code row bothSide verCenter mb40"> <view class="input-box code row bothSide verCenter mb40">
<input type="number" placeholder="请输入手机号码/邮箱" placeholder-style="color:#919399;" class="uni-input" /> <input type="number" placeholder="请输入手机号码/邮箱" placeholder-style="color:#919399;" class="uni-input" v-model="formParams.account" />
<text class="code" @click="login_type = true">国际手机</text> <text class="code" @click="login_type = true">国际手机</text>
</view> </view>
<view class="input-box verification-code row bothSide verCenter" style="margin-bottom: 24rpx;"> <view class="input-box verification-code row bothSide verCenter" style="margin-bottom: 24rpx;" v-if="verify_flag">
<input type="text" placeholder="请输入图中字符,不区分大小写" placeholder-style="color:#919399;" class="uni-input" /> <input type="text" placeholder="请输入图中字符,不区分大小写" placeholder-style="color:#919399;" class="uni-input" v-model="formParams.verify" />
<image src="https://www.ichunt.com/v3/public/verify" class="pic"></image> <image :src="url" class="pic" @click="refresh()"></image>
</view> </view>
</template> </template>
<view class="input-box pwd row bothSide verCenter mb40"> <view class="input-box pwd row bothSide verCenter mb40">
<input type="number" placeholder="请输入密码" placeholder-style="color:#919399;" class="uni-input" /> <input type="number" placeholder="请输入密码" placeholder-style="color:#919399;" class="uni-input" v-model="formParams.pwd" />
<text class="iconfont icon-a-juxingbeifen14"></text> <text class="iconfont icon-a-juxingbeifen14"></text>
</view> </view>
</template> </template>
...@@ -73,6 +73,7 @@ ...@@ -73,6 +73,7 @@
<script> <script>
import { Ichunt_Api, Api_Url } from '@/util/api.js'; import { Ichunt_Api, Api_Url } from '@/util/api.js';
import { setCookie } from '@/util/util.js';
export default { export default {
data() { data() {
return { return {
...@@ -80,10 +81,19 @@ export default { ...@@ -80,10 +81,19 @@ export default {
index: 0, index: 0,
curr: 1, curr: 1,
text_item: ['免密登录/注册', '账号登录'], text_item: ['免密登录/注册', '账号登录'],
array: ['0086', '00886', '00853', '00852'] array: ['0086', '00886', '00853', '00852'],
verify_flag: false, //是否显示验证码
url: Ichunt_Api + '/public/verify',
formParams: {
account: '18682159081',
pwd: '123456',
verify: ''
}
}; };
}, },
onLoad() {}, onLoad() {
console.log(Ichunt_Api);
},
methods: { methods: {
bindPickerChange: function(e, type) { bindPickerChange: function(e, type) {
console.log('picker发送选择改变,携带值为', e.detail.value); console.log('picker发送选择改变,携带值为', e.detail.value);
...@@ -91,9 +101,46 @@ export default { ...@@ -91,9 +101,46 @@ export default {
tab(index) { tab(index) {
this.curr = index; this.curr = index;
}, },
/**
* 刷新验证码
*/
refresh() {
this.url = Ichunt_Api + '/public/verify?time=' + new Date().getTime();
},
submit() { submit() {
this.request(Api_Url + '/login/action', 'GET', {}).then(res => { this.request(Api_Url + '/login/action', 'POST', this.formParams, true, true).then(res => {
console.log(res); if (res.err_code === 0) {
this.verify_flag = false;
uni.showToast({
title: '登录成功',
icon: 'success'
});
setCookie('Yo4teW_csrf', res.data.cookie.Yo4teW_csrf, 7);
setCookie('Yo4teW_gid', res.data.cookie.Yo4teW_gid, 7);
setCookie('Yo4teW_uid', res.data.cookie.Yo4teW_uid, 7);
uni.navigateBack({
delta: 1
});
} else if (res.err_code === 10001 || res.err_code === 10002) {
uni.showModal({
itle: '提示',
content: res.err_msg,
showCancel: false,
success: res => {
if (res.confirm) {
this.verify_flag = true;
} else if (res.cancel) {
}
}
});
} else {
this.verify_flag = false;
uni.showModal({
itle: '提示',
content: res.err_msg,
showCancel: false
});
}
}); });
} }
} }
......
let Ichunt_Api = ''; //3.0网站接口 let Ichunt_Api = ''; //3.0网站接口
let Api_Url = '';//api项目url let Api_Url = ''; //api项目url
let Api_Es = '';//api项目url let Api_Es = ''; //api项目url
let Api_ES_Go='';//型号联想 let Api_ES_Go = ''; //型号联想
switch (window.location.hostname) { switch (window.location.hostname) {
case "m.ichunt.com": case "m.ichunt.com":
Ichunt_Api = 'https://www.ichunt.com/v3'; Ichunt_Api = 'https://www.ichunt.com/v3';
Api_Url="https://api.ichunt.com" Api_Url = "https://api.ichunt.com"
Api_Es="//so12.ichunt.com" Api_Es = "//so12.ichunt.com"
Api_ES_Go="https://s.ichunt.com" Api_ES_Go = "https://s.ichunt.com"
break; break;
default: default:
//本地proxy配置参考vue.config.js //本地proxy配置参考vue.config.js
Ichunt_Api = '/v3' Ichunt_Api = '/v3'
Api_Url= '/apis'; Api_Url = '/apis';
Api_Es="/es" Api_Es = "/es"
Api_ES_Go="http://192.168.1.237:9008" Api_ES_Go = "http://192.168.1.237:9008"
} }
module.exports = { module.exports = {
Ichunt_Api, Ichunt_Api,
Api_Url, Api_Url,
Api_Es, Api_Es,
Api_ES_Go Api_ES_Go
} }
\ No newline at end of file
...@@ -2,33 +2,43 @@ import API_BASE from '../util/api.js' ...@@ -2,33 +2,43 @@ import API_BASE from '../util/api.js'
/** /**
* 请求封装 * 请求封装
*/ */
const request = (url = '', type = 'GET', param = {}, Loading,headertype) => { const request = (url = '', type = 'GET', param = {}, Loading, headertype) => {
const oa_user_id = uni.getStorageSync('oa_user_id') || ''; const Yo4teW_csrf = getCookie('Yo4teW_csrf') || '';
const oa_skey = uni.getStorageSync('oa_skey') || ''; const Yo4teW_gid = getCookie('Yo4teW_gid') || '';
const Yo4teW_uid = getCookie('Yo4teW_uid') || '';
var params = Object.assign(param, {
pf: 2
});
//请求es相关
if(url&&(url.indexOf("so12.ichunt.")!=-1||url.indexOf("so.liexin.net")!=-1)){
params = Object.assign(param, {
hkyefgyd: 1
});
}
//是否启动加载 //是否启动加载
if (Loading) { if (Loading) {
uni.showLoading({ uni.showLoading({
mask: true mask: true
}); });
} }
let header={
"Content-Type": "application/json; charset=utf-8" //h5统一携带参数pf
} var params = Object.assign(param, {
if (headertype) { pf: 2
header={ });
'Content-Type': 'application/x-www-form-urlencoded'
} //请求es相关
if (url && (url.indexOf("so12.ichunt.") != -1 || url.indexOf("so.liexin.net") != -1)) {
params = Object.assign({ hkyefgyd: 1 });
}
//如果uid没有,就添加参数ygagatetffafa,绕过验证登录
if (!Yo4teW_csrf && !Yo4teW_gid && !Yo4teW_uid) {
params = Object.assign({ ygagatetffafa: 1 });
}
//请求类型判断
let header = {
"Content-Type": "application/json; charset=utf-8"
}
if (headertype) {
header = {
'Content-Type': 'application/x-www-form-urlencoded'
}
} }
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
uni.request({ uni.request({
...@@ -44,10 +54,6 @@ const request = (url = '', type = 'GET', param = {}, Loading,headertype) => { ...@@ -44,10 +54,6 @@ const request = (url = '', type = 'GET', param = {}, Loading,headertype) => {
let result = response.data; let result = response.data;
resolve(result); resolve(result);
} else { } else {
uni.showToast({
title: '网络出现问题',
icon: 'error'
});
reject(response); reject(response);
} }
}, },
...@@ -80,7 +86,37 @@ const getPlatform = () => { ...@@ -80,7 +86,37 @@ const getPlatform = () => {
} }
/**
* 设置cookit
*/
const setCookie = (name, value, expireDays) => {
let date = new Date();
date.setTime(date.getTime() + (expireDays * 24 * 60 * 60 * 1000));
let expires = "expires=" + date.toGMTString();
document.cookie = name + "=" + value + "; " + expires;
}
/**
*获取cookie
*/
const getCookie = (name) => {
var strCookie = document.cookie;
var arrCookie = strCookie.split("; ");
for (var i = 0; i < arrCookie.length; i++) {
var arr = arrCookie[i].split("=");
if (name == arr[0]) {
return arr[1];
}
}
return '';
}
module.exports = { module.exports = {
request, request,
getPlatform getPlatform,
setCookie,
getCookie
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment