├── miniprogram ├── pages │ ├── near │ │ ├── near.json │ │ ├── near.wxml │ │ ├── near.wxss │ │ └── near.js │ ├── user │ │ ├── user.json │ │ ├── user.wxss │ │ ├── user.wxml │ │ └── user.js │ ├── editUserinfo │ │ ├── editUserinfo.json │ │ ├── head │ │ │ ├── head.json │ │ │ ├── head.wxml │ │ │ ├── head.wxss │ │ │ └── head.js │ │ ├── name │ │ │ ├── name.json │ │ │ ├── name.wxml │ │ │ ├── name.wxss │ │ │ └── name.js │ │ ├── phone │ │ │ ├── phone.json │ │ │ ├── phone.wxml │ │ │ ├── phone.wxss │ │ │ └── phone.js │ │ ├── location │ │ │ ├── location.json │ │ │ ├── location.wxss │ │ │ ├── location.wxml │ │ │ └── location.js │ │ ├── weixin │ │ │ ├── weixin.json │ │ │ ├── weixin.wxml │ │ │ ├── weixin.wxss │ │ │ └── weixin.js │ │ ├── signature │ │ │ ├── signature.json │ │ │ ├── signature.wxml │ │ │ ├── signature.wxss │ │ │ └── signature.js │ │ ├── editUserinfo.wxss │ │ ├── editUserinfo.js │ │ └── editUserinfo.wxml │ ├── friendList │ │ ├── friendList.json │ │ ├── friendList.wxml │ │ ├── friendList.wxss │ │ └── friendList.js │ ├── index │ │ ├── index.json │ │ ├── user-unlogin.png │ │ ├── index.wxss │ │ ├── index.wxml │ │ └── index.js │ ├── message │ │ ├── message.json │ │ ├── message.wxss │ │ ├── message.wxml │ │ └── message.js │ └── detail │ │ ├── detail.json │ │ ├── detail.wxss │ │ ├── detail.wxml │ │ └── detail.js ├── app.wxss ├── components │ ├── callPhone │ │ ├── callPhone.wxss │ │ ├── callPhone.json │ │ ├── callPhone.wxml │ │ └── callPhone.js │ ├── copyText │ │ ├── copyText.wxss │ │ ├── copyText.json │ │ ├── copyText.wxml │ │ └── copyText.js │ ├── search │ │ ├── search.json │ │ ├── search.wxml │ │ ├── search.wxss │ │ └── search.js │ └── removeList │ │ ├── removeList.json │ │ ├── removeList.wxml │ │ ├── removeList.wxss │ │ └── removeList.js ├── images │ ├── tabbar │ │ ├── 我的.png │ │ ├── 消息.png │ │ ├── 附近.png │ │ ├── 首页.png │ │ ├── 我的_active.png │ │ ├── 消息_active.png │ │ ├── 附近_active.png │ │ └── 首页_active.png │ └── user │ │ └── user-unlogin.png ├── sitemap.json ├── utils │ ├── filter.wxs │ └── utils.js ├── app.js ├── app.json └── style │ ├── guide.wxss │ └── icon │ └── iconfont.wxss ├── cloudfunctions ├── login │ ├── config.json │ ├── package.json │ └── index.js └── update │ ├── config.json │ ├── package.json │ └── index.js ├── README.md └── project.config.json /miniprogram/pages/near/near.json: -------------------------------------------------------------------------------- 1 | { 2 | "usingComponents": {} 3 | } -------------------------------------------------------------------------------- /miniprogram/pages/user/user.json: -------------------------------------------------------------------------------- 1 | { 2 | "usingComponents": {} 3 | } -------------------------------------------------------------------------------- /miniprogram/pages/editUserinfo/editUserinfo.json: -------------------------------------------------------------------------------- 1 | { 2 | "usingComponents": {} 3 | } -------------------------------------------------------------------------------- /miniprogram/pages/editUserinfo/head/head.json: -------------------------------------------------------------------------------- 1 | { 2 | "usingComponents": {} 3 | } -------------------------------------------------------------------------------- /miniprogram/pages/editUserinfo/name/name.json: -------------------------------------------------------------------------------- 1 | { 2 | "usingComponents": {} 3 | } -------------------------------------------------------------------------------- /miniprogram/pages/editUserinfo/phone/phone.json: -------------------------------------------------------------------------------- 1 | { 2 | "usingComponents": {} 3 | } -------------------------------------------------------------------------------- /miniprogram/pages/friendList/friendList.json: -------------------------------------------------------------------------------- 1 | { 2 | "usingComponents": {} 3 | } -------------------------------------------------------------------------------- /miniprogram/app.wxss: -------------------------------------------------------------------------------- 1 | /**app.wxss**/ 2 | @import "style/icon/iconfont.wxss" 3 | 4 | 5 | -------------------------------------------------------------------------------- /miniprogram/components/callPhone/callPhone.wxss: -------------------------------------------------------------------------------- 1 | /* components/callPhone/callPhone.wxss */ -------------------------------------------------------------------------------- /miniprogram/components/copyText/copyText.wxss: -------------------------------------------------------------------------------- 1 | /* components/copyText/copyText.wxss */ -------------------------------------------------------------------------------- /miniprogram/pages/editUserinfo/location/location.json: -------------------------------------------------------------------------------- 1 | { 2 | "usingComponents": {} 3 | } -------------------------------------------------------------------------------- /miniprogram/pages/editUserinfo/weixin/weixin.json: -------------------------------------------------------------------------------- 1 | { 2 | "usingComponents": {} 3 | } -------------------------------------------------------------------------------- /miniprogram/pages/editUserinfo/signature/signature.json: -------------------------------------------------------------------------------- 1 | { 2 | "usingComponents": {} 3 | } -------------------------------------------------------------------------------- /cloudfunctions/login/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "permissions": { 3 | "openapi": [ 4 | ] 5 | } 6 | } -------------------------------------------------------------------------------- /cloudfunctions/update/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "permissions": { 3 | "openapi": [ 4 | ] 5 | } 6 | } -------------------------------------------------------------------------------- /miniprogram/components/search/search.json: -------------------------------------------------------------------------------- 1 | { 2 | "component": true, 3 | "usingComponents": {} 4 | } -------------------------------------------------------------------------------- /miniprogram/components/callPhone/callPhone.json: -------------------------------------------------------------------------------- 1 | { 2 | "component": true, 3 | "usingComponents": {} 4 | } -------------------------------------------------------------------------------- /miniprogram/components/copyText/copyText.json: -------------------------------------------------------------------------------- 1 | { 2 | "component": true, 3 | "usingComponents": {} 4 | } -------------------------------------------------------------------------------- /miniprogram/components/removeList/removeList.json: -------------------------------------------------------------------------------- 1 | { 2 | "component": true, 3 | "usingComponents": {} 4 | } -------------------------------------------------------------------------------- /miniprogram/images/tabbar/我的.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tdsq-lb/miaomiao/HEAD/miniprogram/images/tabbar/我的.png -------------------------------------------------------------------------------- /miniprogram/images/tabbar/消息.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tdsq-lb/miaomiao/HEAD/miniprogram/images/tabbar/消息.png -------------------------------------------------------------------------------- /miniprogram/images/tabbar/附近.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tdsq-lb/miaomiao/HEAD/miniprogram/images/tabbar/附近.png -------------------------------------------------------------------------------- /miniprogram/images/tabbar/首页.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tdsq-lb/miaomiao/HEAD/miniprogram/images/tabbar/首页.png -------------------------------------------------------------------------------- /miniprogram/pages/index/index.json: -------------------------------------------------------------------------------- 1 | { 2 | "usingComponents": { 3 | "search": "/components/search/search" 4 | } 5 | } -------------------------------------------------------------------------------- /miniprogram/images/tabbar/我的_active.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tdsq-lb/miaomiao/HEAD/miniprogram/images/tabbar/我的_active.png -------------------------------------------------------------------------------- /miniprogram/images/tabbar/消息_active.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tdsq-lb/miaomiao/HEAD/miniprogram/images/tabbar/消息_active.png -------------------------------------------------------------------------------- /miniprogram/images/tabbar/附近_active.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tdsq-lb/miaomiao/HEAD/miniprogram/images/tabbar/附近_active.png -------------------------------------------------------------------------------- /miniprogram/images/tabbar/首页_active.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tdsq-lb/miaomiao/HEAD/miniprogram/images/tabbar/首页_active.png -------------------------------------------------------------------------------- /miniprogram/images/user/user-unlogin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tdsq-lb/miaomiao/HEAD/miniprogram/images/user/user-unlogin.png -------------------------------------------------------------------------------- /miniprogram/pages/index/user-unlogin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tdsq-lb/miaomiao/HEAD/miniprogram/pages/index/user-unlogin.png -------------------------------------------------------------------------------- /miniprogram/pages/message/message.json: -------------------------------------------------------------------------------- 1 | { 2 | "usingComponents": { 3 | "remove-list": "/components/removeList/removeList" 4 | } 5 | } -------------------------------------------------------------------------------- /miniprogram/pages/editUserinfo/location/location.wxss: -------------------------------------------------------------------------------- 1 | /* miniprogram/pages/editUserinfo/location/location.wxss */ 2 | .location{ 3 | padding: 20rpx; 4 | } -------------------------------------------------------------------------------- /miniprogram/pages/message/message.wxss: -------------------------------------------------------------------------------- 1 | /* miniprogram/pages/message/message.wxss */ 2 | .message { 3 | padding: 20rpx; 4 | } 5 | 6 | .message-text { 7 | margin: 30rpx; 8 | } -------------------------------------------------------------------------------- /miniprogram/components/copyText/copyText.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /miniprogram/pages/detail/detail.json: -------------------------------------------------------------------------------- 1 | { 2 | "usingComponents": { 3 | "call-phone":"/components/callPhone/callPhone", 4 | "copy-text":"/components/copyText/copyText" 5 | } 6 | } -------------------------------------------------------------------------------- /miniprogram/components/callPhone/callPhone.wxml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /miniprogram/sitemap.json: -------------------------------------------------------------------------------- 1 | { 2 | "desc": "关于本文件的更多信息,请参考文档 https://developers.weixin.qq.com/miniprogram/dev/framework/sitemap.html", 3 | "rules": [{ 4 | "action": "allow", 5 | "page": "*" 6 | }] 7 | } -------------------------------------------------------------------------------- /miniprogram/pages/editUserinfo/location/location.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 开启共享位置: 4 | 5 | -------------------------------------------------------------------------------- /miniprogram/pages/near/near.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | -------------------------------------------------------------------------------- /miniprogram/pages/near/near.wxss: -------------------------------------------------------------------------------- 1 | /* miniprogram/pages/near/near.wxss */ 2 | .map { 3 | position: absolute; 4 | left: 0; 5 | top: 0; 6 | width: 100%; 7 | height: 100%; 8 | } 9 | 10 | .map map { 11 | width: 100%; 12 | height: 100%; 13 | } -------------------------------------------------------------------------------- /miniprogram/pages/editUserinfo/phone/phone.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /miniprogram/pages/editUserinfo/weixin/weixin.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /miniprogram/pages/editUserinfo/signature/signature.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /miniprogram/pages/editUserinfo/phone/phone.wxss: -------------------------------------------------------------------------------- 1 | /* miniprogram/pages/editUserinfo/phone/phone.wxss */ 2 | .phone { 3 | padding: 20rpx; 4 | } 5 | 6 | .phone input { 7 | border: 1px solid #cccccc; 8 | padding: 20rpx; 9 | border-radius: 10rpx; 10 | } 11 | 12 | .phone button { 13 | margin-top: 20rpx; 14 | } -------------------------------------------------------------------------------- /miniprogram/pages/editUserinfo/weixin/weixin.wxss: -------------------------------------------------------------------------------- 1 | /* miniprogram/pages/editUserinfo/weixin/weixin.wxss */ 2 | .weixin { 3 | padding: 20rpx; 4 | } 5 | 6 | .weixin input { 7 | border: 1px solid #cccccc; 8 | padding: 20rpx; 9 | border-radius: 10rpx; 10 | } 11 | 12 | .weixin button { 13 | margin-top: 20rpx; 14 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 云开发 quickstart 2 | 3 | 这是云开发的快速启动指引,其中演示了如何上手使用云开发的三大基础能力: 4 | 5 | - 数据库:一个既可在小程序前端操作,也能在云函数中读写的 JSON 文档型数据库 6 | - 文件存储:在小程序前端直接上传/下载云端文件,在云开发控制台可视化管理 7 | - 云函数:在云端运行的代码,微信私有协议天然鉴权,开发者只需编写业务逻辑代码 8 | 9 | ## 参考文档 10 | 11 | - [云开发文档](https://developers.weixin.qq.com/miniprogram/dev/wxcloud/basis/getting-started.html) 12 | 13 | -------------------------------------------------------------------------------- /cloudfunctions/update/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "lin", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "", 10 | "license": "ISC", 11 | "dependencies": { 12 | "wx-server-sdk": "~2.3.2" 13 | } 14 | } -------------------------------------------------------------------------------- /miniprogram/pages/editUserinfo/signature/signature.wxss: -------------------------------------------------------------------------------- 1 | /* miniprogram/pages/editUserinfo/signature/signature.wxss */ 2 | .signature { 3 | padding: 20rpx; 4 | } 5 | 6 | .signature input { 7 | border: 1px solid #cccccc; 8 | padding: 20rpx; 9 | border-radius: 10rpx; 10 | } 11 | 12 | .signature button { 13 | margin-top: 20rpx; 14 | } -------------------------------------------------------------------------------- /cloudfunctions/login/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "login", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "", 10 | "license": "ISC", 11 | "dependencies": { 12 | "wx-server-sdk": "~2.3.2" 13 | } 14 | } -------------------------------------------------------------------------------- /cloudfunctions/login/index.js: -------------------------------------------------------------------------------- 1 | // 云函数入口文件 2 | const cloud = require('wx-server-sdk') 3 | 4 | cloud.init() 5 | 6 | // 云函数入口函数 7 | exports.main = async (event, context) => { 8 | const wxContext = cloud.getWXContext() 9 | 10 | return { 11 | event, 12 | openid: wxContext.OPENID, 13 | appid: wxContext.APPID, 14 | unionid: wxContext.UNIONID, 15 | } 16 | } -------------------------------------------------------------------------------- /miniprogram/utils/filter.wxs: -------------------------------------------------------------------------------- 1 | var wprdSplit = function (word) { 2 | if (word.length > 4) { 3 | word = word.substring(0, 4) + '...'; 4 | } 5 | return word 6 | } 7 | 8 | var unitFormat = function (number) { 9 | if (number >= 1000) { 10 | number = (number / 1000).toFixed(1) + 'k' 11 | } 12 | return number 13 | } 14 | 15 | module.exports = { 16 | wprdSplit: wprdSplit, 17 | unitFormat: unitFormat 18 | } -------------------------------------------------------------------------------- /miniprogram/pages/editUserinfo/head/head.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /miniprogram/pages/editUserinfo/editUserinfo.wxss: -------------------------------------------------------------------------------- 1 | /* miniprogram/pages/editUserinfo/editUserinfo.wxss */ 2 | .editUserinfo{ 3 | padding: 30rpx 20rpx; 4 | } 5 | .editUserinfo-list-item { 6 | height: 70rpx; 7 | border-bottom: 1px #b4b5b6 dashed; 8 | padding: 12rpx; 9 | display: flex; 10 | align-items: center; 11 | justify-content: space-between; 12 | } 13 | .editUserinfo-list-tips{ 14 | color: red; 15 | margin-left: 20rpx; 16 | font-size: 20rpx; 17 | } -------------------------------------------------------------------------------- /miniprogram/pages/message/message.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 暂无消息 5 | 6 | 7 | 消息列表 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /miniprogram/pages/editUserinfo/name/name.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /miniprogram/components/removeList/removeList.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | {{userMseeage.nickName}} 4 | 5 | 6 | 7 | 删除 8 | -------------------------------------------------------------------------------- /miniprogram/pages/editUserinfo/name/name.wxss: -------------------------------------------------------------------------------- 1 | /* miniprogram/pages/editUserinfo/name/name.wxss */ 2 | .name { 3 | padding: 20rpx; 4 | } 5 | 6 | .name-customize input { 7 | border: 1px solid #cccccc; 8 | padding: 20rpx; 9 | border-radius: 10rpx; 10 | } 11 | 12 | .btn { 13 | width: 100%; 14 | display: flex; 15 | justify-content: space-between; 16 | margin-top: 30rpx; 17 | text-align: center; 18 | } 19 | 20 | .btn button { 21 | width: 40% !important; 22 | font-size: 26rpx; 23 | line-height: 50rpx; 24 | } -------------------------------------------------------------------------------- /miniprogram/utils/utils.js: -------------------------------------------------------------------------------- 1 | const db = wx.cloud.database() 2 | const app = getApp() 3 | 4 | const changdata = (id, data) => { 5 | console.log(id, data) 6 | wx.showLoading({ 7 | title: '更新中', 8 | }) 9 | db.collection('users').doc(id).update({ 10 | data 11 | }).then(res => { 12 | wx.hideLoading() 13 | wx.showToast({ 14 | title: '更新成功', 15 | }) 16 | app.userInfo = Object.assign(app.userInfo, data) 17 | console.log(res) 18 | }) 19 | } 20 | 21 | module.exports = { 22 | changdata 23 | } -------------------------------------------------------------------------------- /miniprogram/pages/friendList/friendList.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 好友列表 4 | 5 | 6 | 7 | 8 | {{item.nickName}} 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /miniprogram/components/copyText/copyText.js: -------------------------------------------------------------------------------- 1 | // components/copyText/copyText.js 2 | Component({ 3 | /** 4 | * 组件的属性列表 5 | */ 6 | options: { 7 | styleIsolation: 'apply-shared' 8 | }, 9 | 10 | properties: { 11 | copyText: String 12 | }, 13 | 14 | /** 15 | * 组件的初始数据 16 | */ 17 | data: { 18 | 19 | }, 20 | 21 | /** 22 | * 组件的方法列表 23 | */ 24 | methods: { 25 | handleCopyText() { 26 | wx.setClipboardData({ 27 | data: this.data.copyText, 28 | success(res) { 29 | } 30 | }) 31 | } 32 | } 33 | }) -------------------------------------------------------------------------------- /miniprogram/components/callPhone/callPhone.js: -------------------------------------------------------------------------------- 1 | // components/callPhone/callPhone.js 2 | Component({ 3 | /** 4 | * 组件的属性列表 5 | */ 6 | 7 | options: { 8 | styleIsolation: 'apply-shared' 9 | }, 10 | 11 | properties: { // 接收父组件传过来的数据 12 | phoneNumber: String 13 | }, 14 | 15 | 16 | /** 17 | * 组件的初始数据 18 | */ 19 | data: { 20 | 21 | }, 22 | 23 | /** 24 | * 组件的方法列表 25 | */ 26 | methods: { 27 | handleCallPhone() { 28 | wx.makePhoneCall({ 29 | phoneNumber: this.data.phoneNumber //仅为示例,并非真实的电话号码 30 | }) 31 | } 32 | } 33 | }) -------------------------------------------------------------------------------- /miniprogram/app.js: -------------------------------------------------------------------------------- 1 | //app.js 2 | App({ 3 | onLaunch: function () { 4 | 5 | if (!wx.cloud) { 6 | console.error('请使用 2.2.3 或以上的基础库以使用云能力') 7 | } else { 8 | wx.cloud.init({ 9 | // env 参数说明: 10 | // env 参数决定接下来小程序发起的云开发调用(wx.cloud.xxx)会默认请求到哪个云环境的资源 11 | // 此处请填入环境 ID, 环境 ID 可打开云控制台查看 12 | // 如不填则使用默认环境(第一个创建的环境) 13 | env: 'dev-3gxahd06015e7858', 14 | traceUser: true, 15 | }) 16 | } 17 | 18 | this.globalData = {} 19 | this.userInfo = {} // 定义全局用户信息数据 20 | this.userMseeage = [] // 定义全局用户消息 21 | } 22 | }) -------------------------------------------------------------------------------- /miniprogram/pages/detail/detail.wxss: -------------------------------------------------------------------------------- 1 | /* miniprogram/pages/detail/detail.wxss */ 2 | .datail { 3 | padding: 20rpx; 4 | } 5 | 6 | .datail-list view { 7 | border-bottom: 1px dashed #b4b5b6; 8 | padding: 20rpx 0; 9 | } 10 | 11 | .datail-list view:first-child{ 12 | border: none; 13 | } 14 | 15 | .datail-list view image { 16 | width: 200rpx; 17 | height: 200rpx; 18 | border-radius: 50%; 19 | margin: 0 auto; 20 | display: block; 21 | margin-bottom: 40rpx; 22 | } 23 | 24 | .datail-list view .lable { 25 | width: 25%; 26 | display: inline-block; 27 | } 28 | 29 | button { 30 | margin-top: 100rpx; 31 | } -------------------------------------------------------------------------------- /miniprogram/pages/friendList/friendList.wxss: -------------------------------------------------------------------------------- 1 | /* miniprogram/pages/friendList/friendList.wxss */ 2 | /* miniprogram/pages/editUserinfo/editUserinfo.wxss */ 3 | .friendList { 4 | padding: 30rpx 20rpx; 5 | } 6 | 7 | .friendList-item { 8 | height: 100rpx; 9 | border-bottom: 1px #b4b5b6 dashed; 10 | padding: 12rpx; 11 | display: flex; 12 | align-items: center; 13 | justify-content: space-between; 14 | } 15 | 16 | .friendList-item image { 17 | width: 80rpx; 18 | height: 80rpx; 19 | border-radius: 50%; 20 | margin-right: 20rpx; 21 | } 22 | 23 | .friendList-item view { 24 | display: flex; 25 | align-items: center; 26 | } -------------------------------------------------------------------------------- /miniprogram/pages/editUserinfo/head/head.wxss: -------------------------------------------------------------------------------- 1 | /* miniprogram/pages/editUserinfo/head/head.wxss */ 2 | .head { 3 | padding: 20rpx; 4 | } 5 | 6 | .head-image { 7 | width: 200rpx; 8 | height: 200rpx; 9 | border-radius: 50%; 10 | background-color: #cccccc; 11 | margin: 0 auto; 12 | } 13 | 14 | .head-image image{ 15 | width: 100%; 16 | height: 100%; 17 | border-radius: 50%; 18 | } 19 | 20 | .btn { 21 | width: 100%; 22 | display: flex; 23 | justify-content: space-between; 24 | margin-top: 50rpx; 25 | text-align: center; 26 | } 27 | 28 | .btn button { 29 | width: 40% !important; 30 | font-size: 26rpx; 31 | line-height: 50rpx; 32 | } -------------------------------------------------------------------------------- /miniprogram/pages/user/user.wxss: -------------------------------------------------------------------------------- 1 | .user { 2 | padding: 10rpx; 3 | box-sizing: border-box; 4 | width: 100%; 5 | } 6 | 7 | .user-info { 8 | height: 150rpx; 9 | border: 1px #b4b5b6 solid; 10 | border-left: none; 11 | border-right: none; 12 | display: flex; 13 | align-items: center; 14 | box-sizing: border-box; 15 | } 16 | 17 | .user-info image { 18 | width: 100rpx; 19 | height: 100rpx; 20 | border-radius: 50%; 21 | overflow: hidden; 22 | } 23 | 24 | .user-info text { 25 | margin-left: 20rpx; 26 | } 27 | 28 | .user-list{ 29 | margin-top: 40rpx; 30 | } 31 | .user-list-item{ 32 | height: 70rpx; 33 | border-bottom: 1px #b4b5b6 dashed; 34 | padding: 12rpx; 35 | display: flex; 36 | align-items: center; 37 | justify-content: space-between; 38 | } -------------------------------------------------------------------------------- /miniprogram/components/removeList/removeList.wxss: -------------------------------------------------------------------------------- 1 | /* components/removeList/removeList.wxss */ 2 | .area { 3 | height: 100rpx; 4 | margin: 20rpx; 5 | position: relative; 6 | width: calc(100% - 40rpx); 7 | border-bottom: 1px dashed #b4b5b6; 8 | } 9 | 10 | .view { 11 | width: calc(100% - 100rpx); 12 | height: 100%; 13 | position: absolute; 14 | left: 100rpx; 15 | top: 0; 16 | line-height: 100rpx; 17 | text-indent: 10rpx; 18 | z-index: 2; 19 | background-color: white; 20 | } 21 | 22 | image { 23 | width: 100rpx; 24 | height: 100rpx; 25 | border-radius: 50%; 26 | position: absolute; 27 | left: 0; 28 | top: 0; 29 | z-index: 1; 30 | } 31 | 32 | .delete { 33 | width: 100rpx; 34 | height: 100rpx; 35 | color: white; 36 | position: absolute; 37 | right: 0; 38 | top: 0; 39 | z-index: 1; 40 | background-color: red; 41 | text-align: center; 42 | line-height: 100rpx; 43 | } -------------------------------------------------------------------------------- /miniprogram/pages/editUserinfo/editUserinfo.js: -------------------------------------------------------------------------------- 1 | // miniprogram/pages/editUserinfo/editUserinfo.js 2 | Page({ 3 | 4 | /** 5 | * 页面的初始数据 6 | */ 7 | data: { 8 | 9 | }, 10 | 11 | /** 12 | * 生命周期函数--监听页面加载 13 | */ 14 | onLoad: function (options) { 15 | 16 | }, 17 | 18 | /** 19 | * 生命周期函数--监听页面初次渲染完成 20 | */ 21 | onReady: function () { 22 | 23 | }, 24 | 25 | /** 26 | * 生命周期函数--监听页面显示 27 | */ 28 | onShow: function () { 29 | 30 | }, 31 | 32 | /** 33 | * 生命周期函数--监听页面隐藏 34 | */ 35 | onHide: function () { 36 | 37 | }, 38 | 39 | /** 40 | * 生命周期函数--监听页面卸载 41 | */ 42 | onUnload: function () { 43 | 44 | }, 45 | 46 | /** 47 | * 页面相关事件处理函数--监听用户下拉动作 48 | */ 49 | onPullDownRefresh: function () { 50 | 51 | }, 52 | 53 | /** 54 | * 页面上拉触底事件的处理函数 55 | */ 56 | onReachBottom: function () { 57 | 58 | }, 59 | 60 | /** 61 | * 用户点击右上角分享 62 | */ 63 | onShareAppMessage: function () { 64 | 65 | } 66 | }) -------------------------------------------------------------------------------- /cloudfunctions/update/index.js: -------------------------------------------------------------------------------- 1 | // 云函数入口文件 2 | const cloud = require('wx-server-sdk') 3 | 4 | cloud.init({ 5 | env: cloud.DYNAMIC_CURRENT_ENV 6 | }) 7 | 8 | const db = cloud.database() 9 | const _ = db.command 10 | 11 | // 所有更新的封装 注意 data更新内容不写死 所有data为前端传过来的字符串 由服务端进行解析处理 12 | exports.main = async (event, context) => { 13 | console.log(event, 'event ================>>>>>>') 14 | try { 15 | //判断event.data是否为 string 如果是 则把字符串转成js语句 执行 16 | if (typeof event.data == 'string') { 17 | event.data = eval('(' + event.data + ')') // eval 把字符串转成js语句 18 | } 19 | if (event.id) { 20 | return await db.collection(event.collection).doc(event.id) 21 | .update({ 22 | data: { 23 | ...event.data 24 | }, 25 | }) 26 | } else { 27 | return await db.collection(event.collection).where({ 28 | ...event.where 29 | }) 30 | .update({ 31 | data: { 32 | ...event.data 33 | }, 34 | }) 35 | } 36 | } catch (e) { 37 | console.error(e) 38 | } 39 | } -------------------------------------------------------------------------------- /miniprogram/pages/index/index.wxss: -------------------------------------------------------------------------------- 1 | .index-swiper { 2 | margin: 20rpx; 3 | height: 300rpx; 4 | border-radius: 10rpx; 5 | overflow: hidden; 6 | margin-top: 100rpx; 7 | } 8 | 9 | .index-swiper image { 10 | width: 100%; 11 | border-radius: 10rpx; 12 | overflow: hidden; 13 | } 14 | 15 | .index-tab { 16 | display: flex; 17 | } 18 | 19 | .index-tab view { 20 | flex: 1; 21 | text-align: center; 22 | padding: 10rpx; 23 | margin: 10rpx; 24 | } 25 | 26 | .index-tab view.active { 27 | border-bottom: 1px red solid; 28 | color: red; 29 | } 30 | 31 | .index-list { 32 | display: flex; 33 | flex-wrap: wrap; 34 | color: hotpink; 35 | } 36 | 37 | .index-list-item { 38 | width: 50%; 39 | margin: 10rpx 0; 40 | } 41 | 42 | .index-list-item image { 43 | width: 90%; 44 | height: 250rpx; 45 | margin: 0 auto; 46 | display: block; 47 | border-radius: 10rpx; 48 | } 49 | 50 | .index-list-text { 51 | width: 90%; 52 | display: flex; 53 | justify-content: space-between; 54 | margin: 0 auto; 55 | margin-top: 10rpx; 56 | font-size: 26rpx; 57 | } 58 | /* .index-list-text text:first-child{ 59 | background-color: black; 60 | } */ -------------------------------------------------------------------------------- /miniprogram/pages/user/user.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 欢迎您:{{nickName}} 5 | 6 | 7 | 8 | 9 | 10 | 编辑个人信息 11 | 12 | 13 | 14 | 15 | 16 | 查看好友列表 17 | 18 | 19 | 20 | 21 | 22 | 个人主页 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /miniprogram/pages/detail/detail.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 昵称: 9 | {{datail.nickName}} 10 | 11 | 12 | 个性签名: 13 | {{datail.signature}} 14 | 15 | 16 | 手机号: 17 | 18 | {{datail.phoneNumber}} 19 | 20 | 21 | 仅好友可见 22 | 23 | 24 | 微信号: 25 | 26 | {{datail.weixinNumber}} 27 | 28 | 29 | 仅好友可见 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /miniprogram/components/search/search.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 8 | 9 | 取消 10 | 11 | 12 | 历史记录 13 | 14 | 15 | 16 | {{item}} 17 | 18 | 20 | 21 | 22 | 23 | {{item.nickName}} 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /miniprogram/pages/index/index.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 推荐 13 | 最新 14 | 15 | 16 | 17 | 18 | 19 | 20 | {{m1.wprdSplit(item.nickName)}} 21 | 22 | 23 | {{m1.unitFormat(item.links)}} 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /miniprogram/pages/friendList/friendList.js: -------------------------------------------------------------------------------- 1 | // miniprogram/pages/friendList/friendList.js 2 | const app = getApp() 3 | const db = wx.cloud.database() 4 | Page({ 5 | 6 | /** 7 | * 页面的初始数据 8 | */ 9 | data: { 10 | friendList: [] 11 | }, 12 | 13 | /** 14 | * 生命周期函数--监听页面加载 15 | */ 16 | onLoad: function (options) { 17 | 18 | }, 19 | 20 | /** 21 | * 生命周期函数--监听页面初次渲染完成 22 | */ 23 | onReady: function () { 24 | db.collection('users').where({ 25 | friendList: app.userInfo._id 26 | }).field({ 27 | userPhoto: true, 28 | nickName: true 29 | }).get().then((res) => { 30 | this.setData({ 31 | friendList: res.data 32 | }) 33 | }) 34 | }, 35 | 36 | /** 37 | * 生命周期函数--监听页面显示 38 | */ 39 | onShow: function () { 40 | 41 | }, 42 | 43 | /** 44 | * 生命周期函数--监听页面隐藏 45 | */ 46 | onHide: function () { 47 | 48 | }, 49 | 50 | /** 51 | * 生命周期函数--监听页面卸载 52 | */ 53 | onUnload: function () { 54 | 55 | }, 56 | 57 | /** 58 | * 页面相关事件处理函数--监听用户下拉动作 59 | */ 60 | onPullDownRefresh: function () { 61 | 62 | }, 63 | 64 | /** 65 | * 页面上拉触底事件的处理函数 66 | */ 67 | onReachBottom: function () { 68 | 69 | }, 70 | 71 | /** 72 | * 用户点击右上角分享 73 | */ 74 | onShareAppMessage: function () { 75 | 76 | } 77 | }) -------------------------------------------------------------------------------- /miniprogram/pages/editUserinfo/location/location.js: -------------------------------------------------------------------------------- 1 | // miniprogram/pages/editUserinfo/location/location.js 2 | const app = getApp() // 通过内置的getApp方法 拿到 app.js 中的this对象 3 | var utils = require('../../../utils/utils') 4 | Page({ 5 | 6 | /** 7 | * 页面的初始数据 8 | */ 9 | data: { 10 | isLocation: true 11 | }, 12 | 13 | /** 14 | * 生命周期函数--监听页面加载 15 | */ 16 | onLoad: function (options) { 17 | 18 | }, 19 | 20 | /** 21 | * 生命周期函数--监听页面初次渲染完成 22 | */ 23 | onReady: function () { 24 | this.setData({ 25 | isLocation: app.userInfo.isLocation 26 | }) 27 | }, 28 | 29 | /** 30 | * 生命周期函数--监听页面显示 31 | */ 32 | onShow: function () { 33 | 34 | }, 35 | 36 | /** 37 | * 生命周期函数--监听页面隐藏 38 | */ 39 | onHide: function () { 40 | 41 | }, 42 | 43 | /** 44 | * 生命周期函数--监听页面卸载 45 | */ 46 | onUnload: function () { 47 | 48 | }, 49 | 50 | /** 51 | * 页面相关事件处理函数--监听用户下拉动作 52 | */ 53 | onPullDownRefresh: function () { 54 | 55 | }, 56 | 57 | /** 58 | * 页面上拉触底事件的处理函数 59 | */ 60 | onReachBottom: function () { 61 | 62 | }, 63 | 64 | /** 65 | * 用户点击右上角分享 66 | */ 67 | onShareAppMessage: function () { 68 | 69 | }, 70 | switchChange(e) { 71 | this.setData({ 72 | isLocation : e.detail.value 73 | }) 74 | const id = app.userInfo._id 75 | const data = { 76 | isLocation: this.data.isLocation 77 | } 78 | utils.changdata(id, data) 79 | } 80 | }) -------------------------------------------------------------------------------- /miniprogram/pages/editUserinfo/phone/phone.js: -------------------------------------------------------------------------------- 1 | // miniprogram/pages/editUserinfo/phone/phone.js 2 | const app = getApp() // 通过内置的getApp方法 拿到 app.js 中的this对象 3 | var utils = require('../../../utils/utils') 4 | Page({ 5 | 6 | /** 7 | * 页面的初始数据 8 | */ 9 | data: { 10 | phoneNumber: '' 11 | }, 12 | 13 | /** 14 | * 生命周期函数--监听页面加载 15 | */ 16 | onLoad: function (options) { 17 | 18 | }, 19 | 20 | /** 21 | * 生命周期函数--监听页面初次渲染完成 22 | */ 23 | onReady: function () { 24 | this.setData({ 25 | phoneNumber: app.userInfo.phoneNumber 26 | }) 27 | }, 28 | 29 | /** 30 | * 生命周期函数--监听页面显示 31 | */ 32 | onShow: function () { 33 | 34 | }, 35 | 36 | /** 37 | * 生命周期函数--监听页面隐藏 38 | */ 39 | onHide: function () { 40 | 41 | }, 42 | 43 | /** 44 | * 生命周期函数--监听页面卸载 45 | */ 46 | onUnload: function () { 47 | 48 | }, 49 | 50 | /** 51 | * 页面相关事件处理函数--监听用户下拉动作 52 | */ 53 | onPullDownRefresh: function () { 54 | 55 | }, 56 | 57 | /** 58 | * 页面上拉触底事件的处理函数 59 | */ 60 | onReachBottom: function () { 61 | 62 | }, 63 | 64 | /** 65 | * 用户点击右上角分享 66 | */ 67 | onShareAppMessage: function () { 68 | 69 | }, 70 | handleText(e) { 71 | this.setData({ 72 | phoneNumber: e.detail.value 73 | }) 74 | }, 75 | handleBtn() { 76 | const id = app.userInfo._id 77 | const data = { 78 | phoneNumber: this.data.phoneNumber 79 | } 80 | utils.changdata(id, data) 81 | } 82 | }) -------------------------------------------------------------------------------- /miniprogram/pages/editUserinfo/weixin/weixin.js: -------------------------------------------------------------------------------- 1 | // miniprogram/pages/editUserinfo/weixin/weixin.js 2 | const app = getApp() // 通过内置的getApp方法 拿到 app.js 中的this对象 3 | var utils = require('../../../utils/utils') 4 | Page({ 5 | 6 | /** 7 | * 页面的初始数据 8 | */ 9 | data: { 10 | weixinNumber: '' 11 | }, 12 | 13 | /** 14 | * 生命周期函数--监听页面加载 15 | */ 16 | onLoad: function (options) { 17 | 18 | }, 19 | 20 | /** 21 | * 生命周期函数--监听页面初次渲染完成 22 | */ 23 | onReady: function () { 24 | this.setData({ 25 | weixinNumber: app.userInfo.weixinNumber 26 | }) 27 | }, 28 | 29 | /** 30 | * 生命周期函数--监听页面显示 31 | */ 32 | onShow: function () { 33 | 34 | }, 35 | 36 | /** 37 | * 生命周期函数--监听页面隐藏 38 | */ 39 | onHide: function () { 40 | 41 | }, 42 | 43 | /** 44 | * 生命周期函数--监听页面卸载 45 | */ 46 | onUnload: function () { 47 | 48 | }, 49 | 50 | /** 51 | * 页面相关事件处理函数--监听用户下拉动作 52 | */ 53 | onPullDownRefresh: function () { 54 | 55 | }, 56 | 57 | /** 58 | * 页面上拉触底事件的处理函数 59 | */ 60 | onReachBottom: function () { 61 | 62 | }, 63 | 64 | /** 65 | * 用户点击右上角分享 66 | */ 67 | onShareAppMessage: function () { 68 | 69 | }, 70 | handleText(e) { 71 | this.setData({ 72 | weixinNumber: e.detail.value 73 | }) 74 | }, 75 | handleBtn() { 76 | const id = app.userInfo._id 77 | const data = { 78 | weixinNumber: this.data.weixinNumber 79 | } 80 | utils.changdata(id, data) 81 | } 82 | }) -------------------------------------------------------------------------------- /miniprogram/pages/editUserinfo/signature/signature.js: -------------------------------------------------------------------------------- 1 | // miniprogram/pages/editUserinfo/signature/signature.js 2 | const app = getApp() // 通过内置的getApp方法 拿到 app.js 中的this对象 3 | const db = wx.cloud.database() 4 | var utils = require('../../../utils/utils') 5 | Page({ 6 | 7 | /** 8 | * 页面的初始数据 9 | */ 10 | data: { 11 | signature: '', 12 | }, 13 | 14 | /** 15 | * 生命周期函数--监听页面加载 16 | */ 17 | onLoad: function (options) { 18 | 19 | }, 20 | 21 | /** 22 | * 生命周期函数--监听页面初次渲染完成 23 | */ 24 | onReady: function () { 25 | this.setData({ 26 | signature: app.userInfo.signature 27 | }) 28 | }, 29 | 30 | /** 31 | * 生命周期函数--监听页面显示 32 | */ 33 | onShow: function () { 34 | 35 | }, 36 | 37 | /** 38 | * 生命周期函数--监听页面隐藏 39 | */ 40 | onHide: function () { 41 | 42 | }, 43 | 44 | /** 45 | * 生命周期函数--监听页面卸载 46 | */ 47 | onUnload: function () { 48 | 49 | }, 50 | 51 | /** 52 | * 页面相关事件处理函数--监听用户下拉动作 53 | */ 54 | onPullDownRefresh: function () { 55 | 56 | }, 57 | 58 | /** 59 | * 页面上拉触底事件的处理函数 60 | */ 61 | onReachBottom: function () { 62 | 63 | }, 64 | 65 | /** 66 | * 用户点击右上角分享 67 | */ 68 | onShareAppMessage: function () { 69 | 70 | }, 71 | handleText(e) { 72 | let value = e.detail.value 73 | this.setData({ 74 | signature: value 75 | }) 76 | }, 77 | handleBtn() { 78 | const id = app.userInfo._id 79 | const data = { 80 | signature: this.data.signature 81 | } 82 | utils.changdata(id, data) 83 | } 84 | }) -------------------------------------------------------------------------------- /miniprogram/pages/editUserinfo/name/name.js: -------------------------------------------------------------------------------- 1 | // miniprogram/pages/editUserinfo/name/name.js 2 | const app = getApp() 3 | var utils = require('../../../utils/utils') 4 | Page({ 5 | 6 | /** 7 | * 页面的初始数据 8 | */ 9 | data: { 10 | nickName: '', 11 | id: '' 12 | }, 13 | 14 | /** 15 | * 生命周期函数--监听页面加载 16 | */ 17 | onLoad: function (options) {}, 18 | 19 | /** 20 | * 生命周期函数--监听页面初次渲染完成 21 | */ 22 | onReady: function () { 23 | this.setData({ 24 | nickName: app.userInfo.nickName, 25 | id: app.userInfo._id 26 | }) 27 | }, 28 | 29 | /** 30 | * 生命周期函数--监听页面显示 31 | */ 32 | onShow: function () { 33 | 34 | }, 35 | 36 | /** 37 | * 生命周期函数--监听页面隐藏 38 | */ 39 | onHide: function () { 40 | 41 | }, 42 | 43 | /** 44 | * 生命周期函数--监听页面卸载 45 | */ 46 | onUnload: function () { 47 | 48 | }, 49 | 50 | /** 51 | * 页面相关事件处理函数--监听用户下拉动作 52 | */ 53 | onPullDownRefresh: function () { 54 | 55 | }, 56 | 57 | /** 58 | * 页面上拉触底事件的处理函数 59 | */ 60 | onReachBottom: function () { 61 | 62 | }, 63 | 64 | /** 65 | * 用户点击右上角分享 66 | */ 67 | onShareAppMessage: function () { 68 | 69 | }, 70 | handleText(e) { 71 | this.setData({ 72 | nickName: e.detail.value 73 | }) 74 | }, 75 | bindGetUserInfo(e) { 76 | this.setData({ 77 | nickName: e.detail.userInfo.nickName 78 | }) 79 | const data = { 80 | nickName: this.data.nickName 81 | } 82 | utils.changdata(this.data.id, data) 83 | }, 84 | handleBtn() { 85 | const data = { 86 | nickName: this.data.nickName 87 | } 88 | utils.changdata(this.data.id, data) 89 | } 90 | }) -------------------------------------------------------------------------------- /miniprogram/components/search/search.wxss: -------------------------------------------------------------------------------- 1 | /* components/search/search.wxss */ 2 | .container { 3 | position: fixed; 4 | left: 0; 5 | top: 0; 6 | width: 100%; 7 | height: 100rpx; 8 | z-index: 999; 9 | overflow: hidden; 10 | } 11 | 12 | .containerFocus { 13 | position: fixed; 14 | left: 0; 15 | top: 0; 16 | width: 100%; 17 | height: 100%; 18 | z-index: 999; 19 | overflow: hidden; 20 | background-color: #ccc; 21 | } 22 | 23 | .search { 24 | display: flex; 25 | align-items: center; 26 | margin: 20rpx; 27 | } 28 | 29 | .search-text { 30 | display: flex; 31 | align-items: center; 32 | flex: 1; 33 | border: 1px solid #b4b5b6; 34 | border-radius: 10rpx; 35 | height: 60rpx; 36 | background-color: white; 37 | } 38 | 39 | .search-text input { 40 | flex: 1; 41 | } 42 | 43 | .search-text .iconsousuo1 { 44 | margin: 0 10rpx; 45 | } 46 | 47 | .search-cancel { 48 | margin: 0 10rpx; 49 | } 50 | 51 | .search-history { 52 | display: flex; 53 | justify-content: space-between; 54 | margin: 20rpx; 55 | margin-bottom: 30rpx; 56 | } 57 | 58 | .search-history-btn text { 59 | border: 1px solid #b4b5b6; 60 | padding: 10rpx 20rpx; 61 | margin: 10rpx; 62 | border-radius: 20rpx; 63 | background-color: white; 64 | } 65 | 66 | .searchList-item { 67 | height: 100rpx; 68 | border-bottom: 1px #b4b5b6 dashed; 69 | margin: 20rpx; 70 | display: flex; 71 | align-items: center; 72 | justify-content: space-between; 73 | } 74 | 75 | .searchList-item image { 76 | width: 80rpx; 77 | height: 80rpx; 78 | border-radius: 50%; 79 | margin-right: 20rpx; 80 | } 81 | 82 | .searchList-item view { 83 | display: flex; 84 | align-items: center; 85 | } -------------------------------------------------------------------------------- /miniprogram/pages/message/message.js: -------------------------------------------------------------------------------- 1 | // miniprogram/pages/message/message.js 2 | const app = getApp() 3 | Page({ 4 | 5 | /** 6 | * 页面的初始数据 7 | */ 8 | data: { 9 | logged: false, 10 | userMessage: [] 11 | }, 12 | 13 | /** 14 | * 生命周期函数--监听页面加载 15 | */ 16 | onLoad: function (options) { 17 | 18 | }, 19 | 20 | /** 21 | * 生命周期函数--监听页面初次渲染完成 22 | */ 23 | onReady: function () { 24 | 25 | }, 26 | 27 | /** 28 | * 生命周期函数--监听页面显示 29 | */ 30 | onShow: function () { 31 | if (app.userInfo._id) { 32 | this.setData({ 33 | logged: true, 34 | userMessage: app.userMessage 35 | }) 36 | } else { 37 | wx.showToast({ 38 | title: '请先登录', 39 | duration: 2000, 40 | icon: 'none', 41 | success: () => { 42 | setTimeout(() => { 43 | wx.switchTab({ 44 | url: '/pages/user/user' 45 | }) 46 | }, 2000) 47 | } 48 | }) 49 | } 50 | }, 51 | 52 | /** 53 | * 生命周期函数--监听页面隐藏 54 | */ 55 | onHide: function () { 56 | 57 | }, 58 | 59 | /** 60 | * 生命周期函数--监听页面卸载 61 | */ 62 | onUnload: function () { 63 | 64 | }, 65 | 66 | /** 67 | * 页面相关事件处理函数--监听用户下拉动作 68 | */ 69 | onPullDownRefresh: function () { 70 | 71 | }, 72 | 73 | /** 74 | * 页面上拉触底事件的处理函数 75 | */ 76 | onReachBottom: function () { 77 | 78 | }, 79 | 80 | /** 81 | * 用户点击右上角分享 82 | */ 83 | onShareAppMessage: function () { 84 | 85 | }, 86 | // 父子组件通信 事件 87 | onMyEvent(ev) { 88 | console.log(ev.detail) 89 | this.setData({ 90 | userMessage: [] 91 | }, () => { 92 | this.setData({ 93 | userMessage: ev.detail 94 | }) 95 | }) 96 | } 97 | }) -------------------------------------------------------------------------------- /miniprogram/pages/editUserinfo/editUserinfo.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 修改头像 6 | 7 | 8 | 9 | 10 | 11 | 修改昵称 12 | 13 | 14 | 15 | 16 | 17 | 修改个性签名 18 | 19 | 20 | 21 | 22 | 23 | 共享位置 24 | 25 | 26 | 27 | 28 | 29 | 设置手机号仅好友可见 30 | 31 | 32 | 33 | 34 | 35 | 设置微信号仅好友可见 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /miniprogram/app.json: -------------------------------------------------------------------------------- 1 | { 2 | "pages": [ 3 | "pages/index/index", 4 | "pages/near/near", 5 | "pages/message/message", 6 | "pages/user/user", 7 | "pages/editUserinfo/editUserinfo", 8 | "pages/friendList/friendList", 9 | "pages/detail/detail", 10 | "pages/editUserinfo/head/head", 11 | "pages/editUserinfo/name/name", 12 | "pages/editUserinfo/signature/signature", 13 | "pages/editUserinfo/location/location", 14 | "pages/editUserinfo/phone/phone", 15 | "pages/editUserinfo/weixin/weixin" 16 | ], 17 | "window": { 18 | "backgroundColor": "#F6F6F6", 19 | "backgroundTextStyle": "light", 20 | "navigationBarBackgroundColor": "#F6F6F6", 21 | "navigationBarTitleText": "云开发 QuickStart", 22 | "navigationBarTextStyle": "black" 23 | }, 24 | "tabBar": { 25 | "color": "#b2b5b6", 26 | "selectedColor": "#967bf5", 27 | "list": [{ 28 | "pagePath": "pages/index/index", 29 | "text": "首页", 30 | "iconPath": "./images/tabbar/首页.png", 31 | "selectedIconPath": "./images/tabbar/首页_active.png" 32 | }, 33 | { 34 | "pagePath": "pages/near/near", 35 | "text": "附近", 36 | "iconPath": "./images/tabbar/附近.png", 37 | "selectedIconPath": "./images/tabbar/附近_active.png" 38 | }, 39 | { 40 | "pagePath": "pages/message/message", 41 | "text": "消息", 42 | "iconPath": "./images/tabbar/消息.png", 43 | "selectedIconPath": "./images/tabbar/消息_active.png" 44 | }, 45 | { 46 | "pagePath": "pages/user/user", 47 | "text": "我的", 48 | "iconPath": "./images/tabbar/我的.png", 49 | "selectedIconPath": "./images/tabbar/我的_active.png" 50 | } 51 | ] 52 | }, 53 | "permission": { 54 | "scope.userLocation": { 55 | "desc": "你的位置信息将用于小程序位置接口的效果展示" 56 | } 57 | }, 58 | "sitemapLocation": "sitemap.json", 59 | "style": "v2" 60 | } -------------------------------------------------------------------------------- /miniprogram/components/search/search.js: -------------------------------------------------------------------------------- 1 | // components/search/search.js 2 | const app = getApp() 3 | const db = wx.cloud.database() 4 | Component({ 5 | /** 6 | * 组件的属性列表 7 | */ 8 | options: { 9 | styleIsolation: 'apply-shared' 10 | }, 11 | properties: { 12 | 13 | }, 14 | 15 | /** 16 | * 组件的初始数据 17 | */ 18 | data: { 19 | isFocus: false, 20 | historyList: [], 21 | searchList: [], 22 | value: '' 23 | }, 24 | 25 | /** 26 | * 组件的方法列表 27 | */ 28 | methods: { 29 | // 点击光标 30 | handleFocus() { 31 | wx.getStorage({ 32 | key: 'searchHistory', 33 | success: (res) => { 34 | this.setData({ 35 | historyList: res.data 36 | }) 37 | } 38 | }) 39 | this.setData({ 40 | isFocus: true 41 | }) 42 | }, 43 | // 取消 44 | handleCancel() { 45 | this.setData({ 46 | isFocus: false, 47 | value: '', 48 | searchList: [] 49 | }) 50 | }, 51 | handleConfirm(e) { 52 | let value = e.detail.value 53 | let historyList = [...this.data.historyList] 54 | historyList.unshift(value) 55 | wx.setStorage({ 56 | key: "searchHistory", 57 | data: [...new Set(historyList)] 58 | }) 59 | this.changSearchList(value) 60 | this.setData({ 61 | value: '' 62 | }) 63 | }, 64 | handleDelte() { 65 | wx.removeStorage({ 66 | key: 'searchHistory', 67 | success: (res) => { 68 | this.setData({ 69 | historyList: [], 70 | value: '' 71 | }) 72 | } 73 | }) 74 | }, 75 | // 搜索 76 | changSearchList(value) { 77 | db.collection('users').where({ 78 | nickName: db.RegExp({ 79 | regexp: value, 80 | options: 'i', 81 | }) 82 | }).field({ 83 | userPhoto: true, 84 | nickName: true 85 | }).get().then((res) => { 86 | this.setData({ 87 | searchList: res.data 88 | }) 89 | }) 90 | }, 91 | handleHistoryBtn(e) { 92 | const value = e.target.dataset.value 93 | this.setData({ 94 | value 95 | }) 96 | this.changSearchList(value) 97 | } 98 | } 99 | }) -------------------------------------------------------------------------------- /miniprogram/pages/editUserinfo/head/head.js: -------------------------------------------------------------------------------- 1 | // miniprogram/pages/editUserinfo/head/head.js 2 | const app = getApp() 3 | var utils = require('../../../utils/utils') 4 | Page({ 5 | 6 | /** 7 | * 页面的初始数据 8 | */ 9 | data: { 10 | userPhoto: '', 11 | id: '' 12 | }, 13 | 14 | /** 15 | * 生命周期函数--监听页面加载 16 | */ 17 | onLoad: function (options) { 18 | 19 | }, 20 | 21 | /** 22 | * 生命周期函数--监听页面初次渲染完成 23 | */ 24 | onReady: function () { 25 | this.setData({ 26 | userPhoto: app.userInfo.userPhoto, 27 | id: app.userInfo._id 28 | }) 29 | }, 30 | 31 | /** 32 | * 生命周期函数--监听页面显示 33 | */ 34 | onShow: function () { 35 | 36 | }, 37 | 38 | /** 39 | * 生命周期函数--监听页面隐藏 40 | */ 41 | onHide: function () { 42 | 43 | }, 44 | 45 | /** 46 | * 生命周期函数--监听页面卸载 47 | */ 48 | onUnload: function () { 49 | 50 | }, 51 | 52 | /** 53 | * 页面相关事件处理函数--监听用户下拉动作 54 | */ 55 | onPullDownRefresh: function () { 56 | 57 | }, 58 | 59 | /** 60 | * 页面上拉触底事件的处理函数 61 | */ 62 | onReachBottom: function () { 63 | 64 | }, 65 | 66 | /** 67 | * 用户点击右上角分享 68 | */ 69 | onShareAppMessage: function () { 70 | 71 | }, 72 | handleUploadImage() { 73 | wx.chooseImage({ 74 | count: 1, 75 | sizeType: ['compressed'], 76 | sourceType: ['album', 'camera'], 77 | success: (res) => { 78 | // tempFilePath可以作为img标签的src属性显示图片 79 | const tempFilePaths = res.tempFilePaths[0] 80 | this.setData({ 81 | userPhoto: tempFilePaths 82 | }) 83 | } 84 | }) 85 | }, 86 | handleBtn() { 87 | const filePath = this.data.userPhoto 88 | const cloudPath = 'my-image' + new Date().getTime() + filePath.match(/\.[^.]+?$/)[0] 89 | wx.cloud.uploadFile({ 90 | cloudPath, 91 | filePath, 92 | success: (res) => { 93 | console.log(res) 94 | const data = { 95 | userPhoto: res.fileID 96 | } 97 | utils.changdata(this.data.id, data) 98 | } 99 | }) 100 | }, 101 | bindGetUserInfo(e) { 102 | this.setData({ 103 | userPhoto: e.detail.userInfo.avatarUrl 104 | }) 105 | const data = { 106 | userPhoto: e.detail.userInfo.avatarUrl 107 | } 108 | utils.changdata(this.data.id, data) 109 | console.log(e) 110 | } 111 | }) -------------------------------------------------------------------------------- /miniprogram/style/guide.wxss: -------------------------------------------------------------------------------- 1 | page { 2 | background: #f6f6f6; 3 | display: flex; 4 | flex-direction: column; 5 | justify-content: flex-start; 6 | } 7 | 8 | .list { 9 | margin-top: 40rpx; 10 | height: auto; 11 | width: 100%; 12 | background: #fff; 13 | padding: 0 40rpx; 14 | border: 1px solid rgba(0, 0, 0, 0.1); 15 | border-left: none; 16 | border-right: none; 17 | transition: all 300ms ease; 18 | display: flex; 19 | flex-direction: column; 20 | align-items: stretch; 21 | box-sizing: border-box; 22 | } 23 | 24 | .list-item { 25 | width: 100%; 26 | padding: 0; 27 | line-height: 104rpx; 28 | font-size: 34rpx; 29 | color: #007aff; 30 | border-top: 1px solid rgba(0, 0, 0, 0.1); 31 | display: flex; 32 | flex-direction: row; 33 | align-content: center; 34 | justify-content: space-between; 35 | box-sizing: border-box; 36 | } 37 | 38 | .list-item:first-child { 39 | border-top: none; 40 | } 41 | 42 | .list-item image { 43 | max-width: 100%; 44 | max-height: 20vh; 45 | margin: 20rpx 0; 46 | } 47 | 48 | .request-text { 49 | color: #222; 50 | padding: 20rpx 0; 51 | font-size: 24rpx; 52 | line-height: 36rpx; 53 | word-break: break-all; 54 | } 55 | 56 | .guide { 57 | width: 100%; 58 | padding: 40rpx; 59 | box-sizing: border-box; 60 | display: flex; 61 | flex-direction: column; 62 | } 63 | 64 | .guide .headline { 65 | font-size: 34rpx; 66 | font-weight: bold; 67 | color: #555; 68 | line-height: 40rpx; 69 | } 70 | 71 | .guide .p { 72 | margin-top: 20rpx; 73 | font-size: 28rpx; 74 | line-height: 36rpx; 75 | color: #666; 76 | } 77 | 78 | .guide .code { 79 | margin-top: 20rpx; 80 | font-size: 28rpx; 81 | line-height: 36rpx; 82 | color: #666; 83 | background: white; 84 | white-space: pre; 85 | } 86 | 87 | .guide .code-dark { 88 | margin-top: 20rpx; 89 | background: rgba(0, 0, 0, 0.8); 90 | padding: 20rpx; 91 | font-size: 28rpx; 92 | line-height: 36rpx; 93 | border-radius: 6rpx; 94 | color: #fff; 95 | white-space: pre 96 | } 97 | 98 | .guide image { 99 | max-width: 100%; 100 | } 101 | 102 | .guide .image1 { 103 | margin-top: 20rpx; 104 | max-width: 100%; 105 | width: 356px; 106 | height: 47px; 107 | } 108 | 109 | .guide .image2 { 110 | margin-top: 20rpx; 111 | width: 264px; 112 | height: 100px; 113 | } 114 | 115 | .guide .flat-image { 116 | height: 100px; 117 | } 118 | 119 | .guide .code-image { 120 | max-width: 100%; 121 | } 122 | 123 | .guide .copyBtn { 124 | width: 180rpx; 125 | font-size: 20rpx; 126 | margin-top: 16rpx; 127 | margin-left: 0; 128 | } 129 | 130 | .guide .nav { 131 | margin-top: 50rpx; 132 | display: flex; 133 | flex-direction: row; 134 | align-content: space-between; 135 | } 136 | 137 | .guide .nav .prev { 138 | margin-left: unset; 139 | } 140 | 141 | .guide .nav .next { 142 | margin-right: unset; 143 | } 144 | 145 | -------------------------------------------------------------------------------- /miniprogram/components/removeList/removeList.js: -------------------------------------------------------------------------------- 1 | // components/removeList/removeList.js 2 | const app = getApp() 3 | const db = wx.cloud.database() 4 | const _ = db.command 5 | Component({ 6 | /** 7 | * 组件的属性列表 8 | */ 9 | properties: { 10 | messageId: String 11 | }, 12 | 13 | /** 14 | * 组件的初始数据 15 | */ 16 | data: { 17 | userMseeage: {} 18 | }, 19 | 20 | /** 21 | * 组件的方法列表 22 | */ 23 | methods: { 24 | handleDelMessage() { 25 | wx.showModal({ 26 | title: '提示消息', 27 | content: '是否删除', 28 | success: (res) => { 29 | if (res.confirm) { 30 | this.removeMessage() 31 | } else if (res.cancel) { 32 | console.log('用户点击取消') 33 | } 34 | } 35 | }) 36 | }, 37 | handleAddFrid() { 38 | wx.showModal({ 39 | title: '提示消息', 40 | content: '申请好友', 41 | success: (res) => { 42 | if (res.confirm) { 43 | // 更新自己的 在客户端完成 44 | db.collection('users').doc(app.userInfo._id).update({ 45 | data: { 46 | friendList: _.unshift(this.data.messageId) 47 | } 48 | }).then((res) => {}) 49 | // 更新其他人的 在服务端完成 50 | wx.cloud.callFunction({ 51 | name: 'update', 52 | data: { 53 | collection: 'users', 54 | id: this.data.messageId, 55 | data: `{friendList:_.unshift('${app.userInfo._id}')}` 56 | } 57 | }).then((res) => { 58 | console.log(res) 59 | }) 60 | this.removeMessage() 61 | } else if (res.cancel) { 62 | console.log('用户点击取消') 63 | } 64 | } 65 | }) 66 | }, 67 | removeMessage() { 68 | db.collection('message').where({ 69 | userId: app.userInfo._id 70 | }).get().then((res) => { 71 | let list = res.data[0].list 72 | list = list.filter((val, i) => { 73 | return val != this.data.messageId 74 | }) 75 | // 调用云函数 76 | wx.cloud.callFunction({ 77 | name: 'update', 78 | data: { 79 | collection: 'message', 80 | where: { 81 | userId: app.userInfo._id 82 | }, 83 | data: { 84 | list 85 | } 86 | } 87 | }).then((res) => { 88 | console.log(res) 89 | this.triggerEvent('myevent', list) 90 | }) 91 | }) 92 | } 93 | }, 94 | lifetimes: { 95 | attached: function () { 96 | // 在组件实例进入页面节点树时执行 97 | db.collection('users').doc(this.data.messageId).field({ 98 | userPhoto: true, 99 | nickName: true 100 | }).get().then((res) => { 101 | this.setData({ 102 | userMseeage: res.data 103 | }) 104 | }) 105 | } 106 | }, 107 | }) -------------------------------------------------------------------------------- /miniprogram/pages/index/index.js: -------------------------------------------------------------------------------- 1 | //index.js 2 | const app = getApp() 3 | const db = wx.cloud.database() 4 | Page({ 5 | data: { 6 | imgUrls: [ 7 | "https://dss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=151472226,3497652000&fm=26&gp=0.jpg", 8 | "https://dss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=151472226,3497652000&fm=26&gp=0.jpg", 9 | "https://dss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=151472226,3497652000&fm=26&gp=0.jpg" 10 | ], 11 | listData: [], 12 | current: 'links' 13 | }, 14 | 15 | /** 16 | * 生命周期函数--监听页面加载 17 | */ 18 | onLoad: function (options) { 19 | 20 | }, 21 | 22 | /** 23 | * 生命周期函数--监听页面初次渲染完成 24 | */ 25 | onReady: function () { 26 | this.initData() 27 | }, 28 | 29 | /** 30 | * 生命周期函数--监听页面显示 31 | */ 32 | onShow: function () { 33 | 34 | }, 35 | 36 | /** 37 | * 生命周期函数--监听页面隐藏 38 | */ 39 | onHide: function () { 40 | 41 | }, 42 | 43 | /** 44 | * 生命周期函数--监听页面卸载 45 | */ 46 | onUnload: function () { 47 | 48 | }, 49 | 50 | /** 51 | * 页面相关事件处理函数--监听用户下拉动作 52 | */ 53 | onPullDownRefresh: function () { 54 | 55 | }, 56 | 57 | /** 58 | * 页面上拉触底事件的处理函数 59 | */ 60 | onReachBottom: function () { 61 | 62 | }, 63 | 64 | /** 65 | * 用户点击右上角分享 66 | */ 67 | onShareAppMessage: function () { 68 | 69 | }, 70 | 71 | //更新 其他用户的一个状态 需要通过云函数来进行 不能直接操作数据库 72 | handleLinks(e) { 73 | const id = e.target.dataset.id 74 | wx.cloud.callFunction({ 75 | name: 'update', 76 | data: { 77 | id: id, 78 | collection: 'users', 79 | data: "{links: _.inc(1)}" // 传递一个字符串 在服务端进行解析 80 | } 81 | }).then(res => { 82 | console.log(res) 83 | const updated = res.result.stats.updated 84 | if (updated) { 85 | const cloneListDate = [...this.data.listData] // 复制一个出来更新 点赞数 86 | cloneListDate.forEach(element => { 87 | if (element._id == id) { 88 | element.links++ 89 | } 90 | }); 91 | this.setData({ // 更新数据 92 | listData: cloneListDate 93 | }) 94 | } 95 | }) 96 | }, 97 | handleCurrent(e) { 98 | const current = e.target.dataset.current 99 | if (current == this.data.current) { 100 | return false 101 | } 102 | this.setData({ 103 | current 104 | }) 105 | this.initData() 106 | }, 107 | handlDetail(e) { 108 | const id = e.target.dataset.id 109 | console.log(id) 110 | wx.navigateTo({ 111 | url: '/pages/detail/detail?userId=' + id, 112 | }) 113 | }, 114 | initData() { 115 | db.collection('users').field({ 116 | userPhoto: true, 117 | nickName: true, 118 | links: true 119 | }).orderBy(this.data.current, 'desc') 120 | .get().then(res => { 121 | console.log(res.data) 122 | this.setData({ 123 | listData: res.data 124 | }) 125 | }) 126 | } 127 | }) -------------------------------------------------------------------------------- /miniprogram/pages/near/near.js: -------------------------------------------------------------------------------- 1 | // miniprogram/pages/near/near.js 2 | const app = getApp() 3 | const db = wx.cloud.database() 4 | const _ = db.command 5 | Page({ 6 | 7 | /** 8 | * 页面的初始数据 9 | */ 10 | data: { 11 | longitude: '', // 中心经度 12 | latitude: '', //中心纬度 13 | markers: [], 14 | id: [] // 用户id 15 | }, 16 | 17 | /** 18 | * 生命周期函数--监听页面加载 19 | */ 20 | onLoad: function (options) { 21 | 22 | }, 23 | 24 | /** 25 | * 生命周期函数--监听页面初次渲染完成 26 | */ 27 | onReady: function () { 28 | this.getLocation() 29 | }, 30 | 31 | /** 32 | * 生命周期函数--监听页面显示 33 | */ 34 | onShow: function () { 35 | this.getLocation() 36 | }, 37 | 38 | /** 39 | * 生命周期函数--监听页面隐藏 40 | */ 41 | onHide: function () { 42 | 43 | }, 44 | 45 | /** 46 | * 生命周期函数--监听页面卸载 47 | */ 48 | onUnload: function () { 49 | 50 | }, 51 | 52 | /** 53 | * 页面相关事件处理函数--监听用户下拉动作 54 | */ 55 | onPullDownRefresh: function () { 56 | 57 | }, 58 | 59 | /** 60 | * 页面上拉触底事件的处理函数 61 | */ 62 | onReachBottom: function () { 63 | 64 | }, 65 | 66 | /** 67 | * 用户点击右上角分享 68 | */ 69 | onShareAppMessage: function () { 70 | 71 | }, 72 | getLocation() { 73 | wx.getLocation({ 74 | type: 'gcj02 ', 75 | success: (res) => { 76 | const latitude = res.latitude 77 | const longitude = res.longitude 78 | this.setData({ 79 | latitude, 80 | longitude 81 | }) 82 | this.getNearUsers() 83 | } 84 | }) 85 | }, 86 | // 获取markers 经纬度 显示个人头像 87 | getNearUsers() { 88 | db.collection('users').where({ 89 | location: _.geoNear({ 90 | geometry: db.Geo.Point(this.data.longitude, this.data.latitude), 91 | minDistance: 0, 92 | maxDistance: 5000, 93 | }), 94 | isLocation: true 95 | }).field({ 96 | longitude: true, 97 | latitude: true, 98 | userPhoto: true 99 | }).get().then((res) => { 100 | const data = res.data 101 | let markers = [] 102 | let id = [] 103 | data.forEach((element, index) => { 104 | if (element.userPhoto.includes('cloud://')) { 105 | wx.cloud.getTempFileURL({ 106 | fileList: [element.userPhoto], 107 | success: res => { 108 | markers.push({ 109 | id: index, 110 | iconPath: res.fileList[0].tempFileURL, 111 | latitude: element.latitude, 112 | longitude: element.longitude, 113 | width: 30, 114 | height: 30 115 | }) 116 | id.push(element._id) 117 | this.setData({ 118 | markers, 119 | id 120 | }) 121 | console.log(marker, '11111111111111111 ===========>>>') 122 | }, 123 | fail: console.error 124 | }) 125 | } else { 126 | markers.push({ 127 | id: index, 128 | iconPath: element.userPhoto, 129 | latitude: element.latitude, 130 | longitude: element.longitude, 131 | width: 30, 132 | height: 30 133 | }) 134 | id.push(element._id) 135 | } 136 | }) 137 | this.setData({ 138 | markers, 139 | id 140 | }) 141 | }) 142 | }, 143 | // 点击跳转到详情页 144 | markertap(e) { 145 | let markerId = this.data.id[e.detail.markerId] 146 | wx.navigateTo({ 147 | url: '/pages/detail/detail?userId=' + markerId, 148 | }) 149 | } 150 | }) -------------------------------------------------------------------------------- /miniprogram/pages/detail/detail.js: -------------------------------------------------------------------------------- 1 | // miniprogram/pages/detail/detail.js 2 | const app = getApp() 3 | const db = wx.cloud.database() 4 | Page({ 5 | 6 | /** 7 | * 页面的初始数据 8 | */ 9 | data: { 10 | datail: {}, 11 | isFriend: false, 12 | isHandle: false 13 | }, 14 | 15 | /** 16 | * 生命周期函数--监听页面加载 17 | */ 18 | onLoad: function (options) { 19 | console.log(options, 'options ============>>>>') 20 | const userId = options.userId 21 | db.collection('users').doc(userId).get().then((res) => { 22 | this.setData({ 23 | datail: res.data 24 | }) 25 | const friendList = res.data.friendList 26 | console.log(friendList) 27 | if (friendList.includes(app.userInfo._id)) { 28 | this.setData({ 29 | isFriend: true 30 | }) 31 | } else { 32 | this.setData({ 33 | isFriend: false 34 | }, () => { 35 | if (userId == app.userInfo._id) { 36 | this.setData({ 37 | isFriend: true, 38 | isHandle: true 39 | }) 40 | } 41 | }) 42 | } 43 | }) 44 | }, 45 | 46 | /** 47 | * 生命周期函数--监听页面初次渲染完成 48 | */ 49 | onReady: function () { 50 | 51 | }, 52 | 53 | /** 54 | * 生命周期函数--监听页面显示 55 | */ 56 | onShow: function () { 57 | 58 | }, 59 | 60 | /** 61 | * 生命周期函数--监听页面隐藏 62 | */ 63 | onHide: function () { 64 | 65 | }, 66 | 67 | /** 68 | * 生命周期函数--监听页面卸载 69 | */ 70 | onUnload: function () { 71 | 72 | }, 73 | 74 | /** 75 | * 页面相关事件处理函数--监听用户下拉动作 76 | */ 77 | onPullDownRefresh: function () { 78 | 79 | }, 80 | 81 | /** 82 | * 页面上拉触底事件的处理函数 83 | */ 84 | onReachBottom: function () { 85 | 86 | }, 87 | 88 | /** 89 | * 用户点击右上角分享 90 | */ 91 | onShareAppMessage: function () { 92 | 93 | }, 94 | handleAddFriend() { 95 | if (app.userInfo._id) { 96 | db.collection('message').where({ 97 | userId: this.data.datail._id 98 | }).get().then(res => { 99 | // 先查询好友 list 数组 进行相应操作 100 | if (res.data.length) { 101 | // 更新 102 | // 如果返回的 res.data 的 length 为真 就执行以下判断 如果为 假 就直接添加好友 103 | if (res.data[0].list.includes(app.userInfo._id)) { // includes 查找字符串是否包含其内容 104 | // 判断是否有重复的 没有则添加好友 105 | wx.showToast({ 106 | title: '已申请过!', 107 | icon: 'none' 108 | }) 109 | } else { 110 | wx.cloud.callFunction({ 111 | name: 'update', 112 | data: { 113 | collection: 'message', 114 | where: { 115 | userId: this.data.datail._id 116 | }, 117 | data: `{list:_.unshift('${app.userInfo._id}')}` 118 | } 119 | }).then(res => { 120 | wx.showToast({ 121 | title: '申请成功~', 122 | }) 123 | }) 124 | } 125 | } else { // 添加 126 | db.collection('message').add({ 127 | data: { 128 | userId: this.data.datail._id, 129 | list: [app.userInfo._id] 130 | } 131 | }).then(res => { 132 | wx.showToast({ 133 | title: '申请成功', 134 | }) 135 | }) 136 | } 137 | }) 138 | } else { 139 | wx.showToast({ 140 | title: '请先登录', 141 | duration: 2000, 142 | icon: 'none', 143 | success: () => { 144 | setTimeout(() => { 145 | wx.switchTab({ 146 | url: '/pages/user/user' 147 | }) 148 | }, 2000) 149 | } 150 | }) 151 | } 152 | } 153 | }) -------------------------------------------------------------------------------- /project.config.json: -------------------------------------------------------------------------------- 1 | { 2 | "miniprogramRoot": "miniprogram/", 3 | "cloudfunctionRoot": "cloudfunctions/", 4 | "setting": { 5 | "urlCheck": true, 6 | "es6": true, 7 | "enhance": true, 8 | "postcss": true, 9 | "preloadBackgroundData": false, 10 | "minified": true, 11 | "newFeature": true, 12 | "coverView": true, 13 | "nodeModules": false, 14 | "autoAudits": false, 15 | "showShadowRootInWxmlPanel": true, 16 | "scopeDataCheck": false, 17 | "uglifyFileName": false, 18 | "checkInvalidKey": true, 19 | "checkSiteMap": true, 20 | "uploadWithSourceMap": true, 21 | "compileHotReLoad": false, 22 | "useMultiFrameRuntime": false, 23 | "useApiHook": true, 24 | "babelSetting": { 25 | "ignore": [], 26 | "disablePlugins": [], 27 | "outputPath": "" 28 | }, 29 | "useIsolateContext": true, 30 | "useCompilerModule": true, 31 | "userConfirmedUseCompilerModuleSwitch": false, 32 | "packNpmManually": false, 33 | "packNpmRelationList": [] 34 | }, 35 | "appid": "wx376bd938e57eaf9b", 36 | "projectname": "miaomiao", 37 | "libVersion": "2.13.2", 38 | "simulatorType": "wechat", 39 | "simulatorPluginLibVersion": {}, 40 | "cloudfunctionTemplateRoot": "cloudfunctionTemplate", 41 | "condition": { 42 | "search": { 43 | "current": -1, 44 | "list": [] 45 | }, 46 | "conversation": { 47 | "current": -1, 48 | "list": [] 49 | }, 50 | "plugin": { 51 | "current": -1, 52 | "list": [] 53 | }, 54 | "game": { 55 | "list": [] 56 | }, 57 | "gamePlugin": { 58 | "current": -1, 59 | "list": [] 60 | }, 61 | "miniprogram": { 62 | "current": 0, 63 | "list": [ 64 | { 65 | "id": -1, 66 | "name": "db guide", 67 | "pathName": "pages/databaseGuide/databaseGuide", 68 | "query": "" 69 | }, 70 | { 71 | "id": -1, 72 | "name": "pages/user/user", 73 | "pathName": "pages/user/user", 74 | "query": "", 75 | "scene": null 76 | }, 77 | { 78 | "id": -1, 79 | "name": "pages/editUserinfo/editUserinfo", 80 | "pathName": "pages/editUserinfo/editUserinfo", 81 | "query": "", 82 | "scene": null 83 | }, 84 | { 85 | "id": -1, 86 | "name": "pages/editUserinfo/signature/signature", 87 | "pathName": "pages/editUserinfo/signature/signature", 88 | "query": "", 89 | "scene": null 90 | }, 91 | { 92 | "id": -1, 93 | "name": "pages/editUserinfo/phone/phone", 94 | "pathName": "pages/editUserinfo/phone/phone", 95 | "query": "", 96 | "scene": null 97 | }, 98 | { 99 | "id": -1, 100 | "name": "pages/editUserinfo/name/name", 101 | "pathName": "pages/editUserinfo/name/name", 102 | "query": "", 103 | "scene": null 104 | }, 105 | { 106 | "id": -1, 107 | "name": "pages/editUserinfo/head/head", 108 | "pathName": "pages/editUserinfo/head/head", 109 | "query": "", 110 | "scene": null 111 | }, 112 | { 113 | "id": 7, 114 | "name": "pages/detail/detail", 115 | "pathName": "pages/detail/detail", 116 | "query": "", 117 | "scene": null 118 | }, 119 | { 120 | "id": -1, 121 | "name": "pages/user/user", 122 | "pathName": "pages/user/user", 123 | "query": "", 124 | "scene": null 125 | }, 126 | { 127 | "id": -1, 128 | "name": "pages/near/near", 129 | "pathName": "pages/near/near", 130 | "query": "", 131 | "scene": null 132 | }, 133 | { 134 | "id": -1, 135 | "name": "pages/near/near", 136 | "pathName": "pages/near/near", 137 | "scene": null 138 | } 139 | ] 140 | } 141 | } 142 | } -------------------------------------------------------------------------------- /miniprogram/pages/user/user.js: -------------------------------------------------------------------------------- 1 | // miniprogram/pages/user/user.js 2 | const app = getApp() // 通过内置的getApp方法 拿到 app.js 中的this对象 3 | const db = wx.cloud.database() // 初始化数据库 4 | Page({ 5 | 6 | /** 7 | * 页面的初始数据 8 | */ 9 | data: { 10 | logged: false, 11 | userPhoto: "../../images/user/user-unlogin.png", 12 | nickName: "小妹妹", 13 | id: '', 14 | }, 15 | 16 | /** 17 | * 生命周期函数--监听页面加载 18 | */ 19 | onLoad: function (options) { 20 | 21 | }, 22 | 23 | /** 24 | * 生命周期函数--监听页面初次渲染完成 25 | */ 26 | onReady: function () { 27 | this.getLocation() 28 | wx.cloud.callFunction({ // 如何数据库中存在用户 则调用此方法自动登录 29 | name: 'login', 30 | data: {} 31 | }).then((res) => { 32 | db.collection('users').where({ 33 | _openid: res.result.openid 34 | }).get().then(res => { 35 | if (res.data.length) { 36 | this.getMessage() 37 | app.userInfo = Object.assign(app.userInfo, res.data[0]) // 更新用户信息写入全局 38 | this.setData({ 39 | userPhoto: app.userInfo.userPhoto, 40 | nickName: app.userInfo.nickName, 41 | logged: true, 42 | id: app.userInfo._id 43 | }) 44 | } 45 | }) 46 | }) 47 | }, 48 | 49 | /** 50 | * 生命周期函数--监听页面显示 51 | */ 52 | onShow: function () { 53 | this.setData({ 54 | userPhoto: app.userInfo.userPhoto, 55 | nickName: app.userInfo.nickName, 56 | id: app.userInfo._id 57 | }) 58 | }, 59 | 60 | /** 61 | * 生命周期函数--监听页面隐藏 62 | */ 63 | onHide: function () { 64 | 65 | }, 66 | 67 | /** 68 | * 生命周期函数--监听页面卸载 69 | */ 70 | onUnload: function () { 71 | 72 | }, 73 | 74 | /** 75 | * 页面相关事件处理函数--监听用户下拉动作 76 | */ 77 | onPullDownRefresh: function () { 78 | 79 | }, 80 | 81 | /** 82 | * 页面上拉触底事件的处理函数 83 | */ 84 | onReachBottom: function () { 85 | 86 | }, 87 | 88 | /** 89 | * 用户点击右上角分享 90 | */ 91 | onShareAppMessage: function () { 92 | 93 | }, 94 | /** 95 | * 点击登录按钮 96 | */ 97 | bindGetUserInfo(e) { // 直接操作数据库 向云数据库 添加个人信息 注意点:前端直接操作数据库记得设置权限 98 | let userInfo = e.detail.userInfo 99 | if (!this.data.logged && userInfo) { 100 | db.collection('users').add({ 101 | data: { 102 | userPhoto: userInfo.avatarUrl, 103 | nickName: userInfo.nickName, 104 | friendList: [], // 好友列表 105 | signature: '', // 签名 106 | phoneNumber: '', // 电话号码 107 | weixinNumber: '', //微信号 108 | links: 0, // 点赞数 109 | time: new Date(), // 时间 110 | isLocation: true, // 是否显示位置信息 111 | longitude: this.longitude, // 中心经度 112 | latitude: this.latitude, //中心纬度 113 | location: db.Geo.Point(this.longitude, this.latitude) 114 | } 115 | }).then(res => { 116 | db.collection('users').doc(res._id).get().then(res => { 117 | app.userInfo = Object.assign(app.userInfo, res.data) // 授权 把用户信息写入全局 118 | this.setData({ 119 | userPhoto: app.userInfo.userPhoto, 120 | nickName: app.userInfo.nickName, 121 | logged: true, 122 | id: app.userInfo._id 123 | }) 124 | }) 125 | }); 126 | } 127 | }, 128 | /** 129 | * 登录以后监听消息 130 | */ 131 | getMessage() { 132 | db.collection('message').where({ 133 | userId: app.userInfo._id 134 | }).watch({ 135 | onChange: function (snapshot) { 136 | console.log('docs\'s changed events', snapshot.docChanges) 137 | if (snapshot.docChanges.length) { 138 | const list = snapshot.docChanges[0].doc.list 139 | if (list.length) { 140 | wx.showTabBarRedDot({ 141 | index: 2 142 | }) 143 | app.userMessage = list 144 | } else { 145 | wx.hideTabBarRedDot({ 146 | index: 2, 147 | }) 148 | app.userMessage = [] 149 | } 150 | } 151 | }, 152 | onError: function (err) { 153 | console.error('the watch closed because of error', err) 154 | } 155 | }) 156 | }, 157 | getLocation() { 158 | wx.getLocation({ 159 | type: 'gcj02 ', 160 | success: (res) => { 161 | this.latitude = res.latitude 162 | this.longitude = res.longitude 163 | } 164 | }) 165 | } 166 | }) -------------------------------------------------------------------------------- /miniprogram/style/icon/iconfont.wxss: -------------------------------------------------------------------------------- 1 | @font-face {font-family: "iconfont"; 2 | src: url('//at.alicdn.com/t/font_1417208_nacl5fa0zw.eot?t=1569206247010'); /* IE9 */ 3 | src: url('//at.alicdn.com/t/font_1417208_nacl5fa0zw.eot?t=1569206247010#iefix') format('embedded-opentype'), /* IE6-IE8 */ 4 | url('data:application/x-font-woff2;charset=utf-8;base64,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') format('woff2'), 5 | url('//at.alicdn.com/t/font_1417208_nacl5fa0zw.woff?t=1569206247010') format('woff'), 6 | url('//at.alicdn.com/t/font_1417208_nacl5fa0zw.ttf?t=1569206247010') format('truetype'), /* chrome, firefox, opera, Safari, Android, iOS 4.2+ */ 7 | url('//at.alicdn.com/t/font_1417208_nacl5fa0zw.svg?t=1569206247010#iconfont') format('svg'); /* iOS 4.1- */ 8 | } 9 | 10 | .iconfont { 11 | font-family: "iconfont" !important; 12 | font-size: 16px; 13 | font-style: normal; 14 | -webkit-font-smoothing: antialiased; 15 | -moz-osx-font-smoothing: grayscale; 16 | } 17 | 18 | .iconshanchu:before { 19 | content: "\e61a"; 20 | } 21 | 22 | .iconfujinderen:before { 23 | content: "\e646"; 24 | } 25 | 26 | .iconshouye:before { 27 | content: "\e630"; 28 | } 29 | 30 | .icontubiao-:before { 31 | content: "\e64f"; 32 | } 33 | 34 | .icondadianhua:before { 35 | content: "\e645"; 36 | } 37 | 38 | .icondianzan:before { 39 | content: "\e633"; 40 | } 41 | 42 | .iconyixianshi_huaban:before { 43 | content: "\e617"; 44 | } 45 | 46 | .iconfuzhi:before { 47 | content: "\e607"; 48 | } 49 | 50 | .iconarrowRight:before { 51 | content: "\e60f"; 52 | } 53 | 54 | .iconsousuo1:before { 55 | content: "\e651"; 56 | } 57 | --------------------------------------------------------------------------------