xiaohaizhao 2 тижнів тому
батько
коміт
e9c767a4a4

+ 30 - 1
pages/address/index.js

@@ -37,8 +37,15 @@ Page({
       });
       content.pageNumber = res.pageNumber + 1;
       content.pageTotal = res.pageTotal;
+      res.data = res.data.filter(v => v.type != '收货')
+      let list = res.pageNumber == 1 ? res.data : this.data.list.concat(res.data),
+        selected = "";
+      try {
+        selected = list.find(v => v.isdefault).contactsid
+      } catch (error) {}
       this.setData({
-        list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data)
+        list,
+        selected
       })
     })
   },
@@ -50,6 +57,28 @@ Page({
     this.data.content.where.condition = detail;
     this.getList(true);
   },
+  // 修改默认
+  radioChange({
+    detail
+  }) {
+    let list = this.data.list,
+      data = list.find(v => v.contactsid == detail)
+    if (data.isdefault == 1) return;
+    data.isdefault = 1;
+    _Http.basic({
+      "id": "20221009155703",
+      "content": data
+    }, false).then(res => {
+      console.log(res)
+      if (res.code != '1') return wx.showToast({
+        title: res.data,
+        icon: "none"
+      });
+      this.setData({
+        list
+      })
+    })
+  },
   onClear(e) {
     this.data.content.where.condition = "";
     this.getList(true);

+ 2 - 1
pages/address/index.json

@@ -1,5 +1,6 @@
 {
   "usingComponents": {
-    "List": "./modules/list/index"
+    "van-radio": "@vant/weapp/radio/index",
+    "van-radio-group": "@vant/weapp/radio-group/index"
   }
 }

+ 114 - 0
pages/address/index.scss

@@ -0,0 +1,114 @@
+// @import "./index.skeleton.wxss";
+
+page {
+	height: 100vh;
+	overflow: hidden;
+}
+
+.total {
+	height: 60rpx;
+	line-height: 60rpx;
+	font-size: 24rpx;
+	font-family: PingFang SC-Regular, PingFang SC;
+	color: #666666;
+	padding-left: 30rpx;
+}
+
+.item {
+	display: flex;
+	flex-wrap: wrap;
+	align-items: center;
+	width: 100vw;
+	padding: 20rpx 30rpx 0;
+	background-color: #FFFFFF;
+	box-sizing: border-box;
+	border-bottom: 1rpx solid #DDDDDD;
+	margin-bottom: 20rpx;
+	overflow: hidden;
+
+	.main {
+		width: 100%;
+		padding-right: 20rpx;
+		box-sizing: border-box;
+		padding-bottom: 20rpx;
+		border-bottom: 1px solid #DDDDDD;
+
+		.title {
+			height: 40rpx;
+			line-height: 40rpx;
+			font-size: 28rpx;
+			font-family: PingFang SC-Semibold, PingFang SC;
+			font-weight: 600;
+			color: #333333;
+		}
+
+		.subfield {
+			margin-top: 6rpx;
+			height: 34rpx;
+			line-height: 34rpx;
+			font-size: 24rpx;
+			color: #999999;
+		}
+	}
+
+	.editor {
+		display: flex;
+		justify-content: space-between;
+		align-items: center;
+		width: 100%;
+		padding: 10rpx 0;
+
+		.radio {
+			font-size: 24rpx;
+			font-family: PingFang SC-Regular, PingFang SC;
+			color: #666666;
+			margin-left: -10rpx;
+		}
+
+		.icon-but {
+			padding-right: 30rpx;
+
+			navigator {
+				display: inline-block;
+				width: 60rpx;
+				line-height: 60rpx;
+				text-align: center;
+				margin-left: 30rpx;
+				width: 32px;
+				color: #707070;
+			}
+		}
+	}
+}
+
+
+.footer {
+	display: flex;
+	justify-content: space-between;
+	align-items: center;
+	padding: 0 30rpx;
+	position: fixed;
+	width: 100vw;
+	height: 130rpx;
+	background: #FFFFFF;
+	box-shadow: 0px -4rpx 16rpx 2rpx rgba(150, 157, 165, 0.16);
+	bottom: 0;
+	box-sizing: border-box;
+
+	.count {
+		font-size: 28rpx;
+		font-family: PingFang SC-Regular, PingFang SC;
+		color: #333333;
+	}
+
+	.but {
+		width: 156rpx;
+		height: 90rpx;
+		background: #3874F6;
+		border-radius: 8rpx;
+		font-size: 28rpx;
+		font-family: PingFang SC-Bold, PingFang SC;
+		font-weight: bold;
+		color: #FFFFFF;
+	}
+}

+ 28 - 1
pages/address/index.wxml

@@ -3,5 +3,32 @@
 </van-search>
 <Yl_ListBox id='ListBox' bind:getlist='getList'>
 	<view style="height: 20rpx;" />
-	<List list="{{list}}" />
+	<van-radio-group value="{{ selected }}" bind:change="radioChange">
+		<view class="item" url="#" wx:for="{{list}}" wx:key="itemno">
+			<navigator class="main" style="padding-left: {{!radio?'10rpx':''}};" data-id="{{item[idname]}}" bindtap="changeResult">
+				<view class="title line-1">{{item.name}}</view>
+				<view class="subfield line-1">
+					收货类型:{{item.type || ' --'}}
+				</view>
+				<view class="subfield line-1">
+					手机号码:{{item.phonenumber || ' --'}}
+				</view>
+				<view class="subfield line-1">
+					省市县:{{item.province + item.city + item.county || " --"}}
+				</view>
+				<view class="subfield line-1">
+					地址:{{ item.address || ' --'}}
+				</view>
+			</navigator>
+			<view class="editor">
+				<van-radio icon-size='14' label-class='radio' name="{{item.contactsid}}">默认收货地址</van-radio>
+				<view class="icon-but" bindtap="handleItem">
+					<navigator url="#" data-item="{{item}}" data-name="edit" class="iconfont icon-dibu-bianji" />
+					<navigator url="#" data-item="{{item}}" data-name="delete" class="iconfont icon-guanlian-shanchu" />
+				</view>
+			</view>
+		</view>
+	</van-radio-group>
+	<view style="height: 130rpx;" />
+	<Yl_Empty wx:if="{{list.length==0}}" />
 </Yl_ListBox>

+ 1 - 20
pages/address/update.js

@@ -50,23 +50,6 @@ Page({
             valueName: "remarks",
             required: false,
             checking: "base"
-        }, {
-            label: "类型",
-            error: false,
-            errMsg: "",
-            type: "radio",
-            value: "配件",
-            placeholder: "类型",
-            valueName: "type",
-            radioList: [{
-                name: "配件",
-                id: "配件"
-            }, {
-                name: "收货",
-                id: "收货"
-            }],
-            required: false,
-            checking: "base"
         }],
         disabled: true
     },
@@ -85,6 +68,7 @@ Page({
             "birthday": "",
             "phonenumber": "",
             "email": "",
+            type: "配件",
             "address": "",
             "remarks": "",
             "workaddress": 1,
@@ -142,9 +126,6 @@ Page({
                     })
                 }
             }, 500)
