order.vue 9.6 KB

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