Skip to content

Commit

Permalink
Initial Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
cy920820 committed Mar 4, 2019
0 parents commit 72d28ce
Show file tree
Hide file tree
Showing 286 changed files with 9,971 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .editorconfig
@@ -0,0 +1,10 @@
root = true

[*]

charset = utf-8
indent_size = 2
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true
end_of_line = lf
11 changes: 11 additions & 0 deletions .gitignore
@@ -0,0 +1,11 @@
node_modules/
.DS_Store
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Editor directories and files
.vscode
.atom
.subl
.idea
12 changes: 12 additions & 0 deletions README.md
@@ -0,0 +1,12 @@
# 云开发 quickstart

这是云开发的快速启动指引,其中演示了如何上手使用云开发的三大基础能力:

- 数据库:一个既可在小程序前端操作,也能在云函数中读写的 JSON 文档型数据库
- 文件存储:在小程序前端直接上传/下载云端文件,在云开发控制台可视化管理
- 云函数:在云端运行的代码,微信私有协议天然鉴权,开发者只需编写业务逻辑代码

## 参考文档

- [云开发文档](https://developers.weixin.qq.com/miniprogram/dev/wxcloud/basis/getting-started.html)

31 changes: 31 additions & 0 deletions cloudfunctions/login/index.js
@@ -0,0 +1,31 @@
// 云函数模板
// 部署:在 cloud-functions/login 文件夹右击选择 “上传并部署”

const cloud = require('wx-server-sdk')

// 初始化 cloud
cloud.init()

/**
* 这个示例将经自动鉴权过的小程序用户 openid 返回给小程序端
*
* event 参数包含小程序端调用传入的 data
*
*/
exports.main = (event, context) => {
console.log(event)
console.log(context)

// 可执行其他自定义逻辑
// console.log 的内容可以在云开发云函数调用日志查看

// 获取 WX Context (微信调用上下文),包括 OPENID、APPID、及 UNIONID(需满足 UNIONID 获取条件)
const wxContext = cloud.getWXContext()

return {
event,
openid: wxContext.OPENID,
appid: wxContext.APPID,
unionid: wxContext.UNIONID,
}
}
14 changes: 14 additions & 0 deletions cloudfunctions/login/package.json
@@ -0,0 +1,14 @@
{
"name": "login",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"wx-server-sdk": "latest"
}
}
8 changes: 8 additions & 0 deletions cloudfunctions/sum/index.js
@@ -0,0 +1,8 @@
// 云函数入口函数
exports.main = (event, context) => {
console.log(event)
console.log(context)
return {
sum: event.a + event.b
}
}
2 changes: 2 additions & 0 deletions miniprogram/.gitignore
@@ -0,0 +1,2 @@
.vscode
/node_modules
15 changes: 15 additions & 0 deletions miniprogram/app.js
@@ -0,0 +1,15 @@
//app.js
App({
onLaunch: function () {

if (!wx.cloud) {
console.error('请使用 2.2.3 或以上的基础库以使用云能力')
} else {
wx.cloud.init({
traceUser: true
})
}

this.globalData = {}
}
})
18 changes: 18 additions & 0 deletions miniprogram/app.json
@@ -0,0 +1,18 @@
{
"pages": [
"pages/index/index",
"pages/userConsole/userConsole",
"pages/storageConsole/storageConsole",
"pages/databaseGuide/databaseGuide",
"pages/addFunction/addFunction",
"pages/deployFunctions/deployFunctions",
"pages/chooseLib/chooseLib"
],
"window": {
"backgroundColor": "#F6F6F6",
"backgroundTextStyle": "light",
"navigationBarBackgroundColor": "#F6F6F6",
"navigationBarTitleText": "The Motor Movies",
"navigationBarTextStyle": "black"
}
}
7 changes: 7 additions & 0 deletions miniprogram/app.wxss
@@ -0,0 +1,7 @@
/**app.wxss**/
.container {
display: flex;
flex-direction: column;
align-items: center;
box-sizing: border-box;
}
Binary file added miniprogram/images/code-db-inc-dec.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added miniprogram/images/code-db-onAdd.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added miniprogram/images/code-db-onQuery.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added miniprogram/images/code-db-onRemove.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added miniprogram/images/code-func-sum.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added miniprogram/images/console-entrance.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added miniprogram/images/create-collection.png
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 miniprogram/jsconfig.json
@@ -0,0 +1,6 @@
{
"compilerOptions": {
"target": "es2015",
"module": "commonjs"
}
}
42 changes: 42 additions & 0 deletions miniprogram/miniprogram_npm/vant-weapp/action-sheet/index.js
@@ -0,0 +1,42 @@
import { VantComponent } from '../common/component';
import { iphonex } from '../mixins/iphonex';
VantComponent({
mixins: [iphonex],
props: {
show: Boolean,
title: String,
cancelText: String,
zIndex: {
type: Number,
value: 100
},
actions: {
type: Array,
value: []
},
overlay: {
type: Boolean,
value: true
},
closeOnClickOverlay: {
type: Boolean,
value: true
}
},
methods: {
onSelect: function onSelect(event) {
var index = event.currentTarget.dataset.index;
var item = this.data.actions[index];

if (item && !item.disabled && !item.loading) {
this.$emit('select', item);
}
},
onCancel: function onCancel() {
this.$emit('cancel');
},
onClose: function onClose() {
this.$emit('close');
}
}
});
@@ -0,0 +1,8 @@
{
"component": true,
"usingComponents": {
"van-icon": "../icon/index",
"van-popup": "../popup/index",
"van-loading": "../loading/index"
}
}
49 changes: 49 additions & 0 deletions miniprogram/miniprogram_npm/vant-weapp/action-sheet/index.wxml
@@ -0,0 +1,49 @@
<wxs src="../wxs/utils.wxs" module="utils" />

