// app.js | // app.js | ||||
App({ | App({ | ||||
onLaunch() { | onLaunch() { | ||||
// 获取本地用户信息 | |||||
const userInfo = wx.getStorageSync('userInfo') || null; | |||||
if(userInfo){ | |||||
this.globalData.userInfo = userInfo; | |||||
console.log(`从本地拿到的userInfo`) | |||||
} | |||||
// 版本更新 | // 版本更新 | ||||
const updateManager = wx.getUpdateManager() | const updateManager = wx.getUpdateManager() | ||||
js_code: res.code | js_code: res.code | ||||
}, | }, | ||||
success: (result) => { | success: (result) => { | ||||
console.log("微信LOGIN result") | |||||
if (!!result.data && result.data.openid) { | if (!!result.data && result.data.openid) { | ||||
console.log(result, 'result'); | |||||
// this.globalData.openid = result.data.openid; | // this.globalData.openid = result.data.openid; | ||||
this.globalData.appid = result.data.appid; | this.globalData.appid = result.data.appid; | ||||
// this.globalData.sessionKey = result.data.sessionKey; | |||||
this.globalData.sessionKey = result.data.sessionKey; | |||||
} | } | ||||
} | } | ||||
}) | }) | ||||
globalData: { | globalData: { | ||||
userInfo: null, | userInfo: null, | ||||
openid: "oBkT7vu1Q8l-xsbux_i1FNmRWuJ4", | openid: "oBkT7vu1Q8l-xsbux_i1FNmRWuJ4", | ||||
// openid:"", | |||||
appid: "", | appid: "", | ||||
sessionKey: "", | sessionKey: "", | ||||
suiteCode: "", | suiteCode: "", | ||||
customerId: "666967", | |||||
customerId: null, | |||||
}, | }, | ||||
// 跳转登录页 | // 跳转登录页 | ||||
goLogin(e) { | goLogin(e) { |
// components/listItem/listItem.js | // components/listItem/listItem.js | ||||
const app = getApp() | |||||
Component({ | Component({ | ||||
/** | /** | ||||
* 组件的属性列表 | * 组件的属性列表 | ||||
productCollect(e){ | productCollect(e){ | ||||
this.triggerEvent('changeCollect'); | this.triggerEvent('changeCollect'); | ||||
}, | }, | ||||
// 聊一聊 | |||||
goToChat(){ | |||||
if(!app.globalData.customerId){ | |||||
app.goLogin(); | |||||
return | |||||
} | |||||
console.log(`点击了聊一聊`) | |||||
}, | |||||
} | } | ||||
}) | }) |
<view bindtap="goDetails" data-item="{{ item }}"> | <view bindtap="goDetails" data-item="{{ item }}"> | ||||
<!-- 详情 --> | <!-- 详情 --> | ||||
<view> | <view> | ||||
<text space class="list-details-text" user-select wx:if="{{ pageStatus == 'detatil' || pageStatus == 'myRelease' }}"> | |||||
{{ item.info }} | |||||
<text space class="list-details-text" user-select wx:if="{{ pageStatus == 'detatil' || pageStatus == 'myRelease' }}">{{ item.info }} | |||||
</text> | </text> | ||||
<text space wx:elif="{{ pageStatus == 'myCollect' }}" class="list-details-text need"><text style="color:red">{{ item.isDeleted > 0 ? '【已删除】' : item.state < 0 ? '【已下架】' : '' }}</text>{{ item.info }} | <text space wx:elif="{{ pageStatus == 'myCollect' }}" class="list-details-text need"><text style="color:red">{{ item.isDeleted > 0 ? '【已删除】' : item.state < 0 ? '【已下架】' : '' }}</text>{{ item.info }} | ||||
</text> | </text> | ||||
<image class="collect-img" src="/images/home/not-collect.png" wx:else /> | <image class="collect-img" src="/images/home/not-collect.png" wx:else /> | ||||
收藏 | 收藏 | ||||
</view> | </view> | ||||
<view class="fr list-foot-text-chat" wx:if="{{ pageStatus != 'myRelease' }}"> | |||||
<view class="fr list-foot-text-chat" wx:if="{{ pageStatus != 'myRelease' }}" bindtap="goToChat"> | |||||
<image class="chat-img" src="/images/home/chat-icon.png" /> | <image class="chat-img" src="/images/home/chat-icon.png" /> | ||||
聊一聊 | 聊一聊 | ||||
</view> | </view> |
data: { | data: { | ||||
// 页面Loading | // 页面Loading | ||||
pageLoading: false, | pageLoading: false, | ||||
customerId: "666678", | |||||
customerId: null, | |||||
// 路由接受的参数 | // 路由接受的参数 | ||||
currentData: {}, | currentData: {}, | ||||
// 感兴趣的需求---- | // 感兴趣的需求---- | ||||
type: data.listDetail.type.join(), | type: data.listDetail.type.join(), | ||||
pageLoading: true, | pageLoading: true, | ||||
}) | }) | ||||
this.getIsCollect(); | |||||
if (app.globalData.customerId) { | |||||
this.setData({ | |||||
customerId: app.globalData.customerId | |||||
}) | |||||
this.getIsCollect(); | |||||
}else{ | |||||
this.getListData(); | |||||
} | |||||
}) | }) | ||||
}, | }, | ||||
// 热门详情点击 | // 热门详情点击 | ||||
$request.get('/businessCommunicationCollect/booleanIsCollect.action', | $request.get('/businessCommunicationCollect/booleanIsCollect.action', | ||||
{ customerId, businessCommunicationDemandId: currentData.businessCommunicationDemandId } | { customerId, businessCommunicationDemandId: currentData.businessCommunicationDemandId } | ||||
).then(res => { | ).then(res => { | ||||
console.log(res); | |||||
if (res.status == 0) { | if (res.status == 0) { | ||||
this.setData({ | this.setData({ | ||||
isCollect: res.data == 0 ? false : true | isCollect: res.data == 0 ? false : true | ||||
}, | }, | ||||
// 切换收藏 | // 切换收藏 | ||||
changeCollect() { | changeCollect() { | ||||
// console.log(this.data.currentData) | |||||
let { currentData, customerId, isCollect } = this.data; | let { currentData, customerId, isCollect } = this.data; | ||||
if(!customerId){ | |||||
app.goLogin(); | |||||
return | |||||
} | |||||
let url = ""; | let url = ""; | ||||
let msg = ""; | let msg = ""; | ||||
// 如果已收藏就取消收藏 else 反之 | // 如果已收藏就取消收藏 else 反之 |
</view> | </view> | ||||
<view wx:else> | <view wx:else> | ||||
<view class="list-view"> | <view class="list-view"> | ||||
<listItem item="{{ currentData }}" pageStatus="detatil" isCollect="{{ isCollect }}" bind:changeCollect="changeCollect"/> | |||||
<listItem item="{{ currentData }}" pageStatus="detatil" isCollect="{{ isCollect }}" bind:changeCollect="changeCollect" /> | |||||
</view> | </view> | ||||
<view class="view-interested">你可能感兴趣的需求</view> | <view class="view-interested">你可能感兴趣的需求</view> | ||||
<view class="list-view" wx:for="{{ listData }}" wx:key="*this"> | |||||
<listItem item="{{ item }}" bind:getItem="goDetails"/> | |||||
<view class="not-data" wx:if="{{ listData.length < 1 }}"> | |||||
<image class="not-data-img" src="/images/home/not-data.png" /> | |||||
<view class="not-info">没有更多感兴趣的需求</view> | |||||
</view> | </view> | ||||
<view class="text-center" wx:if="{{ itemLoading }}"> | |||||
<van-loading size="24px">加载中...</van-loading> | |||||
</view> | |||||
<view class="list-finished text-center" wx:if="{{ isFinished }}"> | |||||
<image class="finished-img" src="/images/home/finished-icon.png" /> | |||||
没有更多啦~ | |||||
<view wx:else> | |||||
<view class="list-view" wx:for="{{ listData }}" wx:key="*this"> | |||||
<listItem item="{{ item }}" bind:getItem="goDetails" /> | |||||
</view> | |||||
<view class="text-center" wx:if="{{ itemLoading }}"> | |||||
<van-loading size="24px">加载中...</van-loading> | |||||
</view> | |||||
<view class="list-finished text-center" wx:if="{{ isFinished }}"> | |||||
<image class="finished-img" src="/images/home/finished-icon.png" /> | |||||
没有更多啦~ | |||||
</view> | |||||
</view> | </view> | ||||
</view> | </view> | ||||
<tabBar currentIndex="{{currentIndex}}"></tabBar> | <tabBar currentIndex="{{currentIndex}}"></tabBar> |
*/ | */ | ||||
data: { | data: { | ||||
userInfo: {}, | |||||
userInfo: null, | |||||
// 是否获取到了用户信息 | // 是否获取到了用户信息 | ||||
hasUserInfo: false, | hasUserInfo: false, | ||||
}, | }, | ||||
* 生命周期函数--监听页面加载 | * 生命周期函数--监听页面加载 | ||||
*/ | */ | ||||
onLoad: function (options) { | onLoad: function (options) { | ||||
const userInfo = wx.getStorageSync('userInfo') || null; | |||||
if (app.globalData.userInfo || userInfo) { | |||||
this.setData({ | |||||
userInfo | |||||
}) | |||||
} | |||||
}, | }, | ||||
// 获取手机号授权 | // 获取手机号授权 | ||||
// 获取用户信息弹框 | // 获取用户信息弹框 | ||||
onCheckboxChange() { | onCheckboxChange() { | ||||
if (!this.data.hasUserInfo) { | if (!this.data.hasUserInfo) { | ||||
this.getUserProfile() | |||||
if(!this.data.userInfo){ | |||||
this.getUserProfile() | |||||
}else{ | |||||
this.setData({ | |||||
hasUserInfo: true | |||||
}) | |||||
} | |||||
} else { | } else { | ||||
this.setData({ | this.setData({ | ||||
userInfo: {}, | |||||
hasUserInfo: false | hasUserInfo: false | ||||
}) | }) | ||||
} | } | ||||
userInfo: res.userInfo, | userInfo: res.userInfo, | ||||
hasUserInfo: true | hasUserInfo: true | ||||
}) | }) | ||||
wx.setStorageSync('userInfo', res.userInfo) | |||||
}, | }, | ||||
fail: () => { | fail: () => { | ||||
wx.showToast({ | wx.showToast({ | ||||
mask: true | mask: true | ||||
}) | }) | ||||
$request.post('/script/getSession.action', {}).then(res => { | $request.post('/script/getSession.action', {}).then(res => { | ||||
console.log(res,'getUserSession---res') | |||||
console.log(res, 'getUserSession---res') | |||||
wx.hideLoading() | wx.hideLoading() | ||||
app.globalData.customerId = res.data.customer.customerId | app.globalData.customerId = res.data.customer.customerId | ||||
// wx.navigateTo({ | // wx.navigateTo({ |
}, | }, | ||||
"compileType": "miniprogram", | "compileType": "miniprogram", | ||||
"libVersion": "2.18.1", | "libVersion": "2.18.1", | ||||
"appid": "wx2fb79bf1a0f4a450", | |||||
"appid": "wx4fdcd0cabdcd387b", | |||||
"projectname": "channel_business", | "projectname": "channel_business", | ||||
"debugOptions": { | "debugOptions": { | ||||
"hidedInDevtools": [] | "hidedInDevtools": [] |