store.js 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  1. "use strict";
  2. var common_vendor = require("../common/vendor.js");
  3. var api_live = require("../api/live.js");
  4. require("../common/request.js");
  5. const _sfc_main = {
  6. data() {
  7. return {
  8. products: [],
  9. liveId: null,
  10. statusBarHeight: common_vendor.index.getWindowInfo().statusBarHeight,
  11. menuRight: common_vendor.index.getStorageSync("menuInfo").menuRight,
  12. menuWidth: common_vendor.index.getStorageSync("menuInfo").menuWidth,
  13. opacity: 0,
  14. opacityTxt: 0,
  15. tabbar: [{
  16. name: "\u5546\u54C1"
  17. }, {
  18. name: "\u5546\u5BB6"
  19. }],
  20. current: 0,
  21. storeInfo: {},
  22. divHeight: "0px",
  23. allCates: [],
  24. cates: [],
  25. subCates: [],
  26. cateSelect: 0,
  27. advs: [],
  28. from: ""
  29. };
  30. },
  31. onLoad(options) {
  32. if (options.liveId) {
  33. this.liveId = options.liveId;
  34. console.log("\u63A5\u6536\u5230\u7684liveId:", this.liveId);
  35. }
  36. this.storeId = options.storeId || "";
  37. this.from = options.from || "";
  38. if (this.storeId) {
  39. this.getStoreInfo();
  40. this.getProductCate();
  41. } else {
  42. common_vendor.index.showToast({
  43. title: "storeId\u4E0D\u5B58\u5728~",
  44. icon: "none"
  45. });
  46. }
  47. },
  48. mounted() {
  49. this.getliveStore();
  50. },
  51. onShow() {
  52. this.divHeight = `calc(100vh - 44px - 88rpx - ${this.statusBarHeight}px)`;
  53. },
  54. onPageScroll(e) {
  55. if (e.scrollTop <= 44) {
  56. this.opacityTxt = 0;
  57. this.opacity = e.scrollTop > this.statusBarHeight ? 0.6 : 0;
  58. } else if (e.scrollTop > 50) {
  59. this.opacity = 1;
  60. this.opacityTxt = 1;
  61. }
  62. },
  63. methods: {
  64. getliveStore() {
  65. let data = {
  66. pageSize: 10,
  67. page: 1
  68. };
  69. api_live.liveStore(this.liveId, data).then((res) => {
  70. if (res.code == 200) {
  71. console.log("\u5C0F\u9EC4\u8F66 \u5E97\u94FA\u5C55\u793A>>>>", res);
  72. this.products = res.data;
  73. } else {
  74. common_vendor.index.showToast({
  75. title: res.msg,
  76. icon: "none"
  77. });
  78. }
  79. }, (rej) => {
  80. });
  81. },
  82. rightClick() {
  83. common_vendor.index.navigateBack();
  84. },
  85. clickTab(item) {
  86. this.current = item.index;
  87. },
  88. previewImage(index) {
  89. common_vendor.index.previewImage({
  90. current: index,
  91. urls: this.licenseImagesList
  92. });
  93. },
  94. getStoreInfo() {
  95. getStoreById({
  96. storeId: this.storeId
  97. }).then((res) => {
  98. if (res.code == 200) {
  99. this.storeInfo = res.data || {};
  100. } else {
  101. common_vendor.index.showToast({
  102. icon: "none",
  103. title: res.msg
  104. });
  105. }
  106. }, (rej) => {
  107. });
  108. },
  109. toSearch() {
  110. if (this.from == "company") {
  111. common_vendor.index.navigateTo({
  112. url: "/pages_company/order/productList?storeId=" + this.storeId || ""
  113. });
  114. } else {
  115. common_vendor.index.navigateTo({
  116. url: "/pages/home/productSearch?storeId=" + this.storeId || ""
  117. });
  118. }
  119. },
  120. handleAdvClick(item) {
  121. if (item.showType == 1) {
  122. common_vendor.index.setStorageSync("url", item.advUrl);
  123. common_vendor.index.navigateTo({
  124. url: "/pages/home/h5?storeId=" + this.storeId || ""
  125. });
  126. } else if (item.showType == 2) {
  127. common_vendor.index.navigateTo({
  128. url: item.advUrl
  129. });
  130. } else if (item.showType == 3) {
  131. common_vendor.index.setStorageSync("content", item.content);
  132. common_vendor.index.navigateTo({
  133. url: "/pages/home/content?storeId=" + this.storeId || ""
  134. });
  135. }
  136. },
  137. getProductCate() {
  138. let data = {};
  139. getProductCate(data).then((res) => {
  140. if (res.code == 200) {
  141. this.allCates = res.data;
  142. this.cates = this.allCates.filter(function(item) {
  143. return item.pid == 0;
  144. });
  145. if (this.cates != null && this.cates.length > 0) {
  146. this.cateSelect = this.cates[0].cateId;
  147. this.getSubCate();
  148. }
  149. } else {
  150. common_vendor.index.showToast({
  151. icon: "none",
  152. title: "\u8BF7\u6C42\u5931\u8D25"
  153. });
  154. }
  155. }, (rej) => {
  156. });
  157. },
  158. choseCate(item) {
  159. this.cateSelect = item.cateId;
  160. this.getSubCate();
  161. },
  162. getSubCate() {
  163. var that = this;
  164. this.subCates = this.allCates.filter(function(item) {
  165. return item.pid == that.cateSelect;
  166. });
  167. },
  168. showProductList(item) {
  169. common_vendor.index.navigateTo({
  170. url: "/pages/shopping/productList?cateId=" + item.cateId + "&pid=" + item.pid + "&storeId=" + this.storeId + "&from=" + this.from
  171. });
  172. }
  173. }
  174. };
  175. if (!Array) {
  176. const _easycom_u_icon2 = common_vendor.resolveComponent("u-icon");
  177. const _easycom_u_image2 = common_vendor.resolveComponent("u-image");
  178. const _easycom_u_tabs2 = common_vendor.resolveComponent("u-tabs");
  179. const _easycom_u_sticky2 = common_vendor.resolveComponent("u-sticky");
  180. (_easycom_u_icon2 + _easycom_u_image2 + _easycom_u_tabs2 + _easycom_u_sticky2)();
  181. }
  182. const _easycom_u_icon = () => "../uni_modules/uview-plus/components/u-icon/u-icon.js";
  183. const _easycom_u_image = () => "../uni_modules/uview-plus/components/u-image/u-image.js";
  184. const _easycom_u_tabs = () => "../uni_modules/uview-plus/components/u-tabs/u-tabs.js";
  185. const _easycom_u_sticky = () => "../uni_modules/uview-plus/components/u-sticky/u-sticky.js";
  186. if (!Math) {
  187. (_easycom_u_icon + _easycom_u_image + _easycom_u_tabs + _easycom_u_sticky)();
  188. }
  189. function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  190. return common_vendor.e({
  191. a: $data.statusBarHeight + "px",
  192. b: common_vendor.o($options.rightClick),
  193. c: common_vendor.p({
  194. name: "arrow-left",
  195. color: "#333",
  196. size: "20"
  197. }),
  198. d: $data.opacity >= 0.6 ? "#f7f7f7" : "#fff",
  199. e: common_vendor.o((...args) => $options.toSearch && $options.toSearch(...args)),
  200. f: `calc(100vw - 100rpx - ${$data.menuRight} - ${$data.menuWidth})`,
  201. g: `rgba(58, 17, 1,${$data.opacity})`,
  202. h: common_vendor.p({
  203. shape: "square",
  204. src: $data.storeInfo.logoUrl || _ctx.logoUrl,
  205. width: "100rpx",
  206. height: "100rpx",
  207. radius: "6"
  208. }),
  209. i: common_vendor.t($data.storeInfo.storeName || ""),
  210. j: common_vendor.t($data.storeInfo.salesCount),
  211. k: $data.storeInfo.storeName,
  212. l: common_vendor.o($options.clickTab),
  213. m: common_vendor.p({
  214. list: $data.tabbar,
  215. current: $data.current
  216. }),
  217. n: common_vendor.p({
  218. bgColor: "#fff",
  219. ["offset-top"]: $data.statusBarHeight + 44
  220. }),
  221. o: common_vendor.f($data.cates, (item, index, i0) => {
  222. return {
  223. a: common_vendor.t(item.cateName),
  224. b: index,
  225. c: common_vendor.n($data.cateSelect == item.cateId ? "item active" : "item"),
  226. d: common_vendor.o(($event) => $options.choseCate(item), index)
  227. };
  228. }),
  229. p: common_vendor.f($data.advs, (item, index, i0) => {
  230. return {
  231. a: item.imageUrl,
  232. b: index,
  233. c: common_vendor.o(($event) => $options.handleAdvClick(item), index)
  234. };
  235. }),
  236. q: common_vendor.f($data.products, (subItem, index, i0) => {
  237. return {
  238. a: subItem.imgUrl,
  239. b: common_vendor.t(subItem.productName),
  240. c: index,
  241. d: common_vendor.o(($event) => $options.showProductList(subItem), index)
  242. };
  243. }),
  244. r: $data.divHeight,
  245. s: $data.current == 0 ? "flex" : "none",
  246. t: common_vendor.p({
  247. name: "map",
  248. color: "#ccc",
  249. size: "18"
  250. }),
  251. v: common_vendor.t($data.storeInfo.address || "--"),
  252. w: $data.storeInfo.phone
  253. }, $data.storeInfo.phone ? {
  254. x: common_vendor.p({
  255. name: "phone",
  256. color: "#ccc",
  257. size: "18"
  258. }),
  259. y: common_vendor.t($data.storeInfo.phone || "--")
  260. } : {}, {
  261. z: $data.storeInfo.descs
  262. }, $data.storeInfo.descs ? {
  263. A: common_vendor.p({
  264. name: "volume",
  265. color: "#ccc",
  266. size: "18"
  267. }),
  268. B: common_vendor.t($data.storeInfo.descs || "--")
  269. } : {}, {
  270. C: common_vendor.p({
  271. name: "file-text",
  272. color: "#ccc",
  273. size: "18"
  274. }),
  275. D: common_vendor.f(_ctx.licenseImagesList, (img, i, i0) => {
  276. return {
  277. a: common_vendor.o(($event) => $options.previewImage(i)),
  278. b: "f7aaac1e-8-" + i0,
  279. c: common_vendor.p({
  280. shape: "square",
  281. lazyLoad: true,
  282. src: img,
  283. width: "100%",
  284. mode: "widthFix",
  285. radius: "6"
  286. }),
  287. d: i
  288. };
  289. }),
  290. E: $data.divHeight,
  291. F: $data.current == 1
  292. });
  293. }
  294. var MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-f7aaac1e"], ["__file", "C:/Users/Administrator/Desktop/\u9879\u76EE/\u76F4\u64AD/liveH5-v3/pages_shop/store.vue"]]);
  295. _sfc_main.__runtimeHooks = 1;
  296. wx.createPage(MiniProgramPage);