|
@@ -1,86 +1,63 @@
|
|
|
<template>
|
|
|
- <view>
|
|
|
- <mescroll-body ref="mescrollRef" @init="mescrollInit" @up="upCallback" @down="downCallback">
|
|
|
- <u-list @scrolltolower="scrolltolower">
|
|
|
- <u-list-item v-for='item in cardTypeList'>
|
|
|
- <view class='flex'>
|
|
|
- {{item.name}}
|
|
|
- {{item.circleName}}
|
|
|
- <u-icon v-if='item.circleName!="默认分类"' @click="del(item)" name="trash-fill" color="#2979ff" size="28"></u-icon>
|
|
|
- <u-icon @click="stick(item)" name="pushpin" color="#2979ff" size="28"></u-icon>
|
|
|
+ <view class="content">
|
|
|
+ <view class="content1">
|
|
|
+ <view v-for='item in cardTypeList'>
|
|
|
+ <view class='flex row flex-between'>
|
|
|
+ <view class="left flex">
|
|
|
+ <view class="f-text flex flex-all-center">{{item.circleName[0]}}</view>
|
|
|
+ <view class="text">{{item.circleName}}</view>
|
|
|
</view>
|
|
|
- </u-list-item>
|
|
|
- </u-list>
|
|
|
- </mescroll-body>
|
|
|
- <u-modal showCancelButton='true'
|
|
|
- @confirm='$u.debounce(confirm, 500)'
|
|
|
- @cancel='show=false' :show="show" title="新增分类" >
|
|
|
+ <view class="right">
|
|
|
+ <image src="../../static/imgs/mySet/del.png" class="img" mode="widthFix"
|
|
|
+ v-if='item.circleName!="默认分类"' @click="del(item)"></image>
|
|
|
+ <image src="../../static/imgs/mySet/zd.png" class="img" mode="widthFix" @click="stick(item)">
|
|
|
+ </image>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ <u-modal showCancelButton='true' @confirm='$u.debounce(confirm, 500)' @cancel='show=false' :show="show"
|
|
|
+ title="新增分类" confirmColor="#112253">
|
|
|
<view class="slot-content">
|
|
|
- <u--input
|
|
|
- v-model="cardTypeData.circleName"
|
|
|
- placeholder="输入分类名称,2-8个字符"
|
|
|
- border="none"
|
|
|
-
|
|
|
- ></u--input>
|
|
|
+ <u--input v-model="cardTypeData.circleName" placeholder="输入分类名称,2-8个字符" border="none"></u--input>
|
|
|
</view>
|
|
|
</u-modal>
|
|
|
|
|
|
- <view class="footer">
|
|
|
- <view @click='add' class='button'>新增</view>
|
|
|
- </view>
|
|
|
+ <view @click='add' class='button'>新增</view>
|
|
|
+ <u-toast ref="uToast"></u-toast>
|
|
|
</view>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
+ var that;
|
|
|
import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
|
|
|
export default {
|
|
|
mixins: [MescrollMixin],
|
|
|
data() {
|
|
|
return {
|
|
|
- show:false,
|
|
|
- page:1,
|
|
|
- limit:20,
|
|
|
- cardTypeList:[],
|
|
|
- cardTypeData:{},
|
|
|
- userInfo:{},
|
|
|
- canReset:false,
|
|
|
-
|
|
|
+ show: false,
|
|
|
+ cardTypeList: [],
|
|
|
+ cardTypeData: {},
|
|
|
+ userInfo: {},
|
|
|
+ canReset: false,
|
|
|
+
|
|
|
};
|
|
|
},
|
|
|
onLoad() {
|
|
|
-
|
|
|
- // this.getList()
|
|
|
+ that = this
|
|
|
},
|
|
|
onShow() {
|
|
|
this.userInfo = uni.getStorageSync("userInfo")
|
|
|
- this.cardTypeData.commonId=uni.getStorageSync("userInfo").id
|
|
|
- this.$nextTick(function() {
|
|
|
- this.canReset && this.mescroll.resetUpScroll() // 重置列表数据为第一页
|
|
|
- this.canReset && this.mescroll.scrollTo(0, 0) // 重置列表数据为第一页时,建议把滚动条也重置到顶部,避免无法再次翻页的问题
|
|
|
- this.canReset = true // 过滤第一次的onShow事件,避免初始化界面时重复触发upCallback, 无需配置auto:false
|
|
|
- });
|
|
|
+ this.cardTypeData.commonId = uni.getStorageSync("userInfo").id
|
|
|
+ this.getList()
|
|
|
},
|
|
|
methods: {
|
|
|
- mescrollInit(){
|
|
|
-
|
|
|
- },
|
|
|
- downCallback(){
|
|
|
- var that = this
|
|
|
- this.$nextTick(() => {
|
|
|
- // mescroll.endSuccess(data.result);
|
|
|
- that.mescroll.resetUpScroll()
|
|
|
- });
|
|
|
-
|
|
|
- },
|
|
|
- upCallback(page){
|
|
|
- var that = this
|
|
|
+ getList() {
|
|
|
uni.showLoading({
|
|
|
- title: '数据加载中'
|
|
|
- })
|
|
|
- this.$request.baseRequest('admin.unimall.cardClassifyInfo', 'list',{
|
|
|
- page:page.num,
|
|
|
- limit:page.size,
|
|
|
- commonId:uni.getStorageSync("userInfo").id
|
|
|
+ title: '数据加载中'
|
|
|
+ })
|
|
|
+ this.$request.baseRequest('admin.unimall.cardClassifyInfo', 'list', {
|
|
|
+ commonId: uni.getStorageSync("userInfo").id
|
|
|
}, failres => {
|
|
|
console.log('res+++++', failres.errmsg)
|
|
|
this.$refs.uToast.show({
|
|
@@ -89,162 +66,182 @@
|
|
|
})
|
|
|
uni.hideLoading()
|
|
|
}).then(res => {
|
|
|
- console.log(res)
|
|
|
- if(page.num == 1) this.cardTypeList = [];
|
|
|
- let curPageLen = res.data.items.length;
|
|
|
- let totalPage = res.data.total;
|
|
|
- if(res.data.items.length>0){
|
|
|
- for(var i=0;i<res.data.items.length;i++){
|
|
|
- res.data.items[i].name=res.data.items[i].circleName[0]
|
|
|
- }
|
|
|
- var itemIndex=res.data.items.findIndex((item)=>{return item.topMarking==1})
|
|
|
- // console.log(itemIndex)
|
|
|
- if(itemIndex!=-1){
|
|
|
- var data=res.data.items.splice(itemIndex,1)
|
|
|
- if(page.num==1){
|
|
|
- data.push({circleName:'默认分类',name:'默'})
|
|
|
- }
|
|
|
- // console.log(data.concat(res.data.items))
|
|
|
- res.data.items=data.concat(res.data.items)
|
|
|
- }else{
|
|
|
- if(page.num==1){
|
|
|
- res.data.items=[{circleName:'默认分类',name:'默'}].concat(res.data.items)
|
|
|
+ this.cardTypeList = res.data.items
|
|
|
+ uni.hideLoading()
|
|
|
+ for (let i = 0; i < this.cardTypeList.length; i++) {
|
|
|
+ if (this.cardTypeList[i].topMarking == 0) {
|
|
|
+ if (i == 0) {
|
|
|
+ this.cardTypeList.unshift({
|
|
|
+ circleName: '默认分类',
|
|
|
+ name: '默'
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ this.cardTypeList.splice(i, 0, {
|
|
|
+ circleName: '默认分类',
|
|
|
+ name: '默'
|
|
|
+ })
|
|
|
}
|
|
|
+ return
|
|
|
}
|
|
|
- this.cardTypeList=this.cardTypeList.concat(res.data.items)
|
|
|
- }else{
|
|
|
- if(page.num==1){
|
|
|
- this.cardTypeList=[{circleName:'默认分类',name:'默'}]
|
|
|
- }
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
- this.$nextTick(() => {
|
|
|
- console.log(that)
|
|
|
- // mescroll.endSuccess(data.result);
|
|
|
- that.mescroll.endBySize(curPageLen, totalPage)
|
|
|
- });
|
|
|
-
|
|
|
- // if (res.errno == 200) {
|
|
|
- uni.hideLoading()
|
|
|
-
|
|
|
- // }
|
|
|
})
|
|
|
},
|
|
|
- del(item){
|
|
|
+ del(item) {
|
|
|
uni.showLoading({
|
|
|
title: '加载中',
|
|
|
- mask:true
|
|
|
+ mask: true
|
|
|
})
|
|
|
- this.$request.baseRequest('admin.unimall.cardClassifyInfo', 'delete',{
|
|
|
- commonId:uni.getStorageSync("userInfo").id,
|
|
|
- id:item.id
|
|
|
+ this.$request.baseRequest('admin.unimall.cardClassifyInfo', 'delete', {
|
|
|
+ commonId: uni.getStorageSync("userInfo").id,
|
|
|
+ id: item.id
|
|
|
}, failres => {
|
|
|
console.log('res+++++', failres.errmsg)
|
|
|
uni.showToast({
|
|
|
- title: failres.errmsg,
|
|
|
- icon: 'none',
|
|
|
- duration: 2000
|
|
|
+ title: failres.errmsg,
|
|
|
+ icon: 'none',
|
|
|
+ duration: 2000
|
|
|
})
|
|
|
uni.hideLoading()
|
|
|
}).then(res => {
|
|
|
- uni.showToast({
|
|
|
- title: '删除成功',
|
|
|
- icon: 'none',
|
|
|
- duration: 2000
|
|
|
- })
|
|
|
uni.hideLoading()
|
|
|
- this.mescroll.resetUpScroll( )
|
|
|
+ this.$refs.uToast.show({
|
|
|
+ type: 'success',
|
|
|
+ message: '删除成功!',
|
|
|
+ complete() {
|
|
|
+ that.getList()
|
|
|
+ }
|
|
|
+ })
|
|
|
})
|
|
|
},
|
|
|
- stick(item){
|
|
|
+ stick(item) {
|
|
|
uni.showLoading({
|
|
|
title: '加载中',
|
|
|
- mask:true
|
|
|
+ mask: true
|
|
|
})
|
|
|
- var type='',type1='',data={}
|
|
|
- if(item.id){
|
|
|
- type='admin.unimall.cardClassifyInfo'
|
|
|
- type1='top'
|
|
|
- data={
|
|
|
- cardClassifyInfo:JSON.stringify({id:item.id})
|
|
|
+ var type = '',
|
|
|
+ type1 = '',
|
|
|
+ data = {}
|
|
|
+ if (item.id) {
|
|
|
+ type = 'admin.unimall.cardClassifyInfo'
|
|
|
+ type1 = 'top'
|
|
|
+ data = {
|
|
|
+ cardClassifyInfo: JSON.stringify({
|
|
|
+ id: item.id
|
|
|
+ })
|
|
|
}
|
|
|
- }else{
|
|
|
- type='admin.unimall.cardClassifyInfo'
|
|
|
- type1='topDefault'
|
|
|
- data={
|
|
|
- cardClassifyInfo:JSON.stringify({commonId:this.cardTypeData.commonId})
|
|
|
+ } else {
|
|
|
+ type = 'admin.unimall.cardClassifyInfo'
|
|
|
+ type1 = 'topDefault'
|
|
|
+ data = {
|
|
|
+ cardClassifyInfo: JSON.stringify({
|
|
|
+ commonId: this.cardTypeData.commonId
|
|
|
+ })
|
|
|
}
|
|
|
}
|
|
|
- this.$request.baseRequest(type, type1,data, failres => {
|
|
|
+ this.$request.baseRequest(type, type1, data, failres => {
|
|
|
console.log('res+++++', failres.errmsg)
|
|
|
uni.showToast({
|
|
|
- title: failres.errmsg,
|
|
|
- icon: 'none',
|
|
|
- duration: 2000
|
|
|
+ title: failres.errmsg,
|
|
|
+ icon: 'none',
|
|
|
+ duration: 2000
|
|
|
})
|
|
|
uni.hideLoading()
|
|
|
}).then(res => {
|
|
|
- uni.showToast({
|
|
|
- title: '置顶成功',
|
|
|
- icon: 'none',
|
|
|
- duration: 2000
|
|
|
- })
|
|
|
uni.hideLoading()
|
|
|
- this.mescroll.resetUpScroll( )
|
|
|
+ this.$refs.uToast.show({
|
|
|
+ type: 'success',
|
|
|
+ message: '置顶成功!',
|
|
|
+ complete() {
|
|
|
+ that.getList()
|
|
|
+ }
|
|
|
+ })
|
|
|
})
|
|
|
},
|
|
|
-
|
|
|
- add(){
|
|
|
- // if(){
|
|
|
-
|
|
|
- // }
|
|
|
- this.show=true
|
|
|
+
|
|
|
+ add() {
|
|
|
+ this.show = true
|
|
|
},
|
|
|
- confirm(){
|
|
|
- if(!this.cardTypeData.circleName){
|
|
|
+ confirm() {
|
|
|
+ if (!this.cardTypeData.circleName) {
|
|
|
uni.showToast({
|
|
|
- title: '分类名称不能为空!',
|
|
|
- icon: 'none',
|
|
|
- duration: 2000
|
|
|
+ title: '分类名称不能为空!',
|
|
|
+ icon: 'none',
|
|
|
+ duration: 2000
|
|
|
})
|
|
|
return
|
|
|
}
|
|
|
- if(this.cardTypeData.circleName<2||this.cardTypeData.circleName>8){
|
|
|
+ if (this.cardTypeData.circleName < 2 || this.cardTypeData.circleName > 8) {
|
|
|
uni.showToast({
|
|
|
- title: '类别名称2-8个字!',
|
|
|
- icon: 'none',
|
|
|
- duration: 2000
|
|
|
+ title: '类别名称2-8个字!',
|
|
|
+ icon: 'none',
|
|
|
+ duration: 2000
|
|
|
})
|
|
|
return
|
|
|
}
|
|
|
- this.$request.baseRequest('admin.unimall.cardClassifyInfo', 'add',{
|
|
|
- cardClassifyInfo:JSON.stringify(this.cardTypeData)
|
|
|
- }, failres => {
|
|
|
+ this.$request.baseRequest('admin.unimall.cardClassifyInfo', 'add', {
|
|
|
+ cardClassifyInfo: JSON.stringify(this.cardTypeData)
|
|
|
+ }, failres => {
|
|
|
console.log('res+++++', failres.errmsg)
|
|
|
- uni.showToast({
|
|
|
- title: failres.errmsg,
|
|
|
- icon: 'none',
|
|
|
- duration: 2000
|
|
|
+ this.$refs.uToast.show({
|
|
|
+ type: 'error',
|
|
|
+ message: failres.errmsg,
|
|
|
})
|
|
|
uni.hideLoading()
|
|
|
}).then(res => {
|
|
|
- console.log(res)
|
|
|
- // if (res.errno == 200) {
|
|
|
uni.hideLoading()
|
|
|
- this.show=false
|
|
|
- this.cardTypeData={
|
|
|
- commonId:uni.getStorageSync("userInfo").id,
|
|
|
+ this.show = false
|
|
|
+ this.cardTypeData = {
|
|
|
+ commonId: uni.getStorageSync("userInfo").id,
|
|
|
}
|
|
|
- this.mescroll.resetUpScroll( )
|
|
|
- // }
|
|
|
+ this.$refs.uToast.show({
|
|
|
+ type: 'success',
|
|
|
+ message: '操作成功',
|
|
|
+ complete() {
|
|
|
+ that.getList()
|
|
|
+ }
|
|
|
+
|
|
|
+ })
|
|
|
})
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
+ .content1 {
|
|
|
+ .row {
|
|
|
+ margin: 20rpx 20rpx 0 20rpx;
|
|
|
+ background-color: #fff;
|
|
|
+ padding: 20rpx;
|
|
|
+ border-radius: 20rpx;
|
|
|
+
|
|
|
+ .f-text {
|
|
|
+ width: 58rpx;
|
|
|
+ height: 58rpx;
|
|
|
+ background-color: #112253;
|
|
|
+ border-radius: 50%;
|
|
|
+ color: #fff;
|
|
|
+ margin-right: 20rpx;
|
|
|
+ font-size: 32rpx;
|
|
|
+ }
|
|
|
|
|
|
-</style>
|
|
|
+ .img {
|
|
|
+ width: 48rpx;
|
|
|
+ margin-left: 20rpx;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ .button {
|
|
|
+ position: fixed;
|
|
|
+ bottom: 108rpx;
|
|
|
+ width: calc(100% - 40rpx);
|
|
|
+ padding: 24rpx 0;
|
|
|
+ color: #fff;
|
|
|
+ background-color: #112253;
|
|
|
+ text-align: center;
|
|
|
+ margin: 0 20rpx;
|
|
|
+ border-radius: 20rpx;
|
|
|
+ }
|
|
|
+</style>
|