rechargeOrder.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395
  1. <template>
  2. <div>
  3. <div v-if="total">
  4. <div class="order-item" v-for="(item,i) in data" :key="item.orderSn">
  5. <InterestsItem :item="item" :i="i" />
  6. </div>
  7. </div>
  8. <div class="scene-nothing" v-else>
  9. <img :src="`${$cdn}images/nothing.png`" alt>
  10. <div>{{$t('manage.myOrders.norecord')}}
  11. <!-- <a class="gotoBuy" >{{$t('manage.gotoBuy')}}</a> -->
  12. </div>
  13. </div>
  14. <div class="paging" v-if="total">
  15. <Paging @clickHandle="pageChange" @maxPage="data=>maxPage=data" :current="currentPage" :total="total" :equable="pageSize"/>
  16. </div>
  17. </div>
  18. </template>
  19. <script>
  20. import InterestsItem from './rechargeItem'
  21. import { mapState } from 'vuex'
  22. import tableList from '@/components/table'
  23. import {capacity, recharge, invoice} from './iconsumption'
  24. import Paging from '@/components/Paging'
  25. import vcenter from '@/components/vcenter'
  26. import MemberApi from '@/apis/member'
  27. import MallConfig from '@/config/mall'
  28. import { i18n } from '@/lang'
  29. let AMOUNTSTR = {
  30. 0: '¥',
  31. 1: '¥',
  32. 2: '$'
  33. }
  34. let methodStr = {
  35. 0: 'getMemberOrderList',
  36. 1: 'getChargeList',
  37. 2: 'getInvoiceList'
  38. }
  39. let rechargeType = {
  40. 0: i18n.t('manage.Spending.rechargeValue.0'),
  41. '-1': i18n.t('manage.Spending.rechargeValue.-1'),
  42. 1: i18n.t('manage.Spending.rechargeValue.1'),
  43. 2: i18n.t('manage.Spending.rechargeValue.2')
  44. }
  45. let invoceStatusType = {
  46. 0: '未开票',
  47. 1: '已开票'
  48. }
  49. let invoiceType = {
  50. 1: '不需要发票',
  51. 2: '增值税普通发票',
  52. 3: '增值税专用发票'
  53. }
  54. export default {
  55. components: {
  56. tableList,
  57. Paging,
  58. vcenter,
  59. InterestsItem
  60. },
  61. data () {
  62. let cameraList = [
  63. {
  64. name: '全部',
  65. id: ''
  66. },
  67. {
  68. name: '二目充值',
  69. id: 0
  70. },
  71. {
  72. name: '会员权益',
  73. id: 4
  74. }
  75. ]
  76. return {
  77. PAYSIDMAP: MallConfig.PAYSIDMAP,
  78. tabHeader: capacity,
  79. data: [],
  80. cameraList,
  81. active: 1,
  82. recharge,
  83. total: 30,
  84. pageSize: 5,
  85. currentPage: 1,
  86. tabActive: false,
  87. deviceActive: false,
  88. max: 0,
  89. activeDevice: '',
  90. activeType: '全部',
  91. activeId: '',
  92. activeTypeId: '',
  93. tabList: [
  94. {
  95. name: this.$t('manage.Spending.tabListMember')
  96. },
  97. {
  98. name: this.$t('manage.Spending.tabListRecharge')
  99. },
  100. {
  101. name: this.$t('manage.Spending.tabListInvoice')
  102. },
  103. ]
  104. }
  105. },
  106. computed: {
  107. ...mapState({
  108. token: state => state.user.token,
  109. language: state => state.language.current,
  110. deviceLogin: state => state.user.deviceLogin,
  111. // myexpansion: state => {
  112. // let type = Object.prototype.toString.call(state.user.myexpansion)
  113. // if (type === '[object Object]') {
  114. // return state.user.myexpansion
  115. // }
  116. // let condition = state.user.myexpansion && state.user.myexpansion !== 'null' && type !== '[object Array]'
  117. // return (condition ? JSON.parse(state.user.myexpansion) : {})
  118. // },
  119. mycharge: state => {
  120. let type = Object.prototype.toString.call(state.user.mycharge)
  121. if (type === '[object Object]') {
  122. return state.user.mycharge
  123. }
  124. let condition = state.user.mycharge && state.user.mycharge !== 'null' && type !== '[object Array]'
  125. return (condition ? JSON.parse(state.user.mycharge) : {})
  126. },
  127. myinvoicelist: state => {
  128. let type = Object.prototype.toString.call(state.user.myinvoicelist)
  129. if (type === '[object Object]') {
  130. return state.user.myinvoicelist
  131. }
  132. let condition = state.user.myinvoicelist && state.user.myinvoicelist !== 'null' && type !== '[object Array]'
  133. return (condition ? JSON.parse(state.user.myinvoicelist) : {})
  134. },
  135. invoicedevice: state => {
  136. let type = Object.prototype.toString.call(state.user.invoicedevice)
  137. if (type === '[object Object]') {
  138. return state.user.invoicedevice
  139. }
  140. let condition = state.user.invoicedevice && state.user.invoicedevice !== 'null'
  141. return (condition ? state.user.invoicedevice : [])
  142. },
  143. searchKey () {
  144. return this.$parent.searchKey
  145. }
  146. })
  147. },
  148. watch: {
  149. currentPage (newVal) {
  150. this.getList()
  151. },
  152. language (newVal) {
  153. this.active = 0
  154. this.data.forEach(item => {
  155. let condition = item['validDate'] === '终身有效' ? (newVal === 'en' ? 'N/A' : '终身有效') : item['validDate']
  156. item['validDateStr'] = condition
  157. item['unitSize1'] = item['unitSize'] + item['unit'] + '/' + this.$t(`manage.shixian.${item['month']}`)
  158. item['channel'] = this.$t(`manage.channelType.${item['status']}`)
  159. item['amount1'] = AMOUNTSTR[item['payType']] + item['amount']
  160. item['payTypeStr'] = this.$t(`manage.PAYSSTR.${item['payType']}`)
  161. })
  162. },
  163. activeId (newVal) {
  164. if (this.active === 2) {
  165. this.getList()
  166. }
  167. this.getInvoiceMax()
  168. },
  169. activeTypeId (newVal) {
  170. if (this.active === 2) {
  171. this.getList()
  172. }
  173. },
  174. active (newVal) {
  175. switch (newVal) {
  176. case 1:
  177. this.tabHeader = recharge
  178. break
  179. case 2:
  180. !this.deviceLogin && this.getAllDevice()
  181. this.tabHeader = invoice
  182. break
  183. default:
  184. this.tabHeader = capacity
  185. break
  186. }
  187. if (newVal !== 1) {
  188. this.$emit('changeSearchShow', false)
  189. } else {
  190. this.$emit('changeSearchShow', true)
  191. }
  192. this.currentPage === 1 ? this.getList() : this.currentPage = 1
  193. }
  194. },
  195. methods: {
  196. pageChange (data) {
  197. this.currentPage = data
  198. },
  199. selectInId (item) {
  200. this.activeDevice = item.childName
  201. this.activeId = item.id
  202. },
  203. selectCamTy (item) {
  204. this.activeType = item.name
  205. this.activeTypeId = item.id
  206. },
  207. showDetail (item) {
  208. this.$toast.showInvoiceDetail(item)
  209. },
  210. getList (searchKey = '') {
  211. window.scrollTo(0, 0)
  212. let str = methodStr[this.active]
  213. this[str](searchKey)
  214. },
  215. openInvice () {
  216. let params = {
  217. max: this.max,
  218. cameraId: this.activeId
  219. };
  220. (this.max && !this.deviceLogin) && this.$toast.showInvoice(params)
  221. },
  222. async getAllDevice (searchKey = '') {
  223. let params = {
  224. cameraType: ''
  225. }
  226. await this.$store.dispatch('getInvoiceDevice', params)
  227. this.activeDevice = this.invoicedevice[0].childName
  228. this.activeId = this.invoicedevice[0].id
  229. },
  230. // 扩容记录
  231. async getConsumpList (searchKey = '') {
  232. if (this.deviceLogin) {
  233. searchKey = this.deviceLogin
  234. }
  235. let data = {
  236. params: {
  237. childName: searchKey.trim(),
  238. pageNum: searchKey ? 1 : this.currentPage,
  239. pageSize: this.pageSize
  240. },
  241. url: this.deviceLogin ? '/device/virtualOrder/expansionList' : '/user/virtualOrder/expansionList'
  242. }
  243. await this.$store.dispatch('getUserExpansion', data)
  244. if (!this.myexpansion.total && searchKey && !this.deviceLogin) {
  245. return this.$toast.show('warn', this.$t('toast.25'), () => {
  246. this.getList()
  247. })
  248. }
  249. console.log(this.myexpansion, 'this.myexpansion')
  250. this.pageSize = this.myexpansion.pageSize
  251. this.total = this.myexpansion.total || 0
  252. this.data = this.myexpansion.list
  253. this.data.forEach(item => {
  254. let condition = item['validDate'] === '终身有效' ? (this.language === 'en' ? 'N/A' : '终身有效') : item['validDate']
  255. item['validDateStr'] = condition
  256. item['statusStr'] = this.$t(`manage.myOrders.${item['status']}`)
  257. item['unitSize1'] = item['unitSize'] + item['unit'] + '/' + this.$t(`manage.shixian.${item['month']}`)
  258. item['channel'] = this.$t(`manage.channelType.${item['status']}`)
  259. item['amount1'] = AMOUNTSTR[item['payType']] + item['amount']
  260. item['payTypeStr'] = this.$t(`manage.PAYSSTR.${item['payType']}`)
  261. })
  262. },
  263. getMemberOrderList () {
  264. let data = {
  265. snCode: this.searchKey,
  266. pageNum: this.currentPage,
  267. pageSize: this.pageSize
  268. }
  269. MemberApi.getVirtualOrderList(data).then(res => {
  270. this.data = res.data.data.list
  271. console.log(this.data)
  272. this.total = res.data.data.total
  273. })
  274. },
  275. async getInvoiceMax () {
  276. let res = await this.$http({
  277. method: 'post',
  278. data: {
  279. cameraId: this.activeId
  280. },
  281. headers: {
  282. token: this.token
  283. },
  284. url: '/user/invoice/max'
  285. })
  286. let data = res.data
  287. if (data.code !== 0) return
  288. this.max = data.data.maxInvoice
  289. },
  290. // 充值记录
  291. async getChargeList (searchKey = '') {
  292. if (this.deviceLogin) {
  293. searchKey = this.deviceLogin
  294. }
  295. let data = {
  296. params: {
  297. childName: searchKey,
  298. pageNum: searchKey ? 1 : this.currentPage,
  299. pageSize: this.pageSize
  300. },
  301. url: this.deviceLogin ? '/device/virtualOrder/chargeList' : '/user/virtualOrder/chargeList'
  302. }
  303. await this.$store.dispatch('getChargeList', data)
  304. if (!this.mycharge.total && searchKey && !this.deviceLogin) {
  305. return this.$toast.show('warn', this.$t('toast.25'), () => {
  306. this.getList()
  307. })
  308. }
  309. this.pageSize = this.mycharge.pageSize
  310. this.total = this.mycharge.total || 0
  311. this.data = this.mycharge.list
  312. this.data.forEach(item => {
  313. item['status'] = rechargeType[item['status']]
  314. })
  315. console.log(this.data)
  316. },
  317. // 发票记录
  318. async getInvoiceList () {
  319. let data = {
  320. params: {
  321. cameraId: this.activeId,
  322. pageNum: this.currentPage,
  323. pageSize: this.pageSize,
  324. type: this.activeTypeId
  325. },
  326. url: this.deviceLogin ? '/device/invoice/list' : '/user/invoice/list'
  327. }
  328. await this.$store.dispatch('getInvoiceList', data)
  329. this.pageSize = this.myinvoicelist.pageSize
  330. this.total = this.myinvoicelist.total || 0
  331. this.data = this.myinvoicelist.list
  332. this.data.forEach(item => {
  333. item['detail'] = '详细'
  334. item['money'] = '¥' + item['money']
  335. item['finish'] = invoceStatusType[item['finish']]
  336. item['type'] = invoiceType[item['type']]
  337. })
  338. },
  339. handleSearch (keyword) {
  340. this.getList(keyword)
  341. }
  342. },
  343. mounted () {
  344. this.getList()
  345. this.$bus.$off('refreshInvoice')
  346. this.$bus.$on('refreshInvoice', () => {
  347. if (this.active === 2) {
  348. this.getList()
  349. }
  350. this.getInvoiceMax()
  351. })
  352. document.addEventListener('click', (e) => {
  353. if (this.$refs.invoiceMenu) {
  354. if (!this.$refs.invoiceMenu.contains(e.target)) {
  355. this.tabActive = false
  356. }
  357. }
  358. if (this.$refs.deviceMenu) {
  359. if (!this.$refs.deviceMenu.contains(e.target)) {
  360. this.deviceActive = false
  361. }
  362. }
  363. })
  364. }
  365. }
  366. </script>
  367. <style lang="less" scoped>
  368. .scene-nothing {
  369. text-align: center;
  370. padding: 42px 0 210px 0;
  371. img {
  372. padding-bottom: 22px;
  373. }
  374. div {
  375. font-size: 16px;
  376. color: #969696;
  377. }
  378. }
  379. </style>