[新增]企业广场,浏览记录,企业广场搜索

This commit is contained in:
唐明明
2020-12-27 15:20:23 +08:00
parent 49275bc648
commit 7e52b7bc22
19 changed files with 507 additions and 49 deletions

View File

@@ -4,6 +4,8 @@
*/
import {req} from "../request"
const lists = (data, name) => req({url: "company/square?name=" + name, data: data})
export default({
lists
})

View File

@@ -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({

View File

@@ -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",

View File

@@ -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",
})
}
}
})
}
})

View File

@@ -1,4 +1,5 @@
{
"usingComponents": {},
"navigationBarTitleText": "企业广场"
"navigationBarTitleText": "企业广场",
"navigationBarBackgroundColor": "#f8f8f8"
}

View File

@@ -1,2 +1,41 @@
 企业广场
<!-- 企业搜索 -->
<view class="search-header">
<navigator class="search-header-nav" url="./search/search">
<image class="search-header-icon" src="/static/icons/search_icon.png" mode="widthFix"></image>搜索
</navigator>
</view>
<!-- 企业浏览记录 -->
<view class="block record">
<block wx:if="{{record.length > 0}}">
<view class="record-title">我浏览过的</view>
<scroll-view class="record-scroll" scroll-x>
<view class="record-item" wx:for="{{record}}" wx:key="record" bindtap="onCompany" data-item="{{item}}">
<image class="record-item-logo" src="{{item.cover != '' ? item.cover : '/static/images/logo_null.png'}}" mode="aspectFill"></image>
<view class="record-item-name nowrap">{{item.name || "-"}}</view>
</view>
</scroll-view>
</block>
<block wx:else>
<view class="pages-hint record-null">暂无浏览记录~</view>
</block>
</view>
<!-- 企业广场列表 -->
<view class="lists-title">全部企业</view>
<view class="block lists">
<block wx:if="{{companyList.length > 0}}">
<view class="lists-item" wx:for="{{companyList}}" wx:key="company" bindtap="onCompany" data-item="{{item}}">
<image class="lists-item-logo" src="{{item.cover != '' ? item.cover : '/static/images/logo_null.png'}}" mode="aspectFill"></image>
<view class="lists-item-name nowrap">{{item.name || "-"}}</view>
<image class="lists-item-icon" src="/static/icons/arrow_right.png" mode="widthFix"></image>
</view>
</block>
<block wx:else>
<view class="pages-hint list-null">
<image src="/static/images/null_icon.png" mode="widthFix"></image>
<view>企业广场还是空的~</view>
</view>
</block>
</view>

View File

@@ -1 +1,131 @@
/* pages/company/index.wxss */
/**
* 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;
}

View File

@@ -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",
})
}
}
})
}
})

View File

@@ -0,0 +1,4 @@
{
"usingComponents": {},
"navigationBarTitleText": "搜索"
}

View File

@@ -0,0 +1,25 @@
<!-- 企业搜索 -->
<view class="search-header">
<form class="search" bindsubmit="searchForm">
<image class="search-icon" src="/static/icons/search_icon.png" mode="widthFix"></image>
<input class="search-input" type="text" name="search" placeholder="输入关键字搜索"></input>
<button class="search-btn" form-type="submit" size="mini">搜索</button>
</form>
</view>
<!-- 搜索结果 -->
<view class="block lists">
<block wx:if="{{companyList.length > 0}}">
<view class="lists-item" wx:for="{{companyList}}" wx:key="company" bindtap="onCompany" data-item="{{item}}">
<image class="lists-item-logo" src="{{item.cover != '' ? item.cover : '/static/images/logo_null.png'}}" mode="aspectFill"></image>
<view class="lists-item-name nowrap">{{item.name || "-"}}</view>
<image class="lists-item-icon" src="/static/icons/arrow_right.png" mode="widthFix"></image>
</view>
</block>
<block wx:else>
<view class="pages-hint list-null">
<image src="/static/images/search_null.png" mode="widthFix"></image>
<view>{{searchValue == '' ? '输入关键字搜索' : '暂无搜索结果'}}</view>
</view>
</block>
</view>

View File

@@ -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;
}

23
pages/welcome/index.js Normal file
View File

@@ -0,0 +1,23 @@
/**
* Web唐明明
* 匆匆数载恍如梦,岁月迢迢华发增。
* 碌碌无为枉半生,一朝惊醒万事空。
*/
Page({
/**
* 页面的初始数据
*/
data: {
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
}
})

4
pages/welcome/index.json Normal file
View File

@@ -0,0 +1,4 @@
{
"usingComponents": {},
"navigationStyle": "custom"
}

2
pages/welcome/index.wxml Normal file
View File

@@ -0,0 +1,2 @@
<!--pages/welcome/index.wxml-->
<text>pages/welcome/index.wxml</text>

8
pages/welcome/index.wxss Normal file
View File

@@ -0,0 +1,8 @@
/**
* Web唐明明
* 匆匆数载恍如梦,岁月迢迢华发增。
* 碌碌无为枉半生,一朝惊醒万事空。
*/

View File

@@ -64,6 +64,12 @@
{
"name": "登录",
"pathName": "pages/login/login",
"query": "",
"scene": null
},
{
"name": "搜索",
"pathName": "pages/company/search/search",
"scene": null
}
]

Binary file not shown.

After

Width:  |  Height:  |  Size: 311 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 426 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB