From 9953c652d12833e94aef46643279f208201785fb Mon Sep 17 00:00:00 2001 From: xuxu Date: Thu, 10 Sep 2020 17:10:39 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B5=8B=E8=83=BD=E4=B8=AD=E5=BF=83=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E4=BF=AE=E6=94=B9=EF=BC=8C=E5=85=9A=E7=BE=A4e?= =?UTF-8?q?=E5=AE=B6=E8=B7=B3=E8=BD=AC=E7=99=BB=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.js | 14 ++++- components/segment/index.wxss | 8 +-- models/topic.js | 50 +++++++++++++++++- models/user.js | 15 ++++++ pages/topics/center/index.js | 17 +++++- pages/topics/center/index.json | 3 +- pages/topics/center/index.wxml | 22 +++++++- pages/topics/center/index.wxss | 18 +++++-- pages/topics/index.js | 94 +++++++++++++++++++++++++--------- pages/topics/index.wxml | 6 +-- pages/user/index.js | 54 +++++++++++++------ 11 files changed, 245 insertions(+), 56 deletions(-) diff --git a/app.js b/app.js index 781c0e2..40d04d2 100644 --- a/app.js +++ b/app.js @@ -3,11 +3,23 @@ import {HTTP} from '/utils/http.js' const http = new HTTP() App({ onLaunch: function (options) { + console.log('党群e家'); + console.log(options); + if(options.referrerInfo.hasOwnProperty('extraData')){ + this.globalData.navigate.mobile = options.extraData.mobile, + this.globalData.navigate.nickname = options.extraData.nickname, + this.globalData.navigate.faceImg = options.extraData.faceImg + } http.fetchAuthToken(res => { // console.log(res) }) }, globalData: { - userInfo: null + userInfo: null, + navigate:{ + mobile:'', + nickname:'', + faceImg:'' + } } }) \ No newline at end of file diff --git a/components/segment/index.wxss b/components/segment/index.wxss index aa5d0dc..a1597b8 100644 --- a/components/segment/index.wxss +++ b/components/segment/index.wxss @@ -2,8 +2,8 @@ .header-titles { height: 36px; display: flex; - /* justify-content: space-around; */ - padding: 5px; + justify-content: center; + /* padding: 5px; */ } .title { min-width: 100rpx; @@ -15,12 +15,14 @@ color: #999999; font-size: 14px; margin-top: 5px; + } .item-title{ display: flex; flex-direction: column; align-items: center; transition: 0.5s all ease-in-out; + flex: 1; } .title-selected { font-size: 15px; @@ -33,7 +35,7 @@ transition: 0.5s all ease-in-out; } .select-line-active { - width: 10px; + width: 20px; background-color: #FA4646; } diff --git a/models/topic.js b/models/topic.js index 7183756..0514490 100644 --- a/models/topic.js +++ b/models/topic.js @@ -15,7 +15,11 @@ const TopicBaseUrl = { topic_addMessage_url:'/api/message/addMessage' ,// 留言箱 topic_streets_url:'/api/whistle/getStreetList',//街道列表 topic_talents_url:'/api/whistle/save',//添加人才吹哨 - topic_center_url:'/api/content/getListByCode' //赋能中心列表 + topic_center_url:'/api/content/getListByCode', //赋能中心列表 + resource_type_url:'/api/resources/typelist ', + resource_list_url:'/api/resources/list', + resource_detail_url:'/api/resources/queryById', + resource_collect_url:'/api/resources/collectResources/' } class TopicModel extends HTTP { @@ -36,6 +40,17 @@ class TopicModel extends HTTP { this.request(params) } + getResourceTypeList(success){ + let params = { + url: TopicBaseUrl.resource_type_url, + method: Method.GET, + data: { + }, + success: success + } + this.request(params) + } + // 新建议题 topicAddGroup(title, content,images,success){ let params = { @@ -207,6 +222,39 @@ class TopicModel extends HTTP { } this.request(params) } + + getResourceList(typeCode,page,success){ + let params = { + url: TopicBaseUrl.resource_list_url + "?pageNo=" + page + "&pageSize=10&typeCode=" + typeCode, + method: Method.GET, + data: { + }, + success: success + } + this.request(params) + } + + getResourceDetail(id,success){ + + let params = { + url: TopicBaseUrl.resource_detail_url + "?id=" + id, + method: Method.GET, + data: { + }, + success: success + } + this.request(params) + } + resourceCollect(id,success){ + let params = { + url: TopicBaseUrl.resource_collect_url + `${id}`, + method: Method.POST, + data:{}, + success: success + } + this.request(params) + } + } diff --git a/models/user.js b/models/user.js index 98db164..a56477f 100644 --- a/models/user.js +++ b/models/user.js @@ -16,6 +16,7 @@ const UserConst = { user_whistleDetail_url:'/api/whistle/getWhistleById', // 吹哨详情 user_saveWhistleComment_url:'/api/whistle/saveComment' ,// 吹哨评价 user_updatePhone_url:'/api/miniuser/updatephone',//更新电话号码 + navigate_user_url:'/api/miniuser/wxregisterbyparams' } class UserModel extends HTTP { @@ -227,6 +228,20 @@ class UserModel extends HTTP { } this.request(params) } + + navigateUser(datas,success){ + let params = { + url:UserConst.navigate_user_url, + method: Method.POST, + data: { + phone:datas.phone, + nickName:datas.nickName, + avatarUrl:datas.avatarUrl + }, + success: success + } + this.request(params) + } } export { UserModel } \ No newline at end of file diff --git a/pages/topics/center/index.js b/pages/topics/center/index.js index 9845d14..b1d7737 100644 --- a/pages/topics/center/index.js +++ b/pages/topics/center/index.js @@ -6,14 +6,27 @@ Component({ properties: { list:{ type:Array, - value:[] + value:[], + }, + typeList:{ + type:Array, + value:[], } }, /** * 组件的初始数据 */ data: { - + icon:[ + {pic:'bank',color:'#03aefb',bg_color:'#d7f3ff'}, + {pic:'balance-scale',color:'#4d9fff',bg_color:'#e9f6fc'}, + {pic:'id-card',color:'#febc30',bg_color:'#fff3d9'}, + {pic:'users',color:'#bea0fe',bg_color:'#f5f0ff'}, + {pic:'globe',color:'#bea0fe',bg_color:'#f5f0ff'}, + {pic:'heart',color:'#febc30',bg_color:'#fff3d9'}, + {pic:'graduation-cap',color:'#bea0fe',bg_color:'#f5f0ff'}, + {pic:'comments',color:'#4d9fff',bg_color:'#e9f6fc'}, + ] }, attached: function () { console.log("center页面") diff --git a/pages/topics/center/index.json b/pages/topics/center/index.json index 4a42478..f466373 100644 --- a/pages/topics/center/index.json +++ b/pages/topics/center/index.json @@ -1,6 +1,7 @@ { "component": true, "usingComponents": { - + "van-grid": "/components/vant/grid/index", + "van-grid-item": "/components/vant/grid-item/index" } } \ No newline at end of file diff --git a/pages/topics/center/index.wxml b/pages/topics/center/index.wxml index d800d12..c6142e2 100644 --- a/pages/topics/center/index.wxml +++ b/pages/topics/center/index.wxml @@ -1,5 +1,26 @@ + + + + + + + + + {{item.typeName}} + + + + + + + + @@ -10,7 +31,6 @@ {{item.title}} - diff --git a/pages/topics/center/index.wxss b/pages/topics/center/index.wxss index a3fc33b..3f774d0 100644 --- a/pages/topics/center/index.wxss +++ b/pages/topics/center/index.wxss @@ -1,4 +1,5 @@ /* pages/topics/interactive/index.wxss */ +@import '../../../style/font.wxss'; .publish{ position: fixed; width: 40px; @@ -60,9 +61,6 @@ image{ justify-content: center; /* border:1px solid black; */ } -.rightActive{ - -} .right-top{ height:60%; @@ -122,4 +120,18 @@ image{ font-size: 12px; color: #D4D4D4; +} + +.nav{ + height:250px; +} + +.circular{ + width: 55px; + height: 55px; + border-radius: 50%; + /* background-color: thistle; */ + display: flex; + align-items: center; + justify-content: center; } \ No newline at end of file diff --git a/pages/topics/index.js b/pages/topics/index.js index 3bd319e..29a5cec 100644 --- a/pages/topics/index.js +++ b/pages/topics/index.js @@ -3,25 +3,27 @@ import dayjs from '../../utils/dayjs/index.js' import relativeTime from '../../utils/dayjs/relativeTime.js' import { TopicModel } from '../../models/topic.js' import { store } from '../../utils/store.js' +import { UserModel } from '../../models/user.js' +let userModel = new UserModel() dayjs.extend(relativeTime) let topicModel = new TopicModel() - +const app = getApp() Page({ /** * 页面的初始数据 */ data: { - // headerTitles: ['互动区', '金点子', '留言箱'], - headerTitles: ['留言互动', '赋能中心', '人才吹哨'], + headerTitles: ['找资源','报需求','交朋友' ], segmentIndex: 0, currPage: 1, //留言互动的列表 topicList: [], goodIdeaList: [], //赋能中心的列表 - centerList: [] + centerList: [], + typeList:[] }, @@ -76,38 +78,75 @@ Page({ // url: '/pages/home/index', // }) // } + if(app.globalData.navigate.mobile){ + var params = { + phone:app.globalData.navigate.mobile, + nickName:app.globalData.navigate.nickname, + avatarUrl:app.globalData.navigate.faceImg + } + userModel.navigateUser(params,res=>{ + store.saveUserInfo({ + nickName: params.nickName, + avatarUrl: params.avatarUrl, + phone: params.phone + }) + wx.reLaunch({ + url: '/pages/home/index', + }) + }) + }else{ + if (res.confirm) { + wx.redirectTo({ + url: '/pages/weChatAuth/index?type=2', + }) + } else if (res.cancel) { + wx.switchTab({ + url: '/pages/home/index', + }) + } + } + + } + }) + + } + } else { + console.log('未绑定微信') + if(app.globalData.navigate.mobile){ + var params = { + phone:app.globalData.navigate.mobile, + nickName:app.globalData.navigate.nickname, + avatarUrl:app.globalData.navigate.faceImg + } + userModel.navigateUser(params,res=>{ + store.saveUserInfo({ + nickName: params.nickName, + avatarUrl: params.avatarUrl, + phone: params.phone + }) + wx.reLaunch({ + url: '/pages/home/index', + }) + }) + }else{ + wx.showModal({ + title: '温馨提示', + content: '是否前往绑定微信?', + success(res) { if (res.confirm) { wx.redirectTo({ - url: '/pages/weChatAuth/index?type=2', + url: '/pages/weChatAuth/index', }) } else if (res.cancel) { wx.switchTab({ url: '/pages/home/index', }) } - } }) - } - } else { - console.log('未绑定微信') - wx.showModal({ - title: '温馨提示', - content: '是否前往绑定微信?', - success(res) { - if (res.confirm) { - wx.redirectTo({ - url: '/pages/weChatAuth/index', - }) - } else if (res.cancel) { - wx.switchTab({ - url: '/pages/home/index', - }) - } - } - }) + } }, @@ -170,6 +209,13 @@ Page({ //赋能中心 fetchCenterList(){ let page = this.data.currPage; + + topicModel.getResourceTypeList(res=>{ + this.setData({ + typeList:res.result + }) + }) + topicModel.getCenterList(page,res => { if (res.list.length == 0) { wx.showToast({ diff --git a/pages/topics/index.wxml b/pages/topics/index.wxml index f68836c..ff429ab 100644 --- a/pages/topics/index.wxml +++ b/pages/topics/index.wxml @@ -3,7 +3,7 @@ - + @@ -12,9 +12,9 @@ -
+
- + diff --git a/pages/user/index.js b/pages/user/index.js index 0f9dc87..834ec08 100644 --- a/pages/user/index.js +++ b/pages/user/index.js @@ -65,24 +65,44 @@ Page({ this.getMsgStatus() } else { //console.log('未绑定手机号码') - wx.showModal({ - title: '温馨提示', - content: '是否前往验证手机号码?', - success(res) { - if (res.confirm) { - // wx.redirectTo({ - // url: '/pages/register/index', - // }) - wx.redirectTo({ - url: '/pages/weChatAuth/index?type=2', - }) - } else if (res.cancel) { - wx.switchTab({ - url: '/pages/home/index', - }) - } + if(app.globalData.navigate.mobile){ + var params = { + phone:app.globalData.navigate.mobile, + nickName:app.globalData.navigate.nickname, + avatarUrl:app.globalData.navigate.faceImg } - }) + userModel.navigateUser(params,res=>{ + store.saveUserInfo({ + nickName: params.nickName, + avatarUrl: params.avatarUrl, + phone: params.phone + }) + + wx.reLaunch({ + url: '/pages/home/index', + }) + }) + }else{ + wx.showModal({ + title: '温馨提示', + content: '是否前往验证手机号码?', + success(res) { + if (res.confirm) { + // wx.redirectTo({ + // url: '/pages/register/index', + // }) + wx.redirectTo({ + url: '/pages/weChatAuth/index?type=2', + }) + } else if (res.cancel) { + wx.switchTab({ + url: '/pages/home/index', + }) + } + } + }) + } + } }) store.saveUserInfo({