uu
This commit is contained in:
parent
70027d20a8
commit
806fc7f132
@ -1,5 +1,7 @@
|
||||
export const host = '/TODO'
|
||||
// TODO 区分环境
|
||||
export const host = 'http://47.102.220.189:58089/api/bizsvr'
|
||||
|
||||
export default {
|
||||
uploadFile: `${host}`
|
||||
loginByApp: `/loginByApp`,
|
||||
getInfoByApp: `/getInfoByApp`
|
||||
}
|
||||
|
||||
@ -1,52 +1,90 @@
|
||||
import { goto } from "./untool";
|
||||
import { showToast } from "./untool"
|
||||
import {
|
||||
goto
|
||||
} from "./untool";
|
||||
import {
|
||||
showToast
|
||||
} from "./untool"
|
||||
|
||||
// 请求接口
|
||||
function dealRequest(def, url, param) {
|
||||
|
||||
const promise = new Promise(function (resolve, reject) {
|
||||
const promise = new Promise(function(resolve, reject) {
|
||||
def.then(function(response) {
|
||||
let {
|
||||
data,
|
||||
cookies,
|
||||
statusCode,
|
||||
header,
|
||||
errMsg
|
||||
} = response
|
||||
if (statusCode != 200) {
|
||||
showToast(`网络错误`)
|
||||
reject({
|
||||
response
|
||||
})
|
||||
}
|
||||
handleResponse({
|
||||
response,
|
||||
data,
|
||||
resolve,
|
||||
reject,
|
||||
url,
|
||||
param
|
||||
});
|
||||
}, function(response) {
|
||||
console.log('request url==========1', url)
|
||||
console.log('request param==========1', param)
|
||||
console.log('response ===========1', response);
|
||||
showToast(`网络错误`)
|
||||
reject({
|
||||
response
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
def.then(function (res) {
|
||||
handleResponse(res, resolve, reject, url, param);
|
||||
}, function (res) {
|
||||
console.log('request url==========1', url)
|
||||
console.log('request param==========1', param)
|
||||
console.log('response ===========1', res);
|
||||
showToast(`网络错误`)
|
||||
reject(res)
|
||||
})
|
||||
})
|
||||
|
||||
// 统一提示 errmsg
|
||||
promise.then(function (res) {
|
||||
}, function (res) {
|
||||
uni.hideLoading()
|
||||
})
|
||||
return promise;
|
||||
// 统一提示 errmsg
|
||||
promise.then(function(res) {}, function(res) {
|
||||
uni.hideLoading()
|
||||
})
|
||||
return promise;
|
||||
}
|
||||
|
||||
// 处理响应
|
||||
function handleResponse(res, resolve, reject, url, param) {
|
||||
const orgRes = { ...res };
|
||||
if ((res && res.respCode == 1)) {
|
||||
resolve(res.respData)
|
||||
} else {
|
||||
if (res.respCode == '-1') { // 统一判断需要认证, 并作页面跳转
|
||||
showToast(res.respMsg)
|
||||
setTimeout(()=>{
|
||||
goto(`TODO`, 1)
|
||||
}, 3500)
|
||||
return reject({ code: {} });
|
||||
}
|
||||
|
||||
setTimeout(()=> {
|
||||
showToast(`网络错误`)
|
||||
}, 0)
|
||||
reject({code: {}});
|
||||
}
|
||||
function handleResponse({
|
||||
data,
|
||||
resolve,
|
||||
reject,
|
||||
url,
|
||||
param
|
||||
}) {
|
||||
data = data || {}
|
||||
const { msg, code } = data
|
||||
if ((code == 200)) {
|
||||
resolve(data)
|
||||
} else {
|
||||
// TODO
|
||||
if (
|
||||
true
|
||||
// code == '-1'
|
||||
) { // 统一判断需要认证, 并作页面跳转
|
||||
showToast(msg)
|
||||
setTimeout(() => {
|
||||
goto(`TODO`, 1)
|
||||
}, 3500)
|
||||
return reject({
|
||||
code: {}
|
||||
});
|
||||
}
|
||||
setTimeout(() => {
|
||||
showToast(`网络错误`)
|
||||
}, 0)
|
||||
reject({
|
||||
code: {}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export {
|
||||
dealRequest,
|
||||
handleResponse
|
||||
}
|
||||
dealRequest,
|
||||
handleResponse
|
||||
}
|
||||
@ -1,17 +1,28 @@
|
||||
import { dealRequest } from "./manageServer"
|
||||
import { showToast } from "./untool"
|
||||
import {
|
||||
dealRequest
|
||||
} from "./manageServer"
|
||||
import {
|
||||
showToast
|
||||
} from "./untool"
|
||||
import {
|
||||
host
|
||||
} from "./api"
|
||||
const corePostBase = (url, reqParams, options = {}) => {
|
||||
|
||||
const corePostBase = (url, reqParams, options) => {
|
||||
return new Promise((resolve, reject)=> {
|
||||
const xToken = ""
|
||||
return new Promise((resolve, reject) => {
|
||||
uni.request({
|
||||
url,
|
||||
url: `${host}${url}`,
|
||||
data: reqParams,
|
||||
header: options,
|
||||
header: {
|
||||
"X-Token": xToken,
|
||||
...options
|
||||
},
|
||||
method: 'POST',
|
||||
success: (res)=> {
|
||||
success: (res) => {
|
||||
resolve(res)
|
||||
},
|
||||
fail: (e)=> {
|
||||
fail: (e) => {
|
||||
reject(e)
|
||||
}
|
||||
})
|
||||
@ -20,19 +31,18 @@ const corePostBase = (url, reqParams, options) => {
|
||||
|
||||
const BaseParam = {}
|
||||
// 请求处理
|
||||
let corePost = function (url, params = {}, options = {}) {
|
||||
let { tid } = Storage.get("MEMBER_SESSION") || {}
|
||||
// 统一把emo转unicode
|
||||
// emoUnicode(params)
|
||||
const reqParams = {
|
||||
...BaseParam,
|
||||
...params,
|
||||
}
|
||||
return dealRequest(corePostBase(url, reqParams, options)).then(res => {
|
||||
// 解析unicode
|
||||
// emoUnicode(res, 2)
|
||||
return res
|
||||
})
|
||||
let corePost = function(url, params = {}, options = {}) {
|
||||
// 统一把emo转unicode
|
||||
// emoUnicode(params)
|
||||
const reqParams = {
|
||||
...BaseParam,
|
||||
...params,
|
||||
}
|
||||
return dealRequest(corePostBase(url, reqParams, options)).then(res => {
|
||||
// 解析unicode
|
||||
// emoUnicode(res, 2)
|
||||
return res
|
||||
})
|
||||
}
|
||||
|
||||
export {
|
||||
|
||||
@ -13,23 +13,26 @@
|
||||
|
||||
<view class="mt-40">
|
||||
<u-input placeholder="请输入账号" color="#fff" font-size="30"
|
||||
v-model="submitParams.username"
|
||||
custom-style="padding: 30rpx 60rpx;background: rgba(255,255,255,0.2); border: 2px solid #FFFFFF;border-radius: 16rpx;"
|
||||
placeholder-style="color: #FFF;"></u-input>
|
||||
</view>
|
||||
<view class="mt-40">
|
||||
<u-input placeholder="请输入密码" color="#fff" font-size="30" type="password"
|
||||
v-model="submitParams.password"
|
||||
custom-style="padding: 30rpx 60rpx;background: rgba(255,255,255,0.2); border: 2px solid #FFFFFF;border-radius: 16rpx;"
|
||||
placeholder-style="color: #FFF;"></u-input>
|
||||
</view>
|
||||
<view class="mt-30">
|
||||
<u-checkbox-group placement="column" v-model="remberPassport">
|
||||
<u-checkbox size="28" labelSize="28" label="记住密码"
|
||||
:name="true"
|
||||
label-color="#fff" activeColor="#fff" iconColor="#B12D29" iconSize="20"></u-checkbox>
|
||||
</u-checkbox-group>
|
||||
</view>
|
||||
|
||||
<view style="margin-top: 70rpx;">
|
||||
<u-button custom-style="height:90rpx;font-size:32rpx;color: #B12D29;font-weight: bold;;box-shadow: 0rpx 12rpx 21rpx 0rpx rgba(177,45,41,0.32);border-radius: 16rpx;">登录</u-button>
|
||||
<u-button @click="handleLogin" custom-style="height:90rpx;font-size:32rpx;color: #B12D29;font-weight: bold;;box-shadow: 0rpx 12rpx 21rpx 0rpx rgba(177,45,41,0.32);border-radius: 16rpx;">登录</u-button>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
@ -38,12 +41,18 @@
|
||||
</template>
|
||||
<script>
|
||||
import getCdnUrl from "@/common/getCdnUrl"
|
||||
import { corePost } from "@/common/request"
|
||||
import apiUrl from "@/common/api"
|
||||
export default {
|
||||
props: {
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
remberPassport: ''
|
||||
submitParams: {
|
||||
username: 'libing',
|
||||
password: '123456'
|
||||
},
|
||||
remberPassport: [true]
|
||||
}
|
||||
},
|
||||
onShareAppMessage() {
|
||||
@ -53,6 +62,15 @@
|
||||
},
|
||||
methods: {
|
||||
getCdnUrl,
|
||||
async handleLogin() {
|
||||
const { remberPassport, submitParams } = this
|
||||
if(remberPassport[0]) {
|
||||
}
|
||||
const res1 = await corePost(apiUrl.loginByApp, submitParams)
|
||||
if(res1.token) {
|
||||
const res2 = await corePost(apiUrl.getInfoByApp, {})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user