Ver código fonte

修改课程列表显示

zs 1 ano atrás
pai
commit
34acfc9b12

+ 170 - 20
pagesMy/course/index.vue

@@ -12,7 +12,39 @@
 			<up-list @scrolltolower="scrolltolower">
 				<up-list-item v-for="(item, index) in list" :key="index">
 					<view class="list">
-						1111
+						<view class="name textOne">{{item.name||'暂无'}}</view>
+						<view class="other_1">
+							<view class="value">
+								<view class="title">类型:</view>
+								<view class="label">{{getDict(item.type,'type')}}</view>
+							</view>
+							<view class="value">
+								<view class="title">学科:</view>
+								<view class="label">{{getDict(item.subject,'subject')}}</view>
+							</view>
+							<view class="value">
+								<view class="title">年级:</view>
+								<view class="label">{{getDict(item.grade,'grade')}}</view>
+							</view>
+						</view>
+						<view class="other_2">
+							<view class="other_2_1">金额(元):</view>
+							<view class="other_2_2 red">{{item.money||'免费'}}</view>
+						</view>
+						<view class="other_2">
+							<view class="other_2_1">时间:</view>
+							<view class="other_2_2 ">{{item.start_time}} - {{item.end_time}}</view>
+						</view>
+						<view class="other_2">
+							<view class="other_2_1">状态:</view>
+							<view class="other_2_2" :class="[item.status=='0'?'red':'']">
+								{{getDict(item.status,'status')}}
+							</view>
+						</view>
+						<view class="bottom">
+							<button class="button button_1" type="default" size="mini" @click="toEdit(item)">修改</button>
+							<button v-if="item.status=='0'" class="button button_2" type="default" size="mini" @click="toDelete(item)">删除</button>
+						</view>
 					</view>
 				</up-list-item>
 			</up-list>
@@ -42,6 +74,12 @@
 	// 数据是否触底
 	const is_bottom = ref(false);
 	const name = ref('');
+	// 字典表
+	const subjectList = ref([])
+	const gradeList = ref([])
+	const showList = ref([])
+	const typeList = ref([])
+	const statusList = ref([])
 	// user
 	const user = computed(() => {
 		return uni.getStorageSync('user');
@@ -62,7 +100,24 @@
 		config.value = uni.getStorageSync('config');
 	};
 	// 其他查询信息
-	const searchOther = async () => { };
+	const searchOther = async () => {
+		let res;
+		// 学科
+		res = await $api(`dictData`, 'GET', { code: 'subject', is_use: '0' });
+		if (res.errcode === 0) subjectList.value = res.data;
+		// 年级
+		res = await $api(`dictData`, 'GET', { code: 'grade', is_use: '0' });
+		if (res.errcode === 0) gradeList.value = res.data;
+		// 类型
+		res = await $api(`dictData`, 'GET', { code: 'courseType', is_use: '0' });
+		if (res.errcode === 0) typeList.value = res.data;
+		// 状态
+		res = await $api(`dictData`, 'GET', { code: 'courseStatus', is_use: '0' });
+		if (res.errcode === 0) statusList.value = res.data;
+		// 是否公开
+		res = await $api(`dictData`, 'GET', { code: 'show', is_use: '0' });
+		if (res.errcode === 0) showList.value = res.data;
+	};
 	// 查询
 	const search = async () => {
 		const info : any = {
@@ -83,6 +138,14 @@
 			});
 		}
 	};
+	const getDict = (data, model) => {
+		let res
+		if (model == 'subject') res = subjectList.value.find((f) => f.value == data)
+		else if (model == 'grade') res = gradeList.value.find((f) => f.value == data)
+		else if (model == 'type') res = typeList.value.find((f) => f.value == data)
+		else if (model == 'status') res = statusList.value.find((f) => f.value == data)
+		return res.label || '暂无'
+	}
 	// 搜索课程
 	const toInput = async (e) => {
 		await clearPage();
@@ -94,6 +157,37 @@
 			url: `/pagesMy/course/add`
 		})
 	};
