18016688350 4 anos atrás
pai
commit
6637bca279
4 arquivos alterados com 89 adições e 16 exclusões
  1. 24 2
      pages/store/add.js
  2. 11 0
      pages/store/add.wxml
  3. 44 14
      pages/store/edit.js
  4. 10 0
      pages/store/edit.wxml

+ 24 - 2
pages/store/add.js

@@ -32,7 +32,7 @@ Page({
     multiArray: [], //picker数据
     value: [0, 0, 0],
     text: "",
-
+    dictList:[],
     isPickerRender: false,
     isPickerShow: false,
     pickerConfig: {
@@ -58,6 +58,8 @@ Page({
       businessBegin: '',
       businessEnd: '',
     },
+
+    
     dataStr: '',
     region: [],
   },
@@ -67,6 +69,7 @@ Page({
    */
   onLoad: function (options) {
     this.getChildListByMtLei()
+    this.getDictByCode();
   },
 
   /**
@@ -287,6 +290,25 @@ Page({
         util.toast("获取不到美团品类")
       }
     }).catch((res) => {})
-  }
+  },
+  //配送类型
+  getDictByCode() { 
+    var that = this
+    util.request(util.api.getDictByCode, {code:"peisong_type"}, "GET", false, true,app.globalData.token).then((res) => {
+      if (res.code == 200) {
+        that.setData({
+          dictList: res.result
+        })
+      }
+    }).catch((res) => {})
+  },
+  //选配送类型
+  bindDictPickerChange: function (e) {
+    var item = this.data.dictList[e.detail.value]
+    this.setData({
+      ['storeInfo.peisongType']: item.value,
+      ['storeInfo.peisongTypeName']: item.text
+    })
+  },
 
 })

+ 11 - 0
pages/store/add.wxml

@@ -64,6 +64,17 @@
       </view>
     </tui-list-cell>
 
+    <picker bindchange="bindDictPickerChange" value="{{index}}" range="{{dictList}}" range-key="text">
+      <tui-list-cell hover="{{false}}">
+        <view class="tui-line-cell">
+          <view class="tui-title">配送类型</view>
+          <input placeholder-class="phcolor" class="tui-input" name="peisongType" placeholder="请选择配送类型" type="text" disabled="true"
+            value="{{storeInfo.peisongTypeName}}" />
+        </view>
+      </tui-list-cell>
+    </picker>
+
+
     <tui-list-cell hover="{{false}}">
       <view class="tui-line-cell">
         <view class="tui-title">所在地区:</view>

+ 44 - 14
pages/store/edit.js

@@ -33,7 +33,7 @@ Page({
     multiArray: [], //picker数据
     value: [0, 0, 0],
     text: "",
-
+    dictList:[],
     isPickerRender: false,
     isPickerShow: false,
     pickerConfig: {
@@ -71,8 +71,10 @@ Page({
     this.setData({
       storeId: options.storeId
     })
-    this.getChildListByMtLei()
-    this.bindStore()
+    this.getChildListByMtLei();
+    this.getDictByCode();
+    
+    
   },
 
   /**
@@ -220,28 +222,34 @@ Page({
     this.setData({
       region: e.detail.value
     })
-    this.data.storeInfo.storeArea = this.data.region.join("")
+    this.data.storeInfo.storeArea = this.data.region.join(" ")
   },
   bindStore(){
     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 ,
-            })
-          }
+        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.businessBegin +" ~ "+ res.result.businessEnd,
-          region: (res.result.storeArea).split(" ")
+          region: res.result.storeArea?(res.result.storeArea).split(" "):[]
         })
+        var peisongTypeData = that.data.dictList.filter((e)=>e.value == res.result.peisongType );
+        if(peisongTypeData !=null && peisongTypeData.length>0){
+          that.setData({
+            ['storeInfo.peisongTypeName']:peisongTypeData[0].text,
+          })
+        }
+
         console.log("========================")
         console.log(storeInfo)
       }
@@ -325,5 +333,27 @@ Page({
         util.toast("获取不到美团品类")
       }
     }).catch((res) => {})
-  }
+  },
+
+  //配送类型
+  getDictByCode() { 
+    var that = this
+    util.request(util.api.getDictByCode, {code:"peisong_type"}, "GET", false, true,app.globalData.token).then((res) => {
+      if (res.code == 200) {
+        that.setData({
+          dictList: res.result
+        })
+        this.bindStore();
+      }
+    }).catch((res) => {})
+    
+  },
+  //选配送类型
+  bindDictPickerChange: function (e) {
+    var item = this.data.dictList[e.detail.value]
+    this.setData({
+      ['storeInfo.peisongType']: item.value,
+      ['storeInfo.peisongTypeName']: item.text
+    })
+  },
 })

+ 10 - 0
pages/store/edit.wxml

@@ -59,6 +59,16 @@
       </view>
     </tui-list-cell>
 
+    <picker bindchange="bindDictPickerChange" value="{{index}}" range="{{dictList}}" range-key="text">
+      <tui-list-cell hover="{{false}}">
+        <view class="tui-line-cell">
+          <view class="tui-title">配送类型</view>
+          <input placeholder-class="phcolor" class="tui-input" name="peisongType" placeholder="请选择配送类型" type="text" disabled="true"
+            value="{{storeInfo.peisongTypeName}}" />
+        </view>
+      </tui-list-cell>
+    </picker>
+
     <tui-list-cell hover="{{false}}">
       <view class="tui-line-cell">
         <view class="tui-title">所在地区:</view>