소스 검색

客户联系人

zhaoxiaohai 2 년 전
부모
커밋
d911cd62f5

+ 2 - 77
packageA/setclient/modules/contacts/index.js

@@ -5,19 +5,6 @@ Component({
     },
     data: {
         list: [],
-        sheet: {
-            actions: [{
-                name: "呼叫"
-            }, {
-                name: "详情"
-            }, {
-                name: "编辑"
-            }, {
-                name: "删除"
-            }],
-            item: {},
-            show: false
-        },
         content: {
             "nacache": true,
             "pageNumber": 1,
@@ -37,7 +24,6 @@ Component({
                 content.pageNumber = 1
                 content.pageTotal = 1
             }
-            if (content.pageNumber > content.pageTotal) return;
             _Http.basic({
                 "id": "20221018150602",
                 content
@@ -57,71 +43,10 @@ Component({
                 })
             })
         },
-        onClick(e) {
-            const {
-                item
-            } = e.currentTarget.dataset;
-            this.setData({
-                "sheet.item": item,
-                "sheet.show": true
-            })
-        },
-        onCancel() {
+        changeTotal() {
             this.setData({
-                "sheet.item": null,
-                "sheet.show": false
+                "content.total": this.data.content.total - 1
             })
-        },
-        onSelect(e) {
-            let item = this.data.sheet.item,
-                that = this;
-            switch (e.detail.name) {
-                case "呼叫":
-                    wx.makePhoneCall({
-                        phoneNumber: item.phonenumber,
-                    })
-                    break;
-                case "删除":
-                    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"
-                                    });
-                                    that.setData({
-                                        list: this.data.list.filter(v => v.contactsid != item.contactsid)
-                                    });
-                                    wx.showToast({
-                                        title: `已删除"${item.name}"!`,
-                                        icon: "none"
-                                    })
-                                })
-                            }
-                        }
-                    })
-                    break;
-                case "编辑":
-                    wx.navigateTo({
-                      url: `/packageA/setclient/modules/contacts/add/index?data=${JSON.stringify(item)}`
-                    })
-                    break;
-                default:
-                    console.log(e.detail.name)
-                    break;
-            }
-            console.log(e)
-            this.onCancel()
         }
     }
 })

+ 3 - 1
packageA/setclient/modules/contacts/index.json

@@ -1,4 +1,6 @@
 {
     "component": true,
-    "usingComponents": {}
+    "usingComponents": {
+        "list": "/packageA/setclient/modules/contacts/list/index"
+    }
 }

+ 0 - 71
packageA/setclient/modules/contacts/index.scss

@@ -1,73 +1,2 @@
 @import "../address/head.scss";
 
-.item {
-    width: 100vw;
-    padding-left: 30rpx;
-    box-sizing: border-box;
-    background-color: #ffffff;
-
-    .content {
-        padding: 20rpx 0;
-        border-bottom: 1px solid #DDD;
-
-        .user {
-            display: flex;
-            width: 100%;
-
-            .portrait {
-                width: 64rpx;
-                height: 64rpx;
-                text-align: center;
-                line-height: 64rpx;
-                background: #3874F6;
-                border-radius: 50%;
-                margin-top: 16rpx;
-                margin-right: 10rpx;
-                flex-shrink: 0;
-                font-size: 24rpx;
-                font-family: PingFang SC-Regular, PingFang SC;
-                color: #FFFFFF;
-            }
-
-            .right {
-                flex: 1;
-
-                .title {
-                    height: 42rpx;
-                    line-height: 42rpx;
-                    font-size: 30rpx;
-                    font-family: PingFang SC-Regular, PingFang SC;
-                    color: #333333;
-
-                    text {
-                        margin-left: 20rpx;
-                        font-size: 24rpx;
-                        font-family: PingFang SC-Regular, PingFang SC;
-                        color: #999999;
-                    }
-                }
-
-                .tap {
-                    text {
-                        display: inline-block;
-                        font-size: 20rpx;
-                        font-family: PingFang SC-Regular, PingFang SC;
-                        color: #FA8C16;
-                        padding: 0 10rpx;
-                        height: 40rpx;
-                        line-height: 38rpx;
-                        background: #FFEFD9;
-                        border-radius: 20rpx;
-                        margin-right: 10rpx;
-                    }
-                }
-            }
-        }
-
-        .exp {
-            font-size: 24rpx;
-            font-family: PingFang SC-Regular, PingFang SC;
-            color: #333333;
-        }
-    }
-}

+ 1 - 23
packageA/setclient/modules/contacts/index.wxml

@@ -12,26 +12,4 @@
     </view>
 </view>
 
-<navigator class="item" url="#" wx:for="{{list}}" wx:key="item.changeuserid" data-item="{{item}}" bindtap="onClick">
-    <view class="content">
-        <view class="user">
-            <view class="portrait">
-                {{item.name[0]}}
-            </view>
-            <view class="right">
-                <view class="title">
-                    {{item.name}}<text>{{item.position}}</text>
-                </view>
-                <view class="tap">
-                    <text>2313123</text>
-                    <text>2313123</text>
-                </view>
-            </view>
-        </view>
-        <view class="exp" style="margin-top: 16rpx;">负责人:32131321</view>
-        <view class="exp" style="margin-top: 10rpx;">手机号:{{item.phonenumber}}</view>
-    </view>
-</navigator>
-<My_empty wx:if="{{list.length==0}}" />
-
-<van-action-sheet show="{{ sheet.show }}" actions="{{ sheet.actions }}" bind:cancel="onCancel" bind:select="onSelect" cancel-text="取消" />
+<list list='{{list}}' contactsid='{{item.contactsid}}' sys_enterpriseid='{{item.sys_enterpriseid}}' bindchangeTotal="changeTotal" />

