order.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331
  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">
  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 onSearchConfirm() {
  129. searchForm.value.pageNumber = 1
  130. pageNum.value = 1
  131. onSearch()
  132. }
  133. function onSearchClear() {
  134. searchForm.value.keyword = null
  135. searchForm.value.pageNumber = 1
  136. pageNum.value = 1
  137. onSearch()
  138. }
  139. function onSearch() {
  140. loadMoreStatus.value = 'more'
  141. query(searchForm.value).then(res => {
  142. if (res && res.message === 'success') {
  143. list.value = res.data
  144. if (res.count === 0) {
  145. visualLoadMore.value = false
  146. }
  147. }
  148. })
  149. }
  150. function onSearchTypeChange(val) {
  151. searchForm.value.type = searchType[val].value
  152. onSearchConfirm()
  153. }
  154. // 前往发票申请
  155. function onToInvoiceApplication() {
  156. uni.navigateTo({
  157. url: '/pages/InvoiceApplication/InvoiceApplication'
  158. })
  159. }
  160. onPullDownRefresh((e) => {
  161. searchForm.value.pageNumber = 1
  162. loadMoreStatus.value = 'more'
  163. query(searchForm.value).then(res => {
  164. if (res && res.message === 'success') {
  165. list.value = res.data
  166. if (res.count === 0) {
  167. visualLoadMore.value = false
  168. }
  169. uni.showToast({
  170. title: '刷新成功',
  171. icon: 'success',
  172. duration: 2000
  173. })
  174. }
  175. uni.stopPullDownRefresh()
  176. })
  177. })
  178. onReachBottom(async () => {
  179. if (loadMoreStatus.value === 'noMore') {
  180. uni.showToast({
  181. title: '没有更多啦>﹏<',
  182. icon: 'none'
  183. })
  184. return
  185. }
  186. visualLoadMore.value = true
  187. loadMoreStatus.value = 'loading'
  188. searchForm.value.pageNum++
  189. query(searchForm.value).then(res => {
  190. if (res && res.message === 'success') {
  191. if (res.data) {
  192. if (res.count >= list.value.length) {
  193. if (list.value.length === res.count) {
  194. loadMoreStatus.value = 'noMore'
  195. visualLoadMore.value = true
  196. } else {
  197. list.value.push(...res.data)
  198. loadMoreStatus.value = 'more'
  199. visualLoadMore.value = false
  200. }
  201. } else {
  202. loadMoreStatus.value = 'noMore'
  203. visualLoadMore.value = true
  204. }
  205. } else {
  206. loadMoreStatus.value = 'noMore'
  207. visualLoadMore.value = true
  208. }
  209. }
  210. })
  211. })
  212. onLoad(() => {
  213. onSearch()
  214. })
  215. </script>
  216. <style lang="scss" scoped>
  217. .container {
  218. height: 100vh;
  219. width: 100vw;
  220. background-color: $uni-text-color-inverse;
  221. .header-box {
  222. padding: 0 20rpx;
  223. background-color: $uni-text-color-inverse;
  224. @include topMagnet();
  225. }
  226. .search-box {
  227. margin-bottom: 20rpx;
  228. ::v-deep(.u-search) {
  229. background-color: #e5e5e5;
  230. border-radius: 50rpx;
  231. .u-action {
  232. width: 18%;
  233. background-color: $uni-color-primary;
  234. border-radius: 50rpx;
  235. color: $uni-text-color-inverse;
  236. margin-right: 8rpx;
  237. font-size: 28rpx;
  238. line-height: 50rpx;
  239. letter-spacing: 3rpx;
  240. text-align: center;
  241. }
  242. }
  243. }
  244. .list-box {
  245. padding: 0 20rpx;
  246. .list-item-box {
  247. padding: 20rpx;
  248. border-bottom: 5rpx solid #E6E6E6;
  249. &:active {
  250. background-color: $uni-bg-color-hover;
  251. }
  252. .title-box {
  253. font-size: $uni-title-font-size-3;
  254. font-weight: bold;
  255. margin-bottom: 20rpx;
  256. @include text-overflow()
  257. }
  258. .main-box {
  259. display: flex;
  260. justify-content: space-between;
  261. padding-left: 20rpx;
  262. .info-box {
  263. width: 50%;
  264. .info-item-box {
  265. display: flex;
  266. font-size: $uni-font-size-3;
  267. color: $uni-text-color-grey;
  268. line-height: 30rpx;
  269. .label {
  270. width: 80rpx;
  271. }
  272. }
  273. }
  274. .price-box {
  275. display: flex;
  276. align-items: flex-end;
  277. text-align: right;
  278. color: $uni-color-error;
  279. font-size: $uni-title-font-size-3;
  280. font-weight: bold;
  281. .button {
  282. background-color: #CCCCCC;
  283. color: $uni-text-color-inverse;
  284. padding: 6rpx 25rpx;
  285. border-radius: $uni-card-border-radius;
  286. }
  287. }
  288. }
  289. }
  290. }
  291. .buttom-block {
  292. height: 100rpx;
  293. padding-bottom: env(5rpx + safe-area-inset-bottom, 0);
  294. }
  295. .bottom-box {
  296. text-align: center;
  297. font-size: $uni-title-font-size-2;
  298. background-color: $uni-bg-color-grey;
  299. position: fixed;
  300. bottom: 0;
  301. width: 100%;
  302. .button {
  303. width: 100%;
  304. height: 100rpx;
  305. line-height: 100rpx;
  306. color: $uni-color-primary;
  307. letter-spacing: 2rpx;
  308. border: 1rpx solid #E9E9E9;
  309. &:active {
  310. background-color: $uni-bg-color-hover;
  311. }
  312. }
  313. }
  314. }
  315. </style>