/******************************************************************************* * Copyright(c) 2022 dongke All rights reserved. / Confidential * 类的信息: * 1.程序名称:增值定制 * 编辑履历: * 作者 日期 版本 修改内容 * 周兴 2024-5-15 1.00 新建 *******************************************************************************/ const Constants = require('@/utils/Constants.js'); const mixins = require('@/mixins/index.js'); const config = require('@/config/config.js'); const app = getApp() Page({ mixins: [mixins], /** * 页面的初始数据 */ data: { regions: [], regionsHavedBuyUuids: [], // 已经购买的数组 functionItems: [], regionsIsBuy: [], funIds: [], imageUrl: config.image_url + '/static/img/', btnFormData: null, // 路由 routeObjName: 'activity', // 底部保存按钮 buttonFootList: [ // { // code: 'buyUpgrade', // title: mixins.$t('buyUpgrade'), // }, { code: 'buyHistory', title: mixins.$t('buyHistory') }], }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { this.setData({ regionsHavedBuyUuids: app.globalData.company.funPackage || [] }) // 查询活动 this.getActivity() }, /** * @desc : 查询活动 * @author : 周兴 * @date : 2024/4/1 */ getActivity() { let params = { appCode: Constants.APP_CODE, activityStatus: Constants.kindCode.activityStatus, cpId: app.globalData.company.cpId, gradeCode: this.data.gradeCode, activityTypeList: [Constants.kindCode.activityFunc], } let service = app.globalData['activityService'] this.excute(service, service.selectActivityItems, params).then(res => { if (res.data.code == Constants.SUCESS_CODE) { console.log("activityService", res); if (res.data && res.data.data) { let regions = []; let regionsAll = res.data.data; let regionsIsBuy = [] let funIds = [] let functionItems = [] regionsAll.forEach(element => { let activityIds = this.data.regionsHavedBuyUuids.map(it => it.activityId) functionItems.push(element.activityItemDescribe) let fids = JSON.parse(element.funIds.value) fids.forEach(it => { it.imageUrl = this.data.imageUrl + it.object_icon + '.png' }) element.funIds = fids if (activityIds.indexOf(element.activityId) > -1) { regionsIsBuy.push(element) return } regions.push(element) }); this.setData({ regions: regions, regionsIsBuy, functionItems: functionItems, funIds: funIds, }) } } }); }, /** * @desc : 升级和已购记录查询 * @date : 2024/2/1 15:49 * @author : 姜永辉 */ open(e) { console.log(e); let _this = this let code = e.detail.name // 升级 if (code == 'buyUpgrade') { wx.navigateTo({ url: '/package-basic-data/pages/activity/activity?upgrade=true', events: { // 回调后 refresh: function (data) { } }, success: function (res) { // 通过eventChannel向被打开页面传送数据 res.eventChannel.emit('params', {}) } }) } // 已购记录查询 else if (code == 'buyHistory') { wx.navigateTo({ url: '/package-basic-data/pages/func-buy/added/added', events: { // 回调后 refresh: function (data) { } }, success: function (res) { // 通过eventChannel向被打开页面传送数据 res.eventChannel.emit('params', { item: _this.data.regionsIsBuy }) } }) } }, /** * @desc : 保存数据服务-跳转收款页面 * @date : 2024/2/1 15:49 * @author : 姜永辉 */ buyFunc(e) { let item = e.currentTarget.dataset.item let _this = this wx.navigateTo({ url: '/package-basic-data/pages/func-buy/add-confirm/add-confirm', events: { // 回调后 refresh: function (data) { // 查询活动 _this.getActivity() } }, success: function (res) { // 通过eventChannel向被打开页面传送数据 res.eventChannel.emit('params', { item: item }) } }) } })