Commit 733b41fc5522d31e945c6d00cb29b6841f3b91d9
1 parent
e6152cb2
feat: hide select list when only one type
Showing
4 changed files
with
10 additions
and
8 deletions
pages/index/index.js
| 1 | 1 | //index.js |
| 2 | 2 | //获取应用实例 |
| 3 | 3 | const app = getApp(); |
| 4 | -const selectedIndex = app.globalData.getSelectedTypeIndex(); | |
| 5 | 4 | const typeList = app.globalData.getTypeList(); |
| 5 | +const selectedIndex = typeList.length > 1 ? app.globalData.getSelectedTypeIndex() : 0; | |
| 6 | 6 | |
| 7 | 7 | let audio = null; |
| 8 | 8 | |
| ... | ... | @@ -11,7 +11,7 @@ Page({ |
| 11 | 11 | placeholder: '点击此处输入文字', |
| 12 | 12 | text: '', |
| 13 | 13 | typeList, |
| 14 | - selectedIndex: String(selectedIndex) ? selectedIndex : 5 | |
| 14 | + selectedIndex: String(selectedIndex) ? selectedIndex : 0 | |
| 15 | 15 | }, |
| 16 | 16 | onLoad(){ |
| 17 | 17 | wx.showShareMenu(); | ... | ... |
pages/index/index.wxml
| ... | ... | @@ -16,7 +16,7 @@ |
| 16 | 16 | <button bindtap="gotoAudioList" class="goto-audio-list" type="primary" size="mini"> 下载 </button> |
| 17 | 17 | <button bindtap="clear" class="button" type="default" size="mini"> 清空 </button> |
| 18 | 18 | </view> |
| 19 | - <view class="type-view"> | |
| 19 | + <view class="type-view" wx:if="{{typeList.length > 1}}"> | |
| 20 | 20 | <button |
| 21 | 21 | wx:for="{{typeList}}" |
| 22 | 22 | wx:key="desc" | ... | ... |
pages/index/index.wxss
| ... | ... | @@ -2,6 +2,7 @@ |
| 2 | 2 | |
| 3 | 3 | .text-view{ |
| 4 | 4 | width: 100%; |
| 5 | + margin-bottom: 20rpx; | |
| 5 | 6 | text-align: center; |
| 6 | 7 | } |
| 7 | 8 | .text-area{ |
| ... | ... | @@ -10,17 +11,19 @@ |
| 10 | 11 | text-align: left; |
| 11 | 12 | box-sizing: border-box; |
| 12 | 13 | display: inline-block; |
| 13 | - border: 1rpx dashed #afafaf; | |
| 14 | + border: 1px dashed #afafaf; | |
| 14 | 15 | } |
| 15 | 16 | |
| 16 | 17 | .button-view{ |
| 17 | 18 | width: 100%; |
| 18 | - margin-top: 20rpx; | |
| 19 | + margin-bottom: 40rpx; | |
| 19 | 20 | text-align: center; |
| 20 | 21 | } |
| 21 | 22 | .button-view button{ |
| 22 | 23 | width: 95%; |
| 23 | 24 | display: inline-block; |
| 25 | + vertical-align: top; | |
| 26 | + margin-bottom: 20rpx; | |
| 24 | 27 | height: 92rpx; |
| 25 | 28 | line-height: 92rpx; |
| 26 | 29 | font-size: 36rpx; |
| ... | ... | @@ -29,7 +32,6 @@ |
| 29 | 32 | |
| 30 | 33 | .type-view{ |
| 31 | 34 | width: 95%; |
| 32 | - margin-top: 40rpx; | |
| 33 | 35 | margin-bottom: 40rpx; |
| 34 | 36 | display: flex; |
| 35 | 37 | justify-content: space-between; |
| ... | ... | @@ -41,5 +43,5 @@ |
| 41 | 43 | letter-spacing: 15rpx; |
| 42 | 44 | } |
| 43 | 45 | .ad-1{ |
| 44 | - margin-bottom: 10px; | |
| 46 | + margin-bottom: 20rpx; | |
| 45 | 47 | } |
| 46 | 48 | \ No newline at end of file | ... | ... |