【前端】云工厂的纸掌柜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.

732 lines
20 KiB

<template>
<view style="position: relative">
<view v-if="hasCompany && hasLogin" 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
v-if="hasLogin && !hasCompany"
class="flex-col-center-center"
style="margin-top: 100rpx"
>
<text style="font-size: 30rpx; text-align: center; font-weight: 600"
>请先完善企业基本信息</text
>
</view>
<view class="" v-if="!hasLogin"
><not-logged @loginChange="loginChange()"></not-logged
></view>
</view>
<view class="flex-col section_4" v-show="visible">
<image
src="/static/imgs/mall/close-icon.png"
class="image_9"
@click="closeShare"
/>
<!-- <view class="flex-col section_5">
<view class="flex-col section_6">
<view class="flex-col items-center group_13">
<image src="/static/imgs/mall/border-bg.png" class="image_10" />
<image :src="shareInfo.storeCodeImg" class="image_11" />
</view>
<view class="flex-col items-center group_14">
<text class="text_15">{{ shareInfo.storeName }}</text>
<text class="text_16">每天上新特价纸,库存有限先到先得</text>
</view>
</view>
</view> -->
<image
style="width: 560rpx; height: 710rpx"
:src="shareInfo.storeCodeImg"
></image>
<view class="bottom-group flex-row view_3">
<text>下载海报</text>
<text class="text_18">下载二维码</text>
<text class="text_19">分享</text>
</view>
</view>
<!-- <view class="share-area" v-if="visible" @click="closeShare">
<view class="share-content">
<image class="bg" src="https://qncloud.oss-cn-shenzhen.aliyuncs.com/paper_shopkeeper/qrCode-bg.png"></image>
<view class="flex-col-center-start code">
<view class="border flex-row-center-center">
<image style="width: 480rpx; height: 480rpx" :src="shareInfo.storeCodeImg"></image>
</view>
<view class="down-button flex-row-center-center" @click.stop="makeScreenShot">
<text class="text">下载二维码</text>
</view>
<text style="font-size: 46rpx; color: #333333">{{ shareInfo.storeName }}</text>
<text style="font-size: 32rpx; color: #888888; margin-top: 14rpx">每天上新特价纸,库存有限先到先得</text>
</view>
</view>
</view> -->
<!-- <view v-if="visible" @click="closeShare">
<web-view :webview-styles="webviewStyles" src="/hybrid/html/share.html"></web-view>
</view> -->
</view>
</template>
<script>
import notLogged from '@/components/not-logged/not-logged.vue'
import uGap from '@/components/u-gap/u-gap.vue'
import { back, go2, loginGo2, saveImage } 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, notLogged },
filters: {
timeFilter(value) {
var abs = ''
if (value) {
abs = getTimer(value)
}
return abs
},
},
data() {
return {
shareInfo: {
storeCodeImg: '',
storeName: '',
},
visible: false, // 分享弹窗
canvasReady: 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: '/static/imgs/mine/user-avatar.png',
backgroundStyle:
'background: url("/static/imgs/mall/top-bg.png") no-repeat;',
storeInfo: '',
}
},
computed: {
hasCompany() {
return this.$store.state.supplierInfo.id != null
},
hasLogin() {
return this.$store.state.qnToken != ''
},
},
onShow() {
if (this.hasCompany) {
this.storeInformation = {
supplierId: this.$store.state.supplierInfo.supplierId,
}
this.downCallback()
this.getSupplier(this.$store.state.supplierInfo.supplierId)
}
},
methods: {
back,
loginChange() {
go2('login')
},
// 获取上新商品数量
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 = '/static/imgs/mine/user-avatar.png'
} 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', { id: item.id })
},
// 上下架事件
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) {
if (this.visible) {
return
}
getSupplierQrCode({
mallSupplierId: this.$store.state.supplierInfo.supplierId,
}).then((res) => {
if (res) {
this.visible = true
this.shareInfo.storeCodeImg = `data:image/png;base64,${res}`
this.shareInfo.storeName = this.storeInformation.name
saveImage(this.shareInfo.storeCodeImg)
}
})
} else {
uni.showToast({
title: '请先完善企业信息',
icon: 'none',
})
}
},
closeShare() {
this.visible = false
},
},
}
</script>
<style lang="scss" scoped>
.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: #888888;
position: fixed;
z-index: 998;
top: 0;
left: 0;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
.share-content {
width: 750rpx;
background-color: #fff;
border-radius: 20rpx;
padding: 64rpx 34rpx 70rpx;
position: relative;
.bg {
position: absolute;
top: 0;
left: 0;
width: 750rpx;
height: 944rpx;
}
.code {
position: relative;
z-index: 10;
background-color: #fff;
width: 680rpx;
border-radius: 20rpx;
box-shadow: 0px 3rpx 13rpx 0px rgba(0, 0, 0, 0.1);
padding: 40rpx 70rpx 64rpx;
.border {
width: 540rpx;
height: 540rpx;
background: url('https://qncloud.oss-cn-shenzhen.aliyuncs.com/paper_shopkeeper/qrCode-border.png')
no-repeat center/cover;
}
}
.down-button {
width: 540rpx;
height: 90rpx;
margin: 40rpx 0 76rpx;
background-image: linear-gradient(180deg, #6092ec 0%, #225dd4 100%);
border-radius: 45rpx;
.text {
font-size: 48rpx;
color: #ffffff;
}
}
}
}
.section_4 {
z-index: 100;
padding: 252rpx 36rpx 403rpx 95rpx;
background-color: rgba(0, 0, 0, 0.5);
top: 0;
right: 0;
bottom: 0;
left: 0;
position: absolute;
.image_9 {
align-self: flex-end;
width: 62rpx;
height: 62rpx;
}
.section_5 {
margin-top: 30rpx;
padding: 60rpx 0;
border-radius: 20rpx;
background-image: url('/static/imgs/mall/qrCode-bg.png');
background-size: 100% 100%;
background-repeat: no-repeat;
width: 560rpx;
.section_6 {
margin: 0 32rpx;
padding: 50rpx 56rpx 0;
background-color: rgb(255, 255, 255);
box-shadow: 0px 2rpx 10rpx 0px rgba(0, 0, 0, 0.1);
border-radius: 16rpx;
width: 496rpx;
.group_13 {
margin: 0 12rpx;
position: relative;
.image_10 {
width: 360rpx;
height: 360rpx;
}
.image_11 {
width: 330rpx;
height: 330rpx;
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
}
}
.group_14 {
padding: 40rpx 0 56rpx;
.text_15 {
color: rgb(51, 51, 51);
font-size: 30rpx;
font-weight: 500;
line-height: 42rpx;
white-space: nowrap;
}
.text_16 {
margin-top: 10rpx;
color: rgb(136, 136, 136);
font-size: 24rpx;
font-weight: 500;
line-height: 33rpx;
white-space: nowrap;
}
}
}
}
.bottom-group {
padding: 0 32rpx;
.text_18 {
margin-left: 83rpx;
}
.text_19 {
margin-left: 83rpx;
}
}
.view_3 {
margin-top: 40rpx;
color: rgb(255, 255, 255);
font-size: 30rpx;
font-weight: 500;
line-height: 42rpx;
white-space: nowrap;
}
}
#posters {
margin-top: 15px;
padding: 60rpx 0;
border-radius: 20rpx;
}
</style>