You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

vp-point.vue 10 kB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  1. <template>
  2. <div class="__reward-pointer-c">
  3. <div class="ui container" style="width:80%;min-width:1200px;">
  4. <div class="__r_p_header">
  5. <div>
  6. <p class="__title">{{ $t('calcPointDetails') }}</p>
  7. </div>
  8. <div style="padding: 0 5px; font-size: 14px">
  9. <span>
  10. <i class="question circle icon link" style="color: rgba(3, 102, 214, 1)" data-position="right center"
  11. data-variation="mini"></i>
  12. <a href="/reward/point/rule" target="_blank" style="color: rgba(3, 102, 214, 1)">{{
  13. $t('calcPointAcquisitionInstructions')
  14. }}</a>
  15. </span>
  16. </div>
  17. </div>
  18. <div class="__r_p_summary">
  19. <div class="__r_p_summary_item-c __flex-1">
  20. <div class="__val">{{ summaryInfo.available }}</div>
  21. <div class="__exp">{{ $t('CurrAvailableCalcPoints') }}</div>
  22. </div>
  23. <div class="__r_p_summary_line"></div>
  24. <div class="__r_p_summary_item-c __flex-1">
  25. <div class="__val">{{ summaryInfo.gain }}</div>
  26. <div class="__exp">{{ $t('totalGainCalcPoints') }}</div>
  27. </div>
  28. <div class="__r_p_summary_item-c __flex-1">
  29. <div class="__val">{{ summaryInfo.used }}</div>
  30. <div class="__exp">{{ $t('totalConsumeCalcPoints') }}</div>
  31. </div>
  32. </div>
  33. <div class="__r_p_tab">
  34. <div class="__r_p_tab-item" :class="tabIndex === 0 ? '__focus' : ''" style="border-radius: 5px 0px 0px 5px"
  35. @click="tabChange(0)">
  36. {{ $t('totalGainDetail') }}
  37. </div>
  38. <div class="__r_p_tab-item" :class="tabIndex === 1 ? '__focus' : ''" style="border-radius: 0px 5px 5px 0px"
  39. @click="tabChange(1)">
  40. {{ $t('totalConsumeDetail') }}
  41. </div>
  42. </div>
  43. <div class="__r_p_table">
  44. <div v-show="tabIndex === 0">
  45. <el-table :data="tableData" row-key="sn" style="width: 100%" v-loading="loading" stripe>
  46. <el-table-column column-key="sn" prop="sn" :label="$t('serialNumber')" align="center" header-align="center"
  47. width="180">
  48. </el-table-column>
  49. <el-table-column column-key="date" prop="date" :label="$t('time')" align="center" header-align="center"
  50. width="180">
  51. </el-table-column>
  52. <el-table-column column-key="sourceType" prop="sourceType" :label="$t('scene')" align="center"
  53. header-align="center" width="180"></el-table-column>
  54. <el-table-column column-key="action" prop="action" :label="$t('behaviorOfPoint')" align="center"
  55. header-align="center" width="200"></el-table-column>
  56. <el-table-column column-key="remark" prop="remark" :label="$t('explanation')" align="left" min-width="200"
  57. header-align="center">
  58. <template slot-scope="scope">
  59. <span v-html="scope.row.remark"></span>
  60. </template>
  61. </el-table-column>
  62. <el-table-column column-key="amount" prop="amount" :label="$t('points')" align="center"
  63. header-align="center" width="120"></el-table-column>
  64. <template slot="empty">
  65. <span>{{ loading ? $t('loading') : $t('noData') }}</span>
  66. </template>
  67. </el-table>
  68. </div>
  69. <div v-show="tabIndex === 1">
  70. <el-table :data="tableData" row-key="sn" style="width: 100%" v-loading="loading" stripe>
  71. <el-table-column column-key="sn" prop="sn" :label="$t('serialNumber')" align="center" header-align="center"
  72. width="180">
  73. </el-table-column>
  74. <el-table-column column-key="date" prop="date" :label="$t('time')" align="center" header-align="center"
  75. width="180">
  76. </el-table-column>
  77. <el-table-column column-key="status" prop="status" :label="$t('status')" align="center"
  78. header-align="center" width="120">
  79. <template slot-scope="scope">
  80. <span :style="{ color: scope.row.statusColor }">{{ scope.row.status }}</span>
  81. </template>
  82. </el-table-column>
  83. <el-table-column column-key="sourceType" prop="sourceType" :label="$t('scene')" align="center"
  84. header-align="center" width="180"></el-table-column>
  85. <el-table-column column-key="duration" prop="duration" :label="$t('runTime')" align="center"
  86. header-align="center" width="120"></el-table-column>
  87. <el-table-column column-key="remark" prop="remark" :label="$t('explanation')" align="left" min-width="200"
  88. header-align="center">
  89. <template slot-scope="scope">
  90. <span v-html="scope.row.remark"></span>
  91. </template>
  92. </el-table-column>
  93. <el-table-column column-key="taskName" prop="taskName" :label="$t('taskName')" align="center"
  94. header-align="center" width="180">
  95. <template slot-scope="scope">
  96. <span v-html="scope.row.taskName"></span>
  97. </template>
  98. </el-table-column>
  99. <el-table-column column-key="amount" prop="amount" :label="$t('points')" align="center"
  100. header-align="center" width="120"></el-table-column>
  101. <template slot="empty">
  102. <span>{{ loading ? $t('loading') : $t('noData') }}</span>
  103. </template>
  104. </el-table>
  105. </div>
  106. <div class="__r_p_pagination">
  107. <div style="margin-top: 2rem">
  108. <div class="center">
  109. <el-pagination background @current-change="currentChange" :current-page="pageInfo.curpage"
  110. :page-sizes="pageInfo.pageSizes" :page-size="pageInfo.pageSize"
  111. layout="total, sizes, prev, pager, next, jumper" :total="pageInfo.total">
  112. </el-pagination>
  113. </div>
  114. </div>
  115. </div>
  116. </div>
  117. </div>
  118. </div>
  119. </template>
  120. <script>
  121. import { getPoint, getPointAccount, getPointList } from "~/apis/modules/point";
  122. import { getRewardPointRecordInfo } from './utils';
  123. export default {
  124. data() {
  125. return {
  126. loading: false,
  127. summaryInfo: {
  128. available: 0,
  129. gain: 0,
  130. used: 0,
  131. },
  132. tabIndex: 0,
  133. tableData: [],
  134. pageInfo: {
  135. curpage: 1,
  136. pageSize: 10,
  137. pageSizes: [10],
  138. total: 100,
  139. },
  140. eventSource: null,
  141. };
  142. },
  143. components: {},
  144. methods: {
  145. currentChange: function (val) {
  146. this.pageInfo.curpage = val;
  147. this.getTableData();
  148. },
  149. tabChange: function (index) {
  150. if (this.tabIndex === index) return;
  151. this.tabIndex = index;
  152. this.pageInfo.curpage = 1;
  153. this.pageInfo.total = 0;
  154. this.getTableData();
  155. },
  156. getSummaryInfo: function () {
  157. getPointAccount().then(res => {
  158. if (res.data && res.data.Code === 0) {
  159. const data = res.data.Data;
  160. this.summaryInfo.available = data.Balance;
  161. this.summaryInfo.gain = data.TotalEarned;
  162. this.summaryInfo.used = data.TotalConsumed;
  163. }
  164. }).catch(err => {
  165. console.log(err);
  166. })
  167. },
  168. getTableData: function () {
  169. this.loading = true;
  170. getPointList({
  171. operate: this.tabIndex === 0 ? 'INCREASE' : 'DECREASE',
  172. page: this.pageInfo.curpage,
  173. // pageSize: this.pageInfo.pageSize,
  174. })
  175. .then((res) => {
  176. this.loading = false;
  177. const tableData = [];
  178. if (res.data && res.data.Code === 0) {
  179. const data = res.data.Data;
  180. const records = data.Records;
  181. for (let i = 0, iLen = records.length; i < iLen; i++) {
  182. const record = records[i];
  183. tableData.push(getRewardPointRecordInfo(record));
  184. }
  185. this.tableData.splice(0, Infinity, ...tableData);
  186. this.pageInfo.total = data.Total;
  187. }
  188. })
  189. .catch((err) => {
  190. console.log(err);
  191. this.loading = false;
  192. this.tableData.splice(0, Infinity);
  193. });
  194. },
  195. },
  196. mounted: function () {
  197. this.getSummaryInfo();
  198. this.getTableData();
  199. const { AppSubUrl, csrf, NotificationSettings } = window.config;
  200. if (NotificationSettings.EventSourceUpdateTime > 0 && !!window.EventSource) {
  201. const source = new EventSource(`${AppSubUrl}/user/events`);
  202. source.addEventListener('reward-operation', (e) => {
  203. try {
  204. this.getSummaryInfo();
  205. this.getTableData();
  206. } catch (err) {
  207. console.error(err);
  208. }
  209. });
  210. this.eventSource = source;
  211. }
  212. },
  213. beforeDestroy: function () {
  214. this.eventSource && this.eventSource.close();
  215. },
  216. };
  217. </script>
  218. <style scoped lang="less">
  219. .__flex-1 {
  220. flex: 1;
  221. }
  222. .__reward-pointer-c {
  223. .__r_p_header {
  224. height: 30px;
  225. margin: 10px 0;
  226. display: flex;
  227. align-items: center;
  228. justify-content: space-between;
  229. .__title {
  230. font-weight: 400;
  231. font-size: 18px;
  232. color: rgb(16, 16, 16);
  233. line-height: 26px;
  234. }
  235. }
  236. .__r_p_summary {
  237. display: flex;
  238. align-items: center;
  239. height: 100px;
  240. background-color: rgb(245, 245, 246);
  241. .__r_p_summary_item-c {
  242. .__val {
  243. text-align: center;
  244. margin: 12px 0;
  245. font-weight: 400;
  246. font-size: 28px;
  247. color: rgb(16, 16, 16);
  248. }
  249. .__exp {
  250. text-align: center;
  251. font-weight: 400;
  252. font-size: 14px;
  253. color: rgba(54, 56, 64, 1);
  254. }
  255. }
  256. }
  257. }
  258. .__r_p_summary_line {
  259. width: 1px;
  260. height: 80%;
  261. background-color: rgb(212, 212, 213);
  262. }
  263. .__r_p_tab {
  264. display: flex;
  265. margin: 18px 0;
  266. .__r_p_tab-item {
  267. width: 115px;
  268. height: 38px;
  269. display: flex;
  270. justify-content: center;
  271. align-items: center;
  272. border: 1px solid rgb(225, 227, 230);
  273. color: #101010;
  274. box-sizing: border-box;
  275. cursor: pointer;
  276. &.__focus {
  277. border-color: rgb(50, 145, 248);
  278. color: rgb(50, 145, 248);
  279. cursor: default;
  280. }
  281. }
  282. }
  283. .__r_p_table {
  284. /deep/ .el-table__header {
  285. th {
  286. background: rgb(245, 245, 246);
  287. color: rgb(96, 98, 102);
  288. font-weight: 400;
  289. font-size: 14px;
  290. }
  291. }
  292. }
  293. </style>