app.js 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  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')) {
  57. setTimeout(() => {
  58. this.globalData.Language.getLanguages(wx.getStorageSync('languagecode'))
  59. }, 500)
  60. } else {
  61. wx.getSystemInfoAsync({
  62. success: res => {
  63. let languagecode = 'ZH';
  64. try {
  65. languagecode = res.language.split("_")[0].toUpperCase()
  66. } catch (error) {}
  67. wx.setStorageSync('languagecode', languagecode);
  68. this.globalData.Language.getLanguages(languagecode);
  69. }
  70. })
  71. }
  72. },
  73. initSocket() {
  74. let that = this;
  75. this.globalData.SocketTask = wx.connectSocket({
  76. url: (this.globalData.http.baseUrl + '/yos/webSocket/').replace("https", "wss").replace("http", "ws") + wx.getStorageSync('userMsg').token,
  77. complete: (res) => {
  78. console.log(res)
  79. }
  80. })
  81. this.globalData.SocketTask.onOpen(function (res) {
  82. that.globalData.socketEstablish = true;
  83. })
  84. this.globalData.SocketTask.onMessage(function (res) {
  85. that.globalData.socket.callback(res)
  86. })
  87. this.globalData.SocketTask.onError(function (res) {
  88. that.globalData.socketEstablish = false;
  89. })
  90. this.globalData.SocketTask.onClose(function (res) {
  91. that.globalData.socketEstablish = false;
  92. })
  93. },
  94. globalData: {
  95. sColors: {
  96. "ACTIVE": "#67C23A",
  97. "上架": "#67C23A",
  98. "下架": "#F56C6C",
  99. "交期待确认": "#F56C6C",
  100. "交期确认": "#3874f6",
  101. "代开始": "#3874f6",
  102. "借出": "#e6a23c",
  103. "停用": "#999999",
  104. "关闭": "#999999",
  105. "历史售后": "#999999",
  106. "发布": "#67C23A",
  107. "发放": "#67C23A",
  108. "合作中": "#67C23A",
  109. "否": "#999999",
  110. "启用": "#67C23A",
  111. "售中": "#e6a23c",
  112. "售出": "#67C23A",
  113. "售前": "#3874f6",
  114. "售后": "#67C23A",
  115. "在库": "#3874f6",
  116. "在职": "#67C23A",
  117. "复核": "#F56C6C",
  118. "多次成交": "#67C23A",
  119. "审核": "#e6a23c",
  120. "已下达": "#67C23A",
  121. "已使用": "#67C23A",
  122. "已入账(人工)": "#3874f6",
  123. "已入账(系统)": "#67C23A",
  124. "已入账(非贷款)": "#e6a23c",
  125. "已入账(人工)": "#3874f6",
  126. "已入账(系统)": "#67C23A",
  127. "已入账(非贷款)": "#e6a23c",
  128. "已分配": "#333333",
  129. "已备货": "#3874f6",
  130. "已失败": "#F56C6C",
  131. "已完成": "#e6a23c",
  132. "已审核": "#67C23A",
  133. "已开票": "#67C23A",
  134. "已成交": "#67C23A",
  135. "已截止": "#999999",
  136. "已截至": "#999999",
  137. "已报备": "#67C23A",
  138. "已提交": "#67C23A",
  139. "已无效": "#999999",
  140. "已核销": "#67C23A",
  141. "已确认(非货款)": "#e6a23c",
  142. "已终止": "#999999",
  143. "已结案": "#999999",
  144. "已读": "#999999",
  145. "已转化": "#e6a23c",
  146. "已过期": "#999999",
  147. "开启": "#67C23A",
  148. "待分配": "#3874f6",
  149. "待处理": "#F56C6C",
  150. "待审核": "#3874f6",
  151. "待执行": "#3874f6",
  152. "待指派": "#3874f6",
  153. "待接单": "#999999",
  154. "待评审": "#3874f6",
  155. "待跟进": "#3874f6",
  156. "意向": "#3874f6",
  157. "报备中": "#e6a23c",
  158. "报废": "#999999",
  159. "提交": "#67C23A",
  160. "收货": "#67C23A",
  161. "新建": "#3874f6",
  162. "无需评审": "#67C23A",
  163. "是": "#F56C6C",
  164. "暂停": "#F56C6C",
  165. "暂缓": "#e6a23c",
  166. "未使用": "#999999",
  167. "未入账": "#F56C6C",
  168. "未备货": "#F56C6C",
  169. "未开票": "#F56C6C",
  170. "未成交": "#3874f6",
  171. "未报备": "#3874f6",
  172. "未核销": "#F56C6C",
  173. "正式": "#67C23A",
  174. "潜在": "#3874f6",
  175. "禁用": "#999999",
  176. "离职": "#999999",
  177. "结束": "#999999",
  178. "置顶": "#F56C6C",
  179. "评审中": "#e6a23c",
  180. "评审拒绝": "#F56C6C",
  181. "评审通过-已有成品": "rgba(103,194,58,0.5)",
  182. "评审通过-暂无成品": "#67C23A",
  183. "跟进中": "#67C23A",
  184. "进行中": "#67C23A",
  185. "部分备货": "#67C23A",
  186. "部分开票": "#e6a23c",
  187. "部分核销": "#e6a23c",
  188. "预提交": "#e6a23c"
  189. },
  190. http: new ApiModel, //挂载接口文件
  191. Language: new Language(), //语言包
  192. queryPer: require("./utils/queryPermissions"), //权限查询
  193. handleSelect: null, //处理选择结果 函数
  194. socketEstablish: false, //是否已经建立socket
  195. SocketTask: '', // Socket方法
  196. socketCallback: null, // Socket回调
  197. }
  198. })