Commit e8f2b75c by 李静静

Initial commit

parents
# 云开发 quickstart
这是云开发的快速启动指引,其中演示了如何上手使用云开发的三大基础能力:
- 数据库:一个既可在小程序前端操作,也能在云函数中读写的 JSON 文档型数据库
- 文件存储:在小程序前端直接上传/下载云端文件,在云开发控制台可视化管理
- 云函数:在云端运行的代码,微信私有协议天然鉴权,开发者只需编写业务逻辑代码
## 参考文档
- [云开发文档](https://developers.weixin.qq.com/miniprogram/dev/wxcloud/basis/getting-started.html)
//app.js
App({
onLaunch: function () {
if (!wx.cloud) {
console.error('请使用 2.2.3 或以上的基础库以使用云能力')
} else {
wx.cloud.init({
// env 参数说明:
// env 参数决定接下来小程序发起的云开发调用(wx.cloud.xxx)会默认请求到哪个云环境的资源
// 此处请填入环境 ID, 环境 ID 可打开云控制台查看
// 如不填则使用默认环境(第一个创建的环境)
// env: 'my-env-id',
traceUser: true,
})
}
this.globalData = {}
}
})
{
"pages": [
"pages/freeCourse/index",
"pages/joinGroup/index"
],
"plugins": {
"chatGroupPlugin": {
"version": "1.0.5",
"provider": "wx4d2deeab3aed6e5a"
}
},
"window": {
"backgroundColor": "#F6F6F6",
"backgroundTextStyle": "light",
"navigationBarBackgroundColor": "#F6F6F6",
"navigationBarTitleText": "",
"navigationBarTextStyle": "black"
},
"sitemapLocation": "sitemap.json",
"style": "v2"
}
\ No newline at end of file
/**app.wxss**/
.container {
display: flex;
flex-direction: column;
align-items: center;
box-sizing: border-box;
}
button {
background: initial;
}
button:focus{
outline: 0;
}
button::after{
border: none;
}
page {
background: #f6f6f6;
display: flex;
flex-direction: column;
justify-content: flex-start;
}
.userinfo, .uploader, .tunnel {
margin-top: 40rpx;
height: 140rpx;
width: 100%;
background: #fff;
border: 1px solid rgba(0, 0, 0, 0.1);
border-left: none;
border-right: none;
display: flex;
flex-direction: row;
align-items: center;
transition: all 300ms ease;
}
.userinfo-avatar {
width: 100rpx;
height: 100rpx;
margin: 20rpx;
border-radius: 50%;
background-size: cover;
background-color: white;
}
.userinfo-avatar:after {
border: none;
}
.userinfo-nickname {
font-size: 32rpx;
color: #007aff;
background-color: white;
background-size: cover;
}
.userinfo-nickname::after {
border: none;
}
.uploader, .tunnel {
height: auto;
padding: 0 0 0 40rpx;
flex-direction: column;
align-items: flex-start;
box-sizing: border-box;
}
.uploader-text, .tunnel-text {
width: 100%;
line-height: 52px;
font-size: 34rpx;
color: #007aff;
}
.uploader-container {
width: 100%;
height: 400rpx;
padding: 20rpx 20rpx 20rpx 0;
display: flex;
align-content: center;
justify-content: center;
box-sizing: border-box;
border-top: 1px solid rgba(0, 0, 0, 0.1);
}
.uploader-image {
width: 100%;
height: 360rpx;
}
.tunnel {
padding: 0 0 0 40rpx;
}
.tunnel-text {
position: relative;
color: #222;
display: flex;
flex-direction: row;
align-content: center;
justify-content: space-between;
box-sizing: border-box;
border-top: 1px solid rgba(0, 0, 0, 0.1);
}
.tunnel-text:first-child {
border-top: none;
}
.tunnel-switch {
position: absolute;
right: 20rpx;
top: -2rpx;
}
.disable {
color: #888;
}
.service {
position: fixed;
right: 40rpx;
bottom: 40rpx;
width: 140rpx;
height: 140rpx;
border-radius: 50%;
background: linear-gradient(#007aff, #0063ce);
box-shadow: 0 5px 10px rgba(0, 0, 0, 0.3);
display: flex;
align-content: center;
justify-content: center;
transition: all 300ms ease;
}
.service-button {
position: absolute;
top: 40rpx;
}
.service:active {
box-shadow: none;
}
.request-text {
padding: 20rpx 0;
font-size: 24rpx;
line-height: 36rpx;
word-break: break-all;
}
//index.js
const app = getApp()
import {request} from "../../utils/request.js"
Page({
data: {
modal:false,
// group_list:[]
},
onLoad: function() {
},
onShow:function(){
console.log(this)
this.getGroupList()
},
showModal:function(){
this.setData({
modal:true
})
},
getGroupList:function(){
console.log(request)
request({
url:"/h5/api/group/free_group_list",
success:(res)=>{
console.log(res.data)
if(res.data&&res.data.code===0){
console.log(res.data.data.list)
this.setData({
group_list:res.data.data.list
})
}
}
})
},
startmessage:function(res){
console.log(res)
},
completemessage:function(res){
console.log(res)
},
modalClose:function(){
this.setData({
modal:false
})
}
})
{
"usingComponents": {
"cell": "plugin://chatGroupPlugin/cell"
}
}
\ No newline at end of file
<!--index.wxml-->
<view class="container">
<view class="header">
<image src="../../images/logo.png" class="logo"/>
</view>
<view class="content">
<view class="content-h3">在专属社群你可以获得:</view>
<view class="content-item">
<image src="../../images/content-img-1.png" class="content-img" />
<view class="content-text-container">
<text class="content-item-h4">海量免费资料</text>
<text class="content-p">大量、系统、全阶段的法考资料免费送。</text>
</view>
</view>
<view class="content-item">
<image src="../../images/content-img-2.png" class="content-img" />
<view class="content-text-container">
<text class="content-item-h4">每日学习计划</text>
<text class="content-p">精准把握学习进度,稳扎稳打,逐步提升。</text>
</view>
</view>
<view class="content-item">
<image src="../../images/content-img-3.png" class="content-img" />
<view class="content-text-container">
<text class="content-item-h4">浓厚学习氛围</text>
<text class="content-p">群内特设每日一题,相互讨论,共同进步。</text>
</view>
</view>
<view class="content-item">
<image src="../../images/content-img-4.png" class="content-img" />
<view class="content-text-container">
<text class="content-item-h4">班主任强督导</text>
<text class="content-p">群内特设每日一题,相互讨论,共同进步。</text>
</view>
</view>
</view>
<view class="join-btn" bindtap="showModal">加入专属备考群</view>
<view wx:if="{{modal}}" class="modal" >
<view class="modal-content">
<view class="modal-close" bindtap="modalClose"></view>
<view class="modal-h4">请选择你的备考状态</view>
<scroll-view class="modal-list" scroll-y="{{true}}"
show-scrollbar="{{false}}"
>
<view class="modal-item" wx:for="{{group_list}}" >
<view class="modal-item-title">{{item.name}}</view>
<view class="modal-item-p">{{item.desc}}</view>
<view class="modal-item-after"></view>
<view class="modal-item-join">
<!-- url='https://work.weixin.qq.com/gm/24e84fe11d990cd99fa67ccd99f1aa4b' -->
<cell
paddingStyle="80"
url='https://work.weixin.qq.com/gm/{{item.uniq_code}}'
bind:startmessage="startmessage"
bind:completemessage="completemessage"
/>
</view>
</view>
</scroll-view>
</view>
</view>
</view>
/**index.wxss**/
.header{
box-sizing: border-box;
padding-top: 80rpx;
width: 100%;
height: 388rpx;
background: #3396ff;
}
.header .logo{
display: block;
margin: 0 auto;
width: 384rpx;
height: 72rpx;
}
.content{
position: relative;
margin: 0 auto -156rpx;
top:-156rpx;
width: 670rpx;
background: #FFFFFF;
box-shadow: 0px 2px 4px rgba(0, 0, 0, 0.04);
border-radius: 12px;
z-index: 1;
}
.content-h3{
margin:0 40rpx;
border-bottom: 2rpx solid #e6e6e6;
font-weight: 600;
font-size: 32rpx;
line-height: 154rpx;
letter-spacing: -0.6rpx;
color: #000000;
}
.content-item{
display: flex;
justify-content: space-around;
padding: 0 40rpx;
height: 184rpx;
align-items: center;
}
.content-img{
flex:1 0 96rpx;
width: 96rpx;
height: 96rpx;
}
.content-text-container{
margin-left: 32rpx;
}
.content-item-h4{
font-size: 32rpx;
line-height: 44rpx;
color:#282828;
}
.content-p{
display: block;
font-size: 28rpx;
line-height:36rpx;
color:#999;
}
.join-btn{
margin: 54rpx auto 20rpx;
width: 686rpx;
height: 96rpx;
line-height: 96rpx;
text-align: center;
background: #3396ff;
border-radius: 48rpx;
color:#fff;
font-size: 30rpx;
}
/* modal */
.modal{
position: absolute;
left: 0;
top: 0;
bottom: 0;
right: 0;
z-index: 2;
background:rgba(0, 0, 0, 0.4);
display: flex;
align-items: flex-end;
}
.modal-content{
position: relative;
overflow: hidden;
width: 100%;
height: 960rpx;
background: #F5F6F8;
border-radius: 24rpx 24rpx 0 0;
}
.modal-close{
position: absolute;
right: 50rpx;
top:40rpx;
width: 48rpx;
height: 48rpx;
content:'';
background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEgAAABICAYAAABV7bNHAAAACXBIWXMAACE4AAAhOAFFljFgAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAGZSURBVHgB7doxjoJAGIbhWYy9R+AIa2Pvye1t9AgcwZ5Ali9hEgvDj84/M8R9n0YKssO8qygDIQAAAAAAAAAJbrfb4Xq9/obCNKbGDs6a4EgHOAzDpWmaS8lIGktjamzvSD/BSYwzbcYwj3Ecz6fT6R4yinGmzRjmvtvtzsfj8REcuAR6ESfKGulFnMgtUnKghThRlkgLcSKXSMnnoL7v2+mlXdjl4H1OWhFH2vnYkrh8xFYesMs7qeRY4naSLnHgpeOIWyDJOYEaccQ1kOSYSK044h5IPCdUM45kCSQeE6sdR7IFkpQJbiGOZA0kn0x0K3EkeyB5Z8La2EocKRJI1kaaXzcRR4oFkpWRlhSNI0UDSUKk4nGkeCD5IFKVOFIlkLwRqVoccV1y/UZ8xAycpA18zRv4oWjgUsPAxaqB5Q4DC2YGllwNLNobuO1j4MahgVvPhuRANf6rJcdMXu7Y7/fd9NIt7OJ+XtDfmn91PxZ26+ZjS8IDVAYewTO4fs0/RWpLXnE/Reo842TxbY8BAwAAAAAA4H/5A61LT4ExBBXTAAAAAElFTkSuQmCC) no-repeat center center /48rpx 48rpx;
z-index: 3;
}
.modal-h4{
padding-left: 72rpx;
font-size:32rpx;
color:#282828;
line-height: 144rpx;
}
.modal-list{
height: 728rpx;
margin:0 auto;
width: 686rpx;
}
.modal-item{
position: relative;
box-sizing: border-box;
margin:0 auto 32rpx;
padding:40rpx;
width: 686rpx;
min-height: 176rpx;
border-radius: 24rpx;
display: flex;
flex-direction: column;
justify-content: center;
background: #fff;
}
.modal-item-after{
position: absolute;
right: 40rpx;
top:50%;
transform: translateY(-50%);
width: 32rpx;
height: 32rpx;
content:'';
background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAACXBIWXMAACE4AAAhOAFFljFgAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAEPSURBVHgB7ZnBDcIwDEUDVe+MwAh0BEZhMkbpsccyAiP0XlWiXyISQhRI7Nix5HdpVfXwn1SnsROC4zhOCsMwHMdxPAQm9kEQhG/btl+WpeeS2AUhYvj19vh8dGua5tx13RQIiAh8CB8hSxQX+BI+QpIoXgNr+GvYDg9OlJooLjDP82W93H+8li2hXQPvJH9OmqvQFkkSYgKghISoAOCWEBcAnBIqAoBLQk0AcEioCgCqhLoAoEhUIQByJaoRADkSVQmAVAnRjqwE/glxYbqITS+jpn9kprcSpjdzprfTphsa0y2l6abe9FilZHhQw2gRZM9Haxgtkoa7Pl7/F9MHHJEXiYkjvArch3yO4xjnAWre4gIsZoBqAAAAAElFTkSuQmCC) no-repeat center center /32rpx 32rpx;
z-index: 3;
}
.modal-item:last-child{
margin-bottom: 120rpx;
}
.modal-item-join{
position: absolute;
width: 100%;
height: 100%;
z-index: 9;
opacity: 0;
overflow: hidden;
}
.modal-item-title{
color: #3396FF;
font-size: 36rpx;
}
.modal-item-p{
display: block;
width: 542rpx;
margin-top: 12rpx;
color: #282828;
font-size: 32rpx;
word-break: break-all;
}
\ No newline at end of file
//index.js
const app = getApp()
Page({
data: {
url:''
},
onLoad: function(query) {
this.setData({
url:'https://work.weixin.qq.com/gm/'+(query.gId||'')
})
},
startmessage:function(){
},
completemessage:function(){
}
})
{
"usingComponents": {
"cell": "plugin://chatGroupPlugin/cell"
}
}
\ No newline at end of file
<!--index.wxml-->
<view class="hidden" id="the-id">
<cell bind:startmessage='startmessage' bind:completemessage="completemessage" url='{{url}}' />
</view>
/**index.wxss**/
.hidden{
/* opacity: 0; */
}
\ No newline at end of file
{
"setting": {
"urlCheck": false,
"es6": true,
"enhance": true,
"postcss": true,
"preloadBackgroundData": false,
"minified": true,
"newFeature": true,
"coverView": true,
"nodeModules": false,
"autoAudits": false,
"showShadowRootInWxmlPanel": true,
"scopeDataCheck": false,
"uglifyFileName": false,
"checkInvalidKey": true,
"checkSiteMap": true,
"uploadWithSourceMap": true,
"compileHotReLoad": false,
"useMultiFrameRuntime": false,
"useApiHook": true,
"babelSetting": {
"ignore": [],
"disablePlugins": [],
"outputPath": ""
},
"enableEngineNative": false,
"useIsolateContext": true,
"useCompilerModule": true,
"userConfirmedUseCompilerModuleSwitch": false,
"packNpmManually": false,
"packNpmRelationList": [],
"minifyWXSS": true
},
"appid": "wxc2a5e8782fb56ad9",
"projectname": "fk_xcx",
"libVersion": "2.14.1",
"simulatorType": "wechat",
"simulatorPluginLibVersion": {},
"condition": {
"search": {
"list": []
},
"conversation": {
"list": []
},
"plugin": {
"list": []
},
"game": {
"list": []
},
"miniprogram": {
"list": [
{
"id": -1,
"name": "db guide",
"pathName": "pages/databaseGuide/databaseGuide"
}
]
}
}
}
\ No newline at end of file
{
"desc": "关于本文件的更多信息,请参考文档 https://developers.weixin.qq.com/miniprogram/dev/framework/sitemap.html",
"rules": [{
"action": "allow",
"page": "*"
}]
}
\ No newline at end of file
page {
background: #f6f6f6;
display: flex;
flex-direction: column;
justify-content: flex-start;
}
.list {
margin-top: 40rpx;
height: auto;
width: 100%;
background: #fff;
padding: 0 40rpx;
border: 1px solid rgba(0, 0, 0, 0.1);
border-left: none;
border-right: none;
transition: all 300ms ease;
display: flex;
flex-direction: column;
align-items: stretch;
box-sizing: border-box;
}
.list-item {
width: 100%;
padding: 0;
line-height: 104rpx;
font-size: 34rpx;
color: #007aff;
border-top: 1px solid rgba(0, 0, 0, 0.1);
display: flex;
flex-direction: row;
align-content: center;
justify-content: space-between;
box-sizing: border-box;
}
.list-item:first-child {
border-top: none;
}
.list-item image {
max-width: 100%;
max-height: 20vh;
margin: 20rpx 0;
}
.request-text {
color: #222;
padding: 20rpx 0;
font-size: 24rpx;
line-height: 36rpx;
word-break: break-all;
}
.guide {
width: 100%;
padding: 40rpx;
box-sizing: border-box;
display: flex;
flex-direction: column;
}
.guide .headline {
font-size: 34rpx;
font-weight: bold;
color: #555;
line-height: 40rpx;
}
.guide .p {
margin-top: 20rpx;
font-size: 28rpx;
line-height: 36rpx;
color: #666;
}
.guide .code {
margin-top: 20rpx;
font-size: 28rpx;
line-height: 36rpx;
color: #666;
background: white;
white-space: pre;
}
.guide .code-dark {
margin-top: 20rpx;
background: rgba(0, 0, 0, 0.8);
padding: 20rpx;
font-size: 28rpx;
line-height: 36rpx;
border-radius: 6rpx;
color: #fff;
white-space: pre
}
.guide image {
max-width: 100%;
}
.guide .image1 {
margin-top: 20rpx;
max-width: 100%;
width: 356px;
height: 47px;
}
.guide .image2 {
margin-top: 20rpx;
width: 264px;
height: 100px;
}
.guide .flat-image {
height: 100px;
}
.guide .code-image {
max-width: 100%;
}
.guide .copyBtn {
width: 180rpx;
font-size: 20rpx;
margin-top: 16rpx;
margin-left: 0;
}
.guide .nav {
margin-top: 50rpx;
display: flex;
flex-direction: row;
align-content: space-between;
}
.guide .nav .prev {
margin-left: unset;
}
.guide .nav .next {
margin-right: unset;
}
//const host='http://ljj.dev.neoteched.com' //开发
const host='https://winterfell-alpha.neoteched.com' //测试
export const request=({url,method,header,success,fail})=>{
if(!url){
console.error('url不能为空')
return
}
wx.request({
url: host+url,
method: method||"GET",
header: header||{
'content-type': 'application/json',
},
success: success||(res=>{
console.log("成功");
console.log(res);
}),
fail:fail||(function(res){
console.log(res);
})
})
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment