transferList.vue 5.9 KB

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