analyze.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import {
  2. ApiModel
  3. } from "../../utils/api";
  4. const _Http = new ApiModel();
  5. function showModel(data, content) {
  6. wx.setStorageSync('qrCodeMsg', data);
  7. wx.showModal({
  8. title: '提示',
  9. content: content,
  10. showCancel: false,
  11. success: (res => {
  12. if (res.confirm) wx.navigateTo({
  13. url: '/pages/login/index',
  14. })
  15. })
  16. });
  17. }
  18. //解析二维码链接
  19. function setDataUrl(url) {
  20. let q = url;
  21. console.log("q", q);
  22. const data = {
  23. type: q.slice(q.indexOf("type=") + 5, q.indexOf('&')),
  24. id: q.slice(q.lastIndexOf('=') + 1),
  25. name: q.slice(q.lastIndexOf('fbrand=') + 7, q.lastIndexOf('&'))
  26. }
  27. if (!wx.getStorageSync('userData').token) {
  28. return showModel(data, '当前未登录,请登录后进入')
  29. } else {
  30. _Http.basic({
  31. "accesstoken": wx.getStorageSync('userData').token,
  32. "classname": "customer.usercenter.usermsg.usermsg",
  33. "method": "query_usermsg",
  34. "content": {}
  35. }).then(res => {
  36. if (res.msg != '成功') showModel(data, "登陆状态已过期,请重新登陆!");
  37. return data;
  38. })
  39. }
  40. }
  41. module.exports = {
  42. setDataUrl
  43. }