|
@@ -0,0 +1,124 @@
|
|
|
|
+"use strict";
|
|
|
|
+const common_vendor = require("../../common/vendor.js");
|
|
|
|
+const common_assets = require("../../common/assets.js");
|
|
|
|
+const _sfc_main = {
|
|
|
|
+ data() {
|
|
|
|
+ return {
|
|
|
|
+ course: {},
|
|
|
|
+ comments: [],
|
|
|
|
+ catalog: [],
|
|
|
|
+ tabIndex: 0,
|
|
|
|
+ defaultCover: "/static/default-course.png",
|
|
|
|
+ defaultAvatar: "/static/1.jpg",
|
|
|
|
+ lockIcon: "/static/lock.png"
|
|
|
|
+ };
|
|
|
|
+ },
|
|
|
|
+ computed: {
|
|
|
|
+ parsedImages() {
|
|
|
|
+ try {
|
|
|
|
+ if (this.course.images) {
|
|
|
|
+ return JSON.parse(this.course.images);
|
|
|
|
+ }
|
|
|
|
+ return [];
|
|
|
|
+ } catch (e) {
|
|
|
|
+ common_vendor.index.__f__("error", "at pages/course/detail.vue:108", "解析图片数据失败:", e);
|
|
|
|
+ return [];
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ onLoad(options) {
|
|
|
|
+ this.fetchDetail(options.id);
|
|
|
|
+ },
|
|
|
|
+ methods: {
|
|
|
|
+ async fetchDetail(id) {
|
|
|
|
+ try {
|
|
|
|
+ const res = await common_vendor.index.request({
|
|
|
|
+ url: `http://localhost:9527/product/findOne?productId=${id}`,
|
|
|
|
+ method: "GET"
|
|
|
|
+ });
|
|
|
|
+ if (res.statusCode === 200) {
|
|
|
|
+ this.course = res.data.data;
|
|
|
|
+ this.comments = res.data.data.comments || [];
|
|
|
|
+ this.catalog = res.data.data.catalog || [];
|
|
|
|
+ } else {
|
|
|
|
+ throw new Error(res.data.message || "获取数据失败");
|
|
|
|
+ }
|
|
|
|
+ } catch (err) {
|
|
|
|
+ common_vendor.index.showToast({
|
|
|
|
+ title: err.message || "加载失败",
|
|
|
|
+ icon: "none"
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+};
|
|
|
|
+function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
|
+ var _a, _b;
|
|
|
|
+ return common_vendor.e({
|
|
|
|
+ a: common_vendor.f($options.parsedImages, (image, index, i0) => {
|
|
|
|
+ return {
|
|
|
|
+ a: image.imageUrl,
|
|
|
|
+ b: index
|
|
|
|
+ };
|
|
|
|
+ }),
|
|
|
|
+ b: common_vendor.t($data.course.name),
|
|
|
|
+ c: common_vendor.t($data.course.subtitle),
|
|
|
|
+ d: common_vendor.t((_a = $data.course.price) == null ? void 0 : _a.toFixed(2)),
|
|
|
|
+ e: common_vendor.t((_b = $data.course.originalPrice) == null ? void 0 : _b.toFixed(2)),
|
|
|
|
+ f: common_vendor.t($data.course.stock),
|
|
|
|
+ g: common_vendor.t($data.comments.length),
|
|
|
|
+ h: $data.comments.length === 0
|
|
|
|
+ }, $data.comments.length === 0 ? {} : {
|
|
|
|
+ i: common_vendor.f($data.comments, (item, k0, i0) => {
|
|
|
|
+ return {
|
|
|
|
+ a: item.avatar || $data.defaultAvatar,
|
|
|
|
+ b: common_vendor.t(item.user),
|
|
|
|
+ c: common_vendor.f(5, (n, k1, i1) => {
|
|
|
|
+ return {
|
|
|
|
+ a: n,
|
|
|
|
+ b: n <= item.star ? 1 : ""
|
|
|
|
+ };
|
|
|
|
+ }),
|
|
|
|
+ d: common_vendor.t(item.content || "此用户没有填写评价"),
|
|
|
|
+ e: item.id
|
|
|
|
+ };
|
|
|
|
+ })
|
|
|
|
+ }, {
|
|
|
|
+ j: common_vendor.n($data.tabIndex === 0 ? "active" : ""),
|
|
|
|
+ k: common_vendor.o(($event) => $data.tabIndex = 0),
|
|
|
|
+ l: common_vendor.n($data.tabIndex === 1 ? "active" : ""),
|
|
|
|
+ m: common_vendor.o(($event) => $data.tabIndex = 1),
|
|
|
|
+ n: common_vendor.n($data.tabIndex === 2 ? "active" : ""),
|
|
|
|
+ o: common_vendor.o(($event) => $data.tabIndex = 2),
|
|
|
|
+ p: $data.tabIndex === 0
|
|
|
|
+ }, $data.tabIndex === 0 ? {
|
|
|
|
+ q: common_vendor.f($options.parsedImages, (image, index, i0) => {
|
|
|
|
+ return {
|
|
|
|
+ a: image.imageUrl,
|
|
|
|
+ b: common_vendor.t(image.courseTitle),
|
|
|
|
+ c: common_vendor.t(image.courseDesc),
|
|
|
|
+ d: index
|
|
|
|
+ };
|
|
|
|
+ })
|
|
|
|
+ } : $data.tabIndex === 1 ? {
|
|
|
|
+ s: common_vendor.f($data.catalog, (item, k0, i0) => {
|
|
|
|
+ return common_vendor.e({
|
|
|
|
+ a: item.icon || $data.lockIcon,
|
|
|
|
+ b: common_vendor.t(item.title),
|
|
|
|
+ c: common_vendor.t(item.type),
|
|
|
|
+ d: common_vendor.t(item.date),
|
|
|
|
+ e: common_vendor.t(item.count),
|
|
|
|
+ f: item.trial
|
|
|
|
+ }, item.trial ? {} : {}, {
|
|
|
|
+ g: item.id
|
|
|
|
+ });
|
|
|
|
+ })
|
|
|
|
+ } : {
|
|
|
|
+ t: common_assets._imports_0$5
|
|
|
|
+ }, {
|
|
|
|
+ r: $data.tabIndex === 1
|
|
|
|
+ });
|
|
|
|
+}
|
|
|
|
+const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-3d21314d"]]);
|
|
|
|
+wx.createPage(MiniProgramPage);
|
|
|
|
+//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/course/detail.js.map
|