record.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  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. <view>{{ dome1() }}</view>
  52. <view>{{ dome2() }}</view>
  53. <!-- 加载更多提示 -->
  54. <view class="loading-more" v-if="loading">
  55. <text>加载中...</text>
  56. </view>
  57. <view class="no-more" v-else-if="!hasMore && recordList.length > 0">
  58. <text>没有更多数据了</text>
  59. </view>
  60. </view>
  61. </template>
  62. <script>
  63. import PageHeader from "@/components/PageHeader/PageHeader.vue";
  64. import channelFlag from "@/common/channelFlag.js";
  65. import channel from "@/common/channel.js";
  66. export default {
  67. components: {
  68. PageHeader,
  69. },
  70. data() {
  71. return {
  72. currentTab: "vip",
  73. recordList: [],
  74. page: 1,
  75. hasMore: true,
  76. loading: false,
  77. offset: 0,
  78. };
  79. },
  80. onLoad(options) {
  81. if (options.type) {
  82. this.currentTab = options.type;
  83. }
  84. this.loadData();
  85. },
  86. onReachBottom() {
  87. if (this.hasMore && !this.loading) {
  88. this.loadData();
  89. }
  90. },
  91. methods: {
  92. switchTab(tab) {
  93. if (this.currentTab === tab) return;
  94. this.currentTab = tab;
  95. this.page = 1;
  96. this.offset = 0;
  97. this.recordList = [];
  98. this.hasMore = true;
  99. this.loadData();
  100. },
  101. loadData() {
  102. if (this.loading) return;
  103. this.loading = true;
  104. let url = "";
  105. let params = {
  106. uuid: getApp().globalData.uuid,
  107. offset: this.offset,
  108. };
  109. if (this.currentTab === "vip") {
  110. url = this.$apiHost + "/Order/getlist";
  111. params.type = "buyVip";
  112. } else {
  113. url = this.$apiHost + "/My/recordlist";
  114. params.type = this.currentTab === "coin" ? "GMM" : "GMD";
  115. }
  116. uni.request({
  117. url: url,
  118. data: params,
  119. header: {
  120. "content-type": "application/json",
  121. sign: getApp().globalData.headerSign,
  122. },
  123. success: (res) => {
  124. if (res && res.data && res.data.success === "yes") {
  125. if (!res.data.list) {
  126. this.hasMore = false;
  127. uni.showToast({
  128. title: res.data.msg || "没有更多数据了",
  129. icon: "none",
  130. });
  131. return;
  132. }
  133. const newList = res.data.list;
  134. if (this.offset === 0) {
  135. this.recordList = newList;
  136. } else {
  137. this.recordList = [...this.recordList, ...newList];
  138. }
  139. this.hasMore = newList.length > 0;
  140. this.offset += 20;
  141. } else {
  142. this.hasMore = false;
  143. uni.showToast({
  144. title: res.data.msg || "获取数据失败",
  145. icon: "none",
  146. });
  147. }
  148. },
  149. fail: (err) => {
  150. console.log("请求失败:", err);
  151. this.hasMore = false;
  152. uni.showToast({
  153. title: "网络错误,请重试",
  154. icon: "none",
  155. });
  156. },
  157. complete: () => {
  158. this.loading = false;
  159. },
  160. });
  161. },
  162. dome1() {
  163. // 直接输出当前渠道标识
  164. console.log('CHANNEL_FLAG:', channelFlag);
  165. return channelFlag;
  166. },
  167. dome2() {
  168. // 获取详细渠道信息
  169. const storeInfo = channel.getCurrentStore();
  170. console.log('渠道详细信息:', storeInfo);
  171. // 递归遍历对象,拼接成字符串
  172. function traverse(obj) {
  173. let result = [];
  174. for (const key in obj) {
  175. if (typeof obj[key] === 'object' && obj[key] !== null) {
  176. result.push(traverse(obj[key]));
  177. } else {
  178. result.push(`${key}:${obj[key]}`);
  179. }
  180. }
  181. return result.join('--j');
  182. }
  183. const str = traverse(storeInfo);
  184. console.log('渠道详细信息:', str);
  185. return str;
  186. // 只获取渠道名称
  187. console.log('渠道名称:', channel.getCurrentStoreName());
  188. }
  189. },
  190. };
  191. </script>
  192. <style lang="scss">
  193. .page {
  194. min-height: 100vh;
  195. background-color: #fff;
  196. padding-top: 10px;
  197. }
  198. .tabs {
  199. display: flex;
  200. height: 100%;
  201. justify-content: center;
  202. align-items: center;
  203. width: 100%;
  204. .tab {
  205. position: relative;
  206. width: 140rpx;
  207. height: 48rpx;
  208. font-size: 32rpx;
  209. font-family: "PingFang SC-Bold";
  210. color: #999;
  211. font-weight: 400;
  212. text-align: center;
  213. margin: 0 20rpx;
  214. &.active {
  215. color: #1f1f1f;
  216. background: url("../../static/me/wd_img_qiehuan.png") center / cover no-repeat;
  217. }
  218. }
  219. }
  220. .record-list {
  221. padding: 0 32rpx;
  222. .record-item {
  223. display: flex;
  224. justify-content: space-between;
  225. align-items: flex-start;
  226. padding: 32rpx 0;
  227. border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  228. .record-info {
  229. .record-title {
  230. font-size: 32rpx;
  231. color: #333;
  232. margin-bottom: 8rpx;
  233. font-weight: 500;
  234. }
  235. .record-time {
  236. font-size: 24rpx;
  237. color: #999;
  238. margin-bottom: 4rpx;
  239. }
  240. }
  241. .record-amount {
  242. text-align: right;
  243. font-size: 32rpx;
  244. color: #333;
  245. font-weight: 500;
  246. &.income {
  247. color: #07c160;
  248. }
  249. &.expense {
  250. color: #ff5967;
  251. }
  252. .status {
  253. display: block;
  254. font-size: 24rpx;
  255. color: #ff5967;
  256. font-weight: normal;
  257. margin-top: 8rpx;
  258. &.success {
  259. color: #999;
  260. }
  261. }
  262. }
  263. }
  264. }
  265. .loading-more,
  266. .no-more {
  267. text-align: center;
  268. padding: 20rpx 0;
  269. color: #999;
  270. font-size: 24rpx;
  271. background-color: #fff;
  272. }
  273. .empty-state {
  274. display: flex;
  275. flex-direction: column;
  276. align-items: center;
  277. justify-content: center;
  278. margin: 40rpx auto;
  279. width: 90%;
  280. max-width: 600rpx;
  281. padding: 40rpx;
  282. background: #FFFFFF;
  283. border-radius: 24rpx;
  284. .empty-image {
  285. width: 200rpx;
  286. height: 200rpx;
  287. margin-bottom: 20rpx;
  288. }
  289. .empty-text {
  290. font-size: 32rpx;
  291. color: #333333;
  292. margin-bottom: 16rpx;
  293. text-align: center;
  294. }
  295. .empty-subtext {
  296. font-size: 28rpx;
  297. color: #999999;
  298. text-align: center;
  299. }
  300. }
  301. .reserveASeat {
  302. width: 100%;
  303. height: calc(var(--status-bar-height) + 100rpx);
  304. }
  305. </style>