order.vue 9.2 KB

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