From d8b41fff43a2cee6a8f714ffa807623b15803786 Mon Sep 17 00:00:00 2001
From: quanyawei <401863037@qq.com>
Date: Fri, 20 Oct 2023 15:21:35 +0800
Subject: [PATCH] fix:立行立改Uniapp小程序新建项目

---
 uni_modules/uview-ui/libs/mixin/mixin.js |  160 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 160 insertions(+), 0 deletions(-)

diff --git a/uni_modules/uview-ui/libs/mixin/mixin.js b/uni_modules/uview-ui/libs/mixin/mixin.js
new file mode 100644
index 0000000..f41a178
--- /dev/null
+++ b/uni_modules/uview-ui/libs/mixin/mixin.js
@@ -0,0 +1,160 @@
+module.exports = {
+    // ������������������������������������������������������������������
+    props: {
+        // ������������������������������������������������������������������������������������
+        customStyle: {
+            type: [Object, String],
+            default: () => ({})
+        },
+        customClass: {
+            type: String,
+            default: ''
+        },
+        // ���������������������
+        url: {
+            type: String,
+            default: ''
+        },
+        // ���������������������
+        linkType: {
+            type: String,
+            default: 'navigateTo'
+        }
+    },
+    data() {
+        return {}
+    },
+    onLoad() {
+        // getRect���������$u���������������������������������in(this)���������������������������������������������������������
+        this.$u.getRect = this.$uGetRect
+    },
+    created() {
+        // ���������������������created���������������������������������������������������created���������������������$u
+        this.$u.getRect = this.$uGetRect
+    },
+    computed: {
+        // ���2.x���������������������$u���������uni������������������������������������������uni.$u.xxx������
+        // ������������������computed���������������������������this.$u������������������������������js���������uni.$u.xxx
+        // ������nvue������������������������������������$u������������������������������������������nvue���������������������������������props���������
+        $u() {
+            // #ifndef APP-NVUE
+            // ������nvue������������props���http���mixin������������������������������setData���������������������������
+            return uni.$u.deepMerge(uni.$u, {
+                props: undefined,
+                http: undefined,
+                mixin: undefined
+            })
+            // #endif
+            // #ifdef APP-NVUE
+            return uni.$u
+            // #endif
+        },
+        /**
+         * ������bem������������
+         * ������������������������H5���nvue������������class������������������������:class="[bem()]"���������������������
+         * ���������������������������������������������������������������������������������������������������������������������������������['a', 'b', 'c']���'a b c'���������
+         * @param {String} name ������������
+         * @param {Array} fixed ������������������������
+         * @param {Array} change ���������������������true������false������������������������������
+         * @returns {Array|string}
+         */
+        bem() {
+            return function (name, fixed, change) {
+                // ������������
+                const prefix = `u-${name}--`
+                const classes = {}
+                if (fixed) {
+                    fixed.map((item) => {
+                        // ���������������������������������
+                        classes[prefix + this[item]] = true
+                    })
+                }
+                if (change) {
+                    change.map((item) => {
+                        // ���������������������������this[item]���������true������false������������������������������������������
+                        this[item] ? (classes[prefix + item] = this[item]) : (delete classes[prefix + item])
+                    })
+                }
+                return Object.keys(classes)
+                    // ������������������������������������������������������������������������������������������������������","������������������
+                    // #ifdef MP-ALIPAY || MP-TOUTIAO || MP-LARK
+                    .join(' ')
+                    // #endif
+            }
+        }
+    },
+    methods: {
+        // ���������������������
+        openPage(urlKey = 'url') {
+            const url = this[urlKey]
+            if (url) {
+                // ������������uni.navigateTo���������
+                uni[this.linkType]({
+                    url
+                })
+            }
+        },
+        // ������������������
+        // ���������������������������������������������������������������������������������������������bug(2020-07-21)
+        // ���������������������������������������������������������������view������
+        $uGetRect(selector, all) {
+            return new Promise((resolve) => {
+                uni.createSelectorQuery()
+                    .in(this)[all ? 'selectAll' : 'select'](selector)
+                    .boundingClientRect((rect) => {
+                        if (all && Array.isArray(rect) && rect.length) {
+                            resolve(rect)
+                        }
+                        if (!all && rect) {
+                            resolve(rect)
+                        }
+                    })
+                    .exec()
+            })
+        },
+        getParentData(parentName = '') {
+            // ���������created������������parent������
+            if (!this.parent) this.parent = {}
+            // ������������������������������������������������������(������������u-radio������������u-radio-group���this)
+            // ������������this���������������������������������������(u-radio���this)���parentData������������������������
+            // ���������������������������������������������������������������������������������this.parent.xxx���������������������������������
+            // ���������������������������������������������������������������������u-radio-group���������data���������������������������������������������������������������
+            this.parent = uni.$u.$parent.call(this, parentName)
+            if (this.parent.children) {
+                // ������������������children������������������������������������������������������������������children���
+                this.parent.children.indexOf(this) === -1 && this.parent.children.push(this)
+            }
+            if (this.parent && this.parentData) {
+                // ������parentData������������������parent���������������������������parentData
+                Object.keys(this.parentData).map((key) => {
+                    this.parentData[key] = this.parent[key]
+                })
+            }
+        },
+        // ������������������
+        preventEvent(e) {
+            e && typeof (e.stopPropagation) === 'function' && e.stopPropagation()
+        },
+        // ���������
+        noop(e) {
+            this.preventEvent(e)
+        }
+    },
+    onReachBottom() {
+        uni.$emit('uOnReachBottom')
+    },
+    beforeDestroy() {
+        // ������������������������������parent���chldren������������checkbox���checkbox-group������������������������������������
+        // ���������������������������������������������children������������������������������������������������������
+        if (this.parent && uni.$u.test.array(this.parent.children)) {
+            // ���������������������������������������children������������������������
+            const childrenList = this.parent.children
+            childrenList.map((child, index) => {
+                // ������������������������
+                if (child === this) {
+                    childrenList.splice(index, 1)
+                }
+            })
+        }
+    }
+}

--
Gitblit v1.8.0