@@ -1,50 +1,92 @@ | |||
// app.js | |||
App({ | |||
onLaunch() { | |||
// 展示本地存储能力 | |||
const logs = wx.getStorageSync('logs') || [] | |||
logs.unshift(Date.now()) | |||
wx.setStorageSync('logs', logs) | |||
onLaunch() { | |||
// 版本更新 | |||
const updateManager = wx.getUpdateManager() | |||
// 登录 | |||
wx.login({ | |||
success: (res) => { | |||
if (res.code) { | |||
//获取openid | |||
wx.request({ | |||
url: this.mangerUrl + '/service/weixin/getWxOpenId', | |||
data: { | |||
appNum: 11, | |||
js_code: res.code | |||
}, | |||
success: (result) => { | |||
if (!!result.data && result.data.openid) { | |||
// this.globalData.openid = result.data.openid; | |||
this.globalData.appid = result.data.appid; | |||
this.globalData.sessionKey = result.data.sessionKey; | |||
updateManager.onCheckForUpdate(function (res) { | |||
// 请求完新版本信息的回调 | |||
if (res.hasUpdate) { | |||
//准备更新 | |||
updateManager.onUpdateReady(function () { | |||
wx.showModal({ | |||
title: '业务交流通更新啦~', | |||
content: '新版本已经准备好,请重启应用', | |||
showCancel: false, | |||
success: function (res) { | |||
if (res.confirm) { | |||
// 新的版本已经下载好,调用 applyUpdate 应用新版本并重启 | |||
updateManager.applyUpdate() | |||
} | |||
} | |||
} | |||
}) | |||
}) | |||
} else { | |||
wx.showToast({ | |||
title: '获取登录信息失败', | |||
icon: 'none', | |||
duration: 2000 | |||
//更新失败 | |||
updateManager.onUpdateFailed(function () { | |||
wx.showModal({ | |||
title: '出错啦', | |||
content: '更新失败,请检查您的网络状况', | |||
showCancel: false, | |||
success: function (res) { | |||
if (res.confirm) { | |||
// 新的版本已经下载好,调用 applyUpdate 应用新版本并重启 | |||
updateManager.applyUpdate() | |||
} | |||
} | |||
}) | |||
}) | |||
} | |||
} | |||
}) | |||
}, | |||
globalData: { | |||
userInfo: null, | |||
openid: "oBkT7vu1Q8l-xsbux_i1FNmRWuJ4", | |||
appid: "", | |||
sessionKey: "", | |||
suiteCode: "", | |||
customerId: "", | |||
}, | |||
// mangerUrl: 'http://test2.hhrchina.com', | |||
mangerUrl: "http://192.168.18.156", | |||
// mangerUrl: "https://www.hhrchina.com", | |||
// mangerUrlPath: "https://www.hhrchina.com", | |||
} | |||
}) | |||
// 登录 | |||
wx.login({ | |||
success: (res) => { | |||
if (res.code) { | |||
//获取openid | |||
wx.request({ | |||
url: this.mangerUrl + '/service/weixin/getWxOpenId', | |||
data: { | |||
appNum: 12, | |||
js_code: res.code | |||
}, | |||
success: (result) => { | |||
if (!!result.data && result.data.openid) { | |||
console.log(result, 'result'); | |||
// this.globalData.openid = result.data.openid; | |||
this.globalData.appid = result.data.appid; | |||
// this.globalData.sessionKey = result.data.sessionKey; | |||
} | |||
} | |||
}) | |||
} else { | |||
wx.showToast({ | |||
title: '获取登录信息失败', | |||
icon: 'none', | |||
duration: 2000 | |||
}) | |||
} | |||
} | |||
}) | |||
}, | |||
globalData: { | |||
userInfo: null, | |||
openid: "oBkT7vu1Q8l-xsbux_i1FNmRWuJ4", | |||
appid: "", | |||
sessionKey: "", | |||
suiteCode: "", | |||
customerId: "", | |||
}, | |||
// 跳转登录页 | |||
goLogin(e) { | |||
wx.navigateTo({ | |||
url: "/pages/login/login" | |||
}) | |||
}, | |||
// mangerUrl: 'http://test2.hhrchina.com', | |||
mangerUrl: "http://192.168.18.156", | |||
// mangerUrl: "https://www.hhrchina.com", | |||
// mangerUrlPath: "https://www.hhrchina.com", | |||
}) |
@@ -1,14 +1,16 @@ | |||
{ | |||
"pages": [ | |||
"pages/myModule/index", | |||
"pages/index/index", | |||
"pages/myModule/index", | |||
"pages/logs/logs", | |||
"pages/releaseModule/index", | |||
"pages/msgModule/index", | |||
"pages/index/components/listDetails/Details", | |||
"pages/index/components/homepage/homepage", | |||
"pages/myModule/components/myRelease/myRelease", | |||
"pages/myModule/components/myAttention/myAttention" | |||
"pages/myModule/components/myAttention/myAttention", | |||
"pages/outLink/outLink", | |||
"pages/login/login" | |||
], | |||
"usingComponents": { | |||
"tabBar": "/components/tabbar/tabbar", | |||
@@ -17,7 +19,8 @@ | |||
"van-icon": "/miniprogram_npm/@vant/weapp/icon", | |||
"van-row": "/miniprogram_npm/@vant/weapp/row", | |||
"van-col": "/miniprogram_npm/@vant/weapp/col", | |||
"van-button": "/miniprogram_npm/@vant/weapp/button" | |||
"van-button": "/miniprogram_npm/@vant/weapp/button", | |||
"van-checkbox": "@vant/weapp/checkbox/index" | |||
}, | |||
"window": { | |||
"backgroundTextStyle": "light", |
@@ -2,4 +2,5 @@ | |||
- index 首页 | |||
- releaseModule 发布需求 | |||
- msgModule 消息 | |||
- myModule 我的 | |||
- myModule 我的 | |||
- outLink 用于跳转外链 |
@@ -160,7 +160,7 @@ Page({ | |||
type = ""; | |||
} | |||
$request.get('/businessCommunicationDemand/getDemandByKeywordOrType.action', | |||
{ page, size, keyword, type,isInterest:0 } | |||
{ page, size, keyword, type, isInterest: 0 } | |||
).then(res => { | |||
// console.log(res); | |||
this.setData({ | |||
@@ -172,7 +172,7 @@ Page({ | |||
// 先push数据 | |||
tempListData.push(...datas.demandList); | |||
tempListData.forEach(el => { | |||
el.createdOn = $util.formatTime(new Date(el.createdOn),true); | |||
el.createdOn = $util.formatTime(new Date(el.createdOn), true); | |||
if (typeof el.type == 'string') { | |||
el.type = el.type.split(','); | |||
} | |||
@@ -215,59 +215,7 @@ Page({ | |||
this.getListData(); | |||
} | |||
}, | |||
/** | |||
* 授权获取加密信息 | |||
*/ | |||
getPhoneNumber(e) { | |||
if (!!e.detail.iv && !!e.detail.encryptedData) { | |||
const iv = e.detail.iv | |||
const encryptedData = e.detail.encryptedData | |||
this.appletLogin(iv, encryptedData) | |||
} else { | |||
wx.showToast({ | |||
title: '请允许授权,获得更好的服务哦', | |||
icon: "none", | |||
duration: 3000 | |||
}) | |||
} | |||
}, | |||
/** | |||
* 用户授权信息存储 | |||
*/ | |||
appletLogin(iv, encrypted) { | |||
$request.get('/com/appletLogin.action', { | |||
// openid: app.globalData.openid, | |||
iv: iv, | |||
encryptedData: encrypted, | |||
sessionKey: app.globalData.sessionKey, | |||
loginState: "业务交流通", | |||
}).then(res => { | |||
this.getUserSession() | |||
}).catch(error => { | |||
console.log(error, 'error appletLogin') | |||
}) | |||
}, | |||
/** | |||
* 获取用户身份信息 | |||
*/ | |||
getUserSession() { | |||
let that = this | |||
wx.showLoading({ | |||
title: '加载中', | |||
mask: true | |||
}) | |||
$request.post('/script/getSession.action', {}).then(res => { | |||
// 如果有传入的urlcustomer | |||
// 跳转到传入地址页面 | |||
wx.setStorageSync('customerId', res.data.customer.customerId) //存储用户customerId到本地 | |||
that.setData({ | |||
isLogin: true | |||
}) | |||
app.globalData.customerId = res.data.customer.customerId | |||
wx.hideLoading() | |||
that.checkIsFinish(res.data.customer.customerId, 1) | |||
}).catch(error => { | |||
console.log(error, "获取error") | |||
}) | |||
goLogin() { | |||
app.goLogin(); | |||
}, | |||
}) |
@@ -15,7 +15,7 @@ | |||
全方位需求 | |||
<text class="sub-title">交流平台</text> | |||
</view> | |||
<button type="default" plain open-type="getPhoneNumber" bindgetphonenumber="getPhoneNumber" class="set-attention" id="shouquan"> | |||
<button type="default" plain class="set-attention" id="shouquan" bindtap="goLogin"> | |||
设置关注类型喜好 >> | |||
</button> | |||
<image class="header-img" src="/images/home/header-icon.png" /> |
@@ -0,0 +1,74 @@ | |||
// pages/login/login.js | |||
Page({ | |||
/** | |||
* 页面的初始数据 | |||
*/ | |||
data: { | |||
userInfo: {}, | |||
// 是否获取到了用户信息 | |||
hasUserInfo: false, | |||
}, | |||
/** | |||
* 生命周期函数--监听页面加载 | |||
*/ | |||
onLoad: function (options) { | |||
}, | |||
// 获取手机号授权 | |||
getPhoneNumber(e) { | |||
console.log(e); | |||
if (!!e.detail.iv && !!e.detail.encryptedData) { | |||
const iv = e.detail.iv | |||
const encryptedData = e.detail.encryptedData | |||
this.appletLogin(iv, encryptedData) | |||
} else { | |||
wx.showToast({ | |||
title: '请允许授权,获得更好的服务哦', | |||
icon: "none", | |||
duration: 3000 | |||
}) | |||
} | |||
}, | |||
// 保存用户信息 | |||
appletLogin(iv,encryptedData){ | |||
}, | |||
// 获取头像昵称... | |||
getUserProfile(e) { | |||
if(this.data.hasUserInfo){ | |||
this.setData({ | |||
userInfo:{}, | |||
hasUserInfo:false | |||
}) | |||
return | |||
} | |||
// 推荐使用wx.getUserProfile获取用户信息,开发者每次通过该接口获取用户个人信息均需用户确认 | |||
// 开发者妥善保管用户快速填写的头像昵称,避免重复弹窗 | |||
wx.getUserProfile({ | |||
desc: '用于完善会员资料', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写 | |||
success: (res) => { | |||
this.setData({ | |||
userInfo: res.userInfo, | |||
hasUserInfo: true | |||
}) | |||
}, | |||
fail: () => { | |||
wx.showToast({ | |||
title: '请允许授权,获得更好的服务哦', | |||
icon: "none", | |||
duration: 3000 | |||
}) | |||
} | |||
}) | |||
}, | |||
/** | |||
* 用户点击右上角分享 | |||
*/ | |||
onShareAppMessage: function () { | |||
} | |||
}) |
@@ -0,0 +1,3 @@ | |||
{ | |||
"usingComponents": {} | |||
} |
@@ -0,0 +1,18 @@ | |||
<!-- pages/login/login.wxml --> | |||
<view class="login-page"> | |||
<view class="qr-code-view"> | |||
<view class="qr-code-img"></view> | |||
</view> | |||
<view class="title-view">申请获取以下权限</view> | |||
<view class="sub-title-view">个人中心需要获得您的手机号</view> | |||
<view class="submin-btn"> | |||
<button class="login-get-phone-number" open-type="getPhoneNumber" bindgetphonenumber="getPhoneNumber" disabled="{{ !hasUserInfo }}"> | |||
授权手机号 | |||
</button> | |||
</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> | |||
</van-checkbox> | |||
</view> | |||
</view> |
@@ -0,0 +1,64 @@ | |||
/* pages/login/login.wxss */ | |||
.login-page { | |||
background: #f2f4f9; | |||
min-height: 100vh; | |||
box-sizing: border-box; | |||
padding: 0 45rpx; | |||
font-family: SourceHanSansCN-Medium; | |||
} | |||
.qr-code-view { | |||
height: 500rpx; | |||
border-bottom: 1rpx solid #cbcfd9; | |||
box-sizing: border-box; | |||
padding-top: 116rpx; | |||
margin-bottom: 30rpx; | |||
} | |||
.qr-code-view .qr-code-img { | |||
width: 258rpx; | |||
height: 258rpx; | |||
margin: 0 auto; | |||
background: green; | |||
} | |||
.title-view { | |||
color: #333033; | |||
font-size: 28rpx; | |||
font-weight: bold; | |||
margin-bottom: 30rpx; | |||
} | |||
.sub-title-view { | |||
font-size: 24rpx; | |||
color: #999; | |||
margin-bottom: 120rpx; | |||
} | |||
.login-get-phone-number { | |||
border-radius: 40rpx; | |||
font-size: 30rpx; | |||
color: #ffffff; | |||
background: #5e73e5; | |||
height: 86rpx; | |||
line-height: 86rpx; | |||
width: 611rpx; | |||
} | |||
.login-get-phone-number[disabled] { | |||
background-color: #999999!important; | |||
color: #fff!important; | |||
} | |||
.get-user-info{ | |||
margin-top: 20rpx; | |||
text-align: center; | |||
} | |||
.get-user-info .info-checkbox{ | |||
display: inline-block; | |||
} | |||
.get-user-info-btn { | |||
font-size: 24rpx; | |||
color: #999999; | |||
} |
@@ -11,7 +11,8 @@ Page({ | |||
isPartner: true, | |||
address: "上海市·徐汇区", | |||
// customerId:666967, | |||
customerId:666678, | |||
customerId: 666678, | |||
isLogin: false, | |||
}, | |||
listData: [ | |||
{ | |||
@@ -32,10 +33,17 @@ Page({ | |||
}, | |||
], | |||
}, | |||
// 前往登录页 | |||
goLogin(e) { | |||
app.goLogin(); | |||
}, | |||
// 路由跳转 | |||
goRouterPage(e) { | |||
let code = e.currentTarget.dataset.code; | |||
let customerid = this.data.user.customerId; | |||
if(!customerid){ | |||
app.goLogin(); | |||
} | |||
let url = ""; | |||
// 前往主页 | |||
if (code == 'homepage') { | |||
@@ -53,6 +61,10 @@ Page({ | |||
if (code == 'my-attention') { | |||
url = "/pages/myModule/components/myAttention/myAttention"; | |||
} | |||
// 前往联系客服 | |||
if (code == 'my-contact') { | |||
url = "/pages/outLink/outLink"; | |||
} | |||
wx.navigateTo({ | |||
url, | |||
success: function (res) { |
@@ -1,7 +1,7 @@ | |||
<!-- pages/myPage/myPage.wxml --> | |||
<view class="my-page page-container"> | |||
<!-- 顶部 --> | |||
<view class="header card-view"> | |||
<view class="header card-view" wx:if="{{ isLogin }}"> | |||
<view class="chatHeads fl"> | |||
<image class="chatHeads-img" src="{{ user.chatHeads }}" /> | |||
</view> | |||
@@ -16,9 +16,7 @@ | |||
<view class="user-name-box fl" wx:else> | |||
<view class="user-name yichu fl">{{ user.name }}</view> | |||
</view> | |||
<view class="user-address fl"> | |||
{{ user.address }} | |||
</view> | |||
<view class="user-address fl">{{ user.address }}</view> | |||
<view class="show-home-page fl" bindtap="goRouterPage" data-code="homepage"> | |||
<image class="home-page-img" src="/images/home/home-page-icon.png" /> | |||
查 看 主 页 >> | |||
@@ -29,6 +27,15 @@ | |||
退出 | |||
</view> | |||
</view> | |||
<view class="header card-view clearfix" wx:else> | |||
<image class="not-login-img fl" src="/images/home/not-login.png" /> | |||
<view class="not-login-view fl"> | |||
<view class="not-login-info">您尚未登录,请登陆后操作</view> | |||
<view class="login-btn-view"> | |||
<button class="login-btn fl" bindtap="goLogin">立即登录</button> | |||
</view> | |||
</view> | |||
</view> | |||
<!-- 内容 --> | |||
<view class="content card-view"> | |||
<view class="li-view" wx:for="{{ listData }}" wx:key="*this" bindtap="goRouterPage" data-code="{{ item.code }}"> |
@@ -165,4 +165,39 @@ | |||
.content .li-view .right-icon { | |||
font-size: 29rpx; | |||
color: #d7dae4; | |||
} | |||
} | |||
.not-login-img { | |||
width: 128rpx; | |||
height: 128rpx; | |||
margin-left: 58rpx; | |||
} | |||
.not-login-view { | |||
height: 128rpx; | |||
width: calc(100% - 186rpx); | |||
box-sizing: border-box; | |||
padding-left: 30rpx; | |||
} | |||
.not-login-view .not-login-info{ | |||
font-size: 26rpx; | |||
color: #728dd4; | |||
margin: 15rpx 0; | |||
} | |||
.login-btn-view { | |||
height: 58rpx; | |||
} | |||
.login-btn{ | |||
width: 194rpx; | |||
height: 58rpx; | |||
line-height: 58rpx; | |||
background-image: linear-gradient(-60deg, | |||
#617bff 0%, | |||
#68c0fe 100%); | |||
box-shadow: 0rpx 3rpx 13rpx 0rpx | |||
rgba(52, 67, 193, 0.28); | |||
border-radius: 29rpx; | |||
font-size: 22rpx; | |||
color: #ffffff; | |||
margin-left: 35rpx; | |||
} |
@@ -0,0 +1,66 @@ | |||
// pages/outLink/outLink.js | |||
Page({ | |||
/** | |||
* 页面的初始数据 | |||
*/ | |||
data: { | |||
}, | |||
/** | |||
* 生命周期函数--监听页面加载 | |||
*/ | |||
onLoad: function (options) { | |||
}, | |||
/** | |||
* 生命周期函数--监听页面初次渲染完成 | |||
*/ | |||
onReady: function () { | |||
}, | |||
/** | |||
* 生命周期函数--监听页面显示 | |||
*/ | |||
onShow: function () { | |||
}, | |||
/** | |||
* 生命周期函数--监听页面隐藏 | |||
*/ | |||
onHide: function () { | |||
}, | |||
/** | |||
* 生命周期函数--监听页面卸载 | |||
*/ | |||
onUnload: function () { | |||
}, | |||
/** | |||
* 页面相关事件处理函数--监听用户下拉动作 | |||
*/ | |||
onPullDownRefresh: function () { | |||
}, | |||
/** | |||
* 页面上拉触底事件的处理函数 | |||
*/ | |||
onReachBottom: function () { | |||
}, | |||
/** | |||
* 用户点击右上角分享 | |||
*/ | |||
onShareAppMessage: function () { | |||
} | |||
}) |
@@ -0,0 +1,3 @@ | |||
{ | |||
"usingComponents": {} | |||
} |
@@ -0,0 +1,2 @@ | |||
<!--pages/outLink/outLink.wxml--> | |||
<web-view src="https://www.baidu.com/"> </web-view> |
@@ -0,0 +1 @@ | |||
/* pages/outLink/outLink.wxss */ |