index.vue 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <template>
  2. <view></view>
  3. </template>
  4. <script>
  5. import tools from '../../common/tools';
  6. import cardfunc from '../../common/cardfunc';
  7. import {
  8. token,
  9. ossUrl
  10. } from '../../common/api';
  11. export default {
  12. data() {
  13. return {
  14. queryObj: {},
  15. queryString: "",
  16. token: "",
  17. ecId: 0, // 卡片id
  18. }
  19. },
  20. onLoad(query) { // 类型非必填,可自动推导
  21. console.log("onLoad");
  22. console.log(query);
  23. this.queryObj = query;
  24. this.queryString = tools.objectToQueryString(this.queryObj);
  25. // console.log(this.queryString);
  26. this.token = query["token"] ?? token;
  27. this.ecId = query["id"] ?? 0;
  28. cardfunc.init(this, this.token, this.ecId);
  29. cardfunc.userConfigQuery(this.userConfigQueryCallback);
  30. },
  31. methods: {
  32. userConfigQueryCallback(userconfig) {
  33. // console.log("[userConfigQueryCallback] userconfig:", userconfig);
  34. userconfig = cardfunc.parseCardConfig(userconfig);
  35. const tplTypeId = userconfig.tplInfo.tplTypeId; // 模板类型ID
  36. const ssctId = userconfig.tplInfo.ssctId; // 模板ID
  37. // const styleId = userconfig.tplInfo.styleId; // 模板样式ID
  38. let tplType = ""; // 模板类型
  39. let tpl = ""; // 模板
  40. if (tplTypeId == 1) {
  41. tplType = "tpl";
  42. if (ssctId > 0) {
  43. tpl = "style" + ssctId;
  44. }
  45. }
  46. if (tplType != "" && tpl != "") {
  47. const url = `/pages/${tplType}/${tpl}/index?${this.queryString}`;
  48. uni.reLaunch({
  49. url: url
  50. });
  51. } else {
  52. uni.showToast({
  53. title: `模板参数错误`,
  54. icon: 'none',
  55. duration: 3000
  56. });
  57. }
  58. },
  59. }
  60. }
  61. </script>