1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- // pages/my/address/address.js
- const app =getApp();
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- addressList:[],
- pageindex: 1
- },
- onLoad:function(){
- },
- onShow(){
- this.setData({pageindex: 1})
- this.address()
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- this.setData({pageindex:this.data.pageindex+=1})
- this.address()
- },
-
- addSite(e){
- let {parmise} = e.currentTarget.dataset
- console.log(parmise);
- wx.navigateTo({
- url: './addSite/addSite?parmise='+parmise,
- })
- },
- editSite(e){
- let {parmise} = e.currentTarget.dataset
- console.log(parmise);
- wx.navigateTo({
- url: './addSite/addSite?parmise='+JSON.stringify(parmise),
- })
- },
- //获取地址列表
- address(){
- var that=this;
- app.api.useApi(app.globalData.baseAppUrl + "api/address/index", {
- network_id: 1,
- page: that.data.pageindex
- }, "get").then(function (res) {
- if (res.original.code != 200) {
- wx.showLoading({
- title:res.original.message.msg,
- })
- that.setData({pageindex: that.data.pageindex -= 1})
- } else {
- if (that.data.pageindex == 1) {
- that.setData({addressList: []})
- }
- if (res.original.message.data.data.length > 0) {
- that.setData({addressList: that.data.addressList.concat(res.original.message.data.data)})
- } else {
- that.setData({pageindex: that.data.pageindex -= 1})
- }
- }
- setTimeout(function () {
- wx.hideLoading({
- success: (res) => {},
- })
- }, 2000);
- }).catch(function (err) {
- console.log(222);
- })
- }
- })
|