transferList.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. <template>
  2. <div class="order-wrapper">
  3. <!-- <breadcrumb :item-name="['订单管理', '订单列表']"></breadcrumb> -->
  4. <el-card>
  5. <!-- 搜索区域 -->
  6. <el-col>
  7. <div class="flex" style="justify-content: space-between;padding-bottom: 20px;">
  8. <el-button type="primary" @click="openBuy">转账</el-button>
  9. <el-button type="primary" icon="el-icon-refresh-right" @click="reload">刷新</el-button>
  10. </div>
  11. </el-col>
  12. <!-- 订单表格区域 -->
  13. <el-table :data="list" border style="width: 100%" max-height="620">
  14. <el-table-column prop="id" label="id" width="180">
  15. </el-table-column>
  16. <el-table-column prop="transfer_num" label="转账金额(元)" width="250"></el-table-column>
  17. <el-table-column prop="to_user_code" label="收款人" width="150">
  18. </el-table-column>
  19. <el-table-column prop="user_id" label="转入/转出">
  20. <template slot-scope="scope">
  21. <el-tag v-if="scope.row.user_id == userInfo.id">转出</el-tag>
  22. <el-tag type="success" v-else>转入</el-tag>
  23. </template>
  24. </el-table-column>
  25. <el-table-column prop="status" label="创建时间">
  26. <template slot-scope="scope">
  27. {{showTime(scope.row.createtime)}}
  28. </template>
  29. </el-table-column>
  30. <el-table-column prop="balance" label="转账后用户余额">
  31. <template slot-scope="scope">
  32. {{userInfo.id == scope.row.user_id ? scope.row.balance: ''}}
  33. </template>
  34. </el-table-column>
  35. </el-table>
  36. <div style="height: 20px;"></div>
  37. <!-- 分页区域 -->
  38. <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
  39. :current-page="queryInfo.page" :page-sizes="[10, 20, 50, 100]" :page-size="queryInfo.pagesize"
  40. layout="total, prev, pager, next, jumper" :total="total">
  41. </el-pagination>
  42. </el-card>
  43. <!-- 修改地址对话框 -->
  44. <el-dialog title="转账" :visible.sync="dialogTableVisible">
  45. <el-form :model="form">
  46. <el-form-item label="收款用户ID" :label-width="formLabelWidth">
  47. <el-input v-model="form.to_user_id" type="number"></el-input>
  48. </el-form-item>
  49. <el-form-item label="转账金额" :label-width="formLabelWidth">
  50. <el-input v-model="form.transfer_num" type="number"></el-input>
  51. </el-form-item>
  52. <el-form-item label="动态口令" :label-width="formLabelWidth" v-if="userInfo.is_binding == 1">
  53. <el-input v-model="form.code" type="number"></el-input>
  54. </el-form-item>
  55. </el-form>
  56. <div class="t-r">
  57. 当前余额: {{userInfo.money*1}}元
  58. </div>
  59. <div slot="footer" class="dialog-footer">
  60. <el-button @click="dialogTableVisible = false">取 消</el-button>
  61. <el-button type="primary" @click="goBuy">确 定</el-button>
  62. </div>
  63. </el-dialog>
  64. </div>
  65. </template>
  66. <script>
  67. import {
  68. mapState,
  69. mapMutations
  70. } from 'vuex';
  71. import {
  72. createCode,
  73. getCodeList,
  74. getUserList
  75. } from '@/request/agent.js'
  76. import {
  77. getRechangeList,
  78. rechange,
  79. getTransferList,
  80. transfer,
  81. getUserInfo
  82. } from '@/request/user.js'
  83. import {
  84. showTime
  85. } from '@/assets/js/tools.js'
  86. export default {
  87. name: 'Order',
  88. data() {
  89. return {
  90. loading: false,
  91. formLabelWidth: '100px',
  92. form: {
  93. to_user_id: '',
  94. transfer_num: '',
  95. code: ''
  96. },
  97. dialogTableVisible: false,
  98. queryInfo: {
  99. type: -1, //-1->全部 0->银行卡 1->微信 2->支付宝
  100. page: 1,
  101. limit: 10
  102. },
  103. list: [],
  104. total: 0,
  105. dataloading: false,
  106. headers: {},
  107. }
  108. },
  109. computed: {
  110. ...mapState(['userInfo'])
  111. },
  112. created() {
  113. this.getList()
  114. this.headers['token'] = window.sessionStorage.getItem('token')
  115. },
  116. methods: {
  117. ...mapMutations(['setUserInfo']),
  118. showTime,
  119. reload() {
  120. this.getList('reload')
  121. this.getUserInfo()
  122. },
  123. getUserInfo() {
  124. getUserInfo().then(res => {
  125. this.setUserInfo(res.data)
  126. })
  127. },
  128. handleAvatarSuccess(res, file) {
  129. this.form.image = res.data.fullurl;
  130. console.log(this.form.image, 'this.form.avatar');
  131. },
  132. beforeAvatarUpload(file) {
  133. // const isJPG = file.type === 'image/jpeg/png';
  134. // const isLt2M = file.size / 1024 / 1024 < 2;
  135. // if (!isJPG) {
  136. // this.$message.error('上传头像图片只能是 JPG 格式!');
  137. // }
  138. // if (!isLt2M) {
  139. // this.$message.error('上传头像图片大小不能超过 2MB!');
  140. // }
  141. // return isJPG && isLt2M;
  142. return true
  143. },
  144. handleAvatarError() {
  145. },
  146. openBuy() {
  147. this.dialogTableVisible = true
  148. },
  149. goBuy() {
  150. let that = this
  151. if (that.loading) {
  152. return
  153. }
  154. if (!that.form.to_user_id) {
  155. return that.$msg.error('请输入收款人ID')
  156. }
  157. if (!that.form.transfer_num) {
  158. return that.$msg.error('请输入转账金额')
  159. }
  160. if(that.userInfo.money < that.form.transfer_num*1) {
  161. return that.$msg.error('您的余额不足本次转账')
  162. }
  163. that.loading = true
  164. transfer(that.form).then(res => {
  165. console.log(res);
  166. that.$msg.success('转账成功')
  167. that.dialogTableVisible = false
  168. that.loading = false
  169. that.getList('reload')
  170. that.getUserInfo()
  171. }).catch(err => {
  172. that.loading = false
  173. })
  174. },
  175. getList(type) {
  176. let that = this
  177. if (type == 'reload') {
  178. that.dataloading = false
  179. that.queryInfo.page = 1
  180. that.dataloading = false
  181. }
  182. if (that.dataloading) {
  183. return
  184. }
  185. that.dataloading = true
  186. getTransferList(that.queryInfo).then(res => {
  187. that.total = res.data.count
  188. that.list = res.data.data
  189. that.dataloading = false
  190. }).catch(err => {
  191. that.dataloading = false
  192. })
  193. },
  194. handleSizeChange(newPageSize) {
  195. this.queryInfo.limit = newPageSize
  196. this.getList()
  197. },
  198. handleCurrentChange(newPageNum) {
  199. this.queryInfo.page = newPageNum
  200. this.getList()
  201. },
  202. },
  203. }
  204. </script>
  205. <style scoped lang="scss">
  206. .avatar-uploader .el-upload {
  207. border: 1px dashed #d9d9d9;
  208. border-radius: 6px;
  209. cursor: pointer;
  210. position: relative;
  211. overflow: hidden;
  212. }
  213. .avatar-uploader .el-upload:hover {
  214. border-color: #409EFF;
  215. }
  216. .avatar-uploader-icon {
  217. font-size: 28px;
  218. color: #8c939d;
  219. width: 178px;
  220. height: 178px;
  221. line-height: 178px;
  222. text-align: center;
  223. border: 1px dashed #d9d9d9;
  224. border-radius: 10px;
  225. }
  226. .t-r {
  227. text-align: right;
  228. padding-top: 10px;
  229. }
  230. </style>