index.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. "use strict";
  2. const common_vendor = require("../../common/vendor.js");
  3. const utils_file = require("../../utils/file.js");
  4. const store_user = require("../../store/user.js");
  5. if (!Math) {
  6. (LoginModal + TabBar)();
  7. }
  8. const TabBar = () => "../../components/TabBar.js";
  9. const LoginModal = () => "../components/LoginModal.js";
  10. const _sfc_main = {
  11. __name: "index",
  12. setup(__props) {
  13. const userStore = store_user.useUserStore();
  14. const showLoginModal = common_vendor.ref(false);
  15. const foodList = common_vendor.ref([
  16. {
  17. image: "/static/demo.png",
  18. name: "川派辣卤牛杂川派辣卤牛杂煲川派辣卤牛杂煲川派辣卤牛杂煲煲",
  19. sales: 160,
  20. tags: [
  21. { text: "招牌", type: "signature" },
  22. { text: "中辣", type: "spicy" }
  23. ],
  24. description: "香煎 M9 和牛粒是将澳洲顶级 M9 和牛切成均匀小粒,以高温快煎方式锁住肉汁。",
  25. price: "49.8"
  26. },
  27. {
  28. image: "/static/demo.png",
  29. name: "川派辣卤牛杂煲",
  30. sales: 160,
  31. tags: [
  32. { text: "招牌", type: "signature" },
  33. { text: "中辣", type: "spicy" }
  34. ],
  35. description: "香煎 M9 和牛粒是将澳洲顶级 M9 和牛切成均匀小粒,以高温快煎方式锁住肉汁。",
  36. price: "49.8"
  37. }
  38. ]);
  39. const getPriceMain = (price) => {
  40. if (!price)
  41. return "";
  42. const priceStr = String(price);
  43. const dotIndex = priceStr.indexOf(".");
  44. return dotIndex > -1 ? priceStr.substring(0, dotIndex) : priceStr;
  45. };
  46. const getPriceDecimal = (price) => {
  47. if (!price)
  48. return "";
  49. const priceStr = String(price);
  50. const dotIndex = priceStr.indexOf(".");
  51. return dotIndex > -1 ? priceStr.substring(dotIndex + 1) : "";
  52. };
  53. const handleLoginSuccess = (res) => {
  54. common_vendor.index.__f__("log", "at pages/index/index.vue:137", "登录成功:", res);
  55. };
  56. const handleLoginCancel = () => {
  57. common_vendor.index.__f__("log", "at pages/index/index.vue:142", "用户取消登录");
  58. };
  59. common_vendor.onLoad((e) => {
  60. });
  61. return (_ctx, _cache) => {
  62. return common_vendor.e({
  63. a: common_vendor.unref(utils_file.getFileUrl)("/static/demo.png"),
  64. b: common_vendor.unref(utils_file.getFileUrl)("img/icon/shop.png"),
  65. c: !common_vendor.unref(userStore).getToken
  66. }, !common_vendor.unref(userStore).getToken ? {
  67. d: common_vendor.o(($event) => showLoginModal.value = true),
  68. e: common_vendor.unref(utils_file.getFileUrl)("img/icon/welcom.png")
  69. } : {}, {
  70. f: common_vendor.unref(utils_file.getFileUrl)("img/icon/zptj.png"),
  71. g: common_vendor.f(foodList.value, (item, index, i0) => {
  72. return {
  73. a: common_vendor.unref(utils_file.getFileUrl)(item.image),
  74. b: common_vendor.t(item.name),
  75. c: common_vendor.t(item.sales),
  76. d: common_vendor.t(getPriceMain(item.price)),
  77. e: common_vendor.t(getPriceDecimal(item.price)),
  78. f: common_vendor.f(item.tags, (tag, tagIndex, i1) => {
  79. return {
  80. a: common_vendor.t(tag.text),
  81. b: tagIndex,
  82. c: common_vendor.n(tag.type)
  83. };
  84. }),
  85. g: common_vendor.t(item.description),
  86. h: index
  87. };
  88. }),
  89. h: common_vendor.unref(utils_file.getFileUrl)("img/icon/star.png"),
  90. i: common_vendor.o(handleLoginSuccess),
  91. j: common_vendor.o(handleLoginCancel),
  92. k: common_vendor.o(($event) => showLoginModal.value = $event),
  93. l: common_vendor.p({
  94. open: showLoginModal.value
  95. })
  96. });
  97. };
  98. }
  99. };
  100. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-1cf27b2a"]]);
  101. wx.createPage(MiniProgramPage);
  102. //# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/index/index.js.map