From 95ba64386d5e68fb3ba4cc7abb4d0b672d9ac56e Mon Sep 17 00:00:00 2001 From: Shern Date: Sun, 20 Sep 2020 20:53:41 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E5=8F=96=E6=B6=88=E4=B8=8B=E6=8B=89?= =?UTF-8?q?=E5=88=B7=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- miniprogram/pages/baby/detail.json | 2 +- miniprogram/pages/baby/index.json | 2 +- miniprogram/pages/benefit/detail.json | 2 +- miniprogram/pages/benefit/index.json | 2 +- miniprogram/pages/find/detail.json | 2 +- miniprogram/pages/find/index.json | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/miniprogram/pages/baby/detail.json b/miniprogram/pages/baby/detail.json index 1a817a9..cc4eecf 100644 --- a/miniprogram/pages/baby/detail.json +++ b/miniprogram/pages/baby/detail.json @@ -4,6 +4,6 @@ "navigationBarTitleText": "宝贝回家", "backgroundColor": "#eeeeee", "backgroundTextStyle": "dark", - "enablePullDownRefresh": true, + "enablePullDownRefresh": false, "usingComponents": {} } \ No newline at end of file diff --git a/miniprogram/pages/baby/index.json b/miniprogram/pages/baby/index.json index 1a817a9..cc4eecf 100644 --- a/miniprogram/pages/baby/index.json +++ b/miniprogram/pages/baby/index.json @@ -4,6 +4,6 @@ "navigationBarTitleText": "宝贝回家", "backgroundColor": "#eeeeee", "backgroundTextStyle": "dark", - "enablePullDownRefresh": true, + "enablePullDownRefresh": false, "usingComponents": {} } \ No newline at end of file diff --git a/miniprogram/pages/benefit/detail.json b/miniprogram/pages/benefit/detail.json index 71c89a4..82744df 100644 --- a/miniprogram/pages/benefit/detail.json +++ b/miniprogram/pages/benefit/detail.json @@ -4,6 +4,6 @@ "navigationBarTitleText": "公益援助", "backgroundColor": "#eeeeee", "backgroundTextStyle": "dark", - "enablePullDownRefresh": true, + "enablePullDownRefresh": false, "usingComponents": {} } \ No newline at end of file diff --git a/miniprogram/pages/benefit/index.json b/miniprogram/pages/benefit/index.json index 71c89a4..82744df 100644 --- a/miniprogram/pages/benefit/index.json +++ b/miniprogram/pages/benefit/index.json @@ -4,6 +4,6 @@ "navigationBarTitleText": "公益援助", "backgroundColor": "#eeeeee", "backgroundTextStyle": "dark", - "enablePullDownRefresh": true, + "enablePullDownRefresh": false, "usingComponents": {} } \ No newline at end of file diff --git a/miniprogram/pages/find/detail.json b/miniprogram/pages/find/detail.json index 1f80f63..3842aba 100644 --- a/miniprogram/pages/find/detail.json +++ b/miniprogram/pages/find/detail.json @@ -4,6 +4,6 @@ "navigationBarTitleText": "寻亲寻人", "backgroundColor": "#eeeeee", "backgroundTextStyle": "dark", - "enablePullDownRefresh": true, + "enablePullDownRefresh": false, "usingComponents": {} } \ No newline at end of file diff --git a/miniprogram/pages/find/index.json b/miniprogram/pages/find/index.json index 1f80f63..3842aba 100644 --- a/miniprogram/pages/find/index.json +++ b/miniprogram/pages/find/index.json @@ -4,6 +4,6 @@ "navigationBarTitleText": "寻亲寻人", "backgroundColor": "#eeeeee", "backgroundTextStyle": "dark", - "enablePullDownRefresh": true, + "enablePullDownRefresh": false, "usingComponents": {} } \ No newline at end of file -- Gitee From 727f5c77bc96e70c74b5746b99d97e11036aa7a2 Mon Sep 17 00:00:00 2001 From: Shern Date: Sun, 20 Sep 2020 21:48:03 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=AF=BB=E4=BA=BA?= =?UTF-8?q?=E4=BB=A5=E5=8F=8A=E4=BC=98=E5=8C=96benefit=E8=AF=A6=E6=83=85?= =?UTF-8?q?=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cloudfunctions/setMyWatch/index.js | 14 ++++--- miniprogram/pages/baby/detail.js | 3 +- miniprogram/pages/baby/detail.wxml | 2 +- miniprogram/pages/benefit/detail.js | 6 ++- miniprogram/pages/find/detail.js | 64 ++++++++++++++++++++++++++++- miniprogram/pages/find/detail.wxml | 5 ++- miniprogram/pages/find/detail.wxss | 48 +++++++++++++++++++++- miniprogram/pages/find/index.js | 6 +-- miniprogram/pages/find/index.wxml | 4 +- 9 files changed, 133 insertions(+), 19 deletions(-) diff --git a/cloudfunctions/setMyWatch/index.js b/cloudfunctions/setMyWatch/index.js index 8fd8be3..cafed58 100644 --- a/cloudfunctions/setMyWatch/index.js +++ b/cloudfunctions/setMyWatch/index.js @@ -9,23 +9,24 @@ const db = cloud.database() exports.main = async(event, context) => { const wxContext = cloud.getWXContext(); - + let { type } = event try { let result = await db.collection("myWatch").where({ openid: wxContext.OPENID }).get(); if (result.data && result.data.length > 0) { - let { watch, _id } = result.data[0]; - let hasWatch = watch.find(val => val == event.id); + let data = result.data[0]; + let _id = data._id + let hasWatch = data[type].find(val => val == event.id); if (hasWatch) { //原本已经这个项目的ID return { isChange: false } } else { - watch.push(event.id); + data[type].push(event.id); return await db.collection('myWatch').doc(_id).update({ data: { - watch + [type]:data[type] } }) } @@ -33,7 +34,8 @@ exports.main = async(event, context) => { return await db.collection('myWatch').add({ data: { openid: wxContext.OPENID, - watch: [event.id] + watch:type=='watch'?[event.id]:[], + benefit:type=='benefit'?[event.id]:[] } }) } diff --git a/miniprogram/pages/baby/detail.js b/miniprogram/pages/baby/detail.js index ed43a33..910d553 100644 --- a/miniprogram/pages/baby/detail.js +++ b/miniprogram/pages/baby/detail.js @@ -56,7 +56,8 @@ Page({ wx.cloud.callFunction({ name: 'setMyWatch', data: { - id: this.data.id + id: this.data.id, + type:'watch' }, complete: function(data){ if(data.result.isChange!==false){ diff --git a/miniprogram/pages/baby/detail.wxml b/miniprogram/pages/baby/detail.wxml index dc13d14..1c387f4 100644 --- a/miniprogram/pages/baby/detail.wxml +++ b/miniprogram/pages/baby/detail.wxml @@ -9,7 +9,7 @@ 性别:{{babyInfo.sex}} 生日:{{babyInfo.birthday}} - + 失踪信息 失踪地点:{{babyInfo.missing.region}}{{babyInfo.missing.city}}{{babyInfo.missing.address}} 失踪时间:{{babyInfo.missing.time}} diff --git a/miniprogram/pages/benefit/detail.js b/miniprogram/pages/benefit/detail.js index 5b88b48..d848a9e 100644 --- a/miniprogram/pages/benefit/detail.js +++ b/miniprogram/pages/benefit/detail.js @@ -33,11 +33,12 @@ Page({ name: 'getMyWatch', // 传给云函数的参数 data: { + type:'benefit' }, // 成功回调 complete: function(data){ let res = data.result; - let myWatch = res.data[0]&&res.data[0].watch || [] + let myWatch = res.data[0]&&res.data[0].benefit || [] let isFocused; if([].indexOf.call(myWatch,options.id)!==-1){ isFocused = 1 @@ -56,7 +57,8 @@ Page({ wx.cloud.callFunction({ name: 'setMyWatch', data: { - id: this.data.id + id: this.data.id, + type:'benefit' }, complete: function(data){ if(data.result.isChange!==false){ diff --git a/miniprogram/pages/find/detail.js b/miniprogram/pages/find/detail.js index f33bcaf..8a34095 100644 --- a/miniprogram/pages/find/detail.js +++ b/miniprogram/pages/find/detail.js @@ -1,18 +1,78 @@ -// miniprogram/pages/find/detail.js +// miniprogram/pages/home/detail.js Page({ /** * 页面的初始数据 */ data: { - + id:'', + isFocused:false, + babyInfo:{} }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { + this.setData({ + id: options.id + }) + var that = this; + const db = wx.cloud.database() + db.collection('findPersonList').where({ + _id: options.id + }).get({ + success: function (res) { + that.setData({ babyInfo: res.data&&res.data[0]||{} }) + } + }) + + + wx.cloud.callFunction({ + // 需调用的云函数名 + name: 'getMyWatch', + // 传给云函数的参数 + data: { + }, + // 成功回调 + complete: function(data){ + let res = data.result; + let myWatch = res.data[0]&&res.data[0].watch || [] + let isFocused; + if([].indexOf.call(myWatch,options.id)!==-1){ + isFocused = 1 + }else{ + isFocused = 0 + } + that.setData({ + isFocused:isFocused + }) + } + }) + }, + handleTap:function(){ + var that = this; + wx.cloud.callFunction({ + name: 'setMyWatch', + data: { + id: this.data.id, + type:'watch' + }, + complete: function(data){ + if(data.result.isChange!==false){ + wx.showToast({ + title: '关注成功', + icon: 'success', + duration: 2000 + }) + + that.setData({ + isFocused:1 + }) + } + } + }) }, /** diff --git a/miniprogram/pages/find/detail.wxml b/miniprogram/pages/find/detail.wxml index 5d9def4..6c48b46 100644 --- a/miniprogram/pages/find/detail.wxml +++ b/miniprogram/pages/find/detail.wxml @@ -1,4 +1,4 @@ - + @@ -15,6 +15,9 @@ 失踪时间:{{babyInfo.missing.time}} 失踪时身高:{{babyInfo.height}} 失踪时特征:{{babyInfo.description}} + 其他:{{babyInfo.other}} + 关注 + 已关注 diff --git a/miniprogram/pages/find/detail.wxss b/miniprogram/pages/find/detail.wxss index 6001334..3479e54 100644 --- a/miniprogram/pages/find/detail.wxss +++ b/miniprogram/pages/find/detail.wxss @@ -1 +1,47 @@ -/* miniprogram/pages/find/detail.wxss */ \ No newline at end of file +/* miniprogram/pages/find/detail.wxss */ +/* miniprogram/pages/home/detail.wxss */ + +.top{ + width:100%; + height: 600rpx; +} + +.baby_img{ + width: 100%; + height: 600rpx; +} + + +.info_cell{ + font-size: 36rpx; + background-color:#fff; + padding: 10rpx 30rpx; + border-top: 1px solid #e6e6e6; + line-height:64rpx; +} + +.baby_name{ + font-weight: bold; + font-size: 48rpx; + margin: 30rpx; +} + +.title{ + margin:0 30rpx; + line-height:64rpx; +} + +.watch_btn{ + position: fixed; + right:0; + top: 800rpx; + width:160rpx; + height: 80rpx; + line-height: 80rpx; + text-align: center; + background-color:red; + color: white; + z-index: 111; + border-top-left-radius: 50rpx; + border-bottom-left-radius: 50rpx; +} \ No newline at end of file diff --git a/miniprogram/pages/find/index.js b/miniprogram/pages/find/index.js index cc0c8af..3968664 100644 --- a/miniprogram/pages/find/index.js +++ b/miniprogram/pages/find/index.js @@ -5,7 +5,7 @@ Page({ * 页面的初始数据 */ data: { - babyList: [] + findPersonList: [] }, /** @@ -15,9 +15,9 @@ Page({ var that = this; const db = wx.cloud.database() - db.collection('babyList').get({ + db.collection('findPersonList').get({ success: function (res) { - that.setData({ babyList: res.data }) + that.setData({ findPersonList: res.data }) } }) }, diff --git a/miniprogram/pages/find/index.wxml b/miniprogram/pages/find/index.wxml index d1655bc..d240ea8 100644 --- a/miniprogram/pages/find/index.wxml +++ b/miniprogram/pages/find/index.wxml @@ -1,9 +1,9 @@ - + - + -- Gitee From 5abbd74345c2a447d096b2224c8f3e1a02899791 Mon Sep 17 00:00:00 2001 From: Shern Date: Sun, 20 Sep 2020 21:50:24 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E6=A0=B7=E5=BC=8F=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- miniprogram/pages/baby/index.wxss | 5 +++++ miniprogram/pages/find/index.wxss | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/miniprogram/pages/baby/index.wxss b/miniprogram/pages/baby/index.wxss index 59e281f..0722412 100644 --- a/miniprogram/pages/baby/index.wxss +++ b/miniprogram/pages/baby/index.wxss @@ -27,3 +27,8 @@ .bot_info{ border-top: 1px solid rgba(0, 0, 0, 0.1); } + +.baby_place{ + max-height: 32rpx; + overflow: hidden; +} \ No newline at end of file diff --git a/miniprogram/pages/find/index.wxss b/miniprogram/pages/find/index.wxss index 2124fcd..31c6435 100644 --- a/miniprogram/pages/find/index.wxss +++ b/miniprogram/pages/find/index.wxss @@ -29,3 +29,8 @@ .bot_info{ border-top: 1px solid rgba(0, 0, 0, 0.1); } + +.baby_place{ + max-height: 32rpx; + overflow: hidden; +} \ No newline at end of file -- Gitee