123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361 |
- "use strict";
- const common_vendor = require("../common/vendor.js");
- const api_live = require("../api/live.js");
- const common_assets = require("../common/assets.js");
- const _sfc_main = {
- data() {
- return {
- page: 1,
- // 当前页码,初始为1
- pageSize: 6,
- // 每页条数(和之前保持一致)
- isLoading: false,
- // 是否正在加载数据,防止重复请求
- hasMore: true,
- // 是否还有更多数据
- inputInfo: "",
- searchTimer: null,
- tabList: [{
- name: "推荐"
- }, {
- name: "分类"
- }],
- products: [],
- liveId: null,
- storeId: null,
- statusBarHeight: common_vendor.index.getWindowInfo().statusBarHeight,
- // 右侧的胶囊距离右侧屏幕距离-px
- menuRight: common_vendor.index.getStorageSync("menuInfo").menuRight,
- // 右侧的胶囊宽度-px
- menuWidth: common_vendor.index.getStorageSync("menuInfo").menuWidth,
- opacity: 0,
- opacityTxt: 0,
- tabbar: [{
- name: "商品"
- }, {
- name: "商家"
- }],
- current: 0,
- storeInfo: {},
- // logoUrl: "/static/images/adfd21c004854c9b8997d371d7a0ce8c.jpg",
- // 商家资质图片
- // licenseImagesList: ["/static/images/sjzz.jpg"],
- divHeight: "0px",
- allCates: [],
- cates: [],
- subCates: [],
- // 选中药品分类
- cateSelect: 0,
- // 轮播图
- advs: [],
- // 'company'表示销售管理的进来的
- from: ""
- };
- },
- onLoad(options) {
- console.log("接收到的options:", options);
- if (options.liveId) {
- this.liveId = options.liveId;
- console.log("接收到的liveId:", this.liveId);
- }
- if (options.storeId) {
- this.storeId = options.storeId || "";
- } else {
- common_vendor.index.showToast({
- title: "storeId不存在~",
- icon: "none"
- });
- }
- },
- mounted() {
- this.queryStore();
- this.queryCollect();
- },
- onShow() {
- this.divHeight = `calc(100vh - 44px - 88rpx - ${this.statusBarHeight}px)`;
- },
- onPageScroll(e) {
- if (e.scrollTop <= 44) {
- this.opacityTxt = 0;
- this.opacity = e.scrollTop > this.statusBarHeight ? 0.6 : 0;
- } else if (e.scrollTop > 50) {
- this.opacity = 1;
- this.opacityTxt = 1;
- }
- if (this.isLoading || !this.hasMore)
- return;
- const {
- scrollHeight,
- scrollTop,
- windowHeight
- } = common_vendor.index.getSystemInfoSync();
- const distanceToBottom = scrollHeight - scrollTop - windowHeight;
- if (distanceToBottom < 300) {
- this.page++;
- this.queryStore();
- }
- },
- methods: {
- handleSearchInput() {
- clearTimeout(this.searchTimer);
- this.searchTimer = setTimeout(() => {
- this.page = 1;
- this.hasMore = true;
- this.queryStore();
- }, 500);
- },
- getPureDecimal(num, precision = 6) {
- const decimalPart = Math.abs(num).toFixed(precision).split(".")[1];
- return (decimalPart == null ? void 0 : decimalPart.replace(/0+$/, "")) || "";
- },
- // // 店铺商品展示(支持分页)
- // getliveStore() {
- // // 如果正在加载或没有更多数据,直接返回
- // if (this.isLoading || !this.hasMore) return;
- // this.isLoading = true; // 标记为加载中
- // const data = {
- // pageSize: this.pageSize,
- // page: this.page // 使用当前页码
- // };
- // liveStore(this.liveId, this.inputInfo, data)
- // .then(res => {
- // this.isLoading = false; // 结束加载状态
- // if (res.code === 200) {
- // const newProducts = res.data || [];
- // // 如果是第一页,直接替换数据;否则合并数据
- // if (this.page === 1) {
- // this.products = newProducts;
- // } else {
- // this.products = [...this.products, ...newProducts];
- // }
- // // 判断是否还有更多数据(如果返回的数量小于每页条数,说明没有更多了)
- // this.hasMore = newProducts.length >= this.pageSize;
- // } else {
- // uni.showToast({
- // title: res.msg,
- // icon: 'none'
- // });
- // }
- // })
- // .catch(rej => {
- // this.isLoading = false; // 异常时也要结束加载状态
- // uni.showToast({
- // title: '加载失败',
- // icon: 'none'
- // });
- // });
- // },
- //查询店铺
- queryStore() {
- if (!this.storeId)
- return;
- if (this.isLoading || !this.hasMore)
- return;
- this.isLoading = true;
- api_live.queryStore(this.storeId, this.pageSize, this.page, this.inputInfo).then(
- (res) => {
- this.isLoading = false;
- if (res.code == 200) {
- const newProducts = res.rows || [];
- if (this.page === 1) {
- this.products = newProducts;
- } else {
- this.products = [...this.products, ...newProducts];
- }
- this.hasMore = newProducts.length >= this.pageSize;
- } else {
- common_vendor.index.showToast({
- title: res.msg,
- icon: "none"
- });
- }
- },
- (rej) => {
- }
- );
- },
- // 小黄车查询店铺
- queryCollect() {
- if (!this.storeId)
- return;
- api_live.store(this.storeId, "").then(
- (res) => {
- if (res.code == 200) {
- console.log("查询店铺>>", res);
- this.storeInfo = res.data;
- } else {
- common_vendor.index.showToast({
- title: res.msg,
- icon: "none"
- });
- }
- },
- (rej) => {
- }
- );
- },
- rightClick() {
- const pages = getCurrentPages();
- if (pages.length > 1) {
- common_vendor.index.navigateBack();
- } else {
- common_vendor.index.redirectTo({
- url: "/pages/home/living"
- // 替换为你的首页路径
- });
- }
- },
- clickTab(item) {
- this.current = item.index;
- },
- // 预览图片
- previewImage(index) {
- common_vendor.index.previewImage({
- current: index,
- urls: this.licenseImagesList
- });
- },
- // getStoreInfo() {
- // getStoreById({
- // storeId: this.storeId
- // }).then(
- // res => {
- // if (res.code == 200) {
- // this.storeInfo = res.data || {}
- // // this.licenseImagesList = this.storeInfo.licenseImages ? this.storeInfo.licenseImages.split(',') : []
- // } else {
- // uni.showToast({
- // icon: 'none',
- // title: res.msg,
- // });
- // }
- // },
- // rej => {}
- // );
- // },
- handleAdvClick(item) {
- if (item.showType == 1) {
- common_vendor.index.setStorageSync("url", item.advUrl);
- common_vendor.index.navigateTo({
- url: "/pages/home/h5?storeId=" + this.storeId || ""
- });
- } else if (item.showType == 2) {
- common_vendor.index.navigateTo({
- url: item.advUrl
- });
- } else if (item.showType == 3) {
- common_vendor.index.setStorageSync("content", item.content);
- common_vendor.index.navigateTo({
- url: "/pages/home/content?storeId=" + this.storeId || ""
- });
- }
- },
- // getAdv() {
- // let data = {
- // advType: 2
- // };
- // getAdv(data).then(
- // res => {
- // if (res.code == 200) {
- // this.advs = res.data;
- // }
- // },
- // rej => {}
- // );
- // },
- // getProductCate() {
- // let data = {};
- // getProductCate(data).then(
- // res => {
- // if (res.code == 200) {
- // this.allCates = res.data;
- // this.cates = this.allCates.filter(function(item) {
- // return item.pid == 0
- // });
- // if (this.cates != null && this.cates.length > 0) {
- // this.cateSelect = this.cates[0].cateId;
- // this.getSubCate()
- // }
- // } else {
- // uni.showToast({
- // icon: 'none',
- // title: "请求失败",
- // });
- // }
- // },
- // rej => {}
- // );
- // },
- // 药品分类选择
- choseCate(item) {
- this.cateSelect = item.cateId;
- this.getSubCate();
- },
- getSubCate() {
- var that = this;
- this.subCates = this.allCates.filter(function(item) {
- return item.pid == that.cateSelect;
- });
- },
- // 查看药品详情
- showProductList(item) {
- common_vendor.index.navigateTo({
- url: "/pages_shop/goods?productId=" + item.productId + "&liveId=" + this.liveId + "&goodsId=" + item.goodsId + "&storeId=" + this.storeId
- });
- }
- }
- };
- if (!Array) {
- const _easycom_u_icon2 = common_vendor.resolveComponent("u-icon");
- const _easycom_u_image2 = common_vendor.resolveComponent("u-image");
- (_easycom_u_icon2 + _easycom_u_image2)();
- }
- const _easycom_u_icon = () => "../uni_modules/uview-plus/components/u-icon/u-icon.js";
- const _easycom_u_image = () => "../uni_modules/uview-plus/components/u-image/u-image.js";
- if (!Math) {
- (_easycom_u_icon + _easycom_u_image)();
- }
- function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
- var _a;
- return common_vendor.e({
- a: $data.statusBarHeight + "px",
- b: common_vendor.o($options.rightClick),
- c: common_vendor.p({
- name: "arrow-left",
- color: "#ffffff",
- size: "20"
- }),
- d: common_assets._imports_0$9,
- e: common_vendor.o([($event) => $data.inputInfo = $event.detail.value, (...args) => $options.handleSearchInput && $options.handleSearchInput(...args)]),
- f: $data.inputInfo,
- g: common_vendor.o((...args) => _ctx.toSearch && _ctx.toSearch(...args)),
- h: common_vendor.p({
- shape: "square",
- src: (_a = $data.storeInfo) == null ? void 0 : _a.logoUrl,
- width: "100rpx",
- height: "100rpx",
- radius: "6"
- }),
- i: common_vendor.t($data.storeInfo.storeName || ""),
- j: common_vendor.t($data.storeInfo.salesCount),
- k: $data.storeInfo.storeName,
- l: common_vendor.f($data.products, (subItem, index, i0) => {
- return {
- a: subItem.imgUrl,
- b: common_vendor.t(subItem.productName),
- c: common_vendor.t(Math.trunc(subItem.price)),
- d: common_vendor.t($options.getPureDecimal(subItem.price) ? $options.getPureDecimal(subItem.price) : "00"),
- e: index,
- f: common_vendor.o(($event) => $options.showProductList(subItem), index)
- };
- }),
- m: $data.page > 1
- }, $data.page > 1 ? common_vendor.e({
- n: $data.isLoading
- }, $data.isLoading ? {} : !$data.hasMore ? {} : {}, {
- o: !$data.hasMore
- }) : {});
- }
- const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-dd5fc6f3"]]);
- _sfc_main.__runtimeHooks = 1;
- wx.createPage(MiniProgramPage);
|