Commit 73a044cb authored by jyx's avatar jyx

接口联调,加解密测试

parent a9f1291d
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -21,15 +21,16 @@ ...@@ -21,15 +21,16 @@
"crypto-md5": "^1.0.0", "crypto-md5": "^1.0.0",
"js-base64": "^3.7.2", "js-base64": "^3.7.2",
"js-md5": "^0.7.3", "js-md5": "^0.7.3",
"md5": "^2.3.0" "md5": "^2.3.0",
"qaui": "^1.0.18"
}, },
"devDependencies": { "devDependencies": {
"@babel/runtime": "^7.12.5", "@babel/runtime": "^7.12.5",
"@types/quickapp": "npm:quickapp-interface@^1.0.0", "@types/quickapp": "npm:quickapp-interface@^1.0.0",
"colors": "^1.4.0", "colors": "^1.4.0",
"husky": "^7.0.1", "husky": "^7.0.1",
"less": "^4.1.1", "less": "^4.1.2",
"less-loader": "^10.0.1", "less-loader": "^10.2.0",
"lint-staged": "^11.0.1", "lint-staged": "^11.0.1",
"onchange": "^5.2.0", "onchange": "^5.2.0",
"prettier": "^2.3.2", "prettier": "^2.3.2",
......
import api from './httpFetch'
export function getClassifyList() {
return api.getClassifyList()
.then((response) => {
return Promise.resolve(JSON.parse(response.data).data)
}).catch((err) => {
return Promise.reject(err)
})
}
export function getArticleByClassify(page = 0, cid) {
return api.getArticleByClassify(page, cid)
.then((response) => {
return Promise.resolve(JSON.parse(response.data).data)
}).catch((err) => {
return Promise.reject(err)
})
}
\ No newline at end of file
import api from './index'
export function getCollectArticle(page) {
return api.getCollectArticle(page)
.then((response) => {
return Promise.resolve(JSON.parse(response.data).data)
}).catch((err) => {
return Promise.reject(err)
})
}
export function collectArticle(id) {
return api.collectArticle(id)
.then((response) => {
var value = JSON.parse(response.data)
if(value.errorCode === -1) {
return Promise.reject('请先登录')
} else {
return Promise.resolve(value.data)
}
}).catch((err) => {
return Promise.reject(err)
})
}
export function collectArticleAdd(title, author, link) {
return api.collectArticleAdd({
title: title,
author: author,
link: link
})
.then((response) => {
return Promise.resolve(JSON.parse(response.data).data)
}).catch((err) => {
return Promise.reject(err)
})
}
export function uncollectArticle(id) {
return api.uncollectArticle(id)
.then((response) => {
return Promise.resolve(JSON.parse(response.data).data)
}).catch((err) => {
return Promise.reject(err)
})
}
export function uncollect(id, originId) {
return api.uncollect(id, originId)
.then((response) => {
return Promise.resolve(JSON.parse(response.data).data)
}).catch((err) => {
return Promise.reject(err)
})
}
export function getCollectWeb() {
return api.getCollectWeb()
.then((response) => {
return Promise.resolve(JSON.parse(response.data).data)
}).catch((err) => {
return Promise.reject(err)
})
}
export function collectWeb(name, link) {
return api.collectWeb({
name: name,
link: link
})
.then((response) => {
return Promise.resolve(JSON.parse(response.data).data)
}).catch((err) => {
return Promise.reject(err)
})
}
export function editCollectWeb(id, name, link) {
return api.editCollectWeb({
id: id,
name: name,
link: link
})
.then((response) => {
return Promise.resolve(JSON.parse(response.data).data)
}).catch((err) => {
return Promise.reject(err)
})
}
export function deleteCollectWeb(id) {
return api.deleteCollectWeb(id)
.then((response) => {
return Promise.resolve(JSON.parse(response.data).data)
}).catch((err) => {
return Promise.reject(err)
})
}
\ No newline at end of file
...@@ -9,31 +9,31 @@ var iv = CryptoJS.enc.Utf8.parse('7d0c9683cfcb0c7c'); //十六位十六进制 ...@@ -9,31 +9,31 @@ var iv = CryptoJS.enc.Utf8.parse('7d0c9683cfcb0c7c'); //十六位十六进制
* @param word * @param word
* @returns {*} * @returns {*}
*/ */
export function encrypt(word){ export function encrypt(word) {
var srcs = CryptoJS.enc.Utf8.parse(word); var srcs = CryptoJS.enc.Utf8.parse(word);
var encrypted = CryptoJS.AES.encrypt(srcs, key, {iv: iv,mode:CryptoJS.mode.CBC,padding: CryptoJS.pad.Pkcs7}); var encrypted = CryptoJS.AES.encrypt(srcs, key, { iv: iv, mode: CryptoJS.mode.CBC, padding: CryptoJS.pad.Pkcs7 });
let ens= encrypted.ciphertext.toString(CryptoJS.enc.Base64) let ens = encrypted.ciphertext.toString(CryptoJS.enc.Base64)
return ens; return ens;
} }
/** /**
* 解密 * 解密
* @param word * @param word
* @returns {*} * @returns {*}
*/ */
export function decrypt(word){ export function decrypt(word) {
// 去除 换行符 空格 下划线 // 去除 换行符 空格 下划线
var replaceWord = word.replace(/[\r\n]/g,"").replace(/\-g/,'+').replace(/_/,'/'); var replaceWord = word.replace(/[\r\n]/g, "").replace(/\-g/, '+').replace(/_/, '/');
//返回的是解密后的对象 //返回的是解密后的对象
let decrypt = CryptoJS.AES.decrypt(replaceWord,key,{ let decrypt = CryptoJS.AES.decrypt(replaceWord, key, {
iv:iv, iv: iv,
mode:CryptoJS.mode.CBC, mode: CryptoJS.mode.CBC,
padding:CryptoJS.pad.Pkcs7 padding: CryptoJS.pad.Pkcs7
}); });
//将解密对象转换成UTF8的字符串 //将解密对象转换成UTF8的字符串
let decryptedStr = decrypt.toString(CryptoJS.enc.Utf8); let decryptedStr = decrypt.toString(CryptoJS.enc.Utf8);
// 返回解密结果 // 返回解密结果
return decryptedStr.toString(); return decryptedStr.toString();
} }
\ No newline at end of file \ No newline at end of file
import api from './index'
export function getBanner() {
return api.getBanner()
.then((response) => {
return Promise.resolve(JSON.parse(response.data).data)
}).catch((err) => {
return Promise.reject(err)
})
}
export function getArticle(page = 0) {
return api.getArticle(page)
.then((response) => {
return Promise.resolve(JSON.parse(response.data).data)
}).catch((err) => {
return Promise.reject(err)
})
}
\ No newline at end of file
import {encrypt,decrypt} from './encry/aesUtil.js' import { encrypt, decrypt } from './encry/aesUtil.js'
import md5 from 'js-md5' import md5 from 'js-md5'
import { encode, decode } from 'js-base64'; import { encode, decode } from 'js-base64';
var fetch = require('@system.fetch') var fetch = require('@system.fetch')
var storage = require('@system.storage') var storage = require('@system.storage')
...@@ -11,20 +10,20 @@ var AES_KEY = 'abcdnnnn123456' ...@@ -11,20 +10,20 @@ var AES_KEY = 'abcdnnnn123456'
var API_ROOT = 'http://test.mints-id.com/news-api/' var API_ROOT = 'http://test.mints-id.com/news-api/'
var headers = { var headers = {
'version':'1.0.0', 'version': '1.0.0',
'pkgName':'com.wenshu.aiyuebao', 'pkgName': 'com.wenshu.aiyuebao',
'channel':'quickapp_' + 'aiyuebao', 'channel': 'quickapp_' + 'aiyuebao',
'Content-Type' :'application/json', 'Content-Type': 'application/json',
} }
// function getAuth(next) { // function getAuth(next) {
// storage.get({ // storage.get({
// key: 'auth', // key: 'auth',
// success: function(data) { // success: function (data) {
// headers.Cookie = data // headers.Cookie = data
// next(true) // next(true)
// }, // },
// fail: function(data, code) { // fail: function (data, code) {
// next(false) // next(false)
// } // }
// }) // })
...@@ -34,11 +33,11 @@ function getAuth() { ...@@ -34,11 +33,11 @@ function getAuth() {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
storage.get({ storage.get({
key: 'auth', key: 'auth',
success: function(data) { success: function (data) {
headers.Cookie = data headers.Cookie = data
resolve(true) resolve(true)
}, },
fail: function(data, code) { fail: function (data, code) {
resolve(false) resolve(false)
} }
}) })
...@@ -61,9 +60,9 @@ function realFetch(url, data = null, method = 'get') { ...@@ -61,9 +60,9 @@ function realFetch(url, data = null, method = 'get') {
var channel = 'quickapp_' + 'aiyuebao' var channel = 'quickapp_' + 'aiyuebao'
var _sign = token + ':' + channel + ':' + time var _sign = token + ':' + channel + ':' + time
var sign = '' + md5(_sign) var sign = '' + md5(_sign)
var check = '' + md5(_sign+':' + jsonData) var check = '' + md5(_sign + ':' + jsonData)
var params = { var params = {
'channel': channel, 'channel': channel,
...@@ -71,10 +70,10 @@ function realFetch(url, data = null, method = 'get') { ...@@ -71,10 +70,10 @@ function realFetch(url, data = null, method = 'get') {
'check': check, 'check': check,
'data': encrypt(jsonData) 'data': encrypt(jsonData)
} }
console.log(params) console.log(params)
headers['token'] = '.' headers['token'] = '.'
headers['last-session'] = encode(time) // base64 编码 headers['last-session'] = encode(time) // base64 编码
headers['new-session'] = md5(time) // md5 加密 headers['new-session'] = md5(time) // md5 加密
...@@ -84,7 +83,7 @@ function realFetch(url, data = null, method = 'get') { ...@@ -84,7 +83,7 @@ function realFetch(url, data = null, method = 'get') {
data: params, data: params,
header: headers, header: headers,
method: method, method: method,
success: function(data) { success: function (data) {
var obj = JSON.parse(data.data) var obj = JSON.parse(data.data)
var decyptData = decrypt(obj.data) var decyptData = decrypt(obj.data)
...@@ -92,7 +91,7 @@ function realFetch(url, data = null, method = 'get') { ...@@ -92,7 +91,7 @@ function realFetch(url, data = null, method = 'get') {
console.log(decyptData) console.log(decyptData)
resolve(data) resolve(data)
}, },
fail: function(data, code) { fail: function (data, code) {
reject(data) reject(data)
} }
}) })
...@@ -101,7 +100,7 @@ function realFetch(url, data = null, method = 'get') { ...@@ -101,7 +100,7 @@ function realFetch(url, data = null, method = 'get') {
function withAuth(url, data = null, method = 'get', canSkip = false) { function withAuth(url, data = null, method = 'get', canSkip = false) {
return getAuth().then((auth) => { return getAuth().then((auth) => {
if(auth || canSkip) { if (auth || canSkip) {
return realFetch(url, data, method) return realFetch(url, data, method)
} else { } else {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
...@@ -112,7 +111,7 @@ function withAuth(url, data = null, method = 'get', canSkip = false) { ...@@ -112,7 +111,7 @@ function withAuth(url, data = null, method = 'get', canSkip = false) {
} }
function post(url, data = null, config = {}) { function post(url, data = null, config = {}) {
if(config.withAuth) { if (config.withAuth) {
return withAuth(url, data, 'post', config.canSkip) return withAuth(url, data, 'post', config.canSkip)
} else { } else {
return realFetch(url, data, 'post') return realFetch(url, data, 'post')
...@@ -120,7 +119,7 @@ function post(url, data = null, config = {}) { ...@@ -120,7 +119,7 @@ function post(url, data = null, config = {}) {
} }
function get(url, data = null, config = {}) { function get(url, data = null, config = {}) {
if(config.withAuth) { if (config.withAuth) {
return withAuth(url, data, 'get', config.canSkip) return withAuth(url, data, 'get', config.canSkip)
} else { } else {
return realFetch(url, data, 'get') return realFetch(url, data, 'get')
...@@ -131,7 +130,7 @@ export default { ...@@ -131,7 +130,7 @@ export default {
/** /**
* 手机号登录 * 手机号登录
*/ */
mobileLogin(params){ mobileLogin(params) {
return post('api/mobilelogin', params) return post('api/mobilelogin', params)
} }
} }
\ No newline at end of file
import {getStore, setStore} from '@/util/store'
const user = {
state: {
token: getStore({
name: 'token'
}) || '',
mobile: getStore({
name: 'mobile'
}) || '',
uid: getStore({
name: 'uid'
}) || '',
tokenid: getStore({
name: 'tokenid'
}) || '',
},
actions: {},
mutations: {
SET_TOKEN: (state, token) => {
state.token = token
setStore({
name: 'token',
content: state.token,
type: '',
})
},
MOBILE: (state, mobile) => {
state.mobile = mobile
setStore({
name: 'mobile',
content: state.mobile,
type: '',
})
},
UID: (state, uid) => {
state.uid = uid
setStore({
name: 'uid',
content: state.uid,
type: '',
})
},
TOKEN_ID: (state, tokenid) => {
state.tokenid = tokenid
setStore({
name: 'tokenid',
content: state.tokenid,
type: '',
})
}
}
}
export default user
\ No newline at end of file
...@@ -6,7 +6,7 @@ import $utils from './utils' ...@@ -6,7 +6,7 @@ import $utils from './utils'
const TIMEOUT = 20000 const TIMEOUT = 20000
Promise.prototype.finally = function(callback) { Promise.prototype.finally = function (callback) {
const P = this.constructor const P = this.constructor
return this.then( return this.then(
value => P.resolve(callback()).then(() => value), value => P.resolve(callback()).then(() => value),
...@@ -66,20 +66,20 @@ function requestHandle(params, timeout = TIMEOUT) { ...@@ -66,20 +66,20 @@ function requestHandle(params, timeout = TIMEOUT) {
} }
export default { export default {
post: function(url, params) { post: function (url, params) {
return requestHandle({ return requestHandle({
method: 'post', method: 'post',
url: url, url: url,
data: params data: params
}) })
}, },
get: function(url, params) { get: function (url, params) {
return requestHandle({ return requestHandle({
method: 'get', method: 'get',
url: $utils.queryString(url, params) url: $utils.queryString(url, params)
}) })
}, },
put: function(url, params) { put: function (url, params) {
return requestHandle({ return requestHandle({
method: 'put', method: 'put',
url: url, url: url,
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
import {Notification, MessageBox} from 'element-ui';
import {selectListByName} from '@/api/common';//用户中心
import {selectClassByServiceType} from '@/api/common';//用户中心
import {getMarketSelect} from '@/api/common';//用户中心
import {getOrgServiceSelect} from '@/api/common';//用户中心
var hua = {
validate: {
username: /^[a-zA-Z0-9]+$/,
number: /^(\d+)$|^[+]{0,1}(\d)+$/,
floatNumber: /^[+]{0,1}(\d+)$|^[+]{0,1}(\d+\.\d{1,2})+$/,
phone: /^0?1[1-9][0-9]\d{8}$/,
idCard: /(^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$)|(^[1-9]\d{5}\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{2}$)/,
other: /^[a-zA-Z0-9]{8,28}$/,
idCard: function (rule, value, callback) {
if (rule.required == false && value.length == 0) {
callback();
}
var reg = /(^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$)|(^[1-9]\d{5}\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{2}$)/
var result = reg.test(value);
if (!result) {
callback(new Error('请输入正确的身份证号码'));
} else {
callback();
}
},
password: function (rule, value, callback) {
if (rule.required == false && value.length == 0) {
callback();
}
var reg = /^[A-Za-z0-9]+$/
var result = reg.test(value);
if (!result) {
callback(new Error('只能输入数字与密码'));
} else {
callback();
}
},
checkKeyword: function (rule, value, callback) {
if (rule.required == false && value.length == 0) {
callback();
}
var reg = /[,]/g;
var result = reg.test(value);
if (result) {
var n = value.match(reg).length;
if (n > 5)
callback(new Error('最多输入6组关键词'));
else
callback();
} else {
callback();
}
},
otherValidate: function (rule, value, callback) {
if (rule.required == false && value.length == 0) {
callback();
}
var reg = hua.validate.other;
var result = reg.test(value);
if (!result) {
callback(new Error('格式不正确'));
} else {
callback();
}
},
percent: function (rule, value, callback) {
if (rule.required == false && value.length == 0) {
callback();
}
// var reg = /^[+]{0,1}(\d+)$|^[+]{0,1}(\d+\.\d{1,2})+$/;
var reg = /^(\d+)$|^(\d+\.\d{1,2})+$/;
var result = reg.test(value);
if (!result) {
callback(new Error('必须是数字,精确到小数点后两位'));
} else {
if (value >= 100) {
callback(new Error('不能超过100%'));
}
callback();
}
},
money: function (rule, value, callback) {
if (rule.required == false && value.length == 0) {
callback();
}
if (value == '' || value == null) {
callback();
}
var reg = /^[+]{0,1}(\d+)$|^[+]{0,1}(\d+\.\d{1,2})+$/;
var result = reg.test(value);
if (!result) {
callback(new Error('必须是数字,精确到小数点后两位'));
} else {
if (value > 9900000000) {
callback(new Error('金额不能超过99亿人民币'));
}
callback();
}
},
money2: function (rule, value, callback) {
if (rule.required == false && value.length == 0) {
callback();
}
if (value == '' || value == null) {
callback();
}
// var reg = /^[+]{0,1}(\d+)$|^[+]{0,1}(\d+\.\d{1,2})+$/;
var reg = /^(\d+)$|^(\d+\.\d{1,2})+$/;
var result = reg.test(value);
if (!result) {
callback(new Error('精确到小数后两位'));
} else {
if (value > 990000) {
callback(new Error('金额不能超过99亿人民币'));
}
callback();
}
},
number: function (rule, value, callback) {
if (!rule.required && (value == '' || value == null)) {
callback();
}
var reg = /^(\d+)$|^[+]{0,1}(\d)+$/;
var result = reg.test(value);
if (!result) {
callback(new Error('必须是正整数'));
} else {
callback();
}
},
moreThan: function (rule, value, callback, value2) {
if (rule.required == false && value.length == 0) {
callback();
}
if (value2 === '' || value2 === undefined) {
// value2 = 0;
callback();
}
if (parseFloat(value2) >= parseFloat(value)) {
callback(new Error('输入值必须大于' + value2));
} else {
callback();
}
},
lessThan: function (rule, value, callback, value2) {
if (rule.required == false && value.length == 0) {
callback();
}
if (value2 == '' || value2 == undefined) {
// value2 = 0;
callback();
}
if (parseFloat(value2) <= parseFloat(value)) {
callback(new Error('输入值必须小于' + value2));
} else {
callback();
}
},
equalMore: function (rule, value, callback, value2) {
if (rule.required == false && value.length == 0) {
callback();
}
if (value2 == '' || value2 == undefined) {
// value2 = 0;
callback();
}
if (parseFloat(value2) > parseFloat(value)) {
callback(new Error('输入值必须大于等于' + value2));
} else {
callback();
}
},
equalLess: function (rule, value, callback, value2) {
if (rule.required == false && value.length == 0) {
callback();
}
if (value2 == '' || value2 == undefined) {
// value2 = 0;
callback();
}
if (parseFloat(value2) < parseFloat(value)) {
callback(new Error('输入值必须小于等于' + value2));
} else {
callback();
}
},
},
getSelect: function (name, e, e2) {
var that = this;
var e = arguments[1] ? arguments[1] : function () {
};
var e2 = arguments[2] ? arguments[2] : function () {
};
selectListByName(name).then(res => {
if (res.code == 0) {
e(res.data);
return;
} else {
e2(res.data);
Notification.error({
title: '错误',
message: res.msg
});
return;
}
});
},
selectClass: function (serviceType, e, e2) {
var that = this;
var e = arguments[1] ? arguments[1] : function () {
};
var e2 = arguments[2] ? arguments[2] : function () {
};
selectClassByServiceType(serviceType).then(res => {
if (res.code == 0) {
e(res.data);
return;
} else {
e2(res.data);
Notification.error({
title: '错误',
message: res.msg
});
return;
}
});
},
getMarketSelect: function (params, e, e2) {
var that = this;
var e = arguments[1] ? arguments[1] : function () {
};
var e2 = arguments[2] ? arguments[2] : function () {
};
getMarketSelect(params).then(res => {
if (res.length > 0) {
e(res);
return;
} else {
e2(res.content);
Notification.error({
title: '错误',
message: res.data.msg
});
return;
}
});
},
getOrgServiceSelect: function (params, e, e2) {
var that = this;
var e = arguments[1] ? arguments[1] : function () {
};
var e2 = arguments[2] ? arguments[2] : function () {
};
getOrgServiceSelect(params).then(res => {
if (res.data.length > 0) {
e(res);
return;
} else {
e2(res.content);
Notification.error({
title: '错误',
message: res.data.msg
});
return;
}
});
},
//加
floatAdd(arg1, arg2) {
var r1, r2, m;
try {
r1 = arg1.toString().split(".")[1].length
} catch (e) {
r1 = 0
}
try {
r2 = arg2.toString().split(".")[1].length
} catch (e) {
r2 = 0
}
m = Math.pow(10, Math.max(r1, r2));
return (arg1 * m + arg2 * m) / m;
},
//减
floatSub(arg1, arg2) {
var r1, r2, m, n;
try {
r1 = arg1.toString().split(".")[1].length
} catch (e) {
r1 = 0
}
try {
r2 = arg2.toString().split(".")[1].length
} catch (e) {
r2 = 0
}
m = Math.pow(10, Math.max(r1, r2));
//动态控制精度长度
n = (r1 >= r2) ? r1 : r2;
return ((arg1 * m - arg2 * m) / m).toFixed(n);
},
//乘
floatMul(arg1, arg2) {
var m = 0,
s1 = arg1.toString(),
s2 = arg2.toString();
try {
m += s1.split(".")[1].length
} catch (e) {
}
try {
m += s2.split(".")[1].length
} catch (e) {
}
return Number(s1.replace(".", "")) * Number(s2.replace(".", "")) / Math.pow(10, m);
},
//除
floatDiv(arg1, arg2) {
var m = 0, s1 = arg1.toString(), s2 = arg2.toString();
try {
m += s1.split(".")[1].length
} catch (e) {
}
try {
m += s2.split(".")[1].length
} catch (e) {
}
return Number(s1.replace(".", "")) * Number(s2.replace(".", "")) / Math.pow(10, m);
},
//获取身份证年龄
getAge: function (identityCard) {
var len = (identityCard + "").length;
if (len == 0) {
return 0;
} else {
if ((len != 15) && (len != 18)) //身份证号码只能为15位或18位其它不合法
{
return 0;
}
}
var strBirthday = "";
if (len == 18) //处理18位的身份证号码从号码中得到生日和性别代码
{
strBirthday = identityCard.substr(6, 4) + "/" + identityCard.substr(10, 2) + "/" + identityCard.substr(12, 2);
}
if (len == 15) {
strBirthday = "19" + identityCard.substr(6, 2) + "/" + identityCard.substr(8, 2) + "/" + identityCard.substr(10, 2);
}
//时间字符串里,必须是“/”
var birthDate = new Date(strBirthday);
var nowDateTime = new Date();
var age = nowDateTime.getFullYear() - birthDate.getFullYear();
//再考虑月、天的因素;.getMonth()获取的是从0开始的,这里进行比较,不需要加1
if (nowDateTime.getMonth() < birthDate.getMonth() || (nowDateTime.getMonth() == birthDate.getMonth() && nowDateTime.getDate() < birthDate.getDate())) {
age--;
}
return age;
},
checkRes: function (res, e, e2) {
var e = arguments[1] ? arguments[1] : function () {
};
var e2 = arguments[2] ? arguments[2] : function () {
};
if (res == undefined) {
return;
}
console.log(res)
if (res.code == 0) {
e(res.data)
Notification({
title: '成功',
message: res.msg,
type: 'success',
duration: 1500,
});
return;
} else {
e2(res.data)
Notification({
title: '失败',
message: res.msg,
type: 'error',
duration: 1500
});
return;
}
},
checkErrer: function (res, e) {
var e = arguments[1] ? arguments[1] : function () {
};
if (res == undefined) {
return;
}
if (res.code == 0) {
e(res.data);
return;
} else {
Notification({
title: '失败',
message: res.msg,
type: 'error',
});
}
},
//整理地址树
getTreeData(data, childrenName) {
var name = arguments[1] ? arguments[1] : 'children';
// 循环遍历json数据
for (var i = 0; i < data.length; i++) {
if (data[i][name] && data[i][name].length < 1) {
// children若为空数组,则将children设为undefined
data[i][name] = undefined;
} else {
// children若不为空数组,则继续 递归调用 本方法
if (data[i][name]) {
this.getTreeData(data[i][name], childrenName);
}
}
}
return data;
},
getThreeData(data, name1, name2, name3) {
var id = arguments[1] ? arguments[1] : 'id';
var name = arguments[2] ? arguments[2] : 'name';
var list = arguments[3] ? arguments[3] : 'list';
for (var i = 0; i < data.length; i++) {
var dataList = data[i][list]
if (dataList && dataList.length < 1) {
// children若为空数组,则将children设为undefined
data[i].id = data[i][id]
data[i].name = data[i][name]
data[i].list = [];
} else {
// children若不为空数组,则继续 递归调用 本方法
data[i].id = data[i][id]
data[i].name = data[i][name]
data[i].list = data[i][list]
if (dataList) {
this.getThreeData(dataList, name1, name2, name3);
}
}
}
return data;
//
},
//获取值
getTreeValue(value, data, e) {
var name = 'classId'
var e = arguments[2] ? arguments[2] : function () {
};
// 循环遍历json数据
for (var i = 0; i < data.length; i++) {
if (data[i][name] && data[i][name] == value) {
e(data[i])
return
} else {
if (data[i].chirdClassVO) {
this.getTreeValue(value, data[i].chirdClassVO, e);
}
if (data[i].children) {
this.getTreeValue(value, data[i].children, e);
}
}
}
},
//整理过滤条件
getTags(val, arr, id, tags) {
// if (val == 1) {
for (let i = 0; i < arr.length; i++) {
if (id == arr[i].id) {
for (let j = 0; j < tags.length; j++) {
if (tags[j].index == val) {
tags.splice(j, 1);
break;
}
}
tags.push({
name: arr[i].name,
id: arr[i].id,
index: val
});
break;
}
}
return tags
// }
},
initDataTable(self, data, name, page) {
var json = data;
self[page].total = Number(json.total);
self[name] = json.records;
},
initDataTable2(self, data, name, page) {
var json = data;
self[page].total = Number(json.total);
self[name] = json.list;
},
handleSizeChange(name, self, size, e) {
self[name].pageSize = size;
self[name].currentPage = 1;
self[name].pageIndex = 0;
e();
},
handleCurrentChange(name, self, currentPage, e) {
self[name].currentPage = currentPage;
self[name].pageIndex = (self[name].currentPage - 1) * self[name].pageSize;
e();
},
initPage(self, nameArry, e) {
var e = arguments[2] ? arguments[2] : function () {
};
for (var i = 0; i < nameArry.length; i++) {
self[nameArry[i]].currentPage = 1;
self[nameArry[i]].start = 0;
}
e();
},
resetForm(formName, obj) {
obj.$refs[formName].resetFields();
return
},
changeList(json) {
var arry = [];
for (var key in json) {
arry.push({value: key, label: json[key]});
}
return arry;
},
sbUrl(json) {
var sbUrl = '';
for (var key in json) {
if (json[key] !== '' && json[key] !== null) {
if (key == 'start') {
sbUrl += "?" + key + "=" + encodeURIComponent(json[key]);
} else {
sbUrl += "&" + key + "=" + encodeURIComponent(json[key]);
}
}
}
return sbUrl;
},
sbUrl2(json) {
// var sbUrl = '';
// for (var key in json) {
// if (json[key] !== '') {
// if (key == 'start') {
// sbUrl += "?" + key + "=" + encodeURIComponent(json[key]);
// } else {
// sbUrl += "&" + key + "=" + encodeURIComponent(json[key]);
// }
// }
// }
// return sbUrl;
// var json = arguments[1] ? arguments[1] : {};
var params = Object.keys(json).map(function (key) {
if (json[key] != '') {
return encodeURIComponent(key) + "=" + encodeURIComponent(json[key]);
}
}).join("&");
// var json = arguments[1] ? arguments[1] : {};
// var params = Object.keys(json).map(function(key) {
// return encodeURIComponent(key) + "=" + encodeURIComponent(json[key]);
// }).join("&");
return '?' + params;
},
delApply(obj, url, querry, e, type) {
var type = arguments[4] ? arguments[4] : 'post';
var e = arguments[3] ? arguments[3] : function () {
};
var that = this;
MessageBox.confirm('请确认是否要执行删除操作?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
obj.axios[type](url, querry).then(res => {
that.checkRes(res, function () {
e(res);
});
});
}).catch(() => {
Notification({
type: 'info',
message: '已取消'
});
});
},
addformNoValidate(obj, formName, url, querry, e, type) {
var type = arguments[5] ? arguments[5] : 'post';
var e = arguments[4] ? arguments[4] : function () {
};
var that = this;
MessageBox.confirm('请确认是否要执行提交操作?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
obj.axios[type](url, querry).then(res => {
that.checkRes(res, function () {
that.resetForm(formName, obj);
e(res);
});
});
}).catch(() => {
Notification({
type: 'info',
message: '已取消'
});
});
},
addform(obj, formName, url, querry, e, type) {
var type = arguments[5] ? arguments[5] : 'post';
var e = arguments[4] ? arguments[4] : function () {
};
var that = this;
MessageBox.confirm('请确认是否要执行提交操作?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
obj.$refs[formName].validate((valid, object) => {
if (valid) {
obj.axios[type](url, querry).then(res => {
that.checkRes(res, function () {
that.resetForm(formName, obj);
e(res);
});
});
} else {
Notification({
type: 'warning',
message: '有必填项还未填完'
});
return false;
}
});
}).catch(() => {
Notification({
type: 'info',
message: '已取消'
});
});
},
download(data, fileName) {
if (!data) {
return
}
let url = window.URL.createObjectURL(new Blob([data]))
let link = document.createElement('a')
link.style.display = 'none'
link.href = url
link.setAttribute('download', fileName)
document.body.appendChild(link)
link.click()
},
download2(file) {
let link = document.createElement('a')
link.style.display = 'none'
link.href = file.attachmentUrl
link.setAttribute('download', file.attachmentName)
document.body.appendChild(link)
link.click()
},
exportDo(url, json) {
var json = arguments[1] ? arguments[1] : {};
var params = Object.keys(json).map(function (key) {
if (json[key] != '') {
return encodeURIComponent(key) + "=" + encodeURIComponent(json[key]);
}
}).join("&");
window.location.href = url + "?" + params;
},
//转意符换成普通字符
escape2Html(str) {
var arrEntities = {'lt': '<', 'gt': '>', 'nbsp': ' ', 'amp': '&', 'quot': '"'};
var rr = str.replace(/&(lt|gt|nbsp|amp|quot);/ig, function (all, t) {
return arrEntities[t];
});
return rr.replace(/\<\/br?\>/g, "");
},
//转换大写金额
changeMoney(n) {
var fraction = ['角', '分'];
var digit = ['零', '壹', '贰', '叁', '肆', '伍', '陆', '柒', '捌', '玖'];
var unit = [
['元', '万', '亿'],
['', '拾', '佰', '仟']
];
var head = n < 0 ? '欠' : '';
n = Math.abs(n);
var s = '';
for (var i = 0; i < fraction.length; i++) {
s += (digit[Math.floor(n * 10 * Math.pow(10, i)) % 10] + fraction[i]).replace(/零./, '');
}
s = s || '整';
n = Math.floor(n);
for (var i = 0; i < unit[0].length && n > 0; i++) {
var p = '';
for (var j = 0; j < unit[1].length && n > 0; j++) {
p = digit[n % 10] + unit[1][j] + p;
n = Math.floor(n / 10);
}
s = p.replace(/(零.)*零$/, '').replace(/^$/, '零') + unit[0][i] + s;
}
return head + s.replace(/(零.)*零元/, '元').replace(/(零.)+/g, '零').replace(/^整$/, '零元整');
},
//金额使用千分位分割符号显示
get_thousand_num(num) {
var decimal = String(num).split('.')[1] || '';//小数部分
var tempArr = [];
var revNumArr = String(num).split('.')[0].split("").reverse();//倒序
for (var i in revNumArr) {
tempArr.push(revNumArr[i]);
if ((i + 1) % 3 === 0 && i != revNumArr.length - 1) {
tempArr.push(',');
}
}
var zs = tempArr.reverse().join('');//整数部分
return decimal ? zs + '.' + decimal : zs;
},
formatTime(time) {
if (('' + time).length === 10) {
time = parseInt(time) * 1000
} else {
time = +time
}
const d = new Date(time)
const now = Date.now()
const diff = (now - d) / 1000
// if (diff < 30) {
// return '刚刚'
// } else if (diff < 3600) {
// // less 1 hour
// return Math.ceil(diff / 60) + '分钟前'
// } else if (diff < 3600 * 24) {
// return Math.ceil(diff / 3600) + '小时前'
// } else if (diff < 3600 * 24 * 2) {
// return '1天前'
// }
return (
d.getFullYear() + '-' +
(d.getMonth() + 1) + '-' +
d.getDate()
// +
// d.getHours() +
// '时' +
// d.getMinutes() +
// '分'
)
},
ueditorConfig() {
return {
// 如果需要上传功能,找后端小伙伴要服务器接口地址
// serverUrl: this.$config.baseUrl + 'ueditor/ueditorConfig',
serverUrl: '/financing/management/file/ueditorConfig',
// 你的UEditor资源存放的路径,相对于打包后的index.public
UEDITOR_HOME_URL: '/public/ueditor/',
// 编辑器不自动被内容撑高
autoHeightEnabled: false,
// 工具栏是否可以浮动
autoFloatEnabled: false,
// 初始容器高度
initialFrameHeight: 340,
// 初始容器宽度
initialFrameWidth: '100%',
zIndex: 1,
// 关闭自动保存
enableAutoSave: true
}
}
}
export default hua
/**
*
* 验证规则
*
*/
export function isvalidUsername(str) {
const valid_map = ['admin', 'editor']
return valid_map.indexOf(str.trim()) >= 0
}
/* 合法uri*/
export function validateURL(textval) {
const urlregex = /^(https?|ftp):\/\/([a-zA-Z0-9.-]+(:[a-zA-Z0-9.&%$-]+)*@)*((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])){3}|([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+\.(com|edu|gov|int|mil|net|org|biz|arpa|info|name|pro|aero|coop|museum|[a-zA-Z]{2}))(:[0-9]+)*(\/($|[a-zA-Z0-9.,?'\\+&%$#=~_-]+))*$/
return urlregex.test(textval)
}
/* 小写字母*/
export function validateLowerCase(str) {
const reg = /^[a-z]+$/
return reg.test(str)
}
/* 大写字母*/
export function validateUpperCase(str) {
const reg = /^[A-Z]+$/
return reg.test(str)
}
/* 大小写字母*/
export function validatAlphabets(str) {
const reg = /^[A-Za-z]+$/
return reg.test(str)
}
/*验证pad还是pc*/
export const vaildatePc = function () {
const userAgentInfo = navigator.userAgent;
const Agents = ["Android", "iPhone",
"SymbianOS", "Windows Phone",
"iPad", "iPod"];
let flag = true;
for (var v = 0; v < Agents.length; v++) {
if (userAgentInfo.indexOf(Agents[v]) > 0) {
flag = false;
break;
}
}
return flag;
}
/**
* validate email
* @param email
* @returns {boolean}
*/
export function validateEmail(email) {
const re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
return re.test(email)
}
/**
* 判断身份证号码
*/
export function cardid(code) {
let list = [];
let result = true;
let msg = '';
var city = {
11: "北京",
12: "天津",
13: "河北",
14: "山西",
15: "内蒙古",
21: "辽宁",
22: "吉林",
23: "黑龙江 ",
31: "上海",
32: "江苏",
33: "浙江",
34: "安徽",
35: "福建",
36: "江西",
37: "山东",
41: "河南",
42: "湖北 ",
43: "湖南",
44: "广东",
45: "广西",
46: "海南",
50: "重庆",
51: "四川",
52: "贵州",
53: "云南",
54: "西藏 ",
61: "陕西",
62: "甘肃",
63: "青海",
64: "宁夏",
65: "新疆",
71: "台湾",
81: "香港",
82: "澳门",
91: "国外 "
};
if (!validatenull(code)) {
if (code.length == 18) {
if (!code || !/(^\d{18}$)|(^\d{17}(\d|X|x)$)/.test(code)) {
msg = "证件号码格式错误";
} else if (!city[code.substr(0, 2)]) {
msg = "地址编码错误";
} else {
//18位身份证需要验证最后一位校验位
code = code.split('');
//∑(ai×Wi)(mod 11)
//加权因子
var factor = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2];
//校验位
var parity = [1, 0, 'X', 9, 8, 7, 6, 5, 4, 3, 2, 'x'];
var sum = 0;
var ai = 0;
var wi = 0;
for (var i = 0; i < 17; i++) {
ai = code[i];
wi = factor[i];
sum += ai * wi;
}
var last = parity[sum % 11];
if (parity[sum % 11] != code[17]) {
msg = "证件号码校验位错误";
} else {
result = false;
}
}
} else {
msg = "证件号码长度不为18位";
}
} else {
msg = "证件号码不能为空";
}
list.push(result);
list.push(msg);
return list;
}
/**
* 判断手机号码是否正确
*/
export function isvalidatemobile(phone) {
let list = [];
let result = true;
let msg = '';
// var isPhone = /^0\d{2,3}-?\d{7,8}$/;
var isPhone = /^1[3|4|5|6|7|8][0-9]\d{4,8}$/;
//增加134 减少|1349[0-9]{7},增加181,增加145,增加17[678]
var isMob = /^((\+?86)|(\(\+86\)))?(13[0123456789][0-9]{8}|15[012356789][0-9]{8}|18[012356789][0-9]{8}|14[57][0-9]{8}|17[3678][0-9]{8})$/;
if (!validatenull(phone)) {
if (phone.length === 11) {
if (!isPhone.test(phone)) {
msg = '手机号码格式不正确';
} else {
result = false;
}
} else {
msg = '手机号码长度不为11位';
}
} else {
msg = '手机号码不能为空';
}
list.push(result);
list.push(msg);
return list;
}
/**
* 判断姓名是否正确
*/
export function validatename(name) {
var regName = /^[\u4e00-\u9fa5]{2,4}$/;
if (!regName.test(name)) return false;
return true;
};
/**
* 判断是否为整数
*/
export function validatenum(num, type) {
let regName = /[^\d.]/g;
if (type == 1) {
if (!regName.test(num)) return false;
} else if (type == 2) {
regName = /[^\d]/g;
if (!regName.test(num)) return false;
}
return true;
};
/**
* 判断是否为小数
*/
export function validatenumord(num, type) {
let regName = /[^\d.]/g;
if (type == 1) {
if (!regName.test(num)) return false;
} else if (type == 2) {
regName = /[^\d.]/g;
if (!regName.test(num)) return false;
}
return true;
};
/**
* 判断是否为空
*/
export function validatenull(val) {
if (val instanceof Array) {
if (val.length == 0) return true;
} else if (val instanceof Object) {
if (JSON.stringify(val) === '{}') return true;
} else {
if (val == 'null' || val == null || val == 'undefined' || val == undefined || val == '') return true;
return false;
}
return false;
};
/**
* 隐藏中间四位手机号
*/
export function getHideTel(val) {
let reg = /^(\d{3})\d{4}(\d{4})$/;
return val.replace(reg, "$1****$2");
};
/**
* 计算图片压缩比例
*/
export function calculateQuality(fileSize) {
let quality
// 大于10M
if (fileSize / 1024 > 10241) {
quality = 0.5
}
// 大于5M
else if (fileSize / 1024 > 5121) {
quality = 0.6
}
// 大于1M
else if (fileSize / 1024 > 1025) {
quality = 0.8
} else {
quality = 1.0
}
return quality
}
/**
* 用户名字*号替换 欧阳峰 -> 欧*锋
*/
export function hiddenName(name) {
var newName
if (name.length == 2) {
newName = name.substr(0, 1) + '*'
} else if (name.length > 2) {
let char = '';
for (let i = 0, len = name.length - 2; i < len; i++) {
char += '*';
}
newName = name.substr(0, 1) + char + name.substr(-1, 1);
} else {
newName = name
}
return newName
}
/**
* 用户名字*号替换 欧阳峰 -> 欧**
*/
export function hiddenName2(name) {
var newName
if (name.length == 2) {
newName = name.substr(0, 1) + '*'
} else if (name.length > 2) {
let char = '';
for (let i = 0, len = name.length - 1; i < len; i++) {
char += '*';
}
newName = name.substr(0, 1) + char;
} else {
newName = name
}
return newName
}
\ No newline at end of file
import wx from 'weixin-js-sdk'
import {getTecentSignInfo} from "../api/public";
export const weiXinShare = (product) => {
let params = {requestUrl: encodeURIComponent(location.href.split('#')[0])}
getTecentSignInfo(params).then(res => {
if (res.code === 0) {
//拿到后端给的这些数据
let appId = res.signInfo.appId;
let timestamp = res.signInfo.timestamp;
let nonceStr = res.signInfo.nonceStr;
let signature = res.signInfo.signature;
//配置微信信息
wx.config({
// debug: true, // true:调试时候弹窗
appId: appId, // 微信appid
timestamp: timestamp, // 时间戳
nonceStr: nonceStr, // 随机字符串
signature: signature, // 签名
jsApiList: [
// 所有要调用的 API 都要加到这个列表中
'updateAppMessageShareData',
'updateTimelineShareData',
]
});
wx.ready(function () {
// 微信分享的数据
let shareData = {
"imgUrl": product.productIconUrl, // 分享显示的缩略图地址
"link": location.href.split('#')[0] + '#' + location.href.split('#')[1], // 分享地址
"desc": product.basicDesc, // 分享描述
"title": product.productName, // 分享标题
success: function () {
console.log('success')
// 分享成功可以做相应的数据处理
// let data = orderId
// this.$router.push({name: 'checkstand', query: {data}})
},
cancel: function () {
// 用户取消分享后执行的回调函数
// alert("分享取消22");
}
};
wx.updateAppMessageShareData(shareData);
wx.updateTimelineShareData(shareData);
});
wx.error(function (res) {
console.log(res)
// config信息验证失败会执行error函数,如签名过期导致验证失败,
// 具体错误信息可以打开config的debug模式查看,也可以在返回的res参数中查看,
//对于SPA可以在这里更新签名。
// alert("好像出错了!!");
});
}
});
}
\ No newline at end of file
<template> <template>
<div class="tutorial-page"> <div class="tutorial-page">
<!-- 灵活使用tabs组件 --> <!-- 灵活使用tabs组件 -->
<div class="flexible-tabs"> <div class="flexible-tabs">
<!-- 监听change事件,触发时动态修改tabs的index属性 --> <!-- 监听change事件,触发时动态修改tabs的index属性 -->
<tabs onchange="changeTabactive" index="{{currentIndex}}"> <tabs onchange="changeTabactive" index="{{currentIndex}}">
<tab-content class="flexible-tab-content"> <tab-content class="flexible-tab-content">
<div class="tab-content-section"> <div class="tab-content-section">
<sign></sign> <sign if="{{tabItems[0].render}}"></sign>
</div> </div>
<div class="tab-content-section"> <div class="tab-content-section">
<news></news> <news if="{{tabItems[1].render}}"></news>
</div> </div>
<div class="tab-content-section"> <div class="tab-content-section">
<my></my> <my if="{{tabItems[2].render}}"></my>
</div> </div>
</tab-content> </tab-content>
</tabs> </tabs>
<!-- 自定义tab-bar组件 --> <!-- 自定义tab-bar组件 -->
<div class="flexible-tabbar"> <div class="flexible-tabbar">
<text class="{{currentIndex === 0 ? 'active' : ''}}" onclick="clickTabBar(0)">{{tabItems[0].text}}</text> <text
<text class="{{currentIndex === 1 ? 'active' : ''}}" onclick="clickTabBar(1)">{{tabItems[1].text}}</text> class="{{currentIndex === 0 ? 'active' : ''}}"
<text class="{{currentIndex === 2 ? 'active' : ''}}" onclick="clickTabBar(2)">{{tabItems[2].text}}</text> onclick="clickTabBar(0)"
>{{ tabItems[0].text }}</text
>
<text
class="{{currentIndex === 1 ? 'active' : ''}}"
onclick="clickTabBar(1)"
>{{ tabItems[1].text }}</text
>
<text
class="{{currentIndex === 2 ? 'active' : ''}}"
onclick="clickTabBar(2)"
>{{ tabItems[2].text }}</text
>
</div> </div>
</div> </div>
</div> </div>
...@@ -36,35 +48,39 @@ import router from '@system.router' ...@@ -36,35 +48,39 @@ import router from '@system.router'
export default { export default {
// 页面级组件的数据模型,影响传入数据的覆盖机制:private内定义的属性不允许被覆盖 // 页面级组件的数据模型,影响传入数据的覆盖机制:private内定义的属性不允许被覆盖
private: { private: {
currentIndex:0, currentIndex: 0,
title: '欢迎体验快应用开发', title: '欢迎体验快应用开发',
type: 'content_1', type: 'content_1',
tabItems:[ tabItems: [
{ {
text:"签到" text: "签到",
render: true
}, },
{ {
text:"新闻" text: "新闻",
render: false
}, },
{ {
text:"我的" text: "我的",
render: false
}, },
] ]
}, },
onInit() { onInit() {
this.$page.setTitleBar({ text: '测试' }) this.$page.setTitleBar({ text: '测试' })
}, },
changeTabactive (evt) { changeTabactive(evt) {
this.currentIndex = evt.index this.currentIndex = evt.index
this.tabItems[evt.index].render = true
}, },
clickTabBar (index) { clickTabBar(index) {
this.currentIndex = index this.currentIndex = index
}, },
routePage (param) { routePage(param) {
router.push({ router.push({
uri: 'ComponentTabs/complex/' + param uri: 'ComponentTabs/complex/' + param
}) })
} }
} }
</script> </script>
...@@ -72,41 +88,43 @@ export default { ...@@ -72,41 +88,43 @@ export default {
@import './../../assets/styles/style.less'; @import './../../assets/styles/style.less';
.tutorial-page { .tutorial-page {
display: flex;
flex-direction: column;
flex: 1;
.flexible-tabs {
flex: 1; flex: 1;
.flexible-tabs { flex-direction: column;
flex: 1; .flexible-tabbar {
flex-direction: column; height: 100px;
.flexible-tabbar { padding: 0 30px;
background-color: #f1f1f1;
align-items: center;
text {
flex-grow: 1;
height: 100px; height: 100px;
padding: 0 30px; margin: 0 30px;
background-color: #f1f1f1; text-align: center;
align-items: center; border: 0px solid #f1f1f1;
text { border-bottom-width: 5px;
flex-grow: 1; }
height: 100px; image {
margin: 0 30px; height: 50px;
text-align: center; width: 50px;
border: 0px solid #f1f1f1; resize-mode: contain;
border-bottom-width: 5px; }
} .active {
image { color: #0faeff;
height: 50px; /* border-bottom-color: #0faeff; */
width: 50px;
resize-mode: contain;
}
.active {
color: #0faeff;
border-bottom-color: #0faeff;
}
} }
.flexible-tab-content { }
.flexible-tab-content {
flex: 1;
.tab-content-section {
flex: 1; flex: 1;
.tab-content-section { background-color: #ff0;
flex: 1; justify-content: center;
background-color: #ff0;
justify-content: center;
}
} }
} }
} }
}
</style> </style>
<template> <template>
<div class="login-wrapper"> <div class="login-wrapper">
<c-input label="手机号" clearable="true" placeholder="请输入手机号" type="num" class="input-border" oninput="onInputUsername"></c-input> <c-input
<c-input label="密码" clearable="true" placeholder="请输入密码" type="password" class="input-border" oninput="onInputPassword"></c-input> label="手机号"
<text class="login-btn" onclick="login">登录</text> clearable="true"
placeholder="请输入手机号"
type="number"
value="{{phone}}"
class="input-border"
oninput="onInputPhone"
></c-input>
<c-input
label="验证码"
clearable="true"
placeholder="请输入验证码"
type="number"
value="{{smsCode}}"
class="input-border"
oninput="onInputSmsCode"
></c-input>
<text class="login-btn" onclick="login">登录</text>
<q-vcode time="10" onsend="sendHandler" onchange="changeHandler"></q-vcode>
</div> </div>
</template> </template>
<import name="q-vcode" src="qaui/src/components/vcode/index"></import>
<import name="c-input" src="../../Common/Component/CInput/index"></import> <import name="c-input" src="../../Common/Component/CInput/index"></import>
<script> <script>
import {login} from '../../Common/Api/user' import { login } from '../../Common/Api/user'
export default { export default {
data() { data() {
return { return {
username: '15156975131', phone: '15156975131',
password: '试试水123456' smsCode: '1234'
} }
}, },
onInit() { onInit() {
this.$page.setTitleBar({ text: '登录' }) this.$page.setTitleBar({ text: '登录' })
}, },
onInputUsername({ detail: { value } }) { onInputPhone({ detail: { value } }) {
this.username = value this.phone = value
}, },
onInputPassword({ detail: { value } }) { onInputSmsCode({ detail: { value } }) {
this.password = value this.smsCode = value
}, },
login() { login() {
if(this.username === null || this.username.length < 6) { if (this.phone === null || this.phone.length < 11) {
$utils.showToast('用户名长度不能小于6') $utils.showToast('手机号长度不能小于11位')
} else if (this.password === null || this.password.length < 6) { } else if (this.smsCode === null || this.smsCode.length < 4) {
$utils.showToast('密码长度不能小于6') $utils.showToast('验证码长度不能小于4位')
} else { } else {
login(this.username, this.password) login(this.phone, this.smsCode)
.then((data) => { .then((data) => {
this.$dispatch('success', { data: data }) this.$dispatch('success', { data: data })
}) })
...@@ -41,7 +60,13 @@ export default { ...@@ -41,7 +60,13 @@ export default {
this.$utils.showToast({ message: data }) this.$utils.showToast({ message: data })
}) })
} }
} },
sendHandler() {
console.log('request for sending verify code!')
},
changeHandler({ detail }) {
console.log('input value', detail.value)
},
} }
</script> </script>
......
<template> <template>
<div class="wrapper"> <div class="wrapper">
<text class="title">{{ title }}</text> <text onclick="click" class="title">{{ title }}</text>
</div> </div>
</template> </template>
<script> <script>
import geolocation from '@system.geolocation'
import vibrator from '@system.vibrator'
export default { export default {
data: { data: {
title: '视频' title: '视频'
}, },
onInit() {} onInit() { },
click() {
vibrator.vibrate({
mode: 'short'
})
// geolocation.getLocation({
// success: function (data) {
// console.log(
// `handling success: longitude = ${data.longitude}, latitude = ${
// data.latitude
// }`
// )
// },
// fail: function (data, code) {
// console.log(`handling fail, code = ${code}, errorMsg=${data}`)
// }
// })
}
} }
</script> </script>
......
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 to comment