feat(uniapp_v2): 二开功能迁移与小程序主包优化

- 从 uniapp 迁移 HJF 页面、API、组件及用户/订单相关改动
- queue、assets 使用独立分包以降低主包体积
- 修复首页单根节点与支付结果页 v-if 链
- 关闭 HjfDemoPanel 全局注册;uniNoticeBar 注释 $getAppWebview 避免 __webviewId__ 报错
- 配置域名与 manifest 应用名称;cache/store 防御性处理

Made-with: Cursor
This commit is contained in:
apple
2026-03-26 12:16:01 +08:00
parent c84aeda062
commit 8e17762510
742 changed files with 184117 additions and 0 deletions

View File

@@ -0,0 +1,280 @@
<template>
<base-drawer mode="bottom" :visible="visible" background-color="transparent" mask maskClosable @close="closeDrawer">
<view class="classify rd-t-40rpx">
<view class="title">修改分类
<view class="close acea-row row-center-wrapper" @tap="closeDrawer">
<text class="iconfont icon-ic_close"></text>
</view>
</view>
<checkbox-group @change="checkboxChange($event)" v-if="categoryList.length">
<view class="list acea-row">
<view class="item">
<view class="tips">一级分类</view>
<scroll-view scroll-y="true" class="scroll-Y">
<view class="itemn line1" :class="{checked: index == currentOne,on:checkedIds.includes(item.id+'')}" v-for="(item,index) in categoryList" :key="index" @click="categoryTap(index)">
<!-- #ifndef MP -->
<checkbox :value="(item.id).toString()"
:checked='checkedIds.includes(item.id+"")'
color="#ffffff" backgroundColor="#ffffff"
activeBackgroundColor="#2A7EFB" activeBorderColor="#2A7EFB"
style="transform:scale(0.9)" />
<!-- #endif -->
<!-- #ifdef MP -->
<checkbox :value="item.id" :checked='checkedIds.includes(item.id+"")' style="transform:scale(0.9)" color="#ffffff" />
<!-- #endif -->
{{item.cate_name}}
</view>
</scroll-view>
</view>
<view class="item on" :class="!categoryList[currentOne].children.length?'on3':''" v-if="categoryList[currentOne]">
<view class="tips">二级分类</view>
<scroll-view scroll-y="true" class="scroll-Y">
<view class="itemn line1" :class="{checked: jIndex == currentTwo,on:checkedIds.includes(j.id+'')}" v-for="(j,jIndex) in categoryList[currentOne].children" :key="jIndex" @click="categoryTwoTap(jIndex)">
<!-- #ifndef MP -->
<checkbox :value="(j.id).toString()" :checked='checkedIds.includes(j.id+"")'
color="#ffffff" backgroundColor="#ffffff"
activeBackgroundColor="#2A7EFB" activeBorderColor="#2A7EFB"
style="transform:scale(0.9)" />
<!-- #endif -->
<!-- #ifdef MP -->
<checkbox :value="j.id" :checked='checkedIds.includes(j.id+"")' style="transform:scale(0.9)" />
<!-- #endif -->
{{j.cate_name}}
</view>
</scroll-view>
</view>
<view class="item on2" v-if="categoryList[currentOne] && categoryList[currentOne].children.length">
<view class="tips">三级分类</view>
<scroll-view scroll-y="true" class="scroll-Y">
<view class="itemn line1" :class="{on:checkedIds.includes(x.id+'')}" v-for="(x,xIndex) in categoryList[currentOne].children[currentTwo].children" :key="xIndex">
<!-- #ifndef MP -->
<checkbox :value="(x.id).toString()" :checked='checkedIds.includes(x.id+"")'
color="#ffffff" backgroundColor="#ffffff"
activeBackgroundColor="#2A7EFB" activeBorderColor="#2A7EFB"
style="transform:scale(0.9)" />
<!-- #endif -->
<!-- #ifdef MP -->
<checkbox :value="x.id" :checked='checkedIds.includes(x.id+"")' style="transform:scale(0.9)" />
<!-- #endif -->
{{x.cate_name}}{{x.id}}
</view>
</scroll-view>
</view>
</view>
</checkbox-group>
<view class="empty-box" v-else>
<emptyPage title="暂无分类~" src="/statics/images/empty-box.png"></emptyPage>
</view>
<view class="footer acea-row row-between-wrapper">
<view class="bnt acea-row row-center-wrapper" @tap="reset">重置</view>
<view class="bnt on acea-row row-center-wrapper" @tap="define">确定</view>
</view>
</view>
</base-drawer>
</template>
<script>
import emptyPage from '@/components/emptyPage.vue';
import {
getCategory,
postBatchProcess
} from "@/api/admin";
export default {
components: {
emptyPage
},
props:{
visible: {
type: Boolean,
default: false,
},
},
data: function() {
return {
categoryList:[],
currentOne:0,
currentTwo:0,
checkedIds:[],
ids:null //父级商品id
};
},
mounted() {},
methods:{
checkboxChange(e, index, item){
this.checkedIds = e.detail.value;
},
categoryTwoTap(index){
this.currentTwo = index
},
categoryTap(index){
this.currentOne = index
this.currentTwo = 0
},
category(id,cateId){
this.ids = id;
if(cateId){
this.checkedIds = cateId.split(',')
}else{
this.checkedIds = []
}
getCategory().then(res=>{
this.categoryList = res.data;
}).catch(err=>{
this.$util.Tips({
title: err
});
})
},
reset(){
this.checkedIds = [];
},
define(){
console.log("非大概");
console.log(this.checkedIds);
if(!this.checkedIds.length){
this.$util.Tips({
title: '请选择分类'
});
return
}
let data = {
type:1,
data:{
cate_id:this.checkedIds
},
ids:this.ids
}
postBatchProcess(data).then(res=>{
this.$util.Tips({
title: res.msg
});
this.$emit('successChange');
}).catch(err=>{
this.$util.Tips({
title: err
});
})
},
closeDrawer() {
this.$emit('closeDrawer');
}
}
}
</script>
<style lang="scss" scoped>
/deep/ checkbox .wx-checkbox-input.wx-checkbox-input-checked {
border: 1px solid $primary-admin;
background-color: $primary-admin;
color: #fff;
}
/deep/checkbox{
margin-right: 13rpx;
}
/deep/uni-checkbox .uni-checkbox-input{
border-radius: 4rpx;
width: 28rpx;
height: 28rpx;
}
.classify{
background-color: #fff;
padding-bottom: 60rpx;
.title{
text-align: center;
height: 108rpx;
line-height: 108rpx;
font-size: 32rpx;
font-family: PingFang SC, PingFang SC;
font-weight: 600;
color: #333333;
position: relative;
padding: 0 30rpx;
.close{
width: 36rpx;
height: 36rpx;
line-height: 36rpx;
background: #EEEEEE;
border-radius: 50%;
position: absolute;
right: 30rpx;
top:38rpx;
.iconfont {
font-weight: 300;
font-size: 20rpx;
}
}
}
.list{
height: 770rpx;
.scroll-Y{
height: 684rpx;
}
.item{
width: 33.33%;
padding-left: 32rpx;
font-size: 26rpx;
font-family: PingFang SC, PingFang SC;
font-weight: 400;
color: #666666;
padding-top: 30rpx;
.tips{
color: #999;
font-size: 24rpx;
margin-bottom: 30rpx;
}
.itemn{
margin-bottom: 58rpx;
&.checked{
color: #000;
}
&.on{
color: $primary-admin;
}
}
&.on{
background-color: #FAFAFA;
}
&.on2{
background-color: #F5F5F5;
}
&.on3{
width: 66.66%;
}
}
}
.footer {
box-sizing: border-box;
padding: 0 20rpx;
width: 100%;
height: 112rpx;
background-color: #fff;
position: fixed;
bottom: 0;
z-index: 30;
height: calc(112rpx + constant(safe-area-inset-bottom)); ///兼容 IOS<11.2/
height: calc(112rpx + env(safe-area-inset-bottom)); ///兼容 IOS>11.2/
padding-bottom: constant(safe-area-inset-bottom); ///兼容 IOS<11.2/
padding-bottom: env(safe-area-inset-bottom); ///兼容 IOS>11.2/
left: 0;
.bnt {
width: 347rpx;
height: 72rpx;
border-radius: 50rpx;
border: 1px solid $primary-admin;
color: $primary-admin;
font-size: 26rpx;
font-family: PingFang SC, PingFang SC;
font-weight: 500;
&.on{
background-color: $primary-admin;
color: #fff;
}
}
}
}
</style>

