Skip to content

Commit

Permalink
知晓云 SDK Demo 百度小程序
Browse files Browse the repository at this point in the history
  • Loading branch information
libicheng committed Oct 17, 2019
0 parents commit eb76163
Show file tree
Hide file tree
Showing 55 changed files with 3,226 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# baidu-minapp-demo
知晓云 SDK Demo 百度小程序
34 changes: 34 additions & 0 deletions app.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
.page-container {
box-sizing:border-box;
background:rgb(239, 239, 239);
overflow:hidden;
}

.card {
margin: 30rpx 20rpx;
padding: 20rpx;
border-radius: 8rpx;
background: rgb(255, 255, 255);
}

.card-title {
font-size: 32rpx;
line-height: 2;
display: block;
}

.card .card-comments {
font-size: 26rpx;
line-height: 1.8;
color: #666;
display: block;
margin-bottom: 10rpx;
}

button {
margin-bottom: 20rpx;
}

.f-margin-bottom-0 {
margin-bottom: 0;
}
13 changes: 13 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import {BAAS_CLIENT_ID} from './env.js'

//app.js
App({
onLaunch() {
this.initBaaS()
},

initBaaS() {
this.BaaS = require('./utils/sdk-baidu.2.8.1.js')
this.BaaS.init(BAAS_CLIENT_ID)
}
})
12 changes: 12 additions & 0 deletions app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"pages": [
"pages/index/index",
"pages/auth/auth",
"pages/schema-change/schema-change",
"pages/schema-query/schema-query",
"pages/invoke-function/invoke-function"
],
"window": {
"navigationBarBackgroundColor": "#222"
}
}
Binary file added assets/images/area.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/hello.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions components/card/card.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.card {
margin:15px 10px;
padding:10px;
border-radius:4px;
background:rgb(255, 255, 255);
}
1 change: 1 addition & 0 deletions components/card/card.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Component({})
3 changes: 3 additions & 0 deletions components/card/card.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"component": true
}
3 changes: 3 additions & 0 deletions components/card/card.swan
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<view class="card">
<slot></slot>
</view>
30 changes: 30 additions & 0 deletions components/input-item/input-item.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
.input-item {
display: flex;
flex-direction: column;
padding: 0 30rpx;
height: 100rpx;
line-height: 100rpx;
}

.input-group {
display: flex;
align-items: center;
}

.input-label {
min-width: 160rpx;
margin-right: 4rpx;
color:rgb(51, 51, 51);
}

.placeholder {
font-size: 34rpx;
color:rgb(51, 51, 51, .4);
}

.split-line {
width: 100%;
height: 1rpx;
border-bottom: 1px solid #000;
opacity: .1;
}
32 changes: 32 additions & 0 deletions components/input-item/input-item.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
Component({
porperties: {
label: {
type: String,
value: '',
},
type: {
type: String,
value: 'text',
},
value: {
type: String,
value: '',
},
placeholder: {
type: String,
value: '',
},
isShowLine: {
type: Boolean,
value: false,
}
},

methods: {
bindInput(e) {
this.triggerEvent('inputchange', {
value: e.detail.value,
})
}
}
})
3 changes: 3 additions & 0 deletions components/input-item/input-item.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"component": true
}
12 changes: 12 additions & 0 deletions components/input-item/input-item.swan
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<view class="input-item">
<view class="input-group">
<view class="input-label">{{label}}</view>
<input
value="{{value}}"
type="{{type}}"
placeholder="{{placeholder}}"
placeholder-class="placeholder"
bindinput="bindInput" />
</view>
<view s-if="isShowLine" class="split-line"></view>
</view>
40 changes: 40 additions & 0 deletions components/list-item/list-item.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
.list-item {
position: relative;
display: -webkit-flex;
display: flex;
flex-flow: row nowrap;
align-items: center;
justify-content: space-between;
min-height: 52px;
padding: 0 16px;
color: rgb(51, 51, 51);
font-size: 15px;
line-height: 1.4;
}

.content {
flex: 1 1 0;
padding: 7px 15px 7px 0;
line-height: 1.5;
text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;
}

