Asynchronous application development of small micro-channel synchronous rotation

the onLoad: function (Options) { 

    // perform synchronization 
    return  new new Promise (function (Resolve, Reject) { 
      wx.checkSession ({ 
        Success: function (RES) {Resolve (RES);}, 
        Fail: function (RES) { 

          // well the synchronization code, the code to perform code execution 
          var that = the this ; 
          wx.request ({ 
            URL: Util.exeCatalog (), // merely exemplary, not actual interface address 
            Data: { 
              the ParentId: 129 , 
            }, 
            Method : ' the GET ' , 
            header: { 
              ' Content-type ': ' File application / json '  // Default 
            }, 
            Success (RES) { 
              var QA = res.data; // Get data json 

              var qaarr = []; // definition array 
              for ( var I in QA) { 

                var qacontentarr = []; // definition array 

                wx.request ({ 
                  URL: Util.exeContent (), // merely exemplary, not actual interface address 
                  Data: { 
                    the CatalogId: QA [I] .CatalogId 
                  }, 
                  Method: ' the GET ', 
                  Header: { 
                    ' Content-type ' : ' file application / json '  // Default 
                  }, 
                  Success (RESS) { 

                    qacontentarr = []; 

                    var qacontent = ress.data; // Get json data 
                    for ( var I in qacontent) {
                       var qaarrjson = {}; 
                      qaarrjson [ ' zi and ' ] = qacontent [I] .Title; 
                      qaarrjson [ ' Li'] = qacontent[i].Description;
                      qacontentarr.push(qaarrjson);
                    }

                  }
                })

                var qaarrjson = {};
                qaarrjson['id'] = i;
                qaarrjson['hidden'] = true;
                qaarrjson['title'] = qa[i].CatalogName;
                qaarrjson['contentH'] = qacontentarr;
                qaarrjson['image'] = '/images/js.png';
                qaarr.push(qaarrjson);

              }

              that.setData({
                systemList: qaarr
              })

            }
          })

        }

      })
    })

  }

Synchronization code

the onLoad: function (Options) { 

    // perform synchronization 
    return  new new Promise (function (Resolve, Reject) { 
      wx.checkSession ({ 
        Success: function (RES) {Resolve (RES);}, 
        Fail: function (RES) { 
             // the method of execution 
        } 
      }) 
    })     

}

 

Guess you like

Origin www.cnblogs.com/zpblogs/p/11323008.html