18016688350 hace 4 años
padre
commit
b1a73247e8

+ 56 - 13
components/timePicker/timePicker.js

@@ -75,6 +75,10 @@ Component({
 
       }
     },
+    format:{
+      type:String,
+      value:'yyyy-MM-dd'
+    },
     config: Object
   },
 
@@ -82,6 +86,12 @@ Component({
    * 组件的初始数据
    */
   data: {
+    isYear:false,
+    isMonth:false,
+    isDay:false,
+    isTime:false,
+    isMin:false,
+    isSecond:false,
     // pickerShow:true
     // limitStartTime: new Date().getTime()-1000*60*60*24*30,
     // limitEndTime: new Date().getTime(),
@@ -99,15 +109,48 @@ Component({
       startValue: this.data.startValue,
       endValue: this.data.endValue,
     });
-
-
-    
-    
+    this.formatDate();
   },
+
   /**
    * 组件的方法列表
    */
   methods: {
+    //格式化时间
+    formatDate(){
+      let format = this.data.format;
+      if(format.indexOf("yyyy")!=-1){//年
+        this.setData({
+          isYear: true,
+        });
+      }
+      if(format.indexOf("MM")!=-1){//月
+        this.setData({
+          isMonth: true,
+        });
+      }
+      if(format.indexOf("dd")!=-1){//日
+        this.setData({
+          isDay: true,
+        });
+      }
+      if(format.indexOf("HH")!=-1){//时
+        this.setData({
+          isTime: true,
+        });
+      }
+      if(format.indexOf("mm")!=-1){//分
+        this.setData({
+          isMin: true,
+        });
+      }
+      if(format.indexOf("ss")!=-1){//秒
+        this.setData({
+          isSecond: true,
+        });
+      }
+    },
+  
     //阻止滑动事件
     onCatchTouchMove(e) {
 
@@ -191,11 +234,11 @@ Component({
           "-" +
           format0(startArr[2]) +
           " " +
-          (this.data.hourColumn ? format0(startArr[3]) : "00") +
+          format0(startArr[3]) +
           ":" +
-          (this.data.minColumn ? format0(startArr[4]) : "00") +
+          format0(startArr[4]) +
           ":" +
-          (this.data.secColumn ? format0(startArr[5]) : "00");
+          format0(startArr[5]);
 
         let endTimeBack =
           endArr[0] +
@@ -204,11 +247,11 @@ Component({
           "-" +
           format0(endArr[2]) +
           " " +
-          (this.data.hourColumn ? format0(endArr[3]) : "00") +
+          format0(endArr[3]) +
           ":" +
-          (this.data.minColumn ? format0(endArr[4]) : "00") +
+          format0(endArr[4]) +
           ":" +
-          (this.data.secColumn ? format0(endArr[5]) : "00");
+          format0(endArr[5]);
 
         let time = {
           startTime: startTimeBack,
@@ -241,9 +284,9 @@ Component({
     },
     //比较时间是否在范围内
     compareTime(val, type) {
-      let h = val[3] ? this.data.HourList[val[3]] : "00";
-      let m = val[4] ? this.data.MinuteList[val[4]] : "00";
-      let s = val[5] ? this.data.SecondList[val[5]] : "00";
+      let h =  this.data.HourList[val[3]]
+      let m =  this.data.HourList[val[4]]
+      let s =  this.data.HourList[val[5]]
       let time =
         this.data.YearList[val[0]] +
         "-" +

+ 12 - 12
components/timePicker/timePicker.wxml

@@ -11,22 +11,22 @@
     <view>
       <picker-view class='sensorTypePicker' indicator-style='height: 35px;' bindchange="changeStartDateTime"
         value="{{startValue}}" style="height: {{endDate?'120px':'250px'}};" bindpickstart="handlePickStart" bindpickend="handlePickEnd">
-        <picker-view-column style="min-width: 70px;flex-shrink: 0">
+        <picker-view-column hidden="{{!isYear}}" style="min-width: 70px;flex-shrink: 0">
           <view class='picker-item' wx:for="{{startYearList}}" wx:key='*this'>{{item}}年</view>
         </picker-view-column>
-        <picker-view-column>
+        <picker-view-column hidden="{{!isMonth}}">
           <view class='picker-item' wx:for="{{startMonthList}}" wx:key='*this'>{{item}}月</view>
         </picker-view-column>
-        <picker-view-column>
+        <picker-view-column hidden="{{!isDay}}">
           <view class='picker-item' wx:for="{{startDayList}}" wx:key='*this'>{{item}}日</view>
         </picker-view-column>
-        <picker-view-column hidden="{{!hourColumn}}">
+        <picker-view-column hidden="{{!isTime}}">
           <view class='picker-item' wx:for="{{startHourList}}" wx:key='*this'>{{item}}时</view>
         </picker-view-column>
-        <picker-view-column hidden="{{!minColumn}}">
+        <picker-view-column hidden="{{!isMin}}">
           <view class='picker-item' wx:for="{{startMinuteList}}" wx:key='*this'>{{item}}分</view>
         </picker-view-column>
-        <picker-view-column hidden="{{!secColumn}}">
+        <picker-view-column hidden="{{!isSecond}}">
           <view class='picker-item' wx:for="{{startSecondList}}" wx:key='*this'>{{item}}秒</view>
         </picker-view-column>
       </picker-view>
@@ -36,22 +36,22 @@
       <view class='to' style='margin-top: 4px;margin-bottom: 4px;'>至</view>
         <picker-view class='sensorTypePicker' indicator-style='height: 35px;' bindchange="changeEndDateTime" bindpickstart="handlePickStart" bindpickend="handlePickEnd" 
           value="{{endValue}}">
-          <picker-view-column style="min-width: 70px;flex-shrink: 0">
+          <picker-view-column hidden="{{!isYear}}" style="min-width: 70px;flex-shrink: 0">
             <view class='picker-item' wx:for="{{endYearList}}" wx:key='*this' style="min-width: 70px;">{{item}}年</view>
           </picker-view-column>
-          <picker-view-column>
+          <picker-view-column hidden="{{!isMonth}}">
             <view class='picker-item' wx:for="{{endMonthList}}" wx:key='*this'>{{item}}月</view>
           </picker-view-column>
-          <picker-view-column>
+          <picker-view-column hidden="{{!isDay}}">
             <view class='picker-item' wx:for="{{endDayList}}" wx:key='*this'>{{item}}日</view>
           </picker-view-column>
-          <picker-view-column hidden="{{!hourColumn}}" >
+          <picker-view-column hidden="{{!isTime}}" >
             <view class='picker-item' wx:for="{{endHourList}}" wx:key='*this'>{{item}}时</view>
           </picker-view-column>
-          <picker-view-column hidden="{{!minColumn}}">
+          <picker-view-column hidden="{{!isMin}}">
             <view class='picker-item' wx:for="{{endMinuteList}}" wx:key='*this'>{{item}}分</view>
           </picker-view-column>
-          <picker-view-column hidden="{{!secColumn}}">
+          <picker-view-column hidden="{{!isSecond}}">
             <view class='picker-item' wx:for="{{startSecondList}}" wx:key='*this'>{{item}}秒</view>
           </picker-view-column>
       

+ 2 - 2
pages/operation/index.wxml

@@ -1,6 +1,6 @@
 <view class="container">
   <view class="grid col-2">
-    <view bindtap="toRouter" data-url="deviceTest">
+    <!-- <view bindtap="toRouter" data-url="deviceTest">
       <view class="margin-xs padding radius shadow-warp operation-list-cel">
         <image class='item-img' src='../../static/images/my/operate_ico_01@3x.png'></image>
         <text class='item-name'>设备测试</text>
@@ -11,7 +11,7 @@
         <image class='item-img' src='../../static/images/my/operate_ico_01@3x.png'></image>
         <text class='item-name'>设备设置</text>
       </view>
-    </view>
+    </view> -->
     <view bindtap="toRouter" data-url="deviceUnbind">
       <view class="margin-xs padding radius shadow-warp operation-list-cel">
         <image class='item-img' src='../../static/images/my/operate_ico_02@3x.png'></image>

+ 96 - 11
pages/store/add.js

@@ -28,6 +28,11 @@ Page({
    * 页面的初始数据
    */
   data: {
+    selectList:[],
+    multiArray: [], //picker数据
+    value: [0, 0, 0],
+    text: "",
+
     isPickerRender: false,
     isPickerShow: false,
     pickerConfig: {
@@ -50,8 +55,8 @@ Page({
       storeHouseNum: '',
       storeArea: '',
       storeAddress: '',
-      storeContractStart: '',
-      storeContractEnd: '',
+      businessBegin: '',
+      businessEnd: '',
     },
     dataStr: '',
     region: [],
@@ -61,7 +66,7 @@ Page({
    * 生命周期函数--监听页面加载
    */
   onLoad: function (options) {
-
+    this.getChildListByMtLei()
   },
 
   /**
@@ -117,15 +122,17 @@ Page({
   setPickerTime: function (val) {
     console.log(val);
     let data = val.detail;
-    let startTime = utils.formatDate(data.startTime,'yyyy-MM-dd')
-    let endTime = utils.formatDate(data.endTime,'yyyy-MM-dd')
+    let startTime = utils.formatDate(data.startTime,'hh:mm')
+    let endTime = utils.formatDate(data.endTime,'hh:mm')
+    console.log(startTime)
+    console.log(endTime)
     this.setData({
-      ["values.startTime"]: data.startTime,
-      ["values.endTime"]: data.endTime,
+      ["values.startTime"]: startTime,
+      ["values.endTime"]: endTime,
       dataStr: startTime +" ~ "+ endTime
     });
-    this.data.storeInfo.storeContractStart = this.data.values.startTime;
-    this.data.storeInfo.storeContractEnd = this.data.values.endTime;
+    this.data.storeInfo.businessBegin = this.data.values.startTime.replace(/\s+/g,"");
+    this.data.storeInfo.businessEnd = this.data.values.endTime.replace(/\s+/g,"");
   },
   formSubmit: function(e) {
     //表单规则
@@ -145,14 +152,34 @@ Page({
       name: "storeDivide",
       rule: ["required"],
       msg: ["请输入门店分成"]
+    },{
+      name: "mtType",
+      rule: ["required"],
+      msg: ["请输入二级品类"]
     }
-    
   ];
+  var that = this
+  if(!that.data.storeInfo.businessBegin||!that.data.storeInfo.businessEnd){
+    util.toast("请输入营业时间")
+    return;
+  }
+  if(!that.data.storeInfo.twoType){
+    util.toast("请输入二级品类")
+    return;
+  }
+  if(!that.data.storeInfo.storeAddress){
+    util.toast("请输入详细地址")
+    return;
+  }
+
+
+
+
     //进行表单检查
     let formData = e.detail.value;
     let checkRes = form.validation(formData, rules);
     if (!checkRes) {
-      var that = this
+      
       util.request(util.api.addStore, that.data.storeInfo, "POST", false, true,app.globalData.token).then((res)=>{
         if (res.code == 200) {
           wx.navigateTo({
@@ -203,5 +230,63 @@ Page({
     wx.navigateTo({
       url: `plugin://chooseLocation/index?key=${key}&referer=${referer}&location=${location}&category=${category}`
     });
+  },
+
+  picker: function(e) {
+    let value = e.detail.value;
+    if (this.data.selectList.length > 0) {
+      let provice = this.data.selectList[value[0]].name
+      let city = this.data.selectList[value[0]].children[value[1]].name
+      this.setData({
+        text: provice + " " + city ,
+        ["storeInfo.twoType"]: this.data.selectList[value[0]].children[value[1]].id,
+        ["storeInfo.oneType"]: this.data.selectList[value[0]].id
+      })
+    }
+  },
+  toArr(object) {
+    let arr = [];
+    for (let i in object) {
+      arr.push(object[i].name);
+    }
+    return arr;
+  },
+  columnPicker: function(e) {
+    console.log(2)
+    //第几列 下标从0开始
+    let column = e.detail.column;
+    //第几行 下标从0开始
+    let value = e.detail.value;
+
+    if (column === 0) {
+      this.setData({
+        multiArray: [
+          this.data.multiArray[0],
+          this.toArr(this.data.selectList[value].children),
+          // this.toArr(this.data.selectList[value].children[0].children)
+        ],
+        value: [value, 0, 0]
+      })
+    } 
+
+  },
+  //获取美团品类
+  getChildListByMtLei(){
+    util.request(util.api.childListByMtLei, {}, "GET", false, true,app.globalData.token).then((res)=>{
+      if (res.code == 200) {
+        
+        
+        this.setData({
+          selectList:res.result,
+          multiArray: [
+            this.toArr(res.result),
+            this.toArr(res.result[0].children),
+          ]
+        })
+      }else{
+        util.toast("获取不到美团品类")
+      }
+    }).catch((res) => {})
   }
+
 })

+ 26 - 1
pages/store/add.wxml

@@ -14,6 +14,10 @@
           maxlength="50" catchinput="inputedit" data-name="storeInfo.storePrincipal"/>
       </view>
     </tui-list-cell>
+
+  
+
+
     <tui-list-cell hover="{{false}}">
       <view class="tui-line-cell">
         <view class="tui-title"><text style="color:red;">*</text>负责人电话:</view>
@@ -39,6 +43,27 @@
         <input placeholder-class="phcolor" class="tui-input" name="storeDivide" placeholder="请输入门店分成百分比" maxlength="50" catchinput="inputedit" data-name="storeInfo.storeDivide"/>
       </view>
     </tui-list-cell>
+
+
+    <tui-list-cell hover="{{false}}" >
+      <view class="tui-line-cell">
+        <view class="tui-title">二级品类</view>
+        <picker name="mtType" value="{{value}}" mode="multiSelector" bindchange="picker" bindcolumnchange="columnPicker" range="{{multiArray}}" >
+          <text class="tui-input" wx:if="{{text==''}}">请选择二级品类</text>
+          <text class="tui-input" wx:if="{{text!=''}}">{{text}}</text>
+        </picker>
+      </view>
+    </tui-list-cell>
+
+
+    <tui-list-cell hover="{{false}}" bindtap="timePickerShow">
+      <view class="tui-line-cell">
+        <view class="tui-title">营业时间</view>
+        <input placeholder-class="phcolor" class="tui-input" placeholder="请选择起止时间" type="text" disabled="true"
+          value="{{dataStr}}" />
+      </view>
+    </tui-list-cell>
+
     <tui-list-cell hover="{{false}}">
       <view class="tui-line-cell">
         <view class="tui-title">所在地区:</view>
@@ -68,7 +93,7 @@
       <button class="btn-primary btn-gray" hover-class="btn-gray-hover" formType="reset">重置</button>
     </view>
 
-  <time-picker pickerShow="{{isPickerShow}}" id="picker" wx:if="{{isPickerRender}}" bind:hidePicker="pickerHide"
+  <time-picker format="HHmm" pickerShow="{{isPickerShow}}" id="picker" wx:if="{{isPickerRender}}" bind:hidePicker="pickerHide"
     bind:setPickerTime="setPickerTime" config="{{pickerConfig}}"></time-picker>
   </form>
 </view>

+ 97 - 10
pages/store/edit.js

@@ -29,6 +29,11 @@ Page({
    * 页面的初始数据
    */
   data: {
+    selectList:[],
+    multiArray: [], //picker数据
+    value: [0, 0, 0],
+    text: "",
+
     isPickerRender: false,
     isPickerShow: false,
     pickerConfig: {
@@ -51,8 +56,8 @@ Page({
       storeHouseNum: '',
       storeArea: '',
       storeAddress: '',
-      storeContractStart: '',
-      storeContractEnd: '',
+      businessBegin: '',
+      businessEnd: '',
     },
     dataStr: '',
     storeId:'',
@@ -66,6 +71,7 @@ Page({
     this.setData({
       storeId: options.storeId
     })
+    this.getChildListByMtLei()
     this.bindStore()
   },
 
@@ -123,15 +129,16 @@ Page({
   setPickerTime: function (val) {
     console.log(val);
     let data = val.detail;
-    let startTime = utils.formatDate(data.startTime,'yyyy-MM-dd')
-    let endTime = utils.formatDate(data.endTime,'yyyy-MM-dd')
+    let startTime = utils.formatDate(data.startTime,'hh:mm')
+    let endTime = utils.formatDate(data.endTime,'hh:mm')
     this.setData({
-      ["values.startTime"]: data.startTime,
-      ["values.endTime"]: data.endTime,
+      ["values.startTime"]: startTime,
+      ["values.endTime"]: endTime,
       dataStr: startTime +" ~ "+ endTime
     });
-    this.data.storeInfo.storeContractStart = this.data.values.startTime;
-    this.data.storeInfo.storeContractEnd = this.data.values.endTime;
+
+    this.data.storeInfo.businessBegin = this.data.values.startTime.replace(/\s+/g,"");
+    this.data.storeInfo.businessEnd = this.data.values.endTime.replace(/\s+/g,"");
   },
   formSubmit: function(e) {
     //表单规则
@@ -148,11 +155,25 @@ Page({
       rule: ["required", "isMobile"],
       msg: ["请输入负责人手机号", "请输入正确的手机号"]
     }];
+
+    var that = this
+    if(!that.data.storeInfo.businessBegin||!that.data.storeInfo.businessEnd){
+      util.toast("请输入营业时间")
+      return;
+    }
+    if(!that.data.storeInfo.twoType){
+      util.toast("请输入二级品类")
+      return;
+    }
+    if(!that.data.storeInfo.storeAddress){
+      util.toast("请输入详细地址")
+      return;
+    }
+
     //进行表单检查
     let formData = e.detail.value;
     let checkRes = form.validation(formData, rules);
     if (!checkRes) {
-      var that = this
       util.request(util.api.editStore, that.data.storeInfo, "PUT", false, true,app.globalData.token).then((res)=>{
         if (res.code == 200) {
           wx.navigateBack({
@@ -205,9 +226,20 @@ Page({
     var that = this
     util.request(util.api.queryByStoreId, {id:that.data.storeId}, "GET", false, true,app.globalData.token).then((res)=>{
       if (res.code == 200) {
+
+          var oneTypeData = that.data.selectList.filter((e)=>e.id == res.result.oneType );
+          if(oneTypeData!=null&&oneTypeData.length>0){
+            var twoTypeData = oneTypeData[0].children.filter((e)=>e.id == res.result.twoType );
+            this.setData({
+              text: oneTypeData[0].name  + " " + twoTypeData[0].name ,
+            })
+          }
+
+          console.log(66666)
+
         that.setData({
           storeInfo: res.result,
-          dataStr: res.result.storeContractStart +" ~ "+ res.result.storeContractEnd,
+          dataStr: res.result.businessBegin +" ~ "+ res.result.businessEnd,
           region: (res.result.storeArea).split(" ")
         })
         console.log("========================")
@@ -238,5 +270,60 @@ Page({
       wx.navigateTo({
         url: `plugin://chooseLocation/index?key=${key}&referer=${referer}&location=${location}&category=${category}`
       });
+    },
+    
+  picker: function(e) {
+    let value = e.detail.value;
+    if (this.data.selectList.length > 0) {
+      let provice = this.data.selectList[value[0]].name
+      let city = this.data.selectList[value[0]].children[value[1]].name
+      this.setData({
+        text: provice + " " + city ,
+        ["storeInfo.twoType"]: this.data.selectList[value[0]].children[value[1]].id,
+        ["storeInfo.oneType"]: this.data.selectList[value[0]].id
+      })
+    }
+  },
+  toArr(object) {
+    let arr = [];
+    for (let i in object) {
+      arr.push(object[i].name);
     }
+    return arr;
+  },
+  columnPicker: function(e) {
+    console.log(2)
+    //第几列 下标从0开始
+    let column = e.detail.column;
+    //第几行 下标从0开始
+    let value = e.detail.value;
+
+    if (column === 0) {
+      this.setData({
+        multiArray: [
+          this.data.multiArray[0],
+          this.toArr(this.data.selectList[value].children),
+          // this.toArr(this.data.selectList[value].children[0].children)
+        ],
+        value: [value, 0, 0]
+      })
+    } 
+
+  },
+  //获取美团品类
+  getChildListByMtLei(){
+    util.request(util.api.childListByMtLei, {}, "GET", false, true,app.globalData.token).then((res)=>{
+      if (res.code == 200) {
+        this.setData({
+          selectList:res.result,
+          multiArray: [
+            this.toArr(res.result),
+            this.toArr(res.result[0].children),
+          ]
+        })
+      }else{
+        util.toast("获取不到美团品类")
+      }
+    }).catch((res) => {})
+  }
 })

+ 20 - 1
pages/store/edit.wxml

@@ -40,6 +40,25 @@
         <input placeholder-class="phcolor" class="tui-input" name="storeDivide" placeholder="请输入门店分成百分比" type="number" maxlength="50" catchinput="inputedit" value="{{storeInfo.storeDivide}}" data-name="storeInfo.storeDivide"/>
       </view>
     </tui-list-cell>
+
+    <tui-list-cell hover="{{false}}" >
+      <view class="tui-line-cell">
+        <view class="tui-title">二级品类</view>
+        <picker name="mtType" value="{{value}}" mode="multiSelector" bindchange="picker" bindcolumnchange="columnPicker" range="{{multiArray}}" >
+          <text class="tui-input" wx:if="{{text==''}}">请选择二级品类</text>
+          <text class="tui-input" wx:if="{{text!=''}}">{{text}}</text>
+        </picker>
+      </view>
+    </tui-list-cell>
+
+    <tui-list-cell hover="{{false}}" bindtap="timePickerShow">
+      <view class="tui-line-cell">
+        <view class="tui-title">营业时间</view>
+        <input placeholder-class="phcolor" class="tui-input" placeholder="请选择起止时间" type="text" disabled="true"
+          value="{{dataStr}}" />
+      </view>
+    </tui-list-cell>
+
     <tui-list-cell hover="{{false}}">
       <view class="tui-line-cell">
         <view class="tui-title">所在地区:</view>
@@ -70,7 +89,7 @@
       <button class="btn-primary btn-red" hover-class="btn-hover" formType="delete" type="primary" data-id="" bindtap="delete">删除</button>
     </view>
 
-  <time-picker pickerShow="{{isPickerShow}}" id="picker" wx:if="{{isPickerRender}}" bind:hidePicker="pickerHide"
+  <time-picker format="HHmm" pickerShow="{{isPickerShow}}" id="picker" wx:if="{{isPickerRender}}" bind:hidePicker="pickerHide"
     bind:setPickerTime="setPickerTime" config="{{pickerConfig}}"></time-picker>
   </form>
 </view>

+ 3 - 1
utils/util.js

@@ -256,7 +256,9 @@ const utils = {
     deviceTypeList:'/api/mgVmDeviceType/list',
     getDictByCode:'/api/sysDict/getDictByCode',
     replenishment: 'api/device/replenishment',
-    mgVmStoreProductSkuList:'/api/mgVmStoreProductSku/list'
+    mgVmStoreProductSkuList:'/api/mgVmStoreProductSku/list',
+
+    childListByMtLei:'/sys/category/childListByMtLei'
   },
   staticDomain:'https://mgvm.oss-cn-beijing.aliyuncs.com/',