| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270 |
- /*******************************************************************************
- * Copyright(c) 2022 dongke All rights reserved. / Confidential
- * 类的信息:
- * 1.程序名称:
- * 2.功能描述:签到画面
- * 编辑履历:
- * 作者 日期 版本 修改内容
- * 姜永辉 2022-11-22 1.00 新建
- *******************************************************************************/
- const Constants = require('@/utils/Constants.js');
- const mixins = require('@/mixins/index.js');
- const config = require('@/config/config.js');
- const util = require('@/utils/util');
- const app = getApp()
- Page({
- mixins: [mixins],
- /**
- * 页面的初始数据
- */
- data: {
- staffName: '',
- staffPhone: '',
- companyName: '',
- versionName: '',
- // 路由
- routeObjName: 'signRecord',
- // 策略
- integralTacticItem: {},
- // 积分
- integral: 0,
- // 优惠券
- couponCount: 0,
- avatarUrl: config.image_url + '/static/img/' + '/order_billing_detail_01.png',
- spot: [],
- navigateBackFlag: true,
- defaultTime: null,
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad(options) {
- this.getCurrentDate()
- // 策略
- // this.getIntegralTactic()
- // // 积分
- // this.getIntegral()
- // 头像
- this.getUser()
- },
- loadInit() {
- // 版本
- this.setData({
- versionName: this.data.freeVersionFlag ? mixins.$t('standardVersion') : mixins.$t('professionalVersion'),
- companyName: app.globalData.company.cpName,
- staffName: app.globalData.user.staffName,
- staffPhone: app.globalData.user.staffPhone
- })
- },
- /**
- * 日期
- * @param {*} e
- */
- dateChange(e) {
- // 当前日期的区间
- let dateArrs = util.getCurrentDateMonth(e.detail.dateString)
- let dayDiffs = new Date(this.data.serverDate).dayDiff(new Date(dateArrs[1]))
- if (dayDiffs > 0) {
- this.selectComponent('#timeclockCalendar').setDefaultTime(dateArrs[1])
- } else {
- this.selectComponent('#timeclockCalendar').setDefaultTime(this.data.serverDate)
- }
- this.getSignData(dateArrs[0], dateArrs[1])
- },
- /**
- * @desc : 跳转云币规则
- * @author : 刘尧
- * @date : 2024/8/2 14:54
- */
- toIntegralRules() {
- let url = config.knowledge_url + '/agreement-index?agId=10002024-0802-0000-0000-000009ff303e'
- let toUrl = '/pages/product/product'
- if (url) {
- wx.navigateTo({
- url: toUrl,
- success: function (res) {
- res.eventChannel.emit('url', url);
- }
- })
- }
- },
- /**
- * @desc : 服务器的日期
- * @author : 姜永辉
- * @date : 2024/4/1
- */
- getCurrentDate() {
- let _this = this
- let service = app.globalData['commonService']
- _this.excute(service, service.getCurrentDate, {}).then(res => {
- //执行保存编辑操作
- _this.save({})
- if (res.data.code == Constants.SUCESS_CODE) {
- //服务器的时间
- let nowDate = res.data.data.currentDate
- let serverDate = new Date(nowDate).toDateStr()
- _this.setData({
- serverDate,
- defaultTime: serverDate
- })
- }
- });
- },
- /**
- * @desc : 策略
- * @author : 姜永辉
- * @date : 2024/4/1
- */
- getIntegralTactic() {
- let params = {}
- let service = app.globalData['integralTacticService']
- this.excute(service, service.selectByCond, params).then(res => {
- if (res.data.code == Constants.SUCESS_CODE) {
- if (res.data && res.data.data.list && res.data.data.list.length > 0) {
- this.setData({
- integralTacticItem: res.data.data.list[0],
- })
- }
- }
- });
- },
- /**
- * @desc : 公司积分
- * @author : 姜永辉
- * @date : 2024/4/1
- */
- getIntegral() {
- let params = {}
- let service = app.globalData['integralService']
- this.excute(service, app.globalData.company.cpId, params).then(res => {
- console.log(res.data, 'getIntegral');
- if (res.data.code == Constants.SUCESS_CODE) {
- if (res.data && res.data.data) {
- this.setData({
- integral: res.data.data.integral,
- })
- }
- }
- });
- },
- /**
- * @desc : 优惠券
- * @author : 姜永辉
- * @date : 2024/4/1
- */
- getCouponCount() {
- let params = {
- integralType: Constants.integralType.sign
- }
- let service = app.globalData['couponUseService']
- this.excute(service, '10002024-0718-0000-0000-000005c0a01e', params).then(res => {
- console.log(res.data);
- if (res.data.code == Constants.SUCESS_CODE) {
- }
- });
- },
- /**
- * @desc : 头像
- * @date : 2024/7/1 15:49
- * @author : 姜永辉
- */
- getUser() {
- let service = app.globalData['oauthService']
- return this.excute(service, service.getUser + '/' + app.globalData.user.userId, {}).then(res => {
- if (res.data.code == Constants.SUCESS_CODE) {
- let avatarUrl = res.data.data.userImage || this.data.defaultAvatarUrl
- this.setData({
- avatarUrl: avatarUrl
- })
- }
- });
- },
- /**
- * @desc : 查询签到
- * @date : 2024年3月8日
- * @author : jyh
- */
- getSignData(accDateStart, accDateEnd) {
- let _this = this
- let params = {
- integralType: Constants.integralType.sign,
- accDateStart: accDateStart,
- accDateEnd: accDateEnd,
- flgValid: true,
- userId: app.globalData.user.userId,
- }
- let service = app.globalData['integralItemService']
- return this.excute(service, service.selectByCond, params).then(res => {
- if (res.data.code == Constants.SUCESS_CODE) {
- let spot = []
- console.log(res.data.data.list);
- res.data.data.list.forEach(it => {
- spot.push({
- date: it.accDate,
- title: it.integral + '个',
- isnormal: true,
- })
- })
- _this.setData({
- spot
- })
- }
- })
- },
- /**
- * @desc : 保存的參數設置
- * @date : 2024/2/1 15:49
- * @author : 姜永辉
- */
- setParams(params) {
- params.userId = app.globalData.user.userId
- params.cpId = app.globalData.company.cpId
- params.staffName = app.globalData.user.staffName
- return params
- },
- /**
- * @desc : 保存签到
- * @date : 2024/2/1 15:49
- * @author : 姜永辉
- */
- saveData() {
- let _this = this
- return this.excute(this.data.service, this.data.service.insert, this.data.params).then(res => {
- if (res.data.code == Constants.SUCESS_CODE) {
- if (!res.data.data) {
- wx.showToast({
- title: '签到成功',
- image: '/static/image/success.png',
- duration: 2000
- })
- }
- let serverDate = _this.data.serverDate
- let dateArrs = util.getCurrentDateMonth(serverDate)
- _this.getSignData(dateArrs[0], dateArrs[1])
- _this.getIntegral()
- _this.setData({
- loading: false,
- })
- }
- })
- },
- })
|