ソースを参照

删除shopping下的地址管理,合并到个人主页的地址管理中

Menethil 7 年 前
コミット
3ccc429808

+ 0 - 2
litemall-wx/app.json

@@ -29,8 +29,6 @@
     "pages/category/category",
     "pages/cart/cart",
     "pages/shopping/checkout/checkout",
-    "pages/shopping/address/address",
-    "pages/shopping/addressAdd/addressAdd",
     "pages/goods/goods",
     "pages/about/about"
   ],

+ 2 - 2
litemall-wx/config/api.js

@@ -1,10 +1,10 @@
 // 以下是业务服务器API地址
 // 本机开发时使用
-// var WxApiRoot = 'http://localhost:8082/wx/';
+ var WxApiRoot = 'http://localhost:8082/wx/';
 // 局域网测试使用
 // var WxApiRoot = 'http://192.168.0.101:8082/wx/';
 // 云平台部署时使用
- var WxApiRoot = 'http://122.152.206.172:8082/wx/';
+// var WxApiRoot = 'http://122.152.206.172:8082/wx/';
 // 云平台上线时使用
 // var WxApiRoot = 'https://www.example.com/wx/';
 

+ 0 - 49
litemall-wx/pages/shopping/address/address.js

@@ -1,49 +0,0 @@
-var util = require('../../../utils/util.js');
-var api = require('../../../config/api.js');
-var app = getApp();
-
-Page({
-  data: {
-    addressList: [],
-  },
-  onLoad: function (options) {
-    // 页面初始化 options为页面跳转所带来的参数
-  },
-  onReady: function () {
-    // 页面渲染完成
-  },
-  onShow: function () {
-    // 页面显示
-    this.getAddressList();
-  },
-  getAddressList (){
-    let that = this;
-    util.request(api.AddressList).then(function (res) {
-      if (res.errno === 0) {
-        that.setData({
-          addressList: res.data
-        });
-      }
-    });
-  },
-  addressAddOrUpdate (event) {
-    wx.navigateTo({
-      url: '/pages/shopping/addressAdd/addressAdd?id=' + event.currentTarget.dataset.addressId
-    })
-  },
-  selectAddress(event){
-    try {
-      wx.setStorageSync('addressId', event.currentTarget.dataset.addressId);
-    } catch (e) {
-
-    }
-
-    wx.navigateBack();
-  },
-  onHide: function () {
-    // 页面隐藏
-  },
-  onUnload: function () {
-    // 页面关闭
-  }
-})

+ 0 - 3
litemall-wx/pages/shopping/address/address.json

@@ -1,3 +0,0 @@
-{
-  "navigationBarTitleText": "地址管理"
-}

+ 0 - 22
litemall-wx/pages/shopping/address/address.wxml

@@ -1,22 +0,0 @@
-<view class="container">
-    <view class="address-list" wx:if="{{ addressList.length > 0 }}">
-        <view class="item" wx:for="{{addressList}}" wx:key="id" bindtap="selectAddress" data-address-id="{{item.id}}">
-            <view class="l">
-                <view class="name">{{item.name}}</view>
-                <view class="default" wx:if="{{item.isDefault}}">默认</view>
-            </view>
-            <view class="c">
-                <view class="mobile">{{item.mobile}}</view>
-                <view class="address">{{item.detailedAddress}}</view>
-            </view>
-            <view class="r">
-                <image catchtap="addressAddOrUpdate" data-address-id="{{item.id}}" class="del" src="/static/images/edit-address.png"></image>
-            </view>
-        </view>
-    </view>
-    <view class="empty-view" wx:if="{{ addressList.length <= 0 }}">
-      <image class="icon" src="http://yanxuan.nosdn.127.net/hxm/yanxuan-wap/p/20161201/style/img/icon-normal/noAddress-26d570cefa.png"></image>
-      <text class="text">收货地址在哪里</text>
-    </view>
-    <view class="add-address" bindtap="addressAddOrUpdate" data-address-id="0">新建</view>
-</view>

+ 0 - 132
litemall-wx/pages/shopping/address/address.wxss

