Code example for dynamically obtaining list object information in a mini program

不言
Release: 2018-10-29 16:49:04
forward
4337 people have browsed it

The content of this article is about code examples for dynamically obtaining list object information in small programs. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.

First the renderings :

Code example for dynamically obtaining list object information in a mini program

Code example for dynamically obtaining list object information in a mini program

##This content Mainly introduces how to dynamically obtain object details in a list: 1. First display the list content:
The list content is still implemented through data binding and chat table rendering, a series of parameters of wx:for set up.

<block>
  <view>
    <!--界面跳转 -->
    <image></image>
    <text>{{item.pf_name}}</text>
    <!-- <text>{{item.pf_id}}</text> -->
  </view>
</block>
Copy after login
Jump function method

goDetail, the object ID to jump to is item.pf_id, and the clicked object is index. Of course, this can also be set as a navigator jump. The difference is that the navigator adds a combination of parameters in the link and passes it to the page, which is suitable for hard-coded content.
2. In view of the dynamic acquisition, it is natural to request background data:

goDetail: function(ev) {
   var that = this;
   var e = ev.currentTarget.dataset.id;
   console.log("++++++",ev,that)
   wx.setStorageSync("people_id", e), wx.navigateTo({
     url: "../detail/detail"
   })
 },
Copy after login
Here the list object

id is stored as cache data and sent to the next page for acquisition. Be sure to print via console.log(" ",ev,that). To test whether the data is obtained or stored. The object details page can be displayed like this:

require("../../utils/util.js"), getApp();
Page({
data: {
  name: "",
  sex: "",
  birthday: "",
  post: "",
  address: "",
  addtime: "",
  phone: "",
  identityCard: "",
  schools: "",
  pspecialty: "",
  diploma: "",
  workingState: "",
  entrytime: "",
  worktime: ""
},
onLoad: function(e) {
  var t = this,
    a = wx.getStorageSync("session_uid"),
    i = wx.getStorageSync("people_id");
  console.log("--------",i,e,a)
  wx.request({
    url: "https://xxxxxxxxxxxxx.com/wx/userinfo/",
    data: {
      pf_id: i,
      Cookie: a
    },
    method: "POST",
    header: {
      "Content-Type": "application/x-www-form-urlencoded"
    },
    success: function(e) {
      console.log("员工数据", e.data.data);
      var a = e.data.data;
      t.setData({
        name: a.pf_name,
        sex: a.pf_sex,
        birthday: a.pf_birthday,
        post: a.m_id_post,
        address: a.pf_address,
        addtime: a.pf_addtime,
        phone: a.pf_phone,
        identityCard: a.pf_identityCard,
        schools: a.pf_schools,
        diploma: a.m_id_diploma,
        pspecialty: a.pf_specialty,
        workingState: a.pf_workingState.state_name,
        entrytime: a.pf_entrytime,
        worktime: a.worktime
      })
    },
    fail: function(e) {}
  })
},
onReady: function() {},
onShareAppMessage: function() {}
});
Copy after login
Send the request information through the parameter ID passed when clicking, get all the information about the object from the server, store it, get it to the front-end page, and display the corresponding. The corresponding field parameters are passed according to the fields set by the background personnel.

Finally you can get the dynamic information of the object.

The above is the detailed content of Code example for dynamically obtaining list object information in a mini program. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:csdn.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!