record.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  1. <template>
  2. <view class="page">
  3. <PageHeader title="" style="border: 1px solid #f2f6f2">
  4. <template v-slot:center>
  5. <view class="tabs">
  6. <view class="tab" :class="{ active: currentTab === 'vip' }" @click="switchTab('vip')">会员记录</view>
  7. <view class="tab" :class="{ active: currentTab === 'coin' }" @click="switchTab('coin')">M币明细</view>
  8. <view class="tab" :class="{ active: currentTab === 'star' }" @click="switchTab('star')">星源记录</view>
  9. </view>
  10. </template>
  11. </PageHeader>
  12. <view class="reserveASeat"></view>
  13. <view class="record-list">
  14. <template v-if="currentTab === 'vip'">
  15. <view v-if="recordList.length === 0" class="empty-state">
  16. <image src="@/static/icon/xx_img_zanwuxiaoxi.png" mode="aspectFit" class="empty-image"></image>
  17. <view class="empty-text">暂无会员记录</view>
  18. <view class="empty-subtext">快去开通会员吧~</view>
  19. </view>
  20. <view v-else class="record-item" v-for="(item, index) in recordList" :key="index">
  21. <view class="record-info">
  22. <view class="record-title">{{ item.name }}</view>
  23. <view class="record-time">订单编号:{{ item.linkid }}</view>
  24. <view class="record-time">开通时间:{{ item.create_time }}</view>
  25. </view>
  26. <view class="record-amount" :class="{ success: item.status === 1 }">
  27. ¥{{ item.money }}
  28. <text class="status">{{
  29. item.status === 1 ? "支付成功" : "待支付"
  30. }}</text>
  31. </view>
  32. </view>
  33. </template>
  34. <template v-else>
  35. <view v-if="recordList.length === 0" class="empty-state">
  36. <image src="@/static/icon/xx_img_zanwuxiaoxi.png" mode="aspectFit" class="empty-image"></image>
  37. <view class="empty-text">{{ currentTab === 'coin' ? '暂无M币记录' : '暂无星源记录' }}</view>
  38. <view class="empty-subtext">{{ currentTab === 'coin' ? '快去充值M币吧~' : '快去获取星源吧~' }}</view>
  39. </view>
  40. <view v-else class="record-item" v-for="(item, index) in recordList" :key="index">
  41. <view class="record-info">
  42. <view class="record-title">{{ item.name }}</view>
  43. <view class="record-time">{{ item.create_time }}</view>
  44. </view>
  45. <view class="record-amount" :class="{ expense: item.type === '-' }">
  46. {{ item.type === "-" ? "-" : "" }}{{ item.num }}
  47. </view>
  48. </view>
  49. </template>
  50. </view>
  51. <!-- 加载更多提示 -->
  52. <view class="loading-more" v-if="loading">
  53. <text>加载中...</text>
  54. </view>
  55. <view class="no-more" v-else-if="!hasMore && recordList.length > 0">
  56. <text>没有更多数据了</text>
  57. </view>
  58. </view>
  59. </template>
  60. <script>
  61. import PageHeader from "@/components/PageHeader/PageHeader.vue";
  62. export default {
  63. components: {
  64. PageHeader,
  65. },
  66. data() {
  67. return {
  68. currentTab: "vip",
  69. recordList: [],
  70. page: 1,
  71. hasMore: true,
  72. loading: false,
  73. offset: 0,
  74. };
  75. },
  76. onLoad(options) {
  77. if (options.type) {
  78. this.currentTab = options.type;
  79. }
  80. this.loadData();
  81. },
  82. onReachBottom() {
  83. if (this.hasMore && !this.loading) {
  84. this.loadData();
  85. }
  86. },
  87. methods: {
  88. switchTab(tab) {
  89. if (this.currentTab === tab) return;
  90. this.currentTab = tab;
  91. this.page = 1;
  92. this.offset = 0;
  93. this.recordList = [];
  94. this.hasMore = true;
  95. this.loadData();
  96. },
  97. loadData() {
  98. if (this.loading) return;
  99. this.loading = true;
  100. let url = "";
  101. let params = {
  102. uuid: getApp().globalData.uuid,
  103. offset: this.offset,
  104. };
  105. if (this.currentTab === "vip") {
  106. url = this.$apiHost + "/Order/getlist";
  107. params.type = "buyVip";
  108. } else {
  109. url = this.$apiHost + "/My/recordlist";
  110. params.type = this.currentTab === "coin" ? "GMM" : "GMD";
  111. }
  112. uni.request({
  113. url: url,
  114. data: params,
  115. header: {
  116. "content-type": "application/json",
  117. sign: getApp().globalData.headerSign,
  118. },
  119. success: (res) => {
  120. if (res && res.data && res.data.success === "yes") {
  121. if (!res.data.list) {
  122. this.hasMore = false;
  123. uni.showToast({
  124. title: res.data.msg || "没有更多数据了",
  125. icon: "none",
  126. });
  127. return;
  128. }
  129. const newList = res.data.list;
  130. if (this.offset === 0) {
  131. this.recordList = newList;
  132. } else {
  133. this.recordList = [...this.recordList, ...newList];
  134. }
  135. this.hasMore = newList.length > 0;
  136. this.offset += 20;
  137. } else {
  138. this.hasMore = false;
  139. uni.showToast({
  140. title: res.data.msg || "获取数据失败",
  141. icon: "none",
  142. });
  143. }
  144. },
  145. fail: (err) => {
  146. console.log("请求失败:", err);
  147. this.hasMore = false;
  148. uni.showToast({
  149. title: "网络错误,请重试",
  150. icon: "none",
  151. });
  152. },
  153. complete: () => {
  154. this.loading = false;
  155. },
  156. });
  157. },
  158. },
  159. };
  160. </script>
  161. <style lang="scss">
  162. .page {
  163. min-height: 100vh;
  164. background-color: #fff;
  165. padding-top: 10px;
  166. }
  167. .tabs {
  168. display: flex;
  169. height: 100%;
  170. justify-content: center;
  171. align-items: center;
  172. width: 100%;
  173. .tab {
  174. position: relative;
  175. width: 140rpx;
  176. height: 48rpx;
  177. font-size: 32rpx;
  178. color: #999;
  179. text-align: center;
  180. margin: 0 20rpx;
  181. transition: all .5s;
  182. padding-right: 10rpx;
  183. font-family: 'PingFang SC-Medium';
  184. font-weight: normal;
  185. &.active {
  186. font-weight: 400;
  187. font-family: "PingFang SC-Bold";
  188. color: #1f1f1f;
  189. background: url("../../static/me/wd_img_qiehuan.png") right center / auto 100% no-repeat;
  190. }
  191. }
  192. }
  193. .record-list {
  194. padding: 0 32rpx;
  195. .record-item {
  196. display: flex;
  197. justify-content: space-between;
  198. align-items: flex-start;
  199. padding: 32rpx 0;
  200. border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  201. .record-info {
  202. .record-title {
  203. font-size: 32rpx;
  204. color: #333;
  205. margin-bottom: 8rpx;
  206. font-weight: 400;
  207. font-family: "PingFang SC-Bold";
  208. }
  209. .record-time {
  210. font-size: 24rpx;
  211. color: #999;
  212. margin-bottom: 4rpx;
  213. }
  214. }
  215. .record-amount {
  216. text-align: right;
  217. font-size: 32rpx;
  218. color: #333;
  219. font-weight: 400;
  220. font-family: "PingFang SC-Bold";
  221. &.income {
  222. color: #1f1f1f;
  223. }
  224. &.expense {
  225. color: #ff5967;
  226. }
  227. .status {
  228. display: block;
  229. font-size: 24rpx;
  230. color: #ff5967;
  231. font-weight: normal;
  232. margin-top: 8rpx;
  233. &.success {
  234. color: #999;
  235. }
  236. }
  237. }
  238. }
  239. }
  240. .loading-more,
  241. .no-more {
  242. text-align: center;
  243. padding: 20rpx 0;
  244. color: #999;
  245. font-size: 24rpx;
  246. background-color: #fff;
  247. }
  248. .empty-state {
  249. display: flex;
  250. flex-direction: column;
  251. align-items: center;
  252. justify-content: center;
  253. margin: 40rpx auto;
  254. width: 90%;
  255. max-width: 600rpx;
  256. padding: 40rpx;
  257. background: #FFFFFF;
  258. border-radius: 24rpx;
  259. .empty-image {
  260. width: 200rpx;
  261. height: 200rpx;
  262. margin-bottom: 20rpx;
  263. }
  264. .empty-text {
  265. font-size: 32rpx;
  266. color: #333333;
  267. margin-bottom: 16rpx;
  268. text-align: center;
  269. }
  270. .empty-subtext {
  271. font-size: 28rpx;
  272. color: #999999;
  273. text-align: center;
  274. }
  275. }
  276. .reserveASeat {
  277. width: 100%;
  278. height: calc(var(--status-bar-height) + 100rpx);
  279. }
  280. </style>