appid: "", | appid: "", | ||||
sessionKey: "", | sessionKey: "", | ||||
suiteCode: "", | suiteCode: "", | ||||
customerId: "", | |||||
customerId: "666967", | |||||
}, | }, | ||||
// 跳转登录页 | // 跳转登录页 | ||||
goLogin(e) { | goLogin(e) { |
// components/tabbar/tabbar.js | // components/tabbar/tabbar.js | ||||
const app = getApp() | const app = getApp() | ||||
Component({ | 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 }); | |||||
} | |||||
} | } | ||||
} | |||||
}) | }) | ||||
### 目录说明 | ### 目录说明 | ||||
- index 首页 | |||||
- releaseModule 发布需求 | |||||
- index 首页 | |||||
- listDetails 详情 | |||||
- homepage 个人主页 | |||||
- releaseModule 发布需求 | |||||
- msgModule 消息 | - msgModule 消息 | ||||
- myModule 我的 | - myModule 我的 | ||||
- outLink 用于跳转外链 | |||||
- myRelease 我发布的需求 | |||||
- myCollect 我收藏的需求 | |||||
- myAttention 我关注的类型 | |||||
- outLink 用于跳转外链 | |||||
- login 登录页 |
// pages/login/login.js | // pages/login/login.js | ||||
const app = getApp() | |||||
const $request = require('../../utils/request.js'); | |||||
Page({ | Page({ | ||||
/** | /** | ||||
* 生命周期函数--监听页面加载 | * 生命周期函数--监听页面加载 | ||||
*/ | */ | ||||
onLoad: function (options) { | onLoad: function (options) { | ||||
}, | }, | ||||
// 获取手机号授权 | // 获取手机号授权 | ||||
this.appletLogin(iv, encryptedData) | this.appletLogin(iv, encryptedData) | ||||
} else { | } else { | ||||
wx.showToast({ | wx.showToast({ | ||||
title: '请允许授权,获得更好的服务哦', | |||||
title: '请允许授权', | |||||
icon: "none", | icon: "none", | ||||
duration: 3000 | 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({ | this.setData({ | ||||
userInfo:{}, | |||||
hasUserInfo:false | |||||
userInfo: {}, | |||||
hasUserInfo: false | |||||
}) | }) | ||||
return | |||||
} | } | ||||
}, | |||||
// 获取用户信息 | |||||
getUserProfile(e) { | |||||
// 推荐使用wx.getUserProfile获取用户信息,开发者每次通过该接口获取用户个人信息均需用户确认 | // 推荐使用wx.getUserProfile获取用户信息,开发者每次通过该接口获取用户个人信息均需用户确认 | ||||
// 开发者妥善保管用户快速填写的头像昵称,避免重复弹窗 | // 开发者妥善保管用户快速填写的头像昵称,避免重复弹窗 | ||||
wx.getUserProfile({ | wx.getUserProfile({ | ||||
}, | }, | ||||
fail: () => { | fail: () => { | ||||
wx.showToast({ | wx.showToast({ | ||||
title: '请允许授权,获得更好的服务哦', | |||||
title: '请允许授权', | |||||
icon: "none", | icon: "none", | ||||
duration: 3000 | 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") | |||||
}) | |||||
}, | |||||
/** | /** | ||||
* 用户点击右上角分享 | * 用户点击右上角分享 | ||||
*/ | */ |
</view> | </view> | ||||
<view class="get-user-info"> | <view class="get-user-info"> | ||||
<van-checkbox class="info-checkbox" value="{{ hasUserInfo }}" bind:change="onCheckboxChange"> | <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> | </van-checkbox> | ||||
</view> | </view> | ||||
</view> | </view> |
const app = getApp() | const app = getApp() | ||||
Page({ | 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); | |||||
}, | |||||
}) | }) |
<!--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> |
/* pages/msgPage/msgPage.wxss */ | /* 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; | |||||
} | } |
<text class="sub-title">(最多可选5项)</text> | <text class="sub-title">(最多可选5项)</text> | ||||
</view> | </view> | ||||
<view class="attention-info">选择后,平台推荐将更符合你的偏好</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> | ||||
<view class="submit-btn"> | <view class="submit-btn"> | ||||
<van-button | <van-button |
/* .attention-view .attention-type{ | /* .attention-view .attention-type{ | ||||
padding-bottom: 10rpx; | padding-bottom: 10rpx; | ||||
} */ | } */ | ||||
.types-box{ | |||||
box-sizing: border-box; | |||||
padding: 0 10rpx; | |||||
} | |||||
.attention-view .attention-type .item-type{ | .attention-view .attention-type .item-type{ | ||||
text-align: center; | text-align: center; | ||||
box-sizing: border-box; | box-sizing: border-box; | ||||
height: 69rpx; | |||||
line-height: 68rpx; | |||||
height: 59rpx; | |||||
line-height: 59rpx; | |||||
border: 1px solid #556fb5; | border: 1px solid #556fb5; | ||||
border-radius: 34rpx; | border-radius: 34rpx; | ||||
color: #556fb5; | color: #556fb5; | ||||
font-size: 31rpx; | |||||
font-size: 26rpx; | |||||
margin-bottom: 20rpx; | margin-bottom: 20rpx; | ||||
font-family: SourceHanSansCN-Normal; | |||||
} | } | ||||
.attention-view .attention-type .item-type.isActive{ | .attention-view .attention-type .item-type.isActive{ | ||||
color: #fff; | color: #fff; |
*/ | */ | ||||
data: { | data: { | ||||
currentIndex: 1, | currentIndex: 1, | ||||
pageLoading: false, | |||||
pageLoading: true, | |||||
tags: [], | tags: [], | ||||
min: 0, | min: 0, | ||||
max: 300, | max: 300, | ||||
// 选中tag | // 选中tag | ||||
selectedTag: [], | selectedTag: [], | ||||
detailValue: "", | detailValue: "", | ||||
saveLoading:false, | |||||
businessCommunicationDemandId:null, | |||||
saveLoading: false, | |||||
businessCommunicationDemandId: null, | |||||
}, | }, | ||||
/** | /** | ||||
*/ | */ | ||||
onLoad() { | onLoad() { | ||||
const eventChannel = this.getOpenerEventChannel() | const eventChannel = this.getOpenerEventChannel() | ||||
if(eventChannel.on){ | |||||
if (eventChannel.on) { | |||||
// 监听acceptDataFromOpenerPage事件,获取上一页面通过eventChannel传送到当前页面的数据 | // 监听acceptDataFromOpenerPage事件,获取上一页面通过eventChannel传送到当前页面的数据 | ||||
eventChannel.on('acceptDataFromOpenerPage', data => { | eventChannel.on('acceptDataFromOpenerPage', data => { | ||||
let listDetail = data.listDetail; | let listDetail = data.listDetail; | ||||
this.setData({ | this.setData({ | ||||
detailValue: listDetail.info, | detailValue: listDetail.info, | ||||
selectedTag: listDetail.type, | selectedTag: listDetail.type, | ||||
businessCommunicationDemandId:listDetail.businessCommunicationDemandId | |||||
businessCommunicationDemandId: listDetail.businessCommunicationDemandId | |||||
}) | }) | ||||
}) | }) | ||||
} | } | ||||
// 发布需求 | // 发布需求 | ||||
releaseDemands() { | releaseDemands() { | ||||
this.setData({ | this.setData({ | ||||
saveLoading:true | |||||
saveLoading: true | |||||
}) | }) | ||||
let { selectedTag, detailValue,businessCommunicationDemandId } = this.data; | |||||
let { selectedTag, detailValue, businessCommunicationDemandId } = this.data; | |||||
let param = { | let param = { | ||||
customerId: 666967, | customerId: 666967, | ||||
info: this.trimRight(detailValue), | info: this.trimRight(detailValue), | ||||
}; | }; | ||||
$request.post('/businessCommunicationDemand/saveDemand.action', param).then(res => { | $request.post('/businessCommunicationDemand/saveDemand.action', param).then(res => { | ||||
this.setData({ | this.setData({ | ||||
saveLoading:false | |||||
saveLoading: false | |||||
}) | }) | ||||
let that = this; | let that = this; | ||||
if (res.status == 0) { | if (res.status == 0) { | ||||
if(!businessCommunicationDemandId){ | |||||
if (!businessCommunicationDemandId) { | |||||
wx.showModal({ | wx.showModal({ | ||||
title: '发布成功', | title: '发布成功', | ||||
content: "请关注平台公众号,如有咨询,可及时接收消息通知!", | content: "请关注平台公众号,如有咨询,可及时接收消息通知!", | ||||
confirmText: "去关注", | confirmText: "去关注", | ||||
cancelText:"关闭", | |||||
success (res1) { | |||||
cancelText: "关闭", | |||||
success(res1) { | |||||
if (res1.confirm) { | if (res1.confirm) { | ||||
that.clearData(); | that.clearData(); | ||||
console.log('用户点击确定') | console.log('用户点击确定') | ||||
} | } | ||||
} | } | ||||
}) | }) | ||||
}else{ | |||||
} else { | |||||
wx.showLoading({ | wx.showLoading({ | ||||
title: '修改成功', | title: '修改成功', | ||||
mask: true | mask: true | ||||
let prevPage = pages[pages.length - 2]; //上一个页面 | let prevPage = pages[pages.length - 2]; //上一个页面 | ||||
let info = prevPage.data //取上页data里的数据也可以修改 | let info = prevPage.data //取上页data里的数据也可以修改 | ||||
let tempListData = info.listData; | let tempListData = info.listData; | ||||
tempListData.forEach(el=>{ | |||||
if(el.businessCommunicationDemandId == businessCommunicationDemandId){ | |||||
tempListData.forEach(el => { | |||||
if (el.businessCommunicationDemandId == businessCommunicationDemandId) { | |||||
el.info = Page.data.detailValue | el.info = Page.data.detailValue | ||||
} | } | ||||
}) | }) | ||||
prevPage.setData({listData:tempListData })//设置数据 | |||||
prevPage.setData({ listData: tempListData })//设置数据 | |||||
wx.navigateBack() | wx.navigateBack() | ||||
}, 1000); | }, 1000); | ||||
} | } | ||||
} else if (res.status == 501) { | } else if (res.status == 501) { | ||||
wx.showModal({ | wx.showModal({ | ||||
title: '发布失败', | title: '发布失败', | ||||
}).catch(err => { | }).catch(err => { | ||||
console.log(err); | console.log(err); | ||||
this.setData({ | this.setData({ | ||||
saveLoading:false | |||||
saveLoading: false | |||||
}) | }) | ||||
}) | }) | ||||
}, | }, | ||||
clearData(){ | |||||
clearData() { | |||||
let tags = this.data.tags; | let tags = this.data.tags; | ||||
tags.forEach(el => { | tags.forEach(el => { | ||||
el.isActive = ''; | el.isActive = ''; | ||||
}) | }) | ||||
this.setData({ | this.setData({ | ||||
selectedTag:[], | |||||
detailValue:"", | |||||
selectedTag: [], | |||||
detailValue: "", | |||||
tags | tags | ||||
}) | }) | ||||
}, | }, |