su-swiper.js 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. "use strict";
  2. const common_vendor = require("../../../common/vendor.js");
  3. const sheep_index = 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. if (!Array) {
  36. const _easycom_su_video2 = common_vendor.resolveComponent("su-video");
  37. _easycom_su_video2();
  38. }
  39. const _easycom_su_video = () => "../su-video/su-video.js";
  40. if (!Math) {
  41. _easycom_su_video();
  42. }
  43. const _sfc_main = {
  44. __name: "su-swiper",
  45. props: {
  46. circular: {
  47. type: Boolean,
  48. default: true
  49. },
  50. autoplay: {
  51. type: Boolean,
  52. default: false
  53. },
  54. interval: {
  55. type: Number,
  56. default: 3e3
  57. },
  58. duration: {
  59. type: Number,
  60. default: 500
  61. },
  62. mode: {
  63. type: String,
  64. default: "default"
  65. },
  66. imageMode: {
  67. type: String,
  68. default: "scaleToFill"
  69. },
  70. list: {
  71. type: Array,
  72. default() {
  73. return [];
  74. }
  75. },
  76. dotStyle: {
  77. type: String,
  78. default: "long"
  79. //default long tag
  80. },
  81. dotCur: {
  82. type: String,
  83. default: "ss-bg-opactity-block"
  84. },
  85. bg: {
  86. type: String,
  87. default: "bg-none"
  88. },
  89. height: {
  90. type: Number,
  91. default: 0
  92. },
  93. imgHeight: {
  94. type: Number,
  95. default: 0
  96. },
  97. imgTopRadius: {
  98. type: Number,
  99. default: 0
  100. },
  101. imgBottomRadius: {
  102. type: Number,
  103. default: 0
  104. },
  105. isPreview: {
  106. type: Boolean,
  107. default: false
  108. },
  109. seizeHeight: {
  110. type: Number,
  111. default: 200
  112. }
  113. },
  114. setup(__props) {
  115. const props = __props;
  116. const state = common_vendor.reactive({
  117. imgHeight: 0,
  118. cur: 0,
  119. moveX: 0,
  120. videoPlaySataus: false,
  121. heightList: []
  122. });
  123. const refs = common_vendor.reactive({
  124. videoRef: {}
  125. });
  126. const swiperChange = (e) => {
  127. if (e.detail.source !== "touch" && e.detail.source !== "autoplay")
  128. return;
  129. state.cur = e.detail.current;
  130. state.videoPlaySataus = false;
  131. if (props.list[state.cur].type === "video") {
  132. refs.videoRef[`video_${state.cur}`].pausePlay();
  133. }
  134. };
  135. const onSwiperItem = (item) => {
  136. if (item.type === "video") {
  137. state.videoPlaySataus = true;
  138. } else {
  139. sheep_index.sheep.$router.go(item.url);
  140. onPreview();
  141. }
  142. };
  143. const onPreview = () => {
  144. if (!props.isPreview)
  145. return;
  146. let previewImage = common_vendor.lodashExports.clone(props.list);
  147. previewImage.forEach((item, index) => {
  148. if (item.type === "video") {
  149. previewImage.splice(index, 1);
  150. }
  151. });
  152. common_vendor.index.previewImage({
  153. urls: previewImage.length < 1 ? [props.src] : previewImage.reduce((pre, cur) => {
  154. pre.push(cur.src);
  155. return pre;
  156. }, []),
  157. current: state.cur
  158. // longPressActions: {
  159. // itemList: ['发送给朋友', '保存图片', '收藏'],
  160. // success: function (data) {
  161. // console.log('选中了第' + (data.tapIndex + 1) + '个按钮,第' + (data.index + 1) + '张图片');
  162. // },
  163. // fail: function (err) {
  164. // console.log(err.errMsg);
  165. // },
  166. // },
  167. });
  168. };
  169. const transition = (e) => {
  170. };
  171. const animationfinish = (e) => {
  172. state.moveX = 0;
  173. };
  174. const videoTimeupdate = (e) => {
  175. props.list[state.cur].currentTime = e.detail.currentTime;
  176. };
  177. const customStyle = common_vendor.computed(() => {
  178. let height;
  179. if (props.height !== 0) {
  180. height = props.height;
  181. }
  182. if (props.height === 0) {
  183. if (state.imgHeight !== 0) {
  184. height = state.imgHeight;
  185. } else if (props.seizeHeight !== 0) {
  186. height = props.seizeHeight;
  187. }
  188. }
  189. return {
  190. height: height + "rpx"
  191. };
  192. });
  193. function onImgLoad(e) {
  194. if (props.height === 0) {
  195. let newHeight = e.detail.height / e.detail.width * 750;
  196. if (state.imgHeight < newHeight) {
  197. state.imgHeight = newHeight;
  198. }
  199. }
  200. }
  201. return (_ctx, _cache) => {
  202. return common_vendor.e({
  203. a: common_vendor.f(props.list, (item, index, i0) => {
  204. return common_vendor.e({
  205. a: item.type === "image"
  206. }, item.type === "image" ? {
  207. b: props.imageMode,
  208. c: item.src,
  209. d: common_vendor.o(onImgLoad, index)
  210. } : {
  211. e: common_vendor.sr((el) => refs.videoRef[`video_${index}`] = el, "b37b3c30-0-" + i0, {
  212. "f": 1
  213. }),
  214. f: (el) => refs.videoRef[`video_${index}`] = el,
  215. g: common_vendor.o(videoTimeupdate, index),
  216. h: "b37b3c30-0-" + i0,
  217. i: common_vendor.p({
  218. poster: common_vendor.unref(sheep_index.sheep).$url.cdn(item.poster),
  219. src: common_vendor.unref(sheep_index.sheep).$url.cdn(item.src),
  220. index,
  221. moveX: state.moveX,
  222. initialTime: item.currentTime || 0,
  223. height: __props.seizeHeight
  224. })
  225. }, {
  226. j: index,
  227. k: state.cur == index ? 1 : "",
  228. l: common_vendor.o(($event) => onSwiperItem(item), index)
  229. });
  230. }),
  231. b: props.circular,
  232. c: state.cur,
  233. d: props.autoplay && !state.videoPlaySataus,
  234. e: props.interval,
  235. f: props.duration,
  236. g: common_vendor.o(transition),
  237. h: common_vendor.o(animationfinish),
  238. i: common_vendor.s(common_vendor.unref(customStyle)),
  239. j: common_vendor.o(swiperChange),
  240. k: !state.videoPlaySataus
  241. }, !state.videoPlaySataus ? common_vendor.e({
  242. l: props.dotStyle != "tag"
  243. }, props.dotStyle != "tag" ? {
  244. m: common_vendor.f(props.list, (item, index, i0) => {
  245. return {
  246. a: index,
  247. b: common_vendor.n(state.cur == index ? "cur" : "")
  248. };
  249. }),
  250. n: common_vendor.n(props.dotCur),
  251. o: common_vendor.n(props.dotStyle)
  252. } : {}, {
  253. p: props.dotStyle == "tag"
  254. }, props.dotStyle == "tag" ? {
  255. q: common_vendor.t(state.cur + 1),
  256. r: common_vendor.t(props.list.length),
  257. s: common_vendor.n(props.dotCur),
  258. t: common_vendor.n(props.dotStyle)
  259. } : {}) : {}, {
  260. v: common_vendor.n(props.mode),
  261. w: common_vendor.n(props.bg),
  262. x: common_vendor.n(props.ui)
  263. });
  264. };
  265. }
  266. };
  267. const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-b37b3c30"], ["__file", "/Users/RuHu.Xu/Desktop/mall-newfeifan-zx-app/sheep/ui/su-swiper/su-swiper.vue"]]);
  268. wx.createComponent(Component);