Commit 64d49eb9 authored by jyx's avatar jyx

代码优化

parent afe8cef8
<script>
import {
PAKEAGE_NAME
} from './utils/utils.js';
import checkUpdate from './utils/update.js';
export default {
onLaunch: function(options) {
......@@ -86,7 +89,7 @@
bottomSafePadding: 12,
h5Url: 'https://api.mints-id.com/index.html',
baseUrl: 'https://dx.mints-tech.cn/minip-api/miniApi',
// baseUrl: 'http://192.168.110.71:8301/minip-api/miniApi',
// baseUrl: 'http://192.168.110.42:8303/miniApi',
titleButtonWidth: 38,
token: '',
userId: 0,
......@@ -96,7 +99,7 @@
versionName: 'v 1.0.0',
auth: false, // 三要素实名认证
userInfo: null,
pkgName: 'com.duben.dybookhm'
pkgName: PAKEAGE_NAME
}
};
</script>
......@@ -118,4 +121,5 @@
@import './scss/agreement.scss';
@import "@/uni_modules/uview-ui/index.scss";
@import '@/uni.scss';
@import '@/static/readiconfont.css';
</style>
\ No newline at end of file
This diff is collapsed.
......@@ -14,8 +14,12 @@ import {
import User from "../models/User.js";
import {
isEmpty,
isNotEmpty
isNotEmpty,
} from "../utils/util.js";
import {
PAKEAGE_NAME
} from "../../utils/utils.js";
import {
printError
} from "../utils/printUtil.js";
......@@ -49,18 +53,20 @@ function successHandler(url, param, res, callback) {
uni.setStorageSync('showLoginModal', false)
}
})
}
if (res.status != 200) {
toastMessage(`服务器异常,${res.status}`)
printError("请求失败", url, param, res.status, res.errMsg);
}
console.log(res)
if (res.statusCode != 200) {
toastMessage(`服务器异常,${res.statusCode}`)
printError("请求失败", url, param, res.statusCode, res.errMsg);
if (typeof callback == 'function') callback(false, res.errMsg)
} else {
if (res.data.code == 200) {
if (res.data.status == 200) {
if (typeof callback == 'function') callback(true, res.data.data)
} else if (res.data.code == 401) {
tokenExpireFn()
if (typeof callback == 'function') callback(false, res.data.message);
} else {
} else {
toastMessage(`服务器异常,${res.data.code}`)
printError("请求失败", url, param, res.data.code);
if (typeof callback == 'function') callback(false, res.data.code)
......@@ -103,7 +109,10 @@ function refreshUserInfo() {
name: userData.username,
nickName: userData.nickname,
avater: userData.avatar,
})
isVip: userData.expireTime > 0
})
console.log(user)
console.log(userData)
saveNickname(userData.nickname);
saveUserInfo(user); // 存储用户数据
postNotification(KEY_NOTIFICATION_LOGIN_SUCCESS); // 通知登录成功
......@@ -138,13 +147,13 @@ function postPhone(data, callback) {
// 请求token
function requestToken(data, callback) {
let url = `${config["BASE_URL"]}/user/ttLogin`;
let header = {
pkgName: 'com.duben.dybookhm',
token: ``
let header = {
pkgname: PAKEAGE_NAME,
token: ``
}
uni.request({
url,
data,
data,
header,
method: "POST",
success: (res) => {
......@@ -158,18 +167,19 @@ function requestToken(data, callback) {
// 请求用户数据
function requestUserInfo(callback) {
let url = `${config['BASE_URL']}/system/user/getCurrentUserInfo`;
let url = `${config['BASE_URL']}/user/baseMsg`;
let header = {
Authorization: `${readToken()}`
token: `${readToken()}`,
pkgname: PAKEAGE_NAME
}
uni.request({
url,
header,
method: "POST",
success: (res) => {
success: (res) => {
successHandler(url, {}, res, callback);
},
fail: (error) => {
fail: (error) => {
failHandler(url, data, error, callback);
}
})
......@@ -221,7 +231,8 @@ function saveToken(token) {
function readToken() {
if (!LOCAL_TOKEN) {
LOCAL_TOKEN = readStorage(KEY_STORAGE_TOKEN)
// LOCAL_TOKEN = readStorage(KEY_STORAGE_TOKEN)
LOCAL_TOKEN = readStorage('token')
}
return LOCAL_TOKEN;
}
......
......@@ -9,8 +9,11 @@ import {
printError,
} from "./printUtil.js"
import {
appendParam
appendParam,
} from "./util";
import {
PAKEAGE_NAME
} from "../../utils/utils";
import {
addNormalNotificationObserver,
removeNotificationObserver
......@@ -65,11 +68,11 @@ let apiRequest = function({
let option = {}; // 请求参数
// url 处理
let handlerUrl = `${config["BASE_URL"]}${urlModule?urlModule:""}${url}`;
if (handlerUrl.indexOf("?") == -1) {
handlerUrl = `${handlerUrl}?t=${new Date().getTime()}`;
} else {
handlerUrl = `${handlerUrl}&t=${new Date().getTime()}`;
}
// if (handlerUrl.indexOf("?") == -1) {
// handlerUrl = `${handlerUrl}?t=${new Date().getTime()}`;
// } else {
// handlerUrl = `${handlerUrl}&t=${new Date().getTime()}`;
// }
option = {
url: handlerUrl,
method
......@@ -87,7 +90,7 @@ let apiRequest = function({
} else { // 其余对象照常插入
option.data = data;
}
}
}
console.log('123')
// token处理
let token = readToken();
......@@ -96,9 +99,9 @@ let apiRequest = function({
if (typeof originQuery.complete == 'function') originQuery.complete();
return;
}
option.header = {
pkgName: 'com.duben.dybookhm',
token: `${token}`
option.header = {
pkgName: PAKEAGE_NAME,
token: `${token}`
}
// header处理
if (header) {
......@@ -106,7 +109,7 @@ let apiRequest = function({
...option.header,
...header
}
}
}
console.log('123')
printInfo("start Req", option);
let requestTask = uni.request({
......@@ -237,9 +240,9 @@ function apiUPLOAD({
}
option.url = `${option.url}?t=${new Date().getTime()}`; // 路径
option.header = {
pkgName: 'com.duben.dybookhm',
token: `${token}`
option.header = {
pkgName: PAKEAGE_NAME,
token: `${token}`
}
if (header) {
option.header = {
......@@ -283,12 +286,12 @@ function successHandler(originQuery, requestTask, res) {
apiRequest(originQuery);
}
removeNotificationObserver(KEY_NOTIFICATION_LOGIN_SUCCESS, requestTask);
}, requestTask);
}, requestTask);
if (uni.getStorageSync('showLoginModal')) {
return
}
uni.setStorageSync('showLoginModal', true)
}
uni.setStorageSync('showLoginModal', true)
uni.showModal({
title: "登录状态已过期",
content: "当前登录状态已过期,请重新登录!",
......@@ -299,8 +302,8 @@ function successHandler(originQuery, requestTask, res) {
showLoginView();
} else {
logout(() => {}, true);
}
uni.setStorageSync('showLoginModal', false)
}
uni.setStorageSync('showLoginModal', false)
}
})
}
......@@ -312,14 +315,14 @@ function successHandler(originQuery, requestTask, res) {
tokenExpireFn();
} else {
if (typeof res.data == 'string') res.data = JSON.parse(res.data);
if (res.data.code == 200) {
if (res.data.status == 200) {
printDebug("请求结果", originQuery.url, res.data.data);
if (typeof originQuery.callback == 'function') originQuery.callback(true, res.data.data);
} else if (res.data.code == 401) {
} else if (res.data.status == 401) {
tokenExpireFn()
if (typeof originQuery.callback == 'function') originQuery.callback(false, res.data.msg);
} else {
toastMessage(res.data.message ? res.data.message : res.data.code ? res.data.code : "未知错误");
toastMessage(res.data.message ? res.data.message : res.data.status ? res.data.status : "未知错误");
printError("请求失败", originQuery.url, res.data.message);
if (typeof originQuery.callback == 'function') originQuery.callback(false, res.data.message);
}
......
const {
printError
} = require("./printUtil")
function saveStorage(key, value) {
try {
uni.setStorageSync(key, value)
} catch (error) {
printError("save storage 错误", error.errMsg, key, value);
}
}
function readStorage(key) {
try {
return uni.getStorageSync(key);
} catch (error) {
printError("read storage 错误", error.errMsg, key);
}
}
function removeStorage(key) {
try {
return uni.removeStorageSync(key);
} catch (error) {
printError("remove storage 错误", error.errMsg, key);
}
}
module.exports = {
saveStorage,
readStorage,
removeStorage
}
const {
printError
} = require("./printUtil")
function saveStorage(key, value) {
try {
uni.setStorageSync(key, value)
} catch (error) {
printError("save storage 错误", error.errMsg, key, value);
}
}
function readStorage(key) {
try {
return uni.getStorageSync(key);
} catch (error) {
printError("read storage 错误", error.errMsg, key);
}
}
function removeStorage(key) {
try {
return uni.removeStorageSync(key);
} catch (error) {
printError("remove storage 错误", error.errMsg, key);
}
}
function clearStorage(key) {
try {
return uni.clearStorageSync(key);
} catch (error) {
printError("remove storage 错误", error.errMsg, key);
}
}
module.exports = {
saveStorage,
readStorage,
removeStorage,
clearStorage
}
\ No newline at end of file
<template>
<view class="search-box" @click="search">
<view class="search-zone c-flex_row c-align_center">
<view class="item">
<uni-icons type='search' size='28' color="#e5e5e5"></uni-icons>
</view>
<input class="item c-flex_1" placeholder="搜索书名/作者名" disabled />
<view class="button item">
搜索
</view>
</view>
</view>
</template>
<script>
import {
gotoBookSearchPage
} from "../../common/services/page-route.js"
import {
ENUM_SEARCH_TYPE
} from "../../static/enums/enum_value.js";
export default {
props: {
searchType: {
type: Object,
default: function() {
return ENUM_SEARCH_TYPE.WAREHOUSE
}
}
},
methods: {
search() {
gotoBookSearchPage(this.searchType);
}
}
}
</script>
<style lang="scss" scoped>
.search-box {
background: transparent;
padding: 10rpx 20rpx;
<template>
<view class="search-box" @click="search">
<view class="search-zone c-flex_row c-align_center">
<view class="item">
<uni-icons type='search' size='28' color="#e5e5e5"></uni-icons>
</view>
<input class="item c-flex_1" placeholder="搜索书名/作者名" disabled />
<view class="mbutton item">
搜索
</view>
</view>
</view>
</template>
<script>
import {
gotoBookSearchPage
} from "../../common/services/page-route.js"
import {
ENUM_SEARCH_TYPE
} from "../../static/enums/enum_value.js";
export default {
props: {
searchType: {
type: Object,
default: function() {
return ENUM_SEARCH_TYPE.WAREHOUSE
}
}
},
methods: {
search() {
gotoBookSearchPage(this.searchType);
}
}
}
</script>
<style lang="scss" scoped>
.search-box {
background: transparent;
padding: 10rpx 20rpx;
.search-zone {
border-radius: 35rpx;
background: #fff;
padding: 4rpx;
font-size: 28rpx;
.item {
margin-left: 20rpx;
}
.button {
height: 70rpx;
line-height: 70rpx;
width: 120rpx;
text-align: center;
color: #fff;
background: #007aff;
border-radius: 35rpx;
}
}
}
width: 100%;
border-radius: 35rpx;
background: #fff;
padding: 4rpx;
font-size: 28rpx;
.item {
margin-left: 20rpx;
}
.mbutton {
width: 100rpx;
height: 70rpx;
line-height: 70rpx;
text-align: center;
color: #fff;
background: #007aff;
border-radius: 35rpx;
}
}
}
</style>
\ No newline at end of file
<template>
<view>
<c-list ref='list' :showShelfEmpty="true" flag='bookshelf' :needLogin="true" :height="height" url='/v1/collect/'
:param="requestParam" @change='changeData'>
<c-list ref='list' :showShelfEmpty="true" flag='bookshelf' :needLogin="true" :height="height" url='/book/collectList/'
:param="requestParam" @change='changeData' method="POST">
<book-list-item v-for='(item, index) in dataList' :key='index' :item='item'
@tapItem='tapItem($event, index)' @close='tapClose($event, index)'>
<template v-slot:footer>
......@@ -59,7 +59,8 @@
}
},
changeData(e) {
this.dataList = e.detail.data.map(item => {
console.log(e)
this.dataList = e.detail.data.list.map(item => {
return new BookshelfBookItem(item)
})
},
......
......@@ -290,8 +290,8 @@
...param,
...this.param
}
}
}
apiRequest({
url: this.url,
method: this.method || "GET",
......
<template>
<view>
<c-list ref='list' flag='warehouse' method="POST" :height="height" url='/v1/article/' :param="requestParam"
<c-list ref='list' flag='warehouse' method="POST" :height="height" url='/book/articleList/' :param="requestParam"
@change='changeData'>
<book-list-item v-for='(item, index) in dataList' :key='index' :item='item' :showClose='false'
@tapItem='tapItem($event, index)' @close='tapClose($event, index)'>
......@@ -39,7 +39,7 @@
computed: {
requestParam: function() {
return {
tagId: this.category.value
categoryId: this.category.value
}
}
},
......
......@@ -5,7 +5,7 @@ import {
function getCategorys(callback) {
apiPOST({
url: "/v1/tag/",
url: "/book/categoryList/",
callback
})
}
......
......@@ -75,7 +75,7 @@
watch: {
categroyChange: {
handler: function(n, o) {
this.$nextTick(() => {
this.$nextTick(() => {
let ref = this.$refs.bookList;
if (ref) {
ref[n.currentIndex].initRefresh();
......@@ -88,13 +88,13 @@
methods: {
show() {
setTimeout(() => {
// 匹配用户直接跳转小说
var bookId=uni.getStorageSync('firstBookId')
// 匹配用户直接跳转小说
var bookId = uni.getStorageSync('firstBookId')
if (bookId != '') {
gotoBookContentPage(bookId);
uni.setStorage({
key: 'firstBookId',
data: ''
gotoBookContentPage(bookId);
uni.setStorage({
key: 'firstBookId',
data: ''
});
}
}, 800);
......@@ -120,7 +120,7 @@
getCategoryData() {
getCategorys((success, data) => {
if (success) {
let result = data ? data.map(item => {
let result = data.records ? data.records.map(item => {
return new Category(item)
}).sort((a, b) => {
return a.sort - b.sort
......
......@@ -9,7 +9,7 @@ const {
}
} = require("../configEnum");
export default {
// BASE_URL: "http://192.168.110.6:8800",
// BASE_URL: "http://192.168.110.42:8303/miniApi",
BASE_URL: "https://dx.mints-tech.cn/minip-api/miniApi",
BASE_URL_MODULE: "",
BASE_SOCKET_URL: "",
......
......@@ -9,7 +9,7 @@ const {
}
} = require("../configEnum");
export default {
// BASE_URL: "https://book.mints-id.com",
// BASE_URL: "http://192.168.110.42:8303/miniApi",
BASE_URL: "https://dx.mints-tech.cn/minip-api/miniApi",
BASE_URL_MODULE: "",
BASE_SOCKET_URL: "",
......
<template>
<view :style="[bgStyle]">
<z-paging :style="[bgStyle]">
<c-empty v-if='showEmpty'></c-empty>
<template v-else>
<detail-warn></detail-warn>
......@@ -18,13 +18,13 @@
<c-login :isShareLink="true"></c-login>
<popup :show="showMoibleLogin" @close="showMoibleLogin=false">
<view>
<button open-type="getPhoneNumber" @getphonenumber="MygetPhonenumber">
<view>请先绑定手机号</view>
<view style="color:green;">去绑定</view>
<button open-type="getPhoneNumber" @getphonenumber="MygetPhonenumber">
<view>请先绑定手机号</view>
<view style="color:green;">去绑定</view>
</button>
</view>
</popup>
</view>
</z-paging>
</template>
<script>
......@@ -126,7 +126,12 @@
// 用户已登录需要记录阅读记录
if (info.userInfo) {
addReadRecord(this.bookId)
}
}
console.log(info)
console.log(this.userInfo)
// this.showVipOpen = data.openVips
// // 用户变动,需要刷新数据
// this.$nextTick(() => {
// uni.startPullDownRefresh({})
......@@ -246,10 +251,10 @@
},
// 文章数据刷新
refreshBookData(bookId) {
getOpens((success, data) => {
// this.showBeanOpen = data.openBeans
this.showVipOpen = data.openVips
})
// getOpens((success, data) => {
// // this.showBeanOpen = data.openBeans
// this.showVipOpen = data.openVips
// })
getBookDetailData(bookId, (success, data) => {
setTimeout(() => {
uni.stopPullDownRefresh();
......@@ -300,19 +305,19 @@
this.tapVipPop()
},
// 展示充值VIP弹框
tapVipPop() {
if (this.mobileLoginLock) {
this.showMoibleLogin = true
return
}
tapVipPop() {
if (this.mobileLoginLock) {
this.showMoibleLogin = true
return
}
this.showVip = true;
},
// 展示充值书豆弹框
tapBeanPop() {
if (this.mobileLoginLock) {
this.showMoibleLogin = true
return
if (this.mobileLoginLock) {
this.showMoibleLogin = true
return
}
this.showBean = true;
......
......@@ -168,15 +168,15 @@
this.imageError = true
},
refreshPackData() {
getPackData((success, data) => {
if (success) {
this.vipPackList = data.map(item => {
let result = new Pack(item);
result.isBeanPack = false;
return result;
})
}
})
// getPackData((success, data) => {
// if (success) {
// this.vipPackList = data.map(item => {
// let result = new Pack(item);
// result.isBeanPack = false;
// return result;
// })
// }
// })
getBookBeanPackData((success, data) => {
if (success) {
this.beanPackList = data.map(item => {
......
......@@ -120,11 +120,11 @@
this.showPop = false;
},
refrehsPackData() {
getPackData((success, data) => {
this.packList = data.map(item => {
return new Pack(item);
})
})
// getPackData((success, data) => {
// this.packList = data.map(item => {
// return new Pack(item);
// })
// })
},
choosePack(item, index) {
this.selectedIndex = index;
......
import {
addNormalNotificationObserver,
postNotification,
removeNotificationObserver
} from "../../../../common/utils/notificationCenter";
import {
readStorage,
saveStorage
} from "../../../../common/utils/storageUtil";
import ContentFormat from "../models/ContentFormat";
import {
apiGET,
apiPOST
} from "../../../../common/utils/apiRequest.js"
/** 获取文章详情
* @param {Object} bookId
* @param {Object} callback
*/
function getBookDetailData(bookId, callback) {
apiPOST({
url: `/v1/article/info?id=${bookId}`,
callback
})
}
/** 获取推荐文章
* @param {Object} bookId
* @param {Object} callback
*/
function getBookRecommendData(bookId,callback) {
apiPOST({
url: `/v1/article/recommend?id=${bookId}`,
callback
})
}
/** 添加阅读记录
* @param {Object} bookId
* @param {Object} callback
*/
function addReadRecord(bookId, callback) {
apiGET({
url: `/readSystem/system/readRecord/addReadRecord?articleId=${bookId}`,
callback
})
}
// 样式设置
const KEY_STORAGE_CONTENT_FORMAT = "KEY_SOTRAGE_CONTENT_FORMAT";
const KEY_NOTIFICATION_CONTENT_FORMAT_CHANGE = "KEY_NOTIFICATION_CONTENT_FORMAT_CHANGE";
function saveContentFormat(format) {
let result = readContentFormat();
Object.keys(format).forEach(key => {
let value = format[key];
result[key] = value || result[key];
})
saveStorage(KEY_STORAGE_CONTENT_FORMAT, result);
notifyContentFormatChange(new ContentFormat(result));
}
function readContentFormat() {
let result = readStorage(KEY_STORAGE_CONTENT_FORMAT);
if (result) {
result = new ContentFormat(result);
} else {
result = new ContentFormat({
fontSize: 17,
backgroundColor: "#fff"
})
}
return result;
}
function notifyContentFormatChange(format) {
postNotification(KEY_NOTIFICATION_CONTENT_FORMAT_CHANGE, format);
}
function watchContentFormatChange(fn, observer) {
if (typeof fn == 'function') fn.call(observer, readContentFormat());
addNormalNotificationObserver(KEY_NOTIFICATION_CONTENT_FORMAT_CHANGE, (data) => {
if (typeof fn == 'function') fn.call(observer, data);
}, observer)
}
function removeContentFormatChangeWatch(observer) {
removeNotificationObserver(KEY_NOTIFICATION_CONTENT_FORMAT_CHANGE, observer);
}
module.exports = {
getBookDetailData,
getBookRecommendData,
addReadRecord,
/**
* content format
*/
saveContentFormat,
readContentFormat,
notifyContentFormatChange,
watchContentFormatChange,
removeContentFormatChangeWatch
import {
addNormalNotificationObserver,
postNotification,
removeNotificationObserver
} from "../../../../common/utils/notificationCenter";
import {
readStorage,
saveStorage
} from "../../../../common/utils/storageUtil";
import ContentFormat from "../models/ContentFormat";
import {
apiGET,
apiPOST
} from "../../../../common/utils/apiRequest.js"
/** 获取文章详情
* @param {Object} bookId
* @param {Object} callback
*/
function getBookDetailData(bookId, callback) {
apiPOST({
url: `/book/info`,
data: {
id: bookId
},
callback
})
}
/** 获取推荐文章
* @param {Object} bookId
* @param {Object} callback
*/
function getBookRecommendData(bookId, callback) {
apiPOST({
url: `/book/recommend`,
data: {
id: bookId
},
callback
})
}
/** 添加阅读记录
* @param {Object} bookId
* @param {Object} callback
*/
function addReadRecord(bookId, callback) {
apiPOST({
url: `/book/addReadRecord`,
data: {
articleId: bookId
},
callback
})
}
// 样式设置
const KEY_STORAGE_CONTENT_FORMAT = "KEY_SOTRAGE_CONTENT_FORMAT";
const KEY_NOTIFICATION_CONTENT_FORMAT_CHANGE = "KEY_NOTIFICATION_CONTENT_FORMAT_CHANGE";
function saveContentFormat(format) {
let result = readContentFormat();
Object.keys(format).forEach(key => {
let value = format[key];
result[key] = value || result[key];
})
saveStorage(KEY_STORAGE_CONTENT_FORMAT, result);
notifyContentFormatChange(new ContentFormat(result));
}
function readContentFormat() {
let result = readStorage(KEY_STORAGE_CONTENT_FORMAT);
if (result) {
result = new ContentFormat(result);
} else {
result = new ContentFormat({
fontSize: 17,
backgroundColor: "#fff"
})
}
return result;
}
function notifyContentFormatChange(format) {
postNotification(KEY_NOTIFICATION_CONTENT_FORMAT_CHANGE, format);
}
function watchContentFormatChange(fn, observer) {
if (typeof fn == 'function') fn.call(observer, readContentFormat());
addNormalNotificationObserver(KEY_NOTIFICATION_CONTENT_FORMAT_CHANGE, (data) => {
if (typeof fn == 'function') fn.call(observer, data);
}, observer)
}
function removeContentFormatChangeWatch(observer) {
removeNotificationObserver(KEY_NOTIFICATION_CONTENT_FORMAT_CHANGE, observer);
}
module.exports = {
getBookDetailData,
getBookRecommendData,
addReadRecord,
/**
* content format
*/
saveContentFormat,
readContentFormat,
notifyContentFormatChange,
watchContentFormatChange,
removeContentFormatChangeWatch
}
\ No newline at end of file
<template>
<view class="search-header-bar">
<view class="input-box item c-flex_1">
<uni-easyinput :value='searchKeyword' placeholder="请输入书名或者作者名" :focus='focus' :styles="inputStyles"
confirmType="search" trim="all" :inputBorder="true" @clear='clearInput'
@change='changeInput'></uni-easyinput>
</view>
<view class="button-box item" @click="tapSearch">
<view class="title">
搜索
</view>
</view>
</view>
</template>
<script>
import {
saveSearchHistory
} from "../services/index.js"
export default {
props: {
keyword: {
type: String,
default: ""
}
},
data: function() {
return {
searchKeyword: "",
focus: true,
height: 0,
}
},
computed: {
inputStyles: function() {
return {
borderColor: "#e5e5e5"
}
}
},
watch: {
keyword: {
handler: function(n) {
this.searchKeyword = n
},
immediate: true
},
searchKeyword: {
handler: function(n, o) {
if (n == o) return;
if (!n) {
this.clearSearch();
} else {
this.startSearch(n)
}
},
immediate: true
},
},
methods: {
clearSearch() {
this.$emit("clear");
},
startSearch(keyword) {
saveSearchHistory(keyword);
this.$emit("start", {
detail: {
keyword
}
})
},
clearInput() {
this.searchKeyword = "";
this.focus = false;
},
changeInput(e) {
this.searchKeyword = e;
},
tapSearch() {
this.focus = false;
}
}
}
</script>
<style lang="scss" scoped>
.search-header-bar {
padding: 15rpx 30rpx;
display: flex;
flex-direction: row;
align-items: center;
background: #fff;
font-size: 28rpx;
.item {
margin-right: 15rpx;
}
.item:last-child {
margin-right: 0;
}
.input-box {}
.button-box {
height: 50rpx;
line-height: 50rpx;
width: 120rpx;
text-align: center;
border-radius: 10rpx;
background: #007aff;
color: #fff;
}
}
<template>
<view class="search-header-bar">
<view class="input-box item c-flex_1">
<uni-easyinput v-model="searchKeyword" placeholder="请输入书名或者作者名" :focus='focus' confirmType="search"
trim="all" :inputBorder="true" @clear="clearInput" @change="changeInput"
@confirm="changeInput"></uni-easyinput>
</view>
<view class="button-box item" @click="tapSearch">
<view class="title">
搜索
</view>
</view>
</view>
</template>
<script>
import {
saveSearchHistory
} from "../services/index.js"
export default {
props: {
keyword: {
type: String,
default: ""
}
},
data: function() {
return {
searchKeyword: "",
focus: true,
height: 0,
}
},
computed: {
inputStyles: function() {
return {
borderColor: "#e5e5e5"
}
}
},
watch: {
keyword: {
handler: function(n) {
this.searchKeyword = n
},
immediate: true
},
searchKeyword: {
handler: function(n, o) {
if (n == o) return;
if (!n) {
this.clearSearch();
} else {
this.startSearch(n)
}
},
immediate: true
},
},
methods: {
clearSearch() {
this.$emit("clear");
},
startSearch(keyword) {
saveSearchHistory(keyword);
this.$emit("start", {
detail: {
keyword
}
})
},
clearInput() {
this.searchKeyword = "";
this.focus = false;
},
changeInput(e) {
this.searchKeyword = e;
},
tapSearch() {
this.focus = false;
}
}
}
</script>
<style lang="scss" scoped>
.search-header-bar {
padding: 15rpx 30rpx;
display: flex;
flex-direction: row;
align-items: center;
background: #fff;
font-size: 28rpx;
.item {
margin-right: 15rpx;
}
.item:last-child {
margin-right: 0;
}
.input-box {}
.button-box {
height: 50rpx;
line-height: 50rpx;
width: 120rpx;
text-align: center;
border-radius: 10rpx;
background: #007aff;
color: #fff;
}
}
</style>
\ No newline at end of file
......@@ -26,6 +26,7 @@
import {
saveSearchHistory,
watchSearchHistoryChange,
clearSearchHistory,
removeSearchHistoryChangeWatch,
getHotRecommondData,
} from "../services/index.js"
......@@ -68,7 +69,7 @@
},
methods: {
tapDeleteHistory() {
saveSearchHistory([])
clearSearchHistory()
},
tapItem(e, flag) {
this.$emit('chooseKeyword', {
......
<template>
<c-list ref="list" flag='search' :needLogin="needLogin" :height="height" :url='requestUrl' :param='requestParam'
@change='changeData'>
<book-list-item v-for='(item, index) in dataList' :key='index' :item='item' :showClose="false"
@tapItem='tapItem($event, index)'>
</book-list-item>
</c-list>
</template>
<script>
import WarehouseBookItem from "../../../../components/warehouse/models/WarehouseBookItem.js"
import {
gotoBookContentPage
} from "../../../../common/services/page-route.js"
import {
ENUM_SEARCH_TYPE
} from "../../../../static/enums/enum_value.js"
export default {
props: {
height: {
type: Number,
default: 0
},
keyword: {
type: String,
default: ""
},
result: {
type: Array,
default: function() {
return null
}
},
searchType: {
type: Object,
default: function() {
return ENUM_SEARCH_TYPE.WAREHOUSE
}
}
},
data: function() {
return {
dataList: null
}
},
computed: {
needLogin: function() {
return this.searchType && this.searchType.value == ENUM_SEARCH_TYPE.BOOKSHELF.value
},
requestUrl: function() {
return !this.searchType || this.searchType.value == ENUM_SEARCH_TYPE.WAREHOUSE.value ?
"/book/articleList/" :
"/readSystem/v1/collect/"
},
requestParam: function() {
return {
searchName: this.keyword
}
}
},
watch: {
result: {
handler: function(n) {
this.dataList = n;
},
immediate: true
}
},
methods: {
refreshList() {
let ref = this.$refs.list;
if (ref) {
ref.onPullRefreshing();
}
},
changeData(e) {
this.dataList = e.detail.data.map(item => {
return new WarehouseBookItem(item)
})
},
tapItem(e, index) {
gotoBookContentPage(e.detail.data.id)
},
}
}
</script>
<style>
<template>
<c-list ref="list" flag='search' method="POST" :needLogin="needLogin" :height="height" :url='requestUrl' :param='requestParam'
@change='changeData'>
<book-list-item v-for='(item, index) in dataList' :key='index' :item='item' :showClose="false"
@tapItem='tapItem($event, index)'>
</book-list-item>
</c-list>
</template>
<script>
import WarehouseBookItem from "../../../../components/warehouse/models/WarehouseBookItem.js"
import {
gotoBookContentPage
} from "../../../../common/services/page-route.js"
import {
ENUM_SEARCH_TYPE
} from "../../../../static/enums/enum_value.js"
export default {
props: {
height: {
type: Number,
default: 0
},
keyword: {
type: String,
default: ""
},
result: {
type: Array,
default: function() {
return null
}
},
searchType: {
type: Object,
default: function() {
return ENUM_SEARCH_TYPE.WAREHOUSE
}
}
},
data: function() {
return {
dataList: null,
}
},
computed: {
needLogin: function() {
return this.searchType && this.searchType.value == ENUM_SEARCH_TYPE.BOOKSHELF.value
},
requestUrl: function() {
return !this.searchType || this.searchType.value == ENUM_SEARCH_TYPE.WAREHOUSE.value ?
"/book/articleList/" :
"/book/collect/"
},
requestParam: function() {
return {
searchName: this.keyword
}
}
},
watch: {
result: {
handler: function(n) {
this.dataList = n;
},
immediate: true
}
},
methods: {
refreshList() {
let ref = this.$refs.list;
if (ref) {
ref.onPullRefreshing();
}
},
changeData(e) {
this.dataList = e.detail.data.map(item => {
return new WarehouseBookItem(item)
})
},
tapItem(e, index) {
gotoBookContentPage(e.detail.data.id)
},
}
}
</script>
<style>
</style>
\ No newline at end of file
import {
addNormalNotificationObserver,
postNotification,
removeNotificationObserver
} from "../../../../common/utils/notificationCenter";
import {
readStorage,
saveStorage
} from "../../../../common/utils/storageUtil";
const KEY_STORAGE_SEARCH_HISTORY = "KEY_STORAGE_SEARCH_HISTORY";
const KEY_NOTIFICATION_SEARCH_HISTORY_CHANGE = 'KEY_NOTIFICATION_SEARCH_HISTORY_CHANGE';
const MAX_SEARCH_HISTORY_LENGTH = 10;
function saveSearchHistory(keyword) {
if (!keyword) return;
let result = readSearchHistory();
if (result.indexOf(keyword) != -1) return;
if (result.length == MAX_SEARCH_HISTORY_LENGTH) {
result.shift();
}
result.push(keyword);
saveStorage(KEY_STORAGE_SEARCH_HISTORY, result);
noticeSearchHistoryChange(result);
}
function readSearchHistory() {
let result = readStorage(KEY_STORAGE_SEARCH_HISTORY);
return result || []
}
function noticeSearchHistoryChange(result) {
if (!result) {
result = readSearchHistory();
}
postNotification(KEY_NOTIFICATION_SEARCH_HISTORY_CHANGE, {
result
})
}
function watchSearchHistoryChange(fn, observer) {
if (typeof fn == 'function') fn.call(observer, readSearchHistory());
addNormalNotificationObserver(KEY_NOTIFICATION_SEARCH_HISTORY_CHANGE, (info) => {
if (typeof fn == 'function') fn.call(observer, info.result)
}, observer);
}
function removeSearchHistoryChangeWatch(observer) {
removeNotificationObserver(KEY_NOTIFICATION_SEARCH_HISTORY_CHANGE, observer);
}
function getHotRecommondData(pageNo, pageSize, callback) {
if (typeof callback == 'function') callback(true, []);
}
module.exports = {
/**
* 搜索历史
*/
saveSearchHistory,
import {
addNormalNotificationObserver,
postNotification,
removeNotificationObserver
} from "../../../../common/utils/notificationCenter";
import {
readStorage,
saveStorage,
clearStorage
} from "../../../../common/utils/storageUtil";
const KEY_STORAGE_SEARCH_HISTORY = "KEY_STORAGE_SEARCH_HISTORY";
const KEY_NOTIFICATION_SEARCH_HISTORY_CHANGE = 'KEY_NOTIFICATION_SEARCH_HISTORY_CHANGE';
const MAX_SEARCH_HISTORY_LENGTH = 10;
function saveSearchHistory(keyword) {
if (!keyword) return;
let result = readSearchHistory();
if (result.indexOf(keyword) != -1) return;
if (result.length == MAX_SEARCH_HISTORY_LENGTH) {
result.shift();
}
result.push(keyword);
saveStorage(KEY_STORAGE_SEARCH_HISTORY, result);
noticeSearchHistoryChange(result);
}
function clearSearchHistory() {
clearStorage(KEY_STORAGE_SEARCH_HISTORY);
noticeSearchHistoryChange([]);
}
function readSearchHistory() {
let result = readStorage(KEY_STORAGE_SEARCH_HISTORY);
return result || []
}
function noticeSearchHistoryChange(result) {
if (!result) {
result = readSearchHistory();
}
postNotification(KEY_NOTIFICATION_SEARCH_HISTORY_CHANGE, {
result
})
}
function watchSearchHistoryChange(fn, observer) {
if (typeof fn == 'function') fn.call(observer, readSearchHistory());
addNormalNotificationObserver(KEY_NOTIFICATION_SEARCH_HISTORY_CHANGE, (info) => {
if (typeof fn == 'function') fn.call(observer, info.result)
}, observer);
}
function removeSearchHistoryChangeWatch(observer) {
removeNotificationObserver(KEY_NOTIFICATION_SEARCH_HISTORY_CHANGE, observer);
}
function getHotRecommondData(pageNo, pageSize, callback) {
if (typeof callback == 'function') callback(true, []);
}
module.exports = {
/**
* 搜索历史
*/
saveSearchHistory,
readSearchHistory,
watchSearchHistoryChange,
removeSearchHistoryChangeWatch,
/**
* 热门推荐
*/
getHotRecommondData,
clearSearchHistory,
watchSearchHistoryChange,
removeSearchHistoryChangeWatch,
/**
* 热门推荐
*/
getHotRecommondData,
}
\ No newline at end of file
......@@ -134,11 +134,11 @@
})
},
refrehsPackData() {
getPackData((success, data) => {
this.packList = data.map(item => {
return new Pack(item);
})
})
// getPackData((success, data) => {
// this.packList = data.map(item => {
// return new Pack(item);
// })
// })
},
choosePack(item, index) {
this.selectedIndex = index;
......
......@@ -110,6 +110,6 @@
<style lang="scss">
.body {
height: 100%;
background-color: white;
// background-color: white;
}
</style>
\ No newline at end of file
......@@ -47,8 +47,8 @@
methods: {
ttLoging() {
var that = this;
var obj = tt.getLaunchOptionsSync()
var obj = tt.getLaunchOptionsSync()
var tips2 = ''; // 投放测试
var thirdParam = "";
var bookId = '';
......@@ -59,16 +59,26 @@
if (this.tips1 == 'mints_book' || tips2 == 'mints_book') {
this.slotParam = JSON.stringify(obj.query);
this.$refs.select.open('center');
}
}
// 首次跳转进小书页面
if (bookId != '') {
uni.setStorage({
key: 'firstBookId',
data: bookId
uni.setStorage({
key: 'firstBookId',
data: bookId
});
}
// app.globalData.userId = data.idcode;
// uni.setStorage({
// key: 'token',
// data: 'D6E76AC8E89ABE548B56568B8814D578D6980EAB68926EB1E7C07BF9E96A316F5F433703067DF5142735505C42F58997'
// });
// setTimeout(() => {
// redirectTo('home');
// }, 1000);
// return
tt.login({
force: true,
success(res) {
......@@ -83,7 +93,7 @@
showLoading: false,
success: ({
data
}) => {
}) => {
app.globalData.userId = data.idcode;
uni.setStorage({
key: 'token',
......
......@@ -300,4 +300,17 @@ body {
line-height: 40rpx;
padding: 0 16rpx;
display: inline-block;
}
.c-flex_row {
display: flex;
flex-direction: row;
}
.c-align_center{
align-items: center;
}
.c-flex_1{
flex: 1;
}
\ No newline at end of file
## 1.1.18(2024-04-11)
- 修复 easyinput组件双向绑定问题
## 1.1.17(2024-03-28)
- 修复 在头条小程序下丢失事件绑定的问题
## 1.1.16(2024-03-20)
- 修复 在密码输入情况下 清除和小眼睛覆盖bug 在edge浏览器下显示双眼睛bug
## 1.1.15(2024-02-21)
- 新增 左侧插槽:left
## 1.1.14(2024-02-19)
- 修复 onBlur的emit传值错误
## 1.1.12(2024-01-29)
- 补充 adjust-position文档属性补充
## 1.1.11(2024-01-29)
- 补充 adjust-position属性传递值:(Boolean)当键盘弹起时,是否自动上推页面
## 1.1.10(2024-01-22)
- 去除 移除无用的log输出
## 1.1.9(2023-04-11)
- 修复 vue3 下 keyboardheightchange 事件报错的bug
## 1.1.8(2023-03-29)
- 优化 trim 属性默认值
## 1.1.7(2023-03-29)
- 新增 cursor-spacing 属性
## 1.1.6(2023-01-28)
- 新增 keyboardheightchange 事件,可监听键盘高度变化
## 1.1.5(2022-11-29)
- 优化 主题样式
## 1.1.4(2022-10-27)
- 修复 props 中背景颜色无默认值的bug
## 1.1.0(2022-06-30)
- 新增 在 uni-forms 1.4.0 中使用可以在 blur 时校验内容
- 新增 clear 事件,点击右侧叉号图标触发
- 新增 change 事件 ,仅在输入框失去焦点或用户按下回车时触发
- 优化 组件样式,组件获取焦点时高亮显示,图标颜色调整等
## 1.0.5(2022-06-07)
- 优化 clearable 显示策略
## 1.0.4(2022-06-07)
- 优化 clearable 显示策略
## 1.0.3(2022-05-20)
- 修复 关闭图标某些情况下无法取消的 bug
## 1.0.2(2022-04-12)
- 修复 默认值不生效的 bug
## 1.0.1(2022-04-02)
- 修复 value 不能为 0 的 bug
## 1.0.0(2021-11-19)
- 优化 组件 UI,并提供设计资源,详见:[https://uniapp.dcloud.io/component/uniui/resource](https://uniapp.dcloud.io/component/uniui/resource)
- 文档迁移,详见:[https://uniapp.dcloud.io/component/uniui/uni-easyinput](https://uniapp.dcloud.io/component/uniui/uni-easyinput)
## 0.1.4(2021-08-20)
- 修复 在 uni-forms 的动态表单中默认值校验不通过的 bug
## 0.1.3(2021-08-11)
- 修复 在 uni-forms 中重置表单,错误信息无法清除的问题
## 0.1.2(2021-07-30)
- 优化 vue3 下事件警告的问题
## 0.1.1
- 优化 errorMessage 属性支持 Boolean 类型
## 0.1.0(2021-07-13)
- 组件兼容 vue3,如何创建 vue3 项目,详见 [uni-app 项目支持 vue3 介绍](https://ask.dcloud.net.cn/article/37834)
## 0.0.16(2021-06-29)
- 修复 confirmType 属性(仅 type="text" 生效)导致多行文本框无法换行的 bug
## 0.0.15(2021-06-21)
- 修复 passwordIcon 属性拼写错误的 bug
## 0.0.14(2021-06-18)
- 新增 passwordIcon 属性,当 type=password 时是否显示小眼睛图标
- 修复 confirmType 属性不生效的问题
## 0.0.13(2021-06-04)
- 修复 disabled 状态可清出内容的 bug
## 0.0.12(2021-05-12)
- 新增 组件示例地址
## 0.0.11(2021-05-07)
- 修复 input-border 属性不生效的问题
## 0.0.10(2021-04-30)
- 修复 ios 遮挡文字、显示一半的问题
## 0.0.9(2021-02-05)
- 调整为 uni_modules 目录规范
- 优化 兼容 nvue 页面
/**
* @desc 函数防抖
* @param func 目标函数
* @param wait 延迟执行毫秒数
* @param immediate true - 立即执行, false - 延迟执行
*/
export const debounce = function(func, wait = 1000, immediate = true) {
let timer;
return function() {
let context = this,
args = arguments;
if (timer) clearTimeout(timer);
if (immediate) {
let callNow = !timer;
timer = setTimeout(() => {
timer = null;
}, wait);
if (callNow) func.apply(context, args);
} else {
timer = setTimeout(() => {
func.apply(context, args);
}, wait)
}
}
}
/**
* @desc 函数节流
* @param func 函数
* @param wait 延迟执行毫秒数
* @param type 1 使用表时间戳,在时间段开始的时候触发 2 使用表定时器,在时间段结束的时候触发
*/
export const throttle = (func, wait = 1000, type = 1) => {
let previous = 0;
let timeout;
return function() {
let context = this;
let args = arguments;
if (type === 1) {
let now = Date.now();
if (now - previous > wait) {
func.apply(context, args);
previous = now;
}
} else if (type === 2) {
if (!timeout) {
timeout = setTimeout(() => {
timeout = null;
func.apply(context, args)
}, wait)
}
}
}
}
{
"id": "yingbing-flip",
"displayName": "好用翻页组件",
"version": "1.0.4",
"description": "高性能翻页组件",
"id": "uni-easyinput",
"displayName": "uni-easyinput 增强输入框",
"version": "1.1.18",
"description": "Easyinput 组件是对原生input组件的增强",
"keywords": [
"翻页"
"uni-ui",
"uniui",
"input",
"uni-easyinput",
"输入框"
],
"repository": "https://gitee.com/yingbing-developer/yingbing-flip.git",
"repository": "https://github.com/dcloudio/uni-ui",
"engines": {
"HBuilderX": "^3.1.0"
"HBuilderX": ""
},
"dcloudext": {
"type": "component-vue",
"directories": {
"example": "../../temps/example_temps"
},
"dcloudext": {
"sale": {
"regular": {
"price": "0.00"
......@@ -28,52 +34,53 @@
"data": "无",
"permissions": "无"
},
"npmurl": ""
"npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui",
"type": "component-vue"
},
"uni_modules": {
"dependencies": [],
"dependencies": [
"uni-scss",
"uni-icons"
],
"encrypt": [],
"platforms": {
"cloud": {
"tcb": "y",
"aliyun": "y"
"aliyun": "y",
"alipay": "n"
},
"client": {
"Vue": {
"vue2": "u",
"vue3": "u"
},
"App": {
"app-vue": "u",
"app-nvue": "u"
"app-vue": "y",
"app-nvue": "y"
},
"H5-mobile": {
"Safari": "u",
"Android Browser": "u",
"微信浏览器(Android)": "u",
"QQ浏览器(Android)": "u"
"Safari": "y",
"Android Browser": "y",
"微信浏览器(Android)": "y",
"QQ浏览器(Android)": "y"
},
"H5-pc": {
"Chrome": "u",
"IE": "u",
"Edge": "u",
"Firefox": "u",
"Safari": "u"
"Chrome": "y",
"IE": "y",
"Edge": "y",
"Firefox": "y",
"Safari": "y"
},
"小程序": {
"微信": "u",
"阿里": "u",
"百度": "u",
"字节跳动": "u",
"QQ": "u",
"钉钉": "u",
"快手": "u",
"飞书": "u",
"京东": "u"
"微信": "y",
"阿里": "y",
"百度": "y",
"字节跳动": "y",
"QQ": "y"
},
"快应用": {
"华为": "u",
"联盟": "u"
},
"Vue": {
"vue2": "y",
"vue3": "y"
}
}
}
......
## 1.0.4(2023-09-02)
* 解决插槽中有scroll-view等滚动组件时滑动报错的问题
## 1.0.3(2023-08-23)
* 解决APP-NVUE端resetLoading不生效的问题
## 1.0.2(2023-07-25)
* 解决竖直翻页时,点击上下2侧翻页不准确得问题
## 1.0.1(2023-07-24)
* 解决APP-NVUE无法点击左右2侧翻页得问题
## 1.0.0(2023-07-22)
* 第一次更新
This diff is collapsed.
export const PAKEAGE_NAME = 'com.duben.dybookhm'
export function trim(str) {
return str ? str.replace(/(^\s*)|(\s*$)/g, "") : ''
}
......
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