index.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. <template>
  2. <view class="venue-navbar">
  3. <view class="navbar-list" v-for="(item,index) in navbarList" :key="index" @click="select_nav(index)">
  4. <view class="list-text">{{item.text}}</view>
  5. <image :src="sel_index==index?'/static/notsel-icon.png':'/static/select-icon.png'" mode=""></image>
  6. </view>
  7. </view>
  8. <view style="height: 70rpx;"></view>
  9. <view class="content">
  10. <view class="select-btn">
  11. <view :class="sel_btn===index?'distance':'score'" v-for="(item,index) in selectList" :key="index"
  12. @click="select_btn(item,index)">{{item.text}}</view>
  13. </view>
  14. <block v-if="courseList?.length>0">
  15. <view class="t-card-list" v-for="item in courseList" :key="item.id" @click="RouterUtils.to_page(`/pages/index/courseDetail/index?id=${item.id}`)">
  16. <view class="t-courseImg">
  17. <image :src="item.cover" mode=""></image>
  18. </view>
  19. <view class="t-course">
  20. <view class="c-title textHidden">{{item.name}}</view>
  21. <view class="c-address" v-if="item.km">{{item.address}} | {{item.km.toFixed(2)}}km</view>
  22. <view class="c-price">¥{{ item?.sellingPrice.toFixed(2) }}
  23. <text v-if="item.priceType==0&&item.originalPrice"
  24. style="font-size: 22rpx;color: #AAAAAA;text-decoration: line-through;">¥{{ item.originalPrice.toFixed(2) }}</text>
  25. </view>
  26. <view class="c-ratio">已售{{item.saleNum||'0'}} {{item.goodRate||'0'}}%好评</view>
  27. <view class="c-class">{{item.coursesNum}}课时 {{item.startTime}}-{{item.endTime}}</view>
  28. <view class="c-icon">
  29. <image v-if="item.priceType==1" src="/src/static/snapped.png" mode="widthFix"></image>
  30. <block v-else>
  31. <image v-if="item.isOneBuy" src="/src/static/snapped1.png" mode="widthFix"></image>
  32. <image v-else src="/src/static/qinggou.png" mode="widthFix"></image>
  33. </block>
  34. </view>
  35. </view>
  36. </view>
  37. </block>
  38. <zs-empty v-else></zs-empty>
  39. </view>
  40. </template>
  41. <script lang="ts" setup>
  42. import { ref, onMounted, computed } from 'vue'
  43. import { onLoad, onReachBottom } from '@dcloudio/uni-app'
  44. import { http } from '@/utils/http'
  45. import { useCacheStore } from '@/stores/cache'
  46. import { RouterUtils } from '@/utils/util';
  47. import zsEmpty from '@/components/zs-empty/index.vue'
  48. const cache = useCacheStore()
  49. const navbarList = ref([{
  50. text: '全部'
  51. }, {
  52. text: '免费课'
  53. }, {
  54. text: '精品课'
  55. }]);
  56. // 132
  57. const selectList = ref([{
  58. text: '距离',
  59. type: 1
  60. }, {
  61. text: '好评',
  62. type: 3
  63. }, {
  64. text: '销量',
  65. type: 2
  66. }])
  67. const sel_index = ref(0);
  68. const sel_btn = ref(0);
  69. onLoad((option)=>{
  70. priceType.value=option.priceType
  71. if(option.priceType==1){
  72. sel_index.value=1
  73. }else if(option.priceType==0){
  74. sel_index.value=2
  75. }
  76. })
  77. onReachBottom(() => {
  78. pageNo.value++
  79. if (sel_index.value === 0) {
  80. get_findByCourseList('', selectType.value)
  81. } else if (sel_index.value === 1) {
  82. get_findByCourseList(1, selectType.value)
  83. } else if (sel_index.value === 2) {
  84. get_findByCourseList('0', selectType.value)
  85. }
  86. })
  87. onMounted(() => {
  88. if(priceType.value){
  89. get_findByCourseList(priceType.value, 1)
  90. }else{
  91. get_findByCourseList('', 1)
  92. }
  93. })
  94. const selectType = ref(1)
  95. const select_btn = (e, i) => {
  96. selectType.value = e.type
  97. pageNo.value = 1
  98. if (sel_index.value === 0) {
  99. get_findByCourseList('', e.type)
  100. } else if (sel_index.value === 1) {
  101. get_findByCourseList(1, e.type)
  102. } else if (sel_index.value === 2) {
  103. get_findByCourseList('0', e.type)
  104. }
  105. sel_btn.value = i
  106. }
  107. const select_nav = (i) => {
  108. sel_index.value = i
  109. sel_btn.value = 0
  110. pageNo.value = 1
  111. if (i === 0) {
  112. get_findByCourseList('', 1)
  113. } else if (i === 1) {
  114. get_findByCourseList(1, 1)
  115. } else if (i === 2) {
  116. get_findByCourseList('0', 1)
  117. }
  118. }
  119. // 获取列表
  120. const courseList = ref()
  121. const pageNo = ref(1)
  122. const priceType=ref()
  123. const get_findByCourseList = (priceType : any, orderByType : number) => {
  124. http.get('/detail/findByCourseList', {
  125. data: {
  126. priceType: priceType,
  127. longitude: cache.get('LON')||0,
  128. latitude: cache.get('LAT')||0,
  129. orderByType: orderByType,
  130. pageNo: pageNo.value,
  131. pageSize: 10
  132. }, loading: true
  133. }).then((res) => {
  134. if (pageNo.value == 1) {
  135. courseList.value = res.result.records
  136. } else {
  137. courseList.value = [...courseList.value, ...res.result.records]
  138. }
  139. })
  140. }
  141. </script>
  142. <style lang="less" scoped>
  143. .venue-navbar {
  144. box-sizing: border-box;
  145. padding: 0rpx 20rpx;
  146. padding-bottom: 30rpx;
  147. background-color: #FFFFFF;
  148. display: flex;
  149. align-items: center;
  150. justify-content: space-around;
  151. position: fixed;
  152. width: 100%;
  153. top: 0;
  154. z-index: 1000;
  155. .navbar-list {
  156. display: flex;
  157. align-items: center;
  158. gap: 10rpx;
  159. .list-text {
  160. font-weight: bold;
  161. font-size: 28rpx;
  162. color: #222222;
  163. }
  164. &>image {
  165. width: 30rpx;
  166. height: 30rpx;
  167. }
  168. }
  169. }
  170. .select-btn {
  171. display: flex;
  172. align-items: center;
  173. gap: 20rpx;
  174. margin-top: 20rpx;
  175. .distance {
  176. width: 92rpx;
  177. height: 48rpx;
  178. background: #222222;
  179. border-radius: 8rpx;
  180. font-size: 28rpx;
  181. color: #C8FF0C;
  182. line-height: 48rpx;
  183. text-align: center;
  184. }
  185. .score {
  186. width: 92rpx;
  187. height: 48rpx;
  188. background: #FFFFFF;
  189. border-radius: 8rpx;
  190. font-size: 28rpx;
  191. color: #AAAAAA;
  192. height: 48rpx;
  193. line-height: 48rpx;
  194. text-align: center;
  195. }
  196. }
  197. .t-card-list {
  198. padding: 20rpx;
  199. background: #FFFFFF;
  200. border-radius: 32rpx;
  201. display: flex;
  202. align-items: center;
  203. gap: 20rpx;
  204. margin-top: 20rpx;
  205. .t-courseImg {
  206. &>image {
  207. width: 200rpx;
  208. height: 200rpx;
  209. border-radius: 32rpx;
  210. }
  211. }
  212. .t-course {
  213. position: relative;
  214. .c-title {
  215. width: 430rpx;
  216. font-weight: 800;
  217. font-size: 32rpx;
  218. color: #222222;
  219. line-height: 52rpx;
  220. }
  221. .c-address {
  222. margin-top: 4rpx;
  223. font-size: 22rpx;
  224. color: #AAAAAA;
  225. }
  226. .c-price {
  227. font-weight: 800;
  228. font-size: 32rpx;
  229. color: #FB5B5B;
  230. height: 44rpx;
  231. line-height: 44rpx;
  232. }
  233. .c-ratio {
  234. font-size: 22rpx;
  235. color: #222222;
  236. height: 32rpx;
  237. line-height: 32rpx;
  238. }
  239. .c-class {
  240. font-size: 22rpx;
  241. color: #AAAAAA;
  242. height: 32rpx;
  243. line-height: 32rpx;
  244. }
  245. .c-icon {
  246. position: absolute;
  247. bottom: -30rpx;
  248. right: -42rpx;
  249. &>image {
  250. width: 161rpx;
  251. }
  252. }
  253. }
  254. }
  255. </style>