statistics.vue 9.3 KB

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