app.js 6.9 KB

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