View File

@@ -0,0 +1,153 @@
<template>
<base-drawer mode="bottom" :visible="visible" background-color="transparent" mask maskClosable @close="closeDrawer">
<view class="edit-price rd-t-40rpx" v-if="goodsInfo.attr_value">
<view class="title">修改价格/库存
<view class="close acea-row row-center-wrapper" @tap="closeDrawer">
<text class="iconfont icon-ic_close"></text>
</view>
</view>
<view class="list">
<view class="item acea-row row-between-wrapper">
<view>售价</view>
<input type="digit" :placeholder="'请填写售价'+tips" placeholder-class="placeholder" v-model="goodsInfo.attr_value.price" />
</view>
<view class="item acea-row row-between-wrapper">
<view>成本价</view>
<input type="digit" :placeholder="'请填写成本价'+tips" placeholder-class="placeholder" v-model="goodsInfo.attr_value.cost" />
</view>
<view class="item acea-row row-between-wrapper">
<view>划线</view>
<input type="digit" :placeholder="'请填写划线'+tips" placeholder-class="placeholder" v-model="goodsInfo.attr_value.ot_price" />
</view>
<view class="item acea-row row-between-wrapper">
<view>库存</view>
<input type="number" :placeholder="'请填写库存'+tips" placeholder-class="placeholder" v-model="goodsInfo.attr_value.stock" />
</view>
</view>
<view v-if="goodsInfo.spec_type" class="bnt acea-row row-center-wrapper" @tap="defineSpec">确定</view>
<view v-else class="bnt acea-row row-center-wrapper" @tap="define">保存</view>
</view>
</base-drawer>
</template>
<script>
import {
postUpdateAttrs
} from "@/api/admin";
export default {
props:{
visible: {
type: Boolean,
default: false,
},
goodsInfo: {
type: Object,
default: () => {}
},
},
data: function() {
return {
tips:''
};
},
mounted() {
this.tips = this.goodsInfo.spec_type?'(可为空)':''
},
methods:{
defineSpec(){
let info = this.goodsInfo.attr_value;
if(info.cost || info.price || info.ot_price || info.stock){
this.$emit('successChange',info);
}else{
this.$util.Tips({
title: '修改类容至少填写一项'
});
}
},
define(){
let data = {
attr_value:[]
}
data.attr_value.push(this.goodsInfo.attr_value)
postUpdateAttrs(this.goodsInfo.id,data).then(res=>{
this.$util.Tips({
title: res.msg
});
this.$emit('successChange');
}).catch(err=>{
this.$util.Tips({
title: err
});
})
},
closeDrawer() {
this.$emit('closeDrawer');
}
}
}
</script>
<style lang="scss" scoped>
.edit-price{
background-color: #fff;
padding-bottom: 60rpx;
.title{
text-align: center;
height: 108rpx;
line-height: 108rpx;
font-size: 32rpx;
font-family: PingFang SC, PingFang SC;
font-weight: 600;
color: #333333;
position: relative;
padding: 0 30rpx;
.close{
width: 36rpx;
height: 36rpx;
line-height: 36rpx;
background: #EEEEEE;
border-radius: 50%;
position: absolute;
right: 30rpx;
top:38rpx;
.iconfont {
font-weight: 300;
font-size: 20rpx;
}
}
}
.list{
padding: 0 10rpx 0 30rpx;
.item{
font-size: 28rpx;
font-family: PingFang SC, PingFang SC;
font-weight: 400;
color: #333333;
height: 72rpx;
margin-bottom: 32rpx;
box-sizing: border-box;
input {
text-align: right;
font-size: 28rpx;
height: 100%;
padding-right: 20rpx;
}
.placeholder{
font-size: 28rpx;
padding-right: 20rpx;
}
}
}
.bnt{
font-size: 26rpx;
font-family: PingFang SC, PingFang SC;
font-weight: 500;
color: #FFFFFF;
width: 710rpx;
height: 72rpx;
background: $primary-admin;
border-radius: 50rpx;
margin: 72rpx auto 0 auto;
}
}
</style>

