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 diff is collapsed.
This diff is collapsed.
/**
*
* 验证规则
*
*/
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