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

633 lines
18 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" />
<image style="width: 560rpx; height: 710rpx" :src="shareInfo.storeCodeImg"></image>
<view class="bottom-group flex-row justify-center view_3">
<text @click="downPoster">下载海报</text>
<text @click="showShareArea" class="text_19">分享</text>
</view>
</view>
<view class="flex-col section_8" v-if="shareAreaVisible">
<view class="flex-row group_20">
<view class="flex-col items-center" @click="sharePoster('WXSceneSession')">
<image src="/static/imgs/general/wx-icon.png" class="image_13" />
<text class="text_33">微信</text>
</view>
<view class="flex-col group_22" @click="sharePoster('WXSceneTimeline')">
<image src="/static/imgs/general/wx-circle-icon.png" class="image_13 image_15" />
<text class="text_34">朋友圈</text>
</view>
</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, saveBase64ToTempFile } 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'
import { H5_URL_STORE } from '@/enums/index.js'
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, // 分享弹窗
shareAreaVisible: 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
}
})
} else {
uni.showToast({
title: '请先完善企业信息',
icon: 'none',
})
}
},
closeShare() {
this.visible = false
this.shareAreaVisible = false
},
downPoster() {
saveImage(this.shareInfo.storeCodeImg)
},
sharePoster(scene) {
uni.share({
provider: 'weixin',
type: 0,
title: this.shareInfo.storeName,
summary: '点击进入我的商城\n限时特价等你来抢!',
scene: scene, // WXSceneTimeline,WXSceneSession
imageUrl: 'https://qncloud.oss-cn-shenzhen.aliyuncs.com/paper_shopkeeper/wx-share-store.png',
href: H5_URL_STORE + `id=${this.$store.state.supplierInfo.supplierId}`,
success: () => {
console.log('分享成功')
},
fail: (err) => {
console.log('err', err)
},
})
},
showShareArea() {
this.shareAreaVisible = true
},
},
}
</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;
}
}
.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_19 {
margin-left: 83rpx;
margin-right: 62rpx;
}
}
.view_3 {
margin-top: 40rpx;
color: rgb(255, 255, 255);
font-size: 30rpx;
font-weight: 500;
line-height: 42rpx;
white-space: nowrap;
}
}
.section_8 {
position: fixed;
z-index: 999;
bottom: 0;
left: 0;
right: 0;
margin-top: 213rpx;
padding: 32rpx 0 52rpx;
color: rgb(0, 0, 0);
font-size: 24rpx;
line-height: 33rpx;
white-space: nowrap;
background-color: rgb(255, 255, 255);
border-radius: 20rpx 20rpx 0px 0px;
.group_20 {
margin: 0 32rpx;
.group_22 {
margin-left: 36rpx;
flex: 1 1 auto;
.image_15 {
margin-left: 4rpx;
}
.text_34 {
margin-top: 10rpx;
}
}
.text_33 {
margin-top: 10rpx;
}
.image_13 {
width: 64rpx;
height: 64rpx;
}
}
}
</style>