sign.js 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  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.getUser()
  49. },
  50. loadInit() {
  51. // 版本
  52. this.setData({
  53. versionName: this.data.freeVersionFlag ? mixins.$t('standardVersion') : mixins.$t('professionalVersion'),
  54. companyName: app.globalData.company.cpName,
  55. staffName: app.globalData.user.staffName,
  56. staffPhone: app.globalData.user.staffPhone
  57. })
  58. },
  59. /**
  60. * 日期
  61. * @param {*} e
  62. */
  63. dateChange(e) {
  64. // 当前日期的区间
  65. let dateArrs = util.getCurrentDateMonth(e.detail.dateString)
  66. let dayDiffs = new Date(this.data.serverDate).dayDiff(new Date(dateArrs[1]))
  67. if (dayDiffs > 0) {
  68. this.selectComponent('#timeclockCalendar').setDefaultTime(dateArrs[1])
  69. } else {
  70. this.selectComponent('#timeclockCalendar').setDefaultTime(this.data.serverDate)
  71. }
  72. this.getSignData(dateArrs[0], dateArrs[1])
  73. },
  74. /**
  75. * @desc : 跳转云币规则
  76. * @author : 刘尧
  77. * @date : 2024/8/2 14:54
  78. */
  79. toIntegralRules() {
  80. let url = config.knowledge_url + '/agreement-index?agId=10002024-0802-0000-0000-000009ff303e'
  81. let toUrl = '/pages/product/product'
  82. if (url) {
  83. wx.navigateTo({
  84. url: toUrl,
  85. success: function (res) {
  86. res.eventChannel.emit('url', url);
  87. }
  88. })
  89. }
  90. },
  91. /**
  92. * @desc : 服务器的日期
  93. * @author : 姜永辉
  94. * @date : 2024/4/1
  95. */
  96. getCurrentDate() {
  97. let _this = this
  98. let service = app.globalData['commonService']
  99. _this.excute(service, service.getCurrentDate, {}).then(res => {
  100. //执行保存编辑操作
  101. _this.save({})
  102. if (res.data.code == Constants.SUCESS_CODE) {
  103. //服务器的时间
  104. let nowDate = res.data.data.currentDate
  105. let serverDate = new Date(nowDate).toDateStr()
  106. _this.setData({
  107. serverDate,
  108. defaultTime: serverDate
  109. })
  110. }
  111. });
  112. },
  113. /**
  114. * @desc : 策略
  115. * @author : 姜永辉
  116. * @date : 2024/4/1
  117. */
  118. getIntegralTactic() {
  119. let params = {}
  120. let service = app.globalData['integralTacticService']
  121. this.excute(service, service.selectByCond, params).then(res => {
  122. if (res.data.code == Constants.SUCESS_CODE) {
  123. if (res.data && res.data.data.list && res.data.data.list.length > 0) {
  124. this.setData({
  125. integralTacticItem: res.data.data.list[0],
  126. })
  127. }
  128. }
  129. });
  130. },
  131. /**
  132. * @desc : 公司积分
  133. * @author : 姜永辉
  134. * @date : 2024/4/1
  135. */
  136. getIntegral() {
  137. let params = {}
  138. let service = app.globalData['integralService']
  139. this.excute(service, app.globalData.company.cpId, params).then(res => {
  140. console.log(res.data, 'getIntegral');
  141. if (res.data.code == Constants.SUCESS_CODE) {
  142. if (res.data && res.data.data) {
  143. this.setData({
  144. integral: res.data.data.integral,
  145. })
  146. }
  147. }
  148. });
  149. },
  150. /**
  151. * @desc : 优惠券
  152. * @author : 姜永辉
  153. * @date : 2024/4/1
  154. */
  155. getCouponCount() {
  156. let params = {
  157. integralType: Constants.integralType.sign
  158. }
  159. let service = app.globalData['couponUseService']
  160. this.excute(service, '10002024-0718-0000-0000-000005c0a01e', params).then(res => {
  161. console.log(res.data);
  162. if (res.data.code == Constants.SUCESS_CODE) {
  163. }
  164. });
  165. },
  166. /**
  167. * @desc : 头像
  168. * @date : 2024/7/1 15:49
  169. * @author : 姜永辉
  170. */
  171. getUser() {
  172. let service = app.globalData['oauthService']
  173. return this.excute(service, service.getUser + '/' + app.globalData.user.userId, {}).then(res => {
  174. if (res.data.code == Constants.SUCESS_CODE) {
  175. let avatarUrl = res.data.data.userImage || this.data.defaultAvatarUrl
  176. this.setData({
  177. avatarUrl: avatarUrl
  178. })
  179. }
  180. });
  181. },
  182. /**
  183. * @desc : 查询签到
  184. * @date : 2024年3月8日
  185. * @author : jyh
  186. */
  187. getSignData(accDateStart, accDateEnd) {
  188. let _this = this
  189. let params = {
  190. integralType: Constants.integralType.sign,
  191. accDateStart: accDateStart,
  192. accDateEnd: accDateEnd,
  193. flgValid: true,
  194. userId: app.globalData.user.userId,
  195. }
  196. let service = app.globalData['integralItemService']
  197. return this.excute(service, service.selectByCond, params).then(res => {
  198. if (res.data.code == Constants.SUCESS_CODE) {
  199. let spot = []
  200. console.log(res.data.data.list);
  201. res.data.data.list.forEach(it => {
  202. spot.push({
  203. date: it.accDate,
  204. title: it.integral + '个',
  205. isnormal: true,
  206. })
  207. })
  208. _this.setData({
  209. spot
  210. })
  211. }
  212. })
  213. },
  214. /**
  215. * @desc : 保存的參數設置
  216. * @date : 2024/2/1 15:49
  217. * @author : 姜永辉
  218. */
  219. setParams(params) {
  220. params.userId = app.globalData.user.userId
  221. params.cpId = app.globalData.company.cpId
  222. params.staffName = app.globalData.user.staffName
  223. return params
  224. },
  225. /**
  226. * @desc : 保存签到
  227. * @date : 2024/2/1 15:49
  228. * @author : 姜永辉
  229. */
  230. saveData() {
  231. let _this = this
  232. return this.excute(this.data.service, this.data.service.insert, this.data.params).then(res => {
  233. if (res.data.code == Constants.SUCESS_CODE) {
  234. if (!res.data.data) {
  235. wx.showToast({
  236. title: '签到成功',
  237. image: '/static/image/success.png',
  238. duration: 2000
  239. })
  240. }
  241. let serverDate = _this.data.serverDate
  242. let dateArrs = util.getCurrentDateMonth(serverDate)
  243. _this.getSignData(dateArrs[0], dateArrs[1])
  244. _this.getIntegral()
  245. _this.setData({
  246. loading: false,
  247. })
  248. }
  249. })
  250. },
  251. })