app-renderjs.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383
  1. var __renderjsModules={};
  2. __renderjsModules["463e3cc3"] = (() => {
  3. var __defProp = Object.defineProperty;
  4. var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
  5. var __getOwnPropNames = Object.getOwnPropertyNames;
  6. var __getOwnPropSymbols = Object.getOwnPropertySymbols;
  7. var __hasOwnProp = Object.prototype.hasOwnProperty;
  8. var __propIsEnum = Object.prototype.propertyIsEnumerable;
  9. var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  10. var __spreadValues = (a, b) => {
  11. for (var prop in b || (b = {}))
  12. if (__hasOwnProp.call(b, prop))
  13. __defNormalProp(a, prop, b[prop]);
  14. if (__getOwnPropSymbols)
  15. for (var prop of __getOwnPropSymbols(b)) {
  16. if (__propIsEnum.call(b, prop))
  17. __defNormalProp(a, prop, b[prop]);
  18. }
  19. return a;
  20. };
  21. var __export = (target, all) => {
  22. for (var name in all)
  23. __defProp(target, name, { get: all[name], enumerable: true });
  24. };
  25. var __copyProps = (to, from, except, desc) => {
  26. if (from && typeof from === "object" || typeof from === "function") {
  27. for (let key of __getOwnPropNames(from))
  28. if (!__hasOwnProp.call(to, key) && key !== except)
  29. __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  30. }
  31. return to;
  32. };
  33. var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
  34. // <stdin>
  35. var stdin_exports = {};
  36. __export(stdin_exports, {
  37. default: () => stdin_default
  38. });
  39. // ../../../../../Desktop/项目/shuibei/uni_modules/z-paging/components/z-paging/config/index.js
  40. var config_default = {};
  41. // ../../../../../Desktop/项目/shuibei/uni_modules/z-paging/components/z-paging/js/z-paging-constant.js
  42. var z_paging_constant_default = {
  43. // 当前版本号
  44. version: "2.8.7",
  45. // 延迟操作的通用时间
  46. delayTime: 100,
  47. // 请求失败时候全局emit使用的key
  48. errorUpdateKey: "z-paging-error-emit",
  49. // 全局emit complete的key
  50. completeUpdateKey: "z-paging-complete-emit",
  51. // z-paging缓存的前缀key
  52. cachePrefixKey: "z-paging-cache",
  53. // 虚拟列表中列表index的key
  54. listCellIndexKey: "zp_index",
  55. // 虚拟列表中列表的唯一key
  56. listCellIndexUniqueKey: "zp_unique_index"
  57. };
  58. // ../../../../../Desktop/项目/shuibei/uni_modules/z-paging/components/z-paging/js/z-paging-utils.js
  59. var storageKey = "Z-PAGING-REFRESHER-TIME-STORAGE-KEY";
  60. var config = null;
  61. var configLoaded = false;
  62. var cachedSystemInfo = null;
  63. var timeoutMap = {};
  64. function gc(key, defaultValue) {
  65. return () => {
  66. _handleDefaultConfig();
  67. if (!config)
  68. return defaultValue;
  69. const value = config[key];
  70. return value === void 0 ? defaultValue : value;
  71. };
  72. }
  73. function getTouch(e) {
  74. let touch = null;
  75. if (e.touches && e.touches.length) {
  76. touch = e.touches[0];
  77. } else if (e.changedTouches && e.changedTouches.length) {
  78. touch = e.changedTouches[0];
  79. } else if (e.datail && e.datail != {}) {
  80. touch = e.datail;
  81. } else {
  82. return { touchX: 0, touchY: 0 };
  83. }
  84. return {
  85. touchX: touch.clientX,
  86. touchY: touch.clientY
  87. };
  88. }
  89. function getTouchFromZPaging(target) {
  90. if (target && target.tagName && target.tagName !== "BODY" && target.tagName !== "UNI-PAGE-BODY") {
  91. const classList = target.classList;
  92. if (classList && classList.contains("z-paging-content")) {
  93. return {
  94. isFromZp: true,
  95. isPageScroll: classList.contains("z-paging-content-page"),
  96. isReachedTop: classList.contains("z-paging-reached-top"),
  97. isUseChatRecordMode: classList.contains("z-paging-use-chat-record-mode")
  98. };
  99. } else {
  100. return getTouchFromZPaging(target.parentNode);
  101. }
  102. } else {
  103. return { isFromZp: false };
  104. }
  105. }
  106. function getParent(parent) {
  107. if (!parent)
  108. return null;
  109. if (parent.$refs.paging)
  110. return parent;
  111. return getParent(parent.$parent);
  112. }
  113. function consoleErr(err) {
  114. console.error(`[z-paging]${err}`);
  115. }
  116. function delay(callback, ms = z_paging_constant_default.delayTime, key) {
  117. const timeout = setTimeout(callback, ms);
  118. ;
  119. if (!!key) {
  120. timeoutMap[key] && clearTimeout(timeoutMap[key]);
  121. timeoutMap[key] = timeout;
  122. }
  123. return timeout;
  124. }
  125. function setRefesrherTime(time, key) {
  126. const datas = getRefesrherTime() || {};
  127. datas[key] = time;
  128. uni.setStorageSync(storageKey, datas);
  129. }
  130. function getRefesrherTime() {
  131. return uni.getStorageSync(storageKey);
  132. }
  133. function getRefesrherTimeByKey(key) {
  134. const datas = getRefesrherTime();
  135. return datas && datas[key] ? datas[key] : null;
  136. }
  137. function getRefesrherFormatTimeByKey(key, textMap) {
  138. const time = getRefesrherTimeByKey(key);
  139. const timeText = time ? _timeFormat(time, textMap) : textMap.none;
  140. return `${textMap.title}${timeText}`;
  141. }
  142. function convertToPx(text) {
  143. const dataType = Object.prototype.toString.call(text);
  144. if (dataType === "[object Number]")
  145. return text;
  146. let isRpx = false;
  147. if (text.indexOf("rpx") !== -1 || text.indexOf("upx") !== -1) {
  148. text = text.replace("rpx", "").replace("upx", "");
  149. isRpx = true;
  150. } else if (text.indexOf("px") !== -1) {
  151. text = text.replace("px", "");
  152. }
  153. if (!isNaN(text)) {
  154. if (isRpx)
  155. return Number(rpx2px(text));
  156. return Number(text);
  157. }
  158. return 0;
  159. }
  160. function rpx2px(rpx) {
  161. return uni.upx2px(rpx);
  162. }
  163. function getSystemInfoSync(useCache = false) {
  164. if (useCache && cachedSystemInfo) {
  165. return cachedSystemInfo;
  166. }
  167. const infoTypes = ["DeviceInfo", "AppBaseInfo", "WindowInfo"];
  168. const { deviceInfo, appBaseInfo, windowInfo } = infoTypes.reduce((acc, key) => {
  169. const method = `get${key}`;
  170. if (uni[method] && uni.canIUse(method)) {
  171. acc[key.charAt(0).toLowerCase() + key.slice(1)] = uni[method]();
  172. }
  173. return acc;
  174. }, {});
  175. if (deviceInfo && appBaseInfo && windowInfo) {
  176. cachedSystemInfo = __spreadValues(__spreadValues(__spreadValues({}, deviceInfo), appBaseInfo), windowInfo);
  177. } else {
  178. cachedSystemInfo = uni.getSystemInfoSync();
  179. }
  180. return cachedSystemInfo;
  181. }
  182. function getTime() {
  183. return (/* @__PURE__ */ new Date()).getTime();
  184. }
  185. function getInstanceId() {
  186. const s = [];
  187. const hexDigits = "0123456789abcdef";
  188. for (let i = 0; i < 10; i++) {
  189. s[i] = hexDigits.substr(Math.floor(Math.random() * 16), 1);
  190. }
  191. return s.join("") + getTime();
  192. }
  193. function wait(ms) {
  194. return new Promise((resolve) => {
  195. setTimeout(resolve, ms);
  196. });
  197. }
  198. function isPromise(func) {
  199. return Object.prototype.toString.call(func) === "[object Promise]";
  200. }
  201. function addUnit(value, unit) {
  202. if (Object.prototype.toString.call(value) === "[object String]") {
  203. let tempValue = value;
  204. tempValue = tempValue.replace("rpx", "").replace("upx", "").replace("px", "");
  205. if (value.indexOf("rpx") === -1 && value.indexOf("upx") === -1 && value.indexOf("px") !== -1) {
  206. tempValue = parseFloat(tempValue) * 2;
  207. }
  208. value = tempValue;
  209. }
  210. return unit === "rpx" ? value + "rpx" : value / 2 + "px";
  211. }
  212. function deepCopy(obj) {
  213. if (typeof obj !== "object" || obj === null)
  214. return obj;
  215. let newObj = Array.isArray(obj) ? [] : {};
  216. for (let key in obj) {
  217. if (obj.hasOwnProperty(key)) {
  218. newObj[key] = deepCopy(obj[key]);
  219. }
  220. }
  221. return newObj;
  222. }
  223. function useBufferedInsert(fn, delay2 = 50) {
  224. let buffer = [];
  225. let timer = null;
  226. let latestArgs = [];
  227. return function insertBuffered(data2, ...args) {
  228. const newData = Object.prototype.toString.call(data2) !== "[object Array]" ? [data2] : data2;
  229. buffer.push(...newData);
  230. latestArgs = args;
  231. if (!timer) {
  232. timer = setTimeout(() => {
  233. fn(buffer.length === 1 ? buffer[0] : buffer, ...latestArgs);
  234. buffer = [];
  235. timer = null;
  236. }, buffer.length === 1 ? 10 : delay2);
  237. }
  238. };
  239. }
  240. function _handleDefaultConfig() {
  241. if (configLoaded)
  242. return;
  243. if (config_default && Object.keys(config_default).length) {
  244. config = config_default;
  245. }
  246. if (!config && uni.$zp) {
  247. config = uni.$zp.config;
  248. }
  249. config = config ? Object.keys(config).reduce((result, key) => {
  250. result[_toCamelCase(key)] = config[key];
  251. return result;
  252. }, {}) : null;
  253. configLoaded = true;
  254. }
  255. function _timeFormat(time, textMap) {
  256. const date = new Date(time);
  257. const currentDate = /* @__PURE__ */ new Date();
  258. const dateDay = new Date(time).setHours(0, 0, 0, 0);
  259. const currentDateDay = (/* @__PURE__ */ new Date()).setHours(0, 0, 0, 0);
  260. const disTime = dateDay - currentDateDay;
  261. let dayStr = "";
  262. const timeStr = _dateTimeFormat(date);
  263. if (disTime === 0) {
  264. dayStr = textMap.today;
  265. } else if (disTime === -864e5) {
  266. dayStr = textMap.yesterday;
  267. } else {
  268. dayStr = _dateDayFormat(date, date.getFullYear() !== currentDate.getFullYear());
  269. }
  270. return `${dayStr} ${timeStr}`;
  271. }
  272. function _dateDayFormat(date, showYear = true) {
  273. const year = date.getFullYear();
  274. const month = date.getMonth() + 1;
  275. const day = date.getDate();
  276. return showYear ? `${year}-${_fullZeroToTwo(month)}-${_fullZeroToTwo(day)}` : `${_fullZeroToTwo(month)}-${_fullZeroToTwo(day)}`;
  277. }
  278. function _dateTimeFormat(date) {
  279. const hour = date.getHours();
  280. const minute = date.getMinutes();
  281. return `${_fullZeroToTwo(hour)}:${_fullZeroToTwo(minute)}`;
  282. }
  283. function _fullZeroToTwo(str) {
  284. str = str.toString();
  285. return str.length === 1 ? "0" + str : str;
  286. }
  287. function _toCamelCase(value) {
  288. return value.replace(/-([a-z])/g, (_, group1) => group1.toUpperCase());
  289. }
  290. var z_paging_utils_default = {
  291. gc,
  292. setRefesrherTime,
  293. getRefesrherFormatTimeByKey,
  294. getTouch,
  295. getTouchFromZPaging,
  296. getParent,
  297. convertToPx,
  298. getTime,
  299. getInstanceId,
  300. consoleErr,
  301. delay,
  302. wait,
  303. isPromise,
  304. addUnit,
  305. deepCopy,
  306. rpx2px,
  307. getSystemInfoSync,
  308. useBufferedInsert
  309. };
  310. // ../../../../../Desktop/项目/shuibei/uni_modules/z-paging/components/z-paging/wxs/z-paging-renderjs.js
  311. var data = {
  312. startY: 0,
  313. isTouchFromZPaging: false,
  314. isUsePageScroll: false,
  315. isReachedTop: true,
  316. isIosAndH5: false,
  317. useChatRecordMode: false,
  318. appLaunched: false
  319. };
  320. var z_paging_renderjs_default = {
  321. mounted() {
  322. if (window) {
  323. this._handleTouch();
  324. this.$ownerInstance.callMethod("_handlePageLaunch");
  325. }
  326. },
  327. methods: {
  328. // 接收逻辑层发送的数据(是否是ios+h5)
  329. renderPropIsIosAndH5Change(newVal) {
  330. if (newVal === -1)
  331. return;
  332. data.isIosAndH5 = newVal;
  333. },
  334. // 拦截处理touch事件
  335. _handleTouch() {
  336. if (!window.$zPagingRenderJsInited) {
  337. window.$zPagingRenderJsInited = true;
  338. window.addEventListener("touchstart", this._handleTouchstart, { passive: true });
  339. window.addEventListener("touchmove", this._handleTouchmove, { passive: false });
  340. }
  341. },
  342. // 处理touch开始
  343. _handleTouchstart(e) {
  344. const touch = z_paging_utils_default.getTouch(e);
  345. data.startY = touch.touchY;
  346. const touchResult = z_paging_utils_default.getTouchFromZPaging(e.target);
  347. data.isTouchFromZPaging = touchResult.isFromZp;
  348. data.isUsePageScroll = touchResult.isPageScroll;
  349. data.isReachedTop = touchResult.isReachedTop;
  350. data.useChatRecordMode = touchResult.isUseChatRecordMode;
  351. },
  352. // 处理touch中
  353. _handleTouchmove(e) {
  354. const touch = z_paging_utils_default.getTouch(e);
  355. const moveY = touch.touchY - data.startY;
  356. if (data.isTouchFromZPaging && (data.isReachedTop && (data.useChatRecordMode ? moveY < 0 : moveY > 0) || !data.useChatRecordMode && data.isIosAndH5 && !data.isUsePageScroll && moveY < 0)) {
  357. if (e.cancelable && !e.defaultPrevented) {
  358. e.preventDefault();
  359. }
  360. }
  361. },
  362. // 移除touch相关事件监听
  363. _removeAllEventListener() {
  364. window.removeEventListener("touchstart");
  365. window.removeEventListener("touchmove");
  366. }
  367. }
  368. };
  369. // <stdin>
  370. var stdin_default = {
  371. name: "z-paging",
  372. mixins: [z_paging_renderjs_default]
  373. };
  374. return __toCommonJS(stdin_exports);
  375. })();