Pārlūkot izejas kodu

始宁农业小程序:新增系统配置接口

panyong 2 gadi atpakaļ
vecāks
revīzija
c995a72498

+ 5 - 0
htmldev/shiningWxMini/app.js

@@ -100,5 +100,10 @@ App({
         this.globalData.objSystemConfig = data
       }
     } catch (err) {}
+
+    if (this.fetchSystemConfigCallback) {
+      this.fetchSystemConfigCallback()
+      this.fetchSystemConfigCallback = null
+    }
   }
 })

+ 40 - 3
htmldev/shiningWxMini/pages/businessApply/businessApply.js

@@ -28,7 +28,10 @@ Page({
       'shop_remark': '' // 备注
     },
     booLock: false,
-    userInfo: {}
+    userInfo: {},
+    booCountryMsg: false,
+    countryMsgList: [],
+    countryMsgInDefaultIndex: 0
   },
   tempFormKey: '',
   tempPostData: {},
@@ -40,6 +43,9 @@ Page({
     app.fetchUserDataCallback = () => {
       this.bindCallBack()
     }
+    app.fetchSystemConfigCallback = () => {
+      this.setCountryMsgList()
+    }
   },
 
   /**
@@ -53,7 +59,7 @@ Page({
    * 生命周期函数--监听页面显示
    */
   onShow() {
-
+    this.setCountryMsgList()
   },
 
   /**
@@ -290,7 +296,7 @@ Page({
       user_card,
       shop_phone,
       country_msg,
-      shop_address,
+      shop_address
     } = this.getForm()
 
     if (!user_name) {
@@ -342,5 +348,36 @@ Page({
     this.setData({
       booLock: false
     })
+  },
+  setCountryMsgList() {
+    const { country_msg_list } = app.globalData.objSystemConfig
+
+    this.setData({
+      countryMsgList: Array.isArray(country_msg_list) && country_msg_list.length > 0 ? country_msg_list : []
+    })
+  },
+  showCountryMsg() {
+    this.setData({
+      booCountryMsg: true
+    })
+  },
+  hideCountryMsg() {
+    if (this.data.countryMsgList.length > 0) {
+      this.selectComponent('#picker-country-msg').setIndexes([this.data.countryMsgInDefaultIndex])
+    }
+
+    this.setData({
+      booCountryMsg: false
+    })
+  },
+  confirmCountryMsg(event) {
+    const { value, index } = event.detail
+
+    this.setData({
+      'form.country_msg': value,
+      countryMsgInDefaultIndex: index
+    })
+
+    this.hideCountryMsg()
   }
 })

+ 3 - 1
htmldev/shiningWxMini/pages/businessApply/businessApply.json

@@ -1,5 +1,7 @@
 {
   "usingComponents": {
-    "van-uploader": "@vant/weapp/uploader/index"
+    "van-uploader": "@vant/weapp/uploader/index",
+    "van-popup": "@vant/weapp/popup/index",
+    "van-picker": "@vant/weapp/picker/index"
   }
 }

+ 18 - 2
htmldev/shiningWxMini/pages/businessApply/businessApply.wxml

@@ -47,10 +47,11 @@
     <view class="value">
       <input
         value="{{form.country_msg}}"
-        placeholder="请输入村信息"
+        placeholder="请选择村信息"
         placeholder-class="placeholder"
         data-formkey="country_msg"
-        bind:input="setFormValue"></input>
+        disabled="{{true}}"
+        bind:tap="showCountryMsg"></input>
     </view>
   </view>
   <view class="form-item">
@@ -161,3 +162,18 @@
     bind:tap="onSubmit">成为农户
   </button>
 </view>
+  <!--弹窗:村信息选择-->
+<van-popup
+  show="{{ booCountryMsg }}"
+  close-on-click-overlay="{{false}}"
+  round
+  position="bottom"
+  bind:click-overlay="hideCountryMsg">
+  <van-picker
+    id="picker-country-msg"
+    columns="{{ countryMsgList }}"
+    show-toolbar
+    default-index="{{ countryMsgInDefaultIndex }}"
+    bind:cancel="hideCountryMsg"
+    bind:confirm="confirmCountryMsg"/>
+</van-popup>