coupon.js 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. ;
  2. var orderPage = new Vue({
  3. el: "#beansPage",
  4. data: {
  5. isRequset:true,
  6. noMore: false,
  7. tabsListIndex:0,
  8. tabsList: [
  9. {value: 0,text: '未使用'},
  10. {value: 1,text: '已使用'},
  11. {value: 2,text: '已失效'}
  12. ],
  13. listQuery:{
  14. userId:0,
  15. pageNum:1,
  16. pageSize:6,
  17. status:1
  18. },
  19. coupinList:[],
  20. listRecord: 0,
  21. pageInput: '1',
  22. userBeans:0,
  23. confirmedCount:'',//待確認數量
  24. paymentCount:'',//待付款
  25. waitShipmentsCount:'',//待发货
  26. shipmentsCount:'',//已发货
  27. salesReturnCount:'',//退货款
  28. modelType:0,
  29. orderIdentificationId:0,
  30. payModelData:{},
  31. hanldOrderData:{},//监听点击的单个订单项的按钮
  32. confrimsBtn:true,
  33. listClass:'used',
  34. dataList:[],
  35. },
  36. filters: {
  37. TypeBtnFormat:function(value){
  38. switch (value) {
  39. case 1:
  40. return '去使用';
  41. break;
  42. case 2:
  43. return '已使用';
  44. break;
  45. case 3:
  46. return '已失效';
  47. break;
  48. }
  49. },
  50. TypeFormat:function(value) {
  51. switch (value) {
  52. case 0:
  53. return '活动券';
  54. break;
  55. case 1:
  56. return '品类券';
  57. break;
  58. case 2:
  59. return '用户专享券';
  60. break;
  61. case 3:
  62. return '店铺券';
  63. break;
  64. case 4:
  65. return '新用户券';
  66. break;
  67. }
  68. }
  69. },
  70. computed: {
  71. pageTotal: function () {
  72. var total = Math.ceil(this.listRecord / this.listQuery.pageSize);
  73. return total > 0 ? total : 1;
  74. },
  75. showPageBtn: function () {
  76. var total = Math.ceil(this.listRecord / this.listQuery.pageSize);
  77. total = total > 0 ? total : 1;
  78. var index = this.listQuery.pageNum, arr = [];
  79. if (total <= 6) {
  80. for (var i = 1; i <= total; i++) {
  81. arr.push(i);
  82. }
  83. return arr;
  84. }
  85. if (index <= 3) return [1, 2, 3, 4, 5, 0, total];
  86. if (index >= total - 2) return [1, 0, total - 4, total - 3, total - 2, total - 1, total];
  87. return [1, 0, index - 2, index - 1, index, index + 1, index + 2, 0, total];
  88. }
  89. },
  90. methods: {
  91. tabClick:function(index){//点击Tab切换查询列表
  92. var _self = this;
  93. _self.tabsListIndex = index;
  94. console.log('tabsListIndex',_self.tabsListIndex)
  95. switch(_self.tabsListIndex){
  96. case 0:
  97. _self.listClass = 'used'
  98. _self.listQuery.status = 1
  99. break;
  100. case 1:
  101. _self.listClass = 'none'
  102. _self.listQuery.status = 2
  103. break;
  104. case 2:
  105. _self.listClass = 'none'
  106. _self.listQuery.status = 3
  107. break;
  108. }
  109. _self.listQuery.pageNum = 1;
  110. _self.QueryCouponCenter();
  111. },
  112. getQueryCouponsCount: function (){// 获取优惠券数量
  113. var _self = this;
  114. ProductApi.QueryCouponsCount({userId:this.listQuery.userId,},function (response) {
  115. if(response.code == 0){
  116. let data = response.data
  117. _self.tabsList[0].num = data.unusedNum
  118. _self.tabsList[1].num = data.usedNum
  119. _self.tabsList[2].num = data.expiredNum
  120. }else{
  121. CAIMEI.Alert(response.msg, '确定', false);
  122. }
  123. })
  124. },
  125. toPagination: function (pageNum) {//点击切换分页
  126. if (pageNum <= this.pageTotal) {
  127. this.listQuery.pageNum = pageNum;
  128. this.QueryCouponCenter();
  129. }
  130. },
  131. checkNum: function () {//输入跳转分页
  132. if (this.pageInput > this.pageTotal) {
  133. this.pageInput = this.pageTotal;
  134. } else if (this.pageInput < 1) {
  135. this.pageInput = 1;
  136. }
  137. },
  138. QueryCouponCenter:function(){//查询订单列表
  139. var _self = this;
  140. ProductApi.QueryCouponCenter(_self.listQuery,function (response) {
  141. if(response.code == 0){
  142. var data = response.data;
  143. if( data.list && data.list.length>0) {
  144. _self.coupinList = [];
  145. _self.coupinList = data.list;
  146. _self.listRecord = data.total;
  147. }else{
  148. _self.coupinList = [];
  149. _self.coupinList = data.list;
  150. _self.listRecord = data.total;
  151. }
  152. _self.isRequset = false;
  153. }else{
  154. CAIMEI.Alert(response.msg, '确定', false);
  155. }
  156. })
  157. },
  158. toUseCoupon:function(coupon){// 点击去使用跳转路由处理
  159. console.log(coupon)
  160. if(coupon.useStatus == 1){
  161. switch (coupon.couponType) {
  162. case 0:// 活动券跳转到商城首页 / 或者活动页(看是否指定了商品)
  163. if(coupon.productType == 1){
  164. window.location.href='/index.html';
  165. }else{
  166. window.location.href='/product/product-coupon.html?couponId='+coupon.couponId;
  167. }
  168. break;
  169. case 1:// 品类券:跳转到产品 / 仪器页
  170. if(coupon.categoryType == 1){
  171. window.location.href='/product/type-287.html';
  172. }else{
  173. window.location.href='/product/type-286.html';
  174. }
  175. break;
  176. case 2:// 专享券:跳转到商城首页
  177. window.location.href='/index.html';
  178. break;
  179. case 3:// 店铺券:跳转到店铺首页
  180. console.log('22222222222')
  181. window.location.href='/supplier-'+coupon.shopId+'.html';
  182. debugger
  183. break;
  184. case 4:// 新用户券:跳转到商城首页
  185. window.location.href='/index.html';
  186. break;
  187. }
  188. }else{
  189. return;
  190. }
  191. },
  192. },
  193. mounted: function () {
  194. var _self = this;
  195. if(globalUserData){
  196. _self.userId = globalUserData.userId;
  197. _self.listQuery.userId = this.userId;
  198. _self.getQueryCouponsCount();
  199. _self.QueryCouponCenter();
  200. }
  201. }
  202. });