|
@@ -1,4 +1,5 @@
|
|
// pages/my/address/addSite/addSite.js
|
|
// pages/my/address/addSite/addSite.js
|
|
|
|
+const app = getApp();
|
|
Page({
|
|
Page({
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -15,8 +16,8 @@ Page({
|
|
name: '',
|
|
name: '',
|
|
phone: '',
|
|
phone: '',
|
|
address: '',
|
|
address: '',
|
|
-
|
|
|
|
- checked4: false
|
|
|
|
|
|
+ checked4: false,
|
|
|
|
+ id:""
|
|
|
|
|
|
},
|
|
},
|
|
|
|
|
|
@@ -24,11 +25,28 @@ Page({
|
|
* 生命周期函数--监听页面加载
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
*/
|
|
onLoad: function (options) {
|
|
onLoad: function (options) {
|
|
|
|
+ var type = options.parmise == 'add' ? true : false;
|
|
|
|
+ console.log(options.parmise);
|
|
|
|
+ if(!type){
|
|
|
|
+ var parmise = JSON.parse(options.parmise)
|
|
|
|
+
|
|
this.setData({
|
|
this.setData({
|
|
- type: options.parmise == '添加' ? true : false
|
|
|
|
|
|
+ type: type,
|
|
|
|
+ resultInfo: {
|
|
|
|
+ name: parmise.username,
|
|
|
|
+ phone: parmise.phone,
|
|
|
|
+ address: parmise.address,
|
|
|
|
+ checked4: parmise.is_default == 1 ? true : false
|
|
|
|
+ },
|
|
|
|
+ name: parmise.username,
|
|
|
|
+ phone: parmise.phone,
|
|
|
|
+ address: parmise.address,
|
|
|
|
+ checked4: parmise.is_default == 1 ? true : false,
|
|
|
|
+ id:parmise.id,
|
|
})
|
|
})
|
|
- console.log(options);
|
|
|
|
-
|
|
|
|
|
|
+ }else{
|
|
|
|
+ this.setData({type: type})
|
|
|
|
+ }
|
|
if (this.data.type) {
|
|
if (this.data.type) {
|
|
wx.setNavigationBarTitle({
|
|
wx.setNavigationBarTitle({
|
|
title: '添加新地址',
|
|
title: '添加新地址',
|
|
@@ -95,6 +113,88 @@ Page({
|
|
console.log(this.data.checked1, this.data.checked2, this.data.checked3);
|
|
console.log(this.data.checked1, this.data.checked2, this.data.checked3);
|
|
},
|
|
},
|
|
|
|
|
|
|
|
+ addAddress() {
|
|
|
|
+ var that = this;
|
|
|
|
+ app.api.useApi(app.globalData.baseAppUrl + "api/address/create", {
|
|
|
|
+ username: that.data.resultInfo.name,
|
|
|
|
+ phone: that.data.resultInfo.phone,
|
|
|
|
+ address: that.data.resultInfo.address,
|
|
|
|
+ is_default: that.data.resultInfo.checked
|
|
|
|
+
|
|
|
|
+ }, "post").then(function (res) {
|
|
|
|
+ if (res.original.code != 200) {
|
|
|
|
+ wx.showLoading({
|
|
|
|
+ title: res.original.message.msg,
|
|
|
|
+ })
|
|
|
|
+ } else {
|
|
|
|
+ wx.navigateTo({
|
|
|
|
+ url: '/pages/my/address/address',
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ setTimeout(function () {
|
|
|
|
+ wx.hideLoading({
|
|
|
|
+ success: (res) => { },
|
|
|
|
+ })
|
|
|
|
+ }, 2000);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ }).catch(function (err) {
|
|
|
|
+ console.log(222);
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+ del(e) {
|
|
|
|
+ console.log(e);
|
|
|
|
+ app.api.useApi(app.globalData.baseAppUrl + "api/address/del", {
|
|
|
|
+ id:e.target.dataset.id,
|
|
|
|
+ }, "post").then(function (res) {
|
|
|
|
+ if (res.original.code != 200) {
|
|
|
|
+ wx.showLoading({
|
|
|
|
+ title: res.original.message.msg,
|
|
|
|
+ })
|
|
|
|
+ } else {
|
|
|
|
+ wx.navigateTo({
|
|
|
|
+ url: '/pages/my/address/address',
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ setTimeout(function () {
|
|
|
|
+ wx.hideLoading({
|
|
|
|
+ success: (res) => { },
|
|
|
|
+ })
|
|
|
|
+ }, 2000);
|
|
|
|
+
|
|
|
|
|
|
|
|
+ }).catch(function (err) {
|
|
|
|
+ console.log(222);
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+ updateaddr(e){
|
|
|
|
+ var that = this;
|
|
|
|
+ app.api.useApi(app.globalData.baseAppUrl + "api/address/update", {
|
|
|
|
+ username: that.data.resultInfo.name,
|
|
|
|
+ phone: that.data.resultInfo.phone,
|
|
|
|
+ address: that.data.resultInfo.address,
|
|
|
|
+ is_default: that.data.resultInfo.checked,
|
|
|
|
+ id:e.target.dataset.id,
|
|
|
|
|
|
|
|
+ }, "post").then(function (res) {
|
|
|
|
+ if (res.original.code != 200) {
|
|
|
|
+ wx.showLoading({
|
|
|
|
+ title: res.original.message.msg,
|
|
|
|
+ })
|
|
|
|
+ } else {
|
|
|
|
+ wx.navigateTo({
|
|
|
|
+ url: '/pages/my/address/address',
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ setTimeout(function () {
|
|
|
|
+ wx.hideLoading({
|
|
|
|
+ success: (res) => { },
|
|
|
|
+ })
|
|
|
|
+ }, 2000);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ }).catch(function (err) {
|
|
|
|
+ console.log(222);
|
|
|
|
+ })
|
|
|
|
+ }
|
|
})
|
|
})
|