index.vue 8.1 KB

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