Selaa lähdekoodia

快速添加联系人

zhaoxiaohai 2 vuotta sitten
vanhempi
commit
e4dfe3ab3f

+ 88 - 0
packageA/setclient/modules/contacts/quickly/index.js

@@ -0,0 +1,88 @@
+const _Http = getApp().globalData.http;
+
+Page({
+    data: {
+        sys_enterpriseid: "",
+        parems: {
+            id: '20221102110003',
+            content: {
+                nocache: true,
+                pageNumber: 1,
+                pageSize: 20,
+                pageTotal: 1,
+                total: 0,
+                where: {
+                    "condition": "",
+                }
+            }
+        },
+        list: [],
+        radio: "",
+        acitonItem: {},
+    },
+    onLoad(options) {
+        if (options.sys_enterpriseid) this.setData({
+            sys_enterpriseid: options.sys_enterpriseid
+        });
+        this.getList();
+    },
+    /* 默认添加 */
+    created() {
+        wx.redirectTo({
+            url: '/packageA/setclient/modules/contacts/add/index?sys_enterpriseid=' + this.data.sys_enterpriseid,
+        })
+    },
+    /* 快速添加 */
+    quickly() {
+        console.log(this.data.acitonItem)
+        wx.redirectTo({
+            url: `/packageA/setclient/modules/contacts/add/index?sys_enterpriseid=${this.data.sys_enterpriseid}&data=${JSON.stringify(this.data.acitonItem)}`,
+        })
+    },
+    onClick(e) {
+        const {
+            item
+        } = e.currentTarget.dataset;
+        delete(item.tag1)
+        this.setData({
+            radio: item.sys_phonebookid,
+            acitonItem: item
+        })
+    },
+    onSearch({
+        detail
+    }) {
+        this.setData({
+            'parems.content.where.condition': detail ? detail : ""
+        });
+        this.getList(true);
+    },
+    onClear() {
+        this.setData({
+            'parems.content.where.condition': ""
+        });
+        this.getList(true);
+    },
+    getList(init = false) {
+        const parems = this.data.parems;
+        if (init) parems.content.pageNumber = 1;
+        if (parems.content.pageNumber > parems.content.pageTotal) return;
+        _Http.basic(parems).then(res => {
+            console.log("通讯录列表", res)
+            if (res.msg != '成功') return wx.showToast({
+                title: res.data,
+                icon: "none"
+            });
+            parems.content.pageNumber = res.pageNumber + 1;
+            parems.content.pageTotal = res.pageTotal;
+            parems.content.total = res.total;
+            this.setData({
+                list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data),
+                parems
+            })
+        })
+    },
+    onReachBottom() {
+        this.getList();
+    },
+})

+ 7 - 0
packageA/setclient/modules/contacts/quickly/index.json

@@ -0,0 +1,7 @@
+{
+    "usingComponents": {
+        "van-radio": "@vant/weapp/radio/index",
+        "van-radio-group": "@vant/weapp/radio-group/index"
+    },
+    "navigationBarTitleText": "选择联系人"
+}

+ 95 - 0
packageA/setclient/modules/contacts/quickly/index.scss

@@ -0,0 +1,95 @@
+.item {
+    display: flex;
+    width: 100vw;
+    height: 120rpx;
+    background: #FFFFFF;
+    align-items: center;
+
+    .radio {
+        padding: 0 30rpx;
+        flex-shrink: 0;
+    }
+
+    .user {
+        display: flex;
+        flex: 1;
+        align-items: center;
+        height: 100%;
+        box-sizing: border-box;
+        border-bottom: 1px solid #ddd;
+
+        .portrait {
+            width: 80rpx;
+            height: 80rpx;
+            background-color: #E7EEFF;
+            border-radius: 50%;
+            text-align: center;
+            line-height: 80rpx;
+            font-size: 28rpx;
+            font-family: PingFang SC-Regular, PingFang SC;
+            color: #3874F6;
+            flex-shrink: 0;
+        }
+
+        .main {
+            height: 80rpx;
+            margin-left: 20rpx;
+
+            .label {
+                height: 42rpx;
+                font-size: 30rpx;
+                font-family: PingFang SC-Regular, PingFang SC;
+                color: #333333;
+            }
+
+            .phone {
+                height: 34rpx;
+                font-size: 24rpx;
+                font-family: PingFang SC-Regular, PingFang SC;
+                color: #999999;
+                margin-top: 4rpx;
+            }
+        }
+    }
+}
+
+.footer {
+    width: 750rpx;
+    height: 130rpx;
+    display: flex;
+    align-items: center;
+    justify-content: flex-end;
+    box-sizing: border-box;
+    position: fixed;
+    background: #FFFFFF;
+    box-shadow: 0px -4rpx 16rpx 2rpx rgba(150, 157, 165, 0.16);
+    bottom: 0;
+    padding-right: 30rpx;
+
+    .base {
+        width: 156rpx;
+        height: 90rpx;
+        border-radius: 8rpx;
+        box-sizing: border-box;
+    }
+
+    .add {
+        background: #FFFFFF;
+        border-radius: 8rpx;
+        border: 2rpx solid #CCCCCC;
+        font-size: 28rpx;
+        font-family: PingFang SC-Bold, PingFang SC;
+        font-weight: bold;
+        color: #666666;
+        margin-right: 20rpx;
+    }
+
+    .confirm {
+        background: #3874F6;
+        font-size: 28rpx;
+        font-family: PingFang SC-Bold, PingFang SC;
+        font-weight: bold;
+        color: #FFFFFF;
+        padding: 0;
+    }
+}

+ 25 - 0
packageA/setclient/modules/contacts/quickly/index.wxml

@@ -0,0 +1,25 @@
+<van-search shape="round" placeholder="请输入搜索关键词" bind:search="onSearch" bind:clear="onClear" />
+<view style="height: 20rpx;" />
+<van-radio-group value="{{ radio }}">
+    <navigator class="item" url="#" wx:for="{{list}}" wx:key="item.sys_phonebookid" data-item="{{item}}" bindtap="onClick">
+        <view class="radio">
+            <van-radio name="{{item.sys_phonebookid}}" icon-size="28rpx" />
+        </view>
+        <view class="user">
+            <view class="portrait">
+                {{item.name[0]}}
+            </view>
+            <view class="main">
+                <view class="label">{{item.name}}</view>
+                <view class="phone">{{item.phonenumber}}</view>
+            </view>
+        </view>
+    </navigator>
+</van-radio-group>
+<My_empty wx:if="{{list.length==0}}" />
+
+<view style="height: 130rpx;" />
+<view class="footer">
+    <van-button custom-class='base add' bindtap="created">创建\n联系人</van-button>
+    <van-button custom-class='base confirm' disabled='{{!radio}}' bind:click='quickly'>确定添加</van-button>
+</view>