diff --git a/apis/interfaces/company.js b/apis/interfaces/company.js index 0332549..46f065f 100644 --- a/apis/interfaces/company.js +++ b/apis/interfaces/company.js @@ -4,6 +4,8 @@ */ import {req} from "../request" +const lists = (data, name) => req({url: "company/square?name=" + name, data: data}) + export default({ - + lists }) diff --git a/apis/request.js b/apis/request.js index 3f0fdfd..fbc8d79 100644 --- a/apis/request.js +++ b/apis/request.js @@ -3,7 +3,7 @@ import {errInfo} from './err' import {updToken} from './updateToken' // 请求方式配置 -const api = "https://new-web-test.cnskl.com/api/" +const api = "https://new-web-test.cnskl.com/api/" // const api = "https://mi-org.cnskl.com/api/" const header = { "Accept": "application/json" @@ -15,8 +15,9 @@ const header = { */ const req = (obj) => { - // header header.Authorization = wx.getStorageSync("token") || "" + header["store-id"] = wx.getStorageSync("storeId") || "" + // 处理请求信息 return new Promise((resolve, reject) => { wx.showLoading({ diff --git a/app.json b/app.json index 61a498b..68e8a60 100644 --- a/app.json +++ b/app.json @@ -1,20 +1,22 @@ { "pages": [ + "pages/company/index", "pages/shortVideo/index", "pages/richText/richText", "pages/login/login", "pages/card/index", - "pages/company/index", "pages/user/index", "pages/home/index", "pages/mall/index", "pages/live/index", - "pages/ticket/index" + "pages/ticket/index", + "pages/company/search/search", + "pages/welcome/index" ], "window": { "backgroundTextStyle": "light", "navigationBarBackgroundColor": "#fff", - "navigationBarTitleText": "短视频", + "navigationBarTitleText": "", "navigationBarTextStyle": "black" }, "style": "v2", diff --git a/pages/company/index.js b/pages/company/index.js index 2475342..89dd7eb 100644 --- a/pages/company/index.js +++ b/pages/company/index.js @@ -1,66 +1,82 @@ -// pages/company/index.js + +/** + * Web唐明明 + * 匆匆数载恍如梦,岁月迢迢华发增。 + * 碌碌无为枉半生,一朝惊醒万事空。 + */ + Page({ /** * 页面的初始数据 */ data: { - + companyList: [], //企业广场列表 + pages : {}, //企业广场分页 + record : [], //浏览记录 }, /** * 生命周期函数--监听页面加载 */ - onLoad: function (options) { - - }, - - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady: function () { - + onLoad(options) { + wx.$api.company.lists({}, "").then(res=>{ + this.setData({ + companyList: res.data, + pages : res.page + }) + }) }, /** * 生命周期函数--监听页面显示 */ - onShow: function () { - + onShow() { + wx.getStorage({ + key : "companyRecord", + success : res=>{ + this.setData({record: res.data}) + } + }) }, /** - * 生命周期函数--监听页面隐藏 + * 点击企业 */ - onHide: function () { + onCompany(e){ + let company = e.currentTarget.dataset.item, + newRecord = [...[company], ...this.data.record], + newobj = {} - }, + let record = newRecord.reduce((preVal, curVal)=>{ + newobj[curVal.company_id] ? '' : newobj[curVal.company_id] = preVal.push(curVal); + return preVal + }, []) - /** - * 生命周期函数--监听页面卸载 - */ - onUnload: function () { + // 去重后的数组长度 + if(record.length > 10){ + record = record.slice(0, 10) + } - }, - - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh: function () { - - }, - - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom: function () { - - }, - - /** - * 用户点击右上角分享 - */ - onShareAppMessage: function () { + // 更新页面数据 + this.setData({ + record: record + }) + // 存储浏览记录 + wx.setStorageSync('companyRecord', record) + + // 存储店铺ID + wx.setStorage({ + data : company.store_id, + key : "storeId", + success : res=>{ + if(res.errMsg == "setStorage:ok"){ + wx.navigateTo({ + url: "/pages/shortVideo/index", + }) + } + } + }) } }) \ No newline at end of file diff --git a/pages/company/index.json b/pages/company/index.json index 8614f61..4650780 100644 --- a/pages/company/index.json +++ b/pages/company/index.json @@ -1,4 +1,5 @@ { "usingComponents": {}, - "navigationBarTitleText": "企业广场" + "navigationBarTitleText": "企业广场", + "navigationBarBackgroundColor": "#f8f8f8" } \ No newline at end of file diff --git a/pages/company/index.wxml b/pages/company/index.wxml index 13e6b36..25dd496 100644 --- a/pages/company/index.wxml +++ b/pages/company/index.wxml @@ -1,2 +1,41 @@ - 企业广场 + + + + 搜索 + + + + + + + 我浏览过的 + + + + {{item.name || "-"}} + + + + + 暂无浏览记录~ + + + + +全部企业 + + + + + {{item.name || "-"}} + + + + + + + 企业广场还是空的~ + + + diff --git a/pages/company/index.wxss b/pages/company/index.wxss index acda737..b4c142b 100644 --- a/pages/company/index.wxss +++ b/pages/company/index.wxss @@ -1 +1,131 @@ -/* pages/company/index.wxss */ \ No newline at end of file + +/** + * Web唐明明 + * 匆匆数载恍如梦,岁月迢迢华发增。 + * 碌碌无为枉半生,一朝惊醒万事空。 + */ + +.search-header{ + box-sizing: border-box; + padding: 20rpx 30rpx 0; +} + +.search-header-nav{ + background: white; + text-align: center; + line-height: 70rpx; + border-radius: 8rpx; + font-size: 30rpx; + color: #afafaf; +} + +.search-header-icon{ + width: 28rpx; + vertical-align: middle; + margin-right: 10rpx; + margin-bottom: 6rpx; +} + +.block{ + margin: 0 30rpx; + background: white; + border-radius: 10rpx; +} + +/* 浏览记录 */ + +.record{ + margin-top: 30rpx; +} + +.record-title{ + font-size: 30rpx; + color: #afafaf; + padding: 20rpx 30rpx; +} + +.record-scroll{ + white-space: nowrap; +} + +.record-item{ + display: inline-block; + text-align: center; + width: 148rpx; + margin: 0 10rpx; + padding-bottom: 20rpx; +} + +.record-item:first-child{ + margin-left: 20rpx; +} + +.record-item:last-child{ + margin-right: 20rpx; +} + +.record-item-logo{ + width: 88rpx; + height: 88rpx; + border-radius: 50%; + vertical-align: top; +} + +.record-item-name{ + font-size: 26rpx; + padding-top: 15rpx; + line-height: 40rpx; +} + +.record-null{ + padding: 80rpx 0; +} + +/* 企业列表 */ +.lists-title{ + padding: 30rpx 30rpx 20rpx 30rpx; + font-weight: bold; +} + +.lists{ + padding: 10rpx 0; +} + +.lists-item{ + position: relative; + padding: 20rpx 80rpx 20rpx 138rpx; + border-bottom: solid 1rpx #eee; + min-height: 88rpx; +} + +.lists-item:last-child{ + border-bottom: none; +} + +.lists-item-logo{ + position: absolute; + left: 30rpx; + top: 20rpx; + width: 88rpx; + height: 88rpx; + border-radius: 50%; +} + +.lists-item-icon{ + position: absolute; + width: 32rpx; + right: 30rpx; + top: calc(50% - 16rpx); +} + +.lists-item-name{ + line-height: 88rpx; + font-size: 32rpx; +} + +/* 企业列表空 */ +.list-null{ + background: white; + padding-bottom: 100rpx; + padding: 200rpx 0; +} diff --git a/pages/company/search/search.js b/pages/company/search/search.js new file mode 100644 index 0000000..21f5c65 --- /dev/null +++ b/pages/company/search/search.js @@ -0,0 +1,90 @@ + +/** + * Web唐明明 + * 匆匆数载恍如梦,岁月迢迢华发增。 + * 碌碌无为枉半生,一朝惊醒万事空。 + */ + +Page({ + + /** + * 页面的初始数据 + */ + data: { + companyList: [], //搜索企业列表 + pages : {}, //分页信息 + searchValue: "", //搜索值 + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad(options) { + + }, + + /** + * 搜索表单 + */ + searchForm(e){ + let value = e.detail.value.search + this.setData({ + searchValue: value + }) + if(value == ""){ + wx.showToast({ + title: "搜索内容不能为空", + icon : "none" + }) + return + } + this.getCompany(value) + }, + + /** + * 获取列表 + */ + getCompany(value){ + wx.$api.company.lists({}, value).then(res=>{ + this.setData({ + companyList: res.data, + pages : res.page + }) + }) + }, + + /** + * 点击企业 + */ + onCompany(e){ + let company = e.currentTarget.dataset.item, + newRecord = [...[company], ...wx.getStorageSync("companyRecord")], + newobj = {} + + let record = newRecord.reduce((preVal, curVal)=>{ + newobj[curVal.company_id] ? '' : newobj[curVal.company_id] = preVal.push(curVal); + return preVal + }, []) + + // 去重后的数组长度 + if(record.length > 10){ + record = record.slice(0, 10) + } + + // 存储浏览记录 + wx.setStorageSync('companyRecord', record) + + // 存储店铺ID + wx.setStorage({ + data : company.store_id, + key : "storeId", + success : res=>{ + if(res.errMsg == "setStorage:ok"){ + wx.redirectTo({ + url: "/pages/shortVideo/index", + }) + } + } + }) + } +}) \ No newline at end of file diff --git a/pages/company/search/search.json b/pages/company/search/search.json new file mode 100644 index 0000000..5667d5c --- /dev/null +++ b/pages/company/search/search.json @@ -0,0 +1,4 @@ +{ + "usingComponents": {}, + "navigationBarTitleText": "搜索" +} \ No newline at end of file diff --git a/pages/company/search/search.wxml b/pages/company/search/search.wxml new file mode 100644 index 0000000..c0cb0f3 --- /dev/null +++ b/pages/company/search/search.wxml @@ -0,0 +1,25 @@ + + + + + + + + + + + {{item.name || "-"}} + + + + + + + {{searchValue == '' ? '输入关键字搜索' : '暂无搜索结果'}} + + + diff --git a/pages/company/search/search.wxss b/pages/company/search/search.wxss new file mode 100644 index 0000000..163ddd4 --- /dev/null +++ b/pages/company/search/search.wxss @@ -0,0 +1,105 @@ + +/** + * Web唐明明 + * 匆匆数载恍如梦,岁月迢迢华发增。 + * 碌碌无为枉半生,一朝惊醒万事空。 + */ + +.search-header{ + position: fixed; + top: 0; + left: 0; + width: 100%; + box-sizing: border-box; + background: white; + padding: 20rpx 30rpx; + box-shadow: 0 0 4rpx 4rpx rgba(0, 0, 0, .05); +} + +.search{ + display: block; + position: relative; + background: #f8f8f8; + height: 70rpx; + padding-left: 70rpx; + padding-right: 160rpx; + border-radius: 8rpx; + font-size: 30rpx; +} + +.search-icon{ + position: absolute; + left: 21rpx; + top: 21rpx; + width: 28rpx; + vertical-align: middle; + margin-right: 10rpx; + margin-bottom: 6rpx; +} + +.search-input{ + height: 70rpx; + padding-right: 20rpx; +} + +.search-btn[size="mini"]{ + position: absolute; + right: 0; + top: 0; + background: #f8f8f8; + color: #0b0041; + font-size: 30rpx; + font-weight: normal; + height: 70rpx; + width: 150rpx; + padding: 0; + line-height: 70rpx; + border-radius: 0 8rpx 8rpx 0; +} + +/* 企业列表 */ +.lists{ + padding: 10rpx 0 10rpx 0; + margin: 140rpx 30rpx 0; + background: white; + border-radius: 10rpx; +} + +.lists-item{ + position: relative; + padding: 20rpx 80rpx 20rpx 138rpx; + border-bottom: solid 1rpx #eee; + min-height: 88rpx; +} + +.lists-item:last-child{ + border-bottom: none; +} + +.lists-item-logo{ + position: absolute; + left: 30rpx; + top: 20rpx; + width: 88rpx; + height: 88rpx; + border-radius: 50%; +} + +.lists-item-icon{ + position: absolute; + width: 32rpx; + right: 30rpx; + top: calc(50% - 16rpx); +} + +.lists-item-name{ + line-height: 88rpx; + font-size: 32rpx; +} + +/* 企业列表空 */ +.list-null{ + background: white; + padding-bottom: 100rpx; + padding: 200rpx 0; +} diff --git a/pages/welcome/index.js b/pages/welcome/index.js new file mode 100644 index 0000000..b269da1 --- /dev/null +++ b/pages/welcome/index.js @@ -0,0 +1,23 @@ + +/** + * Web唐明明 + * 匆匆数载恍如梦,岁月迢迢华发增。 + * 碌碌无为枉半生,一朝惊醒万事空。 + */ + +Page({ + + /** + * 页面的初始数据 + */ + data: { + + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad(options) { + + } +}) \ No newline at end of file diff --git a/pages/welcome/index.json b/pages/welcome/index.json new file mode 100644 index 0000000..7af8b0a --- /dev/null +++ b/pages/welcome/index.json @@ -0,0 +1,4 @@ +{ + "usingComponents": {}, + "navigationStyle": "custom" +} \ No newline at end of file diff --git a/pages/welcome/index.wxml b/pages/welcome/index.wxml new file mode 100644 index 0000000..e51ae68 --- /dev/null +++ b/pages/welcome/index.wxml @@ -0,0 +1,2 @@ + +pages/welcome/index.wxml diff --git a/pages/welcome/index.wxss b/pages/welcome/index.wxss new file mode 100644 index 0000000..c4fcc69 --- /dev/null +++ b/pages/welcome/index.wxss @@ -0,0 +1,8 @@ + +/** + * Web唐明明 + * 匆匆数载恍如梦,岁月迢迢华发增。 + * 碌碌无为枉半生,一朝惊醒万事空。 + */ + + diff --git a/project.config.json b/project.config.json index 317ba93..bb20788 100644 --- a/project.config.json +++ b/project.config.json @@ -64,6 +64,12 @@ { "name": "登录", "pathName": "pages/login/login", + "query": "", + "scene": null + }, + { + "name": "搜索", + "pathName": "pages/company/search/search", "scene": null } ] diff --git a/static/icons/arrow_right.png b/static/icons/arrow_right.png new file mode 100644 index 0000000..e31e080 Binary files /dev/null and b/static/icons/arrow_right.png differ diff --git a/static/icons/search_icon.png b/static/icons/search_icon.png new file mode 100644 index 0000000..f3ea620 Binary files /dev/null and b/static/icons/search_icon.png differ diff --git a/static/images/search_null.png b/static/images/search_null.png new file mode 100644 index 0000000..9c26fab Binary files /dev/null and b/static/images/search_null.png differ