zhaoxiaohai 3 years ago
parent
commit
946ae85dfe

+ 55 - 0
packageA/tags/index.js

@@ -0,0 +1,55 @@
+Page({
+    data: {
+        list: [
+            "标签1",
+            "标签2",
+            "标签22",
+            "标签21231231",
+            "标签212胜多负少",
+            "标签223423SDf",
+            "标签2dsf sdf让他水电费",
+            "标签3"
+        ],
+        copy: [
+            "标签1",
+            "标签2",
+            "标签22",
+            "标签21231231",
+            "标签212胜多负少",
+            "标签223423SDf",
+            "标签2dsf sdf让他水电费",
+            "标签3"
+        ],
+        ownerid: 0,
+        ownertable: 0,
+        actives: [],
+    },
+    onLoad(options) {
+        if (options.ownertable) this.setData({
+            ...options
+        })
+    },
+    onChange(e) {
+        const {
+            tag
+        } = e.target.dataset;
+        if (!tag) return;
+        let actives = this.data.actives;
+        if (actives.some(v => v == tag)) {
+            actives = actives.filter(v => v != tag)
+        } else {
+            actives.push(tag)
+        }
+        this.setData({
+            actives
+        })
+    },
+    /* 搜索 */
+    onInput({
+        detail
+    }) {
+        this.setData({
+            list: detail == '' ? this.data.copy : this.data.copy.filter(v => v.includes(detail))
+        })
+    },
+})

+ 4 - 0
packageA/tags/index.json

@@ -0,0 +1,4 @@
+{
+    "usingComponents": {},
+    "navigationBarTitleText": "标签"
+}

+ 67 - 0
packageA/tags/index.scss

@@ -0,0 +1,67 @@
+.content {
+    width: 100vw;
+    background-color: #fff;
+    padding: 20rpx 30rpx;
+
+    .title {
+        font-size: 28rpx;
+        font-family: PingFangSC-Regular-, PingFangSC-Regular;
+        color: #333333;
+    }
+
+    .tags {
+        display: flex;
+        flex-wrap: wrap;
+
+        .basic {
+            height: 72rpx;
+            line-height: 72rpx;
+            background: #FFFFFF;
+            border-radius: 36rpx;
+            border: 1px solid #CCCCCC;
+            padding: 0 20rpx;
+            margin-top: 20rpx;
+            margin-right: 20rpx;
+            font-size: 28rpx;
+            font-family: PingFang SC-Regular, PingFang SC;
+            color: #666666;
+        }
+
+        .active {
+            background: #FFEFD9;
+            border: 1px solid #FA8C16;
+            color: #FA8C16;
+        }
+    }
+}
+
+.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;
+    }
+}

+ 24 - 0
packageA/tags/index.wxml

@@ -0,0 +1,24 @@
+<van-search value="{{ value }}" shape="round" background="#fff" placeholder="请输入搜索关键词" bind:change='onInput' />
+
+<view class="content" style="margin-top: 20rpx;">
+    <view class="title">请选择添加标签</view>
+    <view class="tags" bindtap="onChange">
+        <van-button custom-class='basic {{active.que(item,actives)?"active":""}}' wx:for="{{list}}" wx:key="index" data-tag="{{item}}">{{item}}</van-button>
+    </view>
+</view>
+
+<view style="height: 130rpx;" />
+<view class="footer">
+    <view class="count">
+        已选:{{actives.length}}
+    </view>
+    <van-button custom-class='but'>确定</van-button>
+</view>
+
+<wxs module="active">
+    module.exports.que = function (name, list) {
+        return list.some(function (v) {
+            return v === name
+        })
+    }
+</wxs>

+ 44 - 0
packageA/tags/modules/Yl-tags/index.js

@@ -0,0 +1,44 @@
+const _Http = getApp().globalData.http;
+Component({
+    properties: {
+        add: Boolean, //是否允许新增
+        ownertable: {
+            type: String,
+            value: "sa_itemgroup"
+        },
+        ownerid: {
+            type: String,
+            value: 11
+        }
+    },
+    data: {
+        datatag: [],
+        systemtag: [],
+    },
+    methods: {
+        /* 获取标签 */
+        getTags() {
+            _Http.basic({
+                "id": 20220929085401,
+                "content": {
+                    ownertable: this.data.ownertable,
+                    ownerid: this.data.ownerid
+                }
+            }).then(res => {
+                console.log("标签列表", res)
+                if (res.msg != '成功') return wx.showToast({
+                    title: res.data,
+                    icon: "none"
+                });
+                this.setData({
+                    ...res.data
+                })
+            })
+        },
+        addTags() {
+            wx.navigateTo({
+                url: `/packageA/tags/index?ownertable=${this.data.ownertable}&ownerid=${this.data.ownerid}`
+            })
+        }
+    }
+})

+ 4 - 0
packageA/tags/modules/Yl-tags/index.json

@@ -0,0 +1,4 @@
+{
+    "component": true,
+    "usingComponents": {}
+}

+ 27 - 0
packageA/tags/modules/Yl-tags/index.scss

@@ -0,0 +1,27 @@
+.tag-box {
+    display: flex;
+    flex-wrap: wrap;
+    width: 100%;
+
+    >view{
+        display: flex;
+        align-items: center;
+        height: 40rpx;
+        font-size: 20rpx;
+        padding: 0 10rpx;
+        border-radius: 20rpx;
+        font-family: PingFang SC-Regular, PingFang SC;
+    }
+    .datatag {
+        background: #FFEFD9;
+        color: #FA8C16;
+        margin-right: 10rpx;
+    }
+
+    .add {
+        color: #666666;
+        background: #FFFFFF;
+        border: 1px solid #CCCCCC;
+        box-sizing: border-box;
+    }
+}

+ 11 - 0
packageA/tags/modules/Yl-tags/index.wxml

@@ -0,0 +1,11 @@
+<view class="tag-box" bindtap="addTags">
+    <view class="systemtag" wx:for="{{systemtag}}" wx:key="item">
+        {{item}}
+    </view>
+    <view class="datatag" wx:for="{{datatag}}" wx:key="item">
+        {{item}}
+    </view>
+    <view class="add" wx:if="{{add}}">
+        <van-icon name="plus" style="margin-right: 6rpx;" />添加
+    </view>
+</view>