浏览代码

选择市场活动

codeMan 3 年之前
父节点
当前提交
9d412baeb8

+ 3 - 2
packageA/saleClue/modules/list/list.wxml

@@ -4,8 +4,9 @@
         <text class="line-1">{{item.enterprisename_customer}}</text>
         <view class="status" style="background-color: {{backColor.getColor(item.status)}};">{{item.status}}</view>
     </view>
-    <view class="exp line-1">省市县:{{item.province?item.province+item.city+item.county:"暂无"}}</view>
-    <view class="exp line-1">联系人:<text>{{item.name}}</text></view>
+    <view class="exp line-1">省市县:{{item.province?item.province+item.city+item.county:"--"}}</view>
+    <view class="exp line-1">市场活动:{{item.campaign_name?item.campaign_name:"--"}}</view>
+    <view class="exp line-1">联系人:<text>{{item.name ? item.name : '--'}}</text></view>
     <view class="exp line-1">手机号:<text>{{item.phonenumber || '--'}}</text></view>
     <view class="exp line-1">来源:<text>{{item.cluesource ? item.cluesource : '--'}}</text></view>
 </navigator>

+ 118 - 0
packageA/select/selectActivity/index.js

@@ -0,0 +1,118 @@
+const _Http = getApp().globalData.http;
+Page({
+    data: {
+        item: null, //自定义表单组件使用
+        result: [], //选中结果
+        radio: false, //是否为单选模式
+        idName: 'contactsid', //选择ID
+        list: []
+    },
+    onLoad(options) {
+        if (options.item) {
+            let item = JSON.parse(options.item);
+            this.setData({
+                item,
+                params: item.params,
+                result: item.value.length ? item.value[1] : [],
+                idName:item.idName
+            })
+        };
+        if (options.params) this.setData({
+            params: JSON.parse(options.params)
+        })
+        if (options.idName) this.setData({
+            idName: options.idName
+        })
+        this.setData({
+            radio: options.radio ? true : false
+        })
+        this.getList();
+    },
+    /* 提交 */
+    submit() {
+        let pages = getCurrentPages(), //页面
+            item = this.data.item, //表单
+            result = this.data.result, //选中结果
+            list = this.data.result.map(value => this.data.list.find(v => v[this.data.idName] == value)); //选中列表
+        try {
+            if (item) { //判断是否表单调用,表单的话吧数据交还给表单
+                let page = pages[pages.length - 2].selectComponent(item.model || "#Form");
+                item.value = this.data.radio ? [list[0].name, result] : [list.map(v => v.name), result];
+                page.handleRoute(item);
+            } else if (this.data.params.model) {
+                //判断是否上级页面中的组件调用
+                let page = pages[pages.length - 2].selectComponent(this.data.params.model);
+                page.handleSelectContacts(result, list)
+            } else {
+                //上级页面调用
+                pages[pages.length - 2].handleSelectContacts(result, list)
+            }
+        } catch (e) {
+            console.log(e)
+            wx.showToast({
+                title: '操作失败',
+                icon: "none"
+            })
+        }
+    },
+    /* 开始搜索 */
+    startSearch({
+        detail
+    }) {
+        let condition = this.data.content?this.data.content.where.condition:this.data.params.content.where.condition;
+        if (detail == condition) return;
+        this.setData({
+            'content.where.condition': detail,
+            'params.content.where.condition': detail
+        });
+        this.getList(true);
+    },
+    /* 取消搜索 */
+    onClear() {
+        this.setData({
+            'content.where.condition': "",
+            'params.content.where.condition': ""
+        });
+        this.getList(true);
+    },
+    /* 选中 */
+    onChange(e) {
+        const id = e.currentTarget.dataset.item[this.data.idName] + "";
+        if (!id) return;
+        let result = this.data.result;
+        if (this.data.radio) {
+            result = [id]
+        } else {
+            if (result.some(v => v == id)) {
+                result = result.filter(v => v != id)
+            } else {
+                result.push(id)
+            }
+        }
+        this.setData({
+            result
+        })
+        if (this.data.radio) this.submit();
+    },
+    //获取列表
+    getList(init = false) {
+        let params = this.data.params;
+        if (init) params.content.pageNumber = 1;
+        if (params.content.pageNumber > params.content.pageTotal) return;
+        _Http.basic(params).then(res => {
+            console.log("联系人", res)
+            if (res.msg != '成功') return wx.showToast({
+                title: res.data,
+                icon: "none"
+            });
+            this.setData({
+                list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data),
+                "params.content.pageNumber": res.pageNumber + 1,
+                "params.content.pageTotal": res.pageTotal,
+            })
+        })
+    },
+    onReachBottom() {
+        this.getList();
+    }
+})

