order.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443
  1. <template>
  2. <view class="container">
  3. <view class="header-box">
  4. <view class="search-box">
  5. <u-search v-model="searchForm.keyword" :clearabled="true" placeholder="搜索您想要的内容"
  6. @search="onSearchConfirm" @custom="onSearchConfirm"></u-search>
  7. </view>
  8. <view class="tab-box" style="padding: 40rpx 0 35rpx;">
  9. <u-tabs name="label" :list="searchType" :is-scroll="true" v-model="searchForm.typeCurrent"
  10. @change="onSearchTypeChange" font-size="32" inactive-color="#000000" bg-color="'rgb(141, 204, 255)'"
  11. active-color="#ffffff" :bar-style="{'background-color': '#2979ff'}"
  12. :active-item-style="{'background-color': '#2979ff', 'border-radius':'30rpx'}" :gutter="40"
  13. height="55" :show-bar="false" duration="0"></u-tabs>
  14. </view>
  15. </view>
  16. <!-- <view class="header-content"></view> -->
  17. <u-empty mode="data" v-if="list.length === 0" iconSize="120" textSize="58" text="暂无数据" margin-top="400">
  18. </u-empty>
  19. <view class="list-box">
  20. <view class="list-item-box" v-for="item in list" :key="item.id" @click="onItem(item)">
  21. <view class="title-box">
  22. {{item.title}}
  23. </view>
  24. <view class="main-box">
  25. <view class="info-box">
  26. <view class="info-item-box">
  27. <view class="label">
  28. 订单编号:
  29. </view>
  30. <view class="text">
  31. {{item.orderNo}}
  32. </view>
  33. </view>
  34. <view class="info-item-box">
  35. <view class="label">
  36. 订单时间:
  37. </view>
  38. <view class="text">
  39. {{item.date}}
  40. </view>
  41. </view>
  42. </view>
  43. <view class="price-box">
  44. <view class="text" v-if="item.status === '1'">
  45. 实付款:&nbsp;¥{{item.amount}}元
  46. </view>
  47. <view class="button error" v-if="item.status === '0'" @click.stop="onPay(item)">
  48. 待支付
  49. </view>
  50. <view class="button" v-if="item.status === '2'">
  51. 订单关闭
  52. </view>
  53. </view>
  54. </view>
  55. </view>
  56. </view>
  57. <uni-load-more v-if="list.length !== 0" v-show="visualLoadMore" :status="loadMoreStatus"></uni-load-more>
  58. <view class="buttom-block" v-if="false"></view>
  59. <view class="bottom-box" v-if="false">
  60. <view class="button" @click="onToInvoiceApplication">
  61. 发票申请
  62. </view>
  63. </view>
  64. </view>
  65. </template>
  66. <script setup>
  67. import {
  68. ref
  69. } from 'vue'
  70. import {
  71. onLoad,
  72. onReachBottom,
  73. onPullDownRefresh
  74. } from '@dcloudio/uni-app'
  75. import {
  76. query,
  77. byId
  78. } from '@/api/order.js'
  79. import {
  80. msgError,
  81. msgSuccess
  82. } from '@/utils/common'
  83. const searchInputStyle = {
  84. backgroundColor: '#E5E5E5'
  85. }
  86. const searchType = [{
  87. label: '全部',
  88. value: null
  89. },
  90. {
  91. label: '研究报告',
  92. value: 8
  93. },
  94. {
  95. label: '培训课程',
  96. value: 9
  97. },
  98. {
  99. label: '个人会费',
  100. value: 1
  101. },
  102. {
  103. label: '机构会费',
  104. value: 2
  105. }
  106. ]
  107. const pageNum = ref(1)
  108. const pageSize = ref(10)
  109. const visualLoadMore = ref(false)
  110. const loadMoreStatus = ref('more')
  111. const searchForm = ref({
  112. keyword: '',
  113. type: null,
  114. typeCurrent: 0,
  115. pageNumber: 1,
  116. pageSize: 10
  117. })
  118. const list = ref([
  119. // {
  120. // id: '01',
  121. // title: '【市场研究】2024年11月广州市中介促成二手住宅市场交易简报',
  122. // type: 8,
  123. // orderNo: '123456789987654321',
  124. // date: '2023年8月8日',
  125. // amount: 9.9,
  126. // invoice: true,
  127. // status: 1
  128. // },
  129. ])
  130. function onItem(order) {
  131. if (order.status === '2') {
  132. uni.showToast({
  133. title: '订单已关闭',
  134. icon: 'none'
  135. })
  136. return
  137. }
  138. uni.showLoading({
  139. title: '加载中...'
  140. })
  141. byId(order.id).then(res => {
  142. if (res && res.code === 0) {
  143. uni.hideLoading()
  144. const objId = res.data.objId
  145. const title = res.data.title
  146. if (res.data.objType === '8') {
  147. uni.navigateTo({
  148. url: `/pages/reportDetail/reportDetail?id=${objId}&title=${title}`
  149. })
  150. }
  151. if (res.data.objType === '9') {
  152. uni.navigateTo({
  153. url: `/pages/goOnEdu/course/courseDetail/courseDetail?id=${objId}&title=${title}`
  154. })
  155. }
  156. } else {
  157. uni.hideLoading()
  158. }
  159. }).catch(e => {
  160. uni.hideLoading()
  161. })
  162. }
  163. function onPay(order) {
  164. wx.requestPayment({
  165. timeStamp: order.prepay.timeStamp,
  166. nonceStr: order.prepay.nonceStr,
  167. package: order.prepay.package,
  168. signType: order.prepay.signType,
  169. paySign: order.prepay.paySign,
  170. success(res) {
  171. msgSuccess('支付成功')
  172. onSearch()
  173. },
  174. fail(res) {
  175. // console.log('支付失败', res)
  176. const errMsg = res.errMsg
  177. if (errMsg.indexOf('fail cancel')) {
  178. msgError('已取消支付')
  179. }
  180. }
  181. })
  182. }
  183. function onSearchConfirm() {
  184. searchForm.value.pageNumber = 1
  185. pageNum.value = 1
  186. onSearch()
  187. }
  188. function onSearchClear() {
  189. searchForm.value.keyword = null
  190. searchForm.value.pageNumber = 1
  191. pageNum.value = 1
  192. onSearch()
  193. }
  194. function onSearch() {
  195. loadMoreStatus.value = 'more'
  196. query(searchForm.value).then(res => {
  197. if (res && res.code === 0) {
  198. list.value = res.data
  199. if (res.count === 0) {
  200. visualLoadMore.value = false
  201. }
  202. }
  203. })
  204. }
  205. function onSearchTypeChange(val) {
  206. searchForm.value.type = searchType[val].value
  207. onSearchConfirm()
  208. }
  209. // 前往发票申请
  210. function onToInvoiceApplication() {
  211. uni.navigateTo({
  212. url: '/pages/InvoiceApplication/InvoiceApplication'
  213. })
  214. }
  215. onPullDownRefresh((e) => {
  216. searchForm.value.pageNumber = 1
  217. loadMoreStatus.value = 'more'
  218. query(searchForm.value).then(res => {
  219. if (res && res.code === 0) {
  220. list.value = res.data
  221. if (res.count === 0) {
  222. visualLoadMore.value = false
  223. }
  224. uni.showToast({
  225. title: '刷新成功',
  226. icon: 'success',
  227. duration: 2000
  228. })
  229. }
  230. uni.stopPullDownRefresh()
  231. })
  232. })
  233. onReachBottom(async () => {
  234. if (loadMoreStatus.value === 'noMore') {
  235. uni.showToast({
  236. title: '没有更多啦>﹏<',
  237. icon: 'none'
  238. })
  239. return
  240. }
  241. visualLoadMore.value = true
  242. loadMoreStatus.value = 'loading'
  243. searchForm.value.pageNumber++
  244. query(searchForm.value).then(res => {
  245. if (res && res.code === 0) {
  246. if (res.data) {
  247. if (res.count >= list.value.length) {
  248. if (list.value.length === res.count) {
  249. loadMoreStatus.value = 'noMore'
  250. visualLoadMore.value = true
  251. } else {
  252. list.value.push(...res.data)
  253. loadMoreStatus.value = 'more'
  254. visualLoadMore.value = false
  255. }
  256. } else {
  257. loadMoreStatus.value = 'noMore'
  258. visualLoadMore.value = true
  259. }
  260. } else {
  261. loadMoreStatus.value = 'noMore'
  262. visualLoadMore.value = true
  263. }
  264. }
  265. })
  266. })
  267. onLoad(() => {
  268. onSearch()
  269. })
  270. </script>
  271. <style>
  272. ::v-deep(.u-tab-item) {
  273. margin-right: 20rpx;
  274. }
  275. ::v-deep(.u-empty) {
  276. height: auto !important;
  277. }
  278. </style>
  279. <style lang="scss" scoped>
  280. $certificate-width: 220rpx;
  281. $certificate-height: 300rpx;
  282. .container {
  283. height: 100vh;
  284. width: 100vw;
  285. background: rgb(141, 204, 255);
  286. background: -moz-linear-gradient(90deg, rgb(141, 204, 255) 10%, rgb(247, 247, 247) 30%);
  287. background: -webkit-linear-gradient(90deg, rgb(141, 204, 255) 10%, rgb(247, 247, 247) 30%);
  288. background: -o-linear-gradient(90deg, rgb(141, 204, 255) 10%, rgb(247, 247, 247) 30%);
  289. background: -ms-linear-gradient(90deg, rgb(141, 204, 255) 10%, rgb(247, 247, 247) 30%);
  290. background: linear-gradient(180deg, rgb(141, 204, 255) 10%, rgb(247, 247, 247) 30%);
  291. $header-bg-color: #8dccff;
  292. // $transition-duration: 0.4s;
  293. .header-box {
  294. padding: 0 20px;
  295. // 应用顶部磁吸效果
  296. @include topMagnet();
  297. // 初始状态:透明背景
  298. background-color: $header-bg-color;
  299. }
  300. .search-box {
  301. padding-top: 10rpx;
  302. // margin-bottom: 20rpx;
  303. ::v-deep(.u-search) {
  304. // background-color: #e5e5e5;
  305. border-radius: 50rpx;
  306. .u-action {
  307. width: 18%;
  308. background-color: $uni-color-primary;
  309. border-radius: 50rpx;
  310. color: $uni-text-color-inverse;
  311. margin-right: 8rpx;
  312. font-size: 28rpx;
  313. line-height: 50rpx;
  314. letter-spacing: 3rpx;
  315. text-align: center;
  316. }
  317. }
  318. }
  319. .list-box {
  320. padding: 0 20rpx;
  321. .list-item-box {
  322. padding: 40rpx 20rpx;
  323. margin: 35rpx 0;
  324. /* border-bottom: 5rpx solid #E6E6E6; */
  325. box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
  326. background-color: #fff;
  327. border-radius: 20rpx;
  328. &:first-child {
  329. // padding: 0 20rpx 40rpx;
  330. margin-top: 0;
  331. }
  332. &:active {
  333. background-color: $uni-bg-color-hover;
  334. }
  335. .title-box {
  336. font-size: 28rpx;
  337. font-weight: bold;
  338. margin-bottom: 20rpx;
  339. @include text-overflow()
  340. }
  341. .main-box {
  342. display: flex;
  343. justify-content: space-between;
  344. // padding-left: 20rpx;
  345. position: relative;
  346. .info-box {
  347. // width: 50%;
  348. width: 100%;
  349. flex: 1 1 auto;
  350. .info-item-box {
  351. display: flex;
  352. font-size: 22rpx;
  353. color: $uni-text-color-grey;
  354. line-height: 40rpx;
  355. .label {
  356. flex: 0 0 auto;
  357. // width: 80rpx;
  358. margin-right: 10rpx;
  359. }
  360. }
  361. }
  362. .price-box {
  363. // flex: 0 0 auto;
  364. position: absolute;
  365. right: 0;
  366. bottom: 0;
  367. display: flex;
  368. align-items: flex-end;
  369. text-align: right;
  370. color: $uni-color-error;
  371. font-size: $uni-title-font-size-3;
  372. font-weight: bold;
  373. .button {
  374. background-color: #CCCCCC;
  375. color: $uni-text-color-inverse;
  376. padding: 6rpx 25rpx;
  377. border-radius: $uni-card-border-radius;
  378. }
  379. .error {
  380. background-color: $uni-color-error;
  381. }
  382. }
  383. }
  384. }
  385. }
  386. .buttom-block {
  387. height: 100rpx;
  388. padding-bottom: env(5rpx + safe-area-inset-bottom, 0);
  389. }
  390. .bottom-box {
  391. text-align: center;
  392. font-size: $uni-title-font-size-2;
  393. background-color: $uni-bg-color-grey;
  394. position: fixed;
  395. bottom: 0;
  396. width: 100%;
  397. .button {
  398. width: 100%;
  399. height: 100rpx;
  400. line-height: 100rpx;
  401. color: $uni-color-primary;
  402. letter-spacing: 2rpx;
  403. border: 1rpx solid #E9E9E9;
  404. &:active {
  405. background-color: $uni-bg-color-hover;
  406. }
  407. }
  408. }
  409. }
  410. </style>