@@ -1,132 +0,0 @@
-page{
-    height: 100%;
-    width: 100%;
-    background: #f4f4f4;
-}
-
-.container{
-  height: 100%;
-  width: 100%;
-}
-
-.address-list{
-    padding-left: 31.25rpx;
-    background: #fff url(http://yanxuan.nosdn.127.net/hxm/yanxuan-wap/p/20161201/style/img/icon-normal/address-bg-bd30f2bfeb.png) 0 0 repeat-x;
-    background-size: auto 10.5rpx;
-    margin-bottom: 90rpx;
-}
-
-.address-list .item{
-    height: 156.55rpx;
-    align-items: center;
-    display: flex;
-    border-bottom: 1rpx solid #DCD9D9;
-}
-
-.address-list .item:last-child{
-
-    border-bottom: none;
-}
-
-.address-list .l{
-    width: 125rpx;
-    height: 80rpx;
-    overflow: hidden;
-}
-
-.address-list .name{
-    width: 125rpx;
-    height: 43rpx;
-    font-size: 29rpx;
-    color: #333;
-    margin-bottom: 5.2rpx;
-        text-overflow: ellipsis;
-    white-space: nowrap;
-    overflow: hidden;
-}
-
-.address-list .default{
-    width: 62.5rpx;
-    height: 33rpx;
-    line-height: 28rpx;
-    text-align: center;
-    font-size: 20rpx;
-    color: #b4282d;
-    border: 1rpx solid #b4282d;
-    visibility: visible;
-}
-
-
-.address-list .c{
-    flex: 1;
-    height: auto;
-    overflow: hidden;
-}
-
-.address-list .mobile{
-
-    height: 29rpx;
-    font-size: 29rpx;
-    line-height: 29rpx;
-    overflow: hidden;
-    color: #333;
-    margin-bottom: 6.25rpx;
-}
-
-.address-list .address{
-    height: 37rpx;
-    font-size: 25rpx;
-    line-height: 37rpx;
-    overflow: hidden;
-    color: #666;
-}
-
-.address-list .r{
-    width: 52rpx;
-    height: auto;
-    overflow: hidden;
-    margin-right: 16.5rpx;
-}
-
-.address-list .del{
-    display: block;
-    width: 52rpx;
-    height: 52rpx;
-}
-
-.add-address{
-    background: #b4282d;
-    text-align: center;
-    width: 100%;
-    height: 99rpx;
-    line-height: 99rpx;
-    position: fixed;
-    border-radius: 0;
-    border: none;
-    color: #fff;
-    font-size: 29rpx;
-    bottom: 0;
-    left:0;
-}
-
-.empty-view{
-  height: 100%;
-  width: 100%;
-  display: flex;
-  flex-direction: column;
-  align-items: center;
-  justify-content: center;
-}
-
-.empty-view .icon{
-  height: 248rpx;
-  width: 258rpx;
-  margin-bottom: 10rpx;
-}
-
-.empty-view .text{
-  width: auto;
-  font-size: 28rpx;
-  line-height: 35rpx;
-  color: #999;
-}

+ 0 - 329
litemall-wx/pages/shopping/addressAdd/addressAdd.js

