order.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411
  1. <template>
  2. <view>
  3. <TuanAppShim bg="#fff"></TuanAppShim>
  4. <view v-if="$store.getters.userInfo.token" class="my-order-container">
  5. <OrderHeader
  6. ref="orderHeaderRef" :current-status="currentStatus" :menus="navMenus" :current-mode="currentOrderMode"
  7. @change-status="handleChangeStatus" @change-mode="handleChangeOrderMode" @search="handleSearchCommunityOrderList"
  8. >
  9. </OrderHeader>
  10. <view class="order-list" :class="{ ani: !isLoading }">
  11. <SubNavs
  12. v-show="isShowSubNav && ['comment', 'append'].includes(isShowSubNav)" :active-value="currentSubValue"
  13. :navs="subNavs" @change-sub="handleChangeSubNavs"
  14. ></SubNavs>
  15. <view v-show="currentOrderMode === 'community'">
  16. </view>
  17. <!-- 商城 -->
  18. <view v-show="currentOrderMode === 'shoppingMall'">
  19. <BusinessOrder
  20. v-for="(orderItem, orderIndex) in shoppingOrderList" :key="orderIndex" :data="orderItem"
  21. show-operate @refresh="getOrderList()" @pay-order="(e) => payObj = e"
  22. ></BusinessOrder>
  23. <view style="padding-bottom: 45upx;">
  24. <LoadingMore
  25. :status="!shoppingIsEmpty && !shoppingOrderList.length
  26. ? 'loading' : !shoppingIsEmpty && shoppingOrderList.length && (shoppingOrderList.length >= shoppingListTotal) ? 'no-more' : ''"
  27. >
  28. </LoadingMore>
  29. <tui-no-data v-if="shoppingIsEmpty" :fixed="false" style="margin-top: 60upx;">暂无数据</tui-no-data>
  30. </view>
  31. </view>
  32. <!-- 商圈 -->
  33. <view v-show="currentOrderMode === 'businessDistrict'">
  34. <BusinessOrder
  35. v-for="(orderItem, orderIndex) in businessOrderList" :key="orderIndex" :data="orderItem"
  36. show-operate @refresh="getOrderList()" @pay-order="(e) => payObj = e"
  37. ></BusinessOrder>
  38. <view style="padding-bottom: 45upx;">
  39. <LoadingMore
  40. :status="!businessIsEmpty && !businessOrderList.length
  41. ? 'loading' : !businessIsEmpty && businessOrderList.length && (businessOrderList.length >= businessListTotal) ? 'no-more' : ''"
  42. >
  43. </LoadingMore>
  44. <tui-no-data v-if="businessIsEmpty" :fixed="false" style="margin-top: 60upx;">暂无数据</tui-no-data>
  45. </view>
  46. </view>
  47. </view>
  48. </view>
  49. <!-- 未登录时 -->
  50. <TuanUnLoginPage v-else></TuanUnLoginPage>
  51. <!-- 商圈支付 -->
  52. <tui-bottom-popup :show="payObj.showPayPopup" @close="payObj.showPayPopup = false">
  53. <view v-if="payObj.showPayPopup" style="padding: 60upx 0 128upx;">
  54. <CashierList
  55. :price-pay="payObj.pricePay" show show-platform-pay :shop-id-pay="payObj.shopId"
  56. @change="(e) => payObj.payInfo = { ...payObj.payInfo, ...e }"
  57. />
  58. <tui-button
  59. type="warning" width="168upx" height="64upx" margin="30upx auto 0"
  60. shape="circle"
  61. @click="handleShopGoPay"
  62. >
  63. 确认支付
  64. </tui-button>
  65. </view>
  66. </tui-bottom-popup>
  67. <!-- toast -->
  68. <tui-toast ref="toast"></tui-toast>
  69. </view>
  70. </template>
  71. <script>
  72. import { businessSubNavs, shoppingSubNavs } from './config'
  73. import { getAllOrderListApi } from '../../api/anotherTFInterface'
  74. import { T_PAY_ORDER } from '../../constant'
  75. import TuanUnLoginPage from './components/TuanUnLoginPage.vue'
  76. import OrderHeader from './components/OrderHeader.vue'
  77. import BusinessOrder from './components/BusinessOrder.vue'
  78. import SubNavs from './components/SubNavs.vue'
  79. import { handleDoPay } from '../../utils/payUtil'
  80. export default {
  81. name: 'Order',
  82. components: {
  83. TuanUnLoginPage,
  84. OrderHeader,
  85. BusinessOrder,
  86. SubNavs
  87. },
  88. data() {
  89. return {
  90. currentOrderMode: 'shoppingMall',
  91. currentStatus: 0,
  92. currentSubValue: 0,
  93. communityCommentOrder: [],
  94. isLoading: false, // 是否加载中
  95. loadingStatus: 'loading', // 加载状态
  96. isShowSubNav: null,
  97. totalCommunityPages: 0,
  98. communityOrderList: [],
  99. // 二次追加订单
  100. awaitPayOrderList: [], // 待支付
  101. payedOrderList: [], // 已支付
  102. refusedOrderList: [], // 已拒绝
  103. // 评论订单
  104. commentOrder: {
  105. commentOrderList: [], // 待评论订单
  106. commentAppendOrderList: [], // 可追加订单
  107. commentedOrderList: [] // 已评论订单
  108. },
  109. currentNavInfo: {
  110. label: '全部',
  111. value: -1
  112. },
  113. // 商城订单
  114. shoppingQueryInfo: {
  115. page: 1,
  116. pageSize: 10,
  117. orderType: 1
  118. },
  119. shoppingOrderList: [],
  120. shoppingListTotal: 0,
  121. shoppingIsEmpty: false,
  122. // 商圈订单
  123. businessQueryInfo: {
  124. page: 1,
  125. pageSize: 10,
  126. orderType: 2
  127. },
  128. businessOrderList: [],
  129. businessListTotal: 0,
  130. businessIsEmpty: false,
  131. // 支付相关
  132. payObj: {
  133. showPayPopup: false,
  134. pricePay: 0,
  135. shopId: '',
  136. payInfo: {}
  137. }
  138. }
  139. },
  140. computed: {
  141. navMenus() {
  142. switch (this.currentOrderMode) {
  143. case 'community':
  144. return []
  145. break
  146. case 'shoppingMall':
  147. return shoppingSubNavs
  148. break
  149. case 'businessDistrict':
  150. return businessSubNavs
  151. break
  152. default:
  153. return ''
  154. break
  155. }
  156. },
  157. subNavs() {
  158. if (this.isShowSubNav) return this.isShowSubNav === 'append' ? [] : this.isShowSubNav === 'comment' ? this.communityCommentOrder : ''
  159. return []
  160. },
  161. appendOrderList() {
  162. if (!this.isShowSubNav) return []
  163. if (this.isShowSubNav === 'append') {
  164. if (this.currentSubValue === 0) {
  165. return this.awaitPayOrderList
  166. } else if (this.currentSubValue === 1) {
  167. return this.payedOrderList
  168. } else if (this.currentSubValue === 2) {
  169. return this.refusedOrderList
  170. }
  171. }
  172. return []
  173. },
  174. noDataVisible() {
  175. if (this.isLoading) return false
  176. if (this.currentOrderMode === 'community') {
  177. if (!this.isShowSubNav) {
  178. return !this.communityOrderList.length
  179. }
  180. if (this.isShowSubNav) {
  181. if (this.isShowSubNav === 'append') {
  182. return !this.appendOrderList.length
  183. } else if (this.isShowSubNav === 'comment') {
  184. if (this.currentSubValue === 0) {
  185. return !this.commentOrder.commentOrderList.length
  186. } else if (this.currentSubValue === 1) {
  187. return !this.commentOrder.commentedOrderList.length
  188. }
  189. return !this.commentOrder.commentAppendOrderList.length
  190. }
  191. }
  192. } else {
  193. return true
  194. }
  195. }
  196. },
  197. onShow() {
  198. uni.removeStorageSync(T_PAY_ORDER)
  199. this.$nextTick(() => {
  200. this.getOrderList()
  201. })
  202. },
  203. methods: {
  204. handleChangeOrderMode(mode) {
  205. if (mode === this.currentOrderMode) return
  206. this.currentOrderMode = mode
  207. if (this.currentOrderMode === 'community') {
  208. } else if (this.currentOrderMode === 'shoppingMall') {
  209. this.currentStatus = 0
  210. } else if (this.currentOrderMode === 'businessDistrict') {
  211. this.currentStatus = 0
  212. }
  213. this.isShowSubNav = null
  214. this.getOrderList()
  215. },
  216. // 清空搜索
  217. clearSearch() {
  218. this.$refs.orderHeaderRef && this.$refs.orderHeaderRef.clearSearch()
  219. },
  220. // 点击搜索
  221. handleSearchCommunityOrderList(searchValue) {
  222. if (this.currentOrderMode === 'community') {
  223. } else {
  224. this.ttoast({
  225. type: 'fial',
  226. title: '只能搜索社区订单'
  227. })
  228. }
  229. },
  230. // 切换状态
  231. handleChangeStatus(navInfo) {
  232. if (!navInfo) return
  233. this.currentNavInfo = navInfo
  234. this.currentStatus = navInfo.value
  235. if (this.currentOrderMode === 'community') {
  236. this.isShowSubNav = null
  237. } else if (this.currentOrderMode === 'shoppingMall') {
  238. } else if (this.currentOrderMode === 'businessDistrict') {
  239. }
  240. this.getOrderList()
  241. },
  242. // 切换sub
  243. handleChangeSubNavs(info) {
  244. this.currentSubValue = info.value
  245. if (this.isShowSubNav === 'comment') {
  246. }
  247. },
  248. // 发起请求获取列表数据
  249. async getOrderList(isLoadmore) {
  250. if (this.currentOrderMode === 'community') {
  251. } else if (this.currentOrderMode === 'shoppingMall') {
  252. uni.showLoading()
  253. getAllOrderListApi({ ...this.shoppingQueryInfo, state: this.currentStatus || '' })
  254. .then((res) => {
  255. this.shoppingListTotal = res.data.total
  256. if (isLoadmore) {
  257. this.shoppingOrderList.push(...res.data.list)
  258. } else {
  259. this.shoppingOrderList = res.data.list
  260. }
  261. this.shoppingIsEmpty = this.shoppingOrderList.length === 0
  262. uni.hideLoading()
  263. })
  264. .catch(() => {
  265. uni.hideLoading()
  266. })
  267. } else if (this.currentOrderMode === 'businessDistrict') {
  268. uni.showLoading()
  269. getAllOrderListApi({ ...this.businessQueryInfo, state: this.currentStatus || '' })
  270. .then((res) => {
  271. this.businessListTotal = res.data.total
  272. if (isLoadmore) {
  273. this.businessOrderList.push(...res.data.list)
  274. } else {
  275. this.businessOrderList = res.data.list
  276. }
  277. this.businessIsEmpty = this.businessOrderList.length === 0
  278. uni.hideLoading()
  279. })
  280. .catch(() => {
  281. uni.hideLoading()
  282. })
  283. }
  284. },
  285. // 去评论
  286. handleComment({ itemData, isAppend }) {
  287. if (isAppend) {
  288. uni.navigateTo({
  289. url:
  290. '/community-center/comment-order/append-comment?orderNo=' +
  291. itemData.orderNo +
  292. '&serveName=' +
  293. itemData.serverName +
  294. '&url=' +
  295. itemData.serverUrl +
  296. '&commentId=' +
  297. itemData.id
  298. })
  299. } else {
  300. uni.navigateTo({
  301. url: '/community-center/comment-order/rate?orderNo=' + itemData.orderNo + '&serveName=' + itemData.serverName + '&url=' + itemData.serverUrl
  302. })
  303. }
  304. },
  305. // 是否可以下拉加载
  306. canReachBottomLoad() {
  307. if (this.currentOrderMode === 'community') {
  308. return ![-3, -2].includes(this.currentStatus)
  309. } else if (this.currentOrderMode === 'businessDistrict') {
  310. return true
  311. }
  312. },
  313. async handleShopGoPay() {
  314. await handleDoPay(this.payObj.payInfo, 1)
  315. this.payObj = {
  316. showPayPopup: false,
  317. pricePay: 0,
  318. shopId: '',
  319. payInfo: {}
  320. }
  321. }
  322. },
  323. onPullDownRefresh() {
  324. if (!this.$store.getters.userInfo.token) return uni.stopPullDownRefresh()
  325. this.awaitPayOrderList = []
  326. this.payedOrderList = []
  327. this.refusedOrderList = []
  328. this.commentOrder.commentOrderList = []
  329. this.commentOrder.commentAppendOrderList = []
  330. this.commentOrder.commentedOrderList = []
  331. this.getOrderList()
  332. },
  333. onReachBottom() {
  334. if (this.canReachBottomLoad()) {
  335. if (this.currentOrderMode === 'community') {
  336. } else if (this.currentOrderMode === 'shoppingMall') {
  337. if (this.shoppingOrderList.length < this.shoppingListTotal) {
  338. ++this.shoppingQueryInfo.page
  339. this.getOrderList(true)
  340. }
  341. } else if (this.currentOrderMode === 'businessDistrict') {
  342. if (this.businessOrderList.length < this.businessListTotal) {
  343. ++this.businessQueryInfo.page
  344. this.getOrderList(true)
  345. }
  346. }
  347. }
  348. }
  349. }
  350. </script>
  351. <style lang="scss" scoped>
  352. /deep/ .tui-lazyload__img {
  353. width: 140rpx !important;
  354. height: 140rpx !important;
  355. background-color: #ccc;
  356. }
  357. @keyframes fade {
  358. 0% {
  359. opacity: 0.4;
  360. transform: translateX(-100vw);
  361. }
  362. 100% {
  363. opacity: 1;
  364. transform: translateX(0);
  365. }
  366. }
  367. .my-order-container {
  368. width: 100vw;
  369. background-color: #f5f5f7;
  370. .order-list {
  371. min-height: 100vh;
  372. background-color: #f5f5f7;
  373. position: relative;
  374. padding: 220upx 30upx 124upx;
  375. box-sizing: border-box;
  376. &.ani {
  377. animation: fade 350ms ease-in-out;
  378. }
  379. }
  380. }
  381. </style>