Commit 2c05781d authored by 和慭琛's avatar 和慭琛

uViewUI框架导入 没成功

parent 234968a4
<style lang="scss">
@import '@/common/index.scss';
@import 'uview-ui/index.scss';
</style>
<script> <script>
export default { export default {
onLaunch: function() { onLaunch: function() {
......
import globalUrl from '@/common/base_url.js'
let codeApiFun = function(vm){
let apiBaseUrl = globalUrl.codeUrl.apiBaseUrl
let getCodeHotBrandList = async (params = {}) => await vm.$u.get( apiBaseUrl + '/brand/get-hot-brand-list', params);
let getCodeBrandSearch = async (params = {}) => await vm.$u.get( apiBaseUrl + '/brand/brand-search', params);
let getCodeCateList = async (params = {}) => await vm.$u.get( apiBaseUrl + '/brand/get-category-list', params);
let getCodeFaultList = async (params = {}) => await vm.$u.post( apiBaseUrl + '/code/get-code-list', params,{'content-type': 'application/x-www-form-urlencoded'});
let getCodeFaultSearch = async (params = {}) => await vm.$u.get( apiBaseUrl + '/code/match', params);
let getCodeFaultReason = async (params = {}) => await vm.$u.post( apiBaseUrl + '/code/get-detail', params,{'content-type': 'application/x-www-form-urlencoded'});
let setCodeThumb = async (params = {}) => await vm.$u.post( apiBaseUrl + '/code/set-thumb', params);
let postFeedback = async (params = {}) => await vm.$u.post( apiBaseUrl + '/feedback/new-add-miss', params);
let getArticleDetail = async (params = {}) => await vm.$u.get( apiBaseUrl + '/article/detail', params);
let getArticleCatalog = async (params = {}) => await vm.$u.get( apiBaseUrl + '/article/catalog', params);
const codeApi = {
getCodeHotBrandList,
getCodeBrandSearch,
getCodeCateList,
getCodeFaultList,
getCodeFaultSearch,
getCodeFaultReason,
setCodeThumb,
postFeedback,
getArticleDetail,
getArticleCatalog,
}
return codeApi
}
module.exports = {
codeApiFun
}
\ No newline at end of file
// 所有模块公共API
// 资料页面接口
let commonApiFun = function(vm){
let getWorkertype = async (params = {}) => await vm.$u.get('/addons/cms/wxapp.user/getworkertype', params);
let getTag = async (params = {}) => await vm.$u.get('/api/cmstag/tagListByType', params);
let getDynamicTag = async (params = {}) => await vm.$u.get('/api/cmstag/tagListByType2', params);
let selectWorkerType = async (params = {}) => await vm.$u.post('/addons/cms/wxapp.user/worker', params);
const commonApi = {
getWorkertype,
getTag,
getDynamicTag,
selectWorkerType
}
return commonApi
}
module.exports = {
commonApiFun
}
\ No newline at end of file
// 资料页面接口
let datumApiFun = function(vm){
// 资料列表
let getDatum = async (params = {}) => await vm.$u.get('/api/cmsarchives/getArchivesList', params);
// 资料收藏
let datumCollect = async (params = {}) => await vm.$u.get('/api/cmscollection/create', params);
// 资料取消收藏
let datumCollectDelete = async (params = {}) => await vm.$u.get('/api/cmscollection/delete', params);
// 获取品牌标签
let getBrandTag = async (params = {}) => await vm.$u.get('/api/cmstag/getBrandTag', params);
// 获取分组的标签
let getTypeTag = async (params = {}) => await vm.$u.get('/api/cmstag/getTypeTag', params);
// 资料点赞
let datumVote = async (params = {}) => await vm.$u.post('/addons/cms/wxapp.archives/vote', params);
let getDatumDetail = async (params = {}) => await vm.$u.get('/addons/cms/wxapp.archives/detail', params);
// 资料评论列表
let getDatumCommentList = async (params = {}) => await vm.$u.get('/addons/cms/wxapp.comment/index', params);
const datumApi = {
getDatum,
datumCollect,
getBrandTag,
getTypeTag,
datumVote,
getDatumDetail,
getDatumCommentList,
datumCollectDelete
}
return datumApi
}
module.exports = {
datumApiFun
}
\ No newline at end of file
import {
codeApiFun
} from '@/common/api/code.js';
import {
datumApiFun
} from '@/common/api/datum.js';
import {
commonApiFun
} from '@/common/api/common.js';
import {
mineApiFun
} from '@/common/api/mine.js';
import {
searchApiFun
} from '@/common/api/search.js';
let apiFun = function(vm) {
let codeApi = codeApiFun(vm);
let datumApi = datumApiFun(vm);
let commonApi = commonApiFun(vm);
let mineApi = mineApiFun(vm);
let searchApi = searchApiFun(vm);
let apiUrl = {
...codeApi,
...datumApi,
...commonApi,
...mineApi,
...searchApi,
}
return apiUrl
}
module.exports = {
apiFun
}
import globalUrl from '@/common/base_url.js'
let mineApiFun = function(vm){
/* 获取我的个人信息 */
let getPerson = async (params = {}) => await vm.$u.get('/addons/ask/api.person/index', params);
/* 获取我的提问列表 */
let listQuestion = async (params = {}) => await vm.$u.get('/addons/ask/api.person/question', params);
/* 获取我的回答列表 */
let listAnswer = async (params = {}) => await vm.$u.get('/addons/ask/api.person/answer', params);
/* 获取我的收藏列表 */
let listCollection = async (params = {}) => await vm.$u.get('/addons/ask/api.person/collection', params);
const mineApi = {
getPerson,
listQuestion,
listAnswer,
listCollection
}
return mineApi
}
module.exports = {
mineApiFun
}
\ No newline at end of file
import globalUrl from '@/common/base_url.js'
let searchApiFun = function(vm){
/* 清空搜索历史信息 */
let clearHistory = async (params = {}) => await vm.$u.get('/api/searchhistory/clear', params);
/* 获取搜索历史列表 */
let listHistory = async (params = {}) => await vm.$u.get('/api/searchhistory/list', params);
/* 获取用户热搜列表 */
let listHotDict = async (params = {}) => await vm.$u.get('/api/search/getHotDict', params);
/* 获取搜索建议列表 */
let listRelatedDict = async (params = {}) => await vm.$u.get('/api/search/getRelatedDict', params);
/* 全文搜索 */
let researchAll = async (params = {}) => await vm.$u.get('/api/search/search', params);
const searchApi = {
clearHistory,
listHistory,
listHotDict,
listRelatedDict,
researchAll
}
return searchApi
}
module.exports = {
searchApiFun
}
\ No newline at end of file
let codeUrl = {
apiUrl: 'https://rest-u.banshouhui.com',
apiBaseUrl: 'https://code.banshouhui.com'
}
/* --------------------------- prod begin --------------------------- */
let askUrl = {
apiUrl: 'https://fa.banshouhui.com',
fileUrl: 'https://s-fa.banshouhui.com',
}
let ucenterUrl = {
apiBaseUrl: 'https://u.banshouhui.com'
}
/* --------------------------- prod end --------------------------- */
/* --------------------------- test begin --------------------------- */
// let askUrl = {
// //apiUrl: 'http://fa.yunya.com',
// apiUrl: 'http://fa.test.ibanshou.cn',
// fileUrl: 'https://s-fa.banshouhui.com',
// staticUrl:'https://fa.banshouhui.com/assets/addons/ask/img/uniapp',
// }
// let ucenterUrl = {
// //apiBaseUrl: 'http://u.yunya.com',
// apiBaseUrl: 'http://fa.test.ibanshou.cn'
// }
/* --------------------------- test end --------------------------- */
function getCodeUrl(uri) {
return codeUrl.apiBaseUrl + uri;
}
function getUcenterUrl(uri) {
return ucenterUrl.apiBaseUrl + uri;
}
export default {
codeUrl,
askUrl,
ucenterUrl,
getCodeUrl,
getUcenterUrl
}
export const others = {
methods: {
//富文本的回调
navigate() {
},
moreClick() {
this.$set(this.moreList[1], 'text', this.detail.collected ? '已收藏' : '收藏');
this.is_more = true;
},
cancel() {
this.is_more = false;
}
}
}
// 收藏
export const collection = {
methods: {
//收藏
goCollectionCreate: async function(item, type) {
let res = await this.$u.api.goCollectionCreate({
id: item.id,
type: type
});
this.$u.toast(res.msg);
if (!res.code) {
return;
}
if (type == 'article' || type == 'question' || type == 'answer') {
item.collected = true;
}
},
//取消收藏
goCollectionDelete: async function(item, type) {
let res = await this.$u.api.goCollectionDelete({
id: item.id,
type: type
});
this.$u.toast(res.msg);
if (!res.code) {
return;
}
if (type == 'article' || type == 'question' || type == 'answer') {
item.collected = false;
}
},
},
}
// 点赞
export const vote = {
methods: {
goVoteCreate: async function(item, type, value = 'up') {
let res = await this.$u.api.goVoteCreate({
id: item.id,
type: type,
value: value
});
this.$u.toast(res.msg);
if (!res.code) {
return;
}
item.vote = value;
item.voteup = res.data.voteup;
},
goVoteDelete: async function(item, type, value = 'up') {
let res = await this.$u.api.goVoteDelete({
id: item.id,
type: type,
value: value
})
this.$u.toast(res.msg);
if (!res.code) {
return;
}
item.voteup = res.data.voteup;
item.vote = '';
},
}
}
// 关注
export const attention = {
methods: {
goAttentionCreate: async function(item, type, callback) {
let res = await this.$u.api.goAttentionCreate({
id: item.id,
type: type
})
this.$u.toast(res.msg);
if (!res.code) {
return;
}
item.followed = true;
if (typeof callback == 'function') {
callback();
};
},
goAttentionDelete: async function(item, type, callback = () => {}) {
let res = await this.$u.api.goAttentionDelete({
id: item.id,
type: type
})
this.$u.toast(res.msg);
if (!res.code) {
return;
}
item.followed = false;
if (typeof callback == 'function') {
callback();
};
},
}
}
//轮播图
export const swipers = {
methods: {
//轮播图事件
clickSwiper(index) {
let path = this.vuex_config.blockList[index].url;
if (path == '/' || !path) {
return;
}
if (path.substr(0, 1) == 'p') {
path = '/' + path;
}
this.$u.route({
url: path
})
},
}
}
//样式
export const styleRest = {
methods: {
getStyle(string) {
let underline = {};
let style = {};
let s = string.split('|');
s.forEach(item => {
if (item == 'b') {
style.fontWeight = 'bold';
}
if (item == 'u') {
underline.textDecoration = 'underline';
}
if (item.indexOf('#') != -1) {
let color = item.split(',');
style.backgroundImage = `linear-gradient(90deg,${color[0]} 0%, ${color[1]?color[1]:color[0]} 100%)`;
style.textFillColor = 'transparent'
}
})
return [underline, style];
},
setStyle(item) {
if (item.style) {
let result = this.getStyle(item.style);
item.styleArray = result[1];
item.underline = result[0];
} else {
item.styleArray = {};
item.underline = {};
}
}
}
}
//跳转标签
export const tagClick = {
methods: {
navigateTag(id, type) {
this.$u.route(`/pages/tag/detail?id=${id}&type=${type}`)
}
}
}
//登录成功之后
export const login = {
methods: {
success: async function(id,index=1) {
let res = await this.$u.api.getUserIndex({
id: id
});
if (!res.code) {
this.$u.toast(res.msg);
return;
}
this.$u.vuex('vuex_user', res.data.user);
this.$u.vuex('vuex_isAdmin', res.data.isAdmin);
// #ifdef APP-PLUS
this.$Router.back(index)
// #endif
// #ifndef APP-PLUS
let value = uni.getStorageSync('last_page');
//有上次页面,关闭所有页面,到此页面
if (value) {
this.$Router.replaceAll(Object.assign({},value))
return;
}
//默认到首页
this.$Router.replaceAll({
url: '/pages/index/index'
});
// #endif
}
}
}
// 查看品类模块(首页资料页)
export const getQuickTag = {
data(){
return {
quickTab:{
tabs:[],
tags:[]
}
}
},
methods:{
getTabTitle(){
},
getTabItem(){
},
}
}
\ No newline at end of file
import Vue from 'vue'
//这里仅示范npm安装方式的引入,其它方式引入请看最上面【安装】部分
import Router from 'uni-simple-router'
Vue.use(Router)
//初始化
const router = new Router({
APP: {
animation: {
animationType: 'pop-in',
animationDuration: 300
}
},
encodeURI:false,
routes: ROUTES //路由表
});
//全局路由前置守卫
router.beforeEach((to, from, next) => {
//去的页面是登录类型,来的页面不是登录类型,就缓存此页面,排除用户协议
if(to.path.indexOf('/login/') != -1 && from.path.indexOf('/login/') == -1 && from.path.indexOf('agreement') == -1){
uni.setStorageSync('last_page', {path:from.path,query:from.query});
}
next();
})
// 全局路由后置守卫
router.afterEach((to, from) => {
})
export default router;
module.exports = {
computed: {
theme() {
if (this.vuex_config.theme) {
let theme = this.vuex_config.theme;
let colorArr = this.$u.colorGradient(theme.bgColor, theme.color, theme.ladder);
return Object.assign({
lightColor:colorArr[theme.number] || '#f5f5f5',
faBorderColor:colorArr[theme.border] || '#f5f5f5'
},theme);
}
return {
bgColor: "#0301c5",
border: 5,
color: "#ffffff",
ladder: 10,
number: 9,
lightColor:'#f5f5f5',
faBorderColor:'#f5f5f5'
};
},
btnBgColor(vote, type) {
return (vote, type) => {
if(typeof type == 'undefined'){
return vote ? this.theme.bgColor : this.theme.lightColor;
}
return vote == type ? this.theme.bgColor : this.theme.lightColor;
};
},
btnColor(vote, type) {
return (vote, type) => {
if(typeof type == 'undefined'){
return vote? this.theme.color : this.theme.bgColor;
}
return vote == type ? this.theme.color : this.theme.bgColor;
};
}
},
}
This diff is collapsed.
//免登录接口
let noLoginUrl = [
'/addons/cms/wxapp.user/getworkertype',
'/api/cmstag/tagListByType',
'/addons/cms/wxapp.login/wxa',//授权昵称头像等
'/addons/cms/wxapp.login/login',// 授权手机号
'/addons/ask/api.common/config',
'/addons/ask/api.login/login',
'/addons/ask/api.login/register',
'/addons/ask/api.login/thirdLogin',
'/addons/ask/api.login/resetpwd',
'/addons/ask/api.user/myinfo',
'/addons/ask/api.user/answer',
'/addons/ask/api.user/question',
'/addons/ask/api.user/article',
'/addons/ask/api.user/follower',
'/addons/ask/api.user/attention',
'/addons/ask/api.question/index',
'/addons/ask/api.question/show',
'/addons/ask/api.article/index',
'/addons/ask/api.article/show',
'/addons/ask/api.zone/index',
'/addons/ask/api.tag/index',
'/addons/ask/api.tag/show',
'/addons/ask/api.expert/index',
'/addons/ask/api.sms/send',
'/addons/ask/api.ems/send',
'/addons/ask/api.ajax/get_answer_list',
'/addons/ask/api.ajax/get_comment_list',
'/addons/ask/api.ajax/get_question_list',
'/addons/ask/api.ajax/get_article_list',
'/addons/ask/api.common/aboutus',
'/addons/ask/api.common/agreement',
'/addons/ask/api.login/wxLogin',
'/addons/ask/api.login/appLogin',
'/addons/ask/api.login/mobilelogin',
'/addons/ask/api.search/index',
'/addons/recharge/api.recharge/config',
'/addons/third/api/getAuthUrl',
'/addons/third/api/callback',
'/addons/third/api/account'
];
//设置session_id
const getSessionId = function(vm) {
let session = vm.$util.getDb('session');
if (!session) {
let guid = vm.$u.guid();
vm.$util.setDb('session', guid);
return guid;
}
return session;
}
// 这里的vm,就是我们在vue文件里面的this,所以我们能在这里获取vuex的变量,比如存放在里面的token
// 同时,我们也可以在此使用getApp().globalData,如果你把token放在getApp().globalData的话,也是可以使用的
import globalUrl from '@/common/base_url.js'
const install = (Vue, vm) => {
// let url = 'https://fa.yunya.com'
let apiBaseUrl = globalUrl.codeUrl.apiBaseUrl;// 故障码apiuri
let apiUrl = globalUrl.askUrl.apiUrl
// #ifdef H5
typeof window.fastUrl !== 'undefined' ? url = window.fastUrl : '',
// #endif
Vue.prototype.$u.http.setConfig({
baseUrl: apiUrl,
header: {
'content-type': 'application/json; charset=utf-8'
},
originalData: true
});
// 请求拦截,配置Token等参数
Vue.prototype.$u.http.interceptor.request = (config) => {
//在需要登录的接口,请求前判断token 是否存在,不存在则到登录
if (noLoginUrl.indexOf(config.url) == -1 && !vm.vuex_token) {
let pages = getCurrentPages();
if((pages[pages.length - 1]).route!=='pages/login/wxlogin'){
vm.$u.route('/pages/login/wxlogin');
}
// vm.$u.route('/pages/login/wxlogin');
return false;
}
config.header.token = vm.vuex_token || '';
// 临时测试 token -- 开发环境
// if (apiUrl == 'http://fa.yunya.com') {
// config.header.token = '0edjXh5micAR3Lf1tkNtObcUtLMdiVGCVOxlkca_PyTi0CFdyo5kF3TMdSEO8wBDHJh8CwDOTCfzvpLeavzLNg';
// }
//设置session_id
// config.header.sid = getSessionId(vm);
config.header.uid = vm.vuex_user.id || 0;
config.header['x-requested-with'] = 'xmlhttprequest';
// if(config.method=='POST'){
// config.data['__token__'] = vm.vuex__token__;
// }
if(config.url.indexOf(apiBaseUrl)>=0){
// 快查相关页面临时参数
config.header['Authorize'] = vm.vuex_token;
}
return config;
}
// 响应拦截,判断状态码是否通过
Vue.prototype.$u.http.interceptor.response = (res) => {
let result = res.data;
//返回__token__,设置
if (res.header.__token__) {
vm.$u.vuex('vuex__token__', res.header.__token__);
}
switch (result.code) {
case 1:
case 0:
return result;
case 401:
//需要登录的接口,当token 过期时,清掉本地token,到登录页面
///*
if (!this.vuex_token) {
uni.navigateTo({
url: '/pages/login/wxlogin'
});
return;
}
//*/
vm.$u.vuex('vuex_token','');
let pages = getCurrentPages();
if((pages[pages.length - 1]).route!=='pages/login/wxlogin'){
vm.$u.route('/pages/login/wxlogin');
}
return result;
case 403://没有权限访问
case 500://没有权限访问
uni.showToast({
icon: "none",
title: result.msg
})
return result;
default:
if (res.statusCode == 200) {
return res.data;
} else {
vm.$u.toast('网络请求错误!');
}
}
}
}
export default {
install
}
page{
background-color: #FAFAFA;
}
.btn-share {
background-color: transparent;
&::after {
display: none;
}
.icon-share {
display: block;
width: 48rpx;
height: 39rpx;
}
}
\ No newline at end of file
import globalUrl from '@/common/base_url.js'
function strlen(value) {
//中文、中文标点、全角字符按1长度,英文、英文符号、数字按0.5长度计算
let cnReg = /([\u4e00-\u9fa5]|[\u3000-\u303F]|[\uFF00-\uFF60])/g;
let mat = value.match(cnReg);
let length = 0;
if (mat) {
return (length = mat.length + (value.length - mat.length) * 0.5);
} else {
return (length = value.length * 0.5);
}
}
/**
*
* 判断是否在微信浏览器 true是
*/
function isWeiXinBrowser() {
// #ifdef H5
let ua = window.navigator.userAgent.toLowerCase()
if (ua.match(/MicroMessenger/i) == 'micromessenger') {
return true
} else {
return false
}
// #endif
return false
}
/**
* 获取url参数
* @param {*} name
* @param {*}
* @returns
*/
function getQueryString(name, url) {
var url = url || window.location.href
var reg = new RegExp('(^|&|/?)' + name + '=([^&|/?]*)(&|/?|$)', 'i')
var r = url.substr(1).match(reg)
if (r != null) {
return r[2]
}
return null
}
//路径转化
function getPath(path) {
if (path.indexOf('?') != -1) {
let arr = path.split('?');
return arr[0];
}
return path;
}
function uniCopy({
content,
success,
error
}) {
content = typeof content === 'string' ? content : content.toString() // 复制内容,必须字符串,数字需要转换为字符串
/**
* 小程序端 和 app端的复制逻辑
*/
//#ifndef H5
uni.setClipboardData({
data: content,
success: function() {
success("复制成功~")
},
fail: function() {
error("复制失败~")
}
});
//#endif
/**
* H5端的复制逻辑
*/
// #ifdef H5
if (!document.queryCommandSupported('copy')) { //为了兼容有些浏览器 queryCommandSupported 的判断
// 不支持
error('浏览器不支持')
}
let textarea = document.createElement("textarea")
textarea.value = content
textarea.readOnly = "readOnly"
document.body.appendChild(textarea)
textarea.select() // 选择对象
textarea.setSelectionRange(0, content.length) //核心
let result = document.execCommand("copy") // 执行浏览器复制命令
if (result) {
success("复制成功~")
} else {
error("复制失败,请检查h5中调用该方法的方式,是不是用户点击的方式调用的,如果不是请改为用户点击的方式触发该方法,因为h5中安全性,不能js直接调用!")
}
textarea.remove()
// #endif
}
function getNavHeight(height=0,platform=''){
// 转换字符数值为真正的数值
// #ifdef H5
return 0;
// #endif
// #ifdef APP-PLUS
return height ? height : 44;
// #endif
// #ifdef MP
// 小程序特别处理,让导航栏高度 = 胶囊高度 + 两倍胶囊顶部与状态栏底部的距离之差(相当于同时获得了导航栏底部与胶囊底部的距离)
// 此方法有缺陷,暂不用(会导致少了几个px),采用直接固定值的方式
// return menuButtonInfo.height + (menuButtonInfo.top - this.statusBarHeight) * 2;//导航高度
let h = platform == 'ios' ? 44 : 48;
return height ? height : h;
// #endif
}
//设置缓存
function setDb(name,value,db_time=7200){
let time = (new Date()).getTime();
let data = {
value:value,
time:time,
db_time:db_time
}
uni.setStorageSync(name, data);
}
//获取缓存
function getDb(name){
try{
let res = uni.getStorageSync(name);
if(!res){
return '';
}
let time = (new Date()).getTime();
if((time-res.time)/1000>=res.db_time){
uni.removeStorageSync(name);
return '';
}
return res.value;
}catch(e){
//TODO handle the exception
return '';
}
}
//获取缓存
function getFileUrlPrefix(){
return globalUrl.askUrl.fileUrl;
}
// 获取base_url
function getUcenterUrl(url) {
return globalUrl.getUcenterUrl(url);
}
// 获取静态文件路径
function getStaticUrl(url) {
return globalUrl.askUrl.apiUrl + '/assets/addons/ask/img/uniapp/' + url;
}
// 获取动态文件路径
function getDynamicUrl(url) {
return globalUrl.askUrl.fileUrl + url;
}
function getAskUrl(url) {
return globalUrl.askUrl.apiUrl + url;
}
// 获取文件类型
function getFileType(fileUrl){
let fileArr = ['doc','ppt','word','xls'];
let fileObj = {
doc:'doc',
docx:'doc',
xls:'xls',
xlsx:'xls',
ppt:'ppt',
pptx:'ppt',
pdf:'pdf',
}
// doc docx xls xlsx ppt pptx pdf
let reg = /\.[^\.]+$/;
let fileType = reg.exec(fileUrl);
let keyUrl = 'word';
keyUrl = fileObj[fileType] || keyUrl;
keyUrl = getStaticUrl('file/'+keyUrl+'.png')
return keyUrl
}
// 处理多次点击方法
function dianji(fn) {
let that = this;
if (that.onoff) {
that.onoff = false;
fn();
setTimeout(function () {
that.onoff = true;
}, 1500)
}
}
export {
strlen,
isWeiXinBrowser,
getQueryString,
getPath,
uniCopy,
getNavHeight,
setDb,
getDb,
getFileUrlPrefix,
getUcenterUrl,
getFileType,
getStaticUrl,
getDynamicUrl,
getAskUrl,
dianji
}
{ {
/*
"easycom": {
"^u-(.*)": "@/uview-ui/components/u-$1/u-$1.vue"
},
*/
"pages": [ //pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages "pages": [ //pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages
{ {
"path": "pages/index/index", "path": "pages/index/index",
......
...@@ -74,3 +74,5 @@ $uni-color-subtitle: #555555; // 二级标题颜色 ...@@ -74,3 +74,5 @@ $uni-color-subtitle: #555555; // 二级标题颜色
$uni-font-size-subtitle:36rpx; $uni-font-size-subtitle:36rpx;
$uni-color-paragraph: #3F536E; // 文章段落颜色 $uni-color-paragraph: #3F536E; // 文章段落颜色
$uni-font-size-paragraph:30rpx; $uni-font-size-paragraph:30rpx;
@import 'uview-ui/theme.scss';
\ No newline at end of file
...@@ -10,5 +10,5 @@ ...@@ -10,5 +10,5 @@
"backgroundColor": "#F8F8F8" "backgroundColor": "#F8F8F8"
}, },
"usingComponents": {}, "usingComponents": {},
"sitemapLocation": "sitemap.json" "sitemapLocation": "sitemap6.json"
} }
\ No newline at end of file
...@@ -4,37 +4,7 @@ ...@@ -4,37 +4,7 @@
"ignore": [] "ignore": []
}, },
"setting": { "setting": {
"urlCheck": false, "urlCheck": false
"es6": true,
"enhance": false,
"postcss": true,
"preloadBackgroundData": false,
"minified": true,
"newFeature": false,
"coverView": true,
"nodeModules": false,
"autoAudits": false,
"showShadowRootInWxmlPanel": true,
"scopeDataCheck": false,
"uglifyFileName": false,
"checkInvalidKey": true,
"checkSiteMap": true,
"uploadWithSourceMap": true,
"compileHotReLoad": false,
"useMultiFrameRuntime": false,
"useApiHook": true,
"babelSetting": {
"ignore": [],
"disablePlugins": [],
"outputPath": ""
},
"enableEngineNative": false,
"useIsolateContext": true,
"useCompilerModule": true,
"userConfirmedUseCompilerModuleSwitch": false,
"packNpmManually": false,
"packNpmRelationList": [],
"minifyWXSS": true
}, },
"compileType": "miniprogram", "compileType": "miniprogram",
"libVersion": "", "libVersion": "",
......
{
"desc": "关于本文件的更多信息,请参考文档 https://developers.weixin.qq.com/miniprogram/dev/framework/sitemap.html",
"rules": [{
"action": "allow",
"page": "*"
}]
}
\ No newline at end of file
MIT License
Copyright (c) 2020 www.uviewui.com
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
\ No newline at end of file
<p align="center">
<img alt="logo" src="https://uviewui.com/common/logo.png" width="120" height="120" style="margin-bottom: 10px;">
</p>
<h3 align="center" style="margin: 30px 0 30px;font-weight: bold;font-size:40px;">uView</h3>
<h3 align="center">多平台快速开发的UI框架</h3>
## 说明
uView UI,是[uni-app](https://uniapp.dcloud.io/)生态优秀的UI框架,全面的组件和便捷的工具会让您信手拈来,如鱼得水
## 特性
- 兼容安卓,iOS,微信小程序,H5,QQ小程序,百度小程序,支付宝小程序,头条小程序
- 60+精选组件,功能丰富,多端兼容,让您快速集成,开箱即用
- 众多贴心的JS利器,让您飞镖在手,召之即来,百步穿杨
- 众多的常用页面和布局,让您专注逻辑,事半功倍
- 详尽的文档支持,现代化的演示效果
- 按需引入,精简打包体积
## 安装
```bash
# npm方式安装
npm i uview-ui
```
## 快速上手
1. `main.js`引入uView库
```js
// main.js
import uView from 'uview-ui';
Vue.use(uView);
```
2. `App.vue`引入基础样式(注意style标签需声明scss属性支持)
```css
/* App.vue */
<style lang="scss">
@import "uview-ui/index.scss";
</style>
```
3. `uni.scss`引入全局scss变量文件
```css
/* uni.scss */
@import "uview-ui/theme.scss";
```
4. `pages.json`配置easycom规则(按需引入)
```js
// pages.json
{
"easycom": {
// npm安装的方式不需要前面的"@/",下载安装的方式需要"@/"
// npm安装方式
"^u-(.*)": "uview-ui/components/u-$1/u-$1.vue"
// 下载安装方式
// "^u-(.*)": "@/uview-ui/components/u-$1/u-$1.vue"
},
// 此为本身已有的内容
"pages": [
// ......
]
}
```
请通过[快速上手](https://uviewui.com/components/quickstart.html)了解更详细的内容
## 使用方法
配置easycom规则后,自动按需引入,无需`import`组件,直接引用即可。
```html
<template>
<u-button>按钮</u-button>
</template>
```
请通过[快速上手](https://uviewui.com/components/quickstart.html)了解更详细的内容
## 链接
- [官方文档](https://uviewui.com/)
- [更新日志](https://uviewui.com/components/changelog.html)
- [升级指南](https://uviewui.com/components/changelog.html)
- [关于我们](https://uviewui.com/cooperation/about.html)
## 预览
您可以通过**微信**扫码,查看最佳的演示效果。
<br>
<br>
<img src="https://uviewui.com/common/weixin_mini_qrcode.png" width="220" height="220" >
<!-- ## 捐赠uView的研发
uView文档和源码全部开源免费,如果您认为uView帮到了您的开发工作,您可以捐赠uView的研发工作,捐赠无门槛,哪怕是一杯可乐也好(相信这比打赏主播更有意义)。
<img src="https://uviewui.com/common/wechat.png" width="220" >
<img style="margin-left: 100px;" src="https://uviewui.com/common/alipay.png" width="220" >
-->
## 版权信息
uView遵循[MIT](https://en.wikipedia.org/wiki/MIT_License)开源协议,意味着您无需支付任何费用,也无需授权,即可将uView应用到您的产品中。
<template>
<u-popup mode="bottom" :border-radius="borderRadius" :popup="false" v-model="value" :maskCloseAble="maskCloseAble"
length="auto" :safeAreaInsetBottom="safeAreaInsetBottom" @close="popupClose" :z-index="uZIndex">
<view class="u-tips u-border-bottom" v-if="tips.text" :style="[tipsStyle]">
{{tips.text}}
</view>
<block v-for="(item, index) in list" :key="index">
<view
@touchmove.stop.prevent
@tap="itemClick(index)"
:style="[itemStyle(index)]"
class="u-action-sheet-item"
:class="[index < list.length - 1 ? 'u-border-bottom' : '']"
:hover-stay-time="150"
>
{{item.text}}
</view>
</block>
<view class="u-gab" v-if="cancelBtn">
</view>
<view @touchmove.stop.prevent class="u-actionsheet-cancel u-action-sheet-item" hover-class="u-hover-class"
:hover-stay-time="150" v-if="cancelBtn" @tap="close">{{cancelText}}</view>
</u-popup>
</template>
<script>
/**
* actionSheet 操作菜单
* @description 本组件用于从底部弹出一个操作菜单,供用户选择并返回结果。本组件功能类似于uni的uni.showActionSheetAPI,配置更加灵活,所有平台都表现一致。
* @tutorial https://www.uviewui.com/components/actionSheet.html
* @property {Array<Object>} list 按钮的文字数组,见官方文档示例
* @property {Object} tips 顶部的提示文字,见官方文档示例
* @property {String} cancel-text 取消按钮的提示文字
* @property {Boolean} cancel-btn 是否显示底部的取消按钮(默认true)
* @property {Number String} border-radius 弹出部分顶部左右的圆角值,单位rpx(默认0)
* @property {Boolean} mask-close-able 点击遮罩是否可以关闭(默认true)
* @property {Boolean} safe-area-inset-bottom 是否开启底部安全区适配(默认false)
* @property {Number String} z-index z-index值(默认1075)
* @property {String} cancel-text 取消按钮的提示文字
* @event {Function} click 点击ActionSheet列表项时触发
* @event {Function} close 点击取消按钮时触发
* @example <u-action-sheet :list="list" @click="click" v-model="show"></u-action-sheet>
*/
export default {
name: "u-action-sheet",
props: {
// 点击遮罩是否可以关闭actionsheet
maskCloseAble: {
type: Boolean,
default: true
},
// 按钮的文字数组,可以自定义颜色和字体大小,字体单位为rpx
list: {
type: Array,
default () {
// 如下
// return [{
// text: '确定',
// color: '',
// fontSize: ''
// }]
return [];
}
},
// 顶部的提示文字
tips: {
type: Object,
default () {
return {
text: '',
color: '',
fontSize: '26'
}
}
},
// 底部的取消按钮
cancelBtn: {
type: Boolean,
default: true
},
// 是否开启底部安全区适配,开启的话,会在iPhoneX机型底部添加一定的内边距
safeAreaInsetBottom: {
type: Boolean,
default: false
},
// 通过双向绑定控制组件的弹出与收起
value: {
type: Boolean,
default: false
},
// 弹出的顶部圆角值
borderRadius: {
type: [String, Number],
default: 0
},
// 弹出的z-index值
zIndex: {
type: [String, Number],
default: 0
},
// 取消按钮的文字提示
cancelText: {
type: String,
default: '取消'
}
},
computed: {
// 顶部提示的样式
tipsStyle() {
let style = {};
if (this.tips.color) style.color = this.tips.color;
if (this.tips.fontSize) style.fontSize = this.tips.fontSize + 'rpx';
return style;
},
// 操作项目的样式
itemStyle() {
return (index) => {
let style = {};
if (this.list[index].color) style.color = this.list[index].color;
if (this.list[index].fontSize) style.fontSize = this.list[index].fontSize + 'rpx';
// 选项被禁用的样式
if (this.list[index].disabled) style.color = '#c0c4cc';
return style;
}
},
uZIndex() {
// 如果用户有传递z-index值,优先使用
return this.zIndex ? this.zIndex : this.$u.zIndex.popup;
}
},
methods: {
// 点击取消按钮
close() {
// 发送input事件,并不会作用于父组件,而是要设置组件内部通过props传递的value参数
// 这是一个vue发送事件的特殊用法
this.popupClose();
this.$emit('close');
},
// 弹窗关闭
popupClose() {
this.$emit('input', false);
},
// 点击某一个item
itemClick(index) {
// disabled的项禁止点击
if(this.list[index].disabled) return;
this.$emit('click', index);
this.$emit('input', false);
}
}
}
</script>
<style lang="scss" scoped>
@import "../../libs/css/style.components.scss";
.u-tips {
font-size: 26rpx;
text-align: center;
padding: 34rpx 0;
line-height: 1;
color: $u-tips-color;
}
.u-action-sheet-item {
@include vue-flex;;
line-height: 1;
justify-content: center;
align-items: center;
font-size: 34rpx;
padding: 34rpx 0;
}
.u-gab {
height: 12rpx;
background-color: rgb(234, 234, 236);
}
.u-actionsheet-cancel {
color: $u-main-color;
}
</style>
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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