Commit b443a0a4 authored by wlxuqu's avatar wlxuqu

重构cell组件

parent 5c9923ce
common/
components/
node_modules/
pages/
static/
store/
unpackage/
.gitignore
App.vue
LICENSE.txt
main.js
manifext.json
pages.json
vue.config.js
package-lock.json
.editorconfig
uni.scss
template.h5.html
...@@ -2,14 +2,14 @@ ...@@ -2,14 +2,14 @@
"easycom": { "easycom": {
"^u-(.*)": "@/uview/components/u-$1/u-$1.vue" "^u-(.*)": "@/uview/components/u-$1/u-$1.vue"
}, },
// "condition": { //模式配置,仅开发期间生效 "condition": { //模式配置,仅开发期间生效
// "current": 0, //当前激活的模式(list 的索引项) "current": 0, //当前激活的模式(list 的索引项)
// "list": [{ "list": [{
// "name": "test", //模式名称 "name": "test", //模式名称
// "path": "pages/componentsA/slider/index", //启动页面,必选 "path": "pages/componentsC/cell/index", //启动页面,必选
// "query": "id=1&name=2" //启动参数,在页面的-+onLoad函数里面得到 "query": "id=1&name=2" //启动参数,在页面的-+onLoad函数里面得到
// }] }]
// }, },
"pages": [ "pages": [
// 演示-组件 // 演示-组件
{ {
......
<template>
</template>
<script>
</script>
<style>
</style>
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
</u-upload> </u-upload>
<u-button :custom-style="{marginTop: '20rpx'}" @click="upload">上传</u-button> <u-button :custom-style="{marginTop: '20rpx'}" @click="upload">上传</u-button>
<u-button :custom-style="{marginTop: '40rpx'}" @click="clear">清空列表</u-button> <u-button :custom-style="{marginTop: '40rpx'}" @click="clear">清空列表</u-button>
<u-button :custom-style="{marginTop: '40rpx'}" @click="reUpload">重新上传</u-button> <!-- <u-button :custom-style="{marginTop: '40rpx'}" @click="reUpload">重新上传</u-button> -->
</view> </view>
</view> </view>
<view class="u-config-wrap"> <view class="u-config-wrap">
......
...@@ -4,13 +4,18 @@ ...@@ -4,13 +4,18 @@
<view class="u-demo-title">演示效果</view> <view class="u-demo-title">演示效果</view>
<view class="u-demo-area"> <view class="u-demo-area">
<u-cell-group title="读万卷书"> <u-cell-group title="读万卷书">
<u-cell-item index="index" @click="click" :hover="hover" :label="label" :arrow="arrow" :value="rightSlot == 'text' ? '蒹葭苍苍' : ''" :title="title"> <u-cell-item center :is-link="true" :label="label" value="铁马冰河入梦来" i
<u-icon slot="icon" size="34" :name="icon"></u-icon> ndex="index" @click="click" :hover-class="hoverClass"
<u-badge :absolute="false" v-if="rightSlot == 'badge'" count="105" slot="right"></u-badge> :arrow="arrow" :title="title"
<u-switch v-if="rightSlot == 'switch'" slot="right" v-model="checked"></u-switch> :icon="icon"
>
<u-badge :absolute="false" v-if="rightSlot == 'badge'" count="105" slot="right-icon"></u-badge>
<u-switch v-if="rightSlot == 'switch'" slot="right-icon" v-model="checked"></u-switch>
</u-cell-item> </u-cell-item>
<u-cell-item title="铁马冰河入梦来" value="行万里路"> <u-cell-item value="" title="铁马冰河入梦来" value="行万里路" :arrow="false">
<u-icon slot="icon" size="34" name="calendar"></u-icon> <u-icon slot="icon" size="34" name="calendar" style="margin-right: 5px;"></u-icon>
<u-icon slot="right-icon" size="34" name="calendar"></u-icon>
<u-field slot="value"></u-field>
</u-cell-item> </u-cell-item>
</u-cell-group> </u-cell-group>
</view> </view>
...@@ -56,9 +61,9 @@ export default { ...@@ -56,9 +61,9 @@ export default {
} }
}, },
computed: { computed: {
hover() { hoverClass() {
// 如果右侧是switch步进器组件的话,去掉cell的点击反馈,因为这个时候点击的反馈应该在switch上 // 如果右侧是switch步进器组件的话,去掉cell的点击反馈,因为这个时候点击的反馈应该在switch上
return this.rightSlot != 'switch'; return this.rightSlot == 'switch' ? 'none' : 'u-cell-hover';
} }
}, },
methods: { methods: {
...@@ -76,6 +81,8 @@ export default { ...@@ -76,6 +81,8 @@ export default {
}, },
rightSlotChange(index) { rightSlotChange(index) {
this.rightSlot = index == 0 ? 'text' : index == 1 ? 'switch' : 'badge' this.rightSlot = index == 0 ? 'text' : index == 1 ? 'switch' : 'badge'
if(index == 0) this.arrow = true;
else this.arrow = false;
}, },
click(index) { click(index) {
// console.log(index); // console.log(index);
......
<template> <template>
<view @tap="click" class="u-cell-item-box" :class="{'u-cell-border': itemIndex > 0 }" hover-stay-time="150" <view
:hover-class="hover ? 'u-hover-class' : ''" :style="{ @tap="click"
backgroundColor: bgColor class="u-cell"
}"> :class="{ 'u-cell-border': itemIndex > 0 && borderBottom, 'u-col-center': center, 'u-border-gap': borderGap, 'u-cell--required': required }"
<view class="u-cell-content"> hover-stay-time="150"
<view class="u-icon-wrap" v-if="icon"> :hover-class="hoverClass"
<u-icon size="32" :name="icon" class="u-icon"></u-icon> :style="{
</view> backgroundColor: bgColor
<view class="u-icon-wrap"> }"
<slot name="icon"></slot> >
</view> <u-icon :size="iconSize" :name="icon" v-if="icon" class="u-cell__left-icon-wrap"></u-icon>
<view class="u-cell-title" :style="[titleStyle]"> <view class="u-flex" v-else>
<text class="u-title-text" v-if="title">{{title}}</text> <slot name="icon"></slot>
<slot name="left"></slot> </view>
</view> <view
<view class="u-cell-value" v-if="value"> class="u-cell_title"
<text class="u-value-text" :style="[valueStyle]" v-if="value">{{value}}</text> :style="[
</view> {
<view v-else class="u-slot-wrap"> width: titleWidth ? titleWidth + 'rpx' : 'auto'
<slot name="right"></slot> },
</view> titleStyle
<view :style="[arrowStyle]" class="u-icon-wrap"> ]"
<u-icon v-if="arrow" size="26" class="u-arror-right" color="#969799" name="arrow-right"></u-icon> >
<block v-if="title">{{ title }}</block>
<slot name="title" v-else></slot>
<view class="u-cell__label" v-if="label || $slots.label" :style="[labelStyle]">
<block v-if="label">{{ label }}</block>
<slot name="label" v-else></slot>
</view> </view>
</view> </view>
<view class="u-cell-label" v-if="label" :style="[labelStyle]">
{{label}} <view class="u-cell__value" :style="[valueStyle]">
<block class="u-cell__value" v-if="value">{{ value }}</block>
<slot v-else></slot>
</view>
<u-icon v-if="arrow" name="arrow-right" :style="[arrowStyle]" class="u-icon-wrap u-cell__right-icon-wrap"></u-icon>
<view class="u-flex" v-else>
<slot name="right-icon"></slot>
</view> </view>
</view> </view>
</template> </template>
<script> <script>
/** /**
* cellItem 单元格Item * cellItem 单元格Item
* @description cell单元格一般用于一组列表的情况,比如个人中心页,设置页等。搭配u-cell-group使用 * @description cell单元格一般用于一组列表的情况,比如个人中心页,设置页等。搭配u-cell-group使用
* @tutorial https://www.uviewui.com/components/cell.html * @tutorial https://www.uviewui.com/components/cell.html
* @property {String} title 左侧标题 * @property {String} title 左侧标题
* @property {String} icon 左侧图标名,只支持uView内置图标,见Icon 图标 * @property {String} icon 左侧图标名,只支持uView内置图标,见Icon 图标
* @property {String} value 右侧内容 * @property {String} value 右侧内容
* @property {String} label 标题下方的描述信息 * @property {String} label 标题下方的描述信息
* @property {Boolean} border 是否显示每个cell的下边框(默认true) * @property {Boolean} border-bottom 是否显示每个cell的下边框(默认true)
* @property {Boolean} hover 是否开启点击反馈,hover-class形式,如果右侧通过slot传递switch进去的话,可以将此值设置为false(默认true) * @property {String} hover-class 是否开启点击反馈,none为无效果(默认true)
* @property {Boolean} arrow 是否显示右侧箭头(默认true) * @property {Boolean} border-gap border-bottom为true时,Cell列表中间的条目的下边框是否与左边有一个间隔(默认true)
* @property {Boolean} arrow-direction 箭头方向,可选值(默认right) * @property {Boolean} arrow 是否显示右侧箭头(默认true)
* @property {Object} title-style 标题样式,对象形式 * @property {Boolean} required 箭头方向,可选值(默认right)
* @property {Object} value-style 右侧内容样式,对象形式 * @property {Boolean} arrow-direction 是否显示左边表示必填的星号(默认false)
* @property {Object} label-style 标题下方描述信息的样式,对象形式 * @property {Object} title-style 标题样式,对象形式
* @property {String} bg-color 背景颜色(默认#ffffff) * @property {Object} value-style 右侧内容样式,对象形式
* @property {String Number} index 用于在click事件回调中返回,标识当前是第几个Item * @property {Object} label-style 标题下方描述信息的样式,对象形式
* @example <u-cell-item icon="integral-fill" title="会员等级" value="新版本"></u-cell-item> * @property {String} bg-color 背景颜色(默认transparent)
*/ * @property {String Number} index 用于在click事件回调中返回,标识当前是第几个Item
export default { * @property {String Number} title-width 标题的宽度,单位rpx
name: "u-cell-item", * @example <u-cell-item icon="integral-fill" title="会员等级" value="新版本"></u-cell-item>
props: { */
// 左侧图标名称(只能uView内置图标),或者图标src export default {
icon: { name: 'u-cell-item',
type: String, props: {
default: '' // 左侧图标名称(只能uView内置图标),或者图标src
}, icon: {
// 左侧标题 type: String,
title: { default: ''
type: String,
default: ''
},
// 右侧内容
value: {
type: String,
default: ''
},
// 标题下方的描述信息
label: {
type: String,
default: ''
},
// 是否显示内边框
border: {
type: Boolean,
default: true
},
// 是否开启点击反馈,即点击是cell背景为灰色
hover: {
type: Boolean,
default: true
},
// 是否显示右侧箭头
arrow: {
type: Boolean,
default: true
},
// 右侧箭头方向,可选值:right|up|down,默认为right
arrowDirection: {
type: String,
default: 'right'
},
// 控制标题的样式
titleStyle: {
type: Object,
default () {
return {};
}
},
// 右侧显示内容的样式
valueStyle: {
type: Object,
default () {
return {};
}
},
// 描述信息的样式
labelStyle: {
type: Object,
default () {
return {};
}
},
// 背景颜色
bgColor: {
type: String,
default: '#ffffff'
},
// 用于识别被点击的是第几个cell
index: {
type: [String, Number],
default: ''
}
}, },
inject: ['uCellGroup'], // 左侧标题
data() { title: {
return { type: String,
itemIndex: 0, default: ''
} },
// 右侧内容
value: {
type: String,
default: ''
},
// 标题下方的描述信息
label: {
type: String,
default: ''
},
// 是否显示内边框
borderBottom: {
type: Boolean,
default: true
},
// 多个cell中,中间的cell显示下划线时,下划线是否给一个到左边的距离
borderGap: {
type: Boolean,
default: true
},
// 是否开启点击反馈,即点击时cell背景为灰色,none为无效果
hoverClass: {
type: String,
default: 'u-cell-hover'
},
// 是否显示右侧箭头
arrow: {
type: Boolean,
default: true
},
// 内容是否垂直居中
center: {
type: Boolean,
default: false
},
// 是否显示左边表示必填的星号
required: {
type: Boolean,
default: false
},
// 标题的宽度,单位rpx
titleWidth: {
type: [Number, String],
default: ''
}, },
created() { // 右侧箭头方向,可选值:right|up|down,默认为right
this.itemIndex = this.uCellGroup.index++; arrowDirection: {
type: String,
default: 'right'
}, },
computed: { // 控制标题的样式
arrowStyle() { titleStyle: {
let style = {}; type: Object,
if (this.arrowDirection == 'top') style.transform = 'rotate(-90deg)'; default() {
else if (this.arrowDirection == 'bottom') style.transform = 'rotate(90deg)'; return {};
else style.transform = 'rotate(0deg)';
return style;
} }
}, },
methods: { // 右侧显示内容的样式
click() { valueStyle: {
this.$emit('click', this.index); type: Object,
default() {
return {};
} }
},
// 描述信息的样式
labelStyle: {
type: Object,
default() {
return {};
}
},
// 背景颜色
bgColor: {
type: String,
default: 'transparent'
},
// 用于识别被点击的是第几个cell
index: {
type: [String, Number],
default: ''
},
// 是否使用lable插槽
useLabelSlot: {
type: Boolean,
default: false
},
// 左边图标的大小,单位rpx,只对传入icon字段时有效
iconSize: {
type: [Number, String],
default: 34
}
},
inject: ['uCellGroup'],
data() {
return {
itemIndex: 0
};
},
created() {
this.itemIndex = this.uCellGroup.index++;
},
computed: {
arrowStyle() {
let style = {};
if (this.arrowDirection == 'up') style.transform = 'rotate(-90deg)';
else if (this.arrowDirection == 'down') style.transform = 'rotate(90deg)';
else style.transform = 'rotate(0deg)';
return style;
}
},
methods: {
click() {
this.$emit('click', this.index);
} }
} }
};
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.u-cell-item-box { .u-cell {
padding: 28rpx 32rpx; position: relative;
position: relative; display: flex;
} box-sizing: border-box;
width: 100%;
padding: 20rpx 32rpx;
font-size: 28rpx;
line-height: 48rpx;
color: $u-content-color;
background-color: #fff;
text-align: left;
}
.u-cell-border:after { .u-cell_title {
left: 32rpx !important; font-size: 28rpx;
position: absolute; }
box-sizing: border-box;
content: ' ';
pointer-events: none;
right: 0;
top: 0;
border-bottom: 1px solid $u-border-color;
-webkit-transform: scaleY(0.5);
transform: scaleY(0.5);
}
.u-cell-content { .u-cell__left-icon-wrap {
display: flex; margin-right: 10rpx;
align-items: center; font-size: 32rpx;
} }
.u-cell-title { .u-cell__right-icon-wrap {
color: #323233; margin-left: 10rpx;
font-size: 30rpx; color: #969799;
flex: 1; font-size: 28rpx;
margin-left: 6rpx; }
text-align: left;
}
.u-cell-value { .u-cell__left-icon-wrap,
flex: 1; .u-cell__right-icon-wrap {
font-size: 26rpx; display: flex;
color: #969799; align-items: center;
text-align: right; height: 48rpx;
} }
.u-cell-label { .u-cell-border:after {
color: #969799; position: absolute;
font-size: 26rpx; box-sizing: border-box;
margin-top: 10rpx; content: ' ';
text-align: left; pointer-events: none;
} right: 0;
left: 0;
top: 0;
border-bottom: 1px solid $u-border-color;
-webkit-transform: scaleY(0.5);
transform: scaleY(0.5);
}
.u-slot-wrap { .u-cell-border {
display: flex; position: relative;
align-items: center; }
}
// 微信小程序需要额外处理可能通过slot传入badge和switch的问题 .u-border-gap:after {
// 否则无法垂直居中 left: 32rpx !important;
/* #ifdef MP-WEIXIN */ }
.u-slot-wrap /deep/ u-badge,
.u-slot-wrap /deep/ u-switch {
display: flex;
align-items: center;
}
/* #endif */ .u-cell__label {
margin-top: 6rpx;
font-size: 26rpx;
line-height: 36rpx;
color: $u-tips-color;
}
.u-icon { .u-cell__value {
margin-right: 6rpx; overflow: hidden;
} text-align: right;
vertical-align: middle;
color: $u-tips-color;
font-size: 26rpx;
}
.u-value-text { .u-cell__title,
margin-right: 10rpx; .u-cell__value {
} flex: 1;
}
.u-title-text { .u-cell--required {
margin-right: 10rpx; overflow: visible;
} display: flex;
align-items: center;
}
.u-cell--required:before {
position: absolute;
content: '*';
left: 8px;
margin-top: 4rpx;
font-size: 14px;
color: $u-type-error;
}
</style> </style>
<template>
<view class="u-form-item">
<slot />
</view>
</template>
<script>
export default {
data() {
return {
}
},
methods: {
}
}
</script>
<style>
</style>
<template>
<view class="u-form">
<slot />
</view>
</template>
<script>
export default {
data() {
return {
}
},
methods: {
}
}
</script>
<style>
</style>
<template> <template>
<text class="uicon" :class="customClass" :style="{ <text class="uicon" :class="customClass" :style="[iconStyle]" @tap="click" :hover-class="hoverClass" @touchstart="touchstart"></text>
color: color,
fontSize: size + 'rpx',
fontWeight: bold ? 'bold' : 'normal',
}"
@tap="click" :hover-class="hoverClass" @touchstart="touchstart">
</text>
</template> </template>
<script> <script>
/** /**
* icon 图标 * icon 图标
* @description 基于字体的图标集,包含了大多数常见场景的图标。 * @description 基于字体的图标集,包含了大多数常见场景的图标。
* @tutorial https://www.uviewui.com/components/icon.html * @tutorial https://www.uviewui.com/components/icon.html
* @property {String} name 图标名称,见示例图标集 * @property {String} name 图标名称,见示例图标集
* @property {String} color 图标颜色(默认inherit) * @property {String} color 图标颜色(默认inherit)
* @property {String Number} size 图标字体大小,单位rpx(默认32) * @property {String Number} size 图标字体大小,单位rpx(默认32)
* @property {String} index 一个用于区分多个图标的值,点击图标时通过click事件传出 * @property {String} index 一个用于区分多个图标的值,点击图标时通过click事件传出
* @property {String} hover-class 图标按下去的样式类,用法同uni的view组件的hover-class参数,详情见官网 * @property {String} hover-class 图标按下去的样式类,用法同uni的view组件的hover-class参数,详情见官网
* @event {Function} click 点击图标时触发 * @event {Function} click 点击图标时触发
* @example <u-icon name="photo" color="#2979ff" size="28"></u-icon> * @example <u-icon name="photo" color="#2979ff" size="28"></u-icon>
*/ */
export default { export default {
name: "u-icon", name: 'u-icon',
props: { props: {
// 图标类名 // 图标类名
name: { name: {
type: String, type: String,
default: '' default: ''
},
// 图标颜色
color: {
type: String,
default: 'inherit'
},
// 字体大小,单位rpx
size: {
type: [Number, String],
default: 'inherit'
},
// 是否显示粗体
bold: {
type: Boolean,
default: false
},
// 点击图标的时候传递事件出去的index(用于区分点击了哪一个)
index: {
type: [Number, String],
default: ''
},
// 触摸图标时的类名
hoverClass: {
type: String,
default: ''
},
// 自定义扩展前缀,方便用户扩展自己的图标库
customPrefix: {
type: String,
default: 'uicon'
}
}, },
data() { // 图标颜色
return { color: {
type: String,
} default: ''
},
// 字体大小,单位rpx
size: {
type: [Number, String],
default: 'inherit'
},
// 是否显示粗体
bold: {
type: Boolean,
default: false
},
// 点击图标的时候传递事件出去的index(用于区分点击了哪一个)
index: {
type: [Number, String],
default: ''
}, },
computed: { // 触摸图标时的类名
customClass() { hoverClass: {
let classes = []; type: String,
classes.push(this.customPrefix + '-' + this.name); default: ''
// uView的自定义图标类名为u-iconfont
if (this.customPrefix == 'uicon') classes.push('u-iconfont');
else classes.push(this.customPrefix);
return classes;
}
}, },
methods: { // 自定义扩展前缀,方便用户扩展自己的图标库
click() { customPrefix: {
this.$emit('click', this.index); type: String,
}, default: 'uicon'
touchstart() { }
this.$emit('touchstart', this.index); },
} data() {
return {};
},
computed: {
customClass() {
let classes = [];
classes.push(this.customPrefix + '-' + this.name);
// uView的自定义图标类名为u-iconfont
if (this.customPrefix == 'uicon') classes.push('u-iconfont');
else classes.push(this.customPrefix);
return classes;
},
iconStyle() {
let style = {};
style = {
fontSize: this.size + 'rpx',
fontWeight: this.bold ? 'bold' : 'normal'
};
if(this.color) style.color = this.color;
return style;
}
},
methods: {
click() {
this.$emit('click', this.index);
},
touchstart() {
this.$emit('touchstart', this.index);
} }
} }
};
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
@import '../../../uview/iconfont.css'; @import '../../../uview/iconfont.css';
.uicon { .uicon {
display: inline-flex; display: inline-flex;
align-items: center; align-items: center;
} }
</style> </style>
...@@ -198,7 +198,7 @@ ...@@ -198,7 +198,7 @@
this.lists.push({url: value.url, error: false, progress: 100}); this.lists.push({url: value.url, error: false, progress: 100});
}) })
} }
} },
}, },
methods: { methods: {
// 清除列表 // 清除列表
...@@ -369,6 +369,14 @@ ...@@ -369,6 +369,14 @@
} }
}); });
}, },
// 用户通过ref手动的形式,移除一张图片
remove(index) {
// 判断索引的合法范围
if(index >= 0 && index < this.lists.length) {
this.lists.splice(index, 1);
this.$emit('on-list-change', this.lists);
}
},
// 预览图片 // 预览图片
doPreviewImage(url, index) { doPreviewImage(url, index) {
if (!this.previewFullImage) if (!this.previewFullImage)
......
This diff is collapsed.
...@@ -58,12 +58,16 @@ u-icon { ...@@ -58,12 +58,16 @@ u-icon {
} }
/* end-iPhoneX底部安全区定义--end */ /* end-iPhoneX底部安全区定义--end */
/* start--hover-class-start */ /* start--各种hover点击反馈相关的类名-start */
.u-hover-class { .u-hover-class {
// background-color: #f7f8f9!important; // background-color: #f7f8f9!important;
opacity: 0.6; opacity: 0.6;
} }
/* end--hover-class--end */
.u-cell-hover {
background-color: #f7f8f9!important;
}
/* end--各种hover点击反馈相关的类名--end */
/* start--文本行数限制--start */ /* start--文本行数限制--start */
.u-line-1 { .u-line-1 {
......
class Request { const Request = {
config = { config: {
baseUrl: '', // 请求的根域名 baseUrl: '', // 请求的根域名
// 默认的请求头 // 默认的请求头
header: { header: {
...@@ -16,28 +16,28 @@ class Request { ...@@ -16,28 +16,28 @@ class Request {
timer: null, // 定时器 timer: null, // 定时器
originalData: false, // 是否在拦截器中返回服务端的原始数据,见文档说明 originalData: false, // 是否在拦截器中返回服务端的原始数据,见文档说明
loadingMask: true, // 展示loading的时候,是否给一个透明的蒙层,防止触摸穿透 loadingMask: true, // 展示loading的时候,是否给一个透明的蒙层,防止触摸穿透
} },
// 判断是否http|https开头的URL // 判断是否http|https开头的URL
static isHttp(url) { isHttp: (url) => {
return /(http|https):\/\/([\w.]+\/?)\S*/.test(url) return /(http|https):\/\/([\w.]+\/?)\S*/.test(url)
} },
// 拦截器 // 拦截器
interceptor = { interceptor: {
// 请求前的拦截 // 请求前的拦截
request: null, request: null,
// 请求后的拦截 // 请求后的拦截
response: null response: null
} },
// 设置全局默认配置 // 设置全局默认配置
setConfig(customConfig) { setConfig: (customConfig) => {
this.config = Object.assign(this.config, customConfig); this.config = Object.assign(this.config, customConfig);
} },
// 主要请求部分 // 主要请求部分
async request(options = {}) { request: (options = {}) => {
// 检查请求拦截 // 检查请求拦截
if (this.interceptor.request && typeof this.interceptor.request === 'function') { if (this.interceptor.request && typeof this.interceptor.request === 'function') {
let tmpConfig = {}; let tmpConfig = {};
...@@ -119,41 +119,40 @@ class Request { ...@@ -119,41 +119,40 @@ class Request {
} }
uni.request(options); uni.request(options);
}) })
} },
constructor() {
// get请求 // get请求
this.get = (url, data = {}, header = {}) => { get: (url, data = {}, header = {}) => {
return this.request({ return this.request({
method: 'GET', method: 'GET',
url, url,
header, header,
data data
}) })
} },
// post请求 // post请求
this.post = (url, data = {}, header = {}) => { post: (url, data = {}, header = {}) => {
return this.request({ return this.request({
url, url,
method: 'POST', method: 'POST',
header, header,
data data
}) })
} },
// put请求,不支持支付宝小程序(HX2.6.15) // put请求,不支持支付宝小程序(HX2.6.15)
this.put = (url, data = {}, header = {}) => { put: (url, data = {}, header = {}) => {
return this.request({ return this.request({
url, url,
method: 'PUT', method: 'PUT',
header, header,
data data
}) })
} },
// delete请求,不支持支付宝和头条小程序(HX2.6.15) // delete请求,不支持支付宝和头条小程序(HX2.6.15)
this.delete = (url, data = {}, header = {}) => { delete: (url, data = {}, header = {}) => {
return this.request({ return this.request({
url, url,
method: 'DELETE', method: 'DELETE',
...@@ -161,6 +160,5 @@ class Request { ...@@ -161,6 +160,5 @@ class Request {
data data
}) })
} }
}
} }
export default new Request export default Request
{
"name": "uview",
"version": "1.1.6",
"description": "uView UI,是uni-app生态优秀的UI框架,全面的组件和便捷的工具会让您信手拈来,如鱼得水",
"main": "uview/index.js",
"keyword": ["uview", "uView", "uni-app", "uniapp", "uviewui", "uview ui", "uviewUI", "uViewui", "uViewUI", "uView UI", "uni ui", "uni UI", "uniapp ui", "ui", "UI框架", "uniapp ui框架", "uniapp UI"],
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": ""
},
"files": ["uview"],
"author": "uView",
"license": "MIT"
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment