recordCoupon.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. <template>
  2. <view class="page" :style="{'min-height':(h)+'px','padding-top':mt+'px'}">
  3. <c-nav-bar title="核销记录"></c-nav-bar>
  4. <view class="top">
  5. <view class="time-container">
  6. <view class="time" @click="showStartDate=true">
  7. <u-icon name="calendar" :label="orderTimeStart || '核销时间-开始'" labelPos="right" labelColor="#666" color="#666" space="7px"
  8. size="25px"></u-icon>
  9. <u-icon name="arrow-down" color="#999" size="20px" style="margin-left: 20rpx;"></u-icon>
  10. </view>
  11. <view class="time" @click="showEndDate=true">
  12. <u-icon name="calendar" :label="orderTimeEnd || '核销时间-结束'" labelPos="right" labelColor="#666" color="#666" space="7px"
  13. size="25px"></u-icon>
  14. <u-icon name="arrow-down" color="#999" size="20px" style="margin-left: 20rpx;"></u-icon>
  15. </view>
  16. </view>
  17. <!-- <view class="right">共{{totalNum}}单 收入¥{{totalAmount}}</view> -->
  18. </view>
  19. <view class="list">
  20. <block v-if="list.length>0">
  21. <view class="item" v-for="(item,index) in list" :key="index">
  22. <!-- <image :src="item.productImg|delArr"></image> -->
  23. <view class="price" style="font-size: bold;">{{item.productName}}</view>
  24. <view style="margin-top: 10rpx;">核销时间:{{item.orderTime}}</view>
  25. <view style="margin-top: 10rpx;">优惠金额:¥{{item.orderAmount}}</view>
  26. <view style="margin-top: 10rpx;">客户姓名:{{item.guestName}}</view>
  27. <view style="margin-top: 10rpx;">客户电话:{{item.guestPhone}}</view>
  28. </view>
  29. <!-- 加载更多 -->
  30. <view class="load-more" v-if="loading">
  31. <u-loading-icon size="24" color="#007A69"></u-loading-icon>
  32. <text style="margin-left: 10rpx;">加载中...</text>
  33. </view>
  34. <!-- 没有更多数据 -->
  35. <view class="no-more" v-else-if="!hasMore && list.length > 0">
  36. 没有更多数据了
  37. </view>
  38. </block>
  39. <block v-else>
  40. <NoData />
  41. </block>
  42. </view>
  43. <u-datetime-picker :immediateChange="true" @confirm="confirmStartDate" @cancel="showStartDate=false" :show="showStartDate" v-model="startDate" visibleItemCount="10" mode="date"></u-datetime-picker>
  44. <u-datetime-picker :immediateChange="true" @confirm="confirmEndDate" @cancel="showEndDate=false" :show="showEndDate" v-model="endDate" visibleItemCount="10" mode="date"></u-datetime-picker>
  45. </view>
  46. </template>
  47. <script>
  48. import {
  49. encrypt,
  50. decrypt,
  51. tuomin
  52. } from '../../utils/aes.js'
  53. export default {
  54. data() {
  55. return {
  56. dateStr: '请选择时间段',
  57. showStartDate: false,
  58. showEndDate: false,
  59. k: '',
  60. list: [],
  61. startDate: Number(new Date()) - 7 * 24 * 60 * 60 * 1000,
  62. endDate: Number(new Date()),
  63. orderTimeStart: '',
  64. orderTimeEnd: '',
  65. merchantId: uni.getStorageSync('merchantId'),
  66. totalAmount: 0,
  67. totalNum: 0,
  68. page:1,
  69. limit:10,
  70. total: 0,
  71. loading: false,
  72. hasMore: true,
  73. }
  74. },
  75. filters: {
  76. delArr(val) {
  77. if (val) {
  78. return val.split(',')[0]
  79. }
  80. }
  81. },
  82. onLoad() {
  83. this.getdata();
  84. },
  85. onReachBottom() {
  86. // 触底加载更多
  87. if (!this.loading && this.hasMore) {
  88. this.page++;
  89. this.getdata();
  90. }
  91. },
  92. methods: {
  93. getdata() {
  94. // 设置加载状态
  95. this.loading = true;
  96. const params = {
  97. page: this.page,
  98. limit: this.limit,
  99. merchantId: this.merchantId
  100. };
  101. // 添加时间段筛选参数
  102. if (this.orderTimeStart) {
  103. params.orderTimeStart = this.orderTimeStart;
  104. }
  105. if (this.orderTimeEnd) {
  106. params.orderTimeEnd = this.orderTimeEnd;
  107. }
  108. this.$api.get('/scenic/merchant/offline/order/page', params).then(res => {
  109. // 关闭加载状态
  110. this.loading = false;
  111. if (res.data.code == 0) {
  112. // this.totalAmount = res.data.data.orderAmount;
  113. // 处理数据累加
  114. if (this.page === 1) {
  115. this.list = res.data.data.list;
  116. } else {
  117. this.list = [...this.list, ...res.data.data.list];
  118. }
  119. // 更新总数
  120. this.totalNum = res.data.data.total || 0;
  121. // 判断是否还有更多数据
  122. this.hasMore = this.list.length < this.totalNum;
  123. }
  124. console.log(res)
  125. }).catch(() => {
  126. // 异常情况下关闭加载状态
  127. this.loading = false;
  128. })
  129. },
  130. confirmStartDate(e) {
  131. // 处理开始时间选择
  132. const date = new Date(e.value);
  133. const year = date.getFullYear();
  134. const month = ('0' + (date.getMonth() + 1)).slice(-2);
  135. const day = ('0' + date.getDate()).slice(-2);
  136. this.orderTimeStart = `${year}-${month}-${day}`;
  137. this.showStartDate = false;
  138. this.updateDateStr();
  139. // 重置分页参数
  140. this.page = 1;
  141. this.list = [];
  142. this.hasMore = true;
  143. this.getdata();
  144. },
  145. confirmEndDate(e) {
  146. // 处理结束时间选择
  147. const date = new Date(e.value);
  148. const year = date.getFullYear();
  149. const month = ('0' + (date.getMonth() + 1)).slice(-2);
  150. const day = ('0' + date.getDate()).slice(-2);
  151. this.orderTimeEnd = `${year}-${month}-${day}`;
  152. this.showEndDate = false;
  153. this.updateDateStr();
  154. // 重置分页参数
  155. this.page = 1;
  156. this.list = [];
  157. this.hasMore = true;
  158. this.getdata();
  159. },
  160. updateDateStr() {
  161. // 更新日期显示字符串
  162. if (this.orderTimeStart && this.orderTimeEnd) {
  163. this.dateStr = `${this.orderTimeStart} 至 ${this.orderTimeEnd}`;
  164. } else if (this.orderTimeStart) {
  165. this.dateStr = `开始时间: ${this.orderTimeStart}`;
  166. } else if (this.orderTimeEnd) {
  167. this.dateStr = `结束时间: ${this.orderTimeEnd}`;
  168. } else {
  169. this.dateStr = '请选择时间段';
  170. }
  171. },
  172. }
  173. }
  174. </script>
  175. <style lang="less" scoped>
  176. .page {
  177. box-sizing: border-box;
  178. background-color: #F5F5F5;
  179. }
  180. .top {
  181. padding: 24rpx 30rpx;
  182. display: flex;
  183. justify-content: space-between;
  184. align-items: center;
  185. background-color: #FFFFFF;
  186. box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.05);
  187. .time-container {
  188. display: flex;
  189. gap: 40rpx;
  190. }
  191. .time {
  192. display: flex;
  193. align-items: center;
  194. gap: 0 10rpx;
  195. padding: 12rpx 20rpx;
  196. background-color: #F9F9F9;
  197. border-radius: 12rpx;
  198. }
  199. .right {
  200. color: #999;
  201. font-size: 24rpx;
  202. }
  203. }
  204. .list {
  205. padding: 20rpx 30rpx;
  206. .item {
  207. background-color: #FFFFFF;
  208. border-radius: 16rpx;
  209. padding: 30rpx;
  210. margin-bottom: 20rpx;
  211. box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.05);
  212. transition: all 0.3s ease;
  213. &:hover {
  214. transform: translateY(-2rpx);
  215. box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.08);
  216. }
  217. .price {
  218. font-size: 34rpx;
  219. font-weight: bold;
  220. color: #333333;
  221. margin-bottom: 16rpx;
  222. line-height: 1.3;
  223. }
  224. view {
  225. font-size: 26rpx;
  226. color: #666666;
  227. line-height: 1.5;
  228. margin-bottom: 12rpx;
  229. &:last-child {
  230. margin-bottom: 0;
  231. }
  232. }
  233. }
  234. }
  235. .load-more {
  236. display: flex;
  237. justify-content: center;
  238. align-items: center;
  239. padding: 40rpx 0;
  240. color: #999;
  241. font-size: 28rpx;
  242. margin: 20rpx 30rpx;
  243. border-radius: 12rpx;
  244. }
  245. .no-more {
  246. display: flex;
  247. justify-content: center;
  248. align-items: center;
  249. padding: 40rpx 0;
  250. color: #999;
  251. font-size: 28rpx;
  252. margin: 20rpx 30rpx;
  253. border-radius: 12rpx;
  254. }
  255. </style>