View File

@@ -0,0 +1,252 @@
<template>
<base-drawer mode="right" :visible="visible" background-color="transparent" mask maskClosable @close="closeDrawer">
<view class="edit-lable">
<!-- #ifdef MP -->
<view class="accountTitle">
<view :style="{height:getHeight.barTop+'px'}"></view>
<view class="sysTitle acea-row row-center-wrapper" :style="{height:getHeight.barHeight+'px'}">
<view>添加标签</view>
</view>
</view>
<view :style="{height:(getHeight.barTop+getHeight.barHeight)+'px'}"></view>
<view class="list" v-if="isStore"
:style="'height: calc(100% - '+(getHeight.barTop+getHeight.barHeight*2+150)+'rpx - constant(safe-area-inset-bottom));height: calc(100% - '+(getHeight.barTop+getHeight.barHeight*2+150)+'rpx - env(safe-area-inset-bottom))'">
<!-- #endif -->
<!-- #ifndef MP -->
<view class="header">添加标签</view>
<view class="list" v-if="isStore">
<!-- #endif -->
<scroll-view scroll-y="true" style="height: 100%">
<view class="item" v-for="(item, index) in labelList" :key="index">
<view class="title" v-if="item.children && item.children.length">{{item.label_name}}</view>
<view class="listn acea-row row-middle" v-if="item.children && item.children.length">
<view class="name acea-row row-center-wrapper" :class="{on:j.disabled}" v-for="(j, indexn) in item.children" :key="indexn" @click="selectLabel(j)">
<text class="line1">{{j.label_name}}</text>
</view>
</view>
</view>
</scroll-view>
</view>
<view class="empty-box" v-else>
<emptyPage title="暂无标签~" src="/statics/images/empty-box.png"></emptyPage>
</view>
<view class="footer acea-row row-between-wrapper">
<view class="bnt acea-row row-center-wrapper" @tap="reset">重置</view>
<view class="bnt on acea-row row-center-wrapper" @tap="define">确定</view>
</view>
</view>
</base-drawer>
</template>
<script>
import emptyPage from '@/components/emptyPage.vue';
import {
getProductLabel,
postBatchProcess
} from "@/api/admin";
import { handleError } from "vue";
export default {
components: {
emptyPage
},
props:{
visible: {
type: Boolean,
default: false,
},
},
data: function() {
return {
// #ifdef MP
getHeight: this.$util.getWXStatusHeight(),
// #endif
labelList:[],
goodsInfo:{}, //列表中已存在id固定不变
dataLabel: [], //已存在选中id(随着选中可以变化)
isStore:false, //判断是否存在标签
num:0, // 判断是否为批量
ids:[] //批量时的id集合
};
},
mounted() {
},
methods:{
define(){
let data = {
data:{
store_label_id:this.dataLabel
},
type:2
}
if(this.num){
data.ids = this.ids
}else{
data.ids = this.goodsInfo.id
}
postBatchProcess(data).then(res=>{
this.$util.Tips({
title: res.msg
});
this.$emit('successChange');
}).catch(err=>{
this.$util.Tips({
title: err
});
})
},
reset(){
this.productLabel(this.goodsInfo,this.num,this.ids);
},
inArray: function (search, array) {
for (let i in array) {
if (array[i] == search) {
return true;
}
}
return false;
},
productLabel(data,num,ids){
this.dataLabel = data.store_label_id || [];
this.goodsInfo = JSON.parse(JSON.stringify(data));
this.num = num;
this.ids = ids;
getProductLabel().then(res=>{
res.data.map(el => {
if (el.children && el.children.length) {
this.isStore = true;
el.children.map(label => {
if (this.inArray(label.id, this.dataLabel)) {
label.disabled = true;
} else {
label.disabled = false;
}
})
}
})
this.labelList = res.data
}).catch(err=>{
this.$util.Tips({
title: err
});
})
},
selectLabel(label) {
if (label.disabled) {
let index = this.dataLabel.indexOf(this.dataLabel.filter(d => d == label.id)[0]);
this.dataLabel.splice(index, 1);
label.disabled = false
} else {
this.dataLabel.push(label.id);
label.disabled = true
}
},
closeDrawer() {
this.$emit('closeDrawer');
}
}
}
</script>
<style lang="scss" scoped>
.accountTitle{
position: fixed;
left:0;
top:0;
width: 100%;
z-index: 99;
padding-bottom: 6rpx;
.sysTitle{
width: 100%;
position: relative;
font-weight: 600;
color: #333333;
font-size: 34rpx;
font-family: PingFang SC, PingFang SC;
}
}
.edit-lable{
background-color: #fff;
width: 670rpx;
border-radius: 40rpx 0 0 40rpx;
height: 100%;
padding: 20rpx 34rpx 0 32rpx;
.header{
text-align: center;
height: 96rpx;
line-height: 96rpx;
font-size: 34rpx;
font-family: PingFang SC, PingFang SC;
font-weight: 600;
color: #333333;
position: relative;
}
.list{
overflow: auto;
height: calc(100% - 208rpx);
height: calc(100% - (208rpx + constant(safe-area-inset-bottom)));
height: calc(100% - (208rpx + env(safe-area-inset-bottom)));
.item{
margin-top: 48rpx;
.title{
font-size: 28rpx;
font-family: PingFang SC, PingFang SC;
font-weight: 600;
color: #333333;
}
.listn{
.name{
width: 184rpx;
height: 56rpx;
background-color: #F5F5F5;
border-radius: 50rpx;
border:1rpx solid #F5F5F5;
font-size: 24rpx;
font-family: PingFang SC, PingFang SC;
font-weight: 400;
color: #333333;
margin-right: 26rpx;
margin-top: 24rpx;
padding: 0 8rpx;
&.on {
background-color:$light-primary-admin;
border-color:$primary-admin;
color: $primary-admin;
}
&:nth-of-type(3n){
margin-right: 0;
}
}
}
}
}
.footer{
width: 100%;
height: 112rpx;
position: fixed;
bottom: 0;
left:0;
padding: 0 32rpx;
background-color: #fff;
border-radius: 0 0 0 40rpx;
height: calc(112rpx + constant(safe-area-inset-bottom)); ///兼容 IOS<11.2/
height: calc(112rpx + env(safe-area-inset-bottom)); ///兼容 IOS>11.2/
padding-bottom: constant(safe-area-inset-bottom); ///兼容 IOS<11.2/
padding-bottom: env(safe-area-inset-bottom); ///兼容 IOS>11.2/
.bnt{
width: 296rpx;
height: 72rpx;
border: 1px solid $primary-admin;
border-radius: 200rpx;
font-size: 26rpx;
font-family: PingFang SC, PingFang SC;
font-weight: 600;
color: $primary-admin;
&.on{
background: $primary-admin;
border-color: $primary-admin;
color: #fff;
}
}
}
}
</style>

