statistics.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422
  1. <template>
  2. <div class="order-wrapper">
  3. <!-- <breadcrumb :item-name="['订单管理', '订单列表']"></breadcrumb> -->
  4. <el-card>
  5. <div class="tj flex">
  6. <div class="tj-item">
  7. <div class="tit">代理订单</div>
  8. <div class="val">{{tj.agent_order||0}}</div>
  9. </div>
  10. <div class="tj-item">
  11. <div class="tit">异常代理订单</div>
  12. <div class="val">{{tj.agent_order_error|| 0}}</div>
  13. </div>
  14. <div class="tj-item">
  15. <div class="tit">未使用注册码</div>
  16. <div class="val">{{tj.code_0|| 0}}</div>
  17. </div>
  18. <div class="tj-item">
  19. <div class="tit">已使用注册码</div>
  20. <div class="val">{{tj.code_1||0}}</div>
  21. </div>
  22. </div>
  23. </el-card>
  24. </div>
  25. </template>
  26. <script>
  27. import {
  28. mapState,
  29. mapMutations
  30. } from 'vuex';
  31. import {
  32. createCode,
  33. getUserList,
  34. getIndex,
  35. dataCount
  36. } from '@/request/agent.js'
  37. import {
  38. getRechangeList,
  39. rechange,
  40. getTokenList,
  41. createOrder,
  42. getUserInfo,
  43. payAuto,
  44. } from '@/request/user.js'
  45. import {
  46. showTime,
  47. sj
  48. } from '@/assets/js/tools.js'
  49. import {
  50. imgs
  51. } from '@/assets/js/admun.js'
  52. import {
  53. set
  54. } from 'core-js/library/core/dict';
  55. export default {
  56. components: {
  57. // SlideVerify
  58. },
  59. name: 'Order',
  60. data() {
  61. return {
  62. showStop: false,
  63. dialogVisible: false,
  64. xdForm: {
  65. phone: '',
  66. address: '',
  67. minPrice: '',
  68. maxPrice: ''
  69. },
  70. imgs: imgs,
  71. msg: '888',
  72. loading: false,
  73. formLabelWidth: '100px',
  74. form: {
  75. recharge_num: '',
  76. image: ''
  77. },
  78. dialogTableVisible: false,
  79. xiadanDia: false, //下单弹窗
  80. queryInfo: {
  81. keyword: '',
  82. page: 1,
  83. limit: 10
  84. },
  85. list: [],
  86. total: 0,
  87. dataloading: false,
  88. headers: {},
  89. tokenList: [],
  90. token: {},
  91. ybToken: {},
  92. minPriceList: [],
  93. maxPriceList: [],
  94. tipList: [],
  95. auto_order: false, //是否启动自动下单
  96. tj: {}
  97. }
  98. },
  99. computed: {
  100. ...mapState(['baseInfo', 'userInfo'])
  101. },
  102. created() {
  103. // this.getUserInfo()
  104. // this.getIndex()
  105. // this.getList()
  106. // this.getTokenList()
  107. this.dataCount()
  108. this.headers['token'] = window.sessionStorage.getItem('token')
  109. // console.log(this.imgs, 'imgs');
  110. },
  111. methods: {
  112. ...mapMutations(['setBaseInfo', 'setUserInfo', 'jUserMoney']),
  113. dataCount() {
  114. dataCount().then(res => {
  115. console.log(res);
  116. this.tj = res.data
  117. })
  118. },
  119. stopAuto() {
  120. this.auto_order = false
  121. this.showStop = false
  122. },
  123. getUserInfo() {
  124. getUserInfo().then(res => {
  125. this.setUserInfo(res.data)
  126. })
  127. },
  128. pd(arr, i = 0) {
  129. let that = this
  130. let len = arr.length - 1
  131. if (i <= len) {
  132. if (i == 0) {
  133. that.tipList.unshift(arr[i])
  134. that.pd(arr, ++i)
  135. } else {
  136. setTimeout(() => {
  137. that.tipList.unshift(arr[i])
  138. if (arr[i].title.indexOf('支付金额:') != -1) {
  139. // let price = zfInfo.title.replace(/支付金额:/,'')*1
  140. that.jUserMoney(-1 * arr[i].title.replace(/支付金额:/, ''))
  141. }
  142. that.pd(arr, ++i)
  143. }, arr[i - 1].time * 1000)
  144. }
  145. } else {
  146. that.xdForm.phone = ''
  147. that.xdForm.address = ''
  148. that.loading = false
  149. if (that.auto_order) {
  150. that.chooseNext()
  151. } else {
  152. that.xdForm.minPrice = ''
  153. that.xdForm.maxPrice = ''
  154. }
  155. }
  156. },
  157. ktAuto() {
  158. let that = this
  159. if (that.userInfo.money * 1 < that.baseInfo.auto_order * 1) {
  160. return that.$msg.error('您当前余额不足')
  161. }
  162. payAuto().then(res => {
  163. that.getUserInfo()
  164. that.dialogVisible = false
  165. that.auto_order = true
  166. that.chooseNext()
  167. //自动下单启动
  168. })
  169. },
  170. openZd() {
  171. let that = this
  172. if (that.loading) {
  173. return that.$msg.error('当前处于下单状态,请等待下单完成')
  174. }
  175. if (that.userInfo.auto_order == 0) {
  176. that.dialogVisible = true
  177. } else {
  178. //自动下单启动
  179. if (that.xdForm.minPrice == '') {
  180. return that.$msg.error('请选择最低价格')
  181. }
  182. if (that.xdForm.maxPrice == '') {
  183. return that.$msg.error('请选择最高价格')
  184. }
  185. that.auto_order = true
  186. that.chooseNext()
  187. }
  188. },
  189. //选择下一个可用token
  190. chooseNext() {
  191. let that = this
  192. that.token = that.tokenList.find(item => item.bl == false)
  193. if (that.auto_order) {
  194. if (that.token) {
  195. if (that.xdForm.minPrice == '') {
  196. return that.$msg.error('请选择最低价格')
  197. }
  198. if (that.xdForm.maxPrice == '') {
  199. return that.$msg.error('请选择最高价格')
  200. }
  201. that.sjAddress()
  202. that.sjPhone()
  203. // that.$msg.success('开启自动下单,请勿进行操作')
  204. // 启动
  205. that.createOrder()
  206. } else {
  207. //停止
  208. that.auto_order = false
  209. }
  210. }
  211. },
  212. createOrder() {
  213. let that = this
  214. if (that.loading) {
  215. return
  216. }
  217. if (that.token.bl) {
  218. if (that.auto_order) {
  219. } else {
  220. return this.$msg.error('该TOKEN,当天使用次数已满!')
  221. }
  222. }
  223. if (that.xdForm.minPrice == '') {
  224. return that.$msg.error('请选择最低价格')
  225. }
  226. if (that.xdForm.maxPrice == '') {
  227. return that.$msg.error('请选择最高价格')
  228. }
  229. if (that.xdForm.minPrice * 1 > that.xdForm.maxPrice * 1) {
  230. return that.$msg.error('最高价格需大于最低价格')
  231. }
  232. if (that.xdForm.phone == '') {
  233. return that.$msg.error('请输入手机号码')
  234. }
  235. if (!/(^1[2|3|4|5|6|7|8|9][0-9]{9}$)/.test(that.xdForm.phone)) {
  236. return that.$msg.error('请输入正确的手机号码')
  237. }
  238. if (that.xdForm.address == '') {
  239. return that.$msg.error('请输入收货地址')
  240. }
  241. that.loading = true
  242. createOrder({
  243. min_price: that.xdForm.minPrice,
  244. max_price: that.xdForm.maxPrice,
  245. address: that.xdForm.address,
  246. phone: that.xdForm.phone,
  247. token: that.token.token
  248. }).then(res => {
  249. //更新token
  250. that.token.count++
  251. if (that.token.count == 2) {
  252. that.token.bl = true
  253. }
  254. // 加载tip
  255. that.pd(res.data, 0)
  256. }).catch(err => {
  257. console.log(err);
  258. that.loading = false
  259. })
  260. },
  261. getIndex() {
  262. getIndex().then(res => {
  263. this.setBaseInfo(res.data)
  264. let arr = [],
  265. arr2 = []
  266. res.data.price_min.forEach(item => {
  267. let a = {
  268. value: item * 1,
  269. label: item
  270. }
  271. arr.push(a)
  272. })
  273. res.data.price_max.forEach(item => {
  274. let a = {
  275. value: item * 1,
  276. label: item
  277. }
  278. arr2.push(a)
  279. })
  280. this.minPriceList = arr
  281. this.maxPriceList = arr2
  282. })
  283. },
  284. showTime,
  285. sjPhone() {
  286. if (this.loading) {
  287. return
  288. }
  289. this.xdForm.phone = sj(this.baseInfo.sys_phone)
  290. },
  291. sjAddress() {
  292. if (this.loading) {
  293. return
  294. }
  295. this.xdForm.address = sj(this.baseInfo.system_address)
  296. },
  297. closeXd() {
  298. this.xiadanDia = false
  299. this.xdForm.phone = ''
  300. this.xdForm.address = ''
  301. },
  302. onSuccess() {
  303. console.log('success');
  304. this.token = this.ybToken
  305. this.xdForm.minPrice = ''
  306. this.xdForm.maxPrice = ''
  307. this.dialogTableVisible = false
  308. },
  309. onFail() {
  310. console.log('fail');
  311. },
  312. onRefresh() {
  313. console.log('refresh');
  314. },
  315. getTokenList() {
  316. getTokenList().then(res => {
  317. this.tokenList = res.data.map(item => {
  318. item.count = item.count * 1
  319. return item
  320. })
  321. // 获取第一次选择的token
  322. this.chooseNext()
  323. console.log(this.token, 'this.token');
  324. })
  325. },
  326. chooseToken(item) {
  327. // console.log(item,'ddddd');
  328. if (this.loading) {
  329. return
  330. }
  331. if (item.bl) {
  332. return this.$msg.error('该TOKEN,当天使用次数已满!')
  333. }
  334. this.ybToken = item
  335. this.dialogTableVisible = true
  336. },
  337. handleAvatarSuccess(res, file) {
  338. this.form.image = res.data.fullurl;
  339. },
  340. beforeAvatarUpload(file) {
  341. // const isJPG = file.type === 'image/jpeg/png';
  342. // const isLt2M = file.size / 1024 / 1024 < 2;
  343. // if (!isJPG) {
  344. // this.$message.error('上传头像图片只能是 JPG 格式!');
  345. // }
  346. // if (!isLt2M) {
  347. // this.$message.error('上传头像图片大小不能超过 2MB!');
  348. // }
  349. // return isJPG && isLt2M;
  350. return true
  351. },
  352. handleAvatarError() {
  353. },
  354. getList(type) {
  355. let that = this
  356. if (type == 'reload') {
  357. that.queryInfo.page = 1
  358. that.dataloading = false
  359. }
  360. if (that.dataloading) {
  361. return
  362. }
  363. that.dataloading = true
  364. getRechangeList(that.queryInfo).then(res => {
  365. that.total = res.data.count
  366. that.list = res.data.data
  367. that.dataloading = false
  368. }).catch(err => {
  369. that.dataloading = false
  370. })
  371. },
  372. handleSizeChange(newPageSize) {
  373. this.queryInfo.limit = newPageSize
  374. this.getList()
  375. },
  376. handleCurrentChange(newPageNum) {
  377. this.queryInfo.page = newPageNum
  378. this.getList()
  379. },
  380. },
  381. }
  382. </script>
  383. <style lang="scss" scoped>
  384. .tj {
  385. width: 500px;
  386. flex-wrap: wrap;
  387. .tj-item {
  388. width: 120px;
  389. height: 120px;
  390. border-radius: 20px;
  391. box-shadow: 0px 0px 7px rgba(0, 0, 0, 0.4);
  392. display: flex;
  393. flex-direction: column;
  394. justify-content: center;
  395. align-items: center;
  396. margin: 20px;
  397. .val {
  398. margin-top: 20px;
  399. color: rgb(15, 131, 254);
  400. }
  401. }
  402. }
  403. </style>