123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199 |
- // pages/integral/integral.js
- import Integralinfo from '../../api/integralinfo'
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- lock: false,
- noResult: false,
- noMore: false,
- bannerList: [],
- couponList: [],
- channelid: '',
- shopid: '',
- storeid: '',
- bodyHidden: true,
- bgStatus: false,
- scorePhone: false,
- animationData: {},
- integralIngo:{},
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- this.getBannerList()
- this.getCouponList()
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- },
- getBannerList: function() {
- Integralinfo.getBannerList({
- channelid: this.data.channelid,
- shopid: this.data.shopid,
- storeid: this.data.storeid
- }).then(res => {
- console.log(res.data)
- this.setData({
- bannerList: res.data
- })
- }).catch(err => {
- console.log(err)
- })
- },
- getCouponList: function() {
- Integralinfo.getList({
- channelid: this.data.channelid,
- shopid: this.data.shopid,
- storeid: this.data.storeid
- }).then(res => {
- this.couponListView(res.data)
- this.data.lock = false
- }).catch(_ => {
- console.log(_)
- this.data.lock = false
- })
- },
- couponListView: function(data) {
- if (!Array.isArray(data) || data.length == 0) {
- console.log("优惠券列表数据为空");
- }
- data.forEach((v) => {
- v.quantity = 0
- v.integral = v.price * v.ratio
- })
- if (this.mobile != '********') {
- let num = this.integralNum > 20000 ? 19999 : this.integralNum
- const arr = []
- for (let i = 0; i < data.length; i++) {
- data[i].quantity = parseInt(num / data[i].integral)
- if (data[i].quantity > 0) {
- num -= (data[i].quantity * data[i].price) * data[i].ratio
- this.total += (data[i].quantity * data[i].price) * data[i].ratio
- arr.push(data[i])
- data.splice(i, 1)
- i--
- }
- }
- this.setData({
- couponList: [...arr, ...data]
- })
- console.log(this.data.couponList)
- }
- },
- // 点击标识点触发
- detailsClick(row) {
- this.hideModal();
- this.row = row.currentTarget.dataset.info
- console.log(this.row)
- if (this.row.detail_type === 0) {
- this.row.detailArr = this.row.detail.split('\n')
- } else {
- this.row.detailArr = row.detail
- }
- this.setData({
- integralIngo: this.row,
- })
- console.log(this.data.integralIngo)
- setTimeout(() => {
- this.showDodal();
- }, 100)
- },
- showDodal() {
- var that = this;
- // 显示遮罩层
- var animation = wx.createAnimation({
- duration: 150,
- timingFunction: "linear",
- delay: 0
- })
- this.setData({
- bgStatus: true,
- bodyHidden: false
- })
-
- that.animation = animation
- animation.translateY(-500).step()
- that.setData({
- animationData: animation.export()
- })
- },
- //隐藏对话框
- hideModal() {
- var that = this;
- console.log(that.data)
- // 隐藏遮罩层
- var animation = wx.createAnimation({
- duration: 150,
- timingFunction: "linear",
- delay: 0
- })
- this.setData({
- bodyHidden: true,
- bgStatus: false,
- scorePhone: false,
- })
-
- that.animation = animation
- animation.translateY(0).step()
- that.setData({
- animationData: animation.export()
- })
- },
-
- })
|