sign.js 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. /*******************************************************************************
  2. * Copyright(c) 2022 dongke All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:
  5. * 2.功能描述:签到画面
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 姜永辉 2022-11-22 1.00 新建
  9. *******************************************************************************/
  10. const Constants = require('@/utils/Constants.js');
  11. const mixins = require('@/mixins/index.js');
  12. const config = require('@/config/config.js');
  13. const util = require('@/utils/util');
  14. const app = getApp()
  15. Page({
  16. mixins: [mixins],
  17. /**
  18. * 页面的初始数据
  19. */
  20. data: {
  21. staffName: '',
  22. staffPhone: '',
  23. companyName: '',
  24. versionName: '',
  25. // 路由
  26. routeObjName: 'signRecord',
  27. // 策略
  28. integralTacticItem: {},
  29. // 积分
  30. integral: 0,
  31. // 优惠券
  32. couponCount: 0,
  33. avatarUrl: config.image_url + '/static/img/' + '/order_billing_detail_01.png',
  34. spot: [],
  35. navigateBackFlag: true,
  36. defaultTime: null,
  37. },
  38. /**
  39. * 生命周期函数--监听页面加载
  40. */
  41. onLoad(options) {
  42. this.getCurrentDate()
  43. // 策略
  44. // this.getIntegralTactic()
  45. // // 积分
  46. // this.getIntegral()
  47. // 获取优惠劵
  48. this.getCouponNumber()
  49. // 头像
  50. this.getUser()
  51. },
  52. loadInit() {
  53. // 版本
  54. this.setData({
  55. versionName: this.data.freeVersionFlag ? mixins.$t('standardVersion') : mixins.$t('professionalVersion'),
  56. companyName: app.globalData.company.cpName,
  57. staffName: app.globalData.user.staffName,
  58. staffPhone: app.globalData.user.staffPhone
  59. })
  60. },
  61. /**
  62. * @desc : 优惠劵数量获取
  63. * @author : 刘尧
  64. * @date : 2024/7/29 15:54
  65. */
  66. getCouponNumber() {
  67. let params = {
  68. couponStatus: Constants.couponStatus.unused,
  69. flgValid: true
  70. }
  71. let service = app.globalData['couponUseService']
  72. this.excute(service, service.countByCond, params).then(res => {
  73. this.setData({
  74. couponCount: res.data.data
  75. })
  76. });
  77. },
  78. /**
  79. * 日期
  80. * @param {*} e
  81. */
  82. dateChange(e) {
  83. // 当前日期的区间
  84. let dateArrs = util.getCurrentDateMonth(e.detail.dateString)
  85. let dayDiffs = new Date(this.data.serverDate).dayDiff(new Date(dateArrs[1]))
  86. if (dayDiffs > 0) {
  87. this.selectComponent('#timeclockCalendar').setDefaultTime(dateArrs[1])
  88. } else {
  89. this.selectComponent('#timeclockCalendar').setDefaultTime(this.data.serverDate)
  90. }
  91. this.getSignData(dateArrs[0], dateArrs[1])
  92. },
  93. /**
  94. * @desc : 跳转云币规则
  95. * @author : 刘尧
  96. * @date : 2024/8/2 14:54
  97. */
  98. toIntegralRules() {
  99. let url = config.knowledge_url + '/agreement-index?agId=10002024-0802-0000-0000-000009ff303e'
  100. let toUrl = '/pages/product/product'
  101. if (url) {
  102. wx.navigateTo({
  103. url: toUrl,
  104. success: function (res) {
  105. res.eventChannel.emit('url', url);
  106. }
  107. })
  108. }
  109. },
  110. /**
  111. * @desc : 服务器的日期
  112. * @author : 姜永辉
  113. * @date : 2024/4/1
  114. */
  115. getCurrentDate() {
  116. let _this = this
  117. let service = app.globalData['commonService']
  118. _this.excute(service, service.getCurrentDate, {}).then(res => {
  119. //执行保存编辑操作
  120. _this.save({})
  121. if (res.data.code == Constants.SUCESS_CODE) {
  122. //服务器的时间
  123. let nowDate = res.data.data.currentDate
  124. let serverDate = new Date(nowDate).toDateStr()
  125. _this.setData({
  126. serverDate,
  127. defaultTime: serverDate
  128. })
  129. }
  130. });
  131. },
  132. /**
  133. * @desc : 策略
  134. * @author : 姜永辉
  135. * @date : 2024/4/1
  136. */
  137. getIntegralTactic() {
  138. let params = {}
  139. let service = app.globalData['integralTacticService']
  140. this.excute(service, service.selectByCond, params).then(res => {
  141. if (res.data.code == Constants.SUCESS_CODE) {
  142. if (res.data && res.data.data.list && res.data.data.list.length > 0) {
  143. this.setData({
  144. integralTacticItem: res.data.data.list[0],
  145. })
  146. }
  147. }
  148. });
  149. },
  150. /**
  151. * @desc : 公司积分
  152. * @author : 姜永辉
  153. * @date : 2024/4/1
  154. */
  155. getIntegral() {
  156. let params = {}
  157. let service = app.globalData['integralService']
  158. this.excute(service, app.globalData.company.cpId, params).then(res => {
  159. console.log(res.data, 'getIntegral');
  160. if (res.data.code == Constants.SUCESS_CODE) {
  161. if (res.data && res.data.data) {
  162. this.setData({
  163. integral: res.data.data.integral,
  164. })
  165. }
  166. }
  167. });
  168. },
  169. /**
  170. * @desc : 优惠券
  171. * @author : 姜永辉
  172. * @date : 2024/4/1
  173. */
  174. getCouponCount() {
  175. let params = {
  176. integralType: Constants.integralType.sign
  177. }
  178. let service = app.globalData['couponUseService']
  179. this.excute(service, '10002024-0718-0000-0000-000005c0a01e', params).then(res => {
  180. console.log(res.data);
  181. if (res.data.code == Constants.SUCESS_CODE) {
  182. }
  183. });
  184. },
  185. /**
  186. * @desc : 头像
  187. * @date : 2024/7/1 15:49
  188. * @author : 姜永辉
  189. */
  190. getUser() {
  191. let service = app.globalData['oauthService']
  192. return this.excute(service, service.getUser + '/' + app.globalData.user.userId, {}).then(res => {
  193. if (res.data.code == Constants.SUCESS_CODE) {
  194. let avatarUrl = res.data.data.userImage || this.data.defaultAvatarUrl
  195. this.setData({
  196. avatarUrl: avatarUrl
  197. })
  198. }
  199. });
  200. },
  201. /**
  202. * @desc : 查询签到
  203. * @date : 2024年3月8日
  204. * @author : jyh
  205. */
  206. getSignData(accDateStart, accDateEnd) {
  207. let _this = this
  208. let params = {
  209. integralType: Constants.integralType.sign,
  210. accDateStart: accDateStart,
  211. accDateEnd: accDateEnd,
  212. flgValid: true,
  213. userId: app.globalData.user.userId,
  214. }
  215. let service = app.globalData['integralItemService']
  216. return this.excute(service, service.selectByCond, params).then(res => {
  217. if (res.data.code == Constants.SUCESS_CODE) {
  218. let spot = []
  219. console.log(res.data.data.list);
  220. res.data.data.list.forEach(it => {
  221. spot.push({
  222. date: it.accDate,
  223. title: it.integral + '个',
  224. isnormal: true,
  225. })
  226. })
  227. _this.setData({
  228. spot
  229. })
  230. }
  231. })
  232. },
  233. /**
  234. * @desc : 保存的參數設置
  235. * @date : 2024/2/1 15:49
  236. * @author : 姜永辉
  237. */
  238. setParams(params) {
  239. params.userId = app.globalData.user.userId
  240. params.cpId = app.globalData.company.cpId
  241. params.staffName = app.globalData.user.staffName
  242. return params
  243. },
  244. /**
  245. * @desc : 保存签到
  246. * @date : 2024/2/1 15:49
  247. * @author : 姜永辉
  248. */
  249. saveData() {
  250. let _this = this
  251. return this.excute(this.data.service, this.data.service.insert, this.data.params).then(res => {
  252. if (res.data.code == Constants.SUCESS_CODE) {
  253. if (!res.data.data) {
  254. wx.showToast({
  255. title: '签到成功',
  256. image: '/static/image/success.png',
  257. duration: 2000
  258. })
  259. }
  260. let serverDate = _this.data.serverDate
  261. let dateArrs = util.getCurrentDateMonth(serverDate)
  262. _this.getSignData(dateArrs[0], dateArrs[1])
  263. _this.getIntegral()
  264. _this.setData({
  265. loading: false,
  266. })
  267. }
  268. })
  269. },
  270. })