默认页面设置为/pages/index/index,即不登录也可以看首页

master
yujialong 7 months ago
parent 0f1a67fa54
commit 913886a897
  1. 21
      apis/request.js
  2. 10
      pages.json
  3. 424
      pages/home/home.vue
  4. 151
      pages/index/index.vue
  5. 2
      pages/login/login.vue
  6. 4
      pages/person/person.vue
  7. 2
      pages/reg/reg.vue
  8. 4
      pages/workbench/workbench.vue
  9. 4
      team/setting/setting.vue

@ -32,16 +32,17 @@ const request = options => {
} else if (status == 401) {
if (!logouted) {
// 登录过期
// uni.clearStorageSync()
// uni.showToast({
// title: message,
// icon: 'none'
// })
// setTimeout(() => {
// uni.navigateTo({
// url: '../login/login'
// })
// }, 1500)
uni.clearStorageSync()
uni.showToast({
title: message,
icon: 'none'
})
setTimeout(() => {
logouted = 0
uni.redirectTo({
url: '../index/index'
})
}, 1500)
reject(data)
logouted = 1
}

@ -16,6 +16,14 @@
"enablePullDownRefresh": false
}
},
{
"path" : "pages/home/home",
"style" :
{
"navigationStyle": "custom",
"enablePullDownRefresh": false
}
},
{
"path" : "pages/workbench/workbench",
"style" :
@ -295,7 +303,7 @@
"fontSize": "22px",
"iconWidth": "20px",
"list": [{
"pagePath": "pages/index/index",
"pagePath": "pages/home/home",
"iconPath": "static/image/tab1.png",
"selectedIconPath": "static/image/tab1-1.png",
"text": "首页"

@ -0,0 +1,424 @@
<template>
<view :class="[{oh: !per}]">
<view class="banner">
<image class="pic" src="@/static/image/index/banner.png" mode="widthFix"></image>
<image class="bg1" src="@/static/image/index/banner1.png"></image>
<view class="texts">
<view class="title">
<image class="logo" src="@/static/image/logo1.png" mode="widthFix"></image>
职站商城
</view>
<view class="text">您的一站式实验教学产品采购平台</view>
</view>
<view class="rect"></view>
</view>
<view class="page">
<view class="search-wrap">
<uni-search-bar class="search" radius="30" placeholder="请输入" v-model="keyword" clearButton="auto" cancelButton="none" @confirm="searchConfirm" />
<view>
<button class="all" type="primary" @click.stop="to('/order/products/products')">全部产品</button>
</view>
</view>
<view class="block" style="margin-top: 0">
<view class="title-wrap">
<view class="title">热门标签</view>
</view>
<ul class="tags">
<li v-for="(tag, i) in tags" :key="i" @click="to(`/order/products/products?tagId=${tag.tagsId}&tagsName=${tag.tagsName}`)">
<view class="icon">
<image :src="require('@/static/image/index/' + (i + 1) + '.png')"></image>
</view>
<view class="text ell">{{ tag.tagsName }}</view>
</li>
</ul>
</view>
<view class="block">
<view class="title-wrap">
<view class="title">热销产品</view>
</view>
<view class="list">
<view v-for="(item, i) in hotProducts" :key="i" class="item" @click="to(`/order/productDetail/productDetail?id=${item.mallId}`)">
<image class="pic" :src="$util.getIcon(item)"></image>
<view class="texts">
<view class="name ell">{{ item.productName }}</view>
<view class="des ell">{{ item.tagsName }}</view>
<view class="meta">{{ item.marketUnitPrice }}/</view>
</view>
</view>
</view>
</view>
<view class="block" style="margin-top: 40rpx">
<view class="title-wrap">
<view class="title">官方推荐</view>
</view>
<view class="list">
<view v-for="(item, i) in offcialProducts" :key="i" class="item" @click="to(`/order/productDetail/productDetail?id=${item.mallId}`)">
<image class="pic" :src="$util.getIcon(item)"></image>
<view class="texts">
<view class="name ell">{{ item.productName }}</view>
<view class="des ell">{{ item.tagsName }}</view>
<view class="meta">{{ item.marketUnitPrice }}/</view>
</view>
</view>
</view>
</view>
</view>
<view v-if="auth('产品:购物车')" class="plus">
<uni-badge size="small" :text="total" absolute="topRight" type="error" :custom-style="customStyle">
<image class="icon" src="@/static/image/product/shop-blue.png" mode="widthFix" @click="$util.to('/order/shopCart/shopCart')"></image>
</uni-badge>
</view>
<view v-if="!per" class="per-mask">功能升级中敬请期待...</view>
</view>
</template>
<script>
import { getUserRolesPermissionMenu } from '@/apis/modules/user.js'
import { tagsList, listOfGoods, shoppingCartList } from '@/apis/modules/product.js'
import { getTeamsByAccountId } from '@/apis/modules/client.js'
export default {
data() {
return {
per: true, //
teamId: uni.getStorageSync('teamId') || '',
list: [],
keyword: '',
tags: [],
hotProducts: [],
offcialProducts: [],
total: 0,
customStyle: {
width: '46rpx',
height: '46rpx',
lineHeight: '40rpx',
fontSize: '34rpx'
}
}
},
onShow() {
this.keyword = ''
this.per = true
this.getInfo()
this.getShopCart()
},
methods: {
//
initRole() {
if (!uni.getStorageSync('auth').includes('首页')) {
this.per = false
}
this.getTags()
this.getProducts()
},
//
getAuth() {
getUserRolesPermissionMenu({
teamId: this.list.find(e => e.teamId == this.teamId).partnerClassificationId,
platformId: 4
}).then(({ permissionMenu }) => {
uni.hideLoading()
const auth = []
//
const generateAuth = (list, parent) => {
list.map(e => {
const name = `${parent ? parent + ':' : ''}${e.name}`
auth.push(name)
generateAuth(e.children, name)
})
}
generateAuth(permissionMenu[0].children, '')
uni.setStorageSync('auth', auth)
this.$forceUpdate()
this.initRole()
}).catch(e => {
uni.hideLoading()
uni.setStorageSync('auth', [])
this.initRole()
})
},
//
getInfo() {
uni.showLoading({
title: '加载中'
})
getTeamsByAccountId().then(({ data }) => {
data.map(e => {
const n = e.partnerClassificationList
e.id = n.id
// parnerIdidteamIduni.getStorageSync('team').partnerId使
e.teamId = e.isTeam == 1 ? +e.partnerClassificationId : n.id
e.partnerClassificationName = n.partnerClassificationName
delete e.partnerClassificationList
})
if (data.length) {
/**
* @description 如果是第一次进则默认选中第一个团队并把该团队的信息存入缓存
* 或者团队列表里没有该id则说明超管已经被转让也需要重新选中团队
*/
if (!uni.getStorageSync('team') || !data.find(e => e.teamId == this.teamId)) {
this.teamId = data[0].teamId
uni.setStorageSync('team', data[0])
}
} else {
// 退
uni.hideLoading()
uni.clearStorageSync()
uni.redirectTo({
url: '../index/index'
})
}
this.list = data
this.getAuth()
}).catch(e => {
uni.hideLoading()
})
},
//
getTags() {
tagsList().then(res => {
this.tags = res.tagsList.slice(0, 8)
}).catch(e => {})
},
//
getShopCart() {
shoppingCartList({
pageNum: 1,
pageSize: 1000,
}).then(({ data }) => {
this.total = data.total
}).catch(e => {})
},
//
getProducts() {
//
listOfGoods({
pageNum: 1,
pageSize: 5,
sort: 1,
isShelves: 0,
hotTag: 1
}).then(({ page }) => {
page.records.forEach(e => {
e.productIntroduction = this.$util.removeTag(e.productIntroduction)
})
this.hotProducts = page.records
}).catch(e => {})
//
listOfGoods({
pageNum: 1,
pageSize: 5,
sort: 0,
isShelves: 0,
hotTag: 1,
selection: 1
}).then(({ page }) => {
page.records.forEach(e => {
e.productIntroduction = this.$util.removeTag(e.productIntroduction)
})
this.offcialProducts = page.records
}).catch(e => {})
},
//
searchConfirm(e) {
if (e.value) this.$util.to(uni.getStorageSync('token') ? `/order/products/products?keyword=${e.value}` : '../login/login')
},
//
to(url) {
this.$util.to(uni.getStorageSync('token') ? url : '../login/login')
},
}
}
</script>
<style scoped lang="scss">
.page {
position: relative;
padding: 10rpx 22rpx;
margin-top: -61rpx;
box-sizing: border-box;
background-color: #fff;
border-top-left-radius: 16px;
border-top-right-radius: 16px;
}
.banner {
position: relative;
.pic {
width: 100%;
}
.bg1 {
position: absolute;
top: -120rpx;
left: -380rpx;
width: 100%;
transform: rotate(20deg);
}
.logo {
width: 70rpx;
margin-right: 14rpx;
}
.texts {
position: absolute;
top: 230rpx;
left: 0;
width: 100%;
text-align: center;
color: #fff;
}
.title {
display: flex;
justify-content: center;
align-items: center;
margin-bottom: 22rpx;
font-size: 48rpx;
font-family: AlimamaShuHeiTi-Bold, AlimamaShuHeiTi;
font-weight: 600;
}
.text {
font-size: 30rpx;
}
.rect {
position: absolute;
bottom: 90rpx;
left: -12rpx;
width: 55rpx;
height: 61rpx;
border-radius: 7px 10px 7px 10px;
opacity: 0.63;
border: 1px solid #FFFFFF;
transform: rotate(54deg);
}
}
.search-wrap {
display: flex;
justify-content: space-between;
align-items: center;
.search {
flex: 1;
}
}
.all {
font-size: 24rpx;
border-radius: 20px;
&::after {
border: none;
}
}
.block {
margin: 20rpx 0;
.title-wrap {
display: flex;
justify-content: space-between;
margin-bottom: 34rpx;
}
.title {
display: inline-flex;
align-items: center;
font-size: 28rpx;
font-weight: 600;
color: #333;
&:before {
content: '';
width: 10rpx;
height: 26rpx;
margin-right: 14rpx;
background: #007FFF;
border-radius: 5px;
}
}
}
.tags {
display: flex;
flex-wrap: wrap;
li {
width: 25%;
margin-bottom: 24rpx;
text-align: center;
&:last-child {
image {
width: 50rpx;
height: 50rpx;
}
}
}
.icon {
display: flex;
justify-content: center;
align-items: center;
width: 90rpx;
height: 90rpx;
margin: 0 auto 18rpx;
background-color: rgb(228,239,255);
border-radius: 50%;
}
image {
width: 60rpx;
height: 60rpx;
}
.text {
width: 165rpx;
margin: 0 auto;
font-size: 24rpx;
color: #333;
}
}
.list {
.item {
display: flex;
align-items: center;
margin-bottom: 28rpx;
}
.pic {
width: 100rpx;
height: 100rpx;
margin-right: 20rpx;
border-radius: 8px;
}
.texts {
width: calc(100% - 156rpx);
}
.name {
font-size: 28rpx;
font-weight: 600;
color: #333;
}
.des {
margin: 10rpx 0;
font-size: 22rpx;
color: #666;
}
.meta {
display: flex;
align-items: center;
font-size: 24rpx;
color: #2E2D31;
.icon {
width: 32rpx;
height: 32rpx;
margin-right: 12rpx;
}
text {
width: 330rpx;
}
}
}
.plus {
bottom: 140rpx;
right: 60rpx;
.icon {
width: 106rpx;
}
.uni-badge {
font-size: 32rpx;
}
}
</style>

@ -15,9 +15,9 @@
<view class="page">
<view class="search-wrap">
<uni-search-bar class="search" radius="30" placeholder="请输入" v-model="keyword" clearButton="auto" cancelButton="none" @confirm="searchConfirm" />
<uni-search-bar class="search" radius="30" placeholder="请输入" v-model="keyword" clearButton="auto" cancelButton="none" @confirm="toLogin" />
<view>
<button class="all" type="primary" @click.stop="toProduct">全部产品</button>
<button class="all" type="primary" @click.stop="toLogin">全部产品</button>
</view>
</view>
@ -27,7 +27,7 @@
</view>
<ul class="tags">
<li v-for="(tag, i) in tags" :key="i" @click="toHot(tag)">
<li v-for="(tag, i) in tags" :key="i" @click="toLogin">
<view class="icon">
<image :src="require('@/static/image/index/' + (i + 1) + '.png')"></image>
</view>
@ -39,12 +39,9 @@
<view class="block">
<view class="title-wrap">
<view class="title">热销产品</view>
<view>
<!-- <button class="all" type="primary" @click.stop="toProduct">全部产品</button> -->
</view>
</view>
<view class="list">
<view v-for="(item, i) in hotProducts" :key="i" class="item" @click="toDetail(item)">
<view v-for="(item, i) in hotProducts" :key="i" class="item" @click="toLogin">
<image class="pic" :src="$util.getIcon(item)"></image>
<view class="texts">
<view class="name ell">{{ item.productName }}</view>
@ -59,12 +56,9 @@
<view class="block" style="margin-top: 40rpx">
<view class="title-wrap">
<view class="title">官方推荐</view>
<view>
<!-- <button class="all" type="primary" @click.stop="toProduct">全部产品</button> -->
</view>
</view>
<view class="list">
<view v-for="(item, i) in offcialProducts" :key="i" class="item" @click="toDetail(item)">
<view v-for="(item, i) in offcialProducts" :key="i" class="item" @click="toLogin">
<image class="pic" :src="$util.getIcon(item)"></image>
<view class="texts">
<view class="name ell">{{ item.productName }}</view>
@ -75,140 +69,39 @@
</view>
</view>
</view>
<view v-if="auth('产品:购物车')" class="plus">
<uni-badge size="small" :text="total" absolute="topRight" type="error" :custom-style="customStyle">
<image class="icon" src="@/static/image/product/shop-blue.png" mode="widthFix" @click="$util.to('/order/shopCart/shopCart')"></image>
</uni-badge>
</view>
<view v-if="!per" class="per-mask">功能升级中敬请期待...</view>
</view>
</template>
<script>
import { getUserRolesPermissionMenu } from '@/apis/modules/user.js'
import { tagsList, listOfGoods, shoppingCartList } from '@/apis/modules/product.js'
import { getTeamsByAccountId } from '@/apis/modules/client.js'
import { tagsList, listOfGoods } from '@/apis/modules/product.js'
export default {
data() {
return {
per: true, //
teamId: uni.getStorageSync('teamId') || '',
list: [],
keyword: '',
tags: [],
hotProducts: [],
offcialProducts: [],
total: 0,
customStyle: {
width: '46rpx',
height: '46rpx',
lineHeight: '40rpx',
fontSize: '34rpx'
}
}
},
onShow() {
this.keyword = ''
this.per = true
//
if (uni.getStorageSync('token')) {
this.getInfo()
this.getShopCart()
} else {
this.getTags()
this.getProducts()
uni.reLaunch({
url: '../home/home'
})
}
this.keyword = ''
this.getTags()
this.getProducts()
},
methods: {
//
initRole() {
if (!uni.getStorageSync('auth').includes('首页')) {
this.per = false
}
this.getTags()
this.getProducts()
},
//
getAuth() {
getUserRolesPermissionMenu({
teamId: this.list.find(e => e.teamId == this.teamId).partnerClassificationId,
platformId: 4
}).then(({ permissionMenu }) => {
uni.hideLoading()
const auth = []
//
const generateAuth = (list, parent) => {
list.map(e => {
const name = `${parent ? parent + ':' : ''}${e.name}`
auth.push(name)
generateAuth(e.children, name)
})
}
generateAuth(permissionMenu[0].children, '')
uni.setStorageSync('auth', auth)
this.$forceUpdate()
this.initRole()
}).catch(e => {
uni.hideLoading()
uni.setStorageSync('auth', [])
this.initRole()
})
},
//
getInfo() {
uni.showLoading({
title: '加载中'
})
getTeamsByAccountId().then(({ data }) => {
data.map(e => {
const n = e.partnerClassificationList
e.id = n.id
// parnerIdidteamIduni.getStorageSync('team').partnerId使
e.teamId = e.isTeam == 1 ? +e.partnerClassificationId : n.id
e.partnerClassificationName = n.partnerClassificationName
delete e.partnerClassificationList
})
if (data.length) {
/**
* @description 如果是第一次进则默认选中第一个团队并把该团队的信息存入缓存
* 或者团队列表里没有该id则说明超管已经被转让也需要重新选中团队
*/
if (!uni.getStorageSync('team') || !data.find(e => e.teamId == this.teamId)) {
this.teamId = data[0].teamId
uni.setStorageSync('team', data[0])
}
} else {
// 退
uni.hideLoading()
uni.clearStorageSync()
uni.navigateTo({
url: '../login/login'
})
}
this.list = data
this.getAuth()
}).catch(e => {
uni.hideLoading()
})
},
//
getTags() {
tagsList().then(res => {
this.tags = res.tagsList.slice(0, 8)
}).catch(e => {})
},
//
getShopCart() {
shoppingCartList({
pageNum: 1,
pageSize: 1000,
}).then(({ data }) => {
this.total = data.total
}).catch(e => {})
},
//
getProducts() {
//
@ -240,21 +133,11 @@
this.offcialProducts = page.records
}).catch(e => {})
},
//
searchConfirm(e) {
e.value && this.$util.to(`/order/products/products?keyword=${e.value}`)
},
//
toHot(item) {
this.$util.to(`/order/products/products?tagId=${item.tagsId}&tagsName=${item.tagsName}`)
},
//
toProduct() {
this.$util.to('/order/products/products')
},
//
toDetail(item) {
this.$util.to('/order/productDetail/productDetail?id=' + item.mallId)
//
toLogin() {
uni.redirectTo({
url: '../login/login'
})
},
}
}

@ -226,7 +226,7 @@
//
toIndex() {
uni.reLaunch({
url: '../index/index'
url: '../home/home'
})
}
}

@ -216,8 +216,8 @@
// 退
uni.hideLoading()
uni.clearStorageSync()
uni.navigateTo({
url: '../login/login'
uni.redirectTo({
url: '../index/index'
})
}
this.disabled = uni.getStorageSync('team').isTeam == 0 //

@ -133,7 +133,7 @@
//
toIndex() {
uni.reLaunch({
url: this.my ? '../person/person' : '../index/index'
url: this.my ? '../person/person' : '../home/home'
})
},
//

@ -222,8 +222,8 @@
// 退
uni.hideLoading()
uni.clearStorageSync()
uni.navigateTo({
url: '../login/login'
uni.redirectTo({
url: '../index/index'
})
}

@ -69,7 +69,9 @@
success(res) {
if (res.confirm) {
uni.clearStorageSync()
that.$util.to('/pages/login/login')
uni.redirectTo({
url: '/pages/index/index'
})
}
}
})

Loading…
Cancel
Save