record.vue 7.7 KB

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