store.js 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  1. "use strict";
  2. const common_vendor = require("../common/vendor.js");
  3. const api_live = require("../api/live.js");
  4. const common_assets = require("../common/assets.js");
  5. const _sfc_main = {
  6. data() {
  7. return {
  8. products: [],
  9. liveId: null,
  10. statusBarHeight: common_vendor.index.getWindowInfo().statusBarHeight,
  11. // 右侧的胶囊距离右侧屏幕距离-px
  12. menuRight: common_vendor.index.getStorageSync("menuInfo").menuRight,
  13. // 右侧的胶囊宽度-px
  14. menuWidth: common_vendor.index.getStorageSync("menuInfo").menuWidth,
  15. opacity: 0,
  16. opacityTxt: 0,
  17. // storeId: "",
  18. tabbar: [{
  19. name: "商品"
  20. }, {
  21. name: "商家"
  22. }],
  23. current: 0,
  24. storeInfo: {},
  25. // logoUrl: "/static/images/adfd21c004854c9b8997d371d7a0ce8c.jpg",
  26. // 商家资质图片
  27. // licenseImagesList: ["/static/images/sjzz.jpg"],
  28. divHeight: "0px",
  29. allCates: [],
  30. cates: [],
  31. subCates: [],
  32. // 选中药品分类
  33. cateSelect: 0,
  34. // 轮播图
  35. advs: [],
  36. // 'company'表示销售管理的进来的
  37. from: ""
  38. };
  39. },
  40. onLoad(options) {
  41. if (options.liveId) {
  42. this.liveId = options.liveId;
  43. console.log("接收到的liveId:", this.liveId);
  44. }
  45. this.storeId = options.storeId || "";
  46. this.from = options.from || "";
  47. if (this.storeId) {
  48. this.getStoreInfo();
  49. this.getProductCate();
  50. } else {
  51. common_vendor.index.showToast({
  52. title: "storeId不存在~",
  53. icon: "none"
  54. });
  55. }
  56. },
  57. mounted() {
  58. this.getliveStore();
  59. },
  60. onShow() {
  61. this.divHeight = `calc(100vh - 44px - 88rpx - ${this.statusBarHeight}px)`;
  62. },
  63. onPageScroll(e) {
  64. if (e.scrollTop <= 44) {
  65. this.opacityTxt = 0;
  66. this.opacity = e.scrollTop > this.statusBarHeight ? 0.6 : 0;
  67. } else if (e.scrollTop > 50) {
  68. this.opacity = 1;
  69. this.opacityTxt = 1;
  70. }
  71. },
  72. methods: {
  73. //小黄车 店铺展示
  74. getliveStore() {
  75. let data = {
  76. pageSize: 10,
  77. page: 1
  78. };
  79. api_live.liveStore(this.liveId, data).then(
  80. (res) => {
  81. if (res.code == 200) {
  82. console.log("小黄车 店铺展示>>>>", res);
  83. this.products = res.data;
  84. } else {
  85. common_vendor.index.showToast({
  86. title: res.msg,
  87. icon: "none"
  88. });
  89. }
  90. },
  91. (rej) => {
  92. }
  93. );
  94. },
  95. rightClick() {
  96. common_vendor.index.navigateBack();
  97. },
  98. clickTab(item) {
  99. this.current = item.index;
  100. },
  101. // 预览图片
  102. previewImage(index) {
  103. common_vendor.index.previewImage({
  104. current: index,
  105. urls: this.licenseImagesList
  106. });
  107. },
  108. getStoreInfo() {
  109. getStoreById({
  110. storeId: this.storeId
  111. }).then(
  112. (res) => {
  113. if (res.code == 200) {
  114. this.storeInfo = res.data || {};
  115. } else {
  116. common_vendor.index.showToast({
  117. icon: "none",
  118. title: res.msg
  119. });
  120. }
  121. },
  122. (rej) => {
  123. }
  124. );
  125. },
  126. toSearch() {
  127. if (this.from == "company") {
  128. common_vendor.index.navigateTo({
  129. url: "/pages_company/order/productList?storeId=" + this.storeId || ""
  130. });
  131. } else {
  132. common_vendor.index.navigateTo({
  133. url: "/pages/home/productSearch?storeId=" + this.storeId || ""
  134. });
  135. }
  136. },
  137. handleAdvClick(item) {
  138. if (item.showType == 1) {
  139. common_vendor.index.setStorageSync("url", item.advUrl);
  140. common_vendor.index.navigateTo({
  141. url: "/pages/home/h5?storeId=" + this.storeId || ""
  142. });
  143. } else if (item.showType == 2) {
  144. common_vendor.index.navigateTo({
  145. url: item.advUrl
  146. });
  147. } else if (item.showType == 3) {
  148. common_vendor.index.setStorageSync("content", item.content);
  149. common_vendor.index.navigateTo({
  150. url: "/pages/home/content?storeId=" + this.storeId || ""
  151. });
  152. }
  153. },
  154. // getAdv() {
  155. // let data = {
  156. // advType: 2
  157. // };
  158. // getAdv(data).then(
  159. // res => {
  160. // if (res.code == 200) {
  161. // this.advs = res.data;
  162. // }
  163. // },
  164. // rej => {}
  165. // );
  166. // },
  167. getProductCate() {
  168. let data = {};
  169. getProductCate(data).then(
  170. (res) => {
  171. if (res.code == 200) {
  172. this.allCates = res.data;
  173. this.cates = this.allCates.filter(function(item) {
  174. return item.pid == 0;
  175. });
  176. if (this.cates != null && this.cates.length > 0) {
  177. this.cateSelect = this.cates[0].cateId;
  178. this.getSubCate();
  179. }
  180. } else {
  181. common_vendor.index.showToast({
  182. icon: "none",
  183. title: "请求失败"
  184. });
  185. }
  186. },
  187. (rej) => {
  188. }
  189. );
  190. },
  191. // 药品分类选择
  192. choseCate(item) {
  193. this.cateSelect = item.cateId;
  194. this.getSubCate();
  195. },
  196. getSubCate() {
  197. var that = this;
  198. this.subCates = this.allCates.filter(function(item) {
  199. return item.pid == that.cateSelect;
  200. });
  201. },
  202. // 查看药品详情
  203. showProductList(item) {
  204. common_vendor.index.navigateTo({
  205. url: "/pages/shopping/productList?cateId=" + item.cateId + "&pid=" + item.pid + "&storeId=" + this.storeId + "&from=" + this.from
  206. });
  207. }
  208. }
  209. };
  210. if (!Array) {
  211. const _easycom_u_icon2 = common_vendor.resolveComponent("u-icon");
  212. const _easycom_u_image2 = common_vendor.resolveComponent("u-image");
  213. const _easycom_u_tabs2 = common_vendor.resolveComponent("u-tabs");
  214. const _easycom_u_sticky2 = common_vendor.resolveComponent("u-sticky");
  215. (_easycom_u_icon2 + _easycom_u_image2 + _easycom_u_tabs2 + _easycom_u_sticky2)();
  216. }
  217. const _easycom_u_icon = () => "../uni_modules/uview-plus/components/u-icon/u-icon.js";
  218. const _easycom_u_image = () => "../uni_modules/uview-plus/components/u-image/u-image.js";
  219. const _easycom_u_tabs = () => "../uni_modules/uview-plus/components/u-tabs/u-tabs.js";
  220. const _easycom_u_sticky = () => "../uni_modules/uview-plus/components/u-sticky/u-sticky.js";
  221. if (!Math) {
  222. (_easycom_u_icon + _easycom_u_image + _easycom_u_tabs + _easycom_u_sticky)();
  223. }
  224. function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  225. return common_vendor.e({
  226. a: $data.statusBarHeight + "px",
  227. b: common_vendor.o($options.rightClick),
  228. c: common_vendor.p({
  229. name: "arrow-left",
  230. color: "#ffffff",
  231. size: "20"
  232. }),
  233. d: common_assets._imports_0$1,
  234. e: $data.opacity >= 0.6 ? "#6b4d40" : "#fff",
  235. f: common_vendor.o((...args) => $options.toSearch && $options.toSearch(...args)),
  236. g: `calc(100vw - 100rpx - ${$data.menuRight} - ${$data.menuWidth})`,
  237. h: `rgba(58, 17, 1,${$data.opacity})`,
  238. i: common_vendor.p({
  239. shape: "square",
  240. src: $data.storeInfo.logoUrl || _ctx.logoUrl,
  241. width: "100rpx",
  242. height: "100rpx",
  243. radius: "6"
  244. }),
  245. j: common_vendor.t($data.storeInfo.storeName || ""),
  246. k: common_vendor.t($data.storeInfo.salesCount),
  247. l: $data.storeInfo.storeName,
  248. m: common_vendor.o($options.clickTab),
  249. n: common_vendor.p({
  250. list: $data.tabbar,
  251. current: $data.current
  252. }),
  253. o: common_vendor.p({
  254. bgColor: "#fff",
  255. ["offset-top"]: $data.statusBarHeight + 44
  256. }),
  257. p: common_vendor.f($data.cates, (item, index, i0) => {
  258. return {
  259. a: common_vendor.t(item.cateName),
  260. b: index,
  261. c: common_vendor.n($data.cateSelect == item.cateId ? "item active" : "item"),
  262. d: common_vendor.o(($event) => $options.choseCate(item), index)
  263. };
  264. }),
  265. q: common_vendor.f($data.advs, (item, index, i0) => {
  266. return {
  267. a: item.imageUrl,
  268. b: index,
  269. c: common_vendor.o(($event) => $options.handleAdvClick(item), index)
  270. };
  271. }),
  272. r: common_vendor.f($data.products, (subItem, index, i0) => {
  273. return {
  274. a: subItem.imgUrl,
  275. b: common_vendor.t(subItem.productName),
  276. c: index,
  277. d: common_vendor.o(($event) => $options.showProductList(subItem), index)
  278. };
  279. }),
  280. s: $data.divHeight,
  281. t: $data.current == 0 ? "flex" : "none",
  282. v: common_vendor.p({
  283. name: "map",
  284. color: "#ccc",
  285. size: "18"
  286. }),
  287. w: common_vendor.t($data.storeInfo.address || "--"),
  288. x: $data.storeInfo.phone
  289. }, $data.storeInfo.phone ? {
  290. y: common_vendor.p({
  291. name: "phone",
  292. color: "#ccc",
  293. size: "18"
  294. }),
  295. z: common_vendor.t($data.storeInfo.phone || "--")
  296. } : {}, {
  297. A: $data.storeInfo.descs
  298. }, $data.storeInfo.descs ? {
  299. B: common_vendor.p({
  300. name: "volume",
  301. color: "#ccc",
  302. size: "18"
  303. }),
  304. C: common_vendor.t($data.storeInfo.descs || "--")
  305. } : {}, {
  306. D: common_vendor.p({
  307. name: "file-text",
  308. color: "#ccc",
  309. size: "18"
  310. }),
  311. E: common_vendor.f(_ctx.licenseImagesList, (img, i, i0) => {
  312. return {
  313. a: common_vendor.o(($event) => $options.previewImage(i), i),
  314. b: "dd5fc6f3-8-" + i0,
  315. c: common_vendor.p({
  316. shape: "square",
  317. lazyLoad: true,
  318. src: img,
  319. width: "100%",
  320. mode: "widthFix",
  321. radius: "6"
  322. }),
  323. d: i
  324. };
  325. }),
  326. F: $data.divHeight,
  327. G: $data.current == 1
  328. });
  329. }
  330. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-dd5fc6f3"]]);
  331. _sfc_main.__runtimeHooks = 1;
  332. wx.createPage(MiniProgramPage);