|
@@ -1,28 +1,26 @@
|
|
<template>
|
|
<template>
|
|
<view>
|
|
<view>
|
|
- <u-list @scrolltolower="scrolltolower">
|
|
|
|
- <u-list-item>
|
|
|
|
- 我是地址我是地址我是地址我是地址我是地址
|
|
|
|
- </u-list-item>
|
|
|
|
- <u-list-item>
|
|
|
|
- 我是地址我是地址我是地址我是地址我是地址
|
|
|
|
- </u-list-item>
|
|
|
|
- <u-list-item>
|
|
|
|
- 我是地址我是地址我是地址我是地址我是地址
|
|
|
|
- </u-list-item>
|
|
|
|
- <u-list-item>
|
|
|
|
- 我是地址我是地址我是地址我是地址我是地址
|
|
|
|
- </u-list-item>
|
|
|
|
- </u-list>
|
|
|
|
- <u-modal :show="show" title="新增分类" >
|
|
|
|
|
|
+ <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>
|
|
|
|
+ </u-list-item>
|
|
|
|
+ </u-list>
|
|
|
|
+ </mescroll-body>
|
|
|
|
+ <u-modal showCancelButton='true'
|
|
|
|
+ @confirm='$u.debounce(confirm, 500)'
|
|
|
|
+ @cancel='show=false' :show="show" title="新增分类" >
|
|
<view class="slot-content">
|
|
<view class="slot-content">
|
|
<u--input
|
|
<u--input
|
|
- v-model="model1.userInfo.sex"
|
|
|
|
|
|
+ v-model="cardTypeData.circleName"
|
|
placeholder="输入分类名称,2-8个字符"
|
|
placeholder="输入分类名称,2-8个字符"
|
|
border="none"
|
|
border="none"
|
|
- showCancelButton='true'
|
|
|
|
- @confirm='confirm'
|
|
|
|
- @cancel='show=false'
|
|
|
|
|
|
+
|
|
></u--input>
|
|
></u--input>
|
|
</view>
|
|
</view>
|
|
</u-modal>
|
|
</u-modal>
|
|
@@ -34,16 +32,171 @@
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<script>
|
|
<script>
|
|
|
|
+ import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
|
|
export default {
|
|
export default {
|
|
|
|
+ mixins: [MescrollMixin],
|
|
data() {
|
|
data() {
|
|
return {
|
|
return {
|
|
show:false,
|
|
show:false,
|
|
|
|
+ page:1,
|
|
|
|
+ limit:20,
|
|
|
|
+ cardTypeList:[],
|
|
|
|
+ cardTypeData:{},
|
|
|
|
+ userInfo:{},
|
|
};
|
|
};
|
|
},
|
|
},
|
|
|
|
+ onLoad() {
|
|
|
|
+
|
|
|
|
+ // this.getList()
|
|
|
|
+ },
|
|
|
|
+ onShow() {
|
|
|
|
+ this.userInfo = uni.getStorageSync("userInfo")
|
|
|
|
+ this.cardTypeData.commonId=uni.getStorageSync("userInfo").id
|
|
|
|
+ },
|
|
methods: {
|
|
methods: {
|
|
- del(){
|
|
|
|
|
|
+ mescrollInit(){
|
|
|
|
|
|
},
|
|
},
|
|
|
|
+ downCallback(){
|
|
|
|
+
|
|
|
|
+ },
|
|
|
|
+ upCallback(page){
|
|
|
|
+ var that = this
|
|
|
|
+ uni.showLoading({
|
|
|
|
+ title: '数据加载中'
|
|
|
|
+ })
|
|
|
|
+ this.$request.baseRequest('admin.unimall.cardClassifyInfo', 'list',{
|
|
|
|
+ page:page.num,
|
|
|
|
+ limit:page.size,
|
|
|
|
+ commonId:uni.getStorageSync("userInfo").id
|
|
|
|
+ }, failres => {
|
|
|
|
+ console.log('res+++++', failres.errmsg)
|
|
|
|
+ this.$refs.uToast.show({
|
|
|
|
+ type: 'error',
|
|
|
|
+ message: failres.errmsg,
|
|
|
|
+ })
|
|
|
|
+ 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=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){
|
|
|
|
+ uni.showLoading({
|
|
|
|
+ title: '加载中',
|
|
|
|
+ mask:true
|
|
|
|
+ })
|
|
|
|
+ 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
|
|
|
|
+ })
|
|
|
|
+ uni.hideLoading()
|
|
|
|
+ }).then(res => {
|
|
|
|
+ uni.showToast({
|
|
|
|
+ title: '删除成功',
|
|
|
|
+ icon: 'none',
|
|
|
|
+ duration: 2000
|
|
|
|
+ })
|
|
|
|
+ uni.hideLoading()
|
|
|
|
+ this.mescroll.resetUpScroll( )
|
|
|
|
+ }).catch(res => {
|
|
|
|
+ uni.showToast({
|
|
|
|
+ title: '置顶失败',
|
|
|
|
+ icon: 'none',
|
|
|
|
+ duration: 2000
|
|
|
|
+ })
|
|
|
|
+ uni.hideLoading()
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+ stick(item){
|
|
|
|
+ uni.showLoading({
|
|
|
|
+ title: '加载中',
|
|
|
|
+ mask:true
|
|
|
|
+ })
|
|
|
|
+ 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})
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ this.$request.baseRequest(type, type1,data, failres => {
|
|
|
|
+ console.log('res+++++', failres.errmsg)
|
|
|
|
+ uni.showToast({
|
|
|
|
+ title: failres.errmsg,
|
|
|
|
+ icon: 'none',
|
|
|
|
+ duration: 2000
|
|
|
|
+ })
|
|
|
|
+ uni.hideLoading()
|
|
|
|
+ }).then(res => {
|
|
|
|
+ uni.showToast({
|
|
|
|
+ title: '置顶成功',
|
|
|
|
+ icon: 'none',
|
|
|
|
+ duration: 2000
|
|
|
|
+ })
|
|
|
|
+ uni.hideLoading()
|
|
|
|
+ this.mescroll.resetUpScroll( )
|
|
|
|
+ }).catch(res => {
|
|
|
|
+ uni.showToast({
|
|
|
|
+ title: '置顶失败',
|
|
|
|
+ icon: 'none',
|
|
|
|
+ duration: 2000
|
|
|
|
+ })
|
|
|
|
+ uni.hideLoading()
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+
|
|
add(){
|
|
add(){
|
|
// if(){
|
|
// if(){
|
|
|
|
|
|
@@ -51,7 +204,44 @@
|
|
this.show=true
|
|
this.show=true
|
|
},
|
|
},
|
|
confirm(){
|
|
confirm(){
|
|
- this.show=false
|
|
|
|
|
|
+ if(!this.cardTypeData.circleName){
|
|
|
|
+ uni.showToast({
|
|
|
|
+ title: '分类名称不能为空!',
|
|
|
|
+ icon: 'none',
|
|
|
|
+ duration: 2000
|
|
|
|
+ })
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ if(this.cardTypeData.circleName<2||this.cardTypeData.circleName>8){
|
|
|
|
+ uni.showToast({
|
|
|
|
+ title: '类别名称2-8个字!',
|
|
|
|
+ icon: 'none',
|
|
|
|
+ duration: 2000
|
|
|
|
+ })
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ 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
|
|
|
|
+ })
|
|
|
|
+ uni.hideLoading()
|
|
|
|
+ }).then(res => {
|
|
|
|
+ console.log(res)
|
|
|
|
+ // if (res.errno == 200) {
|
|
|
|
+ uni.hideLoading()
|
|
|
|
+ this.show=false
|
|
|
|
+ this.cardTypeData={
|
|
|
|
+ commonId:uni.getStorageSync("userInfo").id,
|
|
|
|
+ }
|
|
|
|
+ this.mescroll.resetUpScroll( )
|
|
|
|
+ // }
|
|
|
|
+ })
|
|
|
|
+
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|