index.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450
  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.xyyxt.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. else if(option.educationId||option.projectId||option.businessId)
  168. {
  169. this.activeData = {
  170. educationId: option.educationId??"",
  171. projectId: option.projectId??"",
  172. businessId:option.businessId?? "",
  173. subjectId: "",
  174. sortType: 1
  175. };
  176. }
  177. if (option.current) {
  178. this.$store.state.current = Number(option.current)
  179. }
  180. uni.hideTabBar();
  181. this.initList()
  182. uni.$on('backTop', res => {
  183. //视图会发生重新渲染
  184. this.scrollTop = this.oldScrollTop
  185. //当视图渲染结束 重新设置为0
  186. this.$nextTick(() => {
  187. this.scrollTop = 0
  188. });
  189. })
  190. },
  191. onUnload() {
  192. uni.$off('backTop')
  193. },
  194. watch: {
  195. "current"(newVal, oldVal) {
  196. this.formData.pageNum = 1
  197. this.formData.goodsName = ""
  198. this.activeData = {
  199. educationId: "",
  200. projectId: "",
  201. businessId: "",
  202. subjectId: "",
  203. sortType: 1
  204. }
  205. this.goodsList = []
  206. this.initList()
  207. }
  208. },
  209. computed: {
  210. ...mapGetters(["current", "hideBuyState"])
  211. },
  212. methods: {
  213. backFunc(item) {
  214. console.log('asd', item)
  215. this.activeData = item
  216. this.search()
  217. },
  218. scroll(e) {
  219. //记录scroll 位置
  220. this.oldScrollTop = e.detail.scrollTop
  221. if (e.detail.scrollTop > 100) {
  222. this.backTopBtn = true
  223. } else {
  224. this.backTopBtn = false
  225. }
  226. },
  227. openFilterBox() {
  228. this.$refs.filterShowStatus.openBoxs(this.activeData)
  229. },
  230. search() {
  231. this.formData.pageNum = 1
  232. this.goodsList = []
  233. this.initList()
  234. },
  235. //触底
  236. lower() {
  237. if (this.goodsList.length >= this.total) {
  238. uni.showToast({
  239. title: "已经到底啦~",
  240. icon: "none"
  241. })
  242. return
  243. }
  244. this.formData.pageNum++
  245. this.initList()
  246. },
  247. change(e) {
  248. this.$store.state.current = e
  249. },
  250. initList() {
  251. if (!this.hideBuyState) {
  252. this.$api.goodsList({
  253. ...this.formData,
  254. ...this.activeData,
  255. educationTypeId: this.activeData.educationId,
  256. goodsName: this.formData.goodsName,
  257. goodsType: this.courseLists[this.$store.state.current].type
  258. }).then((res) => {
  259. this.goodsList = this.goodsList.concat(res.data.rows)
  260. this.total = res.data.total
  261. });
  262. }
  263. },
  264. tobuy(item) {
  265. if (item.goodsType == 2) {
  266. uni.navigateTo({
  267. url: "/pages2/bank/detail?id=" + item.goodsId,
  268. });
  269. } else {
  270. // 视频、直播 /pages5/liveDetail/index
  271. uni.navigateTo({
  272. url: "/pages3/course/detail?id=" +
  273. item.goodsId +
  274. "&goodsType=" +
  275. item.goodsType,
  276. });
  277. }
  278. },
  279. },
  280. };
  281. </script>
  282. <style scoped lang="scss">
  283. .noGoods {
  284. height: 80%;
  285. display: flex;
  286. flex-direction: column;
  287. align-items: center;
  288. &>img {
  289. margin-top: 50rpx;
  290. width: 500rpx;
  291. height: 500rpx;
  292. }
  293. &>view {
  294. font-size: 34rpx;
  295. margin-top: 30rpx;
  296. color: #666;
  297. }
  298. }
  299. .course_box {
  300. display: flex;
  301. flex-direction: column;
  302. height: 100vh;
  303. background-color: rgba(241, 244, 247, 1);
  304. .body_course {
  305. flex: 1;
  306. height: 1rpx;
  307. display: flex;
  308. flex-direction: column;
  309. .top {
  310. flex-shrink: 0;
  311. background-color: #fff;
  312. .search_box {
  313. display: flex;
  314. align-items: center;
  315. padding: 40rpx 30rpx;
  316. &>.u_search {
  317. flex: 1;
  318. }
  319. &>.btns {
  320. display: flex;
  321. align-items: center;
  322. margin-left: 30rpx;
  323. &>text {
  324. color: #333;
  325. font-size: 28rpx;
  326. font-weight: 600;
  327. }
  328. &>img {
  329. margin-left: 6rpx;
  330. width: 30rpx;
  331. height: 30rpx;
  332. }
  333. }
  334. }
  335. }
  336. .content {
  337. flex: 1;
  338. height: 1rpx;
  339. overflow: hidden;
  340. &>.scroll-Y {
  341. height: 100%;
  342. }
  343. }
  344. }
  345. }
  346. .content_box {
  347. background-color: #fff;
  348. border-radius: 8rpx;
  349. padding: 20rpx;
  350. margin: 20rpx;
  351. &>.title {
  352. padding-top: 10rpx;
  353. margin-bottom: 30rpx;
  354. color: #333;
  355. font-weight: 600;
  356. font-size: 28rpx;
  357. }
  358. &>.f_x {
  359. display: flex;
  360. &>.img_goods {
  361. width: 235rpx;
  362. height: 138rpx;
  363. overflow: hidden;
  364. border-radius: 8rpx;
  365. margin-right: 20rpx;
  366. flex-shrink: 0;
  367. &>img {
  368. width: 100%;
  369. height: 100%;
  370. }
  371. }
  372. &>.content_goods {
  373. flex: 1;
  374. width: 1rpx;
  375. display: flex;
  376. flex-direction: column;
  377. justify-content: space-between;
  378. &>.top_bus {
  379. text-overflow: ellipsis;
  380. white-space: nowrap;
  381. overflow: hidden;
  382. &>text {
  383. background-color: #f5f7f9;
  384. border-radius: 4rpx;
  385. padding: 6rpx 10rpx;
  386. &:first-child {
  387. margin-right: 14rpx;
  388. }
  389. }
  390. }
  391. &>.price {
  392. display: flex;
  393. align-items: center;
  394. flex-wrap: wrap;
  395. justify-content: space-between;
  396. &>.price1 {
  397. font-size: 36rpx;
  398. font-weight: 700;
  399. color: red;
  400. }
  401. &>.price2 {
  402. text-decoration: line-through;
  403. color: #aaaaaa;
  404. font-size: 24rpx;
  405. }
  406. }
  407. }
  408. }
  409. }
  410. /deep/ .u-scroll-box {
  411. display: flex;
  412. }
  413. /deep/ .u-tab-bar {
  414. background-color: #2979ff !important;
  415. }
  416. /deep/ .u-content {
  417. border: 1rpx solid #2979ff !important;
  418. }
  419. </style>