123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251 |
- <template>
- <view>
- <mescroll-body :up="upOption" 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">
- <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>
- </template>
- <script>
- 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:{},
- upOption:{
- page:{
- num : 0 ,
- size : 10 ,
- time : null
- }
- }
-
- };
- },
- onLoad() {
-
- // this.getList()
- },
- onShow() {
- this.userInfo = uni.getStorageSync("userInfo")
- this.cardTypeData.commonId=uni.getStorageSync("userInfo").id
- },
- methods: {
- mescrollInit(){
-
- },
- downCallback(){
- var that = this
- this.$nextTick(() => {
- // mescroll.endSuccess(data.result);
- that.mescroll.resetUpScroll()
- });
-
- },
- 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( )
- })
- },
- 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( )
- })
- },
-
- add(){
- // if(){
-
- // }
- this.show=true
- },
- confirm(){
- 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( )
- // }
- })
-
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- </style>
|