瀏覽代碼

客户地址

zhaoxiaohai 2 年之前
父節點
當前提交
31f9d02bde

+ 107 - 0
packageA/setclient/modules/address/list/index.js

@@ -0,0 +1,107 @@
+const _Http = getApp().globalData.http;
+Component({
+    options: {
+        addGlobalClass: true
+    },
+    properties: {
+        list: Array
+    },
+
+    /**
+     * 组件的初始数据
+     */
+    data: {
+        radio: 0, //默认
+    },
+
+    /**
+     * 组件的方法列表
+     */
+    methods: {
+        // 修改默认
+        radioChange({
+            detail
+        }) {
+            let list = this.data.list,
+                data = list.find(v => v.contactsid == detail)
+            _Http.basic({
+                "id": "20221018144702",
+                "content": {
+                    "contactsid": data.contactsid,
+                    "sys_enterpriseid": data.sys_enterpriseid
+                }
+            }, false).then(res => {
+                if (res.msg != '成功') return wx.showToast({
+                    title: res.data,
+                    icon: "none"
+                });
+                list = list.map((v, i) => {
+                    v.isdefault = v.contactsid == data.contactsid ? 1 : 0
+                    return v
+                })
+                this.setData({
+                    list
+                })
+                console.log(list)
+            })
+        }, //处理操作
+        handleItem(e) {
+            const {
+                name,
+                item
+            } = e.target.dataset,
+                that = this;
+            if (!name) return;
+            switch (name) {
+                case 'copy':
+                    let str = `收货人:${item.name}\n手机号码:${item.phonenumber}\n所在地区:${item.province+item.city+item.county}\n详细地址:${item.province+item.city+item.county+item.address}`
+                    wx.setClipboardData({
+                        data: str,
+                    })
+                    break;
+                case 'edit':
+                    wx.navigateTo({
+                        url: '/packageA/setclient/modules/address/add/index?data=' + JSON.stringify(item),
+                    })
+                    break;
+                case 'delete':
+                    wx.showModal({
+                        title: '提示',
+                        content: `是否确认删除"${item.name}"`,
+                        complete: (res) => {
+                            if (res.confirm) {
+                                _Http.basic({
+                                    "id": "20221018145502",
+                                    "content": {
+                                        "contactsid": item.contactsid,
+                                        "sys_enterpriseid": item.sys_enterpriseid
+                                    }
+                                }).then(res => {
+                                    console.log("删除地址", res)
+                                    if (res.msg != '成功') return wx.showToast({
+                                        title: res.data,
+                                        icon: "none"
+                                    });
+                                    wx.showToast({
+                                        title: `删除成功!`,
+                                        icon: "none"
+                                    })
+                                    that.setData({
+                                        list: that.data.list.filter(v => v.contactsid != item.contactsid),
+                                        "content.total": that.data.content.total - 1
+                                    });
+                                })
+                            }
+                        }
+                    })
+                    break;
+            }
+        },
+        initRadio() {
+            let data = this.data.list.find(v => v.isdefault == 1);
+            this.setData({
+                radio: data ? data.contactsid : 0
+            })
+        },
+    }
+})

+ 7 - 0
packageA/setclient/modules/address/list/index.json

@@ -0,0 +1,7 @@
+{
+    "component": true,
+    "usingComponents": {
+        "van-radio": "@vant/weapp/radio/index",
+        "van-radio-group": "@vant/weapp/radio-group/index"
+    }
+}

+ 80 - 0
packageA/setclient/modules/address/list/index.scss

@@ -0,0 +1,80 @@
+
+.add-box {
+    width: 100vw;
+    padding-left: 30rpx;
+    padding-top: 20rpx;
+    box-sizing: border-box;
+    background-color: #fff;
+    margin-bottom: 20rpx;
+
+    .detail {
+        width: 100%;
+        border-bottom: 1px solid #DDDDDD;
+        padding-bottom: 20rpx;
+
+        .label {
+            line-height: 42rpx;
+            font-size: 30rpx;
+            font-family: PingFang SC-Regular, PingFang SC;
+            color: #333333;
+            padding-right: 30rpx;
+
+            .tag {
+                display: inline-block;
+                width: 112rpx;
+                height: 40rpx;
+                text-align: center;
+                background: #E7EEFF;
+                border-radius: 4rpx;
+                font-size: 24rpx;
+                font-family: PingFang SC-Regular, PingFang SC;
+                color: #3874F6;
+                margin-right: 10rpx;
+            }
+        }
+
+        .detail-add {
+            font-size: 24rpx;
+            font-family: PingFang SC-Regular, PingFang SC;
+            color: #333333;
+            margin-top: 20rpx;
+        }
+
+        .principal {
+            font-size: 24rpx;
+            font-family: PingFang SC-Regular, PingFang SC;
+            color: #333333;
+            margin-top: 20rpx;
+        }
+    }
+
+    .editor {
+        display: flex;
+        justify-content: space-between;
+        align-items: center;
+        width: 100%;
+        height: 80rpx;
+
+        .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;
+                height: 60rpx;
+                line-height: 60rpx;
+                text-align: center;
+                margin-left: 30rpx;
+                width: 32px;
+                color: #707070;
+            }
+        }
+    }
+}

+ 25 - 0
packageA/setclient/modules/address/list/index.wxml

@@ -0,0 +1,25 @@
+<van-radio-group value="{{ radio }}" bind:change="radioChange">
+    <view class="add-box" wx:for="{{list}}" wx:key="item.changeuserid">
+        <view class="detail">
+            <view class="label">
+                <view class="tag">8888</view>
+                收货人:{{item.name}}
+            </view>
+            <view class="detail-add">
+                手机号:{{item.phonenumber}}
+            </view>
+            <view class="principal">
+                地址:{{item.province + item.city + item.county + item.address}}
+            </view>
+        </view>
+        <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="copy" class="iconfont icon-a-yingxiaowuliaofuzhi" />
+                <navigator url="#" data-item="{{item}}" data-name="edit" class="iconfont icon-bianji" />
+                <navigator url="#" data-item="{{item}}" data-name="delete" class="iconfont icon-shanchu" />
+            </view>
+        </view>
+    </view>
+</van-radio-group>
+<My_empty wx:if="{{list.length==0}}" />