.arrow {
display:block;
width:15px;
height:15px;
margin-left:8px;
background-image:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAaCAYAAAC+aNwHAAAAAXNSR0IArs4c6QAAAdxJREFUOBGlVT1Lw1AUbSSBdMnQf9ChU6GFtr9AEMFBiouDuOikoGixiGgRSi2i1KJTR0fHbuLi5mRbcO7QnyAIQjCSek7ghtc0DQm+5d537z0n97yvpFIYg8GgMxqNavSTjqXhcNgCqOa6bgf+eWICABwBTafTFkiuZB7HaiyChAZMUwCapnXL5XIsSR4BgWyfHQgJbA8k+yCbKrE51ydgBp2cwbSlCuDHUqm0C+tKLGhnCJjEbpxiQa+lEOAnkGzD/kpMtXMETEJOHXJulMJ+Op3ezOfzP0rMc5eCAc6h/RamruSqtm33J5OJqcQ8N7QDKeLh4vmQOWS86rq+XiwWvyUW2oEkof0OoGOZQ9ay4zgv4/HYklhkB1KE3TmEfy9zkL4bhrFaKBQ+YxEQCDkHkPOgkHyAaCVSghRH2VgdREnQo9iZw5k4wuJ1lbo3y7LWcrncF2OREriNKpjbyMUTMAkWSkDbJ8jzQHkD4OdMJrORzWZtidGGdsCjjJwPht83TbMaBJNgroOkl2mmA17nwE3kdd5C+6E3kR34BHxQMPffAvg9gHcAXvgW+AT4cgOr7b9GAHUrlcoebORr5BHgy5dwmpxwANSO+x6ynhIMOhwAXwCc+Gn/14/lDyH1t+arhvp8AAAAAElFTkSuQmCC");
background-size:contain;
background-repeat:no-repeat;
background-position:50% 50%;
}

.bottom-line {
position: absolute;
bottom: 0;
width: 100%;
border-bottom: 1px solid rgb(240, 240, 240);
}
22 changes: 22 additions & 0 deletions components/list-item/list-item.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Component({
properties: {
last: {
type: Boolean,
value: true,
},
arrow: {
type: Boolean,
value: true,
},
url: {
type: String,
value: '',
}
},
methods: {
onTap(e) {
this.triggerEvent('click', e);
}
},
externalClasses: ['my-class']
})
3 changes: 3 additions & 0 deletions components/list-item/list-item.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"component": true
}
8 changes: 8 additions & 0 deletions components/list-item/list-item.swan
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<!-- 这是自定义组件的内部QML结构 -->
<view class="list-item" data-url="{{url}}" bindtap="onTap">
<view class="content">
<slot></slot>
</view>
<view class="arrow" s-if="arrow"></view>
<view class="bottom-line" s-if="last"></view>
</view>
3 changes: 3 additions & 0 deletions components/list/list.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.list {
border-bottom: 1px solid rgb(240, 240, 240);
}
1 change: 1 addition & 0 deletions components/list/list.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Component({})
3 changes: 3 additions & 0 deletions components/list/list.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"component": true
}
3 changes: 3 additions & 0 deletions components/list/list.swan
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<view class="list">
<slot></slot>
</view>
29 changes: 29 additions & 0 deletions components/stepper/stepper.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
.stepper {
display: -webkit-flex;
display: flex;
height: 70rpx;
align-items: stretch;
}

.btn {
border:1px solid rgb(238, 238, 238);
width: 70rpx;
border-radius:0.1rem;
}

.btn-minus {
background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAAGXRFWHRTb2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kRlc2NyaXB0aW9uPiA8L3JkZjpSREY+IDwveDp4bXBtZXRhPiA8P3hwYWNrZXQgZW5kPSJyIj8+jjGoUQAAAF5JREFUeNrs2LEJACAMRUF1/xkc0gUiAe3tRLkHFna59teIKD/UyieBgICAgICAgICAgICAgICAgByVu9batkZ+H3t9318NdCAgICAgICAgICAgICAgICAgIPeaAgwAyuE/sx15o0MAAAAASUVORK5CYII=") center center / 0.4rem 0.4rem no-repeat;
}

