store.js 9.5 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. 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. this.storeId = options.storeId || "";
  53. this.getSearchStore();
  54. },
  55. onShow() {
  56. this.divHeight = `calc(100vh - 44px - 88rpx - ${this.statusBarHeight}px)`;
  57. },
  58. onPageScroll(e) {
  59. if (e.scrollTop <= 44) {
  60. this.opacityTxt = 0;
  61. this.opacity = e.scrollTop > this.statusBarHeight ? 0.6 : 0;
  62. } else if (e.scrollTop > 50) {
  63. this.opacity = 1;
  64. this.opacityTxt = 1;
  65. }
  66. },
  67. methods: {
  68. getPureDecimal(num, precision = 6) {
  69. const decimalPart = Math.abs(num).toFixed(precision).split(".")[1];
  70. return (decimalPart == null ? void 0 : decimalPart.replace(/0+$/, "")) || "";
  71. },
  72. //店铺展示
  73. getliveStore() {
  74. let data = {
  75. pageSize: 10,
  76. page: 1
  77. };
  78. api_live.liveStore(this.liveId, data).then(
  79. (res) => {
  80. if (res.code == 200) {
  81. console.log("小黄车 店铺展示>>>>", res);
  82. this.products = res.data;
  83. } else {
  84. common_vendor.index.showToast({
  85. title: res.msg,
  86. icon: "none"
  87. });
  88. }
  89. },
  90. (rej) => {
  91. }
  92. );
  93. },
  94. //查询店铺
  95. getSearchStore() {
  96. console.log("查询店铺", this.storeId);
  97. api_live.searchStore(this.storeId).then(
  98. (res) => {
  99. if (res.code == 200) {
  100. console.log("查询店铺>>>>", res);
  101. } else {
  102. common_vendor.index.showToast({
  103. title: res.msg,
  104. icon: "none"
  105. });
  106. }
  107. },
  108. (rej) => {
  109. }
  110. );
  111. },
  112. rightClick() {
  113. common_vendor.index.navigateBack();
  114. },
  115. clickTab(item) {
  116. this.current = item.index;
  117. },
  118. // 预览图片
  119. previewImage(index) {
  120. common_vendor.index.previewImage({
  121. current: index,
  122. urls: this.licenseImagesList
  123. });
  124. },
  125. // getStoreInfo() {
  126. // getStoreById({
  127. // storeId: this.storeId
  128. // }).then(
  129. // res => {
  130. // if (res.code == 200) {
  131. // this.storeInfo = res.data || {}
  132. // // this.licenseImagesList = this.storeInfo.licenseImages ? this.storeInfo.licenseImages.split(',') : []
  133. // } else {
  134. // uni.showToast({
  135. // icon: 'none',
  136. // title: res.msg,
  137. // });
  138. // }
  139. // },
  140. // rej => {}
  141. // );
  142. // },
  143. toSearch() {
  144. if (this.from == "company") {
  145. common_vendor.index.navigateTo({
  146. url: "/pages_company/order/productList?storeId=" + this.storeId || ""
  147. });
  148. } else {
  149. common_vendor.index.navigateTo({
  150. url: "/pages/home/productSearch?storeId=" + this.storeId || ""
  151. });
  152. }
  153. },
  154. handleAdvClick(item) {
  155. if (item.showType == 1) {
  156. common_vendor.index.setStorageSync("url", item.advUrl);
  157. common_vendor.index.navigateTo({
  158. url: "/pages/home/h5?storeId=" + this.storeId || ""
  159. });
  160. } else if (item.showType == 2) {
  161. common_vendor.index.navigateTo({
  162. url: item.advUrl
  163. });
  164. } else if (item.showType == 3) {
  165. common_vendor.index.setStorageSync("content", item.content);
  166. common_vendor.index.navigateTo({
  167. url: "/pages/home/content?storeId=" + this.storeId || ""
  168. });
  169. }
  170. },
  171. // getAdv() {
  172. // let data = {
  173. // advType: 2
  174. // };
  175. // getAdv(data).then(
  176. // res => {
  177. // if (res.code == 200) {
  178. // this.advs = res.data;
  179. // }
  180. // },
  181. // rej => {}
  182. // );
  183. // },
  184. // getProductCate() {
  185. // let data = {};
  186. // getProductCate(data).then(
  187. // res => {
  188. // if (res.code == 200) {
  189. // this.allCates = res.data;
  190. // this.cates = this.allCates.filter(function(item) {
  191. // return item.pid == 0
  192. // });
  193. // if (this.cates != null && this.cates.length > 0) {
  194. // this.cateSelect = this.cates[0].cateId;
  195. // this.getSubCate()
  196. // }
  197. // } else {
  198. // uni.showToast({
  199. // icon: 'none',
  200. // title: "请求失败",
  201. // });
  202. // }
  203. // },
  204. // rej => {}
  205. // );
  206. // },
  207. // 药品分类选择
  208. choseCate(item) {
  209. this.cateSelect = item.cateId;
  210. this.getSubCate();
  211. },
  212. getSubCate() {
  213. var that = this;
  214. this.subCates = this.allCates.filter(function(item) {
  215. return item.pid == that.cateSelect;
  216. });
  217. },
  218. // 查看药品详情
  219. showProductList(item) {
  220. common_vendor.index.navigateTo({
  221. url: "/pages/shopping/productList?cateId=" + item.cateId + "&pid=" + item.pid + "&storeId=" + this.storeId + "&from=" + this.from
  222. });
  223. }
  224. }
  225. };
  226. if (!Array) {
  227. const _easycom_u_icon2 = common_vendor.resolveComponent("u-icon");
  228. const _easycom_u_image2 = common_vendor.resolveComponent("u-image");
  229. const _easycom_u_tabs2 = common_vendor.resolveComponent("u-tabs");
  230. (_easycom_u_icon2 + _easycom_u_image2 + _easycom_u_tabs2)();
  231. }
  232. const _easycom_u_icon = () => "../uni_modules/uview-plus/components/u-icon/u-icon.js";
  233. const _easycom_u_image = () => "../uni_modules/uview-plus/components/u-image/u-image.js";
  234. const _easycom_u_tabs = () => "../uni_modules/uview-plus/components/u-tabs/u-tabs.js";
  235. if (!Math) {
  236. (_easycom_u_icon + _easycom_u_image + _easycom_u_tabs)();
  237. }
  238. function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  239. return common_vendor.e({
  240. a: $data.statusBarHeight + "px",
  241. b: common_vendor.o($options.rightClick),
  242. c: common_vendor.p({
  243. name: "arrow-left",
  244. color: "#ffffff",
  245. size: "20"
  246. }),
  247. d: common_assets._imports_0$9,
  248. e: $data.opacity >= 0.6 ? "#6b4d40" : "#6b4d40",
  249. f: common_vendor.o((...args) => $options.toSearch && $options.toSearch(...args)),
  250. g: `rgba(58, 17, 1,1)`,
  251. h: common_vendor.p({
  252. shape: "square",
  253. src: $data.storeInfo.logoUrl || _ctx.logoUrl,
  254. width: "100rpx",
  255. height: "100rpx",
  256. radius: "6"
  257. }),
  258. i: common_vendor.t($data.storeInfo.storeName || ""),
  259. j: common_vendor.t($data.storeInfo.salesCount),
  260. k: $data.storeInfo.storeName,
  261. l: common_vendor.o(_ctx.selectTabList),
  262. m: common_vendor.p({
  263. list: $data.tabList,
  264. lineColor: "linear-gradient( 90deg, #FE8227 0%, #FE4E12 100%)",
  265. activeStyle: {
  266. color: "#222222",
  267. fontWeight: "600",
  268. fontSize: "28rpx"
  269. },
  270. inactiveStyle: {
  271. color: "#757575",
  272. fontSize: "28rpx",
  273. fontWeight: "400"
  274. }
  275. }),
  276. n: 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. o: common_vendor.p({
  287. name: "map",
  288. color: "#ccc",
  289. size: "18"
  290. }),
  291. p: common_vendor.t($data.storeInfo.address || "--"),
  292. q: $data.storeInfo.phone
  293. }, $data.storeInfo.phone ? {
  294. r: common_vendor.p({
  295. name: "phone",
  296. color: "#ccc",
  297. size: "18"
  298. }),
  299. s: common_vendor.t($data.storeInfo.phone || "--")
  300. } : {}, {
  301. t: $data.storeInfo.descs
  302. }, $data.storeInfo.descs ? {
  303. v: common_vendor.p({
  304. name: "volume",
  305. color: "#ccc",
  306. size: "18"
  307. }),
  308. w: common_vendor.t($data.storeInfo.descs || "--")
  309. } : {}, {
  310. x: common_vendor.p({
  311. name: "file-text",
  312. color: "#ccc",
  313. size: "18"
  314. }),
  315. y: common_vendor.f(_ctx.licenseImagesList, (img, i, i0) => {
  316. return {
  317. a: common_vendor.o(($event) => $options.previewImage(i), i),
  318. b: "dd5fc6f3-7-" + 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. z: $data.divHeight,
  331. A: $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);