12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- const WXAPI = require('apifm-wxapi')
- const AUTH = require('../../utils/auth')
- const app = getApp()
- Page({
- data: {
- },
- selectTap: function(e) {
- console.log(e);
- var id = e.currentTarget.dataset.id;
- WXAPI.updateAddress({
- token: wx.getStorageSync('token'),
- id: id,
- isDefault: 'true'
- }).then(function(res) {
- wx.navigateBack({})
- })
- },
- addAddess: function() {
- wx.navigateTo({
- url: "/pages/address-add/index"
- })
- },
- editAddess: function(e) {
- console.log(e);
-
- wx.navigateTo({
- url: "/pages/address-add/index?id=" + e.currentTarget.dataset.id
- })
- },
- onLoad: function() {
- },
- onShow: function() {
- AUTH.checkHasLogined().then(isLogined => {
- if (isLogined) {
- this.initShippingAddress();
- } else {
- AUTH.login(this)
- }
- })
- },
- async initShippingAddress() {
- wx.showLoading({
- title: '',
- })
- const res = await WXAPI.queryAddress(wx.getStorageSync('token'))
- wx.hideLoading({
- success: (res) => {},
- })
- if (res.code == 0) {
- this.setData({
- addressList: res.data
- });
- } else if (res.code == 700) {
- this.setData({
- addressList: null
- });
- } else {
- wx.showToast({
- title: res.msg,
- icon: 'none'
- })
- }
- },
- onPullDownRefresh() {
- this.initShippingAddress()
- wx.stopPullDownRefresh()
- },
- })
|