app.js 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. import {
  2. ApiModel
  3. } from './utils/Api';
  4. import {
  5. Language
  6. } from './utils/language';
  7. App({
  8. onLaunch(options) {
  9. //小程序跳转进入
  10. if (options.query.userMsg) {
  11. let userMsg = JSON.parse(options.query.userMsg)
  12. wx.removeStorageSync('userMsg');
  13. wx.removeStorageSync('auth');
  14. wx.removeStorageSync('userauth');
  15. wx.removeStorageSync('userrole');
  16. wx.removeStorageSync('templetList');
  17. wx.setStorageSync('userMsg', userMsg);
  18. wx.setStorageSync('userrole', userMsg.usertype == 1 ? '业务员' : '经销商');
  19. wx.setStorageSync('auth', JSON.parse(options.query.auth));
  20. wx.setStorageSync('siteP', JSON.parse(options.query.site));
  21. wx.setStorageSync('templetList', JSON.parse(options.query.templetList));
  22. console.log("options.query.templetList", options.query.templetList)
  23. wx.removeStorageSync('languagecode');
  24. wx.setStorageSync('languagecode', options.query.languagecode);
  25. //获取用户权限
  26. this.globalData.http.basic({
  27. "classname": "sysmanage.develop.userauth.userauth",
  28. "method": "query_userauth",
  29. content: {
  30. nocache: true
  31. }
  32. }).then(res => {
  33. console.log("跳转进入查询权限", res)
  34. if (res.code != '1') return wx.showToast({
  35. title: '权限查询失败,请稍后再试',
  36. icon: "none"
  37. })
  38. wx.setStorageSync('userauth', res.data);
  39. });
  40. _Http.basic({
  41. "classname": "sysmanage.develop.optiontype.optiontype",
  42. "method": "optiontypeselect",
  43. "content": {
  44. "typename": "statuscolors"
  45. }
  46. }).then(res => {
  47. if (res.code != '1') return;
  48. res.data.forEach(v => {
  49. this.globalData.sColors[v.value] = v.remarks
  50. })
  51. });
  52. }
  53. if (!wx.getStorageSync('languagecode')) wx.setStorageSync('languagecode', 'ZH');
  54. this.globalData.Language.getLanguages(wx.getStorageSync('languagecode'));
  55. },
  56. initSocket() {
  57. let that = this;
  58. this.globalData.SocketTask = wx.connectSocket({
  59. url: (this.globalData.http.baseUrl + '/yos/webSocket/').replace("https", "wss").replace("http", "ws") + wx.getStorageSync('userMsg').token,
  60. complete: (res) => {
  61. console.log(res)
  62. }
  63. })
  64. this.globalData.SocketTask.onOpen(function (res) {
  65. that.globalData.socketEstablish = true;
  66. })
  67. this.globalData.SocketTask.onMessage(function (res) {
  68. that.globalData.socket.callback(res)
  69. })
  70. this.globalData.SocketTask.onError(function (res) {
  71. that.globalData.socketEstablish = false;
  72. })
  73. this.globalData.SocketTask.onClose(function (res) {
  74. that.globalData.socketEstablish = false;
  75. })
  76. },
  77. globalData: {
  78. sColors: {
  79. "ACTIVE": "#67C23A",
  80. "上架": "#67C23A",
  81. "下架": "#F56C6C",
  82. "交期待确认": "#F56C6C",
  83. "交期确认": "#3874f6",
  84. "代开始": "#3874f6",
  85. "借出": "#e6a23c",
  86. "停用": "#999999",
  87. "关闭": "#999999",
  88. "历史售后": "#999999",
  89. "发布": "#67C23A",
  90. "发放": "#67C23A",
  91. "合作中": "#67C23A",
  92. "否": "#999999",
  93. "启用": "#67C23A",
  94. "售中": "#e6a23c",
  95. "售出": "#67C23A",
  96. "售前": "#3874f6",
  97. "售后": "#67C23A",
  98. "在库": "#3874f6",
  99. "在职": "#67C23A",
  100. "复核": "#F56C6C",
  101. "多次成交": "#67C23A",
  102. "审核": "#e6a23c",
  103. "已下达": "#67C23A",
  104. "已使用": "#67C23A",
  105. "已入账(人工)": "#3874f6",
  106. "已入账(系统)": "#67C23A",
  107. "已入账(非贷款)": "#e6a23c",
  108. "已入账(人工)": "#3874f6",
  109. "已入账(系统)": "#67C23A",
  110. "已入账(非贷款)": "#e6a23c",
  111. "已分配": "#333333",
  112. "已备货": "#3874f6",
  113. "已失败": "#F56C6C",
  114. "已完成": "#e6a23c",
  115. "已审核": "#67C23A",
  116. "已开票": "#67C23A",
  117. "已成交": "#67C23A",
  118. "已截止": "#999999",
  119. "已截至": "#999999",
  120. "已报备": "#67C23A",
  121. "已提交": "#67C23A",
  122. "已无效": "#999999",
  123. "已核销": "#67C23A",
  124. "已确认(非货款)": "#e6a23c",
  125. "已终止": "#999999",
  126. "已结案": "#999999",
  127. "已读": "#999999",
  128. "已转化": "#e6a23c",
  129. "已过期": "#999999",
  130. "开启": "#67C23A",
  131. "待分配": "#3874f6",
  132. "待处理": "#F56C6C",
  133. "待审核": "#3874f6",
  134. "待执行": "#3874f6",
  135. "待指派": "#3874f6",
  136. "待接单": "#999999",
  137. "待评审": "#3874f6",
  138. "待跟进": "#3874f6",
  139. "意向": "#3874f6",
  140. "报备中": "#e6a23c",
  141. "报废": "#999999",
  142. "提交": "#67C23A",
  143. "收货": "#67C23A",
  144. "新建": "#3874f6",
  145. "无需评审": "#67C23A",
  146. "是": "#F56C6C",
  147. "暂停": "#F56C6C",
  148. "暂缓": "#e6a23c",
  149. "未使用": "#999999",
  150. "未入账": "#F56C6C",
  151. "未备货": "#F56C6C",
  152. "未开票": "#F56C6C",
  153. "未成交": "#3874f6",
  154. "未报备": "#3874f6",
  155. "未核销": "#F56C6C",
  156. "正式": "#67C23A",
  157. "潜在": "#3874f6",
  158. "禁用": "#999999",
  159. "离职": "#999999",
  160. "结束": "#999999",
  161. "置顶": "#F56C6C",
  162. "评审中": "#e6a23c",
  163. "评审拒绝": "#F56C6C",
  164. "评审通过-已有成品": "rgba(103,194,58,0.5)",
  165. "评审通过-暂无成品": "#67C23A",
  166. "跟进中": "#67C23A",
  167. "进行中": "#67C23A",
  168. "部分备货": "#67C23A",
  169. "部分开票": "#e6a23c",
  170. "部分核销": "#e6a23c",
  171. "预提交": "#e6a23c"
  172. },
  173. http: new ApiModel, //挂载接口文件
  174. Language: new Language(), //语言包
  175. queryPer: require("./utils/queryPermissions"), //权限查询
  176. handleSelect: null, //处理选择结果 函数
  177. socketEstablish: false, //是否已经建立socket
  178. SocketTask: '', // Socket方法
  179. socketCallback: null, // Socket回调
  180. }
  181. })