123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199 |
- ;
- var orderPage = new Vue({
- el: "#beansPage",
- data: {
- isRequset:false,
- noMore: false,
- tabsListIndex:0,
- listQuery:{
- userId:0,
- pageNum:1,
- pageSize:9
- },
- beansList:[],
- listRecord: 0,
- pageInput: '1',
- modelType:0,
- coupinList:[],
- },
- filters: {
- TypeFormat:function(value) {
- switch (value) {
- case 0:
- return '活动券';
- break;
- case 1:
- return '品类券';
- break;
- case 2:
- return '用户专享券';
- break;
- case 3:
- return '店铺券';
- break;
- case 4:
- return '新用户券';
- break;
- }
- }
- },
- computed: {
- pageTotal: function () {
- var total = Math.ceil(this.listRecord / this.listQuery.pageSize);
- return total > 0 ? total : 1;
- },
- showPageBtn: function () {
- var total = Math.ceil(this.listRecord / this.listQuery.pageSize);
- total = total > 0 ? total : 1;
- var index = this.listQuery.pageNum, arr = [];
- if (total <= 6) {
- for (var i = 1; i <= total; i++) {
- arr.push(i);
- }
- return arr;
- }
- if (index <= 3) return [1, 2, 3, 4, 5, 0, total];
- if (index >= total - 2) return [1, 0, total - 4, total - 3, total - 2, total - 1, total];
- return [1, 0, index - 2, index - 1, index, index + 1, index + 2, 0, total];
- }
- },
- methods: {
- toPagination: function (pageNum) {//点击切换分页
- if (pageNum <= this.pageTotal) {
- this.listQuery.pageNum = pageNum;
- this.QueryCouponCollarList();
- }
- },
- checkNum: function () {//输入跳转分页
- if (this.pageInput > this.pageTotal) {
- this.pageInput = this.pageTotal;
- } else if (this.pageInput < 1) {
- this.pageInput = 1;
- }
- },
- changeOrderFn:function(index,status){
- var _self = this;
- _self.orderTabBarIndex = index;
- _self.listQuery.orderState = status;
- _self.listQuery.searchNo = '';
- _self.listQuery.beginTime = '';
- _self.listQuery.endTime = '';
- _self.listQuery.pageNum = 1;
- _self.isRequset = true;
- _self.QueryCouponCollarList()
- },
- QueryCouponCollarList:function(){//查询优惠券列表
- var _self = this;
- ProductApi.QueryCouponCollarList(_self.listQuery,function (response) {
- if(response.code == 0){
- var data = response.data;
- if( data.list && data.list.length>0) {
- _self.coupinList = [];
- _self.coupinList = data.list;
- _self.listRecord = data.total;
- }else{
- _self.coupinList = [];
- _self.coupinList = data.list;
- _self.listRecord = data.total;
- }
- _self.isRequset = false;
- }else{
- CAIMEI.Alert(response.msg, '确定', false);
- }
- })
- },
- toBuyCoupon:function (coupon) {// 点击购买按钮事件处理
- var _self = this;
- if(this.listQuery.userId == 0){
- window.location.href='/login.html';
- }else{
- ProductApi.createCouponRecord({userId:_self.listQuery.userId, couponId:coupon.couponId}, function (response) {
- if(response.code == 0){
- let couponRecordId = response.data.couponRecordId
- window.location.href = '/pay/caimei-paycash.html?pageType=3&couponId='+coupon.couponId+'&couponRecordId='+couponRecordId;
- }else{
- if(response.code == -1){//个人机构不能购买
- CAIMEI.Alert('该优惠券仅限医美机构购买,请升级为医美机构后再次购买。', '去升级', true, function(){
- window.location.href = "/user/setting/upgrade.html";
- });
- }else if(response.code == -2){//会员机构不是医美机构不能购买
- CAIMEI.dialog('该优惠券仅限医美机构购买',false,function () {});
- }else{
- CAIMEI.Alert(response.msg, '确定', false);
- }
- }
- })
- }
- },
- receiveCoupon:function(coupon){// 点击领取按钮事件处理
- var _self = this;
- console.log(coupon)
- if(_self.listQuery.userId == 0){
- window.location.href='/login.html';
- }else{
- ProductApi.ReceiveCoupon({userId:_self.listQuery.userId, couponId:coupon.couponId, source:1}, function (response) {
- if(response.code == 0){
- CAIMEI.dialog('领取成功',true,function () {
- setTimeout(function(){
- coupon.couponBtnType = 1;
- },200)
- });
- }else{
- CAIMEI.Alert(response.msg, '确定', false);
- }
- })
- }
- },
- myClickCoupon:function (){// 我的优惠券跳转
- var _self = this;
- if(_self.listQuery.userId>0){
- window.location.href='/user/coupon.html';
- }else{
- window.location.href='/login.html';
- }
- },
- toUseCoupon:function (coupon){// 去使用跳转路径
- var _self = this;
- switch (coupon.couponType) {
- case 0:// 活动券跳转到商城首页 / 或者活动页(看是否指定了商品)
- if(coupon.productType == 1){
- _self.QueryCouponCollarList()
- window.open('/index.html');
- }else{
- _self.QueryCouponCollarList()
- window.open('/product/product-coupon.html?couponId='+coupon.couponId);
- }
- break;
- case 1:// 品类券:跳转到产品 / 仪器页
- if(coupon.categoryType == 1){
- _self.QueryCouponCollarList()
- window.open('/product/type-287.html');
- }else{
- _self.QueryCouponCollarList()
- window.open('/product/type-286.html');
- }
- break;
- case 2:// 专享券:跳转到商城首页
- _self.QueryCouponCollarList()
- window.open('/index.html');
- break;
- case 3:// 店铺券:跳转到店铺首页
- _self.QueryCouponCollarList()
- window.open('/supplier-'+coupon.shopId+'.html');
- break;
- case 4:// 新用户券:跳转到商城首页
- _self.QueryCouponCollarList()
- window.open('/index.html');
- break;
- }
- }
- },
- mounted: function () {
- var _self = this;
- if(globalUserData){
- _self.userId = globalUserData.userId;
- _self.listQuery.userId = _self.userId;
- }
- _self.QueryCouponCollarList();
- }
- });
|