order.vue 9.3 KB

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