record.vue 6.3 KB

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