{"remainingRequest":"/data/jenkins/workspace/mer.ws.baibaodun.com.cn/node_modules/thread-loader/dist/cjs.js!/data/jenkins/workspace/mer.ws.baibaodun.com.cn/node_modules/babel-loader/lib/index.js!/data/jenkins/workspace/mer.ws.baibaodun.com.cn/src/directive/longpress/longpress.js","dependencies":[{"path":"/data/jenkins/workspace/mer.ws.baibaodun.com.cn/src/directive/longpress/longpress.js","mtime":1701742078547},{"path":"/data/jenkins/workspace/mer.ws.baibaodun.com.cn/babel.config.js","mtime":1701742078504},{"path":"/data/jenkins/workspace/mer.ws.baibaodun.com.cn/node_modules/cache-loader/dist/cjs.js","mtime":499162500000},{"path":"/data/jenkins/workspace/mer.ws.baibaodun.com.cn/node_modules/thread-loader/dist/cjs.js","mtime":499162500000},{"path":"/data/jenkins/workspace/mer.ws.baibaodun.com.cn/node_modules/babel-loader/lib/index.js","mtime":456789000000}],"contextDependencies":[],"result":["// +----------------------------------------------------------------------\n// | CRMEB [ CRMEB赋能开发者，助力企业发展 ]\n// +----------------------------------------------------------------------\n// | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.\n// +----------------------------------------------------------------------\n// | Licensed CRMEB并不是自由软件，未经许可不能去掉CRMEB相关版权\n// +----------------------------------------------------------------------\n// | Author: CRMEB Team <admin@crmeb.com>\n// +----------------------------------------------------------------------\n\nvar longpress = {\n  bind: function bind(el, binding, vNode) {\n    if (typeof binding.value !== 'function') {\n      throw 'callback must be a function';\n    }\n    // 定义变量\n    var pressTimer = null;\n    // 创建计时器（ 2秒后执行函数 ）\n    var start = function start(e) {\n      if (e.type === 'click' && e.button !== 0) {\n        return;\n      }\n      if (pressTimer === null) {\n        pressTimer = setTimeout(function () {\n          handler();\n        }, 1000);\n      }\n    };\n    // 取消计时器\n    var cancel = function cancel(e) {\n      if (pressTimer !== null) {\n        clearTimeout(pressTimer);\n        pressTimer = null;\n      }\n    };\n    // 运行函数\n    var handler = function handler(e) {\n      binding.value(e);\n    };\n    // 添加事件监听器\n    el.addEventListener('mousedown', start);\n    el.addEventListener('touchstart', start);\n    // 取消计时器\n    el.addEventListener('click', cancel);\n    el.addEventListener('mouseout', cancel);\n    el.addEventListener('touchend', cancel);\n    el.addEventListener('touchcancel', cancel);\n  },\n  // 当传进来的值更新的时候触发\n  componentUpdated: function componentUpdated(el, _ref) {\n    var value = _ref.value;\n    el.$value = value;\n  },\n  // 指令与元素解绑的时候，移除事件绑定\n  unbind: function unbind(el) {\n    el.removeEventListener('click', el.handler);\n  }\n};\nexport default longpress;",null]}