소스 검색

商品管理需求添加,新增,编辑,角色管理完成

ltx529596 4 년 전
부모
커밋
4140e17fc7

+ 245 - 0
src/components/DLHTX-select_tree/select-tree.vue

@@ -0,0 +1,245 @@
+<template>
+    <view id="section_ul" class="selectTrees">
+        <!-- 一级分支 -->
+        <view class="lv1list" v-for="(item, index) in value" :key="index">
+            <view class="tree-one">
+                <!-- 单选框组件 -->
+                <checkbox-group v-if="showCheck"
+                    style="position: absolute;height: 80rpx;line-height: 80rpx; left:20rpx;z-index: 1;">
+                    <checkbox :checked="item.checked" @click="_chooseAll(item,index)" />
+                </checkbox-group>
+                <!-- 名字和iconfont -->
+                <label
+                    style="height:80rpx;display: flex;align-items: center;padding: 20rpx;position: relative;border-bottom: 1px solid #e4e4e4;background: #f3f3f3;"
+                    @click="_showlv2(index)">
+                    <view class="itemT">{{item.name}}</view>
+                    <view class="deleteBtn" v-if="showDelete" @click.stop="deleteItem(item)">删除</view>
+                    <i class="iconfont iconshang" v-if="item.show"
+                        style="position: absolute;top: 18%;right: 2%;font-size: 48rpx;"></i>
+                    <i class="iconfont iconxiala" v-else
+                        style="position: absolute;top: 18%;right: 2%;font-size: 48rpx;"></i>
+                </label>
+            </view>
+            <!-- 二级分支 -->
+            <view v-if='item.show && item.childrenList '>
+                <view class="tree-two" v-for="(item2, index2) in item.childrenList" :key="index2"
+                    style="display: flex;">
+                    <view class="aui-list-item-inner flexIn">
+                        <checkbox-group v-if="showCheck">
+                            <checkbox v-if="!disableLv2Check" :checked="item2.checked"
+                                @click="_chooseOne(index,index2)" />
+                            <checkbox :checked="item2.checked" disabled="true" v-else />
+                        </checkbox-group>
+                        <label style="font-size: 28rpx;">{{item2.name}}</label>
+                    </view>
+                </view>
+            </view>
+        </view>
+    </view>
+</template>
+
+<script>
+export default {
+    name: "select-tree",
+    data() {
+        return {
+            finalList: [],
+            menuKey: 1,
+            selectList: this.value
+        };
+    },
+    props: {
+        // selectList,
+        value: {
+            type: Array,
+            default:[]
+        },
+        showCheck: {
+            //显示多选框
+            type: Boolean,
+            default: true
+        },
+        disableLv2Check: {
+            //让二级标题不可选中
+            type: Boolean,
+            default: false
+        },
+        showDelete: {
+            //显示删除按钮
+            type: Boolean,
+            default: false
+        }
+    },
+    mounted() {
+        // console.log(this.value)
+        // setTimeout(()=>{
+        //      this.selectList = this.value
+        // })
+
+        // this.$forceUpdate()
+    },
+    methods: {
+        _showlv2(index) {
+            console.log('showLv2............................', index)
+            //展开二级目录
+            if (this.selectList[index].show) {
+                this.$set(this.selectList[index], "show", false);
+                this.$emit('input', this.selectList)
+            } else {
+                this.$set(this.selectList[index], "show", true);
+                this.$emit('input', this.selectList)
+            }
+        },
+        _chooseAll(item, index) {
+            //选中一级目录的所有
+            if (this.selectList[index].checked) {
+                //
+                this.$set(this.selectList[index], "checked", false);
+                this.selectList[index].childrenList.forEach(item => {
+                    item.checked = false;
+                });
+                this.$emit('input', this.selectList)
+            } else {
+                this.$set(this.selectList[index], "checked", true);
+                this.selectList[index].childrenList.forEach(item => {
+                    item.checked = true;
+                });
+                this.$emit('input', this.selectList)
+            }
+            this.$set(this.selectList[index], "show", true);
+            this.$emit('input', this.selectList)
+            this.$forceUpdate();
+            this._computedFinalList();
+        },
+        _chooseOne(i1, i2) {
+            if (this.selectList[i1].childrenList[i2].checked) {
+                //去掉勾选
+                this.$set(this.selectList[i1], "checked", false);
+                this.$set(this.selectList[i1].childrenList[i2], "checked", false);
+                this.$forceUpdate();
+                this.$emit('input', this.selectList)
+                this._computedFinalList();
+
+            } else {
+                //增加勾选
+                this.$set(this.selectList[i1], "checked", false);
+                this.$set(this.selectList[i1].childrenList[i2], "checked", true);
+                if (
+                    this.selectList[i1].childrenList.every(item => item.checked == true)
+                ) {
+                    //判断是否全部都是选中
+                    this.$set(this.selectList[i1], "checked", true);
+                }
+                this.$emit('input', this.selectList)
+                this.$forceUpdate();
+                this._computedFinalList();
+            }
+        },
+        _computedFinalList() {
+            //计算最终的值
+            this.finalList = [];
+            this.selectList.forEach(item => {
+                if (item.childrenList) {
+                    item.childrenList.forEach(item2 => {
+                        if (item2.checked) {
+                            this.finalList.push({
+                                lv1_value: { ...item },
+                                lv2_value: { ...item2 }
+                            });
+                        }
+                    });
+                }
+            });
+            this.$emit("choose", this.finalList);
+        },
+        chooseAll() {
+            //选中页面所有层级
+            this.selectList.forEach(item => {
+                this.$set(item, "checked", true);
+                item.childrenList.forEach(item2 => {
+                    this.$set(item2, "checked", true);
+                });
+            });
+            this.$emit('input', this.selectList)
+            this.$forceUpdate();
+            this._computedFinalList();
+        },
+        cancelAll() {
+            //取消选中页面所有层级
+            this.selectList.forEach(item => {
+                this.$set(item, "checked", false);
+                item.childrenList.forEach(item2 => {
+                    this.$set(item2, "checked", false);
+                });
+            });
+            this.$emit('input', this.selectList)
+            this.$forceUpdate();
+            this._computedFinalList();
+        },
+        deleteItem(item) {
+            //删除选中项目
+            this.$emit('input', this.selectList)
+            this.$emit("deleteItem", item);
+        }
+    },
+    watch: {
+        value(res) {
+            console.log(res)
+            this.selectList = res
+            this.$emit('input', this.selectList)
+        }
+    },
+};
+</script>
+
+<style lang="scss" scoped>
+* {
+    font-size: 32rpx;
+}
+
+/* #ifdef APP-PLUS*/
+.selectTrees{
+    margin-bottom: 180rpx;
+}
+/* #endif */
+
+.deleteBtn {
+    position: absolute;
+    right: 10%;
+    background: #f97979;
+    padding: 2rpx 16rpx;
+    color: white;
+    border-radius: 4rpx;
+    font-size: 28rpx;
+}
+
+.itemT {
+    margin-left: 60rpx;
+    font-size: 32rpx;
+    width: 65%;
+    text-overflow: -o-ellipsis-lastline;
+    overflow: hidden;
+    text-overflow: ellipsis;
+    display: -webkit-box;
+    -webkit-line-clamp: 2;
+    line-clamp: 2;
+    -webkit-box-orient: vertical;
+}
+
+.tree-two {
+    padding: 20rpx 68rpx;
+    background: white;
+    border-bottom: 2rpx solid #e2e2e2;
+    font-size: 28rpx;
+}
+
+.flexIn {
+    display: flex;
+    flex-direction: row;
+    justify-content: flex-start;
+    align-items: center;
+    align-content: center;
+    flex-wrap: nowrap;
+    width: 100%;
+}
+</style>

