C端小程序
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

211 lines
6.5 KiB

  1. const navigationBarHeight = (getApp().statusBarHeight + 44)*2;
  2. module.exports =
  3. /******/ (function(modules) { // webpackBootstrap
  4. /******/ // The module cache
  5. /******/ var installedModules = {};
  6. /******/
  7. /******/ // The require function
  8. /******/ function __webpack_require__(moduleId) {
  9. /******/
  10. /******/ // Check if module is in cache
  11. /******/ if(installedModules[moduleId]) {
  12. /******/ return installedModules[moduleId].exports;
  13. /******/ }
  14. /******/ // Create a new module (and put it into the cache)
  15. /******/ var module = installedModules[moduleId] = {
  16. /******/ i: moduleId,
  17. /******/ l: false,
  18. /******/ exports: {}
  19. /******/ };
  20. /******/
  21. /******/ // Execute the module function
  22. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  23. /******/
  24. /******/ // Flag the module as loaded
  25. /******/ module.l = true;
  26. /******/
  27. /******/ // Return the exports of the module
  28. /******/ return module.exports;
  29. /******/ }
  30. /******/
  31. /******/
  32. /******/ // expose the modules object (__webpack_modules__)
  33. /******/ __webpack_require__.m = modules;
  34. /******/
  35. /******/ // expose the module cache
  36. /******/ __webpack_require__.c = installedModules;
  37. /******/
  38. /******/ // define getter function for harmony exports
  39. /******/ __webpack_require__.d = function(exports, name, getter) {
  40. /******/ if(!__webpack_require__.o(exports, name)) {
  41. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  42. /******/ }
  43. /******/ };
  44. /******/
  45. /******/ // define __esModule on exports
  46. /******/ __webpack_require__.r = function(exports) {
  47. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  48. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  49. /******/ }
  50. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  51. /******/ };
  52. /******/
  53. /******/ // create a fake namespace object
  54. /******/ // mode & 1: value is a module id, require it
  55. /******/ // mode & 2: merge all properties of value into the ns
  56. /******/ // mode & 4: return value when already ns object
  57. /******/ // mode & 8|1: behave like require
  58. /******/ __webpack_require__.t = function(value, mode) {
  59. /******/ if(mode & 1) value = __webpack_require__(value);
  60. /******/ if(mode & 8) return value;
  61. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  62. /******/ var ns = Object.create(null);
  63. /******/ __webpack_require__.r(ns);
  64. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  65. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  66. /******/ return ns;
  67. /******/ };
  68. /******/
  69. /******/ // getDefaultExport function for compatibility with non-harmony modules
  70. /******/ __webpack_require__.n = function(module) {
  71. /******/ var getter = module && module.__esModule ?
  72. /******/ function getDefault() { return module['default']; } :
  73. /******/ function getModuleExports() { return module; };
  74. /******/ __webpack_require__.d(getter, 'a', getter);
  75. /******/ return getter;
  76. /******/ };
  77. /******/
  78. /******/ // Object.prototype.hasOwnProperty.call
  79. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  80. /******/
  81. /******/ // __webpack_public_path__
  82. /******/ __webpack_require__.p = "";
  83. /******/
  84. /******/
  85. /******/ // Load entry module and return exports
  86. /******/ return __webpack_require__(__webpack_require__.s = 19);
  87. /******/ })
  88. /************************************************************************/
  89. /******/ ({
  90. /***/ 19:
  91. /***/ (function(module, exports, __webpack_require__) {
  92. "use strict";
  93. Component({
  94. options: {
  95. addGlobalClass: true
  96. },
  97. properties: {
  98. extClass: {
  99. type: String,
  100. value: ''
  101. },
  102. focus: {
  103. type: Boolean,
  104. value: false
  105. },
  106. placeholder: {
  107. type: String,
  108. value: '搜索'
  109. },
  110. value: {
  111. type: String,
  112. value: ''
  113. },
  114. search: {
  115. type: Function,
  116. value: null
  117. },
  118. throttle: {
  119. type: Number,
  120. value: 500
  121. },
  122. cancelText: {
  123. type: String,
  124. value: '取消'
  125. },
  126. cancel: {
  127. type: Boolean,
  128. value: true
  129. }
  130. },
  131. data: {
  132. result: [],
  133. navigationBarHeight
  134. },
  135. lastSearch: Date.now(),
  136. lifetimes: {
  137. attached: function attached() {
  138. if (this.data.focus) {
  139. this.setData({
  140. searchState: true
  141. });
  142. }
  143. }
  144. },
  145. methods: {
  146. clearInput: function clearInput() {
  147. this.setData({
  148. value: ''
  149. });
  150. this.triggerEvent('clear');
  151. },
  152. inputFocus: function inputFocus(e) {
  153. this.triggerEvent('focus', e.detail);
  154. },
  155. inputBlur: function inputBlur(e) {
  156. this.setData({
  157. focus: false
  158. });
  159. this.triggerEvent('blur', e.detail);
  160. },
  161. showInput: function showInput() {
  162. this.setData({
  163. focus: true,
  164. searchState: true
  165. });
  166. },
  167. hideInput: function hideInput() {
  168. this.setData({
  169. searchState: false
  170. });
  171. },
  172. inputChange: function inputChange(e) {
  173. var _this = this;
  174. this.setData({
  175. value: e.detail.value
  176. });
  177. this.triggerEvent('input', e.detail);
  178. if (Date.now() - this.lastSearch < this.data.throttle) {
  179. return;
  180. }
  181. if (typeof this.data.search !== 'function') {
  182. return;
  183. }
  184. this.lastSearch = Date.now();
  185. this.timerId = setTimeout(function () {
  186. _this.data.search(e.detail.value).then(function (json) {
  187. _this.setData({
  188. result: json
  189. });
  190. }).catch(function (err) {
  191. console.log('search error', err);
  192. });
  193. }, this.data.throttle);
  194. },
  195. selectResult: function selectResult(e) {
  196. var index = e.currentTarget.dataset.index;
  197. var item = this.data.result[index];
  198. this.triggerEvent('selectresult', { index: index, item: item });
  199. }
  200. }
  201. });
  202. /***/ })
  203. /******/ });