+	// 修改
+	const toEdit = async (item) => {
+		uni.navigateTo({
+			url: `/pagesMy/course/add?id=${item.id || item._id}`
+		})
+	};
+	// 删除
+	const toDelete = async () => {
+		uni.showModal({
+			title: '提示',
+			content: '确定删除该课程吗?',
+			success: async function (res) {
+				if (res.confirm) {
+					const arr = await $api(`course/${e._id}`, 'DELETE');
+					if (arr.errcode == '0') {
+						uni.showToast({
+							title: '删除信息成功',
+							icon: 'none'
+						})
+						await clearPage()
+						await search()
+					} else {
+						uni.showToast({
+							title: arr.errmsg,
+							icon: 'none'
+						})
+					}
+				}
+			}
+		});
+	};
 	const scrolltolower = () => {
 		if (total.value > list.value.length) {
 			uni.showLoading({
@@ -141,32 +235,88 @@
 			}
 
 			.button {
-				background-color: var(--f3CColor);
+				background-color: var(--3c9Color);
 				color: var(--mainColor);
 			}
 		}
 
-		.one {
-			display: flex;
-			justify-content: center;
-			align-items: center;
-			padding: 2vw;
+		.two {
+			margin: 0 2vw;
 
-			.one_1 {
-				padding: 0 2vw;
-				width: 75vw;
+			.list {
+				background-color: var(--mainColor);
+				border-bottom: 1px solid var(--f5Color);
+				margin: 2vw 0 0 0;
+				border-radius: 4px;
+				padding: 2vw;
 
-				input {
-					padding: 2vw;
-					background-color: var(--f1Color);
-					font-size: var(--font14Size);
-					border-radius: 5px;
+				.name {
+					font-size: var(--font16Size);
+					font-weight: bold;
+					margin: 0 2vw 2vw 2vw;
 				}
-			}
 
-			.button {
-				background-color: var(--3c9Color);
-				color: var(--mainColor);
+				.other_1 {
+					display: flex;
+					justify-content: space-between;
+					padding: 1vw 2vw;
+
+					.value {
+						display: flex;
+						align-items: center;
+
+						.title {
+							font-size: var(--font14Size);
+							font-weight: bold;
+						}
+
+						.label {
+							font-size: var(--font12Size);
+							color: var(--f85Color);
+						}
+					}
+				}
+
+				.other_2 {
+					display: flex;
+					align-items: center;
+					padding: 1vw 2vw;
+
+					.other_2_1 {
+						font-size: var(--font14Size);
+						font-weight: bold;
+					}
+
+					.other_2_2 {
+						width: 70%;
+						font-size: var(--font12Size);
+						color: var(--f85Color);
+					}
+
+					.red {
+						color: var(--ff0Color);
+					}
+				}
+
+				.bottom {
+					margin: 2vw 0 0 0;
+					text-align: center;
+
+					.button {
+						color: var(--mainColor);
+						font-size: var(--font14Size);
+						border-radius: 2vw;
+					}
+
+					.button_1 {
+						margin: 0 2vw 0 0;
+						background-color: var(--3c9Color);
+					}
+
+					.button_2 {
+						background-color: var(--ff0Color);
+					}
+				}
 			}
 		}
 

+ 81 - 5
unpackage/dist/dev/mp-weixin/pagesMy/course/index.js

@@ -24,6 +24,11 @@ const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
     const page = common_vendor.ref(0);
     const is_bottom = common_vendor.ref(false);
     const name = common_vendor.ref("");
+    const subjectList = common_vendor.ref([]);
+    const gradeList = common_vendor.ref([]);
+    const showList = common_vendor.ref([]);
+    const typeList = common_vendor.ref([]);
+    const statusList = common_vendor.ref([]);
     const user = common_vendor.computed(() => {
       return common_vendor.index.getStorageSync("user");
     });
@@ -42,6 +47,22 @@ const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
       config.value = common_vendor.index.getStorageSync("config");
     };
     const searchOther = async () => {
+      let res;
+      res = await $api(`dictData`, "GET", { code: "subject", is_use: "0" });
+      if (res.errcode === 0)
+        subjectList.value = res.data;
+      res = await $api(`dictData`, "GET", { code: "grade", is_use: "0" });
+      if (res.errcode === 0)
+        gradeList.value = res.data;
+      res = await $api(`dictData`, "GET", { code: "courseType", is_use: "0" });
+      if (res.errcode === 0)
+        typeList.value = res.data;
+      res = await $api(`dictData`, "GET", { code: "courseStatus", is_use: "0" });
+      if (res.errcode === 0)
+        statusList.value = res.data;
+      res = await $api(`dictData`, "GET", { code: "show", is_use: "0" });
+      if (res.errcode === 0)
+        showList.value = res.data;
     };
     const search = async () => {
       const info = {
@@ -63,7 +84,19 @@ const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
         });
       }
     };
-    const toInput = async (e) => {
+    const getDict = (data, model) => {
+      let res;
+      if (model == "subject")
+        res = subjectList.value.find((f) => f.value == data);
+      else if (model == "grade")
+        res = gradeList.value.find((f) => f.value == data);
+      else if (model == "type")
+        res = typeList.value.find((f) => f.value == data);
+      else if (model == "status")
+        res = statusList.value.find((f) => f.value == data);
+      return res.label || "暂无";
+    };
+    const toInput = async (e2) => {
       await clearPage();
       await search();
     };
@@ -72,6 +105,35 @@ const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
         url: `/pagesMy/course/add`
       });
     };
