store.js 9.3 KB

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