@@ -1,329 +0,0 @@
-var util = require('../../../utils/util.js');
-var api = require('../../../config/api.js');
-var check = require('../../../utils/check.js');
-
-var app = getApp();
-Page({
-  data: {
-    address: {
-      id: 0,
-      pid: 0,
-      provinceId: 0,
-      cityId: 0,
-      areaId: 0,
-      address: '',
-      name: '',
-      mobile: '',
-      isDefault: 0,
-      provinceName:'',
-      cityName: '',
-      areaName: ''
-    },
-    addressId: 0,
-    openSelectRegion: false,
-    selectRegionList: [
-      { id: 0, name: '省份', pid: 0, type: 1 },
-      { id: 0, name: '城市', pid: 0, type: 2 },
-      { id: 0, name: '区县', pid: 0, type: 3 }
-    ],
-    regionType: 1,
-    regionList: [],
-    selectRegionDone: false
-  },
-  bindinputMobile(event) {
-    let address = this.data.address;
-    address.mobile = event.detail.value;
-    this.setData({
-      address: address
-    });
-  },
-  bindinputName(event) {
-    let address = this.data.address;
-    address.name = event.detail.value;
-    this.setData({
-      address: address
-    });
-  },
-  bindinputAddress(event) {
-    let address = this.data.address;
-    address.address = event.detail.value;
-    this.setData({
-      address: address
-    });
-  },
-  bindIsDefault() {
-    let address = this.data.address;
-    address.isDefault = !address.isDefault;
-    this.setData({
-      address: address
-    });
-  },
-  getAddressDetail() {
-    let that = this;
-    util.request(api.AddressDetail, { id: that.data.addressId }).then(function (res) {
-      if (res.errno === 0) {
-        that.setData({
-          address: res.data
-        });
-        
-      }
-    });
-  },
-  setRegionDoneStatus() {
-    let that = this;
-    let doneStatus = that.data.selectRegionList.every(item => {
-      return item.id != 0;
-    });
-
-    that.setData({
-      selectRegionDone: doneStatus
-    })
-
-  },
-  chooseRegion() {
-    let that = this;
-    this.setData({
-      openSelectRegion: !this.data.openSelectRegion
-    });
-
-    //设置区域选择数据
-    let address = this.data.address;
-    if (address.provinceId > 0 && address.cityId > 0 && address.areaId > 0) {
-      let selectRegionList = this.data.selectRegionList;
-      selectRegionList[0].id = address.provinceId;
-      selectRegionList[0].name = address.provinceName;
-      selectRegionList[0].pid = 0;
-
-      selectRegionList[1].id = address.cityId;
-      selectRegionList[1].name = address.cityName;
-      selectRegionList[1].pid = address.pid;
-
-      selectRegionList[2].id = address.areaId;
-      selectRegionList[2].name = address.areaName;
-      selectRegionList[2].pid = address.cityId;
-
-      this.setData({
-        selectRegionList: selectRegionList,
-        regionType: 3
-      });
-
-      this.getRegionList(address.cityId);
-    } else {
-      this.setData({
-        selectRegionList: [
-          { id: 0, name: '省份', pid: 0, type: 1 },
-          { id: 0, name: '城市', pid: 0, type: 2 },
-          { id: 0, name: '区县', pid: 0, type: 3 }
-        ],
-        regionType: 1
-      })
-      this.getRegionList(0);
-    }
-
-    this.setRegionDoneStatus();
-
-  },
-  onLoad: function (options) {
-    // 页面初始化 options为页面跳转所带来的参数
-    if (options.id && options.id != 0) {
-      this.setData({
-        addressId: options.id
-      });
-      this.getAddressDetail();
-    }
-
-  },
-  onReady: function () {
-
-  },
-  selectRegionType(event) {
-    let that = this;
-    let regionTypeIndex = event.target.dataset.regionTypeIndex;
-    let selectRegionList = that.data.selectRegionList;
-
-    //判断是否可点击
-    if (regionTypeIndex + 1 == this.data.regionType || (regionTypeIndex - 1 >= 0 && selectRegionList[regionTypeIndex - 1].id <= 0)) {
-      return false;
-    }
-
-    this.setData({
-      regionType: regionTypeIndex + 1
-    })
-
-    let selectRegionItem = selectRegionList[regionTypeIndex];
-
-    this.getRegionList(selectRegionItem.pid);
-
-    this.setRegionDoneStatus();
-
-  },
-  selectRegion(event) {
-    let that = this;
-    let regionIndex = event.target.dataset.regionIndex;
-    let regionItem = this.data.regionList[regionIndex];
-    let regionType = regionItem.type;
-    let selectRegionList = this.data.selectRegionList;
-    selectRegionList[regionType - 1] = regionItem;
-
-
-    if (regionType != 3) {
-      this.setData({
-        selectRegionList: selectRegionList,
-        regionType: regionType + 1
-      })
-      this.getRegionList(regionItem.id);
-    } else {
-      this.setData({
-        selectRegionList: selectRegionList
-      })
-    }
-
-    //重置下级区域为空
-    selectRegionList.map((item, index) => {
-      if (index > regionType - 1) {
-        item.id = 0;
-        item.name = index == 1 ? '城市' : '区县';
-        item.pid = 0;
-      }
-      return item;
-    });
-
-    this.setData({
-      selectRegionList: selectRegionList
-    })
-
-
-    that.setData({
-      regionList: that.data.regionList.map(item => {
-
-        //标记已选择的
-        if (that.data.regionType == item.type && that.data.selectRegionList[that.data.regionType - 1].id == item.id) {
-          item.selected = true;
-        } else {
-          item.selected = false;
-        }
-
-        return item;
-      })
-    });
-
-    this.setRegionDoneStatus();
-
-  },
-  doneSelectRegion() {
-    if (this.data.selectRegionDone === false) {
-      return false;
-    }
-
-    let address = this.data.address;
-    let selectRegionList = this.data.selectRegionList;
-    address.provinceId = selectRegionList[0].id;
-    address.cityId = selectRegionList[1].id;
-    address.areaId = selectRegionList[2].id;
-    address.provinceName = selectRegionList[0].name;
-    address.cityName = selectRegionList[1].name;
-    address.areaName = selectRegionList[2].name;
-
-    this.setData({
-      address: address,
-      openSelectRegion: false
-    });
-
-  },
-  cancelSelectRegion() {
-    this.setData({
-      openSelectRegion: false,
-      regionType: this.data.regionDoneStatus ? 3 : 1
-    });
-
-  },
-  getRegionList(regionId) {
-    let that = this;
-    let regionType = that.data.regionType;
-    util.request(api.RegionList, { pid: regionId }).then(function (res) {
-      if (res.errno === 0) {
-        that.setData({
-          regionList: res.data.map(item => {
-
-            //标记已选择的
-            if (regionType == item.type && that.data.selectRegionList[regionType - 1].id == item.id) {
-              item.selected = true;
-            } else {
-              item.selected = false;
-            }
-
-            return item;
-          })
-        });
-      }
-    });
-  },
-  cancelAddress() {
-    wx.navigateBack();
-  },
-  saveAddress() {
-    console.log(this.data.address)
-    let address = this.data.address;
-
-    if (address.name == '') {
-      util.showErrorToast('请输入姓名');
-
-      return false;
-    }
-
-    if (address.mobile == '') {
-      util.showErrorToast('请输入手机号码');
-      return false;
-    }
-
-
-    if (address.areaId == 0) {
-      util.showErrorToast('请输入省市区');
-      return false;
-    }
-
-    if (address.address == '') {
-      util.showErrorToast('请输入详细地址');
-      return false;
-    }
-
-    if (!check.isValidPhone(address.mobile)) {
-      util.showErrorToast('手机号不正确');
-      return false;
-    }
-
-    let that = this;
-    util.request(api.AddressSave, {
-      id: address.id,
-      name: address.name,
-      mobile: address.mobile,
-      provinceId: address.provinceId,
-      cityId: address.cityId,
-      areaId: address.areaId,
-      address: address.address,
-      isDefault: address.isDefault,
-    }, 'POST').then(function (res) {
-      if (res.errno === 0) {
-        try {
-          wx.setStorageSync('addressId', res.data);
-        } catch (e) {
-
-        }
-        wx.navigateBack();
-      }
-    });
-
-  },
-  onShow: function () {
-    // 页面显示
-
-  },
-  onHide: function () {
-    // 页面隐藏
-
-  },
-  onUnload: function () {
-    // 页面关闭
-
-  }
-})