+    const toEdit = async (item) => {
+      common_vendor.index.navigateTo({
+        url: `/pagesMy/course/add?id=${item.id || item._id}`
+      });
+    };
+    const toDelete = async () => {
+      common_vendor.index.showModal({
+        title: "提示",
+        content: "确定删除该课程吗?",
+        success: async function(res) {
+          if (res.confirm) {
+            const arr = await $api(`course/${e._id}`, "DELETE");
+            if (arr.errcode == "0") {
+              common_vendor.index.showToast({
+                title: "删除信息成功",
+                icon: "none"
+              });
+              await clearPage();
+              await search();
+            } else {
+              common_vendor.index.showToast({
+                title: arr.errmsg,
+                icon: "none"
+              });
+            }
+          }
+        }
+      });
+    };
     const scrolltolower = () => {
       if (total.value > list.value.length) {
         common_vendor.index.showLoading({
@@ -99,10 +161,24 @@ const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
         d: total.value > 0
       }, total.value > 0 ? {
         e: common_vendor.f(list.value, (item, index, i0) => {
-          return {
-            a: index,
-            b: "5cb065a7-1-" + i0 + ",5cb065a7-0"
-          };
+          return common_vendor.e({
+            a: common_vendor.t(item.name || "暂无"),
+            b: common_vendor.t(getDict(item.type, "type")),
+            c: common_vendor.t(getDict(item.subject, "subject")),
+            d: common_vendor.t(getDict(item.grade, "grade")),
+            e: common_vendor.t(item.money || "免费"),
+            f: common_vendor.t(item.start_time),
+            g: common_vendor.t(item.end_time),
+            h: common_vendor.t(getDict(item.status, "status")),
+            i: common_vendor.n(item.status == "0" ? "red" : ""),
+            j: common_vendor.o(($event) => toEdit(item), index),
+            k: item.status == "0"
+          }, item.status == "0" ? {
+            l: common_vendor.o(($event) => toDelete(), index)
+          } : {}, {
+            m: index,
+            n: "5cb065a7-1-" + i0 + ",5cb065a7-0"
+          });
         }),
         f: common_vendor.o(scrolltolower)
       } : {

Diferenças do arquivo suprimidas por serem muito extensas
+ 1 - 1
unpackage/dist/dev/mp-weixin/pagesMy/course/index.wxml


+ 58 - 13
unpackage/dist/dev/mp-weixin/pagesMy/course/index.wxss

@@ -24,26 +24,71 @@
   border-radius: 5px;
 }
 .content .one .button.data-v-5cb065a7 {
-  background-color: var(--f3CColor);
+  background-color: var(--3c9Color);
   color: var(--mainColor);
 }
-.content .one.data-v-5cb065a7 {
+.content .two.data-v-5cb065a7 {
+  margin: 0 2vw;
+}
+.content .two .list.data-v-5cb065a7 {
+  background-color: var(--mainColor);
+  border-bottom: 1px solid var(--f5Color);
+  margin: 2vw 0 0 0;
+  border-radius: 4px;
+  padding: 2vw;
+}
+.content .two .list .name.data-v-5cb065a7 {
+  font-size: var(--font16Size);
+  font-weight: bold;
+  margin: 0 2vw 2vw 2vw;
+}
+.content .two .list .other_1.data-v-5cb065a7 {
+  display: flex;
+  justify-content: space-between;
+  padding: 1vw 2vw;
+}
+.content .two .list .other_1 .value.data-v-5cb065a7 {
   display: flex;
-  justify-content: center;
   align-items: center;
-  padding: 2vw;
 }
-.content .one .one_1.data-v-5cb065a7 {
-  padding: 0 2vw;
-  width: 75vw;
+.content .two .list .other_1 .value .title.data-v-5cb065a7 {
+  font-size: var(--font14Size);
+  font-weight: bold;
 }
-.content .one .one_1 input.data-v-5cb065a7 {
-  padding: 2vw;
-  background-color: var(--f1Color);
+.content .two .list .other_1 .value .label.data-v-5cb065a7 {
+  font-size: var(--font12Size);
+  color: var(--f85Color);
+}
+.content .two .list .other_2.data-v-5cb065a7 {
+  display: flex;
+  align-items: center;
+  padding: 1vw 2vw;
+}
+.content .two .list .other_2 .other_2_1.data-v-5cb065a7 {
   font-size: var(--font14Size);
-  border-radius: 5px;
+  font-weight: bold;
 }
-.content .one .button.data-v-5cb065a7 {
-  background-color: var(--3c9Color);
+.content .two .list .other_2 .other_2_2.data-v-5cb065a7 {
+  width: 70%;
+  font-size: var(--font12Size);
+  color: var(--f85Color);
+}
+.content .two .list .other_2 .red.data-v-5cb065a7 {
+  color: var(--ff0Color);
+}
+.content .two .list .bottom.data-v-5cb065a7 {
+  margin: 2vw 0 0 0;
+  text-align: center;
+}
+.content .two .list .bottom .button.data-v-5cb065a7 {
   color: var(--mainColor);
+  font-size: var(--font14Size);
+  border-radius: 2vw;
+}
+.content .two .list .bottom .button_1.data-v-5cb065a7 {
+  margin: 0 2vw 0 0;
+  background-color: var(--3c9Color);
+}
+.content .two .list .bottom .button_2.data-v-5cb065a7 {
+  background-color: var(--ff0Color);
 }