diff --git a/.cloudbase/container/debug.json b/.cloudbase/container/debug.json new file mode 100644 index 0000000..0d44458 --- /dev/null +++ b/.cloudbase/container/debug.json @@ -0,0 +1 @@ +{"containers":[],"config":{}} \ No newline at end of file diff --git a/miniprogram/api/user/park.js b/miniprogram/api/user/park.js new file mode 100644 index 0000000..e3c5eb9 --- /dev/null +++ b/miniprogram/api/user/park.js @@ -0,0 +1,12 @@ +import { + request +} from '../selfRequest'; + + +// 园区列表 +export function selectParkListRq() { + return request({ + url: '/api/room/selectParkList', + method: "get", + }); +} \ No newline at end of file diff --git a/miniprogram/pages/index/index.js b/miniprogram/pages/index/index.js index b068638..8b26775 100644 --- a/miniprogram/pages/index/index.js +++ b/miniprogram/pages/index/index.js @@ -200,9 +200,23 @@ Page({ _this.setData({ userDetail }) + // 登录用户是否选择园区 + _this.userIsPark() }) } else { app.getlogin() + return + } + + }, + + // 登录用户是否选择园区 + userIsPark() { + let parkId = wx.getStorageSync('parkId'); + if (!parkId) { + wx.navigateTo({ + url: '/pages/index/parkList/parkList', + }) } }, diff --git a/miniprogram/pages/index/parkList/parkList.js b/miniprogram/pages/index/parkList/parkList.js index bcd7c1c..6c162a2 100644 --- a/miniprogram/pages/index/parkList/parkList.js +++ b/miniprogram/pages/index/parkList/parkList.js @@ -1,72 +1,98 @@ -let app = getApp() +const app = getApp() + +import { + selectParkListRq +} from "../../../api/user/park.js" + Page({ - /** - * 页面的初始数据 - */ - data: { - DOMAIN_NAME: app.DOMAIN_NAME, - currentTab: 0, - homelist: [], - name: '' - }, + /** + * 页面的初始数据 + */ + data: { + IMG_NAME: app.IMG_NAME, + dataList: [] + }, - /** - * 生命周期函数--监听页面加载 - */ - onLoad() { - this.getList() - }, - - getList() { - var that = this - app.AjaxRequest('get', { - 'content-type': 'application/json' - }, '/park/list', {}, function (res) { - that.setData({ - parkList: res.data - }) - }) - }, - - changePark(e) { - app.AjaxRequest('POST', { - 'content-type': 'application/json', - 'Authorization': 'Bearer ' + app.Getopenid() - }, '/user/profile/update', { - parkId: e.currentTarget.dataset.id - }, function (ret) { - if (ret.code == 0) { - wx.setStorageSync('parkId', e.currentTarget.dataset.id) - wx.setStorageSync('parkName', e.currentTarget.dataset.name) - wx.reLaunch({ - url: '/pages/index/index', + /** + * 生命周期函数--监听页面加载 + */ + onLoad(options) { + let _this = this; + _this.setData({ + ...options, }) - } - }) - }, - - navDetail(e) { - const eventChannel = this.getOpenerEventChannel() - let homelist = this.data.homelist - let index = e.currentTarget.dataset.index - wx.navigateBack({ - url: '../logs/logs', - success() { - eventChannel.emit('acceptDataFromOpenedPage', { - data: homelist[index] + // 园区列表 + _this.getParkList(); + }, + + // 园区列表 + getParkList() { + let _this = this + selectParkListRq().then(res => { + console.log('selectParkListRq', res); + _this.setData({ + dataList: res.data + }) }) - } - }) - }, + }, - getName(e) { - this.setData({ - name: e.detail.value - }) - }, + // 选择园区 + selectPark(e) { + console.log('e.currentTarget.dataset', e); + let obj = e.currentTarget.dataset.obj; + wx.setStorageSync('parkId', obj.id) + wx.setStorageSync('parkName', obj.name) + // 销毁当前页面 + wx.navigateBack(); + }, - search() { - this.getList(this.data.name) - } + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady() { + + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow() { + + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide() { + + }, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload() { + + }, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh() { + + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom() { + + }, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage() { + + } }) \ No newline at end of file diff --git a/miniprogram/pages/index/parkList/parkList.wxml b/miniprogram/pages/index/parkList/parkList.wxml index 61d6d99..2c494a3 100644 --- a/miniprogram/pages/index/parkList/parkList.wxml +++ b/miniprogram/pages/index/parkList/parkList.wxml @@ -1,24 +1,15 @@ - - - - - - - - - - {{item.parkName}} + + + + + + + {{item.name}} + {{item.address}} - {{item.address}} - - - - \ No newline at end of file + + \ No newline at end of file diff --git a/miniprogram/pages/index/parkList/parkList.wxss b/miniprogram/pages/index/parkList/parkList.wxss index 5bd7490..c07c183 100644 --- a/miniprogram/pages/index/parkList/parkList.wxss +++ b/miniprogram/pages/index/parkList/parkList.wxss @@ -1,13 +1,47 @@ -.detailbox{ - position: relative; +.itemListView{ + padding: 20rpx 0; } -input{ - width: 72%; - height: 80rpx; - margin-top: 10rpx; - margin-left: 6%; - background-color: #F3F3F3; - border-radius: 8rpx; - box-sizing: border-box; - padding-left: 20rpx; + +.itemListView .itemView{ + border-bottom: 1px solid rgb(126, 126, 126, 0.2); + padding: 30rpx 30rpx; + display: flex; + justify-content: flex-start; + align-items: center; +} + +.itemListView .itemView:active{ + background-color: rgb(126, 126, 126, 0.2); +} + +.itemListView .itemView .img{ + flex-shrink: 0; + width: 100rpx; + height: 100rpx; +} + +.itemListView .itemView .contentView{ + flex: 1; + margin-left: 30rpx; + overflow: hidden; +} + +.itemListView .itemView .contentView .name{ + font-size: 30rpx; + + text-overflow: ellipsis; + overflow: hidden; + word-break: break-all; + white-space: nowrap; +} + +.itemListView .itemView .contentView .describe{ + margin-top: 10rpx; + font-size: 24rpx; + color: gray; + + text-overflow: ellipsis; + overflow: hidden; + word-break: break-all; + white-space: nowrap; } \ No newline at end of file diff --git a/miniprogram/pages/login/login.js b/miniprogram/pages/login/login.js index 9a5e3a3..b362047 100644 --- a/miniprogram/pages/login/login.js +++ b/miniprogram/pages/login/login.js @@ -68,6 +68,8 @@ Page({ wx.setStorageSync('user', user) wx.setStorageSync('userId', user.id) wx.setStorageSync('token', token) + wx.setStorageSync('parkId', user.parkId) + wx.setStorageSync('parkName', user.parkName) // 跳转首页 wx.reLaunch({ url: '/pages/index/index', diff --git a/miniprogram/pages/my/personalData/personalData.js b/miniprogram/pages/my/personalData/personalData.js index ded7f84..cd186cb 100644 --- a/miniprogram/pages/my/personalData/personalData.js +++ b/miniprogram/pages/my/personalData/personalData.js @@ -55,53 +55,14 @@ Page({ }, parkChange(e) { - var that = this + let that = this that.data.parkList.forEach(item => { if (that.data.park[e.detail.value] == item.parkName) { - wx.request({ - url: app.DOMAIN_NAME + '/user/profile/update', - data: { - parkId: item.id - }, - method: 'POST', - header: { - 'content-type': 'application/json', - 'Authorization': 'Bearer ' + app.Getopenid() - }, - success(ret) { - if (ret.data.code == 402 || ret.data.code == 401) { - wx.hideLoading() - wx.showModal({ - confirmText: '确认', - content: '身份已过期,需重登录', - success(res) { - wx.removeStorageSync('MemberInfo') - wx.removeStorageSync('token') - if (res.confirm) { - wx.reLaunch({ - url: '/pages/login/login' - }) - } - } - }) - } else if (ret.data.code != 0) { - wx.hideLoading() - wx.showModal({ - confirmText: '好的', - content: ret.data.msg || '服务器开小差去了,请重试', - showCancel: false - }) - } else if (ret.data.code == 0) { - that.setData({ - parkindex: e.detail.value - }) - wx.setStorageSync('parkId', item.id) - wx.setStorageSync('parkName', item.parkName) - wx.navigateBack() - wx.hideLoading() - } - } + that.setData({ + parkindex: e.detail.value }) + wx.setStorageSync('parkId', item.id) + wx.setStorageSync('parkName', item.parkName) } }) }, diff --git a/project.private.config.json b/project.private.config.json index 5456c58..c425d88 100644 --- a/project.private.config.json +++ b/project.private.config.json @@ -6,6 +6,13 @@ "condition": { "miniprogram": { "list": [ + { + "name": "pages/index/parkList/parkList", + "pathName": "pages/index/parkList/parkList", + "query": "", + "launchMode": "default", + "scene": null + }, { "name": "pages/meeting/invite/invite", "pathName": "pages/meeting/invite/invite",