-
-
-
         })
     },
     /* 表单是否填写完成 */

+ 18 - 0
pages/index/userCenter/index.js

@@ -50,6 +50,24 @@ Component({
 				}
 			})
 		},
+		toMyAddress() {
+			wx.navigateTo({
+				url: `/select/address/index?params=${JSON.stringify({ 
+				"id":20221009155803,
+				"content": {
+					nocache:true,
+					sys_enterpriseid:this.data.userMsg.enterprise.sys_enterpriseid,
+					"pageNumber": 1, 
+					"pageTotal": 1, 
+					"pageSize": 20,
+					"where": {
+						"condition": "",
+						workaddress:1
+						}, 
+				}
+			 })}&radio=true`,
+			});
+		},
 		/* 退出登录 */
 		outLogin() {
 			clearTimeout(downCount);

+ 1 - 1
pages/index/userCenter/index.wxml

@@ -25,7 +25,7 @@
 				</view>
 			</view>
 		</navigator>
-		<navigator class="item" wx:if="{{userMsg.enterprise.sys_enterpriseid}}" url="/pages/address/index?id={{userMsg.enterprise.sys_enterpriseid}}">
+		<navigator class="item" wx:if="{{userMsg.enterprise.sys_enterpriseid}}" bind:tap="toMyAddress">
 			<view class="con">
 				<view class="label">
 					<text class="iconfont icon-a-wodemendianxinxidizhi" style="color: #085CDF;" />

+ 5 - 20
select/address/addAndEdit.js

@@ -38,7 +38,7 @@ Page({
       value: "",
       placeholder: "例: 科创园11栋1103室",
       valueName: "address",
-      required: false,
+      required: true,
       checking: "base"
     }, {
       label: "备注",
@@ -50,23 +50,6 @@ Page({
       valueName: "remarks",
       required: false,
       checking: "base"
-    }, {
-      label: "类型",
-      error: false,
-      errMsg: "",
-      type: "radio",
-      value: "配件",
-      placeholder: "类型",
-      valueName: "type",
-      radioList: [{
-        name: "配件",
-        id: "配件"
-      }, {
-        name: "收货",
-        id: "收货"
-      }],
-      required: false,
-      checking: "base"
     }],
     disabled: true,
     "content": {
@@ -84,6 +67,7 @@ Page({
       "isprimary": 0 //是否为主地址
     },
     tags: [],
+    type: "配件"
   },
   onLoad(options) {
     if (options.sys_enterpriseid) this.setData({
@@ -102,8 +86,8 @@ Page({
         'form[2].value': item.city ? [item.province, item.city, item.county] : "",
         'form[3].value': item.address,
         'form[4].value': item.remarks,
-        'form[5].value': item.type,
         'content.isdefault': item.isdefault,
+        type: item.type || '配件',
         "disabled": false
       })
     };
@@ -117,7 +101,8 @@ Page({
       ...data,
       "province": data.region[0],
       "city": data.region[1],
-      "county": data.region[2]
+      "county": data.region[2],
+      type: this.data.type || '配件'
     };
     delete(content.region);
     _Http.basic({

+ 2 - 1
select/address/index.js

@@ -47,6 +47,7 @@ Page({
         title: res.msg,
         icon: "none"
       })
+      res.data = res.data.filter(v => v.type != '收货')
       let list = res.pageNumber == 1 ? res.data : this.data.list.concat(res.data),
         selected = "";
       try {
@@ -179,7 +180,7 @@ Page({
       console.log("res", res)
       this.selectComponent('#ListBox').RefreshToComplete();
       if (res.code != '1') return;
-      let list = res.data,
+      let list = res.data.filter(v => v.type != '收货'),
         selected = "";
       try {
         selected = list.find(v => v.isdefault).contactsid

+ 1 - 1
select/address/index.json

@@ -3,5 +3,5 @@
     "van-radio": "@vant/weapp/radio/index",
     "van-radio-group": "@vant/weapp/radio-group/index"
   },
-  "navigationBarTitleText": "选择地址"
+  "navigationBarTitleText": "我的地址"
 }

+ 2 - 2
select/address/index.wxml

@@ -1,6 +1,6 @@
 <van-search class="search" value="{{ params.content.where.condition }}" shape="round" placeholder="请输入搜索关键词" bind:search='startSearch' bind:clear='onClear' />
-<view class="total">共{{params.content.total}}个</view>
-
+<view class="total" style="height: 10px;"></view>
+<!-- 共{{params.content.total}}个 -->
 <Yl_ListBox id='ListBox' bind:getlist='getList'>
     <van-radio-group value="{{ selected }}" bind:change="radioChange">
         <view class="item" url="#" wx:for="{{list}}" wx:key="itemno">