You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

221 lines
4.9 KiB

1 month ago
  1. <template>
  2. <view class="order-container">
  3. <view v-if="orderList.length>0">
  4. <view class="order-text-blod" style="margin: 0 0 14px 10px;">
  5. 全部订单
  6. </view>
  7. <view class="order-item" v-for="(order,index) in orderList" :key="index">
  8. <view class="order-title">
  9. <text
  10. class="order-text-blod">{{order.orderItemList&&order.orderItemList[0]&&order.orderItemList[0].productName}}</text>
  11. <text style="font-size: 14px;color: #A94F20;">{{ getStatusName(order.status) }}</text>
  12. </view>
  13. <view class="order-content">
  14. <view class="order-title">
  15. <text class="order-text-normal">下单时间</text>
  16. <text class="order-text-normal" style="color: #999;">{{order.paymentTime}}</text>
  17. </view>
  18. <view class="order-title" style="margin-top: 14px;">
  19. <text class="order-text-normal">上门频率</text>
  20. <text class="order-text-normal" style="color: #999;">
  21. {{order.service.serviceFrequency =='once_a_day'?'一天一次':'一天两次'}}
  22. </text>
  23. </view>
  24. <!-- <view class="order-title" style="margin-top: 14px;">
  25. <text class="order-text-normal">服务时间</text>
  26. <view>
  27. <view class="order-text-normal" style="color: #999;margin-bottom: 5px;"
  28. v-for="date in (order.service.serviceDate && getDateList(order.service.serviceDate))"
  29. :key="date">
  30. {{date}}
  31. </view>
  32. </view>
  33. </view> -->
  34. </view>
  35. <view class="order-price">
  36. <view class="order-text-blod">
  37. 总价:
  38. <text style="font-size: 20px; color:#FF530A;">{{order.payAmount}}</text>
  39. <text style="color:#FF530A; font-size:14px"> </text>
  40. </view>
  41. </view>
  42. </view>
  43. </view>
  44. <view class="no-data" v-else>
  45. 暂无数据
  46. </view>
  47. <Kefu></Kefu>
  48. </view>
  49. </template>
  50. <script>
  51. import { getOpenIdKey } from '@/utils/auth';
  52. import Kefu from '../common/kefu.vue'
  53. import {
  54. getOrderList,
  55. getOpenId
  56. } from "@/api/system/user.js"
  57. export default {
  58. data() {
  59. return {
  60. prames: {
  61. status: '-1',
  62. page: 0,
  63. size: 20,
  64. openId: ''
  65. },
  66. orderList: [],
  67. openIdStr: '',
  68. totalPages: 1,
  69. statusLsit: [{
  70. value: -1,
  71. label: '全部'
  72. },
  73. {
  74. value: 1,
  75. label: '待派单'
  76. },
  77. {
  78. value: 2,
  79. label: '已派单'
  80. },
  81. {
  82. value: 3,
  83. label: '已完成'
  84. },
  85. ]
  86. };
  87. },
  88. components:{
  89. Kefu
  90. },
  91. onLoad() {
  92. this.openIdStr = getOpenIdKey()
  93. // this.openIdStr = this.$globalData.openIdStr;
  94. this.getOrderData()
  95. },
  96. onReachBottom() {
  97. this.prames.page = this.prames.page + 1
  98. this.getOrderData()
  99. },
  100. onPullDownRefresh() {
  101. this.prames = {
  102. status: '-1',
  103. page: 0,
  104. size: 20,
  105. openId: ''
  106. }
  107. this.orderList = []
  108. this.getOrderData()
  109. // wx.stopPullDownRefresh()
  110. //停止下拉刷新效果的api,如果发现进入刷新状态无法停止,可以用这个
  111. },
  112. methods: {
  113. getOrderData() {
  114. if (!this.openIdStr) {
  115. this.login()
  116. } else {
  117. if (this.prames.page < this.totalPages) {
  118. this.prames.openId = this.openIdStr
  119. getOrderList(this.prames).then(res => {
  120. if (res && res.content) {
  121. this.totalPages = res.totalPages
  122. this.orderList = [...this.orderList, ...res.content]
  123. }
  124. console.log(res);
  125. })
  126. } else {
  127. uni.showToast('暂无更多数据')
  128. }
  129. }
  130. },
  131. login() {
  132. uni.login({
  133. provider: 'weixin',
  134. success: (loginRes) => {
  135. this.getOpenId(loginRes.code)
  136. },
  137. fail: function(error) {
  138. // 授权失败处理
  139. uni.showToast('授权失败,请授权后再试')
  140. }
  141. });
  142. },
  143. getOpenId(code) {
  144. getOpenId(code).then(res => {
  145. if (res.code == 200 && res.data) {
  146. this.openIdStr = JSON.parse(res.data).openId;
  147. this.$globalData.openIdStr = this.openIdStr;
  148. this.getOrderData()
  149. }
  150. })
  151. },
  152. getStatusName(status) {
  153. const currentStatus = this.statusLsit.find(item => item.value == status)
  154. if (currentStatus) {
  155. return currentStatus.label
  156. }
  157. return ''
  158. },
  159. getDateList(serviceDate) {
  160. return JSON.parse(serviceDate).sort()
  161. }
  162. },
  163. }
  164. </script>
  165. <style lang="scss">
  166. .order-container {
  167. padding: 14px 10px;
  168. background-color: #F5F5F7;
  169. height: 100vh;
  170. .order-item {
  171. border-radius: 8px;
  172. background: #FFF;
  173. padding: 18px 10px 14px;
  174. margin-bottom: 10px;
  175. .order-title {
  176. display: flex;
  177. justify-content: space-between;
  178. }
  179. .order-content {
  180. background-color: #FFFCF2;
  181. padding: 14px 16px;
  182. margin-top: 14px;
  183. }
  184. .order-price {
  185. margin-top: 14px;
  186. text-align: end;
  187. }
  188. }
  189. .order-text-blod {
  190. font-size: 16px;
  191. color: #333;
  192. font-weight: bold;
  193. line-height: 16px;
  194. }
  195. .order-text-normal {
  196. font-size: 16px;
  197. color: #333;
  198. line-height: 16px;
  199. }
  200. .no-data {
  201. color: #999;
  202. height: 60vh;
  203. display: flex;
  204. justify-content: center;
  205. align-items: center;
  206. font-size: 20px;
  207. }
  208. }
  209. </style>