Browse Source

联系人列表

zhaoxiaohai 2 năm trước cách đây
mục cha
commit
59a0ea65f2

+ 40 - 62
packageA/setclient/modules/contacts/list/index.js

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

+ 25 - 3
packageA/setclient/modules/contacts/list/index.scss

@@ -1,12 +1,12 @@
 .item {
     width: 100vw;
-    padding-left: 30rpx;
-    box-sizing: border-box;
     background-color: #ffffff;
-
+    margin-bottom: 20rpx;
     .content {
         padding: 20rpx 0;
+        padding-left: 30rpx;
         border-bottom: 1px solid #DDD;
+        box-sizing: border-box;
 
         .user {
             display: flex;
@@ -68,4 +68,26 @@
             color: #333333;
         }
     }
+
+    .editor {
+        display: flex;
+        justify-content: space-between;
+        align-items: center;
+        width: 100%;
+        height: 80rpx;
+        .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;
+            }
+        }
+    }
 }

+ 13 - 5
packageA/setclient/modules/contacts/list/index.wxml

@@ -1,5 +1,5 @@
-<navigator class="item" url="#" wx:for="{{list}}" wx:key="item.changeuserid" data-item="{{item}}" bindtap="itemClick">
-    <view class="content">
+<view class="item" wx:for="{{list}}" wx:key="item.changeuserid">
+    <navigator url="#" class="content" data-item="{{item}}" bindtap="toDetail">
         <view class="user">
             <view class="portrait">
                 {{item.name[0]}}
@@ -16,7 +16,15 @@
         </view>
         <view class="exp" style="margin-top: 16rpx;">负责人:32131321</view>
         <view class="exp" style="margin-top: 10rpx;">手机号:{{item.phonenumber}}</view>
+    </navigator>
+    <view class="editor">
+        <view />
+        <view class="icon-but" bindtap="handleItem">
+            <navigator url="#" data-item="{{item}}" data-name="call" class="iconfont icon-bodadianhua" />
+            <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>
-</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="取消" />
+
+</view>
+<My_empty wx:if="{{list.length==0}}" />