index.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440
  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" :scrollable="false"
  7. 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" :scroll-top="scrollTop"
  20. @scroll="scroll" scroll-with-animation>
  21. <view class="noGoods" v-if="goodsList.length == 0">
  22. <img src="https://file.gdzckj.net/web/static/img/no-content.png" alt="">
  23. <view class="">
  24. 暂无数据
  25. </view>
  26. </view>
  27. <view class="content_box" v-for="(item,index) in goodsList" :key="index" @click="tobuy(item)">
  28. <view class="title">
  29. {{item.goodsName}}
  30. </view>
  31. <view class="f_x">
  32. <view class="img_goods">
  33. <img :src="$method.splitImgHost(item.coverUrl)" alt="">
  34. </view>
  35. <view class="content_goods">
  36. <view class="top_bus">
  37. <text>{{item.educationName}}</text>
  38. <text>{{item.aliasName}}</text>
  39. </view>
  40. <view class="price">
  41. <text class="price1" v-if="!item.specTemplateId ||
  42. (!item.maxPrice && !item.minPrice)"><text v-if="item.standPrice"
  43. style="font-size: 28rpx;font-weight: 400;">¥</text><text
  44. v-if="item.standPrice">{{item.standPrice | formatPrice}}</text><text
  45. v-else>免费</text></text>
  46. <text class="price1" v-else><text
  47. style="font-size: 28rpx;font-weight: 400;">¥</text>{{item.minPrice | formatPrice}}
  48. <template v-if="item.minPrice != item.maxPrice">
  49. <text>-</text>
  50. <text
  51. style="font-size: 28rpx;font-weight: 400;">¥</text>{{ item.maxPrice | formatPrice }}
  52. </template></text>
  53. <text class="price2"
  54. v-if="item.linePrice">原价:¥{{item.linePrice | formatPrice}}</text>
  55. </view>
  56. </view>
  57. </view>
  58. </view>
  59. </scroll-view>
  60. </view>
  61. </view>
  62. <!-- tabbar -->
  63. <myTabbar :backTopBtn="backTopBtn"></myTabbar>
  64. <filter-show-status ref="filterShowStatus" @backFunc="backFunc"></filter-show-status>
  65. </view>
  66. </template>
  67. <script>
  68. import filterShowStatus from "./filterStatus.vue"
  69. import {
  70. mapGetters
  71. } from "vuex";
  72. export default {
  73. components: {
  74. filterShowStatus
  75. },
  76. data() {
  77. return {
  78. backTopBtn: false,
  79. scrollTop: 0,
  80. courseLists: [{
  81. name: "课程",
  82. type: 1
  83. },
  84. {
  85. name: "直播",
  86. type: 6
  87. },
  88. {
  89. name: "题库",
  90. type: 2
  91. },
  92. {
  93. name: "资料",
  94. type: 8
  95. },
  96. // {
  97. // name: "会员商城",
  98. // aliaName: "商品",
  99. // type: 7
  100. // },
  101. ],
  102. goodsList: [],
  103. formData: {
  104. goodsName: "",
  105. pageSize: 8,
  106. pageNum: 1,
  107. goodsStatus: 1,
  108. showStatus: 1
  109. },
  110. total: 0,
  111. oldScrollTop: 0,
  112. activeData: {
  113. educationId: "",
  114. projectId: "",
  115. businessId: "",
  116. subjectId: "",
  117. sortType: 1
  118. },
  119. };
  120. },
  121. onPullDownRefresh() {
  122. // this.initList();
  123. // setTimeout(function() {
  124. // uni.stopPullDownRefresh();
  125. // }, 500);
  126. },
  127. onLoad(option) {
  128. console.log(option, '------option------')
  129. const activeTypeData = {
  130. // 一建继续教育
  131. '1': {
  132. educationId: "2",
  133. projectId: "2",
  134. businessId: "2",
  135. subjectId: "",
  136. sortType: 1
  137. },
  138. // 二建继续教育
  139. '2': {
  140. educationId: "2",
  141. projectId: "2",
  142. businessId: "3",
  143. subjectId: "",
  144. sortType: 1
  145. },
  146. // 职称继续教育
  147. '3': {
  148. educationId: "2",
  149. projectId: "111",
  150. businessId: "242",
  151. subjectId: "",
  152. sortType: 1
  153. },
  154. // 安管人员考前培训
  155. '4': {
  156. educationId: "3",
  157. projectId: "24",
  158. businessId: "65",
  159. subjectId: "",
  160. sortType: 1
  161. }
  162. };
  163. // 判断是否携带筛选条件businessKey
  164. if (activeTypeData.hasOwnProperty(option.businessKey)) {
  165. this.activeData = activeTypeData[option.businessKey];
  166. }
  167. if (option.current) {
  168. this.$store.state.current = Number(option.current)
  169. }
  170. uni.hideTabBar();
  171. this.initList()
  172. uni.$on('backTop', res => {
  173. //视图会发生重新渲染
  174. this.scrollTop = this.oldScrollTop
  175. //当视图渲染结束 重新设置为0
  176. this.$nextTick(() => {
  177. this.scrollTop = 0
  178. });
  179. })
  180. },
  181. onUnload() {
  182. uni.$off('backTop')
  183. },
  184. watch: {
  185. "current"(newVal, oldVal) {
  186. this.formData.pageNum = 1
  187. this.formData.goodsName = ""
  188. this.activeData = {
  189. educationId: "",
  190. projectId: "",
  191. businessId: "",
  192. subjectId: "",
  193. sortType: 1
  194. }
  195. this.goodsList = []
  196. this.initList()
  197. }
  198. },
  199. computed: {
  200. ...mapGetters(["current", "hideBuyState"])
  201. },
  202. methods: {
  203. backFunc(item) {
  204. console.log('asd', item)
  205. this.activeData = item
  206. this.search()
  207. },
  208. scroll(e) {
  209. //记录scroll 位置
  210. this.oldScrollTop = e.detail.scrollTop
  211. if (e.detail.scrollTop > 100) {
  212. this.backTopBtn = true
  213. } else {
  214. this.backTopBtn = false
  215. }
  216. },
  217. openFilterBox() {
  218. this.$refs.filterShowStatus.openBoxs(this.activeData)
  219. },
  220. search() {
  221. this.formData.pageNum = 1
  222. this.goodsList = []
  223. this.initList()
  224. },
  225. //触底
  226. lower() {
  227. if (this.goodsList.length >= this.total) {
  228. uni.showToast({
  229. title: "已经到底啦~",
  230. icon: "none"
  231. })
  232. return
  233. }
  234. this.formData.pageNum++
  235. this.initList()
  236. },
  237. change(e) {
  238. this.$store.state.current = e
  239. },
  240. initList() {
  241. if (!this.hideBuyState) {
  242. this.$api.goodsList({
  243. ...this.formData,
  244. ...this.activeData,
  245. educationTypeId: this.activeData.educationId,
  246. goodsName: this.formData.goodsName,
  247. goodsType: this.courseLists[this.$store.state.current].type
  248. }).then((res) => {
  249. this.goodsList = this.goodsList.concat(res.data.rows)
  250. this.total = res.data.total
  251. });
  252. }
  253. },
  254. tobuy(item) {
  255. if (item.goodsType == 2) {
  256. uni.navigateTo({
  257. url: "/pages2/bank/detail?id=" + item.goodsId,
  258. });
  259. } else {
  260. // 视频、直播 /pages5/liveDetail/index
  261. uni.navigateTo({
  262. url: "/pages3/course/detail?id=" +
  263. item.goodsId +
  264. "&goodsType=" +
  265. item.goodsType,
  266. });
  267. }
  268. },
  269. },
  270. };
  271. </script>
  272. <style scoped lang="scss">
  273. .noGoods {
  274. height: 80%;
  275. display: flex;
  276. flex-direction: column;
  277. align-items: center;
  278. &>img {
  279. margin-top: 50rpx;
  280. width: 500rpx;
  281. height: 500rpx;
  282. }
  283. &>view {
  284. font-size: 34rpx;
  285. margin-top: 30rpx;
  286. color: #666;
  287. }
  288. }
  289. .course_box {
  290. display: flex;
  291. flex-direction: column;
  292. height: 100vh;
  293. background-color: rgba(241, 244, 247, 1);
  294. .body_course {
  295. flex: 1;
  296. height: 1rpx;
  297. display: flex;
  298. flex-direction: column;
  299. .top {
  300. flex-shrink: 0;
  301. background-color: #fff;
  302. .search_box {
  303. display: flex;
  304. align-items: center;
  305. padding: 40rpx 30rpx;
  306. &>.u_search {
  307. flex: 1;
  308. }
  309. &>.btns {
  310. display: flex;
  311. align-items: center;
  312. margin-left: 30rpx;
  313. &>text {
  314. color: #333;
  315. font-size: 28rpx;
  316. font-weight: 600;
  317. }
  318. &>img {
  319. margin-left: 6rpx;
  320. width: 30rpx;
  321. height: 30rpx;
  322. }
  323. }
  324. }
  325. }
  326. .content {
  327. flex: 1;
  328. height: 1rpx;
  329. overflow: hidden;
  330. &>.scroll-Y {
  331. height: 100%;
  332. }
  333. }
  334. }
  335. }
  336. .content_box {
  337. background-color: #fff;
  338. border-radius: 8rpx;
  339. padding: 20rpx;
  340. margin: 20rpx;
  341. &>.title {
  342. padding-top: 10rpx;
  343. margin-bottom: 30rpx;
  344. color: #333;
  345. font-weight: 600;
  346. font-size: 28rpx;
  347. }
  348. &>.f_x {
  349. display: flex;
  350. &>.img_goods {
  351. width: 235rpx;
  352. height: 138rpx;
  353. overflow: hidden;
  354. border-radius: 8rpx;
  355. margin-right: 20rpx;
  356. flex-shrink: 0;
  357. &>img {
  358. width: 100%;
  359. height: 100%;
  360. }
  361. }
  362. &>.content_goods {
  363. flex: 1;
  364. width: 1rpx;
  365. display: flex;
  366. flex-direction: column;
  367. justify-content: space-between;
  368. &>.top_bus {
  369. text-overflow: ellipsis;
  370. white-space: nowrap;
  371. overflow: hidden;
  372. &>text {
  373. background-color: #f5f7f9;
  374. border-radius: 4rpx;
  375. padding: 6rpx 10rpx;
  376. &:first-child {
  377. margin-right: 14rpx;
  378. }
  379. }
  380. }
  381. &>.price {
  382. display: flex;
  383. align-items: center;
  384. flex-wrap: wrap;
  385. justify-content: space-between;
  386. &>.price1 {
  387. font-size: 36rpx;
  388. font-weight: 700;
  389. color: red;
  390. }
  391. &>.price2 {
  392. text-decoration: line-through;
  393. color: #aaaaaa;
  394. font-size: 24rpx;
  395. }
  396. }
  397. }
  398. }
  399. }
  400. /deep/ .u-scroll-box {
  401. display: flex;
  402. }
  403. /deep/ .u-tab-bar {
  404. background-color: #2979ff !important;
  405. }
  406. /deep/ .u-content {
  407. border: 1rpx solid #2979ff !important;
  408. }
  409. </style>