index.vue 7.9 KB

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