<van-popup
show="{{ show }}"
position="bottom"
z-index="{{ zIndex }}"
overlay="{{ overlay }}"
custom-class="van-action-sheet"
safe-area-inset-bottom="{{ safeAreaInsetBottom }}"
close-on-click-overlay="{{ closeOnClickOverlay }}"
bind:close="onClose"
>
<view wx:if="{{ title }}" class="van-hairline--bottom van-action-sheet__header">
{{ title }}
<van-icon
name="close"
custom-class="van-action-sheet__close"
bind:click="onClose"
/>
</view>
<view wx:if="{{ actions && actions.length }}">
<!-- button外包一层view,防止actions动态变化,导致渲染时button被打散 -->
<button
wx:for="{{ actions }}"
wx:key="index"
open-type="{{ item.openType }}"
class="{{ utils.bem('action-sheet__item', { disabled: item.disabled || item.loading }) }} van-hairline--top {{ item.className || '' }}"
hover-class="van-action-sheet__item--hover"
data-index="{{ index }}"
bind:tap="onSelect"
>
<block wx:if="{{ !item.loading }}">
{{ item.name }}
<text wx:if="{{ item.subname }}" class="van-action-sheet__subname" >{{ item.subname }}</text>
</block>
<van-loading wx:else size="20px" />
</button>
</view>
<view
wx:if="{{ cancelText }}"
class="van-action-sheet__cancel"
hover-class="van-action-sheet__cancel--hover"
hover-stay-time="70"
bind:tap="onCancel"
>
{{ cancelText }}
</view>
<slot />
</van-popup>
@@ -0,0 +1 @@
@import '../common/index.wxss';.van-action-sheet{max-height:90%!important;color:#333}.van-action-sheet__cancel,.van-action-sheet__item{height:50px;font-size:16px;line-height:50px;text-align:center;background-color:#fff}.van-action-sheet__cancel--hover,.van-action-sheet__item--hover{background-color:#e8e8e8}.van-action-sheet__cancel{height:60px}.van-action-sheet__cancel::before{display:block;height:10px;background-color:#f8f8f8;content:' '}.van-action-sheet__item--disabled{color:#c9c9c9}.van-action-sheet__item--disabled.van-action-sheet__item--hover{background-color:#fff}.van-action-sheet__subname{margin-left:5px;font-size:12px;color:#7d7e80}.van-action-sheet__header{font-size:16px;font-weight:500;line-height:44px;text-align:center}.van-action-sheet__close{position:absolute!important;top:0;right:0;padding:0 15px;font-size:18px!important;line-height:inherit!important;color:#999}

0 comments on commit 72d28ce

Please sign in to comment.