| @@ -77,7 +77,7 @@ App({ | |||
| appid: "", | |||
| sessionKey: "", | |||
| suiteCode: "", | |||
| customerId: "", | |||
| customerId: "666967", | |||
| }, | |||
| // 跳转登录页 | |||
| goLogin(e) { | |||
| @@ -1,58 +1,62 @@ | |||
| // components/tabbar/tabbar.js | |||
| const app = getApp() | |||
| Component({ | |||
| /** | |||
| * 组件的属性列表 | |||
| */ | |||
| properties: { | |||
| currentIndex: { | |||
| type: String, | |||
| value: '0', | |||
| } | |||
| }, | |||
| /** | |||
| * 组件的属性列表 | |||
| */ | |||
| properties: { | |||
| currentIndex: { | |||
| type: String, | |||
| value: '0', | |||
| } | |||
| }, | |||
| /** | |||
| * 组件的初始数据 | |||
| */ | |||
| data: { | |||
| list: [ | |||
| { | |||
| text: "首页", | |||
| pagePath: "/pages/index/index", | |||
| iconPath: "/images/tabbar/home-bar.png", | |||
| selectedIconPath: "/images/tabbar/home-bar.png", | |||
| }, | |||
| { | |||
| text: "发布需求", | |||
| pagePath: "/pages/releaseModule/index", | |||
| iconPath: "/images/tabbar/release-bar.png", | |||
| selectedIconPath: "/images/tabbar/release-bar.png", | |||
| }, | |||
| { | |||
| text: "消息", | |||
| pagePath: "/pages/msgModule/index", | |||
| iconPath: "/images/tabbar/msg-bar.png", | |||
| selectedIconPath: "/images/tabbar/msg-bar.png", | |||
| }, | |||
| { | |||
| text: "我的", | |||
| pagePath: "/pages/myModule/index", | |||
| iconPath: "/images/tabbar/my-bar.png", | |||
| selectedIconPath: "/images/tabbar/my-bar.png", | |||
| }, | |||
| ] | |||
| }, | |||
| /** | |||
| * 组件的初始数据 | |||
| */ | |||
| data: { | |||
| list: [ | |||
| { | |||
| text: "首页", | |||
| pagePath: "/pages/index/index", | |||
| iconPath: "/images/tabbar/home-bar.png", | |||
| selectedIconPath: "/images/tabbar/home-bar.png", | |||
| }, | |||
| { | |||
| text: "发布需求", | |||
| pagePath: "/pages/releaseModule/index", | |||
| iconPath: "/images/tabbar/release-bar.png", | |||
| selectedIconPath: "/images/tabbar/release-bar.png", | |||
| }, | |||
| { | |||
| text: "消息", | |||
| pagePath: "/pages/msgModule/index", | |||
| iconPath: "/images/tabbar/msg-bar.png", | |||
| selectedIconPath: "/images/tabbar/msg-bar.png", | |||
| }, | |||
| { | |||
| text: "我的", | |||
| pagePath: "/pages/myModule/index", | |||
| iconPath: "/images/tabbar/my-bar.png", | |||
| selectedIconPath: "/images/tabbar/my-bar.png", | |||
| }, | |||
| ] | |||
| }, | |||
| /** | |||
| * 组件的方法列表 | |||
| */ | |||
| methods: { | |||
| tabChange(e) { | |||
| console.log('tab change', e) | |||
| const url = e.detail.item.pagePath; | |||
| wx.redirectTo({ url }); | |||
| // wx.navigateTo({ url }) | |||
| /** | |||
| * 组件的方法列表 | |||
| */ | |||
| methods: { | |||
| tabChange(e) { | |||
| if (e.detail.item.text == "发布需求" || e.detail.item.text == "消息") { | |||
| if (!app.globalData.customerId) { | |||
| app.goLogin(); | |||
| return | |||
| } | |||
| } | |||
| const url = e.detail.item.pagePath; | |||
| wx.redirectTo({ url }); | |||
| } | |||
| } | |||
| } | |||
| }) | |||
| @@ -1,6 +1,16 @@ | |||
| ### 目录说明 | |||
| - index 首页 | |||
| - releaseModule 发布需求 | |||
| - index 首页 | |||
| - listDetails 详情 | |||
| - homepage 个人主页 | |||
| - releaseModule 发布需求 | |||
| - msgModule 消息 | |||
| - myModule 我的 | |||
| - outLink 用于跳转外链 | |||
| - myRelease 我发布的需求 | |||
| - myCollect 我收藏的需求 | |||
| - myAttention 我关注的类型 | |||
| - outLink 用于跳转外链 | |||
| - login 登录页 | |||
| @@ -1,4 +1,6 @@ | |||
| // pages/login/login.js | |||
| const app = getApp() | |||
| const $request = require('../../utils/request.js'); | |||
| Page({ | |||
| /** | |||
| @@ -15,7 +17,7 @@ Page({ | |||
| * 生命周期函数--监听页面加载 | |||
| */ | |||
| onLoad: function (options) { | |||
| }, | |||
| // 获取手机号授权 | |||
| @@ -27,25 +29,47 @@ Page({ | |||
| this.appletLogin(iv, encryptedData) | |||
| } else { | |||
| wx.showToast({ | |||
| title: '请允许授权,获得更好的服务哦', | |||
| title: '请允许授权', | |||
| icon: "none", | |||
| duration: 3000 | |||
| }) | |||
| } | |||
| }, | |||
| // 保存用户信息 | |||
| appletLogin(iv,encryptedData){ | |||
| appletLogin(iv, encryptedData) { | |||
| let { nickName, gender, country, city, province, avatarUrl } = this.data.userInfo; | |||
| $request.get('/com/appletLogin.action', { | |||
| // openid: app.globalData.openid, | |||
| iv: iv, | |||
| encryptedData: encryptedData, | |||
| sessionKey: app.globalData.sessionKey, | |||
| loginState: "业务交流通", | |||
| avatarUrl, | |||
| gender, | |||
| nickName, | |||
| country, | |||
| province, | |||
| city | |||
| }).then(res => { | |||
| // console.log(res,'保存用户信息返回的Res') | |||
| this.getUserSession() | |||
| }).catch(error => { | |||
| console.log(error, 'error appletLogin') | |||
| }) | |||
| }, | |||
| // 获取头像昵称... | |||
| getUserProfile(e) { | |||
| if(this.data.hasUserInfo){ | |||
| // 获取用户信息弹框 | |||
| onCheckboxChange() { | |||
| if (!this.data.hasUserInfo) { | |||
| this.getUserProfile() | |||
| } else { | |||
| this.setData({ | |||
| userInfo:{}, | |||
| hasUserInfo:false | |||
| userInfo: {}, | |||
| hasUserInfo: false | |||
| }) | |||
| return | |||
| } | |||
| }, | |||
| // 获取用户信息 | |||
| getUserProfile(e) { | |||
| // 推荐使用wx.getUserProfile获取用户信息,开发者每次通过该接口获取用户个人信息均需用户确认 | |||
| // 开发者妥善保管用户快速填写的头像昵称,避免重复弹窗 | |||
| wx.getUserProfile({ | |||
| @@ -58,13 +82,35 @@ Page({ | |||
| }, | |||
| fail: () => { | |||
| wx.showToast({ | |||
| title: '请允许授权,获得更好的服务哦', | |||
| title: '请允许授权', | |||
| icon: "none", | |||
| duration: 3000 | |||
| }) | |||
| } | |||
| }) | |||
| }, | |||
| // 保存个人信息后拿到新数据 | |||
| getUserSession() { | |||
| let that = this | |||
| wx.showLoading({ | |||
| title: '加载中', | |||
| mask: true | |||
| }) | |||
| $request.post('/script/getSession.action', {}).then(res => { | |||
| console.log(res,'getUserSession---res') | |||
| wx.hideLoading() | |||
| app.globalData.customerId = res.data.customer.customerId | |||
| // wx.navigateTo({ | |||
| // url: "/pages/mine/mine", //跳转页面的路径,可带参数 ?隔开,不同参数用 & 分隔;相对路径,不需要.wxml后缀 | |||
| // success: function () {}, //成功后的回调; | |||
| // fail: function () {}, //失败后的回调; | |||
| // complete: function () {} //结束后的回调(成功,失败都会执行) | |||
| // }) | |||
| }).catch(error => { | |||
| console.log(error, "获取error") | |||
| }) | |||
| }, | |||
| /** | |||
| * 用户点击右上角分享 | |||
| */ | |||
| @@ -12,7 +12,7 @@ | |||
| </view> | |||
| <view class="get-user-info"> | |||
| <van-checkbox class="info-checkbox" value="{{ hasUserInfo }}" bind:change="onCheckboxChange"> | |||
| <view bindtap="getUserProfile" class="get-user-info-btn">允许访问头像、昵称及地区信息</view> | |||
| <view class="get-user-info-btn">允许访问头像、昵称及地区信息</view> | |||
| </van-checkbox> | |||
| </view> | |||
| </view> | |||
| @@ -3,7 +3,29 @@ | |||
| const app = getApp() | |||
| Page({ | |||
| data: { | |||
| currentIndex: 2 | |||
| }, | |||
| data: { | |||
| currentIndex: 2, | |||
| pageLoading: true, | |||
| customerId: "", | |||
| // 前往关注公众号 | |||
| topShow: true, | |||
| }, | |||
| /** | |||
| * 生命周期函数--监听页面加载 | |||
| */ | |||
| onLoad() { | |||
| this.getMsgData(); | |||
| }, | |||
| closeTopShow() { | |||
| this.setData({ | |||
| topShow: false | |||
| }) | |||
| }, | |||
| getMsgData() { | |||
| setTimeout(() => { | |||
| this.setData({ | |||
| pageLoading: false | |||
| }) | |||
| }, 500); | |||
| }, | |||
| }) | |||
| @@ -1,8 +1,18 @@ | |||
| <!--pages/msgPage/msgPage.wxml--> | |||
| <view class="home-page"> | |||
| <!-- 顶部 --> | |||
| <view class="neirong">消息</view> | |||
| <view>到底</view> | |||
| <tabBar currentIndex="{{currentIndex}}"></tabBar> | |||
| </view> | |||
| <!-- pages/msgPage/msgPage.wxml --> | |||
| <view class="msg-page page-container"> | |||
| <view class="list-loading text-center" wx:if="{{ pageLoading }}"> | |||
| <van-loading size="24px">加载中...</van-loading> | |||
| </view> | |||
| <view wx:else> | |||
| <view class="top-view" wx:if="{{ topShow }}"> | |||
| <image class="msg-top-img fl" src="/images/home/msg-top-icon.png" /> | |||
| <view class="msg-text fl">关注公众号可随时接收离线消息~</view> | |||
| <van-button color="#5e73e5" round class="msg-btn-go fl" size="small">前往关注</van-button> | |||
| <image class="msg-colse-img fl" src="/images/home/close.png" bind:tap="closeTopShow"/> | |||
| </view> | |||
| <view class="msg-box-view"> | |||
| </view> | |||
| </view> | |||
| <tabBar currentIndex="{{currentIndex}}"></tabBar> | |||
| </view> | |||
| @@ -1,11 +1,35 @@ | |||
| /* pages/msgPage/msgPage.wxss */ | |||
| .home-page { | |||
| background: #f5f9ff; | |||
| padding: 20rpx; | |||
| min-height: 100%; | |||
| padding-bottom: 120rpx; | |||
| .top-view { | |||
| background: #fff; | |||
| box-sizing: border-box; | |||
| padding: 0 20rpx; | |||
| height: 88rpx; | |||
| line-height: 88rpx; | |||
| box-shadow: -1px 3px 12px 4px rgba(186, 186, 186, 0.1); | |||
| border-radius: 20rpx; | |||
| } | |||
| .top-view .msg-top-img { | |||
| width: 87rpx; | |||
| height: 67rpx; | |||
| margin-right: 26rpx; | |||
| position: relative; | |||
| top: 13rpx; | |||
| } | |||
| .top-view .msg-text{ | |||
| font-size: 24rpx; | |||
| color: #728dd4; | |||
| margin-right: 10rpx; | |||
| } | |||
| .top-view .msg-btn-go .van-button{ | |||
| width: 144rpx; | |||
| margin-right: 10rpx; | |||
| } | |||
| .neirong{ | |||
| height: 1500rpx; | |||
| .top-view .msg-colse-img{ | |||
| width: 30rpx; | |||
| height: 30rpx; | |||
| margin-left: 10rpx; | |||
| margin-top: 29rpx; | |||
| } | |||
| @@ -10,13 +10,15 @@ | |||
| <text class="sub-title">(最多可选5项)</text> | |||
| </view> | |||
| <view class="attention-info">选择后,平台推荐将更符合你的偏好</view> | |||
| <van-row class="attention-types-view clearfix" gutter="20"> | |||
| <van-col span="8" class="attention-type" wx:for="{{ types }}" wx:key="*this"> | |||
| <view class="item-type {{ item.isActive ? 'isActive' : '' }}" bindtap="changeTags" data-typename="{{ item.typeName }}"> | |||
| {{ item.typeName }} | |||
| </view> | |||
| </van-col> | |||
| </van-row> | |||
| <view class="types-box"> | |||
| <van-row class="attention-types-view clearfix" gutter="15"> | |||
| <van-col span="8" class="attention-type" wx:for="{{ types }}" wx:key="*this"> | |||
| <view class="item-type {{ item.isActive ? 'isActive' : '' }}" bindtap="changeTags" data-typename="{{ item.typeName }}"> | |||
| {{ item.typeName }} | |||
| </view> | |||
| </van-col> | |||
| </van-row> | |||
| </view> | |||
| </view> | |||
| <view class="submit-btn"> | |||
| <van-button | |||
| @@ -32,16 +32,21 @@ | |||
| /* .attention-view .attention-type{ | |||
| padding-bottom: 10rpx; | |||
| } */ | |||
| .types-box{ | |||
| box-sizing: border-box; | |||
| padding: 0 10rpx; | |||
| } | |||
| .attention-view .attention-type .item-type{ | |||
| text-align: center; | |||
| box-sizing: border-box; | |||
| height: 69rpx; | |||
| line-height: 68rpx; | |||
| height: 59rpx; | |||
| line-height: 59rpx; | |||
| border: 1px solid #556fb5; | |||
| border-radius: 34rpx; | |||
| color: #556fb5; | |||
| font-size: 31rpx; | |||
| font-size: 26rpx; | |||
| margin-bottom: 20rpx; | |||
| font-family: SourceHanSansCN-Normal; | |||
| } | |||
| .attention-view .attention-type .item-type.isActive{ | |||
| color: #fff; | |||
| @@ -8,7 +8,7 @@ Page({ | |||
| */ | |||
| data: { | |||
| currentIndex: 1, | |||
| pageLoading: false, | |||
| pageLoading: true, | |||
| tags: [], | |||
| min: 0, | |||
| max: 300, | |||
| @@ -17,8 +17,8 @@ Page({ | |||
| // 选中tag | |||
| selectedTag: [], | |||
| detailValue: "", | |||
| saveLoading:false, | |||
| businessCommunicationDemandId:null, | |||
| saveLoading: false, | |||
| businessCommunicationDemandId: null, | |||
| }, | |||
| /** | |||
| @@ -26,14 +26,14 @@ Page({ | |||
| */ | |||
| onLoad() { | |||
| const eventChannel = this.getOpenerEventChannel() | |||
| if(eventChannel.on){ | |||
| if (eventChannel.on) { | |||
| // 监听acceptDataFromOpenerPage事件,获取上一页面通过eventChannel传送到当前页面的数据 | |||
| eventChannel.on('acceptDataFromOpenerPage', data => { | |||
| let listDetail = data.listDetail; | |||
| this.setData({ | |||
| detailValue: listDetail.info, | |||
| selectedTag: listDetail.type, | |||
| businessCommunicationDemandId:listDetail.businessCommunicationDemandId | |||
| businessCommunicationDemandId: listDetail.businessCommunicationDemandId | |||
| }) | |||
| }) | |||
| } | |||
| @@ -87,9 +87,9 @@ Page({ | |||
| // 发布需求 | |||
| releaseDemands() { | |||
| this.setData({ | |||
| saveLoading:true | |||
| saveLoading: true | |||
| }) | |||
| let { selectedTag, detailValue,businessCommunicationDemandId } = this.data; | |||
| let { selectedTag, detailValue, businessCommunicationDemandId } = this.data; | |||
| let param = { | |||
| customerId: 666967, | |||
| info: this.trimRight(detailValue), | |||
| @@ -98,17 +98,17 @@ Page({ | |||
| }; | |||
| $request.post('/businessCommunicationDemand/saveDemand.action', param).then(res => { | |||
| this.setData({ | |||
| saveLoading:false | |||
| saveLoading: false | |||
| }) | |||
| let that = this; | |||
| if (res.status == 0) { | |||
| if(!businessCommunicationDemandId){ | |||
| if (!businessCommunicationDemandId) { | |||
| wx.showModal({ | |||
| title: '发布成功', | |||
| content: "请关注平台公众号,如有咨询,可及时接收消息通知!", | |||
| confirmText: "去关注", | |||
| cancelText:"关闭", | |||
| success (res1) { | |||
| cancelText: "关闭", | |||
| success(res1) { | |||
| if (res1.confirm) { | |||
| that.clearData(); | |||
| console.log('用户点击确定') | |||
| @@ -128,7 +128,7 @@ Page({ | |||
| } | |||
| } | |||
| }) | |||
| }else{ | |||
| } else { | |||
| wx.showLoading({ | |||
| title: '修改成功', | |||
| mask: true | |||
| @@ -140,16 +140,16 @@ Page({ | |||
| let prevPage = pages[pages.length - 2]; //上一个页面 | |||
| let info = prevPage.data //取上页data里的数据也可以修改 | |||
| let tempListData = info.listData; | |||
| tempListData.forEach(el=>{ | |||
| if(el.businessCommunicationDemandId == businessCommunicationDemandId){ | |||
| tempListData.forEach(el => { | |||
| if (el.businessCommunicationDemandId == businessCommunicationDemandId) { | |||
| el.info = Page.data.detailValue | |||
| } | |||
| }) | |||
| prevPage.setData({listData:tempListData })//设置数据 | |||
| prevPage.setData({ listData: tempListData })//设置数据 | |||
| wx.navigateBack() | |||
| }, 1000); | |||
| } | |||
| } else if (res.status == 501) { | |||
| wx.showModal({ | |||
| title: '发布失败', | |||
| @@ -160,18 +160,18 @@ Page({ | |||
| }).catch(err => { | |||
| console.log(err); | |||
| this.setData({ | |||
| saveLoading:false | |||
| saveLoading: false | |||
| }) | |||
| }) | |||
| }, | |||
| clearData(){ | |||
| clearData() { | |||
| let tags = this.data.tags; | |||
| tags.forEach(el => { | |||
| el.isActive = ''; | |||
| }) | |||
| this.setData({ | |||
| selectedTag:[], | |||
| detailValue:"", | |||
| selectedTag: [], | |||
| detailValue: "", | |||
| tags | |||
| }) | |||
| }, | |||