app.js 6.9 KB

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