order.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  1. <template>
  2. <view class="container">
  3. <view class="header-box">
  4. <view class="search-box">
  5. <u-search
  6. v-model="searchForm.keyword"
  7. :clearabled="true"
  8. bg-color="#E5E5E5"
  9. :input-style="searchInputStyle"
  10. placeholder="搜索您想要的内容"
  11. ></u-search>
  12. </view>
  13. <view class="tab-box">
  14. <u-tabs
  15. name="label"
  16. :list="searchType"
  17. :is-scroll="true"
  18. v-model="searchForm.type"
  19. @change="onSearchTypeChange"
  20. font-size="24"
  21. :bold="false"
  22. inactive-color="#000000"
  23. active-color="#000000"
  24. :bar-style="{'background-color': '#2979ff'}"
  25. :gutter="25"
  26. height="45"
  27. ></u-tabs>
  28. </view>
  29. </view>
  30. <u-empty
  31. mode="data"
  32. v-if="list.length === 0"
  33. iconSize="120"
  34. textSize="58"
  35. text="暂无数据"
  36. >
  37. </u-empty>
  38. <view class="list-box">
  39. <view class="list-item-box" v-for="item in list" :key="item.id" @click="onItem(item)">
  40. <view class="title-box">
  41. {{item.title}}
  42. </view>
  43. <view class="main-box">
  44. <view class="info-box">
  45. <view class="info-item-box">
  46. <view class="label">
  47. 订单编号:
  48. </view>
  49. <view class="text">
  50. {{item.orderNo}}
  51. </view>
  52. </view>
  53. <view class="info-item-box">
  54. <view class="label">
  55. 订单时间:
  56. </view>
  57. <view class="text">
  58. {{item.buyDate}}
  59. </view>
  60. </view>
  61. </view>
  62. <view class="price-box">
  63. <view class="text" v-if="item.status === '1'">
  64. 实付款:&nbsp;¥{{item.buyPrice}}元
  65. </view>
  66. <view class="button" v-if="item.status === '0'">
  67. 待支付
  68. </view>
  69. <view class="button" v-if="item.status === '2'">
  70. 订单关闭
  71. </view>
  72. </view>
  73. </view>
  74. </view>
  75. </view>
  76. <uni-load-more v-show="visualLoadMore" :status="loadMoreStatus"></uni-load-more>
  77. <view class="buttom-block"></view>
  78. <view class="bottom-box">
  79. <view class="button" @click="onToInvoiceApplication">
  80. 发票申请
  81. </view>
  82. </view>
  83. </view>
  84. </template>
  85. <script setup>
  86. import { ref } from 'vue'
  87. import { onLoad, onReachBottom, onPullDownRefresh } from '@dcloudio/uni-app'
  88. import { query } from '@/api/order.js'
  89. const searchInputStyle = {
  90. backgroundColor: '#E5E5E5'
  91. }
  92. const searchType = [
  93. {
  94. label: '全部',
  95. value: null
  96. },
  97. {
  98. label: '研究报告',
  99. value: 8
  100. },
  101. {
  102. label: '培训课程',
  103. value: 9
  104. },
  105. ]
  106. const pageNum = ref(1)
  107. const pageSize = ref(10)
  108. const visualLoadMore = ref(false)
  109. const loadMoreStatus = ref('more')
  110. const searchForm = ref({
  111. keyword: '',
  112. type: null,
  113. pageNumber: 1,
  114. pageSize: 10
  115. })
  116. const list = ref([
  117. {
  118. id: '01',
  119. title: '【市场研究】2024年11月广州市中介促成二手住宅市场交易简报',
  120. type: 8,
  121. orderNo: '123456789987654321',
  122. buyDate: '2023年8月8日',
  123. buyPrice: 9.9,
  124. invoice: true,
  125. status: 1
  126. },
  127. ])
  128. function onItem(order) {
  129. console.log('点击订单', order)
  130. if (order.type === '8') {
  131. // 研究报告
  132. }
  133. if (order.type === '9') {
  134. // 培训课程
  135. }
  136. }
  137. function onSearchConfirm() {
  138. searchForm.value.pageNumber = 1
  139. pageNum.value = 1
  140. onSearch()
  141. }
  142. function onSearchClear() {
  143. searchForm.value.keyword = null
  144. searchForm.value.pageNumber = 1
  145. pageNum.value = 1
  146. onSearch()
  147. }
  148. function onSearch() {
  149. loadMoreStatus.value = 'more'
  150. query(searchForm.value).then(res => {
  151. if (res && res.message === 'success') {
  152. list.value = res.data
  153. if (res.count === 0) {
  154. visualLoadMore.value = false
  155. }
  156. }
  157. })
  158. }
  159. function onSearchTypeChange(val) {
  160. searchForm.value.type = searchType[val].value
  161. onSearchConfirm()
  162. }
  163. // 前往发票申请
  164. function onToInvoiceApplication() {
  165. uni.navigateTo({
  166. url: '/pages/InvoiceApplication/InvoiceApplication'
  167. })
  168. }
  169. onPullDownRefresh((e) => {
  170. searchForm.value.pageNumber = 1
  171. loadMoreStatus.value = 'more'
  172. query(searchForm.value).then(res => {
  173. if (res && res.message === 'success') {
  174. list.value = res.data
  175. if (res.count === 0) {
  176. visualLoadMore.value = false
  177. }
  178. uni.showToast({
  179. title: '刷新成功',
  180. icon: 'success',
  181. duration: 2000
  182. })
  183. }
  184. uni.stopPullDownRefresh()
  185. })
  186. })
  187. onReachBottom(async () => {
  188. if (loadMoreStatus.value === 'noMore') {
  189. uni.showToast({
  190. title: '没有更多啦>﹏<',
  191. icon: 'none'
  192. })
  193. return
  194. }
  195. visualLoadMore.value = true
  196. loadMoreStatus.value = 'loading'
  197. searchForm.value.pageNum++
  198. query(searchForm.value).then(res => {
  199. if (res && res.message === 'success') {
  200. if (res.data) {
  201. if (res.count >= list.value.length) {
  202. if (list.value.length === res.count) {
  203. loadMoreStatus.value = 'noMore'
  204. visualLoadMore.value = true
  205. } else {
  206. list.value.push(...res.data)
  207. loadMoreStatus.value = 'more'
  208. visualLoadMore.value = false
  209. }
  210. } else {
  211. loadMoreStatus.value = 'noMore'
  212. visualLoadMore.value = true
  213. }
  214. } else {
  215. loadMoreStatus.value = 'noMore'
  216. visualLoadMore.value = true
  217. }
  218. }
  219. })
  220. })
  221. onLoad(() => {
  222. onSearch()
  223. })
  224. </script>
  225. <style lang="scss" scoped>
  226. .container {
  227. height: 100vh;
  228. width: 100vw;
  229. background-color: $uni-text-color-inverse;
  230. .header-box {
  231. padding: 0 20rpx;
  232. background-color: $uni-text-color-inverse;
  233. @include topMagnet();
  234. }
  235. .search-box {
  236. margin-bottom: 20rpx;
  237. ::v-deep(.u-search) {
  238. background-color: #e5e5e5;
  239. border-radius: 50rpx;
  240. .u-action {
  241. width: 18%;
  242. background-color: $uni-color-primary;
  243. border-radius: 50rpx;
  244. color: $uni-text-color-inverse;
  245. margin-right: 8rpx;
  246. font-size: 28rpx;
  247. line-height: 50rpx;
  248. letter-spacing: 3rpx;
  249. text-align: center;
  250. }
  251. }
  252. }
  253. .list-box {
  254. padding: 0 20rpx;
  255. .list-item-box {
  256. padding: 20rpx;
  257. border-bottom: 5rpx solid #E6E6E6;
  258. &:active {
  259. background-color: $uni-bg-color-hover;
  260. }
  261. .title-box {
  262. font-size: $uni-title-font-size-3;
  263. font-weight: bold;
  264. margin-bottom: 20rpx;
  265. @include text-overflow()
  266. }
  267. .main-box {
  268. display: flex;
  269. justify-content: space-between;
  270. padding-left: 20rpx;
  271. .info-box {
  272. width: 50%;
  273. .info-item-box {
  274. display: flex;
  275. font-size: $uni-font-size-3;
  276. color: $uni-text-color-grey;
  277. line-height: 30rpx;
  278. .label {
  279. width: 80rpx;
  280. }
  281. }
  282. }
  283. .price-box {
  284. display: flex;
  285. align-items: flex-end;
  286. text-align: right;
  287. color: $uni-color-error;
  288. font-size: $uni-title-font-size-3;
  289. font-weight: bold;
  290. .button {
  291. background-color: #CCCCCC;
  292. color: $uni-text-color-inverse;
  293. padding: 6rpx 25rpx;
  294. border-radius: $uni-card-border-radius;
  295. }
  296. }
  297. }
  298. }
  299. }
  300. .buttom-block {
  301. height: 100rpx;
  302. padding-bottom: env(5rpx + safe-area-inset-bottom, 0);
  303. }
  304. .bottom-box {
  305. text-align: center;
  306. font-size: $uni-title-font-size-2;
  307. background-color: $uni-bg-color-grey;
  308. position: fixed;
  309. bottom: 0;
  310. width: 100%;
  311. .button {
  312. width: 100%;
  313. height: 100rpx;
  314. line-height: 100rpx;
  315. color: $uni-color-primary;
  316. letter-spacing: 2rpx;
  317. border: 1rpx solid #E9E9E9;
  318. &:active {
  319. background-color: $uni-bg-color-hover;
  320. }
  321. }
  322. }
  323. }
  324. </style>