mine.js 29 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126
  1. /*******************************************************************************
  2. * Copyright(c) 2022 dongke All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:
  5. * 2.功能描述:我的设置
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 姜永辉 2024-2-12 1.00
  9. *******************************************************************************/
  10. const api = require('@/utils/api.js');
  11. const config = require('@/config/config.js');
  12. const common = require('@/utils/common.js')
  13. const Constants = require('@/utils/Constants.js');
  14. const util = require('@/utils/util.js')
  15. const mixins = require('@/mixins/index.js')
  16. import Dialog from '@/dist/dialog/dialog.js';
  17. const app = getApp()
  18. Page({
  19. mixins: [mixins],
  20. /**
  21. * 页面的初始数据
  22. */
  23. data: {
  24. integral: 0,
  25. defaultAvatarUrl: config.image_url + '/static/img/' + 'no_profile_picture.png', //默认的图标
  26. imageUrl: config.image_url + '/static/img/',
  27. empowerInfo: null,// 授权信息
  28. dueFlag: false, // 到期标识
  29. dueButtonFlag: false, // 到期标识
  30. videoSrc: 'https://s.dev01.dkiboss.com:7000/file/operate_guide/all.mp4',
  31. cpEndDate: null,
  32. playFlag: false,
  33. companyName: null,
  34. staffName: 'null',
  35. orgName: null,
  36. waitMenuFlag: true, // 是否显示待办工作区
  37. statusHeight: 0, // 状态栏高度
  38. // 路由
  39. routeObjName: 'setting',
  40. companyService: app.globalData['companyService'],
  41. oauthService: app.globalData['oauthService'],
  42. appCount: 0,
  43. noticeCount: 0,
  44. beginnerGuideUrl: '/package-basic-data/pages/beginner-guide/beginner-guide', //新手引导
  45. /** 6个切换组件的值 */
  46. storeHelperValue: 'nearly7days',
  47. /** 6个数据源 */
  48. shopHelper: {},
  49. staffHelper: {},
  50. /** 3个加载loading(实际页面上是6个 因为左右切换无法同时显示两个所以3个就够了) */
  51. filterBlur1: '0',
  52. /** 2种切换组件的options */
  53. tagList: [{
  54. name: '今日',
  55. id: 'today',
  56. value: [util.formatDataTime(new Date()).substring(0, 10), util.formatDataTime(new Date()).substring(0, 10)]
  57. },
  58. {
  59. name: '近7天',
  60. id: 'nearly7days',
  61. value: util.timeForMat(7)
  62. },
  63. {
  64. name: '近30天',
  65. id: 'nearly30days',
  66. value: util.timeForMat(30)
  67. }
  68. ],
  69. active: 'store',
  70. showStoreFlag: true,
  71. menuBtnInfo: null,
  72. // 待办工作
  73. waitMenu: [{
  74. title: '待收款',
  75. code: 'cus-receipt',
  76. path: '/package-sales/pages/customer-collection/customer-collection',
  77. icon: 'btn-account-receivable.png',
  78. },
  79. {
  80. title: '待发货',
  81. code: 'order',
  82. path: '/package-sales/pages/order-billing/order-billing',
  83. icon: 'btn-shipped.png',
  84. },
  85. {
  86. title: '待入库',
  87. code: 'entry-handle',
  88. path: '/package-inventory/pages/warehousing-processing/warehousing-processing',
  89. icon: 'btn-stored.png',
  90. },
  91. {
  92. title: '待出库',
  93. code: 'out-handle',
  94. path: '/package-inventory/pages/outbound-processing/outbound-processing',
  95. icon: 'btn-shipped-out.png',
  96. },
  97. ],
  98. },
  99. /**
  100. * @desc : 改变选择框内容
  101. * @author : 周兴
  102. * @date : 2024/1/26 11:46
  103. */
  104. changeTabs(e) {
  105. let values = e.detail.value
  106. this.setData({
  107. storeHelperValue: e.detail.id
  108. })
  109. this.getHomeOrderRecCost(values[0], values[1])
  110. },
  111. /**
  112. * @desc : 切换头像
  113. * @author : 王英杰
  114. * @date : 2024/4/1
  115. */
  116. onChooseAvatar(e) {
  117. let that = this
  118. const {
  119. avatarUrl
  120. } = e.detail
  121. wx.navigateTo({
  122. url: '/package-base-select/pages/cropper/cropper',
  123. events: {
  124. // 回调后
  125. bindData: function (data) {
  126. that.setData({
  127. avatarUrl: data,
  128. })
  129. that.afterRead(data)
  130. }
  131. },
  132. success: function (res) {
  133. // 通过eventChannel向被打开页面传送数据
  134. res.eventChannel.emit('params', {
  135. src: avatarUrl,
  136. })
  137. }
  138. })
  139. },
  140. /**
  141. * @desc : 上传附件—(上传完成)
  142. * @author : 王英杰
  143. * @date : 2024/3/27 16:16
  144. */
  145. afterRead(path) {
  146. const _this = this;
  147. // 配置存放的文件夹 公司code - 表名 - 年月 -- 日
  148. let folder = app.globalData.company.cpCode + '/' + 't_wx_user' + '/' + new Date().toYearMonth2() + '/' + new Date().toDay()
  149. let url = config.upload_url;
  150. url = url.replace('mdm-server', 'mdm-server' + '-' + app.globalData.company.svcCode.replace('_', '-'))
  151. wx.uploadFile({
  152. url: url,
  153. filePath: path,
  154. name: 'file',
  155. formData: {
  156. 'folder': folder
  157. },
  158. header: {
  159. 'Authorization': 'Bearer ' + app.globalData.token
  160. },
  161. success(res) {
  162. let data = JSON.parse(res.data)
  163. if (data.code === 200) {
  164. let avatarUrlPath = config.image_url + data.data.path
  165. _this.uploadUserImage(avatarUrlPath)
  166. }
  167. },
  168. })
  169. },
  170. /**
  171. * @desc : 上传微信头像
  172. * @author : 王英杰
  173. * @date : 2024/4/1
  174. */
  175. uploadUserImage(avatarUrlPath) {
  176. let _this = this
  177. let param = {
  178. userId: app.globalData.user.userId,
  179. userImage: avatarUrlPath
  180. }
  181. api.request(Constants.SYS_OPENID_API + 'oauth/wx/update_user_image', 'POST', param).then(res => {
  182. if (res.data.code == Constants.SUCESS_CODE) { }
  183. })
  184. },
  185. /**
  186. * @desc : 切换公司
  187. * @author : 周兴
  188. * @date : 2024/4/1
  189. */
  190. changeCp() {
  191. wx.navigateTo({
  192. url: '/pages/company/company',
  193. })
  194. },
  195. /**
  196. * @desc : 跳转到功能页面
  197. * @author : 于继渤
  198. * @date : 2024/1/23 9:16
  199. */
  200. toApp(e) {
  201. let item = e.currentTarget.dataset.item
  202. let hasRightFlag = false;
  203. let menuUuid = null
  204. let menuList = app.globalData.menus
  205. if (menuList && menuList.length > 0) {
  206. // 查看该功能是否有权限
  207. let filters = menuList.filter(it => it.objectCode == item.code);
  208. if (filters && filters.length > 0) {
  209. menuUuid = filters[0].menuUuid
  210. hasRightFlag = true;
  211. }
  212. }
  213. if (!hasRightFlag) {
  214. util.showToast('没有该功能权限');
  215. return;
  216. }
  217. // 打开页面
  218. if (item.path) {
  219. wx.navigateTo({
  220. url: item.path,
  221. success: function (res) {
  222. res.eventChannel.emit('params', {
  223. formMode: 'index',
  224. menuUuid: menuUuid
  225. })
  226. }
  227. })
  228. }
  229. },
  230. /**
  231. * @desc : 查询销售金额收款金额库存成本
  232. * @author : 姜永辉
  233. * @date : 2024/4/9
  234. */
  235. getHomeOrderRecCost(dateBegin, dateEnd) {
  236. let params = {
  237. dateBegin: dateBegin,
  238. dateEnd: dateEnd,
  239. staffId: app.globalData.user.staffId,
  240. }
  241. let service = app.globalData['commonService']
  242. api.request(service.prefix + service.getHomeOrderRecCost, 'POST', params).then(res => {
  243. if (res.data.code == Constants.SUCESS_CODE) {
  244. let data = res.data.data
  245. let valueAmounts = []
  246. valueAmounts.push({
  247. title: '销售金额(元)',
  248. flgAmount: true,
  249. value: data.amtShouldSumAmount ? data.amtShouldSumAmount : 0.00
  250. })
  251. valueAmounts.push({
  252. title: '收款金额(元)',
  253. flgAmount: true,
  254. value: data.amtRecSumAmount ? data.amtRecSumAmount : 0.00
  255. })
  256. valueAmounts.push({
  257. title: '订单数(单)',
  258. flgAmount: false,
  259. value: data.orderQuantity ? data.orderQuantity : 0
  260. })
  261. this.setData({
  262. valueAmounts,
  263. })
  264. }
  265. });
  266. },
  267. /**
  268. * @desc : 跳转到微信聊天界面
  269. * @author : 周兴
  270. * @date : 2024/4/9
  271. */
  272. handleWxService(e) {
  273. // let url= Constants.WX_SERVICE
  274. // wx.navigateTo({
  275. // url: '/pages/product/product',
  276. // success: function (res) {
  277. // res.eventChannel.emit('url', Constants.WX_SERVICE);
  278. // }
  279. // })
  280. wx.openCustomerServiceChat({
  281. extInfo: {
  282. url: Constants.WX_SERVICE
  283. },
  284. corpId: Constants.WX_CPID,
  285. success(res) { }
  286. })
  287. },
  288. /**
  289. * @desc : 跳转到续费页面
  290. * @author : 周兴
  291. * @date : 2024/4/9
  292. */
  293. handleRecharge(e) {
  294. // 标准版 升级只能是 责任人才能升级
  295. if (app.globalData.company.gradeCode == Constants.gradeCode.STD
  296. && !app.globalData.user.flgInit) {
  297. util.showToast('无权续费,请联系责任人')
  298. return
  299. }
  300. let url = '/package-basic-data/pages/activity/renew/renew'
  301. wx.navigateTo({
  302. url: url,
  303. events: {
  304. // 保存成功后刷新页面
  305. refresh: function (data) {
  306. // 刷新一览界面
  307. wx.reLaunch({
  308. url: '/pages/welcome/welcome',
  309. })
  310. }
  311. },
  312. })
  313. },
  314. /**
  315. * @desc : 跳转至增加授权
  316. * @author : 刘尧
  317. * @date : 2024/7/4
  318. */
  319. toAddRole() {
  320. // 标准版 升级只能是 责任人才能升级
  321. if (app.globalData.company.gradeCode == Constants.gradeCode.STD
  322. && !app.globalData.user.flgInit) {
  323. util.showToast('无权增加授权,请联系责任人')
  324. return
  325. }
  326. const item = {
  327. detail: {
  328. customUrl: undefined,
  329. name: "buy"
  330. }
  331. }
  332. this.open(item)
  333. },
  334. /**
  335. * @desc : 升级
  336. * @author : 周兴
  337. * @date : 2024/4/9
  338. */
  339. handleUpgrade(e) {
  340. util.showToast('功能开发中,敬请期待!');
  341. return
  342. let url = '/package-basic-data/pages/activity/activity?upgrade=true'
  343. wx.navigateTo({
  344. url: url,
  345. events: {
  346. // 保存成功后刷新页面
  347. refresh: function (data) {
  348. // 刷新一览界面
  349. wx.reLaunch({
  350. url: '/pages/welcome/welcome',
  351. })
  352. }
  353. },
  354. })
  355. },
  356. /**
  357. * @desc : 查询待发货数据
  358. * @author : 周兴
  359. * @date : 2024/4/9
  360. */
  361. getOrder() {
  362. let params = {
  363. appCode: Constants.APP_CODE,
  364. orderStatusList: ['出库状态-待出库', '出库状态-出库中']
  365. }
  366. let service = app.globalData['orderService']
  367. api.request(service.prefix + service.countOrderByCond, 'POST', params).then(res => {
  368. if (res.data.code == Constants.SUCESS_CODE) {
  369. let waitMenu = this.data.waitMenu;
  370. let filters = waitMenu.filter(it => it.code == 'order')
  371. if (filters && filters.length > 0) {
  372. filters[0].count = res.data.data;
  373. this.setData({
  374. waitMenu: waitMenu
  375. })
  376. }
  377. }
  378. });
  379. },
  380. /**
  381. * @desc : 查询待收款数据
  382. * @author : 周兴
  383. * @date : 2024/4/9
  384. */
  385. getWaitReceival() {
  386. let params = {
  387. appCode: Constants.APP_CODE,
  388. amtResidueZeroFlg: true,
  389. accItemType: '账款类型-应收'
  390. }
  391. let service = app.globalData['accountService']
  392. api.request(service.prefix + service.getReceivableAccountItemCount, 'POST', params).then(res => {
  393. if (res.data.code == Constants.SUCESS_CODE) {
  394. let waitMenu = this.data.waitMenu;
  395. let filters = waitMenu.filter(it => it.code == 'cus-receipt')
  396. if (filters && filters.length > 0) {
  397. filters[0].count = res.data.data;
  398. this.setData({
  399. waitMenu: waitMenu
  400. })
  401. }
  402. }
  403. });
  404. },
  405. /**
  406. * @desc : 查询待入库数据
  407. * @author : 周兴
  408. * @date : 2024/4/9
  409. */
  410. getWaitInbound() {
  411. let params = {
  412. appCode: Constants.APP_CODE,
  413. }
  414. let service = app.globalData['inboundOtherService']
  415. api.request(service.prefix + service.selectWaitInboundCount, 'POST', params).then(res => {
  416. if (res.data.code == Constants.SUCESS_CODE) {
  417. let waitMenu = this.data.waitMenu;
  418. let filters = waitMenu.filter(it => it.code == 'entry-handle')
  419. if (filters && filters.length > 0) {
  420. filters[0].count = res.data.data;
  421. this.setData({
  422. waitMenu: waitMenu
  423. })
  424. }
  425. }
  426. });
  427. },
  428. /**
  429. * @desc : 查询待出库数据
  430. * @author : 周兴
  431. * @date : 2024/4/9
  432. */
  433. getWaitOutbound() {
  434. let params = {
  435. appCode: Constants.APP_CODE,
  436. }
  437. let service = app.globalData['outboundOtherService']
  438. api.request(service.prefix + service.selectWaitOutboundCount, 'POST', params).then(res => {
  439. if (res.data.code == Constants.SUCESS_CODE) {
  440. let waitMenu = this.data.waitMenu;
  441. let filters = waitMenu.filter(it => it.code == 'out-handle')
  442. if (filters && filters.length > 0) {
  443. filters[0].count = res.data.data;
  444. this.setData({
  445. waitMenu: waitMenu
  446. })
  447. }
  448. }
  449. });
  450. },
  451. /**
  452. * @desc : 修改密码跳转
  453. * @date : 2022/5/12 13:49
  454. * @author : 姜永辉
  455. */
  456. toEditPassword() {
  457. wx.navigateTo({
  458. url: './setting/setting',
  459. })
  460. },
  461. /**
  462. * @desc : 公告跳转
  463. * @date : 2022/5/12 13:49
  464. * @author : 姜永辉
  465. */
  466. toNotice() {
  467. wx.navigateTo({
  468. url: '/package-basic-data/pages/notice/notice',
  469. })
  470. },
  471. /**
  472. * @desc : 打开操作手册
  473. * @date : 2024/5/13 13:49
  474. * @author : 周兴
  475. */
  476. toOperateGuide(e) {
  477. let file = 'all.pdf'
  478. // 下载操作手册pdf
  479. let url = config.image_url + '/operate_guide/' + file;
  480. this.downloadFile(url, type);
  481. },
  482. /**
  483. * @desc : 打开操作手册视频
  484. * @date : 2024/5/13 13:49
  485. * @author : 周兴
  486. */
  487. toOperateGuideVideo(e) {
  488. let type = e.currentTarget.dataset.type
  489. if (type == 'close') {
  490. this.setData({
  491. playFlag: false
  492. })
  493. } else {
  494. this.setData({
  495. playFlag: true
  496. })
  497. }
  498. },
  499. /**
  500. * @desc : 设置跳转
  501. * @date : 2022/5/12 13:49
  502. * @author : 姜永辉
  503. */
  504. toSetting() {
  505. this.setData({
  506. loading: true
  507. })
  508. let _this = this
  509. wx.navigateTo({
  510. url: this.data.route.companySetting.url,
  511. events: {
  512. // 回调后,在这里给页面赋值
  513. refresh: function (e) {
  514. wx.reLaunch({
  515. url: '/pages/welcome/welcome',
  516. })
  517. }
  518. },
  519. success: function (res) {
  520. // 通过eventChannel向被打开页面传送数据 TODO 测试例子url是写死的,实际中,需要从route中读取
  521. res.eventChannel.emit('params', {
  522. id: app.globalData.company.cpId,
  523. formMode: Constants.formMode.edit
  524. })
  525. setTimeout(() => {
  526. _this.setData({
  527. loading: false
  528. })
  529. }, 2000)
  530. }
  531. })
  532. },
  533. /**
  534. * @desc : 设置跳转
  535. * @date : 2022/5/12 13:49
  536. * @author : 姜永辉
  537. */
  538. toShare() {
  539. let _this = this
  540. wx.navigateTo({
  541. url: '/package-basic-data/pages/share/share?settingFlg=true',
  542. events: {
  543. // 回调后,在这里给页面赋值
  544. refresh: function (e) {
  545. // 积分
  546. _this.getIntegral()
  547. }
  548. },
  549. success: function (res) {
  550. // 通过eventChannel向被打开页面传送数据 TODO 测试例子url是写死的,实际中,需要从route中读取
  551. res.eventChannel.emit('params', {})
  552. }
  553. })
  554. },
  555. /**
  556. * @desc : 跳转 开具发票
  557. * @date : 2022/5/12 13:49
  558. * @author : 王英杰
  559. */
  560. toInvoicing() {
  561. let _this = this
  562. wx.navigateTo({
  563. url: '/package-basic-data/pages/historical-purchase-history/historical-purchase-history',
  564. events: {
  565. // 回调后,在这里给页面赋值
  566. refresh: function (e) {
  567. }
  568. },
  569. success: function (res) {
  570. // 通过eventChannel向被打开页面传送数据 TODO 测试例子url是写死的,实际中,需要从route中读取
  571. res.eventChannel.emit('params', {})
  572. }
  573. })
  574. },
  575. /**
  576. * @desc : 新手引导
  577. * @date : 2022/5/12 13:49
  578. * @author : 于继渤
  579. */
  580. toBeginnerGuide() {
  581. this.setData({
  582. loading: true
  583. })
  584. let _this = this
  585. wx.navigateTo({
  586. url: this.data.beginnerGuideUrl,
  587. events: {
  588. // 回调后,在这里给页面赋值
  589. bandData: function (e) { }
  590. },
  591. success: function (res) {
  592. // 通过eventChannel向被打开页面传送数据 TODO 测试例子url是写死的,实际中,需要从route中读取
  593. res.eventChannel.emit('params', {})
  594. setTimeout(() => {
  595. _this.setData({
  596. loading: false
  597. })
  598. }, 1000)
  599. }
  600. })
  601. },
  602. /**
  603. * @desc : 退出登录
  604. * @date : 2022/5/12 13:49
  605. * @author : 姜永辉
  606. */
  607. logout(e) {
  608. let _this = this
  609. //提示
  610. Dialog.confirm({
  611. message: '您确定要退出系统?',
  612. }).then(() => {
  613. let params = {
  614. openid: app.globalData.openid,
  615. userId: app.globalData.user.userId,
  616. }
  617. return this.excute(_this.data.oauthService, _this.data.oauthService.logout, params).then(res => {
  618. if (res.data.code === Constants.SUCESS_CODE) {
  619. // 不能清除整个globalData,切换公司会因为找不到globalData数据而报错
  620. // app.globalData = {}
  621. // 清除掉用户信息
  622. delete app.globalData['user']
  623. // 清除公司信息
  624. delete app.globalData['company']
  625. // 调转主页
  626. wx.reLaunch({
  627. url: '../../pages/welcome/welcome',
  628. })
  629. }
  630. });
  631. }).catch(() => {
  632. });
  633. },
  634. /**
  635. * @desc : 重新登录
  636. * @date : 2022/5/12 13:49
  637. * @author : 王英杰
  638. */
  639. LogInAgain() {
  640. wx.reLaunch({
  641. url: '/pages/welcome/welcome',
  642. })
  643. },
  644. /**
  645. * @desc : 查询
  646. * @date : 2024/2/1 15:49
  647. * @author : 王英杰
  648. */
  649. getData(params) {
  650. return this.excute(this.data.oauthService, this.data.oauthService.getUser + '/' + app.globalData.user.userId, {}).then(res => {
  651. if (res.data.code == 200) {
  652. let avatarUrl = res.data.data.userImage || this.data.defaultAvatarUrl
  653. this.setData({
  654. avatarUrl: avatarUrl
  655. })
  656. }
  657. });
  658. },
  659. /**
  660. * @desc : 获取用户信息
  661. * @date : 2022/5/12 13:49
  662. * @author : 姜永辉
  663. */
  664. getUserProfile() {
  665. wx.getUserProfile({
  666. desc: '用于完善用户资料', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
  667. success: (res) => {
  668. let user = res.userInfo
  669. wx.setStorageSync('user', user) //保存用户信息到本地缓存
  670. this.setData({
  671. isShowUserName: true,
  672. userInfo: user,
  673. })
  674. },
  675. fail: res => {
  676. }
  677. })
  678. },
  679. /**
  680. * @desc : 小程序测试例子-测试续费的回调
  681. * @author : admin
  682. * @date : 2023年8月21日
  683. */
  684. toTestExample(e) {
  685. // wx.navigateTo({
  686. // url: '/package-basic-data/pages/test/test',
  687. // })
  688. let wechatPayService = app.globalData['wechatPayService']
  689. api.request(wechatPayService.prefix + 'renew_reminder', 'POST', {}).then(res => {
  690. console.log("renew_reminder", res);
  691. });
  692. },
  693. toOtherPage(e) {
  694. let type = e.currentTarget.dataset.type
  695. let dateValue = e.currentTarget.dataset.datevalue
  696. let jumpType = e.currentTarget.dataset.jumptype
  697. let url = "";
  698. let param = {};
  699. let dateObj = {
  700. today: {
  701. text: '本日',
  702. value: 1
  703. },
  704. nearly30days: {
  705. text: '近30天',
  706. value: 5
  707. },
  708. nearly7days: {
  709. text: '近7天',
  710. value: 6
  711. }
  712. }
  713. let staffObj = {}
  714. if (jumpType === 2) {
  715. staffObj = {
  716. staffId: app.globalData.user.userId,
  717. staffNames: app.globalData.user.userName
  718. }
  719. }
  720. let hasrightflg = true
  721. switch (type) {
  722. case 1:
  723. hasrightflg = this.data.orderflg
  724. url = '/package4/pages/order-billing/order-billing'
  725. param = {
  726. active: 1,
  727. date: dateObj[dateValue],
  728. receiveStatusParam: [],
  729. receiveStatusParamIds: []
  730. }
  731. break;
  732. case 2:
  733. hasrightflg = this.data.customerflg
  734. url = '/package3/pages/customer/customer'
  735. param = {
  736. active: 0,
  737. date: dateObj[dateValue],
  738. keyTypeList: [],
  739. keyTypeNameList: []
  740. }
  741. break;
  742. case 3:
  743. hasrightflg = this.data.customerflg
  744. url = '/package3/pages/customer/customer'
  745. param = {
  746. active: 3,
  747. date: dateObj[dateValue],
  748. keyTypeList: [0, 1],
  749. keyTypeNameList: ["客意品类-定制", "客意品类-智能"]
  750. }
  751. break;
  752. case 4:
  753. hasrightflg = this.data.orderflg
  754. url = '/package4/pages/order-billing/order-billing'
  755. param = {
  756. active: 2,
  757. date: {
  758. text: '自定义',
  759. value: -2
  760. },
  761. receiveStatusParam: ['收款状态-未收', '收款状态-部分'],
  762. receiveStatusParamIds: [0, 1],
  763. type: 2
  764. }
  765. break;
  766. case 5:
  767. hasrightflg = this.data.receivecustomersflg
  768. url = '/package3/pages/receive-customers/receive-customers'
  769. param = {
  770. active: 1,
  771. date: {
  772. text: '自定义',
  773. value: -2
  774. },
  775. followStatusNameList: [],
  776. followStatusList: [],
  777. type: 2
  778. }
  779. break;
  780. case 6:
  781. hasrightflg = this.data.orderflg
  782. url = '/package4/pages/order-billing/order-billing'
  783. param = {
  784. active: 3,
  785. date: dateObj[dateValue],
  786. receiveStatusParam: [],
  787. receiveStatusParamIds: []
  788. }
  789. break;
  790. case 7:
  791. hasrightflg = this.data.receivecustomersflg
  792. url = '/package3/pages/receive-customers/receive-customers'
  793. param = {
  794. active: 0,
  795. date: dateObj[dateValue],
  796. followStatusNameList: ['跟进状态-接待', '跟进状态-报备'],
  797. followStatusList: [0, 1]
  798. }
  799. break;
  800. case 8:
  801. hasrightflg = this.data.receivecustomersflg
  802. url = '/package3/pages/receive-customers/receive-customers'
  803. param = {
  804. active: 0,
  805. date: dateObj[dateValue],
  806. followStatusNameList: ['跟进状态-报备'],
  807. followStatusList: [0]
  808. }
  809. break;
  810. case 9:
  811. hasrightflg = this.data.receivecustomersflg
  812. url = '/package3/pages/receive-customers/receive-customers'
  813. param = {
  814. active: 0,
  815. date: dateObj[dateValue],
  816. followStatusNameList: ['跟进状态-接待'],
  817. followStatusList: [1]
  818. }
  819. break;
  820. case 10:
  821. hasrightflg = this.data.customerflg
  822. url = '/package3/pages/customer/customer'
  823. param = {
  824. active: 1,
  825. date: dateObj.nearly30days
  826. }
  827. break;
  828. }
  829. if (hasrightflg) {
  830. wx.navigateTo({
  831. url: url + '?frommine=' + JSON.stringify(Object.assign(param, staffObj))
  832. })
  833. } else {
  834. wx.showModal({
  835. title: '提示',
  836. content: '没有该功能权限',
  837. showCancel: false
  838. })
  839. }
  840. },
  841. /**
  842. *
  843. * @param {获取待审条数} options
  844. */
  845. getAppCount() {
  846. let params = {
  847. // cpId: app.globalData.user.cpId,
  848. userId: app.globalData.user.userId,
  849. }
  850. api.request(Constants.BPM_WAITING_FOR_APPRAVAL + 'list_count', 'POST', params).then(res => {
  851. if (res.data.code === 200) {
  852. this.setData({
  853. appCount: res.data.data
  854. })
  855. }
  856. })
  857. },
  858. /**
  859. *
  860. * @param {获取未读公告条数} options
  861. * @param {获取未读公告条数} options
  862. * @param {获取未读公告条数} options
  863. */
  864. getNoticeCount() {
  865. let param = {
  866. cpId: app.globalData.user.cpId,
  867. orgId: app.globalData.user.orgId,
  868. userId: app.globalData.user.userId,
  869. }
  870. //操作后台
  871. api.request(Constants.NOTICE_API + 'search_select_count', 'POST', param).then(res => {
  872. if (res.data.code == 200) {
  873. this.setData({
  874. noticeCount: res.data.data
  875. })
  876. }
  877. })
  878. },
  879. /**
  880. * 生命周期函数--监听页面加载
  881. */
  882. onLoad: function (options) {
  883. if (app.globalData.company && app.globalData.company.wxMaxNum) {
  884. let empowerInfo = '授权数量:手机授权' + app.globalData.company.wxMaxNum + '个'
  885. empowerInfo += '(含赠送手机授权1个)';
  886. this.setData({
  887. empowerInfo: empowerInfo
  888. })
  889. }
  890. let res = wx.getSystemInfoSync();
  891. let statusHeight = res.statusBarHeight
  892. this.setData({
  893. statusHeight: statusHeight * 2 + 20
  894. })
  895. if (app.globalData && app.globalData.company) {
  896. let cpEndDate = app.globalData.company.endDate
  897. this.setData({
  898. cpEndDate: cpEndDate, // 企业到期日期
  899. contains2099: cpEndDate.includes("2099") //如果包含2099 就隐藏到期日期
  900. })
  901. // 判断是否即将到期
  902. let endD = new Date(cpEndDate);
  903. // 服务器的日期为准
  904. let nowD = new Date(app.globalData.nowDate).addDays(Constants.CP_ALERT_TIME);
  905. if (endD < nowD) {
  906. this.setData({
  907. dueFlag: true,
  908. dueButtonFlag: true
  909. })
  910. }
  911. }
  912. // // 判断当前用户是否到期 标准版
  913. if (app.globalData.company.gradeCode == Constants.gradeCode.STD &&
  914. app.globalData.company.userEndDate) {
  915. let endD = new Date(app.globalData.company.userEndDate);
  916. // 服务器的日期为准
  917. let nowD = new Date(app.globalData.nowDate).addDays(Constants.CP_ALERT_TIME);
  918. if (endD < nowD) {
  919. let cpEndDate = app.globalData.company.userEndDate
  920. this.setData({
  921. cpEndDate: cpEndDate, // 企业到期日期
  922. contains2099: cpEndDate.includes("2099") //如果包含2099 就隐藏到期日期
  923. })
  924. if (!app.globalData.user.flgInit) {
  925. this.setData({
  926. dueFlag: true
  927. })
  928. } else {
  929. this.setData({
  930. dueButtonFlag: true
  931. })
  932. }
  933. }
  934. }
  935. // 已经有续费的功能了。不能重复
  936. let reNew = app.globalData.company.reNew
  937. if (reNew != null) {
  938. this.setData({
  939. dueButtonFlag: false
  940. })
  941. }
  942. let waitMenu = this.data.waitMenu;
  943. let waitMenuFlag = false;
  944. waitMenu.forEach(it => {
  945. let rightFlag = common.hasPageRight(it.code)
  946. if (rightFlag) {
  947. it.show = true;
  948. waitMenuFlag = true;
  949. // 待收款
  950. if (it.code == Constants.menuCode.cusReceipt) {
  951. // 获取条数
  952. this.getWaitReceival();
  953. } else if (it.code == Constants.menuCode.order) {
  954. // 获取条数
  955. this.getOrder();
  956. } else if (it.code == Constants.menuCode.entryHandle) {
  957. // 获取条数
  958. this.getWaitInbound();
  959. } else if (it.code == Constants.menuCode.outHandle) {
  960. // 获取条数
  961. this.getWaitOutbound();
  962. }
  963. }
  964. })
  965. // 标准版不显示待办
  966. if (this.data.gradeCode == Constants.gradeCode.STD) {
  967. waitMenuFlag = false
  968. }
  969. this.setData({
  970. waitMenuFlag: waitMenuFlag,
  971. companyName: app.globalData.company.cpName,
  972. staffName: app.globalData.user.staffName,
  973. orgName: app.globalData.user.orgName,
  974. waitMenu: waitMenu,
  975. dateBegin: '',
  976. dateEnd: '',
  977. version: wx.getAccountInfoSync().miniProgram.version,
  978. })
  979. /**
  980. * @desc : 获取用户信息
  981. * @date : 2022/5/12 13:49
  982. * @author : 姜永辉
  983. */
  984. if (app.globalData.user) {
  985. this.setData({
  986. userInfo: app.globalData.user,
  987. })
  988. }
  989. // this.getAppCount()
  990. /** 获取胶囊信息 */
  991. this.setData({
  992. menuBtnInfo: wx.getMenuButtonBoundingClientRect()
  993. })
  994. },
  995. onShow() {
  996. if (this.data.mineFlag) {
  997. // this.getAppCount()
  998. /** 获取胶囊信息 */
  999. this.setData({
  1000. menuBtnInfo: wx.getMenuButtonBoundingClientRect()
  1001. })
  1002. }
  1003. // 查询门店助手
  1004. let dates = util.timeForMat(7)
  1005. switch (this.data.storeHelperValue) {
  1006. case 'today':
  1007. dates = util.timeForMat(0);
  1008. break
  1009. case 'nearly7days':
  1010. dates = util.timeForMat(7);
  1011. break
  1012. case 'nearly30days':
  1013. dates = util.timeForMat(30);
  1014. break
  1015. }
  1016. this.getHomeOrderRecCost(dates[0], dates[1])
  1017. // 积分
  1018. this.getIntegral()
  1019. },
  1020. /**
  1021. * 页面相关事件处理函数--监听用户下拉动作
  1022. */
  1023. onPullDownRefresh: function () {
  1024. let that = this
  1025. //调用刷新时将执行的方法
  1026. that.setData({
  1027. loadingShow: true,
  1028. })
  1029. // this.getAppCount()
  1030. /** 获取胶囊信息 */
  1031. this.setData({
  1032. menuBtnInfo: wx.getMenuButtonBoundingClientRect()
  1033. })
  1034. // this.getReportData()
  1035. // this.getNoticeCount()
  1036. //隐藏导航条加载动画
  1037. wx.hideNavigationBarLoading();
  1038. setTimeout(function () {
  1039. that.setData({
  1040. loadingShow: false,
  1041. })
  1042. //停止下拉刷新
  1043. wx.stopPullDownRefresh();
  1044. }, 800)
  1045. },
  1046. /**
  1047. * 检测是否有新版本-手动更新
  1048. */
  1049. checkHasManualUpdate() {
  1050. app.checkHasManualUpdate()
  1051. },
  1052. /**
  1053. *  当前版本号
  1054. */
  1055. getAccountInfoSync() {
  1056. const accountInfo = wx.getAccountInfoSync();
  1057. util.showToast('当前版本号:' + accountInfo.miniProgram.version);
  1058. },
  1059. /**
  1060. * @desc : 公司积分
  1061. * @author : 刘尧
  1062. * @date : 2024/7/25 14:32
  1063. */
  1064. getIntegral() {
  1065. let params = {}
  1066. let service = app.globalData['integralService']
  1067. this.excute(service, app.globalData.company.cpId, params).then(res => {
  1068. if (res.data.code == Constants.SUCESS_CODE) {
  1069. if (res.data && res.data.data) {
  1070. this.setData({
  1071. integral: res.data.data.integral,
  1072. })
  1073. }
  1074. }
  1075. });
  1076. },
  1077. })