+ 2 - 2
src/config/index.config.js

@@ -2,8 +2,8 @@ const CONFIG = {
     //开发环境配置
     development: {
         assetsPath: '/static', // 静态资源路径
-        // baseUrl: 'http://tyou.xiudo.cn/merch',  // 后台接口请求地址
-        baseUrl: 'http://192.168.100.135:83/merch',  // 后台接口请求地址
+        baseUrl: 'http://tyou.xiudo.cn/merch',  // 后台接口请求地址
+        // baseUrl: 'http://192.168.100.135:83/merch',  // 后台接口请求地址
         hostUrl: 'http://localhost:8080',        // H5地址(前端运行地址)
         websocketUrl: '',        // websocket服务端地址
         weixinAppId: '', // 微信公众号appid

+ 24 - 0
src/demo.vue

@@ -0,0 +1,24 @@
+<template>
+    <div>
+        <select-tree @choose='choose' v-model='selectList'></select-tree>
+    </div>
+</template>
+
+<script>
+import selectTree from '@/components/DLHTX-select_tree/DLHTX-select_tree'
+    export default {
+        components: {
+            selectTree,
+        },
+        methods: {
+            choose(e){
+                console.log(e)
+            }
+        },
+    }
+
+</script>
+
+<style lang="scss" scoped>
+
+</style>

+ 80 - 99
src/pages/components/mask.vue

@@ -15,21 +15,20 @@
         <view class="content-warp">
           <view class="message">
             <view class="radiolist">
-
               <view class="checked-box-warp">
                 <view class="father-warp">
-                  <view class="father-item" v-for="fatheritem in list" :key='fatheritem.menuId'>
+                  <view class="father-item" v-for="fatheritem in menuList" :key='fatheritem.id'>
 
-                    <view class="fatherbar" @tap.stop='chechedFather(fatheritem.menuId)'>
-                      <view class="icon active" v-if="hasList.includes(fatheritem.menuId)"></view>
+                    <view class="fatherbar" @tap.stop='chechedFather(fatheritem.id, fatheritem.children)'>
+                      <view class="icon active" v-if="hasMenuList.includes(fatheritem.id)"></view>
                       <view class="icon" v-else></view>
                       <view class="title">{{ fatheritem.name }}</view>
                     </view>
 
                     <view class="son-warp">
-                      <view class="son-item" v-for="sonitem in fatheritem.children" :key="sonitem.menuId">
-                        <view class="sonerbar" @tap.stop='chechedSon(sonitem.menuId)'>
-                          <view class="icon active" v-if="hasList.includes(sonitem.menuId)"></view>
+                      <view class="son-item" v-for="sonitem in fatheritem.children" :key="sonitem.id">
+                        <view class="sonerbar" @tap.stop='chechedSon(sonitem.id,fatheritem)'>
+                          <view class="icon active" v-if="hasMenuList.includes(sonitem.id)"></view>
                           <view class="icon" v-else></view>
                           <view class="title">{{ sonitem.name }}</view>
                         </view>
@@ -38,36 +37,6 @@
                   </view>
                 </view>
               </view>
-               
-              <!-- <view class="uni-list father-list">
-
-                <checkbox-group @change="fatherChange">
-                  <label class="uni-list-cell uni-list-cell-pd checked-bar" v-for="fatheritem in list" :key="fatheritem.menuId">
-                    <view class="main-checked-list">
-                      <checkbox :value="fatheritem.menuId" :checked="hasList.includes(fatheritem.menuId)"/>
-                      <view class="title">{{ fatheritem.name }}</view>
-                    </view>
-
-                      <view class="childemenu">
-                        <view class="uni-list son-list">
-                          <checkbox-group @change="sonChange" class="son-checked-warp">
-                            <label class="uni-list-cell uni-list-cell-pd son-bar" v-for="sonitem in fatheritem.children" :key="sonitem.value">
-                              <view class="son-checked-list">
-                                <checkbox style="transform:scale(0.7)" :value="sonitem.menuId" :checked="hasList.includes(sonitem.menuId)"/>
-                                <view class="son-title">{{sonitem.name}}</view>
-                              </view>
-                            </label>
-                          </checkbox-group>
-                        </view>
-                      </view>
-
-                    <image v-if="!item.checked && item.children" class="moreicon" src="../../static/images/moreicon.png"></image>
-                    <image v-if="item.checked && item.children" class="downicon"  src="../../static/images/downmoreicon.png"></image>
-                  </label>
-                </checkbox-group>
-                
-                
-              </view> -->
              
             </view>
           </view>
@@ -77,6 +46,9 @@
         </view>
       </view>
     </view>
+
+		<rf-loading v-if="!menuList"></rf-loading>
+
   </view>
 </template>
 
@@ -84,89 +56,98 @@
 import editclassifyVue from '../goods/editclassify.vue';
 export default {
   name: 'mask',
-  props: {
-    list:{
-      type:Array,
-      default: [],
-    },
-    hasList: {
-      type:Array,
-      default: []
-    }
-  },
   data () {
     //这里存放数据
     return {
-      roleArray: [],
-      fatherIndex: -1,
-      sonIndex: -1
+      menuList: uni.getStorageSync('menuList') ,
+      hasMenuList: uni.getStorageSync('hasMenuList') || []
     }
   },
   //方法集合
   methods: {
+    // 确认
     sureconver () {
       this.$emit('isSureConver', true)
     },
+    // 关闭
     closeMask () {
       this.$emit('isSureConver', false)
     },
-    getArrayIndex(arr, obj) {
-      let i = arr.length;
-      while (i--) {
-        if (arr[i] === obj) {
-          return i;
+    // 父级权限
+    chechedFather (num,children) {
+      let fatherArr = [num]
+      let childrenArr = []
+      children.forEach(element => {
+        if (element.id) {
+          childrenArr.push(element.id)
         }
-      }
-      return -1;
-    },
-    chechedFather (num) {
-      this.roleDeal(this.hasList,num)
-    },
-    chechedSon (num) {
-     this.roleDeal(this.hasList,num)
-    },
-    // 权限操作
-    roleDeal (arr,value) {
-      if (arr.includes(value)) {
-        let index = arr.length
+      });
+      if (this.hasMenuList.includes(num)) {
+        let index = this.hasMenuList.length
+        let sonindex = childrenArr.length
         while (index --) {
           // 得到下标后删除
-          if (this.hasList[index] === value) return this.hasList.splice(index,1)
+          if (this.hasMenuList[index] === num) {
+            this.hasMenuList.splice(index,1)
+          }
+          for (let i = 0; i < childrenArr.length; i++) {
+            if (this.hasMenuList[index] === childrenArr[i]) {
+             this.hasMenuList.splice(index,1)
+            }
+          }
         }
       } else {
-        arr.push(value)
+        this.hasMenuList = this.hasMenuList.concat(fatherArr,childrenArr)
       }
-    }
-
-    // 父级权限选择
-    // fatherChange (e) {
-    //   debugger
-    //   console.log(e);
-    //   let items = this.list
-    //   for (let i = 0; i < items.length; ++i) {
-    //     const element = items[i]
-    //     if (e.detail.value.includes(element.menuId)) { 
-    //       this.$set(element, 'checked', true)
-    //     } else {
-    //       this.$set(element, 'checked', false)
-    //     }
-    //   }
+      console.log(this.hasMenuList);
+      this.$mStore.commit('setHasRoleList',this.hasMenuList)
+    },
+    // 子权限
+    chechedSon (num,father) {
 
-    // },
+      let temp = []
+      let childrenArr = []
+      father.children.forEach(element => {
+        if (element.id) {
+          childrenArr.push(element.id)
+        }
+      });
+      // 有权限,点击删除权限
+      if (this.hasMenuList.includes(num)) {
+        let index = this.hasMenuList.length
+        while (index--) {
+          if (this.hasMenuList[index] === num) {
+            this.hasMenuList.splice(index,1)
+          }
+        }
+        for (const item of childrenArr) {
+          this.hasMenuList.includes(item) ? temp.push(item) : ''
+        }
+        if (temp.length === 0) {
+          for (let i = 0; i < this.hasMenuList.length; i++) {
+            if (this.hasMenuList[i] === father.id) {
+              this.hasMenuList.splice(i,1)
+            }
+          }
+        }
+        console.log(temp.length);
+      } else {
+        this.hasMenuList.push(num)
+        for (const item of childrenArr) {
+          this.hasMenuList.includes(item) ? temp.push(item) : ''
+        }
+        console.log(temp.length);
+        
+        if (temp.length === father.children.length) {
+          if ( !this.hasMenuList.includes(father.id)) {
+            this.hasMenuList.push(father.id)
+          }
+        }
+      }
+      console.log(this.hasMenuList);
+      this.$mStore.commit('setHasRoleList',this.hasMenuList)
+    }
 
-    // // 子集权限选择
-    // sonChange (e) {
-    //   console.log(e);
-    //   let items = this.list
-    //   for (let i = 0; i < items.length; ++i) {
-    //     const element = items[i]
-    //     if (e.detail.value.includes(element.menuId)) {
-    //       this.$set(element, 'checked', true)
-    //     } else {
-    //       this.$set(element, 'checked', false)
-    //     }
-    //   }
-    // }
 
   }
 };

+ 351 - 309
src/pages/goods/shopdetail.vue

@@ -1,28 +1,30 @@
 <template>
   <view class="shopdetail">
     <view class="shopdetail-content">
+      <!-- 商品来源 -->
+      <view class="goodsfrom">
+        <view class="title">商品来源</view>
+        <view class="radio-warp">
+          <!-- goodsFrom 0自营;1分销 -->
+          <radio-group class="change-radio" name="goodsfrom" @change="changeGoodsFrom">  
+            <label class="radio1"> 
+              <radio class="radioValue1" value="0" :checked="goodsFrom=== '0'" style="transform:scale(0.7)" /><text class="bar">自营</text>
+            </label>
+            <label class="radio2">
+              <radio class="radioValue2" value="1" :checked="goodsFrom === '1'"  style="transform:scale(0.7)" /><text class="bar">分销</text>
+            </label>
+          </radio-group>
+        </view>
+      </view>
       <!-- 所属店铺 -->
       <view class="shop detail-list">
         <view class="menu">
           <view class="uni-list-cell">
             <view class="uni-list-cell-db">
-              <picker
-                class="selectlist"
-                mode="selector"
-                @change="changeStore"
-                :value="storeIndex"
-                :range="storeList"
-                :disabled="storeDisable"
-                range-key="name"
-              >
-                <view class="uni-input title">{{
-                  storeList[storeIndex].name
-                }}</view>
+              <picker class="selectlist"  mode="selector" @change="changeStore" :value="storeIndex" :range="storeList" :disabled="storeDisable" range-key="name">
+                <view class="uni-input title">{{ storeList[storeIndex].name}}</view>
               </picker>
-              <image
-                src="../../static/images/moreicon.png"
-                class="more"
-              ></image>
+              <image src="../../static/images/moreicon.png" class="more"></image>
             </view>
           </view>
         </view>
@@ -32,62 +34,31 @@
         <view class="menu">
           <view class="uni-list-cell">
             <view class="uni-list-cell-db">
-              <picker
-                @change="changeType"
-                :value="typeIndex"
-                :range="typeList"
-                :disabled="typeDisabled"
-                range-key="name"
-                class="selectlist"
-              >
-                <view class="uni-input title">{{
-                  typeList[typeIndex].name
-                }}</view>
+              <picker @change="changeType" :value="typeIndex" :range="typeList" :disabled="typeDisabled" range-key="name" class="selectlist">
+                <view class="uni-input title">{{ typeList[typeIndex].name }}</view>
               </picker>
-              <image
-                src="../../static/images/moreicon.png"
-                class="more"
-              ></image>
+              <image src="../../static/images/moreicon.png" class="more"></image>
             </view>
           </view>
         </view>
       </view>
       <!-- 商品名称 -->
       <view class="shopname detail-list">
-        <!-- <view class="menu" v-if="hasNameList === 1"> -->
-        <view class="menu" v-if="typeProperty === '1'">
+        <view class="menu" v-if="goodsFrom === '1'">
           <view class="uni-list-cell">
             <view class="uni-list-cell-db">
-              <picker
-                @change="changeShop"
-                :value="shopIndex"
-                :range="shopList"
-                :disabled="nameDisabled"
-                range-key="name"
-                class="selectlist"
-              >
-                <view class="uni-input title">{{
-                  shopList[shopIndex].name
-                }}</view>
+              <picker @change="changeShop" :value="shopIndex" :range="shopList" :disabled="nameDisabled" range-key="name" class="selectlist">
+                <view class="uni-input title">{{ shopList[shopIndex].name }}</view>
               </picker>
-              <image
-                src="../../static/images/moreicon.png"
-                class="more"
-              ></image>
+              <image src="../../static/images/moreicon.png" class="more"></image>
             </view>
           </view>
         </view>
-        <!-- <view class="menu" v-if="hasNameList === 0"> -->
-        <view class="menu" v-if="typeProperty === '0'">
-          <input
-            class="input-shopname"
-            type="text"
-            v-model="shopname"
-            placeholder-style="color:#a2a8a8;font-size:28upx"
-            placeholder="请输入商品名称"
-          />
+        <view class="menu" v-if="goodsFrom === '0'">
+          <input class="input-shopname" type="text" v-model="shopname" placeholder-style="color:#a2a8a8;font-size:28upx" placeholder="请输入商品名称"/>
         </view>
       </view>
+
       <!-- 自定义分类 -->
       <view class="classify detail-list noborder">
         <view class="menu">
@@ -120,8 +91,32 @@
           </view>
         </view>
       </view>
+
+      <!-- 核销类型 -->
+      <view class="goodsfrom">
+        <view class="title">核销类型</view>
+        <view class="radio-warp">
+          <!-- verifyType   1验码核销;2滑动核销-->
+          <radio-group class="change-radio" name="goodsfrom" @change="changeCancel">
+            <label class="radio1">
+              <radio class="radioValue1" :checked="verifyType === '1'" value="1" checked="" style="transform:scale(0.7)" /><text class="bar">验码核销</text>
+            </label>
+            <label class="radio2">
+              <radio class="radioValue2" :checked="verifyType === '2'" value="2" style="transform:scale(0.7)" /><text class="bar">滑动核销</text>
+            </label>
+          </radio-group>
+        </view>
+      </view>
+      <!-- 可核销次数 -->
+      <view class="cancelNum">
+        <view class="cancel-num-warp">
+          <view class="title">可核销次数:</view>
+          <!-- checkNum  -->
+          <input class="inputcancelnum"  v-model="checkNum" type="number" placeholder="请输入核销次数" placeholder-style="#a3a8a8">
+        </view>
+      </view>
+
       <!-- 账号限制 -->
-      <!-- <view class="warp" v-if="typeProperty === '1'"> -->
       <view class="warp">
         <view class="idastrict detail-list">
           <view class="menu">
@@ -143,31 +138,49 @@
           </view>
         </view>
       </view>
-      <view class="warp" v-if="typeProperty === '0'">
-        <!-- 卖价 -->
-        <view class="price-warp">
-          <view class="name">卖价:</view>
-          <input
-            class="price"
-            type="text"
-            v-model="price"
-            placeholder="请输入卖价"
-          />
+
+      <!-- 实名制 -->
+      <view class="truename">
+        <view class="truename-warp">
+          <view class="txt">是否开启实名制购票</view>
+          <switch :checked="trueNme" @change="trueNmeChange" />
         </view>
-        <!-- 打折价 -->
-        <view class="price-warp">
-          <view class="name">划线价:</view>
-          <input
-            class="price"
-            type="text"
-            v-model="rateprice"
-            placeholder="请输入划线价"
-          />
+      </view>
+
+      <!-- 可退规则 -->
+      <view class="modeltwo">
+        <view class="title">退订规则</view>
+        <view class="uni-list">
+          <radio-group @change="bookingChange">
+            <label class="uni-list-cell uni-list-cell-pd booking-item" v-for="(item, index) in bookingList" :key="index">
+              <view class="checkth">
+                <radio :value="item.id" :checked="index === bookingIndex"/>
+              </view>
+              <view class="txt">{{ item.name }}</view>
+            </label>
+          </radio-group>
         </view>
+      </view>
+
+      <view class="warp" v-if="goodsFrom === '0'">
+
         <!-- 销售属性 -->
         <view class="property">
+          
           <view class="property-warp">
             <view class="title">销售属性</view>
+
+            <!-- 卖价 -->
+            <view class="price-warp">
+              <view class="name">卖价:</view>
+              <input class="price" type="digit" v-model="price" placeholder="请输入卖价"/>
+            </view>
+            <!-- 打折价 -->
+            <view class="price-warp">
+              <view class="name">划线价:</view>
+              <input class="price" type="digit" v-model="rateprice" placeholder="请输入划线价"/>
+            </view>
+
             <view class="date">
               <view class="namebar">过期日期:</view>
               <view class="num" @tap="openTime"> {{ expirationDate }}</view>
@@ -175,16 +188,9 @@
             <view class="pattern">
               <view class="uni-list">
                 <radio-group @change="radioChange">
-                  <label
-                    class="uni-list-cell uni-list-cell-pd pattern-item"
-                    v-for="(item, index) in patterList"
-                    :key="index"
-                  >
+                  <label class="uni-list-cell uni-list-cell-pd pattern-item" v-for="(item, index) in patterList" :key="index">
                     <view class="checkth">
-                      <radio
-                        :value="item.id"
-                        :checked="index === patterIndex"
-                      />
+                      <radio :value="item.id" :checked="index === patterIndex"/>
                     </view>
                     <view class="txt">
                       <text class="txt1"> {{ item.name }}</text>
@@ -196,6 +202,7 @@
             </view>
           </view>
         </view>
+       
         <!-- 商品库存 -->
         <view class="property">
           <view class="property-warp">
@@ -203,28 +210,16 @@
             <view class="pattern">
               <view class="uni-list">
                 <radio-group @change="shopNumChange">
-                  <label
-                    class="uni-list-cell uni-list-cell-pd pattern-item"
-                    v-for="(item, index) in shopNumList"
-                    :key="index"
-                  >
+                  <label class="uni-list-cell uni-list-cell-pd pattern-item" v-for="(item, index) in shopNumList" :key="index">
                     <view class="checkth">
-                      <radio
-                        :value="item.id"
-                        :checked="index === shopNumIndex"
-                      />
+                      <radio :value="item.id" :checked="index === shopNumIndex"/>
                     </view>
                     <view class="txt">
                       <text class="txt1"> {{ item.name }}</text>
                       <text> {{ item.know }}</text>
                       <view class="inventory"  v-if="item.name === '限日库存模式'">
                         <text class="name">日库存数:</text>
-                        <input
-                          class="dateInventory"
-                          type="number"
-                          placeholder="请输入库存数量"
-                          v-model="dateInventory"
-                        />
+                        <input class="dateInventory" type="number" placeholder="请输入库存数量" v-model="dateInventory"/>
                       </view>
 
                       <view class="ref" v-if="item.name === '限日库存模式'">
@@ -232,17 +227,9 @@
                         <image class="reficon" src="../../static/images/ref.png" @tap="refToday"></image>
                       </view>
 
-                      <view
-                        class="inventory"
-                        v-if="item.name === '限总库存模式'"
-                      >
+                      <view class="inventory" v-if="item.name === '限总库存模式'">
                         <text class="name">总库存数:</text>
-                        <input
-                          class="dateInventory"
-                          type="number"
-                          placeholder="请输入库存数量"
-                          v-model="sunInventory"
-                        />
+                        <input class="dateInventory" type="number" placeholder="请输入库存数量" v-model="sunInventory"/>
                       </view>
 
                       <view class="ref" v-if="item.name === '限总库存模式'">
@@ -272,37 +259,6 @@
               </view>
               <view class="txt">一天内同一身份证可预定数量</view>
             </view>
-            <view class="truename">
-              <view class="truename-warp">
-                <view class="txt">是否开启实名制购票</view>
-                <switch :checked="trueNme" @change="trueNmeChange" />
-              </view>
-            </view>
-            <view class="modeltwo">
-              <view class="uni-list">
-                <radio-group @change="bookingChange">
-                  <label
-                    class="uni-list-cell uni-list-cell-pd booking-item"
-                    v-for="(item, index) in bookingList"
-                    :key="index"
-                  >
-                    <view class="checkth">
-                      <radio
-                        :value="item.id"
-                        :checked="index === bookingIndex"
-                      />
-                    </view>
-                    <view class="txt">{{ item.name }}</view>
-                  </label>
-                </radio-group>
-              </view>
-            </view>
-            <view class="truename">
-              <view class="truename-warp">
-                <view class="txt">订单显示二维码</view>
-                <switch :checked="codeShow" @change="codeShowChange" />
-              </view>
-            </view>
           </view>
         </view>
       </view>
@@ -311,8 +267,7 @@
       <view class="iconcontent">
         <image class="shopLogo" :src="iconurl" v-if="iconurl"></image>
         <text class="icon" @tap="uploadImg">点击上传</text>
-        <text class="per"
-          >{{ uploadtxt }} {{ progress === 0 ? '' : progress }}
+        <text class="per">{{ uploadtxt }} {{ progress === 0 ? '' : progress }}
           <text v-if="progress != 0">%</text></text
         >
       </view>
@@ -351,8 +306,10 @@
           ></editor>
         </view>
       </view>
+
       <view class="btn" @tap="submitMesage">确认</view>
-      <rf-loading v-if="loading"></rf-loading>
+
+      <!-- <rf-loading v-if="loading"></rf-loading> -->
       <uni-calendar
         ref="calendar"
         :insert="false"
@@ -391,7 +348,7 @@ export default {
       storeIndex: 0,
       storeId: '',
       storeDisable: true,
-      typeProperty: '1', // 判断所属店铺是否是自营店铺  1分销  0自营
+
 
       typeList: [{ name: '商品类型(请先选择所属店铺)', id: '' }],
       typeIndex: 0,
@@ -452,16 +409,25 @@ export default {
         { id: '2', name: '限总库存模式', know: '总库存限制,卖完为止。' },
       ],
       shopNumIndex: 0,
+      inventory: '',  // 库存数量
 
       dateInventory: 0,
       sunInventory: 0,
-      inventory: '',
 
       todayResidue: 0,
       sunResidue: 0,
 
       bookingnum: '',
 
+      trueNme: true,
+      codeShow: false,
+      
+      goodsName: '',
+      goodsFrom: '1',  // 0 自营,1分销
+      verifyType: '1', // 1验码核销 ; 2滑动核销
+      checkNum: 1, // 核销次数
+
+      refund: '0', // 可退规则
       bookingList: [
         { id: '0', name: '未消费统一可退' },
         { id: '1', name: '过期不可退' },
@@ -469,9 +435,6 @@ export default {
       ],
       bookingIndex: 0,
 
-      trueNme: false,
-      codeShow: false,
-
       // 规则参数
       astrictDate: {
         data: {
@@ -480,18 +443,11 @@ export default {
           dateSetting: '0', // 有效期模式
           goodsStockFlag: '0', // 库存模式
           bookRule: '', // 同一天限购
-          usubscribeRule: '0', // 可退规则
-          isRealName: '1', // 开启实名制
-          isShowQrcode: '1', // 显示二维码
+          isRealName: '1', // 开启实名制  1是 ; 0 否
         },
       },
     };
   },
-  onShow () {
-    if (this.storeId != '') {
-      this.getLine(this.storeId)
-    }
-  },
   onReady () {
     myCloud = uniCloud.init({
       provider: 'aliyun',
@@ -499,6 +455,11 @@ export default {
       clientSecret: '8nOzV70edtpCd0El6qce3g==',
     });
   },
+  onShow () {
+    if (this.storeId != '') {
+      this.getLine(this.storeId)
+    }
+  },
   onLoad ( option ) {
     if (option.id != 'undefined') {
       this.SHOPID = option.id
@@ -512,9 +473,7 @@ export default {
         this.rateprice = this.shopData.price / 100;
 
         if (this.shopData.expiredTime) {
-          this.expirationDate = this.shopData.expiredTime.slice(0, 10)
-            ? this.shopData.expiredTime.slice(0, 10)
-            : '请选择商品过期日期';
+          this.expirationDate = this.shopData.expiredTime.slice(0, 10) ? this.shopData.expiredTime.slice(0, 10) : '请选择商品过期日期';
         }
 
         // 图标回显
@@ -531,7 +490,15 @@ export default {
             this.pickList.push(element.url)
           });
         }
+     
         let rule = JSON.parse(this.shopData.saleRuleJson);
+        // 实名制
+        if (rule.data.isRealName === '0') {
+          this.trueNme = true;
+        } else {
+          this.trueNme = false;
+        }
+        this.astrictDate.data.isRealName = rule.data.isRealName;
 
         if (rule) {
           this.astrictDate.data.saleDay = rule.data.saleDay
@@ -555,25 +522,7 @@ export default {
           }
           // 预订数量
           this.astrictDate.data.bookRule = rule.data.bookRule;
-
-          // 实名制
-          if (rule.data.isRealName === '0') {
-            this.trueNme = true;
-          } else {
-            this.trueNme = false;
-          }
-          this.astrictDate.data.isRealName = rule.data.isRealName;
-
-          // 可退规则
-          this.bookingIndex = +rule.data.usubscribeRule;
-          this.astrictDate.data.usubscribeRule = rule.data.usubscribeRule;
-          // 二维码
-          if (rule.data.isShowQrcode === '0') {
-            this.codeShow = true;
-          } else {
-            this.codeShow = false;
-          }
-          this.astrictDate.data.isShowQrcode = rule.data.isShowQrcode;
+         
         }
         // 限制购票回显
         if (this.shopData.saleRule === '1') {
@@ -590,11 +539,37 @@ export default {
     }
   },
   methods: {
+
+    // 商品来源
+    changeGoodsFrom(e) {
+      this.goodsFrom = e.detail.value
+    },
+
+    // 核验方式
+    changeCancel(e) {
+      this.verifyType = e.detail.value
+    },
+
     // 获取单个商品信息
     async getShopBuyId (id) {
       this.loading = true;
       await this.$http.get('/goods/getById/' + id).then((res) => {
+        console.log(res);
         if (res.code === 200 && res.msg === 'OK') {
+
+          this.goodsFrom = res.data.goodsFrom
+          this.verifyType = res.data.verifyType
+          this.refund = res.data.refund
+          this.checkNum = res.data.checkNum
+
+          // 可退规则
+          this.bookingList.forEach((item,index) => {
+            if (item.id === res.data.refund) {
+              this.bookingIndex = index
+            }
+          });
+          this.refund = res.data.refund;
+
           this.shopData = res.data;
           this.storeId = res.data.shopId;
           this.typeId = res.data.typeId;
@@ -636,7 +611,7 @@ export default {
       }
 
       this.astrictDate.data.goodsStockFlag = e.detail.value;
-      this.getResidue()
+      // this.getResidue()
     },
     // 剩余库存
     async getResidue () {
@@ -645,6 +620,7 @@ export default {
         id:this.SHOPID,
         goodsStockFlag: this.astrictDate.data.goodsStockFlag
       }).then( res =>{
+        console.log(res);
         if (res.code === 200 && res.msg ==='OK') {
           if (+this.astrictDate.data.goodsStockFlag === 1) {
             this.todayResidue = res.data.now_inventory
@@ -655,11 +631,11 @@ export default {
       })
     },
     refToday () {
-      this.todayResidue = '...'
+      this.todayResidue = 0
       this.getResidue()
     },
     refSun () {
-      this.sunResidue = '...'
+      this.sunResidue = 0
       this.getResidue()
     },
     // 可退模式
@@ -670,7 +646,7 @@ export default {
           break;
         }
       }
-      this.astrictDate.data.usubscribeRule = e.detail.value;
+      this.refund = e.detail.value;
     },
     // 实名制
     trueNmeChange (e) {
@@ -680,14 +656,7 @@ export default {
         this.astrictDate.data.isRealName = '1';
       }
     },
-    // 显示二维码
-    codeShowChange (e) {
-      if (e.detail.value) {
-        this.astrictDate.data.isShowQrcode = '0';
-      } else {
-        this.astrictDate.data.isShowQrcode = '1';
-      }
-    },
+   
     // 初始化编辑器
     onEditorReady () {
       // this.placeholderContent = this.shopData.describ
@@ -716,9 +685,9 @@ export default {
     changeStore (e) {
       this.storeIndex = e.detail.value;
       this.storeId = this.storeList[this.storeIndex].id;
-      this.typeProperty = this.storeList[this.storeIndex].type;
+      console.log(e);
 
-      if (!this.SHOPID) {
+      if (!this.SHOPID && e.detail.value != 0) {
         this.getType(this.storeId)
         this.getLine(this.storeId)
       }
@@ -767,7 +736,6 @@ export default {
                 }
               });
               this.storeId = this.storeList[this.storeIndex].id;
-              this.typeProperty = this.storeList[this.storeIndex].type;
 
               this.getType(this.storeId);
               this.getLine(this.storeId);
@@ -821,7 +789,7 @@ export default {
             // 回显名称
             if (this.shopData.name) {
               this.loading = true;
-              if (this.typeProperty != 0) {
+              if (this.goodsFrom != 0) {
                 this.shopList[0] = { name: this.shopData.name, id: '' };
                 this.shopIndex = 0
                 this.shopId = this.shopList[this.shopIndex].id;
@@ -848,7 +816,8 @@ export default {
         })
         .then(async (res) => {
           let arr = [];
-          this.typeProperty = +res.data.shopFrom;
+
+
           res.data.customGroupList.forEach((element) => {
             arr.push({ name: element.name, id: element.id });
           });
@@ -922,9 +891,7 @@ export default {
               _self.$mHelper.toast('图标上传失败,请重新上传')
             },
             onUploadProgress: function (progressEvent) {
-              _self.progress = Math.round(
-                (progressEvent.loaded * 100) / progressEvent.total
-              );
+              _self.progress = Math.round( (progressEvent.loaded * 100) / progressEvent.total );
               if (_self.progress === 100) {
                 _self.uploadtxt = '上传成功';
               }
@@ -986,87 +953,9 @@ export default {
     // 内容提交
     submitMesage () {
       let _this = this;
-
-      if (this.progress > 0  && this.progress < 100) {
-        this.$mHelper.toast('您有图标正在上传,请在上传完成后提交内容!')
-        return
-      }
-
-      // 判断是否限制账号购买 
-      if (this.showoperat) {
-        this.salerule = '1'
-      } else {
-        this.salerule = '0'
-        this.astrictDate.data.saleDay = '';
-        this.astrictDate.data.saleNum = '';
-      }
-      let name = '';
-      if (this.typeProperty === 1) {
-        if (this.SHOPID) {
-          name = this.shopList[this.shopIndex].name
-        } else {
-          name = this.shopList[this.shopIndex].id;
-        }
-      } else if (this.typeProperty === 0) {
-        name = this.shopname;
-      }
-      if (!this.storeId) {
-        this.$mHelper.toast('请选择所属商铺!');
-        return;
-      }
-      if (!this.typeId) {                                                               
-        this.$mHelper.toast('请选择商品类型!');
-        return;
-      }
-      if (!name) {
-        this.$mHelper.toast('请选择商品名称或者输入商品名称!');
-        return;
-      }
-      if (this.typeProperty === 0) {
-
-        if (!this.lineId) {
-          this.$mHelper.toast('请选择商品分类!');
-          return;
-        }
-        const pat = new RegExp(/(?:^[1-9]([0-9]+)?(?:\.[0-9]{1,2})?$)|(?:^(?:0){1}$)|(?:^[0-9]\.[0-9](?:[0-9])?$)/)
-        if (!this.price || !pat.test(this.price)) {
-          this.$mHelper.toast('请输入正确的商品卖价!');
-          return;
-        }
-        if (!this.rateprice || !pat.test(this.rateprice)) {
-          this.$mHelper.toast('请输入正确的商品划线价!');
-          return;
-        }
-        if (this.expirationDate === '请选择商品过期日期') {
-          this.$mHelper.toast('请选择商品过期日期');
-          return;
-        }
-        if (this.shopIndex === 0) {
-          this.inventory = '';
-        }
-        if (this.shopNumIndex === 1) {
-          this.inventory = this.dateInventory;
-          if (!this.inventory) {
-            this.$mHelper.toast('请输入日库存数量!');
-            return;
-          }
-        }
-        if (this.shopNumIndex === 2) {
-          this.inventory = this.sunInventory;
-          if (!this.inventory) {
-            this.$mHelper.toast('请输入总库存数量!');
-            return;
-          }
-        }
-        if (!this.astrictDate.data.bookRule) {
-          this.$mHelper.toast('请输入预订数量!');
-          return;
-        }
-      }
-    
-      this.loading = true;
-      this.$http
-        .post('/goods/add', {
+      this.proofRule().then( ()=>{
+        this.loading = true;
+        this.$http.post('/goods/add', {
           id: this.shopData.id || '',
           mid: this.scenicId,
           shopId: this.storeId,
@@ -1078,15 +967,21 @@ export default {
           del: this.shopData.del || '',
           upDown: this.shopData.upDown || '',
           saleRule: this.salerule, // 限制购票
+
+          goodsFrom: this.goodsFrom,
+          verifyType: this.verifyType,
+          checkNum: this.checkNum,
+        
+          refund: this.refund,
           saleRuleJson: JSON.stringify(this.astrictDate),
+
           //  自营
-          name: name,
+          name: this.goodsName,
           salePrice: this.price * 100 || null,
           price: this.rateprice * 100 || null,
-          expiredTime:this.expirationDate === '请选择商品过期日期'? '': this.expirationDate,
+          expiredTime: this.expirationDate === '请选择商品过期日期'? '': this.expirationDate,
           inventory: this.inventory
-        })
-        .then((res) => {
+        }).then((res) => {
           if (res.code === 200 && res.msg === 'OK') {
             this.loading = false;
             if (this.shopData.id) {
@@ -1099,7 +994,99 @@ export default {
             }, 500);
           }
         });
+      })
+     
     },
+    // 验证规则
+    proofRule () {
+      return new Promise((resolve,reject)=>{
+
+        if (this.progress > 0  && this.progress < 100) {
+          this.$mHelper.toast('您有图标正在上传,请在上传完成后提交内容!')
+          return
+        }
+        // 判断是否限制账号购买 
+        if (this.showoperat) {
+          this.salerule = '1'
+        } else {
+          this.salerule = '0'
+          this.astrictDate.data.saleDay = '';
+          this.astrictDate.data.saleNum = '';
+        }
+       
+        if (!this.storeId) {
+          this.$mHelper.toast('请选择所属商铺!');
+          return;
+        }
+        if (!this.typeId) {                                                               
+          this.$mHelper.toast('请选择商品类型!');
+          return;
+        }
+
+        if (this.goodsFrom === '1') {  //  分销商品
+          if (this.SHOPID) {
+            this.goodsName = this.shopList[this.shopIndex].name
+          } else {
+            this.goodsName = this.shopList[this.shopIndex].id;
+          }
+        } else if (this.goodsFrom === '0') {
+          this.goodsName = this.shopname;
+        }
+
+        if (!this.goodsName) {
+          this.$mHelper.toast('请选择商品名称或者输入商品名称!');
+          return;
+        }
+
+        console.log(this.goodsFrom);
+        if (this.goodsFrom === '0') {
+
+          if (!this.lineId) {
+            this.$mHelper.toast('请选择商品分类!');
+            return;
+          }
+          const pat = new RegExp(/(?:^[1-9]([0-9]+)?(?:\.[0-9]{1,2})?$)|(?:^(?:0){1}$)|(?:^[0-9]\.[0-9](?:[0-9])?$)/)
+          if (!this.price || !pat.test(this.price)) {
+            this.$mHelper.toast('请输入正确的商品卖价!');
+            return;
+          }
+          if (!this.rateprice || !pat.test(this.rateprice)) {
+            this.$mHelper.toast('请输入正确的商品划线价!');
+            return;
+          }
+          if (this.expirationDate === '请选择商品过期日期') {
+            this.$mHelper.toast('请选择商品过期日期');
+            return;
+          }
+          if (this.shopNumIndex === 0) {
+            this.inventory = '';
+          }
+          console.log(this.shopNumIndex);
+          if (this.shopNumIndex === 1) {
+            this.inventory = this.dateInventory;
+            if (!this.inventory) {
+              this.$mHelper.toast('请输入日库存数量!');
+              return;
+            }
+          }
+          if (this.shopNumIndex === 2) {
+            this.inventory = this.sunInventory;
+            if (!this.inventory) {
+              this.$mHelper.toast('请输入总库存数量!');
+              return;
+            }
+          }
+          if (!this.astrictDate.data.bookRule) {
+            this.$mHelper.toast('请输入预订数量!');
+            return;
+          }
+        }
+
+        resolve()
+
+      })
+
+    }
   },
 };
 </script>
@@ -1108,6 +1095,78 @@ export default {
 .shopdetail {
   .shopdetail-content {
     padding: 24upx 0 0upx;
+    .goodsfrom {
+      background-color: #fff;
+      border-bottom: 1px solid #e7e7e7;
+      .title{
+        padding: 20upx 33upx;
+        font-size: 32rpx;
+        color: #232828;
+        font-weight: 700;
+        background-color: #f1f1f1;
+      }
+      .radio-warp{
+        padding: 22upx 33upx;
+        .change-radio{
+          display: flex;
+          align-items: center;
+          .radio2{
+            margin-left: 60upx;
+          }
+          .bar {
+            margin-left: 20upx;
+          }
+        }
+      }
+    }
+    .cancelNum{
+      background-color: #fff;
+      border-bottom: 1px solid #e7e7e7;
+      .cancel-num-warp{
+        padding: 22upx 33upx;
+        display: flex;
+        align-items: center;
+        .title{
+          color: #000;
+        }
+        .inputcancelnum{
+          margin-left: 20upx;
+        }
+      }
+    }
+    .modeltwo {
+      .title {
+        padding: 20upx 33upx;
+        font-size: 32rpx;
+        color: #232828;
+        font-weight: 700;
+        background-color: #f1f1f1;
+      }
+      .booking-item {
+        display: flex;
+        border-bottom: 1px solid #e7e7e7;
+        padding: 0 33upx 22upx;
+        .checkth {
+          width: 100upx;
+        }
+        .txt {
+          flex: 1;
+        }
+      }
+    }
+    .truename {
+      .truename-warp {
+        padding: 20upx 33upx;
+        display: flex;
+        justify-content: space-between;
+        border-bottom: 1px solid #e7e7e7;
+        background-color: #fff;
+        .txt {
+          font-size: 32upx;
+          font-weight: 700;
+        }
+      }
+    }
     .detail-list {
       padding: 0 33upx;
       background-color: #ffffff;
@@ -1142,7 +1201,7 @@ export default {
           height: 26upx;
         }
         .bigtitle {
-          font-size: 34upx;
+          font-size: 32upx;
           color: #232828;
           font-weight: 700;
         }
@@ -1315,7 +1374,7 @@ export default {
       .property-warp {
         .title {
           padding: 20upx 33upx;
-          font-size: 34rpx;
+          font-size: 32rpx;
           color: #232828;
           font-weight: 700;
         }
@@ -1342,7 +1401,9 @@ export default {
     }
     .pattern {
       .pattern-item {
+        padding: 0 33upx 22upx;
         display: flex;
+        align-items: center;
         border-bottom: 1px solid #e7e7e7;
 
         .checkth {
@@ -1395,7 +1456,7 @@ export default {
       .booking-warp {
         .title {
           padding: 20upx 33upx;
-          font-size: 34rpx;
+          font-size: 32rpx;
           color: #232828;
           font-weight: 700;
         }
@@ -1421,27 +1482,8 @@ export default {
             color: #a3a8a8;
           }
         }
-        .truename {
-          .truename-warp {
-            padding: 20upx 33upx;
-            display: flex;
-            justify-content: space-between;
-            border-bottom: 1px solid #e7e7e7;
-            background-color: #fff;
-          }
-        }
-        .modeltwo {
-          .booking-item {
-            display: flex;
-            border-bottom: 1px solid #e7e7e7;
-            .checkth {
-              width: 100upx;
-            }
-            .txt {
-              flex: 1;
-            }
-          }
-        }
+      
+       
       }
     }
   }

+ 10 - 10
src/pages/index/index.vue

@@ -27,7 +27,8 @@
               <image class="usericon" src="../../static/missing-face.png" mode="widthFix"></image>
 						<view class="message">
               <!-- <open-data type="userNickName" class="name"></open-data> -->
-							<view class="name">{{ uderName | nameDeal}}</view>
+							<!-- <view class="name">{{ uderName | nameDeal}}</view> -->
+							<view class="name">{{ logingname }}</view>
 							<view class="tele"></view>
               <!-- <open-data type="userNickName" class="name"></open-data>
 							<view class="tele">{{ scenicMessage.name }}</view> -->
@@ -401,6 +402,7 @@ export default {
     };
   },
 
+
   // 此处定义传入的数据
   props: {
     shoplist: {
@@ -408,21 +410,19 @@ export default {
       value: null,
     },
   },
-  filters:{
-    nameDeal(value) {
-      console.log(value.indexOf('@'));
-      if ( value.indexOf('@') != -1) {
+  computed:{
+    logingname: function (){
+
+       if ( this.uderName.indexOf('@') != -1) {
         console.log('子账号');
-        return value.slice(value.indexOf('@')+1)
+        return this.uderName.slice(this.uderName.indexOf('@')+1)
       } else {
         console.log('景区账号');
-        return value
+        return this.uderName
       }
     }
   },
-  onReady(){
-   
-  },
+  
   onLoad () {
     // 商家信息
     this.$http.get('/getUserInfo').then(async (res) => {

+ 48 - 11
src/pages/index/userinfo/roleedit.vue

@@ -4,14 +4,14 @@
     <view class="item-warp">
       <view class="bar">
         <view class="item">
-          <view class="title">角色标识</view>
+          <view class="title">角色名称</view>
           <input class="msg"  v-model="roledata.name" type="text" placeholder="..." placeholder-style="color:#bdbdbd" />
         </view>
       </view>
 
       <view class="bar">
         <view class="item">
-          <view class="title">角色名称</view>
+          <view class="title">描述</view>
           <input type="text" v-model="roledata.description" placeholder="..." placeholder-style="color:#bdbdbd">
         </view>
       </view>
@@ -28,10 +28,11 @@
     </view>
 
     <view class="btn">
-      <view class="sure">确认</view>
+      <view class="sure" @tap='submit'>确认</view>
     </view>
 
-    <Maskre :list='menulist' :hasList="hasRoleList" v-if="isShowMask" @isSureConver='watchmask'></Maskre>
+    <Maskre v-if="isShowMask" @isSureConver='watchmask'></Maskre>
+		<rf-loading v-if="isloading"></rf-loading>
   </view>
 </template>
 
@@ -45,20 +46,29 @@ export default {
   data () {
     //这里存放数据
     return {
-      isShowMask: true,
+      isloading: false,
+      isShowMask: false,
+
       roledata: {},
       menulist:[],
-
       hasRoleList: []
     };
   },
   onLoad (option) {
-    this.roledata = JSON.parse(option.roledata)
+    if (JSON.parse(option.roledata) === 'add') {
+      this.roledata ={
+        name: '',
+        description: ''
+      }
+      uni.removeStorageSync('hasMenuList')
+    } else {
+      this.roledata = JSON.parse(option.roledata)
+      this.getRoleBuyId ()
+    }
   },
   onShow () {
 
-    this.getMenuList()
-    this.getRoleBuyId ()
+    this.getMenuList()  
    
   },
   //方法集合
@@ -70,11 +80,10 @@ export default {
     // 打开遮罩层
     showRoleList() {
       this.isShowMask = true
-
     },
     // 菜单列表
     async getMenuList () {
-      await this.$http.get('/mrole/permissionList').then( res=>{
+      await this.$http.get('/mrole/getMiniPermission').then( res=>{
         if (res.code === 200 && res.msg === 'OK') {
           this.menulist = res.data
           this.$mStore.commit('setMenuRole',res.data)
@@ -92,6 +101,34 @@ export default {
           this.$mStore.commit('setHasRoleList',res.data)
         }
       })
+    },
+
+    // 提交信息
+    submit () {
+      if ( !this.roledata.name) {
+        this.$mHelper.toast('角色名不能为空')
+        return
+      }
+      if ( !this.roledata.description) {
+        this.$mHelper.toast('描述不能为空')
+        return
+      }
+      if (this.$mStore.state.hasRoleList.length === 0) {
+        this.$mHelper.toast('请选择菜单权限')
+        return
+      }
+      console.log(this.$mStore.state.hasRoleList);
+      this.roledata.routes = this.$mStore.state.hasRoleList
+      this.roledata.mid = uni.getStorageSync('scenicMessage').id
+      this.isloading = true
+      this.$http.post('/mrole/saveRole', this.roledata).then(res=>{
+        console.log(res);
+        if (res.code === 200 && res.msg==='OK') {
+          this.$mHelper.toast('提交成功!')
+          this.isloading = false
+          this.$mRouter.back()
+        }
+      })
     }
   }
 }

+ 35 - 4
src/pages/index/userinfo/rolemenage.vue

@@ -5,7 +5,7 @@
       <image
         src="../../../static/images/addicon.png"
         class="addicon"
-        @tap="topage('add')"
+        @tap="edit('add')"
       ></image>
     </view>
     <view class="content">
@@ -13,20 +13,23 @@
       <view class="item" v-for="(item,index) in roleList" :key="index">
         <view class="top">
           <view class="expression">
-            <text class="title">标识:</text><text class="msg">{{ item.name }}</text>
+            <text class="title">角色名:</text><text class="msg">{{ item.name }}</text>
           </view>
           <view class="expression name">
-            <text class="title">名称:</text><text class="msg">{{ item.description }}</text>
+            <text class="title">描述:</text><text class="msg">{{ item.description }}</text>
           </view>
         </view>
         <view class="bottom">
           <view class="btns">
             <view class="btn edit" @tap="edit(item)">编辑</view>
-            <view class="btn dele" @tap="dele(itemid)">删除</view>
+            <view class="btn dele" @tap="dele(item.id)">删除</view>
           </view>
         </view>
       </view>
     </view>
+
+		<rf-loading v-if="isloading"></rf-loading>
+
   </view>
 </template>
 
@@ -38,17 +41,45 @@ export default {
   data () {
     //这里存放数据
     return {
+      isloading: false,
       roleList:[],
       mid: uni.getStorageSync('scenicMessage').id
     };
   },
   onShow () {
     this.getRoleList()
+    uni.removeStorageSync('hasMenuList')
+    uni.removeStorageSync('menuList')
   },
   onLoad () {
   },
   //方法集合
   methods: {
+    dele(id) {
+      console.log(id);
+      let _self = this
+      uni.showModal({
+        content: '是否删除该角色?',
+        success: confirmres =>{
+          if (confirmres.confirm) {
+            _self.isloading = true
+            _self.$http.post('/mrole/delete/'+id).then(res=>{
+              console.log(res);
+              if (res.code === 200 && res.msg=== 'OK') {
+                _self.$mHelper.toast('删除成功')
+                _self.getRoleList().then( ()=>{
+                  _self.isloading = false
+                })
+              } else {
+                _self.isloading = false
+                _self.$mHelper.toast(res.msg)
+              }
+            })
+          }
+        }
+      })
+     
+    },
     // 跳转编辑
     edit(data) {
       this.$mRouter.push({route: '/pages/index/userinfo/roleedit', query: {roledata:JSON.stringify(data)}})

+ 127 - 0
src/readme.md

@@ -0,0 +1,127 @@
+### select-tree 二级树形多选组件
+
+二级树形多选组件,组件名:``select-tree``
+
+**组件预览**
+
+![image.png](http://dlhtx.zicp.vip:3000/img/1568968685815.png)
+
+**使用方式:**
+
+在 ``script`` 中引用组件 (默认可以不传selectList,默认有供你预览的数组)
+
+最新版将:selectList = 'selectList' 更改为 v-model='selectList'
+
+```javascript
+import selectTree from "@/components/select-tree/select-tree"
+export default {
+    components: {selectTree}
+}
+```
+
+一般用法
+
+```html
+// 组件
+  <select-tree @choose='choose' v-model='selectList' ref='selectTree'></select-tree>
+// script
+<script>
+import selectTree from "@/components/select-tree/select-tree"
+ export default {
+        components: {
+            selectTree,
+        },
+		  data() {
+            return {
+                selectList:  [
+                    {
+                        name: '水果',
+                        checked: false,
+                        show: false,
+                        childrenList: [
+                            {
+                                checked: false,
+                                name: '西瓜',
+                            }, {
+                                checked: false,
+                                name: '桃子'
+                            }
+                        ]
+                    },
+                    {
+                        name: '工具',
+                        checked: false,
+                        show: false,
+                        childrenList: [
+                            {
+                                checked: false,
+                                name: '锄头'
+                            }, {
+                                checked: false,
+                                name: '铲子'
+                            }
+                        ]
+
+                    }
+                ]
+            }
+        },
+        methods: {
+            choose(e){
+                console.log(e)
+				//返回参数说明
+            },
+			chooseAll(){
+				this.$refs.selectTree.chooseAll()
+			},
+			cancelAll(){
+				this.$refs.selectTree.cancelAll()
+			}
+        },
+    }
+</script>
+```
+**options 参数说明**
+
+|参数|类型|是否必填|说明|
+|:--|:--|:--|:--|
+|selectList|Array|是|传入二维数组|
+|showCheck|Boolean|否|控制多选框是否显示|
+|disableLv2Check|Boolean|否|控制二级多选框disabled|
+
+**事件说明:**
+
+|事件名称|说明|返回参数|
+|:--|:---|:--|
+|choose|点击选项按钮时触发事件|[lv1_value: { ...item }, lv2_value: { ...item2 }]|
+
+**组件内部方法: **
+|方法名称|说明|返回参数|
+|:--|:---|:--|
+|chooseAll|主动选中所有子页面所有层级|无|
+|cancelAll|主动取消所有子页面所有层级|无|
+
+**必须的基本参数说明**
+``` javascript
+selectList:[
+  {
+    name: '水果',//一级树形的名字
+    checked: false,//一级树形复选框是否选中
+    show: false,//二级菜单是否展示
+    childrenList: [
+        {
+          checked: false,//二级树形复选框是否选中
+       	  name: '西瓜',//二级树形的名字
+        }, {
+          checked: false,
+          name: '桃子'
+        }
+    ]
+   }]
+```
+**返回参数预览**
+
+![image.png](http://dlhtx.zicp.vip:3000/img/1568968740956.png)
+
+**修复过程**
+http://dlhtx.zicp.vip:9090/#/blogDetail?blogId=12438

+ 7 - 2
src/store/index.js

@@ -14,15 +14,18 @@ const USER = uni.getStorageSync('user') || {};
 const ROLE = uni.getStorageSync('role')
 const sceniceMessage = uni.getStorageSync('scenicMessage') || ''
 
+const meunList = uni.getStorageSync('menuList') || ''
+const hasMenuList = uni.getStorageSync('hasMenuList') || ''
+
 const store = new Vuex.Store({
     // 数据存放
     state: {
         // 景区信息
         scenic: sceniceMessage,
         // 菜单权限
-        menuRole:[],
+        menuRole:meunList,
         // 角色拥有的权限
-        hasRoleList: [],
+        hasRoleList: hasMenuList,
 
         //用户token
         accessToken: ACCESSTOKEN,
@@ -69,10 +72,12 @@ const store = new Vuex.Store({
     mutations: {
         // 菜单
         setMenuRole (state, data) {
+            uni.setStorageSync('menuList',data)
             state.menuRole = data
         },
         // 角色拥有的权限
         setHasRoleList (state,data) {
+            uni.setStorageSync('hasMenuList',data)
             state.hasRoleList = data
         },
         // 保存景区Id