+ 4 - 0
packageA/select/selectActivity/index.json

@@ -0,0 +1,4 @@
+{
+    "usingComponents": {},
+    "navigationBarTitleText": "选择市场活动"
+}

+ 92 - 0
packageA/select/selectActivity/index.scss

@@ -0,0 +1,92 @@
+.box {
+    width: 100vw;
+    background-color: #fff;
+    box-sizing: border-box;
+
+    .item {
+        display: flex;
+        width: 100%;
+        padding-left: 30rpx;
+        box-sizing: border-box;
+
+        .checkbox {
+            display: flex;
+            align-items: center;
+            width: 58rpx;
+            height: 120rpx;
+        }
+
+        .user {
+            display: flex;
+            align-items: center;
+            width: 100%;
+            height: 120rpx;
+            border-bottom: 1px solid #ddd;
+            box-sizing: border-box;
+
+            .portrait {
+                width: 80rpx;
+                height: 80rpx;
+                background: #3874F6;
+                border-radius: 50%;
+                text-align: center;
+                line-height: 80rpx;
+                font-size: 28rpx;
+                font-family: PingFang SC-Regular, PingFang SC;
+                color: #FFFFFF;
+                flex-shrink: 0;
+            }
+
+            .exp {
+                width: 100%;
+                margin-left: 20rpx;
+
+                .line-1 {
+                    height: 42rpx;
+                    font-size: 30rpx;
+                    font-family: PingFang SC-Regular, PingFang SC;
+                    color: #333333;
+                }
+
+                .phone {
+                    font-size: 24rpx;
+                    font-family: PingFang SC-Regular, PingFang SC;
+                    color: #999999;
+                    margin-top: 4rpx;
+                }
+            }
+        }
+
+    }
+}
+
+.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;
+    }
+}

+ 38 - 0
packageA/select/selectActivity/index.wxml

@@ -0,0 +1,38 @@
+<van-search value="{{ value }}" shape="round" background="#fff" placeholder="搜索姓名、手机号" bind:search='onSearch' bind:clear='onClear' />
+<view style="height: 20rpx;" />
+<van-checkbox-group value="{{ result }}">
+    <view class="box">
+        <navigator url="#" class="item" wx:for="{{list}}" wx:key="index" data-item="{{item}}" bindtap="onChange">
+            <view class="checkbox" wx:if="{{!radio}}">
+                <van-checkbox shape='square' icon-size='14' name="{{item[idName]}}" />
+            </view>
+            <view class="user">
+                <view class="portrait">
+                    {{item.name[0]}}
+                </view>
+                <view class="exp">
+                    <view class="line-1">
+                        {{item.name}}
+                    </view>
+                </view>
+            </view>
+        </navigator>
+    </view>
+</van-checkbox-group>
+
+<My_empty wx:if="{{list.length==0}}" />
+<view style="height: 130rpx;" />
+<view class="footer" wx:if="{{!radio}}">
+    <view class="count">
+        已选:{{result.length}}
+    </view>
+    <van-button custom-class='but' disabled='{{result.length==0}}' bind:click="submit">添加</van-button>
+</view>
+
+<wxs module="active">
+    module.exports.que = function (name, list) {
+        return list.some(function (v) {
+            return v === name
+        })
+    }
+</wxs>