File tree Expand file tree Collapse file tree 8 files changed +59788
-0
lines changed Expand file tree Collapse file tree 8 files changed +59788
-0
lines changed Original file line number Diff line number Diff line change 11{
22 "pages" : [
33 " pages/index/index" ,
4+ " pages/kitchen/kitchen" ,
45 " pages/detail/index" ,
56 " pages/my/index" ,
67 " pages/myStarred/index" ,
Original file line number Diff line number Diff line change 1+ import { knownSupportedEmoji } from './supported' ;
2+ let emojiData = { } ;
3+
4+ Page ( {
5+ data : {
6+ visible : false ,
7+ knownSupportedEmoji,
8+ enableEmoji : [ ] ,
9+ leftEmoji : '' ,
10+ rightEmoji : '' ,
11+ pos : '' ,
12+ } ,
13+ onLoad ( ) {
14+ wx . request ( {
15+ url : 'https://how-to-cook-1255404841.cos.ap-shanghai.myqcloud.com/emoji/emoji.json' ,
16+ success ( res ) {
17+ emojiData = res . data ;
18+ } ,
19+ fail ( err ) {
20+ console . log ( err ) ;
21+ }
22+ } )
23+ } ,
24+ handleSelected ( e ) {
25+ const { pos } = e . currentTarget . dataset ;
26+ const { leftEmoji } = this . data ;
27+
28+ if ( pos == 'right' ) {
29+ if ( leftEmoji == '' ) {
30+ wx . showToast ( { icon : 'none' , title : '从左边开始' } )
31+ return ;
32+ }
33+ this . setData ( {
34+ enableEmoji : knownSupportedEmoji . map ( e => {
35+ const target = emojiData [ leftEmoji ] . find ( item => {
36+ if ( e === leftEmoji ) {
37+ return item . leftEmoji == e && item . rightEmoji == e ;
38+ }
39+ return item . leftEmoji == e || item . rightEmoji == e ;
40+ } )
41+ return {
42+ isValid : ! ! target ,
43+ id : e ,
44+ date : target ? target . date : ''
45+ }
46+ } )
47+ } )
48+ }
49+ this . setData ( { visible : true , pos } )
50+ } ,
51+
52+ onVisibleChange ( e ) {
53+ this . setData ( { visible : e . detail . visible } )
54+ } ,
55+
56+ handleSelectedEmoji ( e ) {
57+ const { pos } = this . data ;
58+ const { id, date, valid } = e . target . dataset ;
59+ const rect = { } ;
60+
61+ if ( pos == 'right' && ! valid ) return ;
62+
63+ if ( pos == 'right' ) {
64+ rect . date = date
65+ }
66+
67+ this . setData ( { ...rect , [ `${ pos } Emoji` ] : id , visible : false } ) ;
68+ }
69+ } )
Original file line number Diff line number Diff line change 1+ {
2+ "component" : true ,
3+ "navigationBarTitleText" : " 表情厨房"
4+ }
Original file line number Diff line number Diff line change 1+ .box {
2+ display : flex ;
3+ align-items : center ;
4+ justify-content : center ;
5+ height : 120px ;
6+ width : 120px ;
7+ border-radius : 6px ;
8+ background-color : #efefef ;
9+ font-size : 58px ;
10+ color : #ccc ;
11+
12+ &-result {
13+ background-color : #fff ;
14+ margin : 32px auto ;
15+ border-radius : 50% ;
16+ width : 150px ;
17+ height : 150px ;
18+ }
19+ }
20+
21+ .container {
22+ display : flex ;
23+ padding : 24px ;
24+ background-color : #e4e4e4 ;
25+ justify-content : space-around ;
26+ }
27+ .block {
28+ background : #fff ;
29+ color : #333 ;
30+ display : flex ;
31+ align-items : center ;
32+ justify-content : space-evenly ;
33+ flex-wrap : wrap ;
34+ }
35+
36+ .popup-wrapper {
37+ height : 60vh ;
38+ }
39+
40+ .emoji {
41+ width : 100 rpx;
42+ height : 100 rpx;
43+ padding : 24 rpx;
44+ }
Original file line number Diff line number Diff line change 1+
2+ <view class="container">
3+ <view class="box box-a" bind:tap="handleSelected" data-pos="left">
4+ <image
5+ wx:if="{{leftEmoji}}"
6+ class="emoji"
7+ src="https://how-to-cook-1255404841.cos.ap-shanghai.myqcloud.com/emoji/svg/emoji_u{{_.fix(leftEmoji)}}.svg" />
8+ <t-icon wx:else name="add" />
9+ </view>
10+ <view class="box box-b" bind:tap="handleSelected" data-pos="right">
11+ <image
12+ wx:if="{{rightEmoji}}"
13+ class="emoji"
14+ src="https://how-to-cook-1255404841.cos.ap-shanghai.myqcloud.com/emoji/svg/emoji_u{{_.fix(rightEmoji)}}.svg" />
15+ <t-icon wx:else name="add" />
16+ </view>
17+ </view>
18+
19+ <view class="box box-result">
20+ <image
21+ wx:if="{{leftEmoji && rightEmoji}}"
22+ class="emoji"
23+ src="https://www.gstatic.com/android/keyboard/emojikitchen/{{date}}/u{{_.fix(leftEmoji)}}/u{{_.fix(leftEmoji)}}_u{{_.fix(rightEmoji)}}.png" />
24+ </view>
25+
26+ <t-popup visible="{{visible}}" bind:visible-change="onVisibleChange" placement="bottom">
27+ <scroll-view class="popup-wrapper" scroll-y>
28+ <view class="block" bind:tap="handleSelectedEmoji">
29+ <view wx:if="{{enableEmoji.length > 0}}">
30+ <image
31+ wx:for="{{enableEmoji}}"
32+ wx:key="index"
33+ lazy-load
34+ class="emoji"
35+ data-id="{{item.id}}"
36+ data-date="{{item.date}}"
37+ data-valid="{{item.isValid}}"
38+ style="{{item.isValid ? '' : 'opacity: .2;'}}"
39+ src="https://how-to-cook-1255404841.cos.ap-shanghai.myqcloud.com/emoji/svg/emoji_u{{_.fix(item.id)}}.svg" />
40+ </view>
41+ <view wx:else>
42+ <image
43+ wx:for="{{knownSupportedEmoji}}"
44+ wx:key="index"
45+ lazy-load
46+ class="emoji"
47+ data-id="{{item}}"
48+ src="https://how-to-cook-1255404841.cos.ap-shanghai.myqcloud.com/emoji/svg/emoji_u{{_.fix(item)}}.svg" />
49+ </view>
50+ </view>
51+ </scroll-view>
52+ </t-popup>
53+
54+ <wxs module="_">
55+ module.exports.fix = function(str) {
56+ return str.split("-")
57+ .filter(function(x) { return x !== "fe0f" })
58+ .join("_")
59+ }
60+ </wxs>
You can’t perform that action at this time.
0 commit comments