123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147 |
- import {
- get,
- post
- } from "../../utils/http";
- Page({
-
- data: {
- store_id: '',
- page: 1,
- limit: 10,
- CouponList: [],
- couponType: ['抵扣券', '满减券', '全额减免券', '卡券'],
- total: '',
- },
-
- onLoad(options) {
-
- this.setData({
- store_id: wx.getStorageSync('store_id')
- })
-
- this.getCouponList()
- },
-
- onReady() {
- },
-
- onShow() {
- },
-
- onHide() {
- },
-
- onUnload() {
- },
-
- onPullDownRefresh() {
- },
-
- onReachBottom() {
- if (this.data.CouponList.length < this.data.total) {
- this.getCouponList(++this.data.page)
- } else {
- return
- }
- },
-
- onShareAppMessage() {
- },
-
- getCouponList(_page) {
- let {
- CouponList
- } = this.data
- get('/v2/api/activity/coupon', {
- store_id: this.data.store || wx.getStorageSync('store_id'),
- page: _page || this.data.page,
- limit: this.data.limit
- }, (res) => {
-
- if (_page == 'no') {
- this.setData({
- CouponList: res.data.list,
- total: res.data.total
- })
- }
-
- if (res.code == 200 && _page != 'no') {
- CouponList.push(...res.data.list)
- this.setData({
- CouponList,
- total: res.data.total
- })
- }
- })
- },
-
- getCoupon(e) {
- let activeId = e.currentTarget.dataset.activeid
- post('/v2/api/activity/receive', {
- id: activeId,
- store_id: wx.getStorageSync('store_id')
- }, (res) => {
- let coupon_id = res.data
- this.getCouponList("no")
-
- wx.requestSubscribeMessage({
- tmplIds: ['1c7uBFGMQYBAFRiJIk2IoyKFhC7En3ElONwm8Nwl5HQ'],
- success(res) {
- console.log(res);
- let status = ''
-
- if (res['1c7uBFGMQYBAFRiJIk2IoyKFhC7En3ElONwm8Nwl5HQ'] == 'reject') {
- status = 2
- } else {
- status = 1
- }
- get('/v2/api/activity/push', {
- type: 1,
- status,
- coupon_id,
- }, res => {})
- },
- })
- })
- },
-
- goProject(){
- wx.switchTab({
- url: '/pages/orderBy/orderBy',
- })
- }
- })
|