| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834 |
- <template>
- <view style="padding-bottom: 130rpx;">
- <view>
- <!-- #ifndef H5 -->
- <view style="position: fixed;top: 0;left: 0;right: 0;z-index: 9999;background: #fff;">
- <!-- #endif -->
- <!-- #ifdef H5 -->
- <view style="position: fixed;top: 44px;left: 0;right: 0;z-index: 99;background: #fff;">
- <!-- #endif -->
- <view class="bg padding-lr padding-tb-sm flex align-center">
- <u-search @change="search" v-model="goodsName" placeholder="搜索商品标题 " bg-color="#F7F7F7"
- style="width: 100%;" shape="square" :show-action="false"></u-search>
- </view>
- <view class="flex bg">
- <view v-for="(item,index) in tab" :key="index" class="flex-sub boxIndex"
- :class="tabIndex == index?'tans':''"
- :style="index==1?'text-align:center':(index==2?'text-align:right;margin-right:40rpx':'')"
- style="position: relative;padding-left: 40rpx;" @click="bindindex(index)">
- {{item.name}}
- <view :class="index==0?'tabse':(index==1?'tabse1':'tabse2')" v-show="tabIndex == index">
-
- </view>
- </view>
- </view>
- <scroll-view scroll-x="true" class="flex align-center padding-sm"
- style="height: 100rpx;width: 100%;white-space: nowrap">
- <view v-for="(item,index) in list" :key="index" class="boxs"
- :class="counts == index?'actives':''" @click="bindTabs(index,item)">{{item.classifyName}}
- </view>
- </scroll-view>
- </view>
- <!-- #ifdef H5 -->
- <view style="margin-top: 155px;" v-if="goodsList.length>0">
- <!-- #endif -->
- <!-- #ifndef H5 -->
- <view style="margin-top: 290upx;padding-bottom: 170px;" v-if="goodsList.length>0">
- <!-- #endif -->
- <u-checkbox-group class="flex justify-center flex-wrap">
- <view class="bg radius" style="width: 686rpx;margin-top: 20rpx;" v-for="(item,index) in goodsList" :key='index'>
- <view class="padding-sm" style="position: relative;">
- <u-checkbox @change="checkboxChange(item)" v-model="item.checkeds">
- </u-checkbox>
- 创建时间:{{item.createTime}}
- <span style="position: absolute;right: 20rpx;">
- <u-switch v-model="item.checked" active-color="#17cd8a" inactive-color="#eee" size="40"
- @change="changeKg(index,item)"></u-switch>
- </span>
- </view>
- <view style="width:100%;border-top: 1upx solid #E6E6E6;"></view>
- <view class="flex padding" @click="goDet(item)">
- <view>
- <image :src="item.goodsCover?item.goodsCover:'../../static/logo.png'" class="radius"
- style="width:210upx;height:170upx;"></image>
- </view>
- <view class="margin-left flex flex-direction justify-between">
- <view class="text-lg text-bold">{{item.goodsName}}</view>
- <view class="margin-tb-xs u-line-2" style="color:#999999;">
- {{item.goodsDescribe}}
- </view>
- <view style="width: 414rpx;" class="text-lg flex justify-between align-center">
- <view class="">
- <text class="text-sm">¥</text>{{item.goodsMoney}}
- </view>
- <view style="margin-right: 10rpx;">库存:{{item.inventory?item.inventory:'0'}}</view>
- </view>
- </view>
- </view>
- <view style="width: 686upx;height: 1upx;border: 1upx solid #E6E6E6;margin:0 auto;"></view>
- <view class="flex justify-between padding align-center" >
- <!-- <view>库存:{{item.inventory?item.inventory:'0'}}</view> -->
- <view class="flex align-center justify-end" style="width: 100%;">
- <view @click="goodsSort(item)" class="btn margin-right-sm">排序</view>
- <view @click="goodupdete(item)" class="btn margin-right-sm">删除</view>
- <view @click="deitor(item)" class="btn margin-right-sm">库存</view>
- <view @click="goUpdate(item)" class="btn">修改</view>
- </view>
- </view>
- </view>
- </u-checkbox-group>
- </view>
- <!-- <view class="addguige text-bold" @click="goAdd()">添加商品</view> -->
- <empty v-if="goodsList.length == 0"></empty>
- </view>
- <view class="selectcz flex align-center">
- <u-checkbox @change="checkboxChanges()" style="margin-left: 40rpx;" v-model="checkedz">全选</u-checkbox>
- <view class="addguige text-bold addguigezz" @click="selectczan">操作</view>
- <view class="addguige text-bold addguigezzs" @click="goAdd()">添加商品</view>
- </view>
- <!-- 排序 -->
- <u-popup v-model="shows3" mode="center" border-radius="14" width="500rpx" height="300rpx"
- :closeable="true">
- <view>
- <view class="padding">
- <view>排序</view>
- <view style="margin-top: 20rpx;" class="flex justify-center">
- <u-number-box :input-width="300" :input-height="60" v-model="paixu" :min="0" placeholder="请填写"></u-number-box>
- </view>
- </view>
- <view class="addguiges" @click="bindclose3()">确定</view>
- </view>
- </u-popup>
- <u-popup v-model="shows" mode="center" border-radius="14" width="500rpx" height="300rpx"
- :closeable="closeable">
- <view>
- <view class="padding">
- <view>添加库存</view>
- <view>
- <u-input v-model="typeperature" placeholder="请填写" type="number" />
- </view>
- </view>
- <view class="addguiges" @click="bindclose()">确定</view>
- </view>
- </u-popup>
- <!-- 批量修改库存 -->
- <u-popup v-model="shows2" mode="center" border-radius="14" width="500rpx" height="300rpx"
- :closeable="true">
- <view>
- <view class="padding">
- <view>修改库存</view>
- <view>
- <u-input v-model="typeperature2" placeholder="请填写" type="number" />
- </view>
- </view>
- <view class="addguiges" @click="bindclose2()">确定</view>
- </view>
- </u-popup>
- <!-- 多选操作菜单 -->
- <u-action-sheet :list="tabIndex==2?lists1:lists" @click="click" v-model="show"></u-action-sheet>
- </view>
- </template>
- <script>
- import empty from '@/components/empty.vue'
- export default {
- components: {
- empty
- },
- data() {
- return {
- goodsIds:[],
- shows3:false,
- paixu:0,
- shows2:false,
- typeperature2:'',
- checkedz:false,
- show: false,
- lists: [{
- text: '批量下架'
- }, {
- text: '修改库存'
- }, {
- text: '批量删除'
- }],
- lists1: [{
- text: '批量上架',
- }, {
- text: '修改库存'
- }, {
- text: '批量删除'
- }],
- tab: [{
- name: '出售中',
- }, {
- name: '已售完',
- }, {
- name: '已下架'
- }],
- tabIndex: 0,
- list: [{
- name: '奶茶热饮'
- }, {
- name: '鲜榨果汁'
- }, {
- name: '牛奶系列'
- }, {
- name: '超低折扣'
- }],
- counts: '',
- classifyId: '',
- page: 1,
- limit: 10,
- shopId: '',
- goodsName: '',
- goodsList: [],
- totalCount: 0,
- shows: false,
- typeperature: '',
- goodsId: '',
- checked: false,
- pageList: [],
- closeable: true
- }
- },
- onLoad(option) {
- uni.showLoading({
- title: '加载中......',
- mask: true, // 是否显示透明蒙层,防止触摸穿透
- icon: 'loading'
- })
- // this.shopId = option.shopId
- this.shopId = this.$queue.getData("shopId")
- this.getClassifyList()
- },
- onShow() {
- this.getGoodsList()
- },
- methods: {
- // 批量库存
- bindclose2(index){
- if (!this.typeperature2) {
- uni.showToast({
- title: '请填写规格数量',
- icon: 'none',
- duration: 1000
- })
- return
- }
- if(this.typeperature2<0){
- uni.showToast({
- title: '库存数量不得小于0',
- icon: 'none',
- duration: 1000
- })
- return
- }
- let data = {
- goodsIds: this.goodsIds.join(),
- inventory: this.typeperature2
- }
- let that = this
- that.shows2 = false
- uni.showModal({
- title:'提示',
- content:'确认已选中的商品批量修改库存?',
- complete:function(ret){
- if(ret.confirm){
- that.$Request.getA("/admin/goods/updateBatchInventory", data).then(res => {
- if (res.code == 0) {
- that.shows2 = false
- uni.showToast({
- title: '修改成功',
- icon: 'none'
- })
- that.typeperature2 = ''
- that.checkedz = false
- that.goodsIds = []
- that.page = 1
- that.getGoodsList()
- }
- });
- }
- }
- })
-
- },
- bindclose3(){
- let data = {
- sort:this.paixu,
- goodsId:this.goodsId
- }
- this.$Request.getA('/admin/goods/updateSort', data).then(res => {
- if(res.code==0){
- uni.showToast({
- title:'修改成功'
- })
- this.goodsId = ''
- this.shows3 = false
- this.page = 1
- this.getGoodsList();
- }else{
- uni.showModal({
- title: '提示',
- content: res.msg,
- success: function (res) {
- if (res.confirm) {
- } else if (res.cancel) {
- }
- }
- });
- }
- })
- },
- //排序
- goodsSort(item){
- if(item.sort){
- this.paixu = item.sort
- }else{
- this.paixu = 0
- }
-
- this.shows3 = true
- this.goodsId = item.goodsId
- },
- selectczan(){
- if(this.goodsIds.length==0){
- uni.showToast({
- title:'请选择商品后操作',
- icon:'none'
- })
- }else{
- this.show = true
- }
- },
- //全选
- checkboxChanges(){
- this.goodsIds = []
- if(this.checkedz==false){//全选(把总复选框选中并把goodsid赋给数组)
- this.goodsList.map(item=>{
- item.checkeds = true
- this.goodsIds.push(item.goodsId)
- })
- console.log(this.goodsList)
- }else{//全不选
- this.goodsList.map(item=>{
- item.checkeds = false
- })
- }
- },
- //批量操作
- caozuos(url,datas,data){
- let that = this
- uni.showModal({
- title:'提示',
- content:'确认'+data+'已选中的商品?',
- complete:function(ret){
- if(ret.confirm){
- that.$Request.getA(url, datas).then(res => {
- if(res.code==0){
- uni.showToast({
- title:data+'成功'
- })
- that.checkedz=false
- that.goodsIds = []
- that.page = 1
- that.getGoodsList();
- }else{
- uni.showModal({
- title: '提示',
- content: res.msg,
- success: function (res) {
- if (res.confirm) {
- } else if (res.cancel) {
- }
- }
- });
- }
- })
- }
- }
- })
-
- },
- //选择的操作
- click(e) {
- let data = this.lists[e].text
- if(this.tabIndex==2){
- if(data == '批量下架'){
- data = '批量上架'
- }
- }
- switch (data) {
- case '批量下架':
- let datas = {
- goodsIds:this.goodsIds.join(','),
- status:1
- }
- this.caozuos('/admin/goods/updateBatchStatus',datas,data)
- break;
- case '修改库存':
- this.shows2 = true
- break;
- case '批量删除':
- let datas2 = {
- goodsIds:this.goodsIds.join(','),
- }
- this.caozuos('/admin/goods/deleteBatchIds',datas2,data)
- break;
- case '批量上架':
- let datas1 = {
- goodsIds:this.goodsIds.join(','),
- status:0
- }
- this.caozuos('/admin/goods/updateBatchStatus',datas1,data)
- break;
- default:
- break;
- }
- },
- // 选中某个复选框时,由checkbox时触发
- checkboxChange(e) {
- if(this.goodsIds.indexOf(e.goodsId)==-1){//如果没有选中则把goodsid增加到数组中
- this.goodsIds.push(e.goodsId)
- }else{//如果找到了则把goodsid删除
- this.goodsIds.splice(this.goodsIds.indexOf(e.goodsId),1)
- }
- if(this.goodsIds.length==this.goodsList.length){ //判断是否全部选中
- this.checkedz = true
- }else{
- this.checkedz = false
- }
- },
- //修改商品
- goUpdate(item) {
- uni.navigateTo({
- url: '/my/publish/goods?goodsId=' + item.goodsId
- })
- },
- goAdd() {
- uni.navigateTo({
- url: '/my/publish/goods'
- })
- },
- //搜索
- search() {
- this.getGoodsList()
- },
- bindindex(index) {
- console.log(index)
- uni.showLoading({
- title: '加载中......',
- mask: true, // 是否显示透明蒙层,防止触摸穿透
- icon: 'loading'
- })
- this.page = 1
- this.tabIndex = index
- this.getGoodsList()
- },
- getGoodsList() {
- let data = {
- page: this.page,
- limit: this.limit,
- goodsName: this.goodsName,
- // shopId: this.shopId,
- classifyId: this.classifyId,
- shopId: uni.getStorageSync('shopId'),
- status: this.tabIndex == 1 ? 2 : (this.tabIndex == 2 ? 1 : this.tabIndex)
- }
- this.$Request.getA("/admin/goodsShop/selectGoodsByShopId", data).then(res => {
- if (res.code == 0) {
- uni.hideLoading()
- if (res.data.list.length > 0) {
- for (var i in res.data.list) {
- if (res.data.list[i].status == 1) {
- res.data.list[i].checked = false
- } else {
- res.data.list[i].checked = true
- }
- }
- console.log('res.data.list', res.data.list)
- if (this.page == 1) {
- this.goodsList = res.data.list
- } else {
- this.goodsList = [...this.goodsList, ...res.data.list]
- }
- this.totalCount = res.data.totalCount
- } else {
- if (this.page == 1) {
- this.goodsList = []
- } else {
- this.goodsList = this.goodsList
- }
- }
- }
- uni.stopPullDownRefresh();
- uni.hideLoading()
- });
- },
- //删除商品
- goodupdete(e) {
- console.log(e)
- let that = this
- uni.showModal({
- title: '提示',
- content: '确定要删除当前商品吗?刪除后无法恢复',
- cancelText: "取消", // 取消按钮的文字
- confirmText: "确定", // 确认按钮文字
- showCancel: true, // 是否显示取消按钮,默认为 true
- confirmColor: '#f55850',
- cancelColor: '#39B54A',
- success: (res) => {
- if (res.confirm) {
- let data = {
- shopId: uni.getStorageSync('shopId'),
- goodsId: e.goodsId,
- }
- that.$Request.postA("/admin/goodsShop/deleteGoodsByShopId", data).then(res => {
- if (res.code == 0) {
- uni.showToast({
- title: "删除成功",
- icon: 'none'
- })
- that.page = 1
- that.getGoodsList();
- } else {
- uni.showModal({
- title: '提示',
- content: res.msg,
- success: function (res) {
- if (res.confirm) {
- } else if (res.cancel) {
- }
- }
- });
- }
- });
- } else {
- }
- }
- })
- },
- // 商品类型
- getClassifyList() {
- let data={
- shopId:this.shopId
- }
- this.$Request.getA("/admin/goods/selectAllClassify",data).then(res => {
- if (res.code == 0) {
- let data = [{
- classifyName: '全部',
- classifyId: ''
- }]
- this.list = [...data, ...res.data]
- this.classifyId = this.list[0].classifyId
- this.getGoodsList()
- }
- });
- },
- //库存弹框
- bindclose(index) {
- if (!this.typeperature) {
- uni.showToast({
- title: '请填写规格数量',
- icon: 'none',
- duration: 1000
- })
- return
- }
- let data = {
- shopId: uni.getStorageSync('shopId'),
- goodsId: this.goodsId,
- inventory: this.typeperature
- }
- this.$Request.postJson("/admin/goodsShop/updateGoodsByShopId", data).then(res => {
- if (res.code == 0) {
- this.shows = false
- this.typeperature = ''
- uni.showToast({
- title: '修改成功',
- icon: 'none'
- })
- this.getGoodsList()
- }
- });
- },
- //编辑库存
- deitor(e) {
- this.shows = true
- this.goodsId = e.goodsId
- },
- add(item) {
- let that = this
- let data = [{
- goodsId: item.goodsId,
- shopId: this.shopId
- }]
- this.$Request.postJsonA("/admin/goodsShop/addGoodsByShopId", data).then(res => {
- if (res.code == 0) {
- this.page = 1
- this.getGoodsList()
- uni.showToast({
- title: '添加成功',
- icon: 'none'
- })
- this.getGoodsList()
- }
- });
- },
- goDet(e) {
- uni.navigateTo({
- url: '/my/store/goodDetail?goodsId=' + e.goodsId + "&shopId=" + this.shopId + '&type=2'
- })
- },
- bindDetail() {
- uni.navigateTo({
- url: './goodDetail'
- })
- },
- bindTabs(index, e) {
- console.log(e)
- uni.showLoading({
- title: '加载中......',
- mask: true, // 是否显示透明蒙层,防止触摸穿透
- icon: 'loading'
- })
- this.counts = index
- this.classifyId = e.classifyId
- this.page = 1
- this.getGoodsList()
- },
- bindAddgood() {
- uni.navigateTo({
- url: './addgood'
- })
- },
- // 上下架商品
- changeKg(index, row) {
- console.log(row.status)
- var datas = {}
- datas.goodsIds = row.goodsId
- if (row.status == 0) {
- datas.status = 1
- }
- if (row.status == 1) {
- datas.status = 0
- }
- // datas.status = row.status
- // this.$Request.postJsonA("/admin/goods/update", datas).then(res => {
- this.$Request.getT("/admin/goods/updateBatchStatus", datas).then(res => {
- if (res.code == 0) {
- this.page = 1
- uni.showToast({
- title: '操作成功',
- icon: 'none'
- })
- this.getGoodsList()
- }
- });
- }
- },
- onReachBottom: function() {
- this.page = this.page + 1;
- this.getGoodsList();
- if (this.totalCount == this.goodsList.length) {
- uni.showToast({
- title: '已经到底了~',
- icon: 'none'
- })
- }
- },
- onPullDownRefresh: function() {
- this.page = 1;
- this.getGoodsList();
- },
- }
- </script>
- <style lang="scss" scoped>
- page {
- background: #EDF1F7;
- }
- .selectcz {
- width: 100%;
- background-color: #FFFFFF;
- position: fixed;
- bottom: 0upx;
- left: 0;
- right: 0;
- z-index: 9;
- }
-
- .tabse {
- width: 50rpx;
- height: 10rpx;
- background-color: #FCD202;
- position: absolute;
- bottom: 0;
- left: 45%;
- transform: translate(-100%, -100%);
- }
-
- .tabse1 {
- width: 50rpx;
- height: 10rpx;
- background-color: #FCD202;
- position: absolute;
- bottom: 0;
- left: 70%;
- transform: translate(-100%, -100%);
- }
-
- .tabse2 {
- width: 50rpx;
- height: 10rpx;
- background-color: #FCD202;
- position: absolute;
- bottom: 0;
- left: 95%;
- transform: translate(-100%, -100%);
- }
- .bg {
- background: #FFFFFF;
- }
- .boxs {
- // width: 150upx;
- height: 55upx;
- // border: 2upx solid #CCCCCC;
- border-radius: 28upx;
- text-align: center;
- line-height: 55upx;
- color: #999999;
- margin-right: 30rpx;
- display: inline-block;
- }
- .actives {
- // width: 150upx;
- height: 55upx;
- border: 2upx solid #FFCC00;
- border-radius: 28upx;
- text-align: center;
- line-height: 55upx;
- color: #000000;
- margin-right: 30rpx;
- }
- .btn {
- width: 120upx;
- height: 64upx;
- border: 2upx solid #999999;
- border-radius: 8upx;
- text-align: center;
- line-height: 64rpx;
- color: #000000;
- }
- .box {
- width: 131upx;
- height: 45rpx;
- background: #FFEAF0;
- border-radius: 4upx;
- text-align: center;
- line-height: 45rpx;
- font-size: 24upx;
- font-weight: 500;
- color: #FE215B;
- }
- .page-box {
- position: relative;
- // left: 0;
- height: 100vh;
- z-index: 0;
- top: -20px;
- }
- .centre {
- position: absolute;
- left: 0;
- top: 0;
- right: 0;
- bottom: 0;
- margin: auto;
- height: 400rpx;
- text-align: center;
- // padding: 200rpx auto;
- font-size: 32rpx;
- image {
- width: 387rpx;
- height: 341rpx;
- // margin-bottom: 20rpx;
- margin: 0 auto 20rpx;
- // border: 1px dotted #000000;
- }
- .tips {
- font-size: 32rpx;
- color: #2F3044;
- margin-top: 20rpx;
- font-weight: 700;
- }
- .btn {
- margin: 80rpx auto;
- width: 600rpx;
- border-radius: 32rpx;
- line-height: 90rpx;
- color: #ffffff;
- font-size: 34rpx;
- background: #5074FF;
- }
- }
- .boxIndex {
- height: 78upx;
- line-height: 78upx;
- }
- .tans {
- background: #fff;
- }
- .addguige {
- width: 38%;
- color: #ffffff;
- text-align: center;
- height: 88upx;
- line-height: 88upx;
- }
- .addguigezz{
- border-radius: 16upx 0 0 0;
- background-color: #999999;
- box-shadow: 0px 10upx 20upx 0px #999999;
- }
- .addguigezzs{
- border-radius: 0 16upx 0 0;
- background: #FCD202;
- box-shadow: 0px 10upx 20upx 0px #FCD202;
- }
- .addguiges {
- width: 90%;
- margin: 0 auto;
- background: #FCD202;
- box-shadow: 0px 10upx 20upx 0px #FFD9B3;
- border-radius: 16upx;
- text-align: center;
- height: 88upx;
- line-height: 88upx;
- /* position: fixed;
- bottom: 25upx;
- left: 0;
- right: 0; */
- }
- </style>
|