View File

@@ -0,0 +1,651 @@
<template>
<view class="goods-list">
<!-- #ifdef MP || APP-PLUS -->
<view class="accountTitle">
<view :style="{height:getHeight.barTop+'px'}"></view>
<view class="sysTitle acea-row row-center-wrapper" :style="{height:getHeight.barHeight+'px'}">
<view>商品管理</view>
<text class="iconfont icon-ic_leftarrow" @click="goarrow"></text>
</view>
</view>
<view :style="{height:(getHeight.barTop+getHeight.barHeight)+'px'}"></view>
<!-- #endif -->
<view class="searchCon acea-row row-between-wrapper">
<view class="search acea-row row-middle">
<text class="iconfont icon-ic_search"></text>
<input class="inputs" placeholder='请输入商品名称/ID' placeholder-class='placeholder' confirm-type='search' name="search"
v-model="keyword" @confirm="searchSubmit"></input>
</view>
<view @click="manageTap" v-if="administer">取消</view>
<view class="edit acea-row row-center-wrapper" @click="manageTap" v-else>
<text class="iconfont icon-ic_batch"></text>
</view>
</view>
<view class="nav acea-row row-middle">
<view class="item" :class="current == index?'on':''" v-for="(item, index) in navList" :key="index" @click="navTap(item,index)">
{{item.name}}
<image src="../static/adorn.png" v-if="current == index"></image>
</view>
</view>
<view class="list" v-if="goodsList.length">
<checkbox-group @change="checkboxChange">
<view class="acea-row row-middle" v-for="(item, index) in goodsList" :key="index">
<!-- #ifndef MP -->
<checkbox class="checkbox" v-if="administer" :value="(item.id).toString()" :checked="item.checked"
color="#ffffff" backgroundColor="#ffffff"
activeBackgroundColor="#2A7EFB" activeBorderColor="#2A7EFB"/>
<!-- #endif -->
<!-- #ifdef MP -->
<checkbox class="checkbox" v-if="administer" :value="item.id" :checked="item.checked"
color="#ffffff"/>
<!-- #endif -->
<view class="item">
<view class="top acea-row row-center-wrapper" @tap="goDetail(item)">
<view class="pictrue">
<image :src="item.image"></image>
</view>
<view class="text">
<view class="name line1">{{item.store_name}}</view>
<view class="info">
<text>销量: {{item.sales}}</text>
<text>库存: {{item.stock}}</text>
<text>评分: {{item.star}}</text>
</view>
<baseMoney
:money="item.price"
symbolSize="20"
integerSize="32"
decimalSize="20"
color="#FF7E00"
></baseMoney>
</view>
</view>
<view class="bottom acea-row row-right" v-if="!administer">
<view class="bnt acea-row row-center-wrapper" :class="item.is_show?'':'up'" @click="setShow(item,0)">{{item.is_show?'下架':'上架'}}</view>
<view class="bnt on acea-row row-center-wrapper" @tap="openDrawer(item)">编辑</view>
</view>
</view>
</view>
</checkbox-group>
</view>
<view class="empty-box" v-if="goodsList.length == 0 && !loading">
<emptyPage title="暂无商品~" src="/statics/images/empty-box.gif"></emptyPage>
</view>
<Loading :loaded="loadend" :loading="loading"></Loading>
<view class="footerH"></view>
<view class="footer acea-row row-between-wrapper" v-if="administer">
<checkbox-group @change="checkboxAllChange">
<checkbox value="all" :checked="isAllSelect" color="#ffffff" backgroundColor="#ffffff"
activeBackgroundColor="#2A7EFB" activeBorderColor="#2A7EFB" />
<text class='checkAll'>全选({{getIds().length}})</text>
</checkbox-group>
<view class="acea-row row-middle">
<view class="bnt acea-row row-center-wrapper" @click="editLabels">添加标签</view>
<view class="bnt acea-row row-center-wrapper" @click="editClass">修改分类</view>
<view class="bnt acea-row row-center-wrapper" v-if="type == 1" @click="setShow('',1,0)">下架</view>
<view class="bnt acea-row row-center-wrapper" v-else-if="type == 2" @click="setShow('',1,1)">上架</view>
</view>
</view>
<footer-page></footer-page>
<base-drawer mode="bottom" :visible="visible" background-color="transparent" mask maskClosable @close="closeDrawer">
<view class="edit-list rd-t-40rpx">
<view class="item" v-for="(item, index) in editList" :key="index" @tap="editInfo(index)">{{item.name}}</view>
</view>
</base-drawer>
<edit-price :visible='visiblePrice' :goodsInfo='goodsInfo' @closeDrawer='priceCloseDrawer' @successChange='successChange'></edit-price>
<edit-lable ref="lable" :visible='visibleLable' @closeDrawer='lableCloseDrawer' @successChange='successChange'></edit-lable>
<classify ref="classify" :visible='visibleClass' @closeDrawer='classCloseDrawer' @successChange='successChange'></classify>
</view>
</template>
<script>
import Loading from '@/components/Loading/index';
import emptyPage from '@/components/emptyPage.vue';
import footerPage from '../components/footerPage/index.vue';
import editPrice from './components/editPrice/index.vue';
import editLable from './components/label/index.vue';
import classify from './components/classify/index.vue';
import { goShopDetail } from '@/libs/order.js';
import {
adminProductList,
productSetShow
} from "@/api/admin";
export default {
components: {
editPrice,
editLable,
classify,
footerPage,
emptyPage,
Loading
},
data() {
return {
getHeight: this.$util.getWXStatusHeight(),
navList:[
{
name:'全部',
type:''
},
{
name:'出售中',
type:1
},
{
name:'仓库中',
type:2
},
{
name:'已售罄',
type:4
},
{
name:'库存警告',
type:5
}
],
editList:[
{
name:'修改价格/库存'
},
{
name:'商品分类'
},
{
name:'商品标签'
},
],
current:0,
administer:0,
isAllSelect: false,
goodsList:[],
goodsInfo:{},
visible:false,
visiblePrice:false, //价格库存是否显示
visibleLable:false, //标签是否显示
loadTitle: '加载更多',
loading: false,
loadend: false,
limit: 20,
page: 1,
keyword:'', //搜索字段
type:'', //商品状态
visibleClass:false,
}
},
onShow() {
},
onLoad(option) {
this.type = option.type || '';
this.keyword = option.keyword || '';
for (let i = 0; i < this.navList.length; i++) {
if (this.navList[i].type == this.type) {
this.current = i;
break;
}
}
this.productList();
},
methods: {
// 去详情页
goDetail(item) {
if(!item.is_show){
this.$util.Tips({
title: '商品未上架'
});
return
}
goShopDetail(item, this.$store.state.app.uid).catch(res => {
uni.navigateTo({
url: `/pages/goods_details/index?id=${item.id}`
});
});
},
goarrow(){
uni.navigateBack()
},
editClass(){
if(!this.getIds().length){
this.$util.Tips({
title: '请选择商品'
});
return
}
this.$refs.classify.category(this.getIds(),'');
let that = this;
setTimeout(function(){
that.visibleClass = true
},200)
},
classCloseDrawer(){
this.visibleClass = false
},
successChange(){
this.visibleClass = false
this.visibleLable = false
this.visiblePrice = false
this.init();
},
//批量编辑标签
editLabels(){
if(!this.getIds().length){
this.$util.Tips({
title: '请选择商品'
});
return
}
this.visibleLable = true
this.$refs.lable.productLabel({},1,this.getIds());
},
//批量获取id集合
getIds(){
let ids = []
this.goodsList.forEach(item=>{
if(item.checked){
ids.push(item.id)
}
})
ids.slice(0, 100)
return ids
},
setShow(item,num,type){
let data = {}
if(num){
if(!this.getIds().length){
this.$util.Tips({
title: '请选择商品'
});
return
}
data = {
id:this.getIds(),
is_show:type
}
}else{
data = {
id:item.id,
is_show:item.is_show?0:1
}
}
productSetShow(data).then(res=>{
this.$util.Tips({
title: res.msg
});
this.init();
}).catch(err=>{
this.$util.Tips({
title: err
});
})
},
init(){
this.goodsList = [];
this.page = 1;
this.loadend = false;
this.loading = false;
this.productList();
},
searchSubmit(){
this.init();
},
productList(){
let that = this;
if (this.loading) return;
if (this.loadend) return;
that.loading = true;
that.loadTitle = "";
adminProductList({
page: that.page,
limit: that.limit,
store_name: that.keyword,
type: that.type,
}).then(res=>{
let goodsList = res.data.list;
goodsList.forEach(item => {
item.checked = false;
})
this.isAllSelect = false
let loadend = goodsList.length < that.limit;
that.goodsList = that.$util.SplitArray(goodsList, that.goodsList);
that.$set(that, 'goodsList', that.goodsList);
that.loadend = loadend;
that.loadTitle = loadend ? '没有更多内容啦~' : '加载更多';
that.page = that.page + 1;
that.loading = false;
}).catch(err=>{
that.loading = false;
that.loadTitle = "加载更多";
})
},
editInfo(index){
switch (index) {
case 0:
this.visible = false
if(this.goodsInfo.spec_type){
uni.navigateTo({
url: '/pages/admin/goods/specs?id='+this.goodsInfo.id
})
}else{
this.visiblePrice = true
}
break;
case 1:
this.visible = false
this.visibleClass = true
break;
case 2:
this.visibleLable = true
this.visible = false
break;
}
},
lableCloseDrawer(){
this.visibleLable = false
},
priceCloseDrawer(){
this.visiblePrice = false
},
openDrawer(item){
this.visible = true
this.goodsInfo = JSON.parse(JSON.stringify(item))
this.$refs.lable.productLabel(this.goodsInfo,0,[]);
this.$refs.classify.category(item.id,item.cate_id);
},
closeDrawer(){
this.visible = false
},
manageTap() {
this.administer = !this.administer;
},
navTap(item,index){
this.current = index;
if (this.type != item.type) {
this.type = item.type;
this.init();
}
},
checkboxChange(event) {
let idList = event.detail.value;
this.goodsList.forEach((item) => {
if (idList.indexOf(item.id + '') !== -1) {
item.checked = true;
} else {
item.checked = false;
}
})
if (idList.length == this.goodsList.length) {
this.isAllSelect = true;
} else {
this.isAllSelect = false;
}
},
forGoods(val) {
let that = this;
if (!that.goodsList.length) return
that.goodsList.forEach((item) => {
if (val) {
item.checked = true;
} else {
item.checked = false;
}
})
},
checkboxAllChange(event) {
let value = event.detail.value;
if (value.length) {
if(this.goodsList.length>100){
this.$util.Tips({
title: '每次最多只提交100条数据'
});
}
this.isAllSelect = true;
this.forGoods(1)
} else {
this.isAllSelect = false;
this.forGoods(0)
}
},
},
onReachBottom(){
this.productList();
}
}
</script>
<style lang="scss" scoped>
/deep/checkbox .wx-checkbox-input.wx-checkbox-input-checked {
border: 1px solid $primary-admin !important;
background-color: $primary-admin !important;
}
/deep/uni-checkbox .uni-checkbox-input{
margin-top: -4rpx;
}
/deep/checkbox:not([disabled]) .uni-checkbox-input:hover {
border-color: #d1d1d1 !important;
}
.empty-box{
padding: 0 20rpx;
}
.accountTitle{
background: #F5F5F5;
position: fixed;
left:0;
top:0;
width: 100%;
z-index: 99;
padding-bottom: 6rpx;
.sysTitle{
width: 100%;
position: relative;
font-weight: 500;
color: #333333;
font-size: 30rpx;
.iconfont{
position: absolute;
font-size: 42rpx;
left:20rpx;
width: 60rpx;
font-weight: 500;
}
}
}
.goods-list{
padding-top: 20rpx;
.searchCon{
padding: 0 20rpx;
.search{
width: 618rpx;
height: 72rpx;
background: #FFFFFF;
border-radius: 50rpx;
padding: 0 34rpx;
.iconfont{
color: #999;
font-size: 32rpx;
margin-right: 16rpx;
}
.inputs{
font-size: 28rpx;
width: 100%;
height: 100%;
flex: 1;
}
.placeholder{
color: #ccc;
}
}
.edit{
width: 72rpx;
height: 72rpx;
background: #FFFFFF;
border-radius: 50%;
.iconfont {
color: #666;
font-size: 36rpx;
}
}
}
.nav{
padding: 20rpx 20rpx 18rpx 34rpx;
position: sticky;
top:0;
left:0;
width: 100%;
background-color: #F5F5F5;
z-index: 9;
.item{
font-weight: 400;
font-size: 26rpx;
color: #333333;
padding: 10rpx 0;
position: relative;
&~.item{
margin-left: 72rpx;
}
&.on{
font-weight: 500;
color: $primary-admin;
font-size: 30rpx;
font-family: PingFang SC, PingFang SC;
}
image {
width: 14rpx;
height: 14rpx;
display: block;
position: absolute;
bottom: 0;
right: -4rpx;
}
}
}
.list{
padding-bottom: 20rpx;
padding: 0 20rpx 20rpx 20rpx;
/deep/uni-checkbox .uni-checkbox-input{
background-color: #f5f5f5;
margin: 0 20rpx 20rpx 0;
}
/deep/wx-checkbox .wx-checkbox-input{
background-color: #f5f5f5;
margin: 0 20rpx 20rpx 0;
}
.item {
width: 100%;
background-color: #fff;
padding: 24rpx;
box-sizing: border-box;
margin-bottom: 20rpx;
border-radius: 24rpx;
flex: 1;
overflow: hidden;
.top{
.checkbox{
margin-right: 10rpx;
}
.pictrue{
width: 136rpx;
height: 136rpx;
margin-right: 20rpx;
image {
width: 100%;
height: 100%;
border-radius: 16rpx;
}
}
.text{
flex: 1;
overflow: hidden;
.name {
font-size: 28rpx;
font-weight: 400;
color: #333333;
}
.info {
font-size: 24rpx;
font-weight: 400;
color: #666666;
margin: 10rpx 0 18rpx 0;
text {
margin-right: 40rpx;
}
}
}
}
.bottom{
margin-top: 26rpx;
.bnt{
width: 144rpx;
height: 56rpx;
border:1px solid #ccc;
font-size: 24rpx;
font-family: PingFang SC, PingFang SC;
font-weight: 400;
color: #333333;
border-radius: 50rpx;
&~.bnt{
margin-left: 16rpx;
}
&.on{
border-color: $primary-admin;
background-color: $primary-admin;
color: #fff;
}
&.up{
border-color: #FF7E00;
color: #FF7E00;
}
}
}
}
}
.footerH {
height: 110rpx;
height: calc(110rpx + constant(safe-area-inset-bottom)); ///兼容 IOS<11.2/
height: calc(110rpx + env(safe-area-inset-bottom)); ///兼容 IOS>11.2/
}
.footer {
box-sizing: border-box;
padding: 0 32rpx;
width: 100%;
height: 96rpx;
background-color: #fff;
position: fixed;
bottom: 0;
z-index: 30;
height: calc(96rpx + constant(safe-area-inset-bottom)); ///兼容 IOS<11.2/
height: calc(96rpx + env(safe-area-inset-bottom)); ///兼容 IOS>11.2/
padding-bottom: constant(safe-area-inset-bottom); ///兼容 IOS<11.2/
padding-bottom: env(safe-area-inset-bottom); ///兼容 IOS>11.2/
width: 100%;
left: 0;
.bnt {
width: 160rpx;
height: 64rpx;
border-radius: 50rpx;
border: 1rpx solid $primary-admin;
color: $primary-admin;
font-size: 24rpx;
font-family: PingFang SC, PingFang SC;
font-weight: 500;
&~.bnt{
margin-left: 16rpx;
}
}
}
.edit-list{
background-color: #fff;
padding: 45rpx 34rpx;
.item{
font-family: PingFang SC, PingFang SC;
font-weight: 400;
color: #333333;
font-size: 32rpx;
text-align: center;
height: 106rpx;
line-height: 106rpx;
}
}
}
</style>

