【前端】云工厂的纸掌柜app
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

496 lines
14 KiB

<template>
<view>
<view v-if="hasCompany" class="wrapper">
<uni-nav-bar :fixed="true" color="#ffffff" background-color="#ffffff" :status-bar="true">
<view slot="left" class="left-title">纸商城</view>
<view slot="right" class="right-title" @tap="shareTap">分享</view>
</uni-nav-bar>
<view class="top-box" :style="backgroundStyle">
<view class=""><image class="image" :src="logo" mode=""></image></view>
<view class="center">
<view class="title">{{ storeInformation.name }}</view>
<view class="desc">全部商品 {{ storeInformation.productNumber }} &nbsp; | &nbsp;上新 {{ storeInformation.currentProductNumber }}</view>
</view>
<view class="right">
<view class="cut" @click="checkMall()">
切换商城
<image class="cut-icon" src="/static/imgs/mall/cut-icon.png" mode=""></image>
</view>
<view class="set" @click="setting">设置</view>
</view>
</view>
<view>
<scroll-list ref="list" :option="option" @load="upCallback" @refresh="downCallback">
<view v-for="(item, index) in listData" :key="index" style="margin-bottom: 20rpx">
<view class="content" @click="detailInfo(item)">
<image
class="image"
:src="item.litPicUrl || 'https://qncloud.oss-cn-shenzhen.aliyuncs.com/paper_shopkeeper/paper-default-small.png'"
mode=""
></image>
<view class="" style="width: 100%">
<view class="title">
<view class="">{{ item.name }}</view>
<view class="">
<image
class="icon"
:src="item.status === 30111 ? '/static/imgs/mall/grounding-icon.png' : '/static/imgs/mall/sold-out-icon.png'"
mode=""
></image>
</view>
</view>
<view class="sub-title">{{ item.manufacturerName }}/{{ item.categoryName }}/{{ item.brandName }}</view>
<view class="desc flex-row-center-start" style="flex-wrap: wrap">
克重(价格):
<text style="margin-right: 8rpx" v-for="(sku, index) in item.skuList" :key="index">{{ sku.weight }}g({{ sku.listPrice }}元)</text>
</view>
</view>
</view>
<view class="other">
<view class="time">{{ item.updateTime | timeFilter }}</view>
<view class="btn">
<view class="" @click="editPaper(item)" v-if="item.status === 30112">编辑</view>
<view class="divide"></view>
<view class="" @click="productStatusChange(item)">{{ item.status === 30111 ? '下架' : '上架' }}</view>
</view>
</view>
</view>
<view slot="empty">
<no-data></no-data>
</view>
</scroll-list>
</view>
<view>
<view class="offer-prices" @click="nativeTo()"><image class="my-image" src="../../static/imgs/trade/camera.png"></image></view>
</view>
</view>
<view v-else>
<uni-nav-bar :fixed="true" :status-bar="true">
<view slot="left" style="font-size: 40rpx; color: #000000">纸商城</view>
</uni-nav-bar>
<view class="flex-col-center-center" style="margin-top: 100rpx">
<text style="font-size: 30rpx; text-align: center; font-weight: 600">请先完善企业基本信息</text>
</view>
</view>
<view class="share-area" v-if="visible">
<view class="close-icon">
<uni-icons @click="closeShare" type="close" size="35" color="white"></uni-icons>
</view>
<view class="share-content">
<view class="flex-col-center-start">
<text style="font-size: 34rpx">截图分享店铺</text>
<image style="width: 250rpx; height: 250rpx; margin-top: 30rpx" :src="storeCodeImg"></image>
</view>
</view>
</view>
</view>
</template>
<script>
import uGap from '@/components/u-gap/u-gap.vue'
import { back, go2, loginGo2 } from '@/utils/hook.js'
import { SupplierList, productStatus, storeDetail, getSupplierQrCode } from '@/apis/add-paper.js'
import { getTimer } from '@/utils/index.js'
import noData from './no-data.vue'
export default {
components: { uGap, noData },
filters: {
timeFilter(value) {
var abs = ''
if (value) {
abs = getTimer(value)
}
return abs
}
},
data() {
return {
storeCodeImg: '', // 店铺二维码
visible: false, // 分享弹窗
storeInformation: {
supplierId: null,
name: null,
productNumber: 0,
currentProductNumber: 0
},
option: {
size: 10,
auto: true,
emptyText: '暂无数据~',
disabled: false
},
pattern: {
backgroundColor: '#007AFF',
buttonColor: '#007AFF'
},
content: [],
horizontal: 'right',
vertical: 'bottom',
direction: 'vertical',
orderPagination: {
pageNum: 0, // 初始会执行一次下拉加载
pageSize: 10,
storeId: null,
name: null,
supplierId: this.$store.state.supplierInfo.supplierId
},
listData: [],
logo: 'https://qncloud.oss-cn-shenzhen.aliyuncs.com/ztb_pic/testPic.jfif',
backgroundStyle: 'background: url("/static/imgs/mall/top-bg.png") no-repeat;',
storeInfo: ''
}
},
computed: {
hasCompany() {
return this.$store.state.supplierInfo.id != null
}
},
onShow() {
if (this.hasCompany) {
this.storeInformation = {
supplierId: this.$store.state.supplierInfo.supplierId
}
this.downCallback()
this.getSupplier(this.$store.state.supplierInfo.supplierId)
}
},
methods: {
back,
// 获取上新商品数量
getSupplier(id) {
storeDetail(id)
.then((res) => {
if (res) {
this.storeInfo = res
this.$set(this.storeInformation, 'productNumber', res.productNumber)
this.$set(this.storeInformation, 'currentProductNumber', res.currentProductNumber)
this.$set(this.storeInformation, 'name', res.name)
if (!res.logo) {
this.logo = 'bug 默认logo'
} else {
this.logo = res.logo
}
if (!res.backgroundImg) {
this.backgroundStyle = 'background: url("/static/imgs/mall/top-bg.png") no-repeat;'
} else {
this.backgroundStyle = 'background: url(' + res.backgroundImg + ') no-repeat;'
}
}
})
.catch((err) => {
reject(err)
})
},
// 获取纸品列表
queryData() {
return new Promise((resolve, reject) => {
SupplierList({ ...this.orderPagination })
.then((res) => {
if (res) {
if (this.orderPagination.pageNum == 1) {
this.listData = res.records
} else {
this.listData = this.listData.concat(res.records)
}
resolve({ list: this.listData, total: res.total })
}
})
.catch((err) => {
reject(err)
})
})
},
downCallback() {
this.orderPagination.pageNum = 1
this.queryData()
.then(({ list, total }) => {
this.$refs.list.refreshSuccess({ list, total })
})
.catch(() => {
this.$refs.list.refreshFail()
})
},
upCallback() {
this.orderPagination.pageNum++
this.queryData()
.then(({ list, total }) => {
this.$refs.list.loadSuccess({ list, total })
})
.catch(() => {
this.$refs.list.loadFail()
})
},
// 切换商城按钮
checkMall() {
go2('switching-mall', { supplierId: this.storeInformation.supplierId })
},
// 按钮点击事件
nativeTo() {
var params = {
title: '添加纸品'
}
go2('add-paper', params)
},
// 编辑事件
editPaper(item) {
var params = {
...item,
title: '编辑纸品'
}
go2('add-paper', params)
},
// 店铺设置按钮
setting(item) {
go2('store-settings', this.storeInfo)
},
// 详情点击事件
detailInfo(item) {
loginGo2('paper-detail', item)
},
// 上下架事件
productStatusChange(item) {
var params = {
id: item.id,
status: item.status === 30111 ? 30112 : 30111
}
productStatus(params).then((res) => {
if (res) {
uni.showToast({
title: '状态修改成功',
icon: 'success'
})
setTimeout(() => {
this.orderPagination.pageNum = 1
this.downCallback()
}, 500)
}
})
},
// 分享
shareTap() {
if (this.hasCompany) {
getSupplierQrCode({ mallSupplierId: this.$store.state.supplierInfo.supplierId }).then((res) => {
if (res) {
this.visible = true
this.storeCodeImg = `data:image/png;base64,${res}`
}
})
} else {
uni.showToast({
title: '请先完善企业信息',
icon: 'none'
})
}
},
closeShare() {
this.visible = false
}
}
}
</script>
<style lang="scss">
.wrapper {
width: 750rpx;
overflow: hidden;
.left-title {
font-size: 40rpx;
color: #000000;
letter-spacing: 0;
font-weight: 500;
}
.right-title {
font-size: 28rpx;
color: #007aff;
text-align: right;
font-weight: 500;
}
.top-box {
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-around;
height: 180rpx;
background-size: 100%;
.image {
width: 100rpx;
height: 100rpx;
border-radius: 50%;
}
.right {
width: 140rpx;
}
.center {
position: relative;
left: -20rpx;
}
.title {
font-size: 34rpx;
color: #ffffff;
letter-spacing: 2rpx;
font-weight: 600;
margin-bottom: 12rpx;
}
.desc {
opacity: 0.75;
font-size: 28rpx;
color: #ffffff;
letter-spacing: 0;
font-weight: 500;
padding-right: 32rpx;
}
.cut {
display: flex;
align-items: center;
font-size: 24rpx;
color: #ffffff;
letter-spacing: 0;
text-align: center;
font-weight: 400;
.cut-icon {
width: 29.42rpx;
height: 26.67rpx;
margin-left: 10rpx;
}
}
.set {
opacity: 0.75;
font-size: 28rpx;
color: #ffffff;
letter-spacing: 0;
font-weight: 500;
position: relative;
top: 39rpx;
left: 60rpx;
}
}
.content {
background: #ffffff;
border-bottom: 2rpx solid rgba(221, 221, 221, 0.5);
display: flex;
flex-direction: row;
padding: 24rpx 0rpx 24rpx 32rpx;
.image {
width: 100rpx;
height: 100rpx;
flex: 0 0 100rpx;
margin-right: 18rpx;
}
.title {
display: flex;
flex-direction: row;
justify-content: space-between;
font-size: 32rpx;
color: #333333;
letter-spacing: 0;
font-weight: 500;
.icon {
position: relative;
top: -22rpx;
width: 150rpx;
height: 50rpx;
}
}
.sub-title {
position: relative;
font-size: 28rpx;
color: #333333;
letter-spacing: 0;
font-weight: 400;
top: -4rpx;
}
.desc {
font-size: 28rpx;
color: #555555;
letter-spacing: 0;
font-weight: 400;
padding-top: 10rpx;
line-height: 1.4;
}
}
.other {
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
height: 80rpx;
background: #ffffff;
padding: 0rpx 32rpx;
.time {
font-size: 28rpx;
color: #888888;
letter-spacing: 0;
font-weight: 400;
}
.btn {
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
font-size: 28rpx;
color: #007aff;
letter-spacing: 0;
text-align: right;
font-weight: 400;
}
.divide {
width: 2rpx;
height: 32rpx;
background: #d8d8d8;
margin: 0 32rpx;
}
.icon {
width: 24rpx;
height: 24rpx;
margin-left: 6rpx;
}
}
.offer-prices {
position: absolute;
z-index: 100;
right: 32rpx;
bottom: 122rpx;
border-radius: 50%;
width: 100rpx;
height: 100rpx;
overflow: hidden;
box-shadow: 0rpx 4rpx 34rpx 0rpx rgba(0, 0, 0, 0.2);
}
.my-image {
width: 100rpx;
height: 100rpx;
}
}
.share-area {
width: 750rpx;
height: 100vh;
background: rgba(0, 0, 0, 0.5);
position: fixed;
z-index: 1000;
top: 0;
left: 0;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
.close-icon {
width: 750rpx;
padding: 0 32rpx;
height: 70rpx;
flex-grow: 0;
flex-shrink: 0;
display: flex;
flex-direction: row;
align-items: center;
justify-content: flex-end;
}
.share-content {
width: 560rpx;
margin-top: 26rpx;
background-color: #fff;
border-radius: 20rpx;
padding: 42rpx;
}
}
</style>