su-notice-bar.js 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. "use strict";
  2. const common_vendor = require("../../../common/vendor.js");
  3. require("../../index.js");
  4. require("../../url/index.js");
  5. require("../../store/index.js");
  6. require("../../store/app.js");
  7. require("../../api/promotion/diy.js");
  8. require("../../request/index.js");
  9. require("../../config/index.js");
  10. require("../../platform/index.js");
  11. require("../../platform/provider/wechat/index.js");
  12. require("../../platform/provider/wechat/miniProgram.js");
  13. require("../../api/member/auth.js");
  14. require("../../api/member/social.js");
  15. require("../../api/member/user.js");
  16. require("../../platform/provider/apple/index.js");
  17. require("../../platform/share.js");
  18. require("../../router/index.js");
  19. require("../../hooks/useModal.js");
  20. require("../../helper/index.js");
  21. require("../../helper/test.js");
  22. require("../../helper/digit.js");
  23. require("../../helper/throttle.js");
  24. require("../../platform/pay.js");
  25. require("../../api/pay/order.js");
  26. require("../../store/user.js");
  27. require("../../store/cart.js");
  28. require("../../api/trade/cart.js");
  29. require("../../api/pay/wallet.js");
  30. require("../../api/trade/order.js");
  31. require("../../api/promotion/coupon.js");
  32. require("../../store/sys.js");
  33. require("../../store/modal.js");
  34. require("../../config/zIndex.js");
  35. const _sfc_main = {
  36. name: "UniNoticeBar",
  37. emits: ["click", "getmore", "close"],
  38. props: {
  39. text: {
  40. type: String,
  41. default: ""
  42. },
  43. moreText: {
  44. type: String,
  45. default: ""
  46. },
  47. backgroundColor: {
  48. type: String,
  49. default: ""
  50. },
  51. speed: {
  52. // 默认1s滚动100px
  53. type: Number,
  54. default: 100
  55. },
  56. color: {
  57. type: String,
  58. default: "var(--ui-BG-Main)"
  59. },
  60. moreColor: {
  61. type: String,
  62. default: "#FF9A43"
  63. },
  64. single: {
  65. // 是否单行
  66. type: [Boolean, String],
  67. default: false
  68. },
  69. scrollable: {
  70. // 是否滚动,添加后控制单行效果取消
  71. type: [Boolean, String],
  72. default: false
  73. },
  74. showIcon: {
  75. // 是否显示左侧icon
  76. type: [Boolean, String],
  77. default: false
  78. },
  79. showGetMore: {
  80. // 是否显示右侧查看更多
  81. type: [Boolean, String],
  82. default: false
  83. },
  84. showClose: {
  85. // 是否显示左侧关闭按钮
  86. type: [Boolean, String],
  87. default: false
  88. }
  89. },
  90. data() {
  91. const elId = `Uni_${Math.ceil(Math.random() * 1e6).toString(36)}`;
  92. const elIdBox = `Uni_${Math.ceil(Math.random() * 1e6).toString(36)}`;
  93. return {
  94. textWidth: 0,
  95. boxWidth: 0,
  96. wrapWidth: "",
  97. webviewHide: false,
  98. elId,
  99. elIdBox,
  100. show: true,
  101. animationDuration: "none",
  102. animationPlayState: "paused",
  103. animationDelay: "0s"
  104. };
  105. },
  106. mounted() {
  107. this.$nextTick(() => {
  108. this.initSize();
  109. });
  110. },
  111. methods: {
  112. initSize() {
  113. if (this.scrollable) {
  114. let query = [];
  115. let textQuery = new Promise((resolve, reject) => {
  116. common_vendor.index.createSelectorQuery().in(this).select(`#${this.elId}`).boundingClientRect().exec((ret) => {
  117. this.textWidth = ret[0].width;
  118. resolve();
  119. });
  120. });
  121. let boxQuery = new Promise((resolve, reject) => {
  122. common_vendor.index.createSelectorQuery().in(this).select(`#${this.elIdBox}`).boundingClientRect().exec((ret) => {
  123. this.boxWidth = ret[0].width;
  124. resolve();
  125. });
  126. });
  127. query.push(textQuery);
  128. query.push(boxQuery);
  129. Promise.all(query).then(() => {
  130. this.animationDuration = `${this.textWidth / this.speed}s`;
  131. this.animationDelay = `-${this.boxWidth / this.speed}s`;
  132. setTimeout(() => {
  133. this.animationPlayState = "running";
  134. }, 1e3);
  135. });
  136. }
  137. },
  138. loopAnimation() {
  139. },
  140. clickMore() {
  141. this.$emit("getmore");
  142. },
  143. close() {
  144. this.show = false;
  145. this.$emit("close");
  146. },
  147. onClick() {
  148. this.$emit("click");
  149. }
  150. }
  151. };
  152. if (!Array) {
  153. const _easycom_uni_icons2 = common_vendor.resolveComponent("uni-icons");
  154. _easycom_uni_icons2();
  155. }
  156. const _easycom_uni_icons = () => "../../../uni_modules/uni-icons/components/uni-icons/uni-icons.js";
  157. if (!Math) {
  158. _easycom_uni_icons();
  159. }
  160. function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  161. return common_vendor.e({
  162. a: $data.show
  163. }, $data.show ? common_vendor.e({
  164. b: $props.showIcon === true || $props.showIcon === "true"
  165. }, $props.showIcon === true || $props.showIcon === "true" ? {
  166. c: common_vendor.p({
  167. type: "sound",
  168. color: $props.color,
  169. size: "22"
  170. })
  171. } : {}, {
  172. d: common_vendor.t($props.text),
  173. e: $data.elId,
  174. f: $props.scrollable ? 1 : "",
  175. g: !$props.scrollable && ($props.single || $props.showGetMore) ? 1 : "",
  176. h: $props.color,
  177. i: $data.wrapWidth + "px",
  178. j: $data.animationDuration,
  179. k: $data.animationDuration,
  180. l: $data.webviewHide ? "paused" : $data.animationPlayState,
  181. m: $data.webviewHide ? "paused" : $data.animationPlayState,
  182. n: $data.animationDelay,
  183. o: $data.animationDelay,
  184. p: $data.elIdBox,
  185. q: $props.scrollable ? 1 : "",
  186. r: !$props.scrollable && ($props.single || $props.moreText) ? 1 : "",
  187. s: $props.scrollable ? 1 : "",
  188. t: !$props.scrollable && ($props.single || $props.moreText) ? 1 : "",
  189. v: $props.showGetMore === true || $props.showGetMore === "true"
  190. }, $props.showGetMore === true || $props.showGetMore === "true" ? common_vendor.e({
  191. w: $props.moreText.length > 0
  192. }, $props.moreText.length > 0 ? {
  193. x: common_vendor.t($props.moreText),
  194. y: $props.moreColor
  195. } : {
  196. z: common_vendor.p({
  197. type: "right",
  198. color: $props.moreColor,
  199. size: "16"
  200. })
  201. }, {
  202. A: common_vendor.o((...args) => $options.clickMore && $options.clickMore(...args))
  203. }) : {}, {
  204. B: ($props.showClose === true || $props.showClose === "true") && ($props.showGetMore === false || $props.showGetMore === "false")
  205. }, ($props.showClose === true || $props.showClose === "true") && ($props.showGetMore === false || $props.showGetMore === "false") ? {
  206. C: common_vendor.p({
  207. type: "closeempty",
  208. color: $props.color,
  209. size: "16"
  210. }),
  211. D: common_vendor.o((...args) => $options.close && $options.close(...args))
  212. } : {}, {
  213. E: $props.backgroundColor,
  214. F: common_vendor.o((...args) => $options.onClick && $options.onClick(...args))
  215. }) : {});
  216. }
  217. const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-8eee8640"], ["__file", "/Users/RuHu.Xu/Desktop/mall-newfeifan-zx-app/sheep/ui/su-notice-bar/su-notice-bar.vue"]]);
  218. wx.createComponent(Component);