View File

@@ -0,0 +1,340 @@
<template>
<view class="specs">
<checkbox-group @change="checkboxChange">
<view class="list acea-row" :class="administer?'on':''" v-for="(item, index) in attrsList" :key="index">
<!-- #ifndef MP -->
<checkbox class="checkbox" v-if="administer" :value="(item.id).toString()" :checked="item.checked" />
<!-- #endif -->
<!-- #ifdef MP -->
<checkbox class="checkbox" v-if="administer" :value="item.id" :checked="item.checked" />
<!-- #endif -->
<view class="listCon">
<!-- <view class="item acea-row row-middle">
<view class="name">商品图</view>
<view class="pictrue">
<image :src="item.image" mode="aspectFill"></image>
</view>
</view> -->
<view class="item acea-row row-middle">
<view class="name">规格名称</view>
<view class="info">{{item.suk}}</view>
</view>
<view class="item acea-row row-middle">
<view class="name">售价</view>
<input type="number" :disabled="administer" min='0' v-model="item.price" placeholder="请填写售价" placeholder-class="placeholder"/>
</view>
<view class="item acea-row row-middle">
<view class="name">成本价</view>
<input type="number" :disabled="administer" v-model="item.cost" placeholder="请填写成本价" placeholder-class="placeholder"/>
</view>
<view class="item acea-row row-middle">
<view class="name">原价</view>
<input type="number" :disabled="administer" v-model="item.ot_price" placeholder="请填写原价" placeholder-class="placeholder"/>
</view>
<view class="item acea-row row-middle">
<view class="name">库存</view>
<input type="number" :disabled="administer" v-model="item.stock" placeholder="请填写库存" placeholder-class="placeholder"/>
</view>
</view>
</view>
</checkbox-group>
<view class="footer on acea-row row-between-wrapper" v-if="administer">
<checkbox-group @change="checkboxAllChange">
<checkbox value="all" :checked="isAllSelect" />
<text class='checkAll'>全选</text>
</checkbox-group>
<view class="acea-row row-middle">
<view class="bnt acea-row row-center-wrapper" @click="manageTap">取消</view>
<view class="bnt on acea-row row-center-wrapper" @click="batchEdit">批量修改</view>
</view>
</view>
<view class="footer acea-row row-between-wrapper" v-else>
<view class="bnt acea-row row-center-wrapper" @click="manageTap">批量操作</view>
<view class="bnt on acea-row row-center-wrapper" @click="define">保存</view>
</view>
<edit-price :visible='visiblePrice' :goodsInfo='goodsInfo' @closeDrawer='priceCloseDrawer' @successChange='successChange'></edit-price>
</view>
</template>
<script>
import editPrice from './components/editPrice/index.vue';
import {
getGetAttrs,
postUpdateAttrs
} from "@/api/admin";
export default {
components: {
editPrice
},
data() {
return {
attrsList:[],
id:0,
administer:false,
isAllSelect: false,
visiblePrice: false,
goodsInfo:{
id:0,
spec_type:1,
attr_value:{}
}
}
},
onShow() {
},
onLoad(option) {
this.id = option.id;
this.getAttrsList();
},
methods:{
//批量获取id集合
getIds(){
let ids = []
this.attrsList.forEach(item=>{
if(item.checked){
ids.push(item.id)
}
})
return ids
},
batchEdit(){
if(!this.getIds().length){
this.$util.Tips({
title: '请选择商品规格'
});
return
}
this.goodsInfo.id = this.id;
this.goodsInfo.attr_value = {
cost:'',
price:'',
ot_price:'',
stock:''
}
this.visiblePrice = true;
},
define(){
let data = {
attr_value:[]
}
this.attrsList.forEach(item=>{
data.attr_value.push({
cost:item.cost,
price:item.price,
ot_price:item.ot_price,
stock:item.stock,
unique:item.unique
})
})
postUpdateAttrs(this.id,data).then(res=>{
this.$util.Tips({
title: res.msg
},() => {
uni.navigateTo({
url: '/pages/admin/goods/index'
})
});
}).catch(err=>{
this.$util.Tips({
title: err
});
})
},
getAttrsList(){
getGetAttrs(this.id).then(res=>{
let data = res.data;
data.forEach(item => {
item.checked = false;
})
this.attrsList = data;
}).catch(err=>{
this.$util.Tips({
title: err
});
})
},
checkboxChange(event) {
let idList = event.detail.value;
this.attrsList.forEach((item) => {
if (idList.indexOf(item.id + '') !== -1) {
item.checked = true;
} else {
item.checked = false;
}
})
if (idList.length == this.attrsList.length) {
this.isAllSelect = true;
} else {
this.isAllSelect = false;
}
},
forGoods(val) {
let that = this;
if (!that.attrsList.length) return
that.attrsList.forEach((item) => {
if (val) {
item.checked = true;
} else {
item.checked = false;
}
})
},
checkboxAllChange(event) {
let value = event.detail.value;
if (value.length) {
this.isAllSelect = true;
this.forGoods(1)
} else {
this.isAllSelect = false;
this.forGoods(0)
}
},
manageTap() {
this.administer = !this.administer;
},
priceCloseDrawer(){
this.visiblePrice = false
},
successChange(e){
this.visiblePrice = false
let data = e;
this.attrsList.forEach(item=>{
if(item.checked){
if(data.cost){
item.cost = data.cost
}
if(data.price){
item.price = data.price
}
if(data.ot_price){
item.ot_price = data.ot_price
}
if(data.stock){
item.stock = data.stock
}
}
})
this.manageTap();
}
}
}
</script>
<style lang="scss" scoped>
/deep/checkbox .uni-checkbox-input.uni-checkbox-input-checked {
border: 1px solid $primary-admin !important;
background-color: $primary-admin !important;
}
/deep/checkbox .wx-checkbox-input.wx-checkbox-input-checked {
border: 1px solid $primary-admin !important;
background-color: $primary-admin !important;
}
.specs{
padding: 24rpx 20rpx 112rpx 20rpx;
padding-bottom: calc(112rpx + constant(safe-area-inset-bottom)); ///兼容 IOS<11.2/
padding-bottom: calc(112rpx + env(safe-area-inset-bottom)); ///兼容 IOS>11.2/
.list{
background-color: #fff;
border-radius: 24rpx;
padding: 0 24rpx;
margin-bottom: 20rpx;
.listCon{
flex: 1;
}
&.on {
input{
color: #999999 !important;
}
}
.checkbox{
margin: 32rpx 12rpx 0 0;
}
.item{
min-height: 102rpx;
font-size: 28rpx;
font-family: PingFang SC, PingFang SC;
font-weight: 400;
&~.item{
border-top: 1px solid #F1F1F1;
}
.name{
color: #333333;
width: 115rpx;
margin-right: 39rpx;
}
.info{
color: #999999;
flex: 1;
}
input {
font-size: 36rpx;
font-family: 'Regular';
color: #333333;
}
// #ifdef MP
input {
font-size: 30rpx;
}
// #endif
.placeholder{
font-size:28rpx;
}
.pictrue{
width: 100rpx;
height: 100rpx;
image {
width: 100%;
height: 100%;
border-radius: 16rpx;
}
}
}
}
.footer {
box-sizing: border-box;
padding: 0 20rpx;
width: 100%;
height: 112rpx;
background-color: #fff;
position: fixed;
bottom: 0;
z-index: 30;
height: calc(112rpx + constant(safe-area-inset-bottom)); ///兼容 IOS<11.2/
height: calc(112rpx + env(safe-area-inset-bottom)); ///兼容 IOS>11.2/
padding-bottom: constant(safe-area-inset-bottom); ///兼容 IOS<11.2/
padding-bottom: env(safe-area-inset-bottom); ///兼容 IOS>11.2/
width: 100%;
left: 0;
&.on {
height: 96rpx;
height: calc(96rpx + constant(safe-area-inset-bottom)); ///兼容 IOS<11.2/
height: calc(96rpx + env(safe-area-inset-bottom)); ///兼容 IOS>11.2/
.bnt{
width: 160rpx;
height: 64rpx;
font-size: 24rpx;
&.on{
background-color: $primary-admin;
color: #fff;
margin-left: 16rpx;
}
}
}
.bnt {
width: 346rpx;
height: 72rpx;
border-radius: 200rpx;
border: 1px solid $primary-admin;
color: $primary-admin;
font-size: 26rpx;
font-family: PingFang SC, PingFang SC;
font-weight: 500;
&.on{
background-color: $primary-admin;
color: #fff;
}
}
}
}
</style>