+ 0 - 3
litemall-wx/pages/shopping/addressAdd/addressAdd.json

@@ -1,3 +0,0 @@
-{
-  "navigationBarTitleText": "编辑地址"
-}

+ 0 - 39
litemall-wx/pages/shopping/addressAdd/addressAdd.wxml

@@ -1,39 +0,0 @@
-<view class="add-address">
-    <view class="add-form">
-        <view class="form-item">
-            <input class="input" bindinput="bindinputName" placeholder="姓名" value="{{address.name}}" auto-focus/>
-        </view>
-        <view class="form-item">
-            <input class="input" bindinput="bindinputMobile" value="{{address.mobile}}" placeholder="手机号码"/>
-        </view>
-        <view class="form-item">
-            <input class="input" value="{{address.provinceName + address.cityName + address.areaName}}" disabled="true" bindtap="chooseRegion" placeholder="省份、城市、区县"/>
-        </view>
-        <view class="form-item">
-            <input class="input" bindinput="bindinputAddress" value="{{address.address}}" placeholder="详细地址, 如街道、楼盘号等"/>
-        </view>
-        <view class="form-default">
-            <text bindtap="bindIsDefault" class="default-input {{address.isDefault == 1 ? 'selected' : ''}}">设为默认地址</text>
-        </view>
-    </view>
-
-    <view class="btns">
-        <button class="cannel" bindtap="cancelAddress">取消</button>
-        <button class="save" bindtap="saveAddress">保存</button>
-    </view>
-
-    <view class="region-select" wx:if="{{openSelectRegion}}">
-      <view class="hd">
-        <view class="region-selected">
-          <view class="item {{item.id == 0 ? 'disabled' : ''}} {{(regionType -1) === index ? 'selected' : ''}}" bindtap="selectRegionType" data-region-type-index="{{index}}" wx:for="{{selectRegionList}}" wx:key="id">{{item.name}}</view>
-        </view>
-        <view class="done {{selectRegionDone ? '' : 'disabled'}}" bindtap="doneSelectRegion">确定</view>
-      </view>
-      <view class="bd">
-        <scroll-view scroll-y class="region-list">
-          <view class="item {{item.selected ? 'selected' : ''}}" bindtap="selectRegion" data-region-index="{{index}}" wx:for="{{regionList}}" wx:key="id">{{item.name}}</view>
-        </scroll-view>
-      </view>
-    </view>
-</view>
-<view class="bg-mask" bindtap="cancelSelectRegion" wx:if="{{openSelectRegion}}"></view>

+ 0 - 177
litemall-wx/pages/shopping/addressAdd/addressAdd.wxss

@@ -1,177 +0,0 @@
-page{
-    height: 100%;
-    background: #f4f4f4;
-}
-.add-address .add-form{
-    background: #fff;
-    width: 100%;
-    height: auto;
-    overflow: hidden;
-}
-
-.add-address .form-item{
-    height: 116rpx;
-    padding-left: 31.25rpx;
-    border-bottom: 1px solid #d9d9d9;
-    display: flex;
-    align-items: center;
-    padding-right: 31.25rpx;
-}
-
-.add-address .input{
-    flex: 1;
-    height: 44rpx;
-    line-height: 44rpx;
-    overflow: hidden;
-}
-
-.add-address .form-default{
-    border-bottom: 1px solid #d9d9d9;
-    height: 96rpx;
-    background: #fafafa;
-    padding-top: 28rpx;
-    font-size: 28rpx;
-}
-
-.default-input{
-    margin: 0 auto;
-    display: block;
-    width: 240rpx;
-    height: 40rpx;
-    padding-left: 50rpx;
-    line-height: 40rpx;
-    background: url(http://yanxuan.nosdn.127.net/hxm/yanxuan-wap/p/20161201/style/img/sprites/checkbox-sed825af9d3-a6b8540d42.png) 1rpx -448rpx no-repeat;
-    background-size: 38rpx 486rpx;
-    font-size: 28rpx;
-}
-
-.default-input.selected{
-    background: url(http://yanxuan.nosdn.127.net/hxm/yanxuan-wap/p/20161201/style/img/sprites/checkbox-sed825af9d3-a6b8540d42.png) 0 -192rpx no-repeat;
-    background-size: 38rpx 486rpx;
-}
-
-.add-address .btns{
-    position: fixed;
-    bottom: 0;
-    left: 0;
-    overflow: hidden;
-    display: flex;
-    height: 100rpx;
-    width: 100%;
-}
-
-.add-address .cannel,.add-address .save{
-    flex: 1;
-    height: 100rpx;
-    text-align: center;
-    line-height: 100rpx;
-    font-size: 28rpx;
-    color: #fff;
-    border:none;
-    border-radius: 0;
-}
-
-.add-address .cannel{
-    background: #333;
-}
-
-.add-address .save{
-    background: #b4282d;
-}
-
-
-.region-select{
-  width: 100%;
-  height: 600rpx;
-  background: #fff;
-  position: fixed;
-  z-index: 10;
-  left:0;
-  bottom: 0;
-}
-
-.region-select .hd{
-  height: 108rpx;
-  width: 100%;
-  border-bottom: 1px solid #f4f4f4;
-  padding: 46rpx 30rpx 0 30rpx;
-}
-
-.region-select .region-selected{
-  float: left;
-  height: 60rpx;
-  display: flex;
-}
-
-.region-select .region-selected .item{
-  max-width: 140rpx;
-  margin-right: 30rpx;
-  text-align: left;
-  line-height: 60rpx;
-  height: 100%;
-  color: #333;
-  font-size: 28rpx;
-  overflow: hidden;
-      text-overflow: ellipsis;
-    white-space: nowrap;
-}
-
-.region-select .region-selected .item.disabled{
-  color: #999;
-}
-
-.region-select .region-selected .item.selected{
-  color: #b4282d;
-}
-
-.region-select .done{
-  float: right;
-  height: 60rpx;
-  width: 60rpx;
-  border: none;
-  background: #fff;
-  line-height: 60rpx;
-  text-align: center;
-  color: #333;
-  font-size: 28rpx;
-}
-
-.region-select .done.disabled{
-  color: #999;
-}
-
-
-
-.region-select .bd{
-  height: 492rpx;
-  width: 100%;
-  padding: 0 30rpx;
-}
-
-.region-select .region-list{
-  height: 492rpx;
-}
-
-.region-select .region-list .item{
-  width: 100%;
-  height: 104rpx;
-  line-height: 104rpx;
-  text-align: left;
-  color: #333;
-  font-size: 28rpx;
-}
-
-.region-select .region-list .item.selected{
-  color: #b4282d;
-}
-
-
-.bg-mask{
-  height: 100%;
-  width: 100%;
-  background: rgba(0, 0, 0, 0.4);
-  position: fixed;
-  top:0;
-  left:0;
-  z-index: 8;
-}

+ 2 - 2
litemall-wx/pages/shopping/checkout/checkout.js

@@ -44,12 +44,12 @@ Page({
   },
   selectAddress() {
     wx.navigateTo({
-      url: '/pages/shopping/address/address',
+      url: '/pages/ucenter/address/address',
     })
   },
   addAddress() {
     wx.navigateTo({
-      url: '/pages/shopping/addressAdd/addressAdd',
+      url: '/pages/ucenter/addressAdd/addressAdd',
     })
   },
   onReady: function () {

+ 30 - 4
litemall-wx/pages/ucenter/address/address.js

@@ -28,9 +28,29 @@ Page({
   },
   addressAddOrUpdate (event) {
     console.log(event)
-    wx.navigateTo({
-      url: '/pages/ucenter/addressAdd/addressAdd?id=' + event.currentTarget.dataset.addressId
-    })
+
+    //返回之前,先取出上一页对象,并设置addressId
+    var pages = getCurrentPages();
+    var prevPage = pages[pages.length - 2];
+
+    if (prevPage.route == "pages/shopping/checkout/checkout") {
+      console.log(event.currentTarget.dataset.addressId);
+      prevPage.setData({
+        addressId: event.currentTarget.dataset.addressId
+      })
+
+      try {
+        wx.setStorageSync('addressId', event.currentTarget.dataset.addressId);
+      } catch (e) {
+
+      }
+
+      wx.navigateBack();
+    } else {
+      wx.navigateTo({
+        url: '/pages/ucenter/addressAdd/addressAdd?id=' + event.currentTarget.dataset.addressId
+      })
+    }
   },
   deleteAddress(event){
     console.log(event.target)
@@ -41,9 +61,15 @@ Page({
       success: function (res) {
         if (res.confirm) {
           let addressId = event.target.dataset.addressId;
-          util.request(api.AddressDelete, { id: addressId }, 'POST').then(function (res) {
+          util.request(api.AddressDelete, {
+            id: addressId
+          }, 'POST').then(function(res) {
             if (res.errno === 0) {
               that.getAddressList();
+              wx.removeStorage({
+                key: 'addressId',
+                success: function(res) {},
+              })
             }
           });
           console.log('用户点击确定')

+ 16 - 0
litemall-wx/pages/ucenter/addressAdd/addressAdd.js

@@ -307,6 +307,22 @@ Page({
       countyName: address.areaName
     }, 'POST').then(function (res) {
       if (res.errno === 0) {
+        //返回之前,先取出上一页对象,并设置addressId
+        var pages = getCurrentPages();
+        var prevPage = pages[pages.length - 2];
+        console.log(prevPage);
+        if (prevPage.route == "pages/shopping/checkout/checkout") {
+          prevPage.setData({
+            addressId: res.data
+          })
+
+          try {
+            wx.setStorageSync('addressId', res.data);
+          } catch (e) {
+
+          }
+          console.log("set address");
+        }
         wx.navigateBack();
       }
     });