Skip to content

Commit

Permalink
fix(swan): 兼容 swan 百度小程序
Browse files Browse the repository at this point in the history
  • Loading branch information
SzHeJason committed Feb 11, 2019
1 parent 3ea48ef commit adb3f94
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 70 deletions.
1 change: 1 addition & 0 deletions .stylelintrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"extends": "stylelint-config-standard",
"plugins": ["stylelint-scss"],
"rules": {
"declaration-colon-newline-after": null,
"at-rule-no-unknown": null,
"color-hex-case": null,
"block-closing-brace-newline-after": null,
Expand Down
7 changes: 4 additions & 3 deletions src/common/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ function delayGetClientRect ({
selectorStr,
delayTime = 500
}): Promise<Array<execObject>> {
const $scope = ENV === Taro.ENV_TYPE.WEB ? self : self.$scope
const $scope =
ENV === Taro.ENV_TYPE.WEB || ENV === Taro.ENV_TYPE.SWAN ? self : self.$scope
const selector: SelectorQuery = Taro.createSelectorQuery().in($scope)

return new Promise(resolve => {
Expand Down Expand Up @@ -188,7 +189,7 @@ function initTestEnv () {
}
}

function isTest() {
function isTest () {
return process.env.NODE_ENV === 'test'
}

Expand All @@ -214,7 +215,7 @@ function handleTouchScroll (flag) {
}
}

function pxTransform(size) {
function pxTransform (size) {
if (!size) return ''
return Taro.pxTransform(size)
}
Expand Down
4 changes: 2 additions & 2 deletions src/components/toast/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,15 @@ export default class AtToast extends AtComponent {
{hasMask && <View className='at-toast__overlay' />}
<View className={bodyClass} onClick={this.handleClick}>
<View className='toast-body-content'>
{realImg && (
{realImg ? (
<View className='toast-body-content__img'>
<Image
className='toast-body-content__img-item'
src={realImg}
mode='scaleToFill'
/>
</View>
)}
) : null}
{isRenderIcon && (
<View className='toast-body-content__icon'>
<Text className={iconClass} />
Expand Down
95 changes: 34 additions & 61 deletions src/pages/action/toast/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,12 @@ export default class ToastPage extends Component {
this.state = INIT_STATE
}

handleClick = (text, icon, image, hasMask, status) => {
handleClick = params => {
if (this.state.isOpened) {
return this.setState(INIT_STATE)
}
const state = Object.assign(
{ ...INIT_STATE, isOpened: true },
{ text, icon, image, hasMask, status }
)

const state = Object.assign({ ...INIT_STATE, isOpened: true }, params)

this.setState(state)
}
Expand Down Expand Up @@ -66,28 +64,19 @@ export default class ToastPage extends Component {
<View className='panel__content'>
<View className='example-item'>
<AtButton
onClick={this.handleClick.bind(
this,
'文本内容',
'',
'',
false,
''
)}
onClick={this.handleClick.bind(this, {
text: '文本内容'
})}
>
文本 Toast
</AtButton>
</View>
<View className='example-item'>
<AtButton
onClick={this.handleClick.bind(
this,
'文本内容',
'analytics',
'',
false,
''
)}
onClick={this.handleClick.bind(this, {
text: '文本内容',
icon: 'analytics'
})}
>
文本 + ICON
</AtButton>
Expand All @@ -100,14 +89,11 @@ export default class ToastPage extends Component {
<View className='panel__content'>
<View className='example__item'>
<AtButton
onClick={this.handleClick.bind(
this,
'凹凸实验室',
'',
'http://storage.360buyimg.com/mtd/home/group-21533885306540.png',
false,
''
)}
onClick={this.handleClick.bind(this, {
text: '凹凸实验室',
image:
'http://storage.360buyimg.com/mtd/home/group-21533885306540.png'
})}
>
自定义图片 Toast
</AtButton>
Expand All @@ -120,14 +106,10 @@ export default class ToastPage extends Component {
<View className='panel__content'>
<View className='example__item'>
<AtButton
onClick={this.handleClick.bind(
this,
'透明遮罩层的作用在于不可点击下面的元素',
'',
'',
true,
''
)}
onClick={this.handleClick.bind(this, {
text: '透明遮罩层的作用在于不可点击下面的元素',
hasMask: true
})}
>
添加遮罩层 Toast
</AtButton>
Expand All @@ -140,14 +122,11 @@ export default class ToastPage extends Component {
<View className='panel__content'>
<View className='example__item'>
<AtButton
onClick={this.handleClick.bind(
this,
'错误提示',
'',
'',
true,
'error'
)}
onClick={this.handleClick.bind(this, {
text: '错误提示',
hasMask: true,
status: 'error'
})}
>
错误提示 Toast
</AtButton>
Expand All @@ -160,14 +139,11 @@ export default class ToastPage extends Component {
<View className='panel__content'>
<View className='example__item'>
<AtButton
onClick={this.handleClick.bind(
this,
'正确提示',
'',
'',
true,
'success'
)}
onClick={this.handleClick.bind(this, {
text: '正确提示',
hasMask: true,
status: 'success'
})}
>
正确提示 Toast
</AtButton>
Expand All @@ -180,14 +156,11 @@ export default class ToastPage extends Component {
<View className='panel__content'>
<View className='example__item'>
<AtButton
onClick={this.handleClick.bind(
this,
'正在加载…',
'',
'',
true,
'loading'
)}
onClick={this.handleClick.bind(this, {
text: '正在加载…',
hasMask: true,
status: 'loading'
})}
>
加载中 Toast
</AtButton>
Expand Down
12 changes: 8 additions & 4 deletions src/style/components/calendar.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@import '../mixins/index.scss';
@import '../variables/default.scss';
@import "../mixins/index.scss";
@import "../variables/default.scss";

.at-calendar {
overflow: hidden;
Expand Down Expand Up @@ -109,7 +109,10 @@
background-color: transparent;

.flex__item-container {
background-color: rgba($color: $at-calendar-main-color, $alpha: 0.7);
background-color: rgba(
$color: $at-calendar-main-color,
$alpha: 0.7
);
}
}
}
Expand Down Expand Up @@ -170,7 +173,8 @@
}
}

&--weapp {
&--weapp,
&--swan {
.main__body {
height: 480px;
}
Expand Down

0 comments on commit adb3f94

Please sign in to comment.