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

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