import common from '../../utils/util'; import server from '../../utils/main'; const app = getApp(); var isPaying = false; var paytype=3;//3是单买 4是套餐 5是礼品卡 var buytype = 110;//110是6个月 112是12个月,111是永久 var detail=""; var selectedCouponID=0; Page({ data: { CouponList: [], }, onLoad: function (options) { var id = options.id; paytype = options.paytype; var result, price = 0; var programList = server.getProgramList(); var arrProduct=wx.getStorageSync("ProductPrice"); for (var j = 0; j < arrProduct.length; j++) { if (id==arrProduct[j].ProductNum){ for (var k = 0; k < arrProduct[j].Period.length; k++) { if (arrProduct[j].Period[k].Select) { price = arrProduct[j].Period[k].Price; detail = arrProduct[j].Period[k].Detail; } } result = arrProduct[j]; } } this.setData({ Containnerheight: common.getSystemHeight(), Product: result, Price: price, IsDiscount: false, CouponName:"未选择", }); }, selectPeriod: function (e) { var id = e.currentTarget.dataset.id; var list = this.data.Product.Period; var price = 0; for (var i = 0; i < list.length; i++) { if (i == id) { list[i].Select = true; price = list[i].Price; if (this.data.Coupon){ price=price-Number(this.data.Coupon.Price); } if (price.toString().indexOf(".") < 0) { price = price + ".00"; } detail = list[i].Detail; if (i==0) buytype=110; else if (i == 1) buytype = 112; else if (i == 2) buytype = 111; } else list[i].Select = false; } this.data.Product.Period = list; this.setData({ Product: this.data.Product, Price: price, }); }, showDiscount: function () { this.GetUserCouponListByUserID(); }, closeDiscount: function () { this.setData({ IsDiscount: false, }); }, GetUserCouponListByUserID: function (callback) { var that = this; that.setData({ IsDiscount: true, }); wx.showLoading({ title: '请稍后', }); server.getData('GetUserCouponListByUserID?ProductID='+app.globalData.ProgramID+'&UserID=' + app.globalData.userInfo.UserID, function (data) { if (data) { that.setData({ CouponList:data, }); } wx.hideLoading(); }); }, selectCoupon:function(e){ selectedCouponID=e.currentTarget.dataset.id; var list = this.data.CouponList; for(var i=0;i