├── .gitignore
├── App.vue
├── README.md
├── common
├── classify.data.js
├── demo.scss
├── http.api.js
├── http.interceptor.js
├── index.list.js
├── locales
│ ├── en.js
│ └── zh.js
└── vue-i18n.min.js
├── components
└── page-nav
│ └── page-nav.vue
├── main.js
├── manifest.json
├── pages.json
├── pages
├── classifications
│ └── index.vue
├── index
│ ├── index.vue
│ └── swiper.vue
├── my
│ ├── addSite.vue
│ ├── address.vue
│ └── index.vue
└── shoppingCart
│ └── index.vue
├── static
├── common
│ └── js
│ │ └── touch-emulator.js
├── index
│ ├── ad.gif
│ ├── grid_1.png
│ ├── grid_10.png
│ ├── grid_2.png
│ ├── grid_3.png
│ ├── grid_4.png
│ ├── grid_5.png
│ ├── grid_6.png
│ ├── grid_7.png
│ ├── grid_8.png
│ ├── grid_9.png
│ └── swiper_1.jpg
├── my
│ └── header.png
├── navs
│ ├── classifications.png
│ ├── classifications_select.png
│ ├── index.png
│ ├── index_select.png
│ ├── my.png
│ ├── my_select.png
│ ├── shoppingCart.png
│ └── shoppingCart_select.png
└── uview
│ └── common
│ ├── favicon.ico
│ └── logo.png
├── store
├── $u.mixin.js
└── index.js
├── uni.scss
├── uview-ui
├── LICENSE
├── README.md
├── components
│ ├── u-action-sheet
│ │ └── u-action-sheet.vue
│ ├── u-alert-tips
│ │ └── u-alert-tips.vue
│ ├── u-avatar-cropper
│ │ ├── u-avatar-cropper.vue
│ │ └── weCropper.js
│ ├── u-avatar
│ │ └── u-avatar.vue
│ ├── u-back-top
│ │ └── u-back-top.vue
│ ├── u-badge
│ │ └── u-badge.vue
│ ├── u-button
│ │ └── u-button.vue
│ ├── u-calendar
│ │ └── u-calendar.vue
│ ├── u-car-keyboard
│ │ └── u-car-keyboard.vue
│ ├── u-card
│ │ └── u-card.vue
│ ├── u-cell-group
│ │ └── u-cell-group.vue
│ ├── u-cell-item
│ │ └── u-cell-item.vue
│ ├── u-checkbox-group
│ │ └── u-checkbox-group.vue
│ ├── u-checkbox
│ │ └── u-checkbox.vue
│ ├── u-circle-progress
│ │ └── u-circle-progress.vue
│ ├── u-col
│ │ └── u-col.vue
│ ├── u-collapse-item
│ │ └── u-collapse-item.vue
│ ├── u-collapse
│ │ └── u-collapse.vue
│ ├── u-column-notice
│ │ └── u-column-notice.vue
│ ├── u-count-down
│ │ └── u-count-down.vue
│ ├── u-count-to
│ │ └── u-count-to.vue
│ ├── u-divider
│ │ └── u-divider.vue
│ ├── u-dropdown-item
│ │ └── u-dropdown-item.vue
│ ├── u-dropdown
│ │ └── u-dropdown.vue
│ ├── u-empty
│ │ └── u-empty.vue
│ ├── u-field
│ │ └── u-field.vue
│ ├── u-form-item
│ │ └── u-form-item.vue
│ ├── u-form
│ │ └── u-form.vue
│ ├── u-full-screen
│ │ └── u-full-screen.vue
│ ├── u-gap
│ │ └── u-gap.vue
│ ├── u-grid-item
│ │ └── u-grid-item.vue
│ ├── u-grid
│ │ └── u-grid.vue
│ ├── u-icon
│ │ └── u-icon.vue
│ ├── u-image
│ │ └── u-image.vue
│ ├── u-index-anchor
│ │ └── u-index-anchor.vue
│ ├── u-index-list
│ │ └── u-index-list.vue
│ ├── u-input
│ │ └── u-input.vue
│ ├── u-keyboard
│ │ └── u-keyboard.vue
│ ├── u-lazy-load
│ │ └── u-lazy-load.vue
│ ├── u-line-progress
│ │ └── u-line-progress.vue
│ ├── u-line
│ │ └── u-line.vue
│ ├── u-link
│ │ └── u-link.vue
│ ├── u-loading-page
│ │ └── u-loading-page.vue
│ ├── u-loading
│ │ └── u-loading.vue
│ ├── u-loadmore
│ │ └── u-loadmore.vue
│ ├── u-mask
│ │ └── u-mask.vue
│ ├── u-message-input
│ │ └── u-message-input.vue
│ ├── u-modal
│ │ └── u-modal.vue
│ ├── u-navbar
│ │ └── u-navbar.vue
│ ├── u-no-network
│ │ └── u-no-network.vue
│ ├── u-notice-bar
│ │ └── u-notice-bar.vue
│ ├── u-number-box
│ │ └── u-number-box.vue
│ ├── u-number-keyboard
│ │ └── u-number-keyboard.vue
│ ├── u-parse
│ │ ├── libs
│ │ │ ├── CssHandler.js
│ │ │ ├── MpHtmlParser.js
│ │ │ ├── config.js
│ │ │ ├── handler.wxs
│ │ │ └── trees.vue
│ │ └── u-parse.vue
│ ├── u-picker
│ │ └── u-picker.vue
│ ├── u-popup
│ │ └── u-popup.vue
│ ├── u-radio-group
│ │ └── u-radio-group.vue
│ ├── u-radio
│ │ └── u-radio.vue
│ ├── u-rate
│ │ └── u-rate.vue
│ ├── u-read-more
│ │ └── u-read-more.vue
│ ├── u-row-notice
│ │ └── u-row-notice.vue
│ ├── u-row
│ │ └── u-row.vue
│ ├── u-search
│ │ └── u-search.vue
│ ├── u-section
│ │ └── u-section.vue
│ ├── u-select
│ │ └── u-select.vue
│ ├── u-skeleton
│ │ └── u-skeleton.vue
│ ├── u-slider
│ │ └── u-slider.vue
│ ├── u-steps
│ │ └── u-steps.vue
│ ├── u-sticky
│ │ └── u-sticky.vue
│ ├── u-subsection
│ │ └── u-subsection.vue
│ ├── u-swipe-action
│ │ └── u-swipe-action.vue
│ ├── u-swiper
│ │ └── u-swiper.vue
│ ├── u-switch
│ │ └── u-switch.vue
│ ├── u-tabbar
│ │ └── u-tabbar.vue
│ ├── u-table
│ │ └── u-table.vue
│ ├── u-tabs-swiper
│ │ └── u-tabs-swiper.vue
│ ├── u-tabs
│ │ └── u-tabs.vue
│ ├── u-tag
│ │ └── u-tag.vue
│ ├── u-td
│ │ └── u-td.vue
│ ├── u-th
│ │ └── u-th.vue
│ ├── u-time-line-item
│ │ └── u-time-line-item.vue
│ ├── u-time-line
│ │ └── u-time-line.vue
│ ├── u-toast
│ │ └── u-toast.vue
│ ├── u-top-tips
│ │ └── u-top-tips.vue
│ ├── u-tr
│ │ └── u-tr.vue
│ ├── u-upload
│ │ └── u-upload.vue
│ ├── u-verification-code
│ │ └── u-verification-code.vue
│ └── u-waterfall
│ │ └── u-waterfall.vue
├── iconfont.css
├── index.js
├── index.scss
├── libs
│ ├── config
│ │ ├── config.js
│ │ └── zIndex.js
│ ├── css
│ │ ├── color.scss
│ │ ├── common.scss
│ │ ├── style.components.scss
│ │ ├── style.h5.scss
│ │ ├── style.mp.scss
│ │ ├── style.nvue.scss
│ │ └── style.vue.scss
│ ├── function
│ │ ├── $parent.js
│ │ ├── addUnit.js
│ │ ├── bem.js
│ │ ├── color.js
│ │ ├── colorGradient.js
│ │ ├── debounce.js
│ │ ├── deepClone.js
│ │ ├── deepMerge.js
│ │ ├── getParent.js
│ │ ├── guid.js
│ │ ├── md5.js
│ │ ├── queryParams.js
│ │ ├── random.js
│ │ ├── randomArray.js
│ │ ├── route.js
│ │ ├── sys.js
│ │ ├── test.js
│ │ ├── throttle.js
│ │ ├── timeFormat.js
│ │ ├── timeFrom.js
│ │ ├── toast.js
│ │ ├── trim.js
│ │ └── type2icon.js
│ ├── mixin
│ │ ├── mixin.js
│ │ └── mpShare.js
│ ├── request
│ │ └── index.js
│ ├── store
│ │ └── index.js
│ └── util
│ │ ├── area.js
│ │ ├── async-validator.js
│ │ ├── city.js
│ │ ├── emitter.js
│ │ └── province.js
├── package.json
└── theme.scss
└── vue.config.js
/.gitignore:
--------------------------------------------------------------------------------
1 | /unpackage
2 | /*.zip
3 |
--------------------------------------------------------------------------------
/App.vue:
--------------------------------------------------------------------------------
1 |
7 |
8 |
12 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |

2 |
vue-mall-beautiful
3 |
uni插件市场首款基于 uview-ui 的绝佳的商城模板
4 |
uview的快捷让我叹为观止,uview-ui同时支持手机网页、APP,微信小程序、支付宝小程序、百度小城序、360小程序、QQ小程序、今日头条小程序
5 |
6 |
7 | [
8 | ](https://github.com/chuzhixin/vue-mall-beautiful)
9 | ## 郑重承诺
10 | 如果vue-mall-beautiful最终商业化成功,vmb愿意贡献每单20%的净利润用于支持uview的开发,第一次使用uview写开源项目,时间仓促欢迎体验star
11 |
12 | ## 演示地址
13 |
14 | ### - [🚀vue-mall-beautiful开源地址](https://github.com/chuzhixin/vue-mall-beautiful/)
15 | ### - 🚀vue-mall-beautiful手机端演示地址,扫码可访问(小程序、app版本需要自行下载编译)
16 | ### 
17 | ### - [🚀vue-admin-beautiful-pro演示地址](https://chu1204505056.gitee.io/vue-admin-beautiful/?hmsr=%E6%8F%92%E4%BB%B6%E5%B8%82%E5%9C%BA&hmpl=&hmcu=&hmkw=&hmci=)
18 |
19 | ## vue-admin-beautiful 前端讨论群-1 972435319
20 |
21 | 不管您加或者不加,您都可以享受到开源的代码,感谢您的支持和信任,群内提供 vue-admin-beautiful-template 基础版本和详细的基础使用文档适合框架快速入门
22 |
23 | 
24 |
25 |
26 |
27 | ## 开发者评级
28 |
29 | [](https://github.com/chuzhixin/vue-admin-beautiful)
30 |
--------------------------------------------------------------------------------
/common/demo.scss:
--------------------------------------------------------------------------------
1 | /* #ifndef APP-NVUE */
2 | view,
3 | text {
4 | box-sizing: border-box;
5 | }
6 | /* #endif */
7 |
8 | /* start--演示页面使用的统一样式--start */
9 | .u-demo {
10 | padding: 50rpx 40rpx;
11 | }
12 |
13 | .u-demo-wrap {
14 | border-width: 1px;
15 | border-color: #ddd;
16 | border-style: dashed;
17 | background-color: rgb(250, 250, 250);
18 | padding: 40rpx 20rpx;
19 | border-radius: 6px;
20 | }
21 |
22 | .u-demo-area {
23 | text-align: center;
24 | }
25 |
26 | .u-no-demo-here {
27 | color: $u-tips-color;
28 | font-size: 26rpx;
29 | }
30 |
31 | .u-demo-result-line {
32 | border-width: 1px;
33 | border-color: #ddd;
34 | border-style: dashed;
35 | padding: 10rpx 40rpx;
36 | margin-top: 30rpx;
37 | border-radius: 5px;
38 | background-color: rgb(240, 240, 240);
39 | color: $u-content-color;
40 | font-size: 32rpx;
41 | /* #ifndef APP-NVUE */
42 | word-break: break-word;
43 | display: inline-block;
44 | /* #endif */
45 | text-align: left;
46 |
47 | }
48 |
49 | .u-demo-title,
50 | .u-config-title {
51 | text-align: center;
52 | font-size: 32rpx;
53 | font-weight: bold;
54 | margin-bottom: 40rpx;
55 | }
56 |
57 | .u-config-item {
58 | margin-top: 50rpx;
59 | }
60 |
61 | .u-config-title {
62 | margin-top: 40rpx;
63 | padding-bottom: 10rpx;
64 | }
65 |
66 | .u-item-title {
67 | position: relative;
68 | font-size: 28rpx;
69 | padding-left: 8px;
70 | line-height: 1;
71 | margin-bottom: 22rpx;
72 | }
73 |
74 | .u-item-title:after {
75 | position: absolute;
76 | width: 4px;
77 | top: -1px;
78 | height: 16px;
79 | /* #ifndef APP-NVUE */
80 | content: '';
81 | /* #endif */
82 | left: 0;
83 | border-radius: 10px;
84 | background-color: $u-content-color;
85 | }
86 | /* end--演示页面使用的统一样式--end */
87 |
--------------------------------------------------------------------------------
/common/http.api.js:
--------------------------------------------------------------------------------
1 | // 如果没有通过拦截器配置域名的话,可以在这里写上完整的URL(加上域名部分)
2 | let hotSearchUrl = '/ebapi/store_api/hot_search';
3 | let indexUrl = '/ebapi/public_api/index';
4 |
5 | // 此处第二个参数vm,就是我们在页面使用的this,你可以通过vm获取vuex等操作,更多内容详见uView对拦截器的介绍部分:
6 | // https://uviewui.com/js/http.html#%E4%BD%95%E8%B0%93%E8%AF%B7%E6%B1%82%E6%8B%A6%E6%88%AA%EF%BC%9F
7 | const install = (Vue, vm) => {
8 | // 此处没有使用传入的params参数
9 | let getSearch = (params = {}) => vm.$u.get(hotSearchUrl, {
10 | id: 2
11 | });
12 |
13 | // 此处使用了传入的params参数,一切自定义即可
14 | let getInfo = (params = {}) => vm.$u.post(indexUrl, params);
15 |
16 | // 将各个定义的接口名称,统一放进对象挂载到vm.$u.api(因为vm就是this,也即this.$u.api)下
17 | vm.$u.api = {getSearch, getInfo};
18 | }
19 |
20 | export default {
21 | install
22 | }
--------------------------------------------------------------------------------
/common/http.interceptor.js:
--------------------------------------------------------------------------------
1 | // 这里的vm,就是我们在vue文件里面的this,所以我们能在这里获取vuex的变量,比如存放在里面的token
2 | // 同时,我们也可以在此使用getApp().globalData,如果你把token放在getApp().globalData的话,也是可以使用的
3 | const install = (Vue, vm) => {
4 | Vue.prototype.$u.http.setConfig({
5 | baseUrl: 'https://api.youzixy.com',
6 | // 如果将此值设置为true,拦截回调中将会返回服务端返回的所有数据response,而不是response.data
7 | // 设置为true后,就需要在this.$u.http.interceptor.response进行多一次的判断,请打印查看具体值
8 | // originalData: true,
9 | // 设置自定义头部content-type
10 | // header: {
11 | // 'content-type': 'xxx'
12 | // }
13 | });
14 | // 请求拦截,配置Token等参数
15 | Vue.prototype.$u.http.interceptor.request = (config) => {
16 | config.header.Token = 'xxxxxx';
17 |
18 | // 方式一,存放在vuex的token,假设使用了uView封装的vuex方式,见:https://uviewui.com/components/globalVariable.html
19 | // config.header.token = vm.token;
20 |
21 | // 方式二,如果没有使用uView封装的vuex方法,那么需要使用$store.state获取
22 | // config.header.token = vm.$store.state.token;
23 |
24 | // 方式三,如果token放在了globalData,通过getApp().globalData获取
25 | // config.header.token = getApp().globalData.username;
26 |
27 | // 方式四,如果token放在了Storage本地存储中,拦截是每次请求都执行的,所以哪怕您重新登录修改了Storage,下一次的请求将会是最新值
28 | // const token = uni.getStorageSync('token');
29 | // config.header.token = token;
30 |
31 | return config;
32 | }
33 | // 响应拦截,判断状态码是否通过
34 | Vue.prototype.$u.http.interceptor.response = (res) => {
35 | // 如果把originalData设置为了true,这里得到将会是服务器返回的所有的原始数据
36 | // 判断可能变成了res.statueCode,或者res.data.code之类的,请打印查看结果
37 | if(res.code == 200) {
38 | // 如果把originalData设置为了true,这里return回什么,this.$u.post的then回调中就会得到什么
39 | return res.data;
40 | } else return false;
41 | }
42 | }
43 |
44 | export default {
45 | install
46 | }
--------------------------------------------------------------------------------
/common/locales/en.js:
--------------------------------------------------------------------------------
1 | export default {
2 | // 可以以页面为单位来写,比如首页的内容,写在index字段,个人中心写在center,共同部分写在common部分
3 | components: {
4 | desc: 'Numerous components cover the various requirements of the development process, and the components are rich in functions and compatible with multiple terminals. Let you integrate quickly, out of the box'
5 | },
6 | js: {
7 | desc: 'Numerous intimate gadgets are a weapon that you can call upon during the development process, allowing you to dart in your hand and pierce the Yang with a hundred steps'
8 | },
9 | template: {
10 | desc: 'Collection of many commonly used pages and layouts, reducing the repetitive work of developers, allowing you to focus on logic and get twice the result with half the effort'
11 | },
12 | nav: {
13 | components: 'Comonents',
14 | js: 'JS',
15 | template: 'Template'
16 | },
17 | common: {
18 | intro: 'UI framework for rapid development of multiple platforms',
19 | title: 'uView UI',
20 | },
21 | }
--------------------------------------------------------------------------------
/common/locales/zh.js:
--------------------------------------------------------------------------------
1 | export default {
2 | // 可以以页面为单位来写,比如首页的内容,写在index字段,个人中心写在center,共同部分写在common部分
3 | components: {
4 | desc: '众多组件覆盖开发过程的各个需求,组件功能丰富,多端兼容。让你快速集成,开箱即用'
5 | },
6 | js: {
7 | desc: '众多的贴心小工具,是你开发过程中召之即来的利器,让你飞镖在手,百步穿杨'
8 | },
9 | template: {
10 | desc: '收集众多的常用页面和布局,减少开发者的重复工作,让你专注逻辑,事半功倍'
11 | },
12 | nav: {
13 | components: '组件',
14 | js: '工具',
15 | template: '模板'
16 | },
17 | common: {
18 | intro: '多平台快速开发的UI框架',
19 | title: 'uView UI',
20 | },
21 | }
--------------------------------------------------------------------------------
/components/page-nav/page-nav.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | {{$t('common.title')}}
8 |
9 |
10 | {{$t('common.intro')}}
11 |
12 |
13 |
14 |
15 | {{desc}}
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
47 |
48 |
99 |
--------------------------------------------------------------------------------
/main.js:
--------------------------------------------------------------------------------
1 | import Vue from 'vue'
2 | import App from './App'
3 |
4 | Vue.config.productionTip = false
5 |
6 | App.mpType = 'app'
7 |
8 | // 此处为演示Vue.prototype使用,非uView的功能部分
9 | Vue.prototype.vuePrototype = ''
10 |
11 | // 引入全局uView
12 | import uView from 'uview-ui'
13 | Vue.use(uView)
14 |
15 | // 此处为演示vuex使用,非uView的功能部分
16 | import store from '@/store'
17 |
18 | // 引入uView提供的对vuex的简写法文件
19 | let vuexStore = require('@/store/$u.mixin.js')
20 | Vue.mixin(vuexStore)
21 |
22 | // 引入uView对小程序分享的mixin封装
23 | let mpShare = require('uview-ui/libs/mixin/mpShare.js');
24 | Vue.mixin(mpShare)
25 |
26 | // i18n部分的配置
27 | // 引入语言包,注意路径
28 | import Chinese from '@/common/locales/zh.js';
29 | import English from '@/common/locales/en.js';
30 |
31 | // VueI18n
32 | import VueI18n from './common/vue-i18n.min.js'
33 |
34 | // VueI18n
35 | Vue.use(VueI18n)
36 |
37 | const i18n = new VueI18n({
38 | // 默认语言
39 | locale: 'zh',
40 | // 引入语言文件
41 | messages: {
42 | 'zh': Chinese,
43 | 'en': English,
44 | }
45 | })
46 |
47 | // 由于微信小程序的运行机制问题,需声明如下一行,H5和APP非必填
48 | Vue.prototype._i18n = i18n
49 |
50 | const app = new Vue({
51 | i18n,
52 | store,
53 | ...App
54 | })
55 |
56 | // http拦截器,将此部分放在new Vue()和app.$mount()之间,才能App.vue中正常使用
57 | import httpInterceptor from '@/common/http.interceptor.js'
58 | Vue.use(httpInterceptor, app)
59 |
60 | // http接口API抽离,免于写url或者一些固定的参数
61 | import httpApi from '@/common/http.api.js'
62 | Vue.use(httpApi, app)
63 |
64 | app.$mount()
65 |
--------------------------------------------------------------------------------
/pages.json:
--------------------------------------------------------------------------------
1 | {
2 | "easycom": {
3 | "^u-(.*)": "@/uview-ui/components/u-$1/u-$1.vue"
4 | },
5 | "pages": [{
6 | "path": "pages/index/index",
7 | "style": {
8 | "navigationStyle": "custom"
9 | }
10 | }, {
11 | "path": "pages/classifications/index",
12 | "style": {
13 | "navigationBarTitleText": "分类"
14 | }
15 | }, {
16 | "path": "pages/shoppingCart/index",
17 | "style": {
18 | "navigationBarTitleText": "购物车"
19 | }
20 | }, {
21 | "path": "pages/my/index",
22 | "style": {
23 | "navigationBarTitleText": "我的"
24 | }
25 | }, {
26 | "path": "pages/my/address",
27 | "style": {
28 | "navigationBarTitleText": "收货地址"
29 | }
30 | }, {
31 | "path": "pages/my/addSite",
32 | "style": {
33 | "navigationBarTitleText": "添加收货地址"
34 | }
35 | }],
36 | "globalStyle": {
37 | "navigationBarTextStyle": "black",
38 | "navigationBarTitleText": "vue-mall-beautiful",
39 | "navigationBarBackgroundColor": "#FFFFFF",
40 | "backgroundColor": "#FFFFFF"
41 | },
42 | "tabBar": {
43 | "color": "#909399",
44 | "selectedColor": "#ff3131",
45 | "backgroundColor": "#FFFFFF",
46 | "borderStyle": "black",
47 | "list": [{
48 | "pagePath": "pages/index/index",
49 | "iconPath": "static/navs/index.png",
50 | "selectedIconPath": "static/navs/index_select.png",
51 | "text": "首页"
52 | }, {
53 | "pagePath": "pages/classifications/index",
54 | "iconPath": "static/navs/classifications.png",
55 | "selectedIconPath": "static/navs/classifications_select.png",
56 | "text": "分类"
57 | }, {
58 | "pagePath": "pages/shoppingCart/index",
59 | "iconPath": "static/navs/shoppingCart.png",
60 | "selectedIconPath": "static/navs/shoppingCart_select.png",
61 | "text": "购物车"
62 | }, {
63 | "pagePath": "pages/my/index",
64 | "iconPath": "static/navs/my.png",
65 | "selectedIconPath": "static/navs/my_select.png",
66 | "text": "我的"
67 | }]
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/pages/index/swiper.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
31 |
--------------------------------------------------------------------------------
/pages/my/addSite.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | 收货人
6 |
7 |
8 |
9 | 手机号码
10 |
11 |
12 |
13 | 所在地区
14 |
15 |
16 |
17 | 详细地址
18 |
19 |
20 |
21 |
22 |
23 | 标签
24 |
25 | 家
26 | 公司
27 | 学校
28 |
29 |
30 |
31 |
32 |
33 | 设置默认地址
34 | 提醒:每次下单会默认推荐该地址
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 | 保存
43 |
44 |
45 |
46 |
47 |
48 |
63 |
64 |
197 |
--------------------------------------------------------------------------------
/pages/my/address.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {{ res.name }}
6 |
7 | {{ item.tagText }}
8 |
9 |
10 |
11 | {{ res.phone }}
12 | {{res.site}}
13 |
14 |
15 |
16 |
17 |
18 | 新建收货地址
19 |
20 |
21 |
22 |
23 |
24 |
82 |
83 |
152 |
--------------------------------------------------------------------------------
/pages/my/index.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
17 |
18 |
19 |
20 |
21 | {{ '宫格' + (index + 1) }}
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
77 |
78 |
131 |
--------------------------------------------------------------------------------
/static/index/ad.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zxwk1998/vue-mall-beautiful/5fd8bc323b43bae80d6bd30c0345e7098d908181/static/index/ad.gif
--------------------------------------------------------------------------------
/static/index/grid_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zxwk1998/vue-mall-beautiful/5fd8bc323b43bae80d6bd30c0345e7098d908181/static/index/grid_1.png
--------------------------------------------------------------------------------
/static/index/grid_10.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zxwk1998/vue-mall-beautiful/5fd8bc323b43bae80d6bd30c0345e7098d908181/static/index/grid_10.png
--------------------------------------------------------------------------------
/static/index/grid_2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zxwk1998/vue-mall-beautiful/5fd8bc323b43bae80d6bd30c0345e7098d908181/static/index/grid_2.png
--------------------------------------------------------------------------------
/static/index/grid_3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zxwk1998/vue-mall-beautiful/5fd8bc323b43bae80d6bd30c0345e7098d908181/static/index/grid_3.png
--------------------------------------------------------------------------------
/static/index/grid_4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zxwk1998/vue-mall-beautiful/5fd8bc323b43bae80d6bd30c0345e7098d908181/static/index/grid_4.png
--------------------------------------------------------------------------------
/static/index/grid_5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zxwk1998/vue-mall-beautiful/5fd8bc323b43bae80d6bd30c0345e7098d908181/static/index/grid_5.png
--------------------------------------------------------------------------------
/static/index/grid_6.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zxwk1998/vue-mall-beautiful/5fd8bc323b43bae80d6bd30c0345e7098d908181/static/index/grid_6.png
--------------------------------------------------------------------------------
/static/index/grid_7.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zxwk1998/vue-mall-beautiful/5fd8bc323b43bae80d6bd30c0345e7098d908181/static/index/grid_7.png
--------------------------------------------------------------------------------
/static/index/grid_8.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zxwk1998/vue-mall-beautiful/5fd8bc323b43bae80d6bd30c0345e7098d908181/static/index/grid_8.png
--------------------------------------------------------------------------------
/static/index/grid_9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zxwk1998/vue-mall-beautiful/5fd8bc323b43bae80d6bd30c0345e7098d908181/static/index/grid_9.png
--------------------------------------------------------------------------------
/static/index/swiper_1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zxwk1998/vue-mall-beautiful/5fd8bc323b43bae80d6bd30c0345e7098d908181/static/index/swiper_1.jpg
--------------------------------------------------------------------------------
/static/my/header.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zxwk1998/vue-mall-beautiful/5fd8bc323b43bae80d6bd30c0345e7098d908181/static/my/header.png
--------------------------------------------------------------------------------
/static/navs/classifications.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zxwk1998/vue-mall-beautiful/5fd8bc323b43bae80d6bd30c0345e7098d908181/static/navs/classifications.png
--------------------------------------------------------------------------------
/static/navs/classifications_select.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zxwk1998/vue-mall-beautiful/5fd8bc323b43bae80d6bd30c0345e7098d908181/static/navs/classifications_select.png
--------------------------------------------------------------------------------
/static/navs/index.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zxwk1998/vue-mall-beautiful/5fd8bc323b43bae80d6bd30c0345e7098d908181/static/navs/index.png
--------------------------------------------------------------------------------
/static/navs/index_select.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zxwk1998/vue-mall-beautiful/5fd8bc323b43bae80d6bd30c0345e7098d908181/static/navs/index_select.png
--------------------------------------------------------------------------------
/static/navs/my.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zxwk1998/vue-mall-beautiful/5fd8bc323b43bae80d6bd30c0345e7098d908181/static/navs/my.png
--------------------------------------------------------------------------------
/static/navs/my_select.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zxwk1998/vue-mall-beautiful/5fd8bc323b43bae80d6bd30c0345e7098d908181/static/navs/my_select.png
--------------------------------------------------------------------------------
/static/navs/shoppingCart.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zxwk1998/vue-mall-beautiful/5fd8bc323b43bae80d6bd30c0345e7098d908181/static/navs/shoppingCart.png
--------------------------------------------------------------------------------
/static/navs/shoppingCart_select.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zxwk1998/vue-mall-beautiful/5fd8bc323b43bae80d6bd30c0345e7098d908181/static/navs/shoppingCart_select.png
--------------------------------------------------------------------------------
/static/uview/common/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zxwk1998/vue-mall-beautiful/5fd8bc323b43bae80d6bd30c0345e7098d908181/static/uview/common/favicon.ico
--------------------------------------------------------------------------------
/static/uview/common/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zxwk1998/vue-mall-beautiful/5fd8bc323b43bae80d6bd30c0345e7098d908181/static/uview/common/logo.png
--------------------------------------------------------------------------------
/store/$u.mixin.js:
--------------------------------------------------------------------------------
1 | import { mapState } from 'vuex'
2 | import store from "@/store"
3 |
4 | // 尝试将用户在根目录中的store/index.js的vuex的state变量,全部加载到全局变量中
5 | let $uStoreKey = [];
6 | try{
7 | $uStoreKey = store.state ? Object.keys(store.state) : [];
8 | }catch(e){
9 |
10 | }
11 |
12 | module.exports = {
13 | beforeCreate() {
14 | // 将vuex方法挂在到$u中
15 | // 使用方法为:如果要修改vuex的state中的user.name变量为"史诗" => this.$u.vuex('user.name', '史诗')
16 | // 如果要修改vuex的state的version变量为1.0.1 => this.$u.vuex('version', '1.0.1')
17 | this.$u.vuex = (name, value) => {
18 | this.$store.commit('$uStore', {
19 | name,value
20 | })
21 | }
22 | },
23 | computed: {
24 | // 将vuex的state中的所有变量,解构到全局混入的mixin中
25 | ...mapState($uStoreKey)
26 | }
27 | }
--------------------------------------------------------------------------------
/store/index.js:
--------------------------------------------------------------------------------
1 | import Vue from 'vue'
2 | import Vuex from 'vuex'
3 | Vue.use(Vuex)
4 |
5 | let lifeData = {};
6 |
7 | try{
8 | // 尝试获取本地是否存在lifeData变量,第一次启动APP时是不存在的
9 | lifeData = uni.getStorageSync('lifeData');
10 | }catch(e){
11 |
12 | }
13 |
14 | // 需要永久存储,且下次APP启动需要取出的,在state中的变量名
15 | let saveStateKeys = ['vuex_user', 'vuex_token'];
16 |
17 | // 保存变量到本地存储中
18 | const saveLifeData = function(key, value){
19 | // 判断变量名是否在需要存储的数组中
20 | if(saveStateKeys.indexOf(key) != -1) {
21 | // 获取本地存储的lifeData对象,将变量添加到对象中
22 | let tmp = uni.getStorageSync('lifeData');
23 | // 第一次打开APP,不存在lifeData变量,故放一个{}空对象
24 | tmp = tmp ? tmp : {};
25 | tmp[key] = value;
26 | // 执行这一步后,所有需要存储的变量,都挂载在本地的lifeData对象中
27 | uni.setStorageSync('lifeData', tmp);
28 | }
29 | }
30 | const store = new Vuex.Store({
31 | state: {
32 | // 如果上面从本地获取的lifeData对象下有对应的属性,就赋值给state中对应的变量
33 | // 加上vuex_前缀,是防止变量名冲突,也让人一目了然
34 | vuex_user: lifeData.vuex_user ? lifeData.vuex_user : {name: '明月'},
35 | vuex_token: lifeData.vuex_token ? lifeData.vuex_token : '',
36 | // 如果vuex_version无需保存到本地永久存储,无需lifeData.vuex_version方式
37 | vuex_version: '1.0.1',
38 | vuex_demo: '绛紫',
39 | // 自定义tabbar数据
40 | vuex_tabbar: [{
41 | iconPath: "/static/uview/example/component.png",
42 | selectedIconPath: "/static/uview/example/component_select.png",
43 | text: '组件',
44 | pagePath: '/pages/example/components'
45 | },
46 | {
47 | iconPath: "/static/uview/example/js.png",
48 | selectedIconPath: "/static/uview/example/js_select.png",
49 | text: '工具',
50 | midButton: true,
51 | pagePath: '/pages/example/js'
52 | },
53 | {
54 | iconPath: "/static/uview/example/template.png",
55 | selectedIconPath: "/static/uview/example/template_select.png",
56 | text: '模板',
57 | pagePath: '/pages/example/template'
58 | }
59 | ]
60 | },
61 | mutations: {
62 | $uStore(state, payload) {
63 | // 判断是否多层级调用,state中为对象存在的情况,诸如user.info.score = 1
64 | let nameArr = payload.name.split('.');
65 | let saveKey = '';
66 | let len = nameArr.length;
67 | if(len >= 2) {
68 | let obj = state[nameArr[0]];
69 | for(let i = 1; i < len - 1; i ++) {
70 | obj = obj[nameArr[i]];
71 | }
72 | obj[nameArr[len - 1]] = payload.value;
73 | saveKey = nameArr[0];
74 | } else {
75 | // 单层级变量,在state就是一个普通变量的情况
76 | state[payload.name] = payload.value;
77 | saveKey = payload.name;
78 | }
79 | // 保存变量到本地,见顶部函数定义
80 | saveLifeData(saveKey, state[saveKey])
81 | }
82 | }
83 | })
84 |
85 | export default store
86 |
--------------------------------------------------------------------------------
/uni.scss:
--------------------------------------------------------------------------------
1 | /**
2 | * 下方引入的为uView UI的集成样式文件,为scss预处理器,其中包含了一些"u-"开头的自定义变量
3 | * 使用的时候,请将下面的一行复制到您的uniapp项目根目录的uni.scss中即可
4 | * uView自定义的css类名和scss变量,均以"u-"开头,不会造成冲突,请放心使用
5 | */
6 | @import 'uview-ui/theme.scss';
7 | $base-color-red:#ee0a24;
8 | $base-color-default:#{$base-color-red};
--------------------------------------------------------------------------------
/uview-ui/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2020 www.uviewui.com
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
--------------------------------------------------------------------------------
/uview-ui/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | uView
5 | 多平台快速开发的UI框架
6 |
7 |
8 | ## 说明
9 |
10 | uView UI,是[uni-app](https://uniapp.dcloud.io/)生态优秀的UI框架,全面的组件和便捷的工具会让您信手拈来,如鱼得水
11 |
12 | ## 特性
13 |
14 | - 兼容安卓,iOS,微信小程序,H5,QQ小程序,百度小程序,支付宝小程序,头条小程序
15 | - 60+精选组件,功能丰富,多端兼容,让您快速集成,开箱即用
16 | - 众多贴心的JS利器,让您飞镖在手,召之即来,百步穿杨
17 | - 众多的常用页面和布局,让您专注逻辑,事半功倍
18 | - 详尽的文档支持,现代化的演示效果
19 | - 按需引入,精简打包体积
20 |
21 |
22 | ## 安装
23 |
24 | ```bash
25 | # npm方式安装
26 | npm i uview-ui
27 | ```
28 |
29 | ## 快速上手
30 |
31 | 1. `main.js`引入uView库
32 | ```js
33 | // main.js
34 | import uView from 'uview-ui';
35 | Vue.use(uView);
36 | ```
37 |
38 | 2. `App.vue`引入基础样式(注意style标签需声明scss属性支持)
39 | ```css
40 | /* App.vue */
41 |
44 | ```
45 |
46 | 3. `uni.scss`引入全局scss变量文件
47 | ```css
48 | /* uni.scss */
49 | @import "uview-ui/theme.scss";
50 | ```
51 |
52 | 4. `pages.json`配置easycom规则(按需引入)
53 |
54 | ```js
55 | // pages.json
56 | {
57 | "easycom": {
58 | // npm安装的方式不需要前面的"@/",下载安装的方式需要"@/"
59 | // npm安装方式
60 | "^u-(.*)": "uview-ui/components/u-$1/u-$1.vue"
61 | // 下载安装方式
62 | // "^u-(.*)": "@/uview-ui/components/u-$1/u-$1.vue"
63 | },
64 | // 此为本身已有的内容
65 | "pages": [
66 | // ......
67 | ]
68 | }
69 | ```
70 |
71 | 请通过[快速上手](https://uviewui.com/components/quickstart.html)了解更详细的内容
72 |
73 | ## 使用方法
74 | 配置easycom规则后,自动按需引入,无需`import`组件,直接引用即可。
75 |
76 | ```html
77 |
78 | 按钮
79 |
80 | ```
81 |
82 | 请通过[快速上手](https://uviewui.com/components/quickstart.html)了解更详细的内容
83 |
84 | ## 链接
85 |
86 | - [官方文档](https://uviewui.com/)
87 | - [更新日志](https://uviewui.com/components/changelog.html)
88 | - [升级指南](https://uviewui.com/components/changelog.html)
89 | - [关于我们](https://uviewui.com/cooperation/about.html)
90 |
91 | ## 预览
92 |
93 | 您可以通过**微信**扫码,查看最佳的演示效果。
94 |
95 |
96 |
97 |
98 |
105 | ## 版权信息
106 | uView遵循[MIT](https://en.wikipedia.org/wiki/MIT_License)开源协议,意味着您无需支付任何费用,也无需授权,即可将uView应用到您的产品中。
107 |
--------------------------------------------------------------------------------
/uview-ui/components/u-back-top/u-back-top.vue:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
12 | {{tips}}
13 |
14 |
15 |
16 |
17 |
18 |
19 |
124 |
125 |
154 |
--------------------------------------------------------------------------------
/uview-ui/components/u-cell-group/u-cell-group.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | {{title}}
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
51 |
52 |
71 |
--------------------------------------------------------------------------------
/uview-ui/components/u-checkbox-group/u-checkbox-group.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
113 |
114 |
124 |
--------------------------------------------------------------------------------
/uview-ui/components/u-col/u-col.vue:
--------------------------------------------------------------------------------
1 |
2 |
13 |
14 |
15 |
16 |
17 |
90 |
91 |
152 |
--------------------------------------------------------------------------------
/uview-ui/components/u-collapse/u-collapse.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
96 |
97 |
100 |
--------------------------------------------------------------------------------
/uview-ui/components/u-divider/u-divider.vue:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
13 |
14 |
15 |
16 |
17 |
106 |
107 |
154 |
--------------------------------------------------------------------------------
/uview-ui/components/u-dropdown-item/u-dropdown-item.vue:
--------------------------------------------------------------------------------
1 |
2 | {}" @tap.stop.prevent="() => {}">
3 |
4 |
5 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
105 |
106 |
109 |
--------------------------------------------------------------------------------
/uview-ui/components/u-empty/u-empty.vue:
--------------------------------------------------------------------------------
1 |
2 |
5 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
171 |
172 |
194 |
--------------------------------------------------------------------------------
/uview-ui/components/u-form/u-form.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
131 |
132 |
135 |
--------------------------------------------------------------------------------
/uview-ui/components/u-full-screen/u-full-screen.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
38 |
39 |
53 |
--------------------------------------------------------------------------------
/uview-ui/components/u-gap/u-gap.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
51 |
52 |
55 |
--------------------------------------------------------------------------------
/uview-ui/components/u-grid-item/u-grid-item.vue:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
81 |
82 |
127 |
--------------------------------------------------------------------------------
/uview-ui/components/u-grid/u-grid.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
72 |
73 |
91 |
--------------------------------------------------------------------------------
/uview-ui/components/u-index-anchor/u-index-anchor.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | {{ index }}
9 |
10 |
11 |
12 |
13 |
14 |
15 |
68 |
69 |
90 |
--------------------------------------------------------------------------------
/uview-ui/components/u-line-progress/u-line-progress.vue:
--------------------------------------------------------------------------------
1 |
2 |
7 |
12 |
13 |
14 | {{percent + '%'}}
15 |
16 |
17 |
18 |
19 |
20 |
102 |
103 |
148 |
--------------------------------------------------------------------------------
/uview-ui/components/u-line/u-line.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
77 |
78 |
85 |
--------------------------------------------------------------------------------
/uview-ui/components/u-link/u-link.vue:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
10 |
11 |
12 |
82 |
83 |
90 |
--------------------------------------------------------------------------------
/uview-ui/components/u-loading-page/u-loading-page.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
22 |
23 |
26 |
--------------------------------------------------------------------------------
/uview-ui/components/u-loading/u-loading.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
53 |
54 |
104 |
--------------------------------------------------------------------------------
/uview-ui/components/u-mask/u-mask.vue:
--------------------------------------------------------------------------------
1 |
2 | {}" :class="{
3 | 'u-mask-zoom': zoom,
4 | 'u-mask-show': show
5 | }">
6 |
7 |
8 |
9 |
10 |
102 |
103 |
124 |
--------------------------------------------------------------------------------
/uview-ui/components/u-number-keyboard/u-number-keyboard.vue:
--------------------------------------------------------------------------------
1 |
2 | {}">
3 |
4 |
13 | {{ item }}
14 |
15 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
121 |
122 |
159 |
--------------------------------------------------------------------------------
/uview-ui/components/u-parse/libs/CssHandler.js:
--------------------------------------------------------------------------------
1 | const cfg = require('./config.js'),
2 | isLetter = c => (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z');
3 |
4 | function CssHandler(tagStyle) {
5 | var styles = Object.assign(Object.create(null), cfg.userAgentStyles);
6 | for (var item in tagStyle)
7 | styles[item] = (styles[item] ? styles[item] + ';' : '') + tagStyle[item];
8 | this.styles = styles;
9 | }
10 | CssHandler.prototype.getStyle = function(data) {
11 | this.styles = new parser(data, this.styles).parse();
12 | }
13 | CssHandler.prototype.match = function(name, attrs) {
14 | var tmp, matched = (tmp = this.styles[name]) ? tmp + ';' : '';
15 | if (attrs.class) {
16 | var items = attrs.class.split(' ');
17 | for (var i = 0, item; item = items[i]; i++)
18 | if (tmp = this.styles['.' + item])
19 | matched += tmp + ';';
20 | }
21 | if (tmp = this.styles['#' + attrs.id])
22 | matched += tmp + ';';
23 | return matched;
24 | }
25 | module.exports = CssHandler;
26 |
27 | function parser(data, init) {
28 | this.data = data;
29 | this.floor = 0;
30 | this.i = 0;
31 | this.list = [];
32 | this.res = init;
33 | this.state = this.Space;
34 | }
35 | parser.prototype.parse = function() {
36 | for (var c; c = this.data[this.i]; this.i++)
37 | this.state(c);
38 | return this.res;
39 | }
40 | parser.prototype.section = function() {
41 | return this.data.substring(this.start, this.i);
42 | }
43 | // 状态机
44 | parser.prototype.Space = function(c) {
45 | if (c == '.' || c == '#' || isLetter(c)) {
46 | this.start = this.i;
47 | this.state = this.Name;
48 | } else if (c == '/' && this.data[this.i + 1] == '*')
49 | this.Comment();
50 | else if (!cfg.blankChar[c] && c != ';')
51 | this.state = this.Ignore;
52 | }
53 | parser.prototype.Comment = function() {
54 | this.i = this.data.indexOf('*/', this.i) + 1;
55 | if (!this.i) this.i = this.data.length;
56 | this.state = this.Space;
57 | }
58 | parser.prototype.Ignore = function(c) {
59 | if (c == '{') this.floor++;
60 | else if (c == '}' && !--this.floor) this.state = this.Space;
61 | }
62 | parser.prototype.Name = function(c) {
63 | if (cfg.blankChar[c]) {
64 | this.list.push(this.section());
65 | this.state = this.NameSpace;
66 | } else if (c == '{') {
67 | this.list.push(this.section());
68 | this.Content();
69 | } else if (c == ',') {
70 | this.list.push(this.section());
71 | this.Comma();
72 | } else if (!isLetter(c) && (c < '0' || c > '9') && c != '-' && c != '_')
73 | this.state = this.Ignore;
74 | }
75 | parser.prototype.NameSpace = function(c) {
76 | if (c == '{') this.Content();
77 | else if (c == ',') this.Comma();
78 | else if (!cfg.blankChar[c]) this.state = this.Ignore;
79 | }
80 | parser.prototype.Comma = function() {
81 | while (cfg.blankChar[this.data[++this.i]]);
82 | if (this.data[this.i] == '{') this.Content();
83 | else {
84 | this.start = this.i--;
85 | this.state = this.Name;
86 | }
87 | }
88 | parser.prototype.Content = function() {
89 | this.start = ++this.i;
90 | if ((this.i = this.data.indexOf('}', this.i)) == -1) this.i = this.data.length;
91 | var content = this.section();
92 | for (var i = 0, item; item = this.list[i++];)
93 | if (this.res[item]) this.res[item] += ';' + content;
94 | else this.res[item] = content;
95 | this.list = [];
96 | this.state = this.Space;
97 | }
98 |
--------------------------------------------------------------------------------
/uview-ui/components/u-parse/libs/config.js:
--------------------------------------------------------------------------------
1 | /* 配置文件 */
2 | var cfg = {
3 | // 出错占位图
4 | errorImg: null,
5 | // 过滤器函数
6 | filter: null,
7 | // 代码高亮函数
8 | highlight: null,
9 | // 文本处理函数
10 | onText: null,
11 | // 实体编码列表
12 | entities: {
13 | quot: '"',
14 | apos: "'",
15 | semi: ';',
16 | nbsp: '\xA0',
17 | ensp: '\u2002',
18 | emsp: '\u2003',
19 | ndash: '–',
20 | mdash: '—',
21 | middot: '·',
22 | lsquo: '‘',
23 | rsquo: '’',
24 | ldquo: '“',
25 | rdquo: '”',
26 | bull: '•',
27 | hellip: '…'
28 | },
29 | blankChar: makeMap(' ,\xA0,\t,\r,\n,\f'),
30 | boolAttrs: makeMap('allowfullscreen,autoplay,autostart,controls,ignore,loop,muted'),
31 | // 块级标签,将被转为 div
32 | blockTags: makeMap('address,article,aside,body,caption,center,cite,footer,header,html,nav,pre,section'),
33 | // 将被移除的标签
34 | ignoreTags: makeMap('area,base,canvas,frame,iframe,input,link,map,meta,param,script,source,style,svg,textarea,title,track,wbr'),
35 | // 只能被 rich-text 显示的标签
36 | richOnlyTags: makeMap('a,colgroup,fieldset,legend,table'),
37 | // 自闭合的标签
38 | selfClosingTags: makeMap('area,base,br,col,circle,ellipse,embed,frame,hr,img,input,line,link,meta,param,path,polygon,rect,source,track,use,wbr'),
39 | // 信任的标签
40 | trustTags: makeMap('a,abbr,ad,audio,b,blockquote,br,code,col,colgroup,dd,del,dl,dt,div,em,fieldset,h1,h2,h3,h4,h5,h6,hr,i,img,ins,label,legend,li,ol,p,q,source,span,strong,sub,sup,table,tbody,td,tfoot,th,thead,tr,title,ul,video'),
41 | // 默认的标签样式
42 | userAgentStyles: {
43 | address: 'font-style:italic',
44 | big: 'display:inline;font-size:1.2em',
45 | blockquote: 'background-color:#f6f6f6;border-left:3px solid #dbdbdb;color:#6c6c6c;padding:5px 0 5px 10px',
46 | caption: 'display:table-caption;text-align:center',
47 | center: 'text-align:center',
48 | cite: 'font-style:italic',
49 | dd: 'margin-left:40px',
50 | mark: 'background-color:yellow',
51 | pre: 'font-family:monospace;white-space:pre;overflow:scroll',
52 | s: 'text-decoration:line-through',
53 | small: 'display:inline;font-size:0.8em',
54 | u: 'text-decoration:underline'
55 | }
56 | }
57 |
58 | function makeMap(str) {
59 | var map = Object.create(null),
60 | list = str.split(',');
61 | for (var i = list.length; i--;)
62 | map[list[i]] = true;
63 | return map;
64 | }
65 |
66 | // #ifdef MP-WEIXIN
67 | if (wx.canIUse('editor')) {
68 | cfg.blockTags.pre = void 0;
69 | cfg.ignoreTags.rp = true;
70 | Object.assign(cfg.richOnlyTags, makeMap('bdi,bdo,caption,rt,ruby'));
71 | Object.assign(cfg.trustTags, makeMap('bdi,bdo,caption,pre,rt,ruby'));
72 | }
73 | // #endif
74 |
75 | // #ifdef APP-PLUS
76 | cfg.ignoreTags.iframe = void 0;
77 | Object.assign(cfg.trustTags, makeMap('embed,iframe'));
78 | // #endif
79 |
80 | module.exports = cfg;
81 |
--------------------------------------------------------------------------------
/uview-ui/components/u-parse/libs/handler.wxs:
--------------------------------------------------------------------------------
1 | var inline = {
2 | abbr: 1,
3 | b: 1,
4 | big: 1,
5 | code: 1,
6 | del: 1,
7 | em: 1,
8 | i: 1,
9 | ins: 1,
10 | label: 1,
11 | q: 1,
12 | small: 1,
13 | span: 1,
14 | strong: 1,
15 | sub: 1,
16 | sup: 1
17 | }
18 | module.exports = {
19 | use: function(item) {
20 | return !item.c && !inline[item.name] && (item.attrs.style || '').indexOf('display:inline') == -1
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/uview-ui/components/u-radio-group/u-radio-group.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
99 |
100 |
110 |
--------------------------------------------------------------------------------
/uview-ui/components/u-read-more/u-read-more.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
8 |
9 |
12 |
16 | {{ showMore ? openText : closeText }}
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
142 |
143 |
180 |
--------------------------------------------------------------------------------
/uview-ui/components/u-row/u-row.vue:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
10 |
11 |
12 |
60 |
61 |
80 |
--------------------------------------------------------------------------------
/uview-ui/components/u-section/u-section.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
11 |
12 |
13 |
14 | {{title}}
15 |
16 |
19 |
20 |
21 | {{subTitle}}
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
117 |
118 |
155 |
--------------------------------------------------------------------------------
/uview-ui/components/u-steps/u-steps.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
9 |
13 |
21 |
24 | {{ index + 1 }}
25 |
26 |
27 |
28 |
31 |
34 | {{ item.name }}
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
109 |
110 |
201 |
--------------------------------------------------------------------------------
/uview-ui/components/u-sticky/u-sticky.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
150 |
151 |
158 |
--------------------------------------------------------------------------------
/uview-ui/components/u-switch/u-switch.vue:
--------------------------------------------------------------------------------
1 |
2 |
4 |
8 |
9 |
10 |
11 |
12 |
13 |
108 |
109 |
164 |
--------------------------------------------------------------------------------
/uview-ui/components/u-table/u-table.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
76 |
77 |
85 |
--------------------------------------------------------------------------------
/uview-ui/components/u-td/u-td.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
51 |
52 |
67 |
--------------------------------------------------------------------------------
/uview-ui/components/u-th/u-th.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
48 |
49 |
63 |
--------------------------------------------------------------------------------
/uview-ui/components/u-time-line-item/u-time-line-item.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
52 |
53 |
84 |
--------------------------------------------------------------------------------
/uview-ui/components/u-time-line/u-time-line.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
23 |
24 |
44 |
--------------------------------------------------------------------------------
/uview-ui/components/u-top-tips/u-top-tips.vue:
--------------------------------------------------------------------------------
1 |
2 | {{ title }}
6 |
7 |
8 |
69 |
70 |
122 |
--------------------------------------------------------------------------------
/uview-ui/components/u-tr/u-tr.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
18 |
19 |
26 |
--------------------------------------------------------------------------------
/uview-ui/components/u-verification-code/u-verification-code.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
154 |
155 |
165 |
--------------------------------------------------------------------------------
/uview-ui/components/u-waterfall/u-waterfall.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
156 |
157 |
177 |
--------------------------------------------------------------------------------
/uview-ui/index.js:
--------------------------------------------------------------------------------
1 | // 引入全局mixin
2 | import mixin from './libs/mixin/mixin.js'
3 | // 引入关于是否mixin集成小程序分享的配置
4 | // import wxshare from './libs/mixin/mpShare.js'
5 | // 全局挂载引入http相关请求拦截插件
6 | import http from './libs/request'
7 |
8 | function wranning(str) {
9 | // 开发环境进行信息输出,主要是一些报错信息
10 | // 这个环境的来由是在程序编写时候,点击hx编辑器运行调试代码的时候,详见:
11 | // https://uniapp.dcloud.io/frame?id=%e5%bc%80%e5%8f%91%e7%8e%af%e5%a2%83%e5%92%8c%e7%94%9f%e4%ba%a7%e7%8e%af%e5%a2%83
12 | if (process.env.NODE_ENV === 'development') {
13 | console.warn(str)
14 | }
15 | }
16 |
17 | // 尝试判断在根目录的/store中是否有$u.mixin.js,此文件uView默认为需要挂在到全局的vuex的state变量
18 | // HX2.6.11版本,放到try中,控制台依然会警告,暂时不用此方式,
19 | // let vuexStore = {};
20 | // try {
21 | // vuexStore = require("@/store/$u.mixin.js");
22 | // } catch (e) {
23 | // //TODO handle the exception
24 | // }
25 |
26 | // post类型对象参数转为get类型url参数
27 | import queryParams from './libs/function/queryParams.js'
28 | // 路由封装
29 | import route from './libs/function/route.js'
30 | // 时间格式化
31 | import timeFormat from './libs/function/timeFormat.js'
32 | // 时间戳格式化,返回多久之前
33 | import timeFrom from './libs/function/timeFrom.js'
34 | // 颜色渐变相关,colorGradient-颜色渐变,hexToRgb-十六进制颜色转rgb颜色,rgbToHex-rgb转十六进制
35 | import colorGradient from './libs/function/colorGradient.js'
36 | // 生成全局唯一guid字符串
37 | import guid from './libs/function/guid.js'
38 | // 主题相关颜色,info|success|warning|primary|default|error,此颜色已在uview.scss中定义,但是为js中也能使用,故也定义一份
39 | import color from './libs/function/color.js'
40 | // 根据type获取图标名称
41 | import type2icon from './libs/function/type2icon.js'
42 | // 打乱数组的顺序
43 | import randomArray from './libs/function/randomArray.js'
44 | // 对象和数组的深度克隆
45 | import deepClone from './libs/function/deepClone.js'
46 | // 对象深度拷贝
47 | import deepMerge from './libs/function/deepMerge.js'
48 | // 添加单位
49 | import addUnit from './libs/function/addUnit.js'
50 |
51 | // 规则检验
52 | import test from './libs/function/test.js'
53 | // 随机数
54 | import random from './libs/function/random.js'
55 | // 去除空格
56 | import trim from './libs/function/trim.js'
57 | // toast提示,对uni.showToast的封装
58 | import toast from './libs/function/toast.js'
59 | // 获取父组件参数
60 | import getParent from './libs/function/getParent.js'
61 | // 获取整个父组件
62 | import $parent from './libs/function/$parent.js'
63 | // 获取sys()和os()工具方法
64 | // 获取设备信息,挂载到$u的sys()(system的缩写)属性中,
65 | // 同时把安卓和ios平台的名称"ios"和"android"挂到$u.os()中,方便取用
66 | import {sys, os} from './libs/function/sys.js'
67 | // 防抖方法
68 | import debounce from './libs/function/debounce.js'
69 | // 节流方法
70 | import throttle from './libs/function/throttle.js'
71 |
72 |
73 | // 配置信息
74 | import config from './libs/config/config.js'
75 | // 各个需要fixed的地方的z-index配置文件
76 | import zIndex from './libs/config/zIndex.js'
77 |
78 | const $u = {
79 | queryParams: queryParams,
80 | route: route,
81 | timeFormat: timeFormat,
82 | date: timeFormat, // 另名date
83 | timeFrom,
84 | colorGradient: colorGradient.colorGradient,
85 | guid,
86 | color,
87 | sys,
88 | os,
89 | type2icon,
90 | randomArray,
91 | wranning,
92 | get: http.get,
93 | post: http.post,
94 | put: http.put,
95 | 'delete': http.delete,
96 | hexToRgb: colorGradient.hexToRgb,
97 | rgbToHex: colorGradient.rgbToHex,
98 | test,
99 | random,
100 | deepClone,
101 | deepMerge,
102 | getParent,
103 | $parent,
104 | addUnit,
105 | trim,
106 | type: ['primary', 'success', 'error', 'warning', 'info'],
107 | http,
108 | toast,
109 | config, // uView配置信息相关,比如版本号
110 | zIndex,
111 | debounce,
112 | throttle,
113 | }
114 |
115 | const install = Vue => {
116 | Vue.mixin(mixin)
117 | if (Vue.prototype.openShare) {
118 | Vue.mixin(mpShare);
119 | }
120 | // Vue.mixin(vuexStore);
121 | // 时间格式化,同时两个名称,date和timeFormat
122 | Vue.filter('timeFormat', (timestamp, format) => {
123 | return timeFormat(timestamp, format)
124 | })
125 | Vue.filter('date', (timestamp, format) => {
126 | return timeFormat(timestamp, format)
127 | })
128 | // 将多久以前的方法,注入到全局过滤器
129 | Vue.filter('timeFrom', (timestamp, format) => {
130 | return timeFrom(timestamp, format)
131 | })
132 | Vue.prototype.$u = $u
133 | }
134 |
135 | export default {
136 | install
137 | }
--------------------------------------------------------------------------------
/uview-ui/index.scss:
--------------------------------------------------------------------------------
1 | // 引入公共基础类
2 | @import "./libs/css/common.scss";
3 | @import "./libs/css/color.scss";
4 |
5 | // 非nvue的样式
6 | /* #ifndef APP-NVUE */
7 | @import "./libs/css/style.vue.scss";
8 | /* #endif */
9 |
10 | // nvue的特有样式
11 | /* #ifdef APP-NVUE */
12 | @import "./libs/css/style.nvue.scss";
13 | /* #endif */
14 |
15 | // 小程序特有的样式
16 | /* #ifdef MP */
17 | @import "./libs/css/style.mp.scss";
18 | /* #endif */
19 |
20 | // H5特有的样式
21 | /* #ifdef H5 */
22 | @import "./libs/css/style.h5.scss";
23 | /* #endif */
--------------------------------------------------------------------------------
/uview-ui/libs/config/config.js:
--------------------------------------------------------------------------------
1 | // 此版本发布于2020-09-07
2 | let version = '1.6.8';
3 |
4 | export default {
5 | v: version,
6 | version: version,
7 | // 主题名称
8 | type: [
9 | 'primary',
10 | 'success',
11 | 'info',
12 | 'error',
13 | 'warning'
14 | ]
15 | }
--------------------------------------------------------------------------------
/uview-ui/libs/config/zIndex.js:
--------------------------------------------------------------------------------
1 | // uniapp在H5中各API的z-index值如下:
2 | /**
3 | * actionsheet: 999
4 | * modal: 999
5 | * navigate: 998
6 | * tabbar: 998
7 | * toast: 999
8 | */
9 |
10 | export default {
11 | toast: 10090,
12 | noNetwork: 10080,
13 | // popup包含popup,actionsheet,keyboard,picker的值
14 | popup: 10075,
15 | mask: 10070,
16 | navbar: 980,
17 | topTips: 975,
18 | sticky: 970,
19 | indexListSticky: 965,
20 | }
--------------------------------------------------------------------------------
/uview-ui/libs/css/color.scss:
--------------------------------------------------------------------------------
1 | .u-type-primary-light {
2 | color: $u-type-primary-light;
3 | }
4 |
5 | .u-type-warning-light {
6 | color: $u-type-warning-light;
7 | }
8 |
9 | .u-type-success-light {
10 | color: $u-type-success-light;
11 | }
12 |
13 | .u-type-error-light {
14 | color: $u-type-error-light;
15 | }
16 |
17 | .u-type-info-light {
18 | color: $u-type-info-light;
19 | }
20 |
21 | .u-type-primary-light-bg {
22 | background-color: $u-type-primary-light;
23 | }
24 |
25 | .u-type-warning-light-bg {
26 | background-color: $u-type-warning-light;
27 | }
28 |
29 | .u-type-success-light-bg {
30 | background-color: $u-type-success-light;
31 | }
32 |
33 | .u-type-error-light-bg {
34 | background-color: $u-type-error-light;
35 | }
36 |
37 | .u-type-info-light-bg {
38 | background-color: $u-type-info-light;
39 | }
40 |
41 | .u-type-primary-dark {
42 | color: $u-type-primary-dark;
43 | }
44 |
45 | .u-type-warning-dark {
46 | color: $u-type-warning-dark;
47 | }
48 |
49 | .u-type-success-dark {
50 | color: $u-type-success-dark;
51 | }
52 |
53 | .u-type-error-dark {
54 | color: $u-type-error-dark;
55 | }
56 |
57 | .u-type-info-dark {
58 | color: $u-type-info-dark;
59 | }
60 |
61 | .u-type-primary-dark-bg {
62 | background-color: $u-type-primary-dark;
63 | }
64 |
65 | .u-type-warning-dark-bg {
66 | background-color: $u-type-warning-dark;
67 | }
68 |
69 | .u-type-success-dark-bg {
70 | background-color: $u-type-success-dark;
71 | }
72 |
73 | .u-type-error-dark-bg {
74 | background-color: $u-type-error-dark;
75 | }
76 |
77 | .u-type-info-dark-bg {
78 | background-color: $u-type-info-dark;
79 | }
80 |
81 | .u-type-primary-disabled {
82 | color: $u-type-primary-disabled;
83 | }
84 |
85 | .u-type-warning-disabled {
86 | color: $u-type-warning-disabled;
87 | }
88 |
89 | .u-type-success-disabled {
90 | color: $u-type-success-disabled;
91 | }
92 |
93 | .u-type-error-disabled {
94 | color: $u-type-error-disabled;
95 | }
96 |
97 | .u-type-info-disabled {
98 | color: $u-type-info-disabled;
99 | }
100 |
101 | .u-type-primary {
102 | color: $u-type-primary;
103 | }
104 |
105 | .u-type-warning {
106 | color: $u-type-warning;
107 | }
108 |
109 | .u-type-success {
110 | color: $u-type-success;
111 | }
112 |
113 | .u-type-error {
114 | color: $u-type-error;
115 | }
116 |
117 | .u-type-info {
118 | color: $u-type-info;
119 | }
120 |
121 | .u-type-primary-bg {
122 | background-color: $u-type-primary;
123 | }
124 |
125 | .u-type-warning-bg {
126 | background-color: $u-type-warning;
127 | }
128 |
129 | .u-type-success-bg {
130 | background-color: $u-type-success;
131 | }
132 |
133 | .u-type-error-bg {
134 | background-color: $u-type-error;
135 | }
136 |
137 | .u-type-info-bg {
138 | background-color: $u-type-info;
139 | }
140 |
141 | .u-main-color {
142 | color: $u-main-color;
143 | }
144 |
145 | .u-content-color {
146 | color: $u-content-color;
147 | }
148 |
149 | .u-tips-color {
150 | color: $u-tips-color;
151 | }
152 |
153 | .u-light-color {
154 | color: $u-light-color;
155 | }
156 |
--------------------------------------------------------------------------------
/uview-ui/libs/css/common.scss:
--------------------------------------------------------------------------------
1 | .u-relative,
2 | .u-rela {
3 | position: relative;
4 | }
5 |
6 | .u-absolute,
7 | .u-abso {
8 | position: absolute;
9 | }
10 |
11 | // nvue不能用标签命名样式,不能放在微信组件中,否则微信开发工具会报警告,无法使用标签名当做选择器
12 | /* #ifndef APP-NVUE */
13 | image {
14 | display: inline-block;
15 | }
16 |
17 | // 在weex,也即nvue中,所有元素默认为border-box
18 | view,
19 | text {
20 | box-sizing: border-box;
21 | }
22 | /* #endif */
23 |
24 | .u-font-xs {
25 | font-size: 22rpx;
26 | }
27 |
28 | .u-font-sm {
29 | font-size: 26rpx;
30 | }
31 |
32 | .u-font-md {
33 | font-size: 28rpx;
34 | }
35 |
36 | .u-font-lg {
37 | font-size: 30rpx;
38 | }
39 |
40 | .u-font-xl {
41 | font-size: 34rpx;
42 | }
43 |
44 | .u-flex {
45 | /* #ifndef APP-NVUE */
46 | display: flex;
47 | /* #endif */
48 | flex-direction: row;
49 | align-items: center;
50 | }
51 |
52 | .u-flex-wrap {
53 | flex-wrap: wrap;
54 | }
55 |
56 | .u-flex-nowrap {
57 | flex-wrap: nowrap;
58 | }
59 |
60 | .u-col-center {
61 | align-items: center;
62 | }
63 |
64 | .u-col-top {
65 | align-items: flex-start;
66 | }
67 |
68 | .u-col-bottom {
69 | align-items: flex-end;
70 | }
71 |
72 | .u-row-center {
73 | justify-content: center;
74 | }
75 |
76 | .u-row-left {
77 | justify-content: flex-start;
78 | }
79 |
80 | .u-row-right {
81 | justify-content: flex-end;
82 | }
83 |
84 | .u-row-between {
85 | justify-content: space-between;
86 | }
87 |
88 | .u-row-around {
89 | justify-content: space-around;
90 | }
91 |
92 | .u-text-left {
93 | text-align: left;
94 | }
95 |
96 | .u-text-center {
97 | text-align: center;
98 | }
99 |
100 | .u-text-right {
101 | text-align: right;
102 | }
103 |
104 | .u-flex-col {
105 | /* #ifndef APP-NVUE */
106 | display: flex;
107 | /* #endif */
108 | flex-direction: column;
109 | }
110 |
111 | // 定义flex等分
112 | @for $i from 0 through 12 {
113 | .u-flex-#{$i} {
114 | flex: $i;
115 | }
116 | }
117 |
118 | // 定义字体(px)单位,小于20都为px单位字体
119 | @for $i from 9 to 20 {
120 | .u-font-#{$i} {
121 | font-size: $i + px;
122 | }
123 | }
124 |
125 | // 定义字体(rpx)单位,大于或等于20的都为rpx单位字体
126 | @for $i from 20 through 40 {
127 | .u-font-#{$i} {
128 | font-size: $i + rpx;
129 | }
130 | }
131 |
132 | // 定义内外边距,历遍1-80
133 | @for $i from 0 through 80 {
134 | // 只要双数和能被5除尽的数
135 | @if $i % 2 == 0 or $i % 5 == 0 {
136 | // 得出:u-margin-30或者u-m-30
137 | .u-margin-#{$i}, .u-m-#{$i} {
138 | margin: $i + rpx!important;
139 | }
140 |
141 | // 得出:u-padding-30或者u-p-30
142 | .u-padding-#{$i}, .u-p-#{$i} {
143 | padding: $i + rpx!important;
144 | }
145 |
146 | @each $short, $long in l left, t top, r right, b bottom {
147 | // 缩写版,结果如: u-m-l-30
148 | // 定义外边距
149 | .u-m-#{$short}-#{$i} {
150 | margin-#{$long}: $i + rpx!important;
151 | }
152 |
153 | // 定义内边距
154 | .u-p-#{$short}-#{$i} {
155 | padding-#{$long}: $i + rpx!important;
156 | }
157 |
158 | // 完整版,结果如:u-margin-left-30
159 | // 定义外边距
160 | .u-margin-#{$long}-#{$i} {
161 | margin-#{$long}: $i + rpx!important;
162 | }
163 |
164 | // 定义内边距
165 | .u-padding-#{$long}-#{$i} {
166 | padding-#{$long}: $i + rpx!important;
167 | }
168 | }
169 | }
170 | }
171 |
172 | // 重置nvue的默认关于flex的样式
173 | .u-reset-nvue {
174 | flex-direction: row;
175 | align-items: center;
176 | }
--------------------------------------------------------------------------------
/uview-ui/libs/css/style.components.scss:
--------------------------------------------------------------------------------
1 | // 定义混入指令,用于在非nvue环境下的flex定义,因为nvue没有display属性,会报错
2 | @mixin vue-flex($direction: row) {
3 | /* #ifndef APP-NVUE */
4 | display: flex;
5 | flex-direction: $direction;
6 | /* #endif */
7 | }
--------------------------------------------------------------------------------
/uview-ui/libs/css/style.h5.scss:
--------------------------------------------------------------------------------
1 | /* H5的时候,隐藏滚动条 */
2 | ::-webkit-scrollbar {
3 | display: none;
4 | width: 0 !important;
5 | height: 0 !important;
6 | -webkit-appearance: none;
7 | background: transparent;
8 | }
9 |
--------------------------------------------------------------------------------
/uview-ui/libs/css/style.mp.scss:
--------------------------------------------------------------------------------
1 | /* start--微信小程序编译后页面有组件名的元素,特别处理--start */
2 | /* #ifdef MP-WEIXIN || MP-QQ */
3 | u-td, u-th {
4 | flex: 1;
5 | align-self: stretch;
6 | }
7 |
8 | .u-td {
9 | height: 100%;
10 | }
11 |
12 | u-icon {
13 | display: inline-flex;
14 | align-items: center;
15 | }
16 |
17 | // 各家小程序宫格组件外层设置为100%,避免受到父元素display: flex;的影响
18 | u-grid {
19 | width: 100%;
20 | flex: 0 0 100%;
21 | }
22 |
23 | // 避免小程序线条组件因为父组件display: flex;而失效
24 | u-line {
25 | flex: 1;
26 | }
27 |
28 | u-switch {
29 | display: inline-flex;
30 | align-items: center;
31 | }
32 |
33 | u-dropdown {
34 | flex: 1;
35 | }
36 | /* #endif */
37 | /* end-微信小程序编译后页面有组件名的元素,特别处理--end */
38 |
39 |
40 | /* #ifdef MP-QQ || MP-TOUTIAO */
41 | // 需要做这一切额外的兼容,都是因为TX的无能
42 | u-icon {
43 | line-height: 0;
44 | }
45 | /* #endif */
46 |
47 | /* start--头条小程序编译后页面有组件名的元素,特别处理--start */
48 | // 由于头条小程序不支持直接组件名形式写样式,目前只能在写组件的时候给组件加上对应的类名
49 | /* #ifdef MP-TOUTIAO */
50 | .u-td, .u-th, .u-tr {
51 | flex: 1;
52 | align-self: stretch;
53 | }
54 |
55 | .u-row, .u-col {
56 | flex: 1;
57 | align-self: stretch;
58 | }
59 |
60 | // 避免小程序线条组件因为父组件display: flex;而失效
61 | .u-line {
62 | flex: 1;
63 | }
64 |
65 | .u-dropdown {
66 | flex: 1;
67 | }
68 | /* #endif */
69 | /* end-头条小程序编译后页面有组件名的元素,特别处理--end */
70 |
71 |
72 |
73 |
--------------------------------------------------------------------------------
/uview-ui/libs/css/style.nvue.scss:
--------------------------------------------------------------------------------
1 | .nvue {
2 | font-size: 24rpx;
3 | }
--------------------------------------------------------------------------------
/uview-ui/libs/css/style.vue.scss:
--------------------------------------------------------------------------------
1 | page {
2 | color: $u-main-color;
3 | font-size: 28rpx;
4 | }
5 |
6 | /* start--去除webkit的默认样式--start */
7 | .u-fix-ios-appearance {
8 | -webkit-appearance:none;
9 | }
10 | /* end--去除webkit的默认样式--end */
11 |
12 | /* start--icon图标外层套一个view,让其达到更好的垂直居中的效果--start */
13 | .u-icon-wrap {
14 | display: flex;
15 | align-items: center;
16 | }
17 | /* end-icon图标外层套一个view,让其达到更好的垂直居中的效果--end */
18 |
19 | /* start--iPhoneX底部安全区定义--start */
20 | .safe-area-inset-bottom {
21 | padding-bottom: 0;
22 | padding-bottom: constant(safe-area-inset-bottom);
23 | padding-bottom: env(safe-area-inset-bottom);
24 | }
25 | /* end-iPhoneX底部安全区定义--end */
26 |
27 | /* start--各种hover点击反馈相关的类名-start */
28 | .u-hover-class {
29 | // background-color: #f7f8f9!important;
30 | opacity: 0.6;
31 | }
32 |
33 | .u-cell-hover {
34 | background-color: #f7f8f9!important;
35 | }
36 | /* end--各种hover点击反馈相关的类名--end */
37 |
38 | /* start--文本行数限制--start */
39 | .u-line-1 {
40 | overflow: hidden;
41 | white-space: nowrap;
42 | text-overflow: ellipsis;
43 | }
44 |
45 | .u-line-2 {
46 | -webkit-line-clamp: 2;
47 | }
48 |
49 | .u-line-3 {
50 | -webkit-line-clamp: 3;
51 | }
52 |
53 | .u-line-4 {
54 | -webkit-line-clamp: 4;
55 | }
56 |
57 | .u-line-5 {
58 | -webkit-line-clamp: 5;
59 | }
60 |
61 | .u-line-2, .u-line-3, .u-line-4, .u-line-5 {
62 | overflow: hidden;
63 | word-break: break-all;
64 | text-overflow: ellipsis;
65 | display: -webkit-box; // 弹性伸缩盒
66 | -webkit-box-orient: vertical; // 设置伸缩盒子元素排列方式
67 | }
68 |
69 | /* end--文本行数限制--end */
70 |
71 |
72 | /* start--Retina 屏幕下的 1px 边框--start */
73 | .u-border,
74 | .u-border-bottom,
75 | .u-border-left,
76 | .u-border-right,
77 | .u-border-top,
78 | .u-border-top-bottom {
79 | position: relative
80 | }
81 |
82 | .u-border-bottom:after,
83 | .u-border-left:after,
84 | .u-border-right:after,
85 | .u-border-top-bottom:after,
86 | .u-border-top:after,
87 | .u-border:after {
88 | /* #ifndef APP-NVUE */
89 | content: ' ';
90 | /* #endif */
91 | position: absolute;
92 | left: 0;
93 | top: 0;
94 | pointer-events: none;
95 | box-sizing: border-box;
96 | -webkit-transform-origin: 0 0;
97 | transform-origin: 0 0;
98 | // 多加0.1%,能解决有时候边框缺失的问题
99 | width: 199.8%;
100 | height: 199.7%;
101 | transform: scale(0.5, 0.5);
102 | border: 0 solid $u-border-color;
103 | z-index: 2;
104 | }
105 |
106 | .u-border-top:after {
107 | border-top-width: 1px
108 | }
109 |
110 | .u-border-left:after {
111 | border-left-width: 1px
112 | }
113 |
114 | .u-border-right:after {
115 | border-right-width: 1px
116 | }
117 |
118 | .u-border-bottom:after {
119 | border-bottom-width: 1px
120 | }
121 |
122 | .u-border-top-bottom:after {
123 | border-width: 1px 0
124 | }
125 |
126 | .u-border:after {
127 | border-width: 1px
128 | }
129 | /* end--Retina 屏幕下的 1px 边框--end */
130 |
131 |
132 | /* start--clearfix--start */
133 | .u-clearfix:after,
134 | .clearfix:after {
135 | /* #ifndef APP-NVUE */
136 | content: '';
137 | /* #endif */
138 | display: table;
139 | clear: both
140 | }
141 | /* end--clearfix--end */
142 |
143 | /* start--高斯模糊tabbar底部处理--start */
144 | .u-blur-effect-inset {
145 | width: 750rpx;
146 | height: var(--window-bottom);
147 | background-color: #FFFFFF;
148 | }
149 | /* end--高斯模糊tabbar底部处理--end */
150 |
151 | /* start--提升H5端uni.toast()的层级,避免被uView的modal等遮盖--start */
152 | /* #ifdef H5 */
153 | uni-toast {
154 | z-index: 10090;
155 | }
156 | uni-toast .uni-toast {
157 | z-index: 10090;
158 | }
159 | /* #endif */
160 | /* end--提升H5端uni.toast()的层级,避免被uView的modal等遮盖--end */
161 |
162 | /* start--去除button的所有默认样式--start */
163 | .u-reset-button {
164 | padding: 0;
165 | font-size: inherit;
166 | line-height: inherit;
167 | background-color: transparent;
168 | color: inherit;
169 | }
170 |
171 | .u-reset-button::after {
172 | border: none;
173 | }
174 | /* end--去除button的所有默认样式--end */
175 |
176 |
--------------------------------------------------------------------------------
/uview-ui/libs/function/$parent.js:
--------------------------------------------------------------------------------
1 | // 获取父组件的参数,因为支付宝小程序不支持provide/inject的写法
2 | // this.$parent在非H5中,可以准确获取到父组件,但是在H5中,需要多次this.$parent.$parent.xxx
3 | // 这里默认值等于undefined有它的含义,因为最顶层元素(组件)的$parent就是undefined,意味着不传name
4 | // 值(默认为undefined),就是查找最顶层的$parent
5 | export default function $parent(name = undefined) {
6 | let parent = this.$parent;
7 | // 通过while历遍,这里主要是为了H5需要多层解析的问题
8 | while (parent) {
9 | // 父组件
10 | if (parent.$options && parent.$options.name !== name) {
11 | // 如果组件的name不相等,继续上一级寻找
12 | parent = parent.$parent;
13 | } else {
14 | return parent;
15 | }
16 | }
17 | return false;
18 | }
--------------------------------------------------------------------------------
/uview-ui/libs/function/addUnit.js:
--------------------------------------------------------------------------------
1 | import validation from './test.js';
2 |
3 | // 添加单位,如果有rpx,%,px等单位结尾或者值为auto,直接返回,否则加上rpx单位结尾
4 | export default function addUnit(value = 'auto', unit = 'rpx') {
5 | value = String(value);
6 | // 用uView内置验证规则中的number判断是否为数值
7 | return validation.number(value) ? `${value}${unit}` : value;
8 | }
--------------------------------------------------------------------------------
/uview-ui/libs/function/bem.js:
--------------------------------------------------------------------------------
1 | function bem(name, conf) {
2 |
3 | }
4 |
5 | module.exports.bem = bem;
6 |
--------------------------------------------------------------------------------
/uview-ui/libs/function/color.js:
--------------------------------------------------------------------------------
1 | // 为了让用户能够自定义主题,会逐步弃用此文件,各颜色通过css提供
2 | // 为了给某些特殊场景使用和向后兼容,无需删除此文件(2020-06-20)
3 | let color = {
4 | primary: "#2979ff",
5 | primaryDark: "#2b85e4",
6 | primaryDisabled: "#a0cfff",
7 | primaryLight: "#ecf5ff",
8 | bgColor: "#f3f4f6",
9 |
10 | info: "#909399",
11 | infoDark: "#82848a",
12 | infoDisabled: "#c8c9cc",
13 | infoLight: "#f4f4f5",
14 |
15 | warning: "#ff9900",
16 | warningDark: "#f29100",
17 | warningDisabled: "#fcbd71",
18 | warningLight: "#fdf6ec",
19 |
20 | error: "#fa3534",
21 | errorDark: "#dd6161",
22 | errorDisabled: "#fab6b6",
23 | errorLight: "#fef0f0",
24 |
25 | success: "#19be6b",
26 | successDark: "#18b566",
27 | successDisabled: "#71d5a1",
28 | successLight: "#dbf1e1",
29 |
30 | mainColor: "#303133",
31 | contentColor: "#606266",
32 | tipsColor: "#909399",
33 | lightColor: "#c0c4cc",
34 | borderColor: "#e4e7ed"
35 | }
36 |
37 | export default color;
--------------------------------------------------------------------------------
/uview-ui/libs/function/colorGradient.js:
--------------------------------------------------------------------------------
1 | /**
2 | * 求两个颜色之间的渐变值
3 | * @param {string} startColor 开始的颜色
4 | * @param {string} endColor 结束的颜色
5 | * @param {number} step 颜色等分的份额
6 | * */
7 | function colorGradient(startColor = 'rgb(0, 0, 0)', endColor = 'rgb(255, 255, 255)', step = 10) {
8 | let startRGB = hexToRgb(startColor, false); //转换为rgb数组模式
9 | let startR = startRGB[0];
10 | let startG = startRGB[1];
11 | let startB = startRGB[2];
12 |
13 | let endRGB = hexToRgb(endColor, false);
14 | let endR = endRGB[0];
15 | let endG = endRGB[1];
16 | let endB = endRGB[2];
17 |
18 | let sR = (endR - startR) / step; //总差值
19 | let sG = (endG - startG) / step;
20 | let sB = (endB - startB) / step;
21 | let colorArr = [];
22 | for (let i = 0; i < step; i++) {
23 | //计算每一步的hex值
24 | let hex = rgbToHex('rgb(' + Math.round((sR * i + startR)) + ',' + Math.round((sG * i + startG)) + ',' + Math.round((sB *
25 | i + startB)) + ')');
26 | colorArr.push(hex);
27 | }
28 | return colorArr;
29 | }
30 |
31 | // 将hex表示方式转换为rgb表示方式(这里返回rgb数组模式)
32 | function hexToRgb(sColor, str = true) {
33 | let reg = /^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/;
34 | sColor = sColor.toLowerCase();
35 | if (sColor && reg.test(sColor)) {
36 | if (sColor.length === 4) {
37 | let sColorNew = "#";
38 | for (let i = 1; i < 4; i += 1) {
39 | sColorNew += sColor.slice(i, i + 1).concat(sColor.slice(i, i + 1));
40 | }
41 | sColor = sColorNew;
42 | }
43 | //处理六位的颜色值
44 | let sColorChange = [];
45 | for (let i = 1; i < 7; i += 2) {
46 | sColorChange.push(parseInt("0x" + sColor.slice(i, i + 2)));
47 | }
48 | if(!str) {
49 | return sColorChange;
50 | } else {
51 | return `rgb(${sColorChange[0]},${sColorChange[1]},${sColorChange[2]})`;
52 | }
53 | } else if (/^(rgb|RGB)/.test(sColor)) {
54 | let arr = sColor.replace(/(?:\(|\)|rgb|RGB)*/g, "").split(",")
55 | return arr.map(val => Number(val));
56 | } else {
57 | return sColor;
58 | }
59 | };
60 |
61 | // 将rgb表示方式转换为hex表示方式
62 | function rgbToHex(rgb) {
63 | let _this = rgb;
64 | let reg = /^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/;
65 | if (/^(rgb|RGB)/.test(_this)) {
66 | let aColor = _this.replace(/(?:\(|\)|rgb|RGB)*/g, "").split(",");
67 | let strHex = "#";
68 | for (let i = 0; i < aColor.length; i++) {
69 | let hex = Number(aColor[i]).toString(16);
70 | hex = String(hex).length == 1 ? 0 + '' + hex : hex; // 保证每个rgb的值为2位
71 | if (hex === "0") {
72 | hex += hex;
73 | }
74 | strHex += hex;
75 | }
76 | if (strHex.length !== 7) {
77 | strHex = _this;
78 | }
79 | return strHex;
80 | } else if (reg.test(_this)) {
81 | let aNum = _this.replace(/#/, "").split("");
82 | if (aNum.length === 6) {
83 | return _this;
84 | } else if (aNum.length === 3) {
85 | let numHex = "#";
86 | for (let i = 0; i < aNum.length; i += 1) {
87 | numHex += (aNum[i] + aNum[i]);
88 | }
89 | return numHex;
90 | }
91 | } else {
92 | return _this;
93 | }
94 | }
95 |
96 | export default {
97 | colorGradient,
98 | hexToRgb,
99 | rgbToHex
100 | }
--------------------------------------------------------------------------------
/uview-ui/libs/function/debounce.js:
--------------------------------------------------------------------------------
1 | let timeout = null;
2 |
3 | /**
4 | * 防抖原理:一定时间内,只有最后一次操作,再过wait毫秒后才执行函数
5 | *
6 | * @param {Function} func 要执行的回调函数
7 | * @param {Number} wait 延时的时间
8 | * @param {Boolean} immediate 是否立即执行
9 | * @return null
10 | */
11 | function debounce(func, wait = 500, immediate = false) {
12 | // 清除定时器
13 | if (timeout !== null) clearTimeout(timeout);
14 | // 立即执行,此类情况一般用不到
15 | if (immediate) {
16 | var callNow = !timeout;
17 | timeout = setTimeout(function() {
18 | timeout = null;
19 | }, wait);
20 | if (callNow) typeof func === 'function' && func();
21 | } else {
22 | // 设置定时器,当最后一次操作后,timeout不会再被清除,所以在延时wait毫秒后执行func回调方法
23 | timeout = setTimeout(function() {
24 | typeof func === 'function' && func();
25 | }, wait);
26 | }
27 | }
28 |
29 | export default debounce
30 |
--------------------------------------------------------------------------------
/uview-ui/libs/function/deepClone.js:
--------------------------------------------------------------------------------
1 | // 判断arr是否为一个数组,返回一个bool值
2 | function isArray (arr) {
3 | return Object.prototype.toString.call(arr) === '[object Array]';
4 | }
5 |
6 | // 深度克隆
7 | function deepClone (obj) {
8 | // 对常见的“非”值,直接返回原来值
9 | if([null, undefined, NaN, false].includes(obj)) return obj;
10 | if(typeof obj !== "object" && typeof obj !== 'function') {
11 | //原始类型直接返回
12 | return obj;
13 | }
14 | var o = isArray(obj) ? [] : {};
15 | for(let i in obj) {
16 | if(obj.hasOwnProperty(i)){
17 | o[i] = typeof obj[i] === "object" ? deepClone(obj[i]) : obj[i];
18 | }
19 | }
20 | return o;
21 | }
22 |
23 | export default deepClone;
24 |
--------------------------------------------------------------------------------
/uview-ui/libs/function/deepMerge.js:
--------------------------------------------------------------------------------
1 | import deepClone from "./deepClone";
2 |
3 | // JS对象深度合并
4 | function deepMerge(target = {}, source = {}) {
5 | target = deepClone(target);
6 | if (typeof target !== 'object' || typeof source !== 'object') return false;
7 | for (var prop in source) {
8 | if (!source.hasOwnProperty(prop)) continue;
9 | if (prop in target) {
10 | if (typeof target[prop] !== 'object') {
11 | target[prop] = source[prop];
12 | } else {
13 | if (typeof source[prop] !== 'object') {
14 | target[prop] = source[prop];
15 | } else {
16 | if (target[prop].concat && source[prop].concat) {
17 | target[prop] = target[prop].concat(source[prop]);
18 | } else {
19 | target[prop] = deepMerge(target[prop], source[prop]);
20 | }
21 | }
22 | }
23 | } else {
24 | target[prop] = source[prop];
25 | }
26 | }
27 | return target;
28 | }
29 |
30 | export default deepMerge;
--------------------------------------------------------------------------------
/uview-ui/libs/function/getParent.js:
--------------------------------------------------------------------------------
1 | // 获取父组件的参数,因为支付宝小程序不支持provide/inject的写法
2 | // this.$parent在非H5中,可以准确获取到父组件,但是在H5中,需要多次this.$parent.$parent.xxx
3 | export default function getParent(name, keys) {
4 | let parent = this.$parent;
5 | // 通过while历遍,这里主要是为了H5需要多层解析的问题
6 | while (parent) {
7 | // 父组件
8 | if (parent.$options.name !== name) {
9 | // 如果组件的name不相等,继续上一级寻找
10 | parent = parent.$parent;
11 | } else {
12 | let data = {};
13 | // 判断keys是否数组,如果传过来的是一个数组,那么直接使用数组元素值当做键值去父组件寻找
14 | if(Array.isArray(keys)) {
15 | keys.map(val => {
16 | data[val] = parent[val] ? parent[val] : '';
17 | })
18 | } else {
19 | // 历遍传过来的对象参数
20 | for(let i in keys) {
21 | // 如果子组件有此值则用,无此值则用父组件的值
22 | // 判断是否空数组,如果是,则用父组件的值,否则用子组件的值
23 | if(Array.isArray(keys[i])) {
24 | if(keys[i].length) {
25 | data[i] = keys[i];
26 | } else {
27 | data[i] = parent[i];
28 | }
29 | } else if(keys[i].constructor === Object) {
30 | // 判断是否对象,如果是对象,且有属性,那么使用子组件的值,否则使用父组件的值
31 | if(Object.keys(keys[i]).length) {
32 | data[i] = keys[i];
33 | } else {
34 | data[i] = parent[i];
35 | }
36 | } else {
37 | // 只要子组件有传值,即使是false值,也是“传值”了,也需要覆盖父组件的同名参数
38 | data[i] = (keys[i] || keys[i] === false) ? keys[i] : parent[i];
39 | }
40 | }
41 | }
42 | return data;
43 | }
44 | }
45 |
46 | return {};
47 | }
--------------------------------------------------------------------------------
/uview-ui/libs/function/guid.js:
--------------------------------------------------------------------------------
1 | /**
2 | * 本算法来源于简书开源代码,详见:https://www.jianshu.com/p/fdbf293d0a85
3 | * 全局唯一标识符(uuid,Globally Unique Identifier),也称作 uuid(Universally Unique IDentifier)
4 | * 一般用于多个组件之间,给它一个唯一的标识符,或者v-for循环的时候,如果使用数组的index可能会导致更新列表出现问题
5 | * 最可能的情况是左滑删除item或者对某条信息流"不喜欢"并去掉它的时候,会导致组件内的数据可能出现错乱
6 | * v-for的时候,推荐使用后端返回的id而不是循环的index
7 | * @param {Number} len uuid的长度
8 | * @param {Boolean} firstU 将返回的首字母置为"u"
9 | * @param {Nubmer} radix 生成uuid的基数(意味着返回的字符串都是这个基数),2-二进制,8-八进制,10-十进制,16-十六进制
10 | */
11 | function guid(len = 32, firstU = true, radix = null) {
12 | let chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split('');
13 | let uuid = [];
14 | radix = radix || chars.length;
15 |
16 | if (len) {
17 | // 如果指定uuid长度,只是取随机的字符,0|x为位运算,能去掉x的小数位,返回整数位
18 | for (let i = 0; i < len; i++) uuid[i] = chars[0 | Math.random() * radix];
19 | } else {
20 | let r;
21 | // rfc4122标准要求返回的uuid中,某些位为固定的字符
22 | uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-';
23 | uuid[14] = '4';
24 |
25 | for (let i = 0; i < 36; i++) {
26 | if (!uuid[i]) {
27 | r = 0 | Math.random() * 16;
28 | uuid[i] = chars[(i == 19) ? (r & 0x3) | 0x8 : r];
29 | }
30 | }
31 | }
32 | // 移除第一个字符,并用u替代,因为第一个字符为数值时,该guuid不能用作id或者class
33 | if (firstU) {
34 | uuid.shift();
35 | return 'u' + uuid.join('');
36 | } else {
37 | return uuid.join('');
38 | }
39 | }
40 |
41 | export default guid;
42 |
--------------------------------------------------------------------------------
/uview-ui/libs/function/queryParams.js:
--------------------------------------------------------------------------------
1 | /**
2 | * 对象转url参数
3 | * @param {*} data,对象
4 | * @param {*} isPrefix,是否自动加上"?"
5 | */
6 | function queryParams(data = {}, isPrefix = true, arrayFormat = 'brackets') {
7 | let prefix = isPrefix ? '?' : ''
8 | let _result = []
9 | if (['indices', 'brackets', 'repeat', 'comma'].indexOf(arrayFormat) == -1) arrayFormat = 'brackets';
10 | for (let key in data) {
11 | let value = data[key]
12 | // 去掉为空的参数
13 | if (['', undefined, null].indexOf(value) >= 0) {
14 | continue;
15 | }
16 | // 如果值为数组,另行处理
17 | if (value.constructor === Array) {
18 | // e.g. {ids: [1, 2, 3]}
19 | switch (arrayFormat) {
20 | case 'indices':
21 | // 结果: ids[0]=1&ids[1]=2&ids[2]=3
22 | for (let i = 0; i < value.length; i++) {
23 | _result.push(key + '[' + i + ']=' + value[i])
24 | }
25 | break;
26 | case 'brackets':
27 | // 结果: ids[]=1&ids[]=2&ids[]=3
28 | value.forEach(_value => {
29 | _result.push(key + '[]=' + _value)
30 | })
31 | break;
32 | case 'repeat':
33 | // 结果: ids=1&ids=2&ids=3
34 | value.forEach(_value => {
35 | _result.push(key + '=' + _value)
36 | })
37 | break;
38 | case 'comma':
39 | // 结果: ids=1,2,3
40 | let commaStr = "";
41 | value.forEach(_value => {
42 | commaStr += (commaStr ? "," : "") + _value;
43 | })
44 | _result.push(key + '=' + commaStr)
45 | break;
46 | default:
47 | value.forEach(_value => {
48 | _result.push(key + '[]=' + _value)
49 | })
50 | }
51 | } else {
52 | _result.push(key + '=' + value)
53 | }
54 | }
55 | return _result.length ? prefix + _result.join('&') : ''
56 | }
57 |
58 | export default queryParams;
59 |
--------------------------------------------------------------------------------
/uview-ui/libs/function/random.js:
--------------------------------------------------------------------------------
1 | function random(min, max) {
2 | if (min >= 0 && max > 0 && max >= min) {
3 | let gab = max - min + 1;
4 | return Math.floor(Math.random() * gab + min);
5 | } else {
6 | return 0;
7 | }
8 | }
9 |
10 | export default random;
11 |
--------------------------------------------------------------------------------
/uview-ui/libs/function/randomArray.js:
--------------------------------------------------------------------------------
1 | // 打乱数组
2 | function randomArray(array = []) {
3 | // 原理是sort排序,Math.random()产生0<= x < 1之间的数,会导致x-0.05大于或者小于0
4 | return array.sort(() => Math.random() - 0.5);
5 | }
6 |
7 | export default randomArray
8 |
--------------------------------------------------------------------------------
/uview-ui/libs/function/route.js:
--------------------------------------------------------------------------------
1 | import queryParams from '../../libs/function/queryParams.js';
2 | /**
3 | * 路由跳转
4 | * 注意:本方法没有对跳转的回调函数进行封装
5 | */
6 | function route(options = {}, params = false) {
7 | let config = {
8 | type: 'navigateTo',
9 | url: '',
10 | delta: 1, // navigateBack页面后退时,回退的层数
11 | params: {}, // 传递的参数
12 | animationType: 'pop-in', // 窗口动画,只在APP有效
13 | animationDuration: 300, // 窗口动画持续时间,单位毫秒,只在APP有效
14 | };
15 | config = Object.assign(config, options);
16 | // 如果url没有"/"开头,添加上,因为uni的路由跳转需要"/"开头
17 | if (config.url[0] != '/') config.url = '/' + config.url;
18 | // 判断是否有传递显式的参数,Object.keys转为数组并判断长度,switchTab类型时不能携带参数
19 | if (Object.keys(config.params).length && config.type != 'switchTab') {
20 | // 判断用户传递的url中,是否带有参数
21 | // 使用正则匹配,主要依据是判断是否有"/","?","="等,如“/page/index/index?name=mary"
22 | // 如果有url中有get参数,转换后无需带上"?"
23 | let query = '';
24 | if (/.*\/.*\?.*=.*/.test(config.url)) {
25 | // object对象转为get类型的参数
26 | query = queryParams(config.params, false);
27 | // 因为已有get参数,所以后面拼接的参数需要带上"&"隔开
28 | config.url += "&" + query;
29 | } else {
30 | query = queryParams(config.params);
31 | config.url += query;
32 | }
33 | }
34 | // 简写形式,把url和参数拼接起来
35 | if (typeof options === 'string' && typeof params == 'object') {
36 | let query = '';
37 | if (/.*\/.*\?.*=.*/.test(options)) {
38 | // object对象转为get类型的参数
39 | query = queryParams(params, false);
40 | // 因为已有get参数,所以后面拼接的参数需要带上"&"隔开
41 | options += "&" + query;
42 | } else {
43 | query = queryParams(params);
44 | options += query;
45 | }
46 | }
47 | // 判断是否一个字符串,如果是,直接跳转(简写法)
48 | // 如果是中情形,默认第二个参数为对象形式的参数
49 | if (typeof options === 'string') {
50 | if (options[0] != '/') options = '/' + options;
51 | return uni.navigateTo({
52 | url: options
53 | });
54 | }
55 | // navigateTo类型的跳转
56 | if (config.type == 'navigateTo' || config.type == 'to') {
57 | return uni.navigateTo({
58 | url: config.url,
59 | animationType: config.animationType,
60 | animationDuration: config.animationDuration,
61 | });
62 | }
63 | if (config.type == 'redirectTo' || config.type == 'redirect') {
64 | return uni.redirectTo({
65 | url: config.url,
66 | });
67 | }
68 | if (config.type == 'switchTab' || config.type == 'tab') {
69 | return uni.switchTab({
70 | url: config.url,
71 | });
72 | }
73 | if (config.type == 'reLaunch') {
74 | return uni.reLaunch({
75 | url: config.url
76 | });
77 | }
78 | if (config.type == 'navigateBack' || config.type == 'back') {
79 | return uni.navigateBack({
80 | delta: parseInt(config.delta ? config.delta : this.delta)
81 | });
82 | }
83 | }
84 |
85 | export default route;
86 |
--------------------------------------------------------------------------------
/uview-ui/libs/function/sys.js:
--------------------------------------------------------------------------------
1 | export function os() {
2 | return uni.getSystemInfoSync().platform;
3 | };
4 |
5 | export function sys() {
6 | return uni.getSystemInfoSync();
7 | }
8 |
9 |
10 |
--------------------------------------------------------------------------------
/uview-ui/libs/function/test.js:
--------------------------------------------------------------------------------
1 | /**
2 | * 验证电子邮箱格式
3 | */
4 | function email(value) {
5 | return /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/.test(value);
6 | }
7 |
8 | /**
9 | * 验证手机格式
10 | */
11 | function mobile(value) {
12 | return /^1[23456789]\d{9}$/.test(value)
13 | }
14 |
15 | /**
16 | * 验证URL格式
17 | */
18 | function url(value) {
19 | return /^((https|http|ftp|rtsp|mms):\/\/)(([0-9a-zA-Z_!~*'().&=+$%-]+: )?[0-9a-zA-Z_!~*'().&=+$%-]+@)?(([0-9]{1,3}.){3}[0-9]{1,3}|([0-9a-zA-Z_!~*'()-]+.)*([0-9a-zA-Z][0-9a-zA-Z-]{0,61})?[0-9a-zA-Z].[a-zA-Z]{2,6})(:[0-9]{1,4})?((\/?)|(\/[0-9a-zA-Z_!~*'().;?:@&=+$,%#-]+)+\/?)$/
20 | .test(value)
21 | }
22 |
23 | /**
24 | * 验证日期格式
25 | */
26 | function date(value) {
27 | return !/Invalid|NaN/.test(new Date(value).toString())
28 | }
29 |
30 | /**
31 | * 验证ISO类型的日期格式
32 | */
33 | function dateISO(value) {
34 | return /^\d{4}[\/\-](0?[1-9]|1[012])[\/\-](0?[1-9]|[12][0-9]|3[01])$/.test(value)
35 | }
36 |
37 | /**
38 | * 验证十进制数字
39 | */
40 | function number(value) {
41 | return /^(?:-?\d+|-?\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/.test(value)
42 | }
43 |
44 | /**
45 | * 验证整数
46 | */
47 | function digits(value) {
48 | return /^\d+$/.test(value)
49 | }
50 |
51 | /**
52 | * 验证身份证号码
53 | */
54 | function idCard(value) {
55 | return /^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}([0-9]|X)$/.test(
56 | value)
57 | }
58 |
59 | /**
60 | * 是否车牌号
61 | */
62 | function carNo(value) {
63 | // 新能源车牌
64 | const xreg = /^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}(([0-9]{5}[DF]$)|([DF][A-HJ-NP-Z0-9][0-9]{4}$))/;
65 | // 旧车牌
66 | const creg = /^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}[A-HJ-NP-Z0-9]{4}[A-HJ-NP-Z0-9挂学警港澳]{1}$/;
67 | if (value.length === 7) {
68 | return creg.test(value);
69 | } else if (value.length === 8) {
70 | return xreg.test(value);
71 | } else {
72 | return false;
73 | }
74 | }
75 |
76 | /**
77 | * 金额,只允许2位小数
78 | */
79 | function amount(value) {
80 | //金额,只允许保留两位小数
81 | return /^[1-9]\d*(,\d{3})*(\.\d{1,2})?$|^0\.\d{1,2}$/.test(value);
82 | }
83 |
84 | /**
85 | * 中文
86 | */
87 | function chinese(value) {
88 | let reg = /^[\u4e00-\u9fa5]+$/gi;
89 | return reg.test(value);
90 | }
91 |
92 | /**
93 | * 只能输入字母
94 | */
95 | function letter(value) {
96 | return /^[a-zA-Z]*$/.test(value);
97 | }
98 |
99 | /**
100 | * 只能是字母或者数字
101 | */
102 | function enOrNum(value) {
103 | //英文或者数字
104 | let reg = /^[0-9a-zA-Z]*$/g;
105 | return reg.test(value);
106 | }
107 |
108 | /**
109 | * 验证是否包含某个值
110 | */
111 | function contains(value, param) {
112 | return value.indexOf(param) >= 0
113 | }
114 |
115 | /**
116 | * 验证一个值范围[min, max]
117 | */
118 | function range(value, param) {
119 | return value >= param[0] && value <= param[1]
120 | }
121 |
122 | /**
123 | * 验证一个长度范围[min, max]
124 | */
125 | function rangeLength(value, param) {
126 | return value.length >= param[0] && value.length <= param[1]
127 | }
128 |
129 | /**
130 | * 是否固定电话
131 | */
132 | function landline(value) {
133 | let reg = /^\d{3,4}-\d{7,8}(-\d{3,4})?$/;
134 | return reg.test(value);
135 | }
136 |
137 | /**
138 | * 判断是否为空
139 | */
140 | function empty(value) {
141 | switch (typeof value) {
142 | case 'undefined':
143 | return true;
144 | case 'string':
145 | if (value.replace(/(^[ \t\n\r]*)|([ \t\n\r]*$)/g, '').length == 0) return true;
146 | break;
147 | case 'boolean':
148 | if (!value) return true;
149 | break;
150 | case 'number':
151 | if (0 === value || isNaN(value)) return true;
152 | break;
153 | case 'object':
154 | if (null === value || value.length === 0) return true;
155 | for (var i in value) {
156 | return false;
157 | }
158 | return true;
159 | }
160 | return false;
161 | }
162 |
163 | /**
164 | * 是否json字符串
165 | */
166 | function jsonString(value) {
167 | if (typeof value == 'string') {
168 | try {
169 | var obj = JSON.parse(value);
170 | if (typeof obj == 'object' && obj) {
171 | return true;
172 | } else {
173 | return false;
174 | }
175 | } catch (e) {
176 | return false;
177 | }
178 | }
179 | return false;
180 | }
181 |
182 |
183 | /**
184 | * 是否数组
185 | */
186 | function array(value) {
187 | if (typeof Array.isArray === "function") {
188 | return Array.isArray(value);
189 | } else {
190 | return Object.prototype.toString.call(value) === "[object Array]";
191 | }
192 | }
193 |
194 | /**
195 | * 是否对象
196 | */
197 | function object(value) {
198 | return Object.prototype.toString.call(value) === '[object Object]';
199 | }
200 |
201 | /**
202 | * 是否短信验证码
203 | */
204 | function code(value, len = 6) {
205 | return new RegExp(`^\\d{${len}}$`).test(value);
206 | }
207 |
208 |
209 | export default {
210 | email,
211 | mobile,
212 | url,
213 | date,
214 | dateISO,
215 | number,
216 | digits,
217 | idCard,
218 | carNo,
219 | amount,
220 | chinese,
221 | letter,
222 | enOrNum,
223 | contains,
224 | range,
225 | rangeLength,
226 | empty,
227 | isEmpty: empty,
228 | jsonString,
229 | landline,
230 | object,
231 | array,
232 | code
233 | }
234 |
--------------------------------------------------------------------------------
/uview-ui/libs/function/throttle.js:
--------------------------------------------------------------------------------
1 | let timer, flag;
2 | /**
3 | * 节流原理:在一定时间内,只能触发一次
4 | *
5 | * @param {Function} func 要执行的回调函数
6 | * @param {Number} wait 延时的时间
7 | * @param {Boolean} immediate 是否立即执行
8 | * @return null
9 | */
10 | function throttle(func, wait = 500, immediate = true) {
11 | if (immediate) {
12 | if (!flag) {
13 | flag = true;
14 | // 如果是立即执行,则在wait毫秒内开始时执行
15 | typeof func === 'function' && func();
16 | timer = setTimeout(() => {
17 | flag = false;
18 | }, wait);
19 | }
20 | } else {
21 | if (!flag) {
22 | flag = true
23 | // 如果是非立即执行,则在wait毫秒内的结束处执行
24 | timer = setTimeout(() => {
25 | flag = false
26 | typeof func === 'function' && func();
27 | }, wait);
28 | }
29 |
30 | }
31 | };
32 | export default throttle
33 |
--------------------------------------------------------------------------------
/uview-ui/libs/function/timeFormat.js:
--------------------------------------------------------------------------------
1 | // padStart 的 polyfill,因为某些机型或情况,还无法支持es7的padStart,比如电脑版的微信小程序
2 | // 所以这里做一个兼容polyfill的兼容处理
3 | if (!String.prototype.padStart) {
4 | // 为了方便表示这里 fillString 用了ES6 的默认参数,不影响理解
5 | String.prototype.padStart = function(maxLength, fillString = ' ') {
6 | if (Object.prototype.toString.call(fillString) !== "[object String]") throw new TypeError(
7 | 'fillString must be String')
8 | let str = this
9 | // 返回 String(str) 这里是为了使返回的值是字符串字面量,在控制台中更符合直觉
10 | if (str.length >= maxLength) return String(str)
11 |
12 | let fillLength = maxLength - str.length,
13 | times = Math.ceil(fillLength / fillString.length)
14 | while (times >>= 1) {
15 | fillString += fillString
16 | if (times === 1) {
17 | fillString += fillString
18 | }
19 | }
20 | return fillString.slice(0, fillLength) + str;
21 | }
22 | }
23 |
24 | function timeFormat(timestamp = null, fmt = 'yyyy-mm-dd') {
25 | // 其他更多是格式化有如下:
26 | // yyyy:mm:dd|yyyy:mm|yyyy年mm月dd日|yyyy年mm月dd日 hh时MM分等,可自定义组合
27 | timestamp = parseInt(timestamp);
28 | // 如果为null,则格式化当前时间
29 | if (!timestamp) timestamp = Number(new Date());
30 | // 判断用户输入的时间戳是秒还是毫秒,一般前端js获取的时间戳是毫秒(13位),后端传过来的为秒(10位)
31 | if (timestamp.toString().length == 10) timestamp *= 1000;
32 | let date = new Date(timestamp);
33 | let ret;
34 | let opt = {
35 | "y+": date.getFullYear().toString(), // 年
36 | "m+": (date.getMonth() + 1).toString(), // 月
37 | "d+": date.getDate().toString(), // 日
38 | "h+": date.getHours().toString(), // 时
39 | "M+": date.getMinutes().toString(), // 分
40 | "s+": date.getSeconds().toString() // 秒
41 | // 有其他格式化字符需求可以继续添加,必须转化成字符串
42 | };
43 | for (let k in opt) {
44 | ret = new RegExp("(" + k + ")").exec(fmt);
45 | if (ret) {
46 | fmt = fmt.replace(ret[1], (ret[1].length == 1) ? (opt[k]) : (opt[k].padStart(ret[1].length, "0")))
47 | };
48 | };
49 | return fmt;
50 | }
51 |
52 | export default timeFormat
53 |
--------------------------------------------------------------------------------
/uview-ui/libs/function/timeFrom.js:
--------------------------------------------------------------------------------
1 | import timeFormat from '../../libs/function/timeFormat.js';
2 |
3 | /**
4 | * 时间戳转为多久之前
5 | * @param String timestamp 时间戳
6 | * @param String | Boolean format 如果为时间格式字符串,超出一定时间范围,返回固定的时间格式;
7 | * 如果为布尔值false,无论什么时间,都返回多久以前的格式
8 | */
9 | function timeFrom(timestamp = null, format = 'yyyy-mm-dd') {
10 | if (timestamp == null) timestamp = Number(new Date());
11 | timestamp = parseInt(timestamp);
12 | // 判断用户输入的时间戳是秒还是毫秒,一般前端js获取的时间戳是毫秒(13位),后端传过来的为秒(10位)
13 | if (timestamp.toString().length == 10) timestamp *= 1000;
14 | var timer = (new Date()).getTime() - timestamp;
15 | timer = parseInt(timer / 1000);
16 | // 如果小于5分钟,则返回"刚刚",其他以此类推
17 | let tips = '';
18 | switch (true) {
19 | case timer < 300:
20 | tips = '刚刚';
21 | break;
22 | case timer >= 300 && timer < 3600:
23 | tips = parseInt(timer / 60) + '分钟前';
24 | break;
25 | case timer >= 3600 && timer < 86400:
26 | tips = parseInt(timer / 3600) + '小时前';
27 | break;
28 | case timer >= 86400 && timer < 2592000:
29 | tips = parseInt(timer / 86400) + '天前';
30 | break;
31 | default:
32 | // 如果format为false,则无论什么时间戳,都显示xx之前
33 | if(format === false) {
34 | if(timer >= 2592000 && timer < 365 * 86400) {
35 | tips = parseInt(timer / (86400 * 30)) + '个月前';
36 | } else {
37 | tips = parseInt(timer / (86400 * 365)) + '年前';
38 | }
39 | } else {
40 | tips = timeFormat(timestamp, format);
41 | }
42 | }
43 | return tips;
44 | }
45 |
46 | export default timeFrom;
47 |
--------------------------------------------------------------------------------
/uview-ui/libs/function/toast.js:
--------------------------------------------------------------------------------
1 | function toast(title, duration = 1500) {
2 | uni.showToast({
3 | title: title,
4 | icon: 'none',
5 | duration: duration
6 | })
7 | }
8 |
9 | export default toast
10 |
--------------------------------------------------------------------------------
/uview-ui/libs/function/trim.js:
--------------------------------------------------------------------------------
1 | function trim(str, pos = 'both') {
2 | if (pos == 'both') {
3 | return str.replace(/^\s+|\s+$/g, "");
4 | } else if (pos == "left") {
5 | return str.replace(/^\s*/, '');
6 | } else if (pos == 'right') {
7 | return str.replace(/(\s*$)/g, "");
8 | } else if (pos == 'all') {
9 | return str.replace(/\s+/g, "");
10 | } else {
11 | return str;
12 | }
13 | }
14 |
15 | export default trim
16 |
--------------------------------------------------------------------------------
/uview-ui/libs/function/type2icon.js:
--------------------------------------------------------------------------------
1 | /**
2 | * 根据主题type值,获取对应的图标
3 | * @param String type 主题名称,primary|info|error|warning|success
4 | * @param String fill 是否使用fill填充实体的图标
5 | */
6 | function type2icon(type = 'success', fill = false) {
7 | // 如果非预置值,默认为success
8 | if (['primary', 'info', 'error', 'warning', 'success'].indexOf(type) == -1) type = 'success';
9 | let iconName = '';
10 | // 目前(2019-12-12),info和primary使用同一个图标
11 | switch (type) {
12 | case 'primary':
13 | iconName = 'info-circle';
14 | break;
15 | case 'info':
16 | iconName = 'info-circle';
17 | break;
18 | case 'error':
19 | iconName = 'close-circle';
20 | break;
21 | case 'warning':
22 | iconName = 'error-circle';
23 | break;
24 | case 'success':
25 | iconName = 'checkmark-circle';
26 | break;
27 | default:
28 | iconName = 'checkmark-circle';
29 | }
30 | // 是否是实体类型,加上-fill,在icon组件库中,实体的类名是后面加-fill的
31 | if (fill) iconName += '-fill';
32 | return iconName;
33 | }
34 |
35 | export default type2icon
36 |
--------------------------------------------------------------------------------
/uview-ui/libs/mixin/mixin.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | data() {
3 | return {}
4 | },
5 | onLoad() {
6 | // getRect挂载到$u上,因为这方法需要使用in(this),所以无法把它独立成一个单独的文件导出
7 | this.$u.getRect = this.$uGetRect
8 | },
9 | methods: {
10 | // 查询节点信息
11 | // 目前此方法在支付宝小程序中无法获取组件跟接点的尺寸,为支付宝的bug(2020-07-21)
12 | // 解决办法为在组件根部再套一个没有任何作用的view元素
13 | $uGetRect(selector, all) {
14 | return new Promise(resolve => {
15 | uni.createSelectorQuery().
16 | in(this)[all ? 'selectAll' : 'select'](selector)
17 | .boundingClientRect(rect => {
18 | if (all && Array.isArray(rect) && rect.length) {
19 | resolve(rect)
20 | }
21 | if (!all && rect) {
22 | resolve(rect)
23 | }
24 | })
25 | .exec()
26 | })
27 | }
28 | },
29 | onReachBottom() {
30 | uni.$emit('uOnReachBottom')
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/uview-ui/libs/mixin/mpShare.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | onLoad() {
3 | // 设置默认的转发参数
4 | this.$u.mpShare = {
5 | title: '', // 默认为小程序名称
6 | path: '', // 默认为当前页面路径
7 | imageUrl: '' // 默认为当前页面的截图
8 | }
9 | },
10 | onShareAppMessage() {
11 | return this.$u.mpShare
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/uview-ui/libs/request/index.js:
--------------------------------------------------------------------------------
1 | import deepMerge from "../function/deepMerge";
2 | import validate from "../function/test";
3 | class Request {
4 | // 设置全局默认配置
5 | setConfig(customConfig) {
6 | // 深度合并对象,否则会造成对象深层属性丢失
7 | this.config = deepMerge(this.config, customConfig);
8 | }
9 |
10 | // 主要请求部分
11 | request(options = {}) {
12 | // 检查请求拦截
13 | if (this.interceptor.request && typeof this.interceptor.request === 'function') {
14 | let tmpConfig = {};
15 | let interceptorRequest = this.interceptor.request(options);
16 | if (interceptorRequest === false) {
17 | // 返回一个处于pending状态中的Promise,来取消原promise,避免进入then()回调
18 | return new Promise(()=>{});
19 | }
20 | this.options = interceptorRequest;
21 | }
22 | options.dataType = options.dataType || this.config.dataType;
23 | options.responseType = options.responseType || this.config.responseType;
24 | options.url = options.url || '';
25 | options.params = options.params || {};
26 | options.header = Object.assign(this.config.header, options.header);
27 | options.method = options.method || this.config.method;
28 |
29 | return new Promise((resolve, reject) => {
30 | options.complete = (response) => {
31 | // 请求返回后,隐藏loading(如果请求返回快的话,可能会没有loading)
32 | uni.hideLoading();
33 | // 清除定时器,如果请求回来了,就无需loading
34 | clearTimeout(this.config.timer);
35 | this.config.timer = null;
36 | // 判断用户对拦截返回数据的要求,如果originalData为true,返回所有的数据(response)到拦截器,否则只返回response.data
37 | if(this.config.originalData) {
38 | // 判断是否存在拦截器
39 | if (this.interceptor.response && typeof this.interceptor.response === 'function') {
40 | let resInterceptors = this.interceptor.response(response);
41 | // 如果拦截器不返回false,就将拦截器返回的内容给this.$u.post的then回调
42 | if (resInterceptors !== false) {
43 | resolve(resInterceptors);
44 | } else {
45 | // 如果拦截器返回false,意味着拦截器定义者认为返回有问题,直接接入catch回调
46 | reject(response);
47 | }
48 | } else {
49 | // 如果要求返回原始数据,就算没有拦截器,也返回最原始的数据
50 | resolve(response);
51 | }
52 | } else {
53 | if (response.statusCode == 200) {
54 | if (this.interceptor.response && typeof this.interceptor.response === 'function') {
55 | let resInterceptors = this.interceptor.response(response.data);
56 | if (resInterceptors !== false) {
57 | resolve(resInterceptors);
58 | } else {
59 | reject(response.data);
60 | }
61 | } else {
62 | // 如果不是返回原始数据(originalData=false),且没有拦截器的情况下,返回纯数据给then回调
63 | resolve(response.data);
64 | }
65 | } else {
66 | // 不返回原始数据的情况下,服务器状态码不为200,modal弹框提示
67 | // if(response.errMsg) {
68 | // uni.showModal({
69 | // title: response.errMsg
70 | // });
71 | // }
72 | reject(response)
73 | }
74 | }
75 | }
76 |
77 | // 判断用户传递的URL是否/开头,如果不是,加上/,这里使用了uView的test.js验证库的url()方法
78 | options.url = validate.url(options.url) ? options.url : (this.config.baseUrl + (options.url.indexOf('/') == 0 ?
79 | options.url : '/' + options.url));
80 |
81 | // 是否显示loading
82 | // 加一个是否已有timer定时器的判断,否则有两个同时请求的时候,后者会清除前者的定时器id
83 | // 而没有清除前者的定时器,导致前者超时,一直显示loading
84 | if(this.config.showLoading && !this.config.timer) {
85 | this.config.timer = setTimeout(() => {
86 | uni.showLoading({
87 | title: this.config.loadingText,
88 | mask: this.config.loadingMask
89 | })
90 | this.config.timer = null;
91 | }, this.config.loadingTime);
92 | }
93 | uni.request(options);
94 | })
95 | // .catch(res => {
96 | // // 如果返回reject(),不让其进入this.$u.post().then().catch()后面的catct()
97 | // // 因为很多人都会忘了写后面的catch(),导致报错捕获不到catch
98 | // return new Promise(()=>{});
99 | // })
100 | }
101 |
102 | constructor() {
103 | this.config = {
104 | baseUrl: '', // 请求的根域名
105 | // 默认的请求头
106 | header: {},
107 | method: 'POST',
108 | // 设置为json,返回后uni.request会对数据进行一次JSON.parse
109 | dataType: 'json',
110 | // 此参数无需处理,因为5+和支付宝小程序不支持,默认为text即可
111 | responseType: 'text',
112 | showLoading: true, // 是否显示请求中的loading
113 | loadingText: '请求中...',
114 | loadingTime: 800, // 在此时间内,请求还没回来的话,就显示加载中动画,单位ms
115 | timer: null, // 定时器
116 | originalData: false, // 是否在拦截器中返回服务端的原始数据,见文档说明
117 | loadingMask: true, // 展示loading的时候,是否给一个透明的蒙层,防止触摸穿透
118 | }
119 |
120 | // 拦截器
121 | this.interceptor = {
122 | // 请求前的拦截
123 | request: null,
124 | // 请求后的拦截
125 | response: null
126 | }
127 |
128 | // get请求
129 | this.get = (url, data = {}, header = {}) => {
130 | return this.request({
131 | method: 'GET',
132 | url,
133 | header,
134 | data
135 | })
136 | }
137 |
138 | // post请求
139 | this.post = (url, data = {}, header = {}) => {
140 | return this.request({
141 | url,
142 | method: 'POST',
143 | header,
144 | data
145 | })
146 | }
147 |
148 | // put请求,不支持支付宝小程序(HX2.6.15)
149 | this.put = (url, data = {}, header = {}) => {
150 | return this.request({
151 | url,
152 | method: 'PUT',
153 | header,
154 | data
155 | })
156 | }
157 |
158 | // delete请求,不支持支付宝和头条小程序(HX2.6.15)
159 | this.delete = (url, data = {}, header = {}) => {
160 | return this.request({
161 | url,
162 | method: 'DELETE',
163 | header,
164 | data
165 | })
166 | }
167 | }
168 | }
169 | export default new Request
170 |
--------------------------------------------------------------------------------
/uview-ui/libs/store/index.js:
--------------------------------------------------------------------------------
1 | // 暂时不用vuex模块方式实现,将该方法直接放入到/store/index.js中
2 | const module = {
3 | actions: {
4 | $uStore({rootState}, params) {
5 | let nameArr = params.name.split('.');
6 | if(nameArr.length >= 2) {
7 | let obj = rootState[nameArr[0]];
8 | for(let i = 1; i < nameArr.length - 1; i ++) {
9 | obj = obj[nameArr[i]];
10 | }
11 | obj[nameArr[nameArr.length - 1]] = params.value;
12 | } else {
13 | rootState[params.name] = params.value;
14 | }
15 | }
16 | }
17 | }
18 |
19 | export default module
--------------------------------------------------------------------------------
/uview-ui/libs/util/emitter.js:
--------------------------------------------------------------------------------
1 | /**
2 | * 递归使用 call 方式this指向
3 | * @param componentName // 需要找的组件的名称
4 | * @param eventName // 事件名称
5 | * @param params // 需要传递的参数
6 | */
7 | function broadcast(componentName, eventName, params) {
8 | // 循环子节点找到名称一样的子节点 否则 递归 当前子节点
9 | this.$children.map(child=>{
10 | if (componentName===child.$options.name) {
11 | child.$emit.apply(child,[eventName].concat(params))
12 | }else {
13 | broadcast.apply(child,[componentName,eventName].concat(params))
14 | }
15 | })
16 | }
17 | export default {
18 | methods: {
19 | /**
20 | * 派发 (向上查找) (一个)
21 | * @param componentName // 需要找的组件的名称
22 | * @param eventName // 事件名称
23 | * @param params // 需要传递的参数
24 | */
25 | dispatch(componentName, eventName, params) {
26 | let parent = this.$parent || this.$root;//$parent 找到最近的父节点 $root 根节点
27 | let name = parent.$options.name; // 获取当前组件实例的name
28 | // 如果当前有节点 && 当前没名称 且 当前名称等于需要传进来的名称的时候就去查找当前的节点
29 | // 循环出当前名称的一样的组件实例
30 | while (parent && (!name||name!==componentName)) {
31 | parent = parent.$parent;
32 | if (parent) {
33 | name = parent.$options.name;
34 | }
35 | }
36 | // 有节点表示当前找到了name一样的实例
37 | if (parent) {
38 | parent.$emit.apply(parent,[eventName].concat(params))
39 | }
40 | },
41 | /**
42 | * 广播 (向下查找) (广播多个)
43 | * @param componentName // 需要找的组件的名称
44 | * @param eventName // 事件名称
45 | * @param params // 需要传递的参数
46 | */
47 | broadcast(componentName, eventName, params) {
48 | broadcast.call(this,componentName, eventName, params)
49 | }
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/uview-ui/libs/util/province.js:
--------------------------------------------------------------------------------
1 | var provinceData=[{"label":"北京市","value":"11"},{"label":"天津市","value":"12"},{"label":"河北省","value":"13"},{"label":"山西省","value":"14"},{"label":"内蒙古自治区","value":"15"},{"label":"辽宁省","value":"21"},{"label":"吉林省","value":"22"},{"label":"黑龙江省","value":"23"},{"label":"上海市","value":"31"},{"label":"江苏省","value":"32"},{"label":"浙江省","value":"33"},{"label":"安徽省","value":"34"},{"label":"福建省","value":"35"},{"label":"江西省","value":"36"},{"label":"山东省","value":"37"},{"label":"河南省","value":"41"},{"label":"湖北省","value":"42"},{"label":"湖南省","value":"43"},{"label":"广东省","value":"44"},{"label":"广西壮族自治区","value":"45"},{"label":"海南省","value":"46"},{"label":"重庆市","value":"50"},{"label":"四川省","value":"51"},{"label":"贵州省","value":"52"},{"label":"云南省","value":"53"},{"label":"西藏自治区","value":"54"},{"label":"陕西省","value":"61"},{"label":"甘肃省","value":"62"},{"label":"青海省","value":"63"},{"label":"宁夏回族自治区","value":"64"},{"label":"新疆维吾尔自治区","value":"65"},{"label":"台湾","value":"66"},{"label":"香港","value":"67"},{"label":"澳门","value":"68"}];export default provinceData;
--------------------------------------------------------------------------------
/uview-ui/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "_from": "uview-ui@^1.6.8",
3 | "_id": "uview-ui@1.6.8",
4 | "_inBundle": false,
5 | "_integrity": "sha512-lFhClwUbZkLLYcrfcrdO/DPymh0/1C2yXrF7otpSLkCrRp9FShe0g6lH7KAxLTFx3C+V46hlWzTQB7XTz0CQgA==",
6 | "_location": "/uview-ui",
7 | "_phantomChildren": {},
8 | "_requested": {
9 | "type": "range",
10 | "registry": true,
11 | "raw": "uview-ui@^1.6.8",
12 | "name": "uview-ui",
13 | "escapedName": "uview-ui",
14 | "rawSpec": "^1.6.8",
15 | "saveSpec": null,
16 | "fetchSpec": "^1.6.8"
17 | },
18 | "_requiredBy": [
19 | "/"
20 | ],
21 | "_resolved": "https://registry.npmjs.org/uview-ui/-/uview-ui-1.6.8.tgz",
22 | "_shasum": "57efe4cdaba462a9b9e6db6200ebc19a1ecb55b5",
23 | "_spec": "uview-ui@^1.6.8",
24 | "_where": "C:\\Users\\12045\\Documents\\HBuilderProjects\\vue-mall-beautiful",
25 | "author": {
26 | "name": "uView"
27 | },
28 | "bundleDependencies": false,
29 | "deprecated": false,
30 | "description": "uView UI,是uni-app生态优秀的UI框架,全面的组件和便捷的工具会让您信手拈来,如鱼得水",
31 | "devDependencies": {
32 | "node-sass": "^4.14.0",
33 | "sass-loader": "^8.0.2"
34 | },
35 | "keywords": [
36 | "uview",
37 | "uView",
38 | "uni-app",
39 | "uni-app ui",
40 | "uniapp",
41 | "uviewui",
42 | "uview ui",
43 | "uviewUI",
44 | "uViewui",
45 | "uViewUI",
46 | "uView UI",
47 | "uni ui",
48 | "uni UI",
49 | "uniapp ui",
50 | "ui",
51 | "UI框架",
52 | "uniapp ui框架",
53 | "uniapp UI"
54 | ],
55 | "license": "MIT",
56 | "main": "index.js",
57 | "name": "uview-ui",
58 | "repository": {
59 | "type": "git",
60 | "url": ""
61 | },
62 | "scripts": {
63 | "test": "echo \"Error: no test specified\" && exit 1"
64 | },
65 | "version": "1.6.8"
66 | }
67 |
--------------------------------------------------------------------------------
/uview-ui/theme.scss:
--------------------------------------------------------------------------------
1 | // 此文件为uView的主题变量,这些变量目前只能通过uni.scss引入才有效,另外由于
2 | // uni.scss中引入的样式会同时混入到全局样式文件和单独每一个页面的样式中,造成微信程序包太大,
3 | // 故uni.scss只建议放scss变量名相关样式,其他的样式可以通过main.js或者App.vue引入
4 |
5 | $u-main-color: #303133;
6 | $u-content-color: #606266;
7 | $u-tips-color: #909399;
8 | $u-light-color: #c0c4cc;
9 | $u-border-color: #e4e7ed;
10 | $u-bg-color: #f3f4f6;
11 |
12 | $u-type-primary: #2979ff;
13 | $u-type-primary-light: #ecf5ff;
14 | $u-type-primary-disabled: #a0cfff;
15 | $u-type-primary-dark: #2b85e4;
16 |
17 | $u-type-warning: #ff9900;
18 | $u-type-warning-disabled: #fcbd71;
19 | $u-type-warning-dark: #f29100;
20 | $u-type-warning-light: #fdf6ec;
21 |
22 | $u-type-success: #19be6b;
23 | $u-type-success-disabled: #71d5a1;
24 | $u-type-success-dark: #18b566;
25 | $u-type-success-light: #dbf1e1;
26 |
27 | $u-type-error: #fa3534;
28 | $u-type-error-disabled: #fab6b6;
29 | $u-type-error-dark: #dd6161;
30 | $u-type-error-light: #fef0f0;
31 |
32 | $u-type-info: #909399;
33 | $u-type-info-disabled: #c8c9cc;
34 | $u-type-info-dark: #82848a;
35 | $u-type-info-light: #f4f4f5;
36 |
37 | $u-form-item-height: 70rpx;
38 | $u-form-item-border-color: #dcdfe6;
39 |
--------------------------------------------------------------------------------
/vue.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | // 配置路径别名
3 | configureWebpack: {
4 | devServer: {
5 | // 调试时允许内网穿透,让外网的人访问到本地调试的H5页面
6 | disableHostCheck: true
7 | }
8 | },
9 | //productionSourceMap: false,
10 | }
11 |
--------------------------------------------------------------------------------