.input {
width: 80rpx;
text-align: center;
}

.btn-plus {
background-image:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyppVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuNi1jMTMyIDc5LjE1OTI4NCwgMjAxNi8wNC8xOS0xMzoxMzo0MCAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENDIDIwMTUuNSAoTWFjaW50b3NoKSIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDo1ODU0RTgzRjI2ODYxMUU4OUY0N0VFQzhCQkYwQTYyOCIgeG1wTU06RG9jdW1lbnRJRD0ieG1wLmRpZDo1ODU0RTg0MDI2ODYxMUU4OUY0N0VFQzhCQkYwQTYyOCI+IDx4bXBNTTpEZXJpdmVkRnJvbSBzdFJlZjppbnN0YW5jZUlEPSJ4bXAuaWlkOjU4NTRFODNEMjY4NjExRTg5RjQ3RUVDOEJCRjBBNjI4IiBzdFJlZjpkb2N1bWVudElEPSJ4bXAuZGlkOjU4NTRFODNFMjY4NjExRTg5RjQ3RUVDOEJCRjBBNjI4Ii8+IDwvcmRmOkRlc2NyaXB0aW9uPiA8L3JkZjpSREY+IDwveDp4bXBtZXRhPiA8P3hwYWNrZXQgZW5kPSJyIj8+jv5jrAAAAHdJREFUeNrs2sENgCAMBVDq/jMwpA5QIdERIIivCQdO5SXt5YfIzLJDHWWTmgKJiDq8x4zRapDWJsNogYCAgICAgICAgICAgID8D1J6+PAEEGe/fuzU9/1SFDsCAgICAgICAgICAgICAgKyEuQa3SD811qsbgEGAMVVTz/OpY/oAAAAAElFTkSuQmCC");
background-size:0.4rem 0.4rem;
background-repeat:no-repeat;
background-position:center center;
}

36 changes: 36 additions & 0 deletions components/stepper/stepper.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
Component({
properties: {
value: {
type: Number,
value: 0
},
step: {
type: Number,
value: 1
},
},

lifetimes: {
attached() {},
},

methods: {
onBtnClick(e) {
const operator = e.target.dataset.operator
const offset = Number(operator + this.data.step)
this.setData({value: this.data.value + offset})
this.emitInputChange()
},

onInput(e) {
this.setData({value: e.detail.value})
this.emitInputChange()
},

emitInputChange() {
this.triggerEvent('inputchange', {
value: this.data.value
})
}
}
})
3 changes: 3 additions & 0 deletions components/stepper/stepper.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"component": true
}
5 changes: 5 additions & 0 deletions components/stepper/stepper.swan
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<view class="stepper">
<view class="item btn btn-minus" bindtap="onBtnClick" data-operator="-"></view>
<input class="item input" type="{{type}}" bindinput="onInput" value="{{value}}" />
<view class="item btn btn-plus" bindtap="onBtnClick" data-operator="+"></view>
</view>
3 changes: 3 additions & 0 deletions env
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// 请把文件名修改成 env.js

export const BAAS_CLIENT_ID = '从 BaaS 后台获取 clientID'
43 changes: 43 additions & 0 deletions pages/auth/auth.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
.status-panel {
padding: 10px;
background: #fff;
margin-bottom: 10px;
font-size: 14px;
}

.status-panel view {
line-height: 2;
color: #333333;
}

.status-info {
margin: 10px 0;
}

.status-panel .user-info {
margin-top: 20px;
}

.status-panel .user-info-name {
text-align: center;
}

.status-panel .user-info-avatar {
margin: 0 auto;
display: block;
width: 60px;
height: 60px;
border-radius: 50%;
}

.btn-group {
margin: 10px;
}

.f-margin-bottom-0 {
margin-bottom: 0;
}

button {
margin-bottom: 20rpx;
}
Loading

0 comments on commit eb76163

Please sign in to comment.