store.js 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336
  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. inputInfo: "",
  9. inputno: "",
  10. searchTimer: null,
  11. tabList: [{
  12. name: "推荐"
  13. }, {
  14. name: "分类"
  15. }],
  16. products: [],
  17. liveId: null,
  18. storeId: null,
  19. statusBarHeight: common_vendor.index.getWindowInfo().statusBarHeight,
  20. // 右侧的胶囊距离右侧屏幕距离-px
  21. menuRight: common_vendor.index.getStorageSync("menuInfo").menuRight,
  22. // 右侧的胶囊宽度-px
  23. menuWidth: common_vendor.index.getStorageSync("menuInfo").menuWidth,
  24. opacity: 0,
  25. opacityTxt: 0,
  26. tabbar: [{
  27. name: "商品"
  28. }, {
  29. name: "商家"
  30. }],
  31. current: 0,
  32. storeInfo: {},
  33. // logoUrl: "/static/images/adfd21c004854c9b8997d371d7a0ce8c.jpg",
  34. // 商家资质图片
  35. // licenseImagesList: ["/static/images/sjzz.jpg"],
  36. divHeight: "0px",
  37. allCates: [],
  38. cates: [],
  39. subCates: [],
  40. // 选中药品分类
  41. cateSelect: 0,
  42. // 轮播图
  43. advs: [],
  44. // 'company'表示销售管理的进来的
  45. from: ""
  46. };
  47. },
  48. onLoad(options) {
  49. console.log("接收到的options:", options);
  50. if (options.liveId) {
  51. this.liveId = options.liveId;
  52. this.getliveStore();
  53. console.log("接收到的liveId:", this.liveId);
  54. }
  55. if (options.storeId) {
  56. this.storeId = options.storeId || "";
  57. } else {
  58. common_vendor.index.showToast({
  59. title: "storeId不存在~",
  60. icon: "none"
  61. });
  62. }
  63. },
  64. mounted() {
  65. this.getSearchStore();
  66. },
  67. onShow() {
  68. this.divHeight = `calc(100vh - 44px - 88rpx - ${this.statusBarHeight}px)`;
  69. },
  70. onPageScroll(e) {
  71. if (e.scrollTop <= 44) {
  72. this.opacityTxt = 0;
  73. this.opacity = e.scrollTop > this.statusBarHeight ? 0.6 : 0;
  74. } else if (e.scrollTop > 50) {
  75. this.opacity = 1;
  76. this.opacityTxt = 1;
  77. }
  78. },
  79. methods: {
  80. handleSearchInput() {
  81. clearTimeout(this.searchTimer);
  82. this.searchTimer = setTimeout(() => {
  83. this.getliveStore();
  84. }, 500);
  85. },
  86. getPureDecimal(num, precision = 6) {
  87. const decimalPart = Math.abs(num).toFixed(precision).split(".")[1];
  88. return (decimalPart == null ? void 0 : decimalPart.replace(/0+$/, "")) || "";
  89. },
  90. //店铺展示
  91. getliveStore() {
  92. let data = {
  93. pageSize: 10,
  94. page: 1
  95. };
  96. api_live.liveStore(this.liveId, this.inputInfo, data).then(
  97. (res) => {
  98. if (res.code == 200) {
  99. console.log("小黄车 店铺展示>>>>", res);
  100. this.products = res.data;
  101. } else {
  102. common_vendor.index.showToast({
  103. title: res.msg,
  104. icon: "none"
  105. });
  106. }
  107. },
  108. (rej) => {
  109. }
  110. );
  111. },
  112. //查询店铺
  113. getSearchStore() {
  114. if (!this.storeId)
  115. return;
  116. api_live.store(this.storeId, this.inputno).then(
  117. (res) => {
  118. if (res.code == 200) {
  119. console.log("查询店铺>>>>", res);
  120. this.storeInfo = res.data;
  121. } else {
  122. common_vendor.index.showToast({
  123. title: res.msg,
  124. icon: "none"
  125. });
  126. }
  127. },
  128. (rej) => {
  129. }
  130. );
  131. },
  132. rightClick() {
  133. const pages = getCurrentPages();
  134. if (pages.length > 1) {
  135. common_vendor.index.navigateBack();
  136. } else {
  137. common_vendor.index.redirectTo({
  138. url: "/pages/home/living"
  139. // 替换为你的首页路径
  140. });
  141. }
  142. },
  143. clickTab(item) {
  144. this.current = item.index;
  145. },
  146. // 预览图片
  147. previewImage(index) {
  148. common_vendor.index.previewImage({
  149. current: index,
  150. urls: this.licenseImagesList
  151. });
  152. },
  153. // getStoreInfo() {
  154. // getStoreById({
  155. // storeId: this.storeId
  156. // }).then(
  157. // res => {
  158. // if (res.code == 200) {
  159. // this.storeInfo = res.data || {}
  160. // // this.licenseImagesList = this.storeInfo.licenseImages ? this.storeInfo.licenseImages.split(',') : []
  161. // } else {
  162. // uni.showToast({
  163. // icon: 'none',
  164. // title: res.msg,
  165. // });
  166. // }
  167. // },
  168. // rej => {}
  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([($event) => $data.inputInfo = $event.detail.value, (...args) => $options.handleSearchInput && $options.handleSearchInput(...args)]),
  264. f: $data.inputInfo,
  265. g: common_vendor.o((...args) => _ctx.toSearch && _ctx.toSearch(...args)),
  266. h: common_vendor.p({
  267. shape: "square",
  268. src: $data.storeInfo.logoUrl || _ctx.logoUrl,
  269. width: "100rpx",
  270. height: "100rpx",
  271. radius: "6"
  272. }),
  273. i: common_vendor.t($data.storeInfo.storeName || ""),
  274. j: common_vendor.t($data.storeInfo.salesCount),
  275. k: $data.storeInfo.storeName,
  276. l: common_vendor.f($data.products, (subItem, index, i0) => {
  277. return {
  278. a: subItem.imgUrl,
  279. b: common_vendor.t(subItem.productName),
  280. c: common_vendor.t(Math.trunc(subItem.price)),
  281. d: common_vendor.t($options.getPureDecimal(subItem.price) ? $options.getPureDecimal(subItem.price) : "00"),
  282. e: index,
  283. f: common_vendor.o(($event) => $options.showProductList(subItem), index)
  284. };
  285. }),
  286. m: common_vendor.p({
  287. name: "map",
  288. color: "#ccc",
  289. size: "18"
  290. }),
  291. n: common_vendor.t($data.storeInfo.address || "--"),
  292. o: $data.storeInfo.phone
  293. }, $data.storeInfo.phone ? {
  294. p: common_vendor.p({
  295. name: "phone",
  296. color: "#ccc",
  297. size: "18"
  298. }),
  299. q: common_vendor.t($data.storeInfo.phone || "--")
  300. } : {}, {
  301. r: $data.storeInfo.descs
  302. }, $data.storeInfo.descs ? {
  303. s: common_vendor.p({
  304. name: "volume",
  305. color: "#ccc",
  306. size: "18"
  307. }),
  308. t: common_vendor.t($data.storeInfo.descs || "--")
  309. } : {}, {
  310. v: common_vendor.p({
  311. name: "file-text",
  312. color: "#ccc",
  313. size: "18"
  314. }),
  315. w: common_vendor.f(_ctx.licenseImagesList, (img, i, i0) => {
  316. return {
  317. a: common_vendor.o(($event) => $options.previewImage(i), i),
  318. b: "dd5fc6f3-6-" + i0,
  319. c: common_vendor.p({
  320. shape: "square",
  321. lazyLoad: true,
  322. src: img,
  323. width: "100%",
  324. mode: "widthFix",
  325. radius: "6"
  326. }),
  327. d: i
  328. };
  329. }),
  330. x: $data.divHeight,
  331. y: $data.current == 1
  332. });
  333. }
  334. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-dd5fc6f3"]]);
  335. _sfc_main.__runtimeHooks = 1;
  336. wx.createPage(MiniProgramPage);