+ 93 - 0
packageA/setclient/modules/contacts/list/index.js

@@ -0,0 +1,93 @@
+const _Http = getApp().globalData.http;
+Component({
+    properties: {
+        list: Array,
+        contactsid: String,
+        sys_enterpriseid: String,
+        changeTotal: Function
+    },
+    data: {
+        sheet: {
+            actions: [{
+                name: "呼叫"
+            }, {
+                name: "详情"
+            }, {
+                name: "编辑"
+            }, {
+                name: "删除"
+            }],
+            item: {},
+            show: false
+        },
+    },
+    methods: {
+        itemClick(e) {
+            const {
+                item
+            } = e.currentTarget.dataset;
+            this.setData({
+                "sheet.item": item,
+                "sheet.show": true
+            })
+        },
+        onCancel() {
+            this.setData({
+                "sheet.item": null,
+                "sheet.show": false
+            })
+        },
+        onSelect(e) {
+            let item = this.data.sheet.item,
+                that = this;
+            switch (e.detail.name) {
+                case "呼叫":
+                    wx.makePhoneCall({
+                        phoneNumber: item.phonenumber,
+                    })
+                    break;
+                case "删除":
+                    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"
+                                    });
+                                    that.setData({
+                                        list: this.data.list.filter(v => v.contactsid != item.contactsid)
+                                    });
+                                    wx.showToast({
+                                        title: `删除成功!`,
+                                        icon: "none"
+                                    })
+                                    that.triggerEvent("changeTotal")
+                                })
+                            }
+                        }
+                    })
+                    break;
+                case "编辑":
+                    wx.navigateTo({
+                        url: `/packageA/setclient/modules/contacts/add/index?data=${JSON.stringify(item)}`
+                    })
+                    break;
+                default:
+                    console.log(e.detail.name)
+                    break;
+            }
+            console.log(e)
+            this.onCancel()
+        }
+    }
+})

+ 6 - 0
packageA/setclient/modules/contacts/list/index.json

@@ -0,0 +1,6 @@
+{
+    "component": true,
+    "usingComponents": {
+        "van-action-sheet": "@vant/weapp/action-sheet/index"
+    }
+}

+ 71 - 0
packageA/setclient/modules/contacts/list/index.scss

@@ -0,0 +1,71 @@
+.item {
+    width: 100vw;
+    padding-left: 30rpx;
+    box-sizing: border-box;
+    background-color: #ffffff;
+
+    .content {
+        padding: 20rpx 0;
+        border-bottom: 1px solid #DDD;
+
+        .user {
+            display: flex;
+            width: 100%;
+
+            .portrait {
+                width: 64rpx;
+                height: 64rpx;
+                text-align: center;
+                line-height: 64rpx;
+                background: #3874F6;
+                border-radius: 50%;
+                margin-top: 16rpx;
+                margin-right: 10rpx;
+                flex-shrink: 0;
+                font-size: 24rpx;
+                font-family: PingFang SC-Regular, PingFang SC;
+                color: #FFFFFF;
+            }
+
+            .right {
+                flex: 1;
+
+                .title {
+                    height: 42rpx;
+                    line-height: 42rpx;
+                    font-size: 30rpx;
+                    font-family: PingFang SC-Regular, PingFang SC;
+                    color: #333333;
+
+                    text {
+                        margin-left: 20rpx;
+                        font-size: 24rpx;
+                        font-family: PingFang SC-Regular, PingFang SC;
+                        color: #999999;
+                    }
+                }
+
+                .tap {
+                    text {
+                        display: inline-block;
+                        font-size: 20rpx;
+                        font-family: PingFang SC-Regular, PingFang SC;
+                        color: #FA8C16;
+                        padding: 0 10rpx;
+                        height: 40rpx;
+                        line-height: 38rpx;
+                        background: #FFEFD9;
+                        border-radius: 20rpx;
+                        margin-right: 10rpx;
+                    }
+                }
+            }
+        }
+
+        .exp {
+            font-size: 24rpx;
+            font-family: PingFang SC-Regular, PingFang SC;
+            color: #333333;
+        }
+    }
+}

+ 22 - 0
packageA/setclient/modules/contacts/list/index.wxml

@@ -0,0 +1,22 @@
+<navigator class="item" url="#" wx:for="{{list}}" wx:key="item.changeuserid" data-item="{{item}}" bindtap="itemClick">
+    <view class="content">
+        <view class="user">
+            <view class="portrait">
+                {{item.name[0]}}
+            </view>
+            <view class="right">
+                <view class="title">
+                    {{item.name}}<text>{{item.position}}</text>
+                </view>
+                <view class="tap">
+                    <text>2313123</text>
+                    <text>2313123</text>
+                </view>
+            </view>
+        </view>
+        <view class="exp" style="margin-top: 16rpx;">负责人:32131321</view>
+        <view class="exp" style="margin-top: 10rpx;">手机号:{{item.phonenumber}}</view>
+    </view>
+</navigator>
+<My_empty wx:if="{{list.length==0}}" />
+<van-action-sheet show="{{ sheet.show }}" actions="{{ sheet.actions }}" bind:cancel="onCancel" bind:select="onSelect" cancel-text="取消" />