su-notice-bar.js 6.6 KB

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