index.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364
  1. <template>
  2. <view class="course_box">
  3. <nav-logo title="选购中心"></nav-logo>
  4. <view class="body_course">
  5. <view class="top">
  6. <u-tabs :list="courseLists" height="100" :current="current" @change="change"
  7. :scrollable="false" font-size="32" active-color="#333"></u-tabs>
  8. <view class="search_box">
  9. <u-search class="u_search" :show-action="false" @clear="search"
  10. :placeholder="`请输入${current == 4 ? '商品':courseLists[current].name}名称`"
  11. v-model="formData.goodsName" @search="search"></u-search>
  12. <view class="btns" @click="openFilterBox">
  13. <text>筛选</text>
  14. <img src="@/static/modIcon/screen.png" alt="">
  15. </view>
  16. </view>
  17. </view>
  18. <view class="content">
  19. <scroll-view scroll-y="true" class="scroll-Y" @scrolltolower="lower">
  20. <view class="noGoods" v-if="goodsList.length == 0">
  21. <img src="https://file.xyyxt.net/web/static/img/no-content.png" alt="">
  22. <view class="">
  23. 暂无数据
  24. </view>
  25. </view>
  26. <view class="content_box" v-for="(item,index) in goodsList" :key="index" @click="tobuy(item)">
  27. <view class="title">
  28. {{item.goodsName}}
  29. </view>
  30. <view class="f_x">
  31. <view class="img_goods">
  32. <img :src="$method.splitImgHost(item.coverUrl)" alt="">
  33. </view>
  34. <view class="content_goods">
  35. <view class="top_bus">
  36. <text>{{item.educationName}}</text>
  37. <text>{{item.aliasName}}</text>
  38. </view>
  39. <view class="price">
  40. <text class="price1" v-if="!item.specTemplateId ||
  41. (!item.maxPrice && !item.minPrice)"><text v-if="item.standPrice"
  42. style="font-size: 28rpx;font-weight: 400;">¥</text><text v-if="item.standPrice">{{item.standPrice | formatPrice}}</text><text v-else>免费</text></text>
  43. <text class="price1" v-else><text
  44. style="font-size: 28rpx;font-weight: 400;">¥</text>{{item.minPrice | formatPrice}}
  45. <template v-if="item.minPrice != item.maxPrice">
  46. <text>-</text>
  47. <text style="font-size: 28rpx;font-weight: 400;">¥</text>{{ item.maxPrice | formatPrice }}
  48. </template></text>
  49. <text class="price2" v-if="item.linePrice">原价:¥{{item.linePrice | formatPrice}}</text>
  50. </view>
  51. </view>
  52. </view>
  53. </view>
  54. </scroll-view>
  55. </view>
  56. </view>
  57. <!-- tabbar -->
  58. <myTabbar></myTabbar>
  59. <filter-show-status ref="filterShowStatus" @backFunc="backFunc"></filter-show-status>
  60. </view>
  61. </template>
  62. <script>
  63. import filterShowStatus from "./filterStatus.vue"
  64. import {
  65. mapGetters
  66. } from "vuex";
  67. export default {
  68. components: {
  69. filterShowStatus
  70. },
  71. data() {
  72. return {
  73. courseLists: [{
  74. name: "课程",
  75. type: 1
  76. },
  77. {
  78. name: "直播",
  79. type: 6
  80. },
  81. {
  82. name: "题库",
  83. type: 2
  84. },
  85. {
  86. name: "资料",
  87. type: 8
  88. },
  89. // {
  90. // name: "会员商城",
  91. // aliaName: "商品",
  92. // type: 7
  93. // },
  94. ],
  95. goodsList: [],
  96. formData: {
  97. goodsName: "",
  98. pageSize: 8,
  99. pageNum: 1,
  100. goodsStatus: 1,
  101. showStatus: 1
  102. },
  103. total: 0,
  104. activeData: {
  105. educationId: "",
  106. projectId: "",
  107. businessId: "",
  108. subjectId: "",
  109. sortType: 1
  110. },
  111. };
  112. },
  113. onPullDownRefresh() {
  114. // this.initList();
  115. // setTimeout(function() {
  116. // uni.stopPullDownRefresh();
  117. // }, 500);
  118. },
  119. onLoad(option) {
  120. uni.hideTabBar();
  121. this.initList()
  122. },
  123. watch: {
  124. "current"(newVal, oldVal) {
  125. this.formData.pageNum = 1
  126. this.formData.goodsName = ""
  127. this.activeData = {
  128. educationId: "",
  129. projectId: "",
  130. businessId: "",
  131. subjectId: "",
  132. sortType: 1
  133. }
  134. this.goodsList = []
  135. this.initList()
  136. }
  137. },
  138. computed:{...mapGetters(["current"])},
  139. methods: {
  140. backFunc(item) {
  141. this.activeData = item
  142. this.search()
  143. },
  144. openFilterBox() {
  145. this.$refs.filterShowStatus.openBoxs(this.activeData)
  146. },
  147. search() {
  148. this.formData.pageNum = 1
  149. this.goodsList = []
  150. this.initList()
  151. },
  152. //触底
  153. lower() {
  154. if (this.goodsList.length >= this.total) {
  155. uni.showToast({
  156. title: "已经到底啦~",
  157. icon: "none"
  158. })
  159. return
  160. }
  161. this.formData.pageNum++
  162. this.initList()
  163. },
  164. change(e) {
  165. this.$store.state.current = e
  166. },
  167. initList() {
  168. this.$api.goodsList({
  169. ...this.formData,
  170. ...this.activeData,
  171. educationTypeId: this.activeData.educationId,
  172. goodsName: this.formData.goodsName,
  173. goodsType: this.courseLists[this.$store.state.current].type
  174. }).then((res) => {
  175. this.goodsList = this.goodsList.concat(res.data.rows)
  176. this.total = res.data.total
  177. });
  178. },
  179. tobuy(item) {
  180. if (item.goodsType == 2) {
  181. uni.navigateTo({
  182. url: "/pages2/bank/detail?id=" + item.goodsId,
  183. });
  184. } else {
  185. // 视频、直播 /pages5/liveDetail/index
  186. uni.navigateTo({
  187. url: "/pages3/course/detail?id=" +
  188. item.goodsId +
  189. "&goodsType=" +
  190. item.goodsType,
  191. });
  192. }
  193. },
  194. },
  195. };
  196. </script>
  197. <style scoped lang="scss">
  198. .noGoods {
  199. height: 80%;
  200. display: flex;
  201. flex-direction: column;
  202. align-items: center;
  203. &>img {
  204. margin-top: 50rpx;
  205. width: 500rpx;
  206. height: 500rpx;
  207. }
  208. &>view {
  209. font-size: 34rpx;
  210. margin-top: 30rpx;
  211. color: #666;
  212. }
  213. }
  214. .course_box {
  215. display: flex;
  216. flex-direction: column;
  217. height: 100vh;
  218. background-color: rgba(241, 244, 247, 1);
  219. .body_course {
  220. flex: 1;
  221. height: 1rpx;
  222. display: flex;
  223. flex-direction: column;
  224. .top {
  225. flex-shrink: 0;
  226. background-color: #fff;
  227. .search_box {
  228. display: flex;
  229. align-items: center;
  230. padding: 40rpx 30rpx;
  231. &>.u_search {
  232. flex: 1;
  233. }
  234. &>.btns {
  235. display: flex;
  236. align-items: center;
  237. margin-left: 30rpx;
  238. &>text {
  239. color: #333;
  240. font-size: 28rpx;
  241. font-weight: 600;
  242. }
  243. &>img {
  244. margin-left: 6rpx;
  245. width: 30rpx;
  246. height: 30rpx;
  247. }
  248. }
  249. }
  250. }
  251. .content {
  252. flex: 1;
  253. height: 1rpx;
  254. overflow: hidden;
  255. &>.scroll-Y {
  256. height: 100%;
  257. }
  258. }
  259. }
  260. }
  261. .content_box {
  262. background-color: #fff;
  263. border-radius: 8rpx;
  264. padding: 20rpx;
  265. margin: 20rpx;
  266. &>.title {
  267. padding-top: 10rpx;
  268. margin-bottom: 30rpx;
  269. color: #333;
  270. font-weight: 600;
  271. font-size: 28rpx;
  272. }
  273. &>.f_x {
  274. display: flex;
  275. &>.img_goods {
  276. width: 235rpx;
  277. height: 138rpx;
  278. overflow: hidden;
  279. border-radius: 8rpx;
  280. margin-right: 20rpx;
  281. flex-shrink: 0;
  282. &>img {
  283. width: 100%;
  284. height: 100%;
  285. }
  286. }
  287. &>.content_goods {
  288. flex: 1;
  289. width: 1rpx;
  290. display: flex;
  291. flex-direction: column;
  292. justify-content: space-between;
  293. &>.top_bus {
  294. text-overflow: ellipsis;
  295. white-space: nowrap;
  296. overflow: hidden;
  297. &>text {
  298. background-color: #f5f7f9;
  299. border-radius: 4rpx;
  300. padding: 6rpx 10rpx;
  301. &:first-child {
  302. margin-right: 14rpx;
  303. }
  304. }
  305. }
  306. &>.price {
  307. display: flex;
  308. align-items: center;
  309. flex-wrap: wrap;
  310. justify-content: space-between;
  311. &>.price1 {
  312. font-size: 36rpx;
  313. font-weight: 700;
  314. color: red;
  315. }
  316. &>.price2 {
  317. text-decoration: line-through;
  318. color: #aaaaaa;
  319. font-size: 24rpx;
  320. }
  321. }
  322. }
  323. }
  324. }
  325. /deep/ .u-scroll-box {
  326. display: flex;
  327. }
  328. /deep/ .u-tab-bar {
  329. background-color: #2979ff !important;
  330. }
  331. /deep/ .u-content {
  332. border: 1rpx solid #2979ff !important;
  333. }
  334. </style>