diff --git a/app.json b/app.json index 8013d00..09c5994 100644 --- a/app.json +++ b/app.json @@ -14,8 +14,7 @@ "pages/user/order_detail/order_detail", "pages/user/userinfo/userinfo", "pages/user/coupon/coupon", - "pages/user/checkcoupon/checkcoupon", - "pages/user/add_address/add_address", + "pages/user/checkcoupon/checkcoupon", "pages/user/express/express", "pages/activity/seckill_list/seckill_list", "pages/activity/pind_list/pind_list", @@ -232,7 +231,8 @@ "pages/user/return_goods_info/return_goods_info", "pages/user/return_goods_list/return_goods_list", "pages/user/return_goods/return_goods", - "pages/user/address_list/address_list" + "pages/user/address_list/address_list", + "pages/user/add_address/add_address" ] } diff --git a/packageF/pages/user/add_address/add_address.js b/packageF/pages/user/add_address/add_address.js new file mode 100644 index 0000000..ba94069 --- /dev/null +++ b/packageF/pages/user/add_address/add_address.js @@ -0,0 +1,203 @@ +var s = function(s) { + return s && s.__esModule ? s : { + default: s + }; +}(require("../../../../utils/regions/Regions.js")), e = getApp(), a = e.globalData.setting,os=a,t = e.request; +var ut = require("../../../../utils/util.js"), oo = e.globalData; + +Page({ + data: { + url: a.url, + resourceUrl: a.resourceUrl, + iurl: a.imghost, + address: null, + isnew:0, + is_op_co:false,//switch开关 + disabled:0 + }, + onLoad: function(s) { + var a = this,th=a; + var is_e = ut.isEmptyObject(s); + this.setData({ + address: s, isnew:is_e, + }), e.getUserInfo(function(s) { + a.setData({ + user: s + }); + th.initRegions(); + }) + }, + + onReachBottom: function () { + if (this.data.total <= 6) return; + if (this.data.ismore) return; + this.requestAddressList(); + }, + + requestAddressList: function () { + var e = this; + t.get(e.data.url + "/api/weshop/useraddress/page", { + data: { store_id: os.stoid, user_id: oo.user_id, page: e.data.curpage, pageSize: 20 }, + success: function (t) { + e.data.curpage++; + var arr1 = e.data.addresses; + var arr2 = t.data.data.pageData; + var arr3 = [...arr1, ...arr2]; + + var ismore = 0; + if (arr3.length == t.data.data.total) ismore = 1 + + e.setData({ + addresses: arr3, total: t.data.data.total, ismore: ismore + }), wx.stopPullDownRefresh(); + } + }); + }, + initRegions: function() { + var e = this; + new s.default(this, "regions", { + endAreaLevelCall: function(s, a, t) { + console.log("initRegions"); + console.log(t); + Object.assign(e.data.address, t), e.setData({ + "disabled": 0, + "address.province_name": e.data.address.province_name, + "address.city_name": e.data.address.city_name, + "address.district_name": e.data.address.district_name, + "address.twon_name": e.data.address.twon_name, + "address.more_address": + e.data.address.province_name + "-" + e.data.address.city_name + "-" + e.data.address.district_name + +"-"+e.data.address.twon_name, + }); + console.log(e.data.address); + } + }); + }, + //-----------添加或者编辑----------- + submitAddress: function (s) { + var a = this.data.address, b = a, th = this; + Object.assign(a, s.detail.value), a.is_default = Number(a.is_default); + a.store_id = os.stoid; + + //判断用户名是否为空 + var cs = th.check(a.consignee); + if (cs != 1) { + return getApp().my_warnning("收货姓名不能为空", 0, th); + } + + var ob = ut.check_mobile(a.mobile); + if (ob.code != 1) { + return getApp().my_warnning(ob.title, 0, th); + } + + if (a.more_address == null || a.more_address == undefined || a.more_address == "") { + getApp().my_warnning("请选择地区", 0, th); + return false; + } + //判断地址是否为空 + var add = th.check(a.address); + if (add != 1) { + return getApp().my_warnning("详细地址不能为空", 0, th); + } + + //判断是不是空对象 + //--------如果是修改地址---------- + if (!th.data.isnew) { + if (a.is_default == 1) { + t.put("/api/weshop/useraddress/update", { + data: { user_id: oo.user_id, is_default: 0 }, + success: function (s) { + t.put("/api/weshop/useraddress/updateById", { + data: a, + success: function (s) { + e.showSuccess(s.data.msg, function () { + wx.navigateBack(); + }); + } + }); + } + }); + + } else { + t.put("/api/weshop/useraddress/updateById", { + data: a, + success: function (s) { + e.showSuccess(s.data.msg, function () { + wx.navigateBack(); + }); + } + }); + } + + } else { + a['user_id'] = oo.user_id; + a['store_id'] = os.stoid; + + + if (a.is_default == 1) { + t.put("/api/weshop/useraddress/update", { + data: { user_id: oo.user_id, is_default: 0 }, + success: function (s) { + + //-----新增地址------- + t.post("/api/weshop/useraddress/save", { + data: a, + success: function (s) { + e.showSuccess(s.data.msg, function () { + wx.navigateBack(); + }); + } + }); + + } + }) + } else { + + //-----新增地址------- + t.post("/api/weshop/useraddress/save", { + data: a, + success: function (s) { + e.showSuccess(s.data.msg, function () { + wx.navigateBack(); + }); + } + }); + } + + + + } + }, + + //---------删除收货地址------------ + deleteAddress: function() { + var s = this.data.address.address_id; + s && wx.showModal({ + title: "确定删除?", + success: function(a) { + a.confirm && t.delete("/api/weshop/useraddress/del/" + oo.user_id+"/"+s, { + success: function(s) { + e.showSuccess("删除成功", function() { + wx.navigateBack(); + }, 500); + } + }); + } + }); + }, + //是否是默认地址 + bind_is_op_co:function(e){ + var i = e.detail; + this.setData({ + is_op_co:i + }) + console.log(i) + }, + check:function(as){ + var code = 1; + if(as===''){ + code = -1; + } + return code; +} +}); \ No newline at end of file diff --git a/packageF/pages/user/add_address/add_address.json b/packageF/pages/user/add_address/add_address.json new file mode 100644 index 0000000..5394760 --- /dev/null +++ b/packageF/pages/user/add_address/add_address.json @@ -0,0 +1,7 @@ +{ + "navigationBarTitleText": "收货地址", + "enablePullDownRefresh": false, + "usingComponents": { + "warn": "/components/long_warn/long_warn" + } +} \ No newline at end of file diff --git a/packageF/pages/user/add_address/add_address.wxml b/packageF/pages/user/add_address/add_address.wxml new file mode 100644 index 0000000..1a61698 --- /dev/null +++ b/packageF/pages/user/add_address/add_address.wxml @@ -0,0 +1,41 @@ + + + + + +
+ + + 收货人 + + + + 手机号码 + + + + 所在地区 + {{address.more_address==null?'省市区县,乡镇等':address.more_address}} + + + + + + 详细地址 + + + + 设为默认地址 + + + + + + +
+
+ + + diff --git a/packageF/pages/user/add_address/add_address.wxss b/packageF/pages/user/add_address/add_address.wxss new file mode 100644 index 0000000..f40f148 --- /dev/null +++ b/packageF/pages/user/add_address/add_address.wxss @@ -0,0 +1,135 @@ +page { + background: rgb(255, 255, 255); +} + +.topbcolor { + width: 100%; + height: 7rpx; + background-color: rgb(245, 245, 245); +} + +.item { + display: flex; + align-items: center; + padding: 0 31rpx; + width: 100%; + box-sizing: border-box; + border-bottom: 1rpx #f5f5f5 solid; + height: 98rpx; + position: relative; + font-size: 26rpx; + padding-top: 16rpx; +} + +.item-name { + display: flex; + align-items: center; + height: 100%; + width: 104rpx; +} + +.item-img { + height: 100%; + align-items: center; +} + +.item_default { + display: flex; + justify-content: space-between; +} + +.item_default .item-name { + width: 200rpx; +} + +.item-input { + display: flex; + height: 100%; + margin-left: 40rpx; + /* word-break: keep-all; + white-space: nowrap; + overflow: hidden; */ + text-overflow: ellipsis; + color: rgb(0, 0, 0); + align-items: center; + width: 74%; +} + +.item-inputaddress { + color: rgb(199, 199, 199); + margin-left: 40rpx; +} + +.detailed { + height: 193rpx; + padding-bottom: 95rpx; + display: flex; + padding: 0 31rpx; + padding-top: 41rpx; + font-size: 26rpx; + border-bottom: 1rpx #f5f5f5 solid; +} + +.detailed .detailed_item-name { + width: 137rpx; +} + +.detailed_item-input { + margin-left: 40rpx; + height: auto; + width: 100%; + min-height: 40rpx; + padding-bottom: 28rpx; +} + +.item-switch { + zoom: 0.7; +} + +.item-switch::before { + width: 80rpx !important; + height: 35rpx !important; + zoom: 1; +} + +.arrow { + position: absolute; + right: 26rpx; + width: 26rpx; + height: 26rpx; + padding-top: 28rpx; +} + +.address-btns { + position: absolute; + display: flex; + justify-content: center; + align-items: center; + bottom: 80rpx; + width: 100%; +} + +.delete-btn { + display: flex; + justify-content: center; + align-items: center; + width: 285rpx; + height: 60rpx; + border-radius: 40rpx; + font-size: 27rpx; + color: rgb(0, 0, 0); + border: 1rpx solid rgb(210, 210, 210); +} + +.submit-btn { + display: flex; + justify-content: center; + align-items: center; + width: 285rpx; + height: 59rpx; + background-color: #e30000; + font-size: 27rpx; + color: rgb(255, 255, 255); + border-radius: 40rpx; +} +@import "../../../../utils/regions/regions.wxss"; diff --git a/packageF/pages/user/address_list/address_list.js b/packageF/pages/user/address_list/address_list.js new file mode 100644 index 0000000..b71ad20 --- /dev/null +++ b/packageF/pages/user/address_list/address_list.js @@ -0,0 +1,198 @@ +var e = getApp(), t = require("../../../../utils/request.js"), os = e.globalData.setting, oo = e.globalData, t = e.request; + +Page({ + data: { + url: e.globalData.setting.url, + resourceUrl: e.globalData.setting.resourceUrl, + iurl: e.globalData.setting.imghost, + addresses: [], + operate: null, + curpage: 1, + total: 0, + ismore: 0, + is_back:0, //有没有跳转 + isloading:0, + is_address_read:0 + }, + onLoad: function (e) { + var pages = getCurrentPages(); + var prevPage = pages[pages.length - 2]; //上一个页面 + //直接调用上一个页面的setData()方法,把数据存到上一个页面中去 + prevPage.setData({ + is_zy: 1 + }) + //清空is_pick_up + getApp().request.put("/api/weshop/useraddress/updatePickUp", { + data: {user_id: getApp().globalData.user_id, is_pickup: 0}, + success: function (s) { + } + }); + + this.data.operate = e.operate; + }, + onShow: function () { + var is_back=getApp().globalData.is_cart_old; + if (is_back) this.setData({ is_back: is_back}) + + this.data.curpage = 1; + this.data.addresses = []; + this.requestAddressList(); + console.log(this.data.addresses) + }, + + onReachBottom: function () { + if (this.data.total <= 6) return; + if (this.data.ismore) return; + this.requestAddressList(); + }, + + requestAddressList: function () { + var tt = Math.random() * 100 + var e = this; + t.get(e.data.url + "/api/weshop/useraddress/page", { + data: { store_id: os.stoid, user_id: oo.user_id, page: e.data.curpage, pageSize: 20, t: tt }, + success: function (t) { + e.data.curpage++; + var arr1 = e.data.addresses; + var arr2 = t.data.data.pageData; + var arr3 = [...arr1, ...arr2]; + var ismore = 0; + if (arr3.length == t.data.data.total) ismore = 1 + e.setData({ + addresses: arr3, total: t.data.data.total, ismore: ismore, + is_address_read:1 + }), wx.stopPullDownRefresh(); + } + }); + }, + + /*----------编辑地址----------*/ + editAddress: function (e) { + var t = this.getAddressData(e.currentTarget.dataset.id), s = ""; + for (var a in t) s += (0 != s.length ? "&" : "?") + a + "=" + t[a]; + s && wx.navigateTo({ + url: "/packageF/pages/user/add_address/add_address" + s + }); + }, + + /*-----选择地址返回确认------*/ + selectAddress: function (e) { + if (null != this.data.operate) { + oo.baddr = e.currentTarget.dataset.item; + wx.navigateBack(); + } + }, + + getAddressData: function (e) { + var t = this.data.addresses; + for (var s in t) if (t[s].address_id == e) break; + return s ? t[s] : {}; + }, + + go_url: function (e) { + var url = e.currentTarget.dataset.url; + getApp().goto(url); + + }, + //判断是否选择 + add_is_pickup:function(e){ + + if(this.data.is_back==0) return false; + + var th = this; + var index = e.currentTarget.dataset.ind; + var a = this.data.addresses[index]; + + if (th.data.isloading) return; + th.data.isloading=1; + + t.put("/api/weshop/useraddress/updatePickUp", { + data: { user_id: oo.user_id, is_pickup: 0 }, + isShowLoading:0, + success: function (s) { + + a.is_pickup = 1; + t.put("/api/weshop/useraddress/updateById", { + data: a, + isShowLoading: 0, + success: function (s) { + + th.data.isloading=0 + if (th.data.is_back) { + wx.navigateBack({}); + } + + },fail: function (t) { + th.data.isloading = 0; + } + }); + }, + fail: function (t) { + th.data.isloading = 0; + } + }); + + + + } , + + //获取微信地址 + get_wx:function(){ + var th=this; + wx.getSetting({ + success(res) { + getApp().globalData.no_clear=1; + console.log("vres.authSetting['scope.address']:", res.authSetting['scope.address']); + if (res.authSetting['scope.address']) { + getApp().globalData.no_clear=1; + wx.chooseAddress({ + success(res) { + th.save_wx_addr(res); + } + }) + + } else { + if (res.authSetting['scope.address'] == false) { + getApp().globalData.no_clear=1; + wx.openSetting({ + success(res) {} + }) + } else { + + getApp().globalData.no_clear=1; + wx.chooseAddress({ + success(res) { + th.save_wx_addr(res); + } + }) + } + } + } + }) + }, + + save_wx_addr:function (res) { + var pd={},th=this; + pd.store_id=os.stoid; + pd.user_id=getApp().globalData.user_id; + pd.userName=res.userName; + pd.provinceName=res.provinceName; + pd.countryName=res.countyName; + pd.cityName=res.cityName; + pd.detailInfo=res.detailInfo; + pd.postalCode=res.postalCode; + pd.telNumber=res.telNumber; + getApp().request.promisePost("/api/weshop/useraddress/saveWx",{data:pd}).then(res=>{ + if(res.data.code==0){ + getApp().my_warnning("保存成功",1,th); + setTimeout(function () { + th.onShow(); + },1000) + } + }) + + }, + + + +}); \ No newline at end of file diff --git a/packageF/pages/user/address_list/address_list.json b/packageF/pages/user/address_list/address_list.json new file mode 100644 index 0000000..467c798 --- /dev/null +++ b/packageF/pages/user/address_list/address_list.json @@ -0,0 +1,6 @@ +{ + "navigationBarTitleText": "收货地址", + "usingComponents": { + "warn": "/components/long_warn/long_warn" + } +} \ No newline at end of file diff --git a/packageF/pages/user/address_list/address_list.wxml b/packageF/pages/user/address_list/address_list.wxml new file mode 100644 index 0000000..794f1cf --- /dev/null +++ b/packageF/pages/user/address_list/address_list.wxml @@ -0,0 +1,78 @@ + + + + + + + + + 暂无收货地址 + + + + + + + + 获取微信地址 + + + + + + 新建收货地址 + + + + + + + + + + + + + + + + + + + + + {{item.consignee}} + + {{item.mobile}} + 默认地址 + + + + {{item.more_address}} {{item.address}} + + + + + + + + + + + + + + + + + 获取微信地址 + + + + + + 新建收货地址 + + + + \ No newline at end of file diff --git a/packageF/pages/user/address_list/address_list.wxss b/packageF/pages/user/address_list/address_list.wxss new file mode 100644 index 0000000..d20eeaa --- /dev/null +++ b/packageF/pages/user/address_list/address_list.wxss @@ -0,0 +1,247 @@ +/* 没有收货地址时的样式 */ + +.nothing { + width: 100%; + font-size: 31rpx; +} + +.nothing image { + width: 299rpx; + height: 283rpx; + margin-top: 161rpx; +} + +.nothing .nothingaddress { + color: rgb(251, 65, 66); + margin-top: 35rpx; +} + +.nothing .address { + margin-top: 61rpx; +} + +.nothing .address navigator { + color: rgb(255, 255, 255); + background-color: rgb(251, 65, 66); + width: 256rpx; + height: 55rpx; + border-radius: 30rpx; + display: flex; + align-items: center; + justify-content: center; +} + +/* page { + margin-bottom: 200rpx; +} + +.address-box { + background-color: white; + padding: 25rpx 0 25rpx 25rpx; + font-size: 28rpx; + border-bottom: 3rpx #f8f8f8 solid; +} + +.address-user { + box-sizing: border-box; + float: left; + width: 150rpx; +} + +.N-name { + font-size: 30rpx; + padding-bottom: 20rpx; + word-break: keep-all; + white-space: nowrap; + text-overflow: ellipsis; + overflow: hidden; +} + +.default { + color: white; + background-color: red; + padding: 4rpx; + width: fit-content; + border-radius: 6rpx; +} + +.address-info { + box-sizing: border-box; + float: left; + width: 480rpx; + padding-left: 10rpx; +} + +.mobile { + padding-bottom: 25rpx; +} + +.address { + height: 70rpx; + overflow: hidden; +} + +.address-edit { + box-sizing: border-box; + width: 95rpx; + float: left; + text-align: center; + padding-top: 32rpx; +} + +.address-edit>image { + width: 36rpx; + height: 42rpx; +} + +.address-create { + width: 50%; + text-align: center; + position: fixed; + bottom: 80rpx; + left: 25%; +} + +.create-btn { + font-size: 28rpx; + color: white; + background-color: #f23030; + border-radius: 10rpx; + text-align: center; + line-height: 80rpx; + display: block; +} */ + +page { + margin-bottom: 200rpx; +} + +.topbcolor { + width: 100%; + height: 7rpx; + background-color: rgb(245, 245, 245); +} + +.container { + margin-top: 7rpx; +} + +.container .address-box { + width: 100%; +} + +.container .address-box .address-user { + display: flex; + justify-content: center; + width: 100%; + border-bottom: 2rpx solid rgb(245, 245, 245); + height: 180rpx; + align-items: center; +} + +.container .address-box .address-user .icon { + padding-right: 20rpx; + display: flex; + align-items: center; + height: 100%; +} + +.container .address-box .address-user .no_xuanze { + width: 31rpx; + height: 31rpx; + border-radius: 50%; + border: 1rpx solid; +} + +.container .address-box .address-user .address { + width: 530rpx; +} + +.container .address-box .address-user .address .user { + display: flex; + align-items: center; + width: 500rpx; + font-weight: bold; + font-size: 31rpx; + color: rgb(40, 36, 33); +} + +.container .address-box .address-user .address .user .userName { + overflow: hidden; + text-overflow: ellipsis; + display: -webkit-box; + -webkit-box-orient: vertical; + -webkit-line-clamp: 1; + max-width: 149rpx; +} + +.container .address-box .address-user .address .user .userPhone { + margin-left: 41rpx; +} + +.container .address-box .address-user .address .user .default { + display: flex; + width: 105rpx; + height: 31rpx; + background-color: rgb(239, 22, 51); + justify-content: center; + font-size: 20rpx; + color: rgb(255, 255, 253); + border-radius: 8rpx; + margin-left: 21rpx; + line-height: 31rpx; +} + +.container .address-box .address-user .address .ShippingAddress { + font-size: 24rpx; + color: rgb(41, 38, 33); + height: 66rpx; +} + +.container .address-box .address-user .edit { + display: flex; + justify-content: center; + margin-left: 60rpx; + height: 100%; + align-items: center; +} + +.container .address-box .address-user .edit image { + width: 41rpx; + height: 38rpx; + align-items: center; +} + +.container .new { + width: 86%; + display: flex; + position: fixed; + bottom: 0rpx; + height: 204rpx; + align-items: center; + background-color: rgb(255, 255, 255); + margin-left:7% +} + +.container .new .add { + margin-right: 10rpx; +} + +.container navigator { + display: flex; + width: 300rpx; + height: 62rpx; + background-color: rgb(239, 22, 51); + border-radius: 40rpx; + justify-content: center; + align-items: center; + color: rgb(255, 255, 255); + font-size: 27rpx; +} + +.container navigator.ye{ + background-color: #fc872d; +} +.nothing .address navigator.ye{ + background-color: #fc872d; +} diff --git a/pages/user/address_list/address_list.js b/pages/user/address_list/address_list.js index a6c1960..51f1e5c 100644 --- a/pages/user/address_list/address_list.js +++ b/pages/user/address_list/address_list.js @@ -71,7 +71,7 @@ Page({ var t = this.getAddressData(e.currentTarget.dataset.id), s = ""; for (var a in t) s += (0 != s.length ? "&" : "?") + a + "=" + t[a]; s && wx.navigateTo({ - url: "/pages/user/add_address/add_address" + s + url: "/packageF/pages/user/add_address/add_address" + s }); }, diff --git a/pages/user/address_list/address_list.wxml b/pages/user/address_list/address_list.wxml index 619915a..794f1cf 100644 --- a/pages/user/address_list/address_list.wxml +++ b/pages/user/address_list/address_list.wxml @@ -16,7 +16,7 @@ 获取微信地址 - + + 新建收货地址 @@ -69,7 +69,7 @@ 获取微信地址 - + + 新建收货地址