123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125 |
- // index.js 我的地址
- var tcity = require("../../utils/citys.js");
- // addressDefault :设为默认地址 1为默认
- var addressList = [
-
- ];
- Page({
- data: {
- addressList: addressList,
- isSelect: false,
- nickName: '',
- userInfoAvatar: '',
- sex: '',
- province: '',
- city: '',
- provinces: [],
- province: "",
- citys: [],
- city: "",
- countys: [],
- county: '',
- value: [0, 0, 0],
- values: [0, 0, 0],
- condition: false,
- flag: 0,
- hidden : 'hidden'
- },
- onLoad: function () {
- wx.showNavigationBarLoading()
- var that = this;
-
- var host = getApp().globalData.servsers;
- var un_id = getApp().globalData.un_id;
- var openid = getApp().globalData.openid;
- if ((un_id == undefined || un_id == '' || un_id == null) || (openid == undefined || openid == '' || openid == null)) {
- wx.navigateTo({
- url: '/pages/authorize/authorize?link=selectAddress',
- })
- } else {
- wx.request({
- url: host + "/adressapi/adressview",
- data: {
- user_id: un_id
- },
- method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
- header: {
- 'Accept': 'application/json'
- },
- success: function (res) {
- that.setData({
- addressList: res.data.rows
- });
- if (res == null || res.data == null) {
- console.error('网络请求失败');
- return;
- }
- wx.hideNavigationBarLoading(
- that.setData({
- hidden: ''
- })
- )
- }
- });
- }
-
- },
- onShow:function(e){
- // var listLength = addressList.length;
- // var defaultData = [];
- // var count = 0;
- // for (var i = 1; i < listLength; i++) {//判断是否有默认地址
- // defaultData[i] = addressList[i].addressDefault;
- // if (defaultData[i] == 1) {
- // this.setData({
- // 'selectnum': i
- // })
- // count++;
- // }
- // }
- // if (listLength == 1){
- // this.setData({
- // 'selectnum': 0
- // })
- // }else{
- // if (count == 0){
- // this.setData({
- // 'selectnum': 0
- // })
- // }
- // }
- },
- selectAddress: function (options){//勾选地址
- var that = this
- var id = options.currentTarget.dataset.id;
- var province = options.currentTarget.dataset.province;
- var city = options.currentTarget.dataset.city;
- var area = options.currentTarget.dataset.area;
- var consignee = options.currentTarget.dataset.consignee;
- var phone = options.currentTarget.dataset.phone;
- var adress = options.currentTarget.dataset.adress;
- var pages = getCurrentPages();
- var currPage = pages[pages.length - 1]; //当前页面
- var prevPage = pages[pages.length - 2]; //上一个页面
-
- //if (prevPage.route == 'pages/confirmOrder/confirmOrder'){
- prevPage.setData({
- province: province,
- city: city,
- area: area,
- adress: adress,
- consignee: consignee,
- phone: phone
- });
- wx.navigateBack